9312 lines
378 KiB
JavaScript
9312 lines
378 KiB
JavaScript
/*
|
||||
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|||
|
|
if you want to view the source, please visit the github repository of this plugin
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
var __create = Object.create;
|
|||
|
|
var __defProp = Object.defineProperty;
|
|||
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|||
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|||
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|||
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|||
|
|
var __commonJS = (cb, mod) => function __require() {
|
|||
|
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|||
|
|
};
|
|||
|
|
var __export = (target, all) => {
|
|||
|
|
for (var name in all)
|
|||
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|||
|
|
};
|
|||
|
|
var __copyProps = (to, from, except, desc) => {
|
|||
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|||
|
|
for (let key of __getOwnPropNames(from))
|
|||
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|||
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|||
|
|
}
|
|||
|
|
return to;
|
|||
|
|
};
|
|||
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|||
|
|
// If the importer is in node compatibility mode or this is not an ESM
|
|||
|
|
// file that has been converted to a CommonJS file using a Babel-
|
|||
|
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|||
|
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|||
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|||
|
|
mod
|
|||
|
|
));
|
|||
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|||
|
|
|
|||
|
|
// node_modules/xml2js/lib/defaults.js
|
|||
|
|
var require_defaults = __commonJS({
|
|||
|
|
"node_modules/xml2js/lib/defaults.js"(exports) {
|
|||
|
|
(function() {
|
|||
|
|
exports.defaults = {
|
|||
|
|
"0.1": {
|
|||
|
|
explicitCharkey: false,
|
|||
|
|
trim: true,
|
|||
|
|
normalize: true,
|
|||
|
|
normalizeTags: false,
|
|||
|
|
attrkey: "@",
|
|||
|
|
charkey: "#",
|
|||
|
|
explicitArray: false,
|
|||
|
|
ignoreAttrs: false,
|
|||
|
|
mergeAttrs: false,
|
|||
|
|
explicitRoot: false,
|
|||
|
|
validator: null,
|
|||
|
|
xmlns: false,
|
|||
|
|
explicitChildren: false,
|
|||
|
|
childkey: "@@",
|
|||
|
|
charsAsChildren: false,
|
|||
|
|
includeWhiteChars: false,
|
|||
|
|
async: false,
|
|||
|
|
strict: true,
|
|||
|
|
attrNameProcessors: null,
|
|||
|
|
attrValueProcessors: null,
|
|||
|
|
tagNameProcessors: null,
|
|||
|
|
valueProcessors: null,
|
|||
|
|
emptyTag: ""
|
|||
|
|
},
|
|||
|
|
"0.2": {
|
|||
|
|
explicitCharkey: false,
|
|||
|
|
trim: false,
|
|||
|
|
normalize: false,
|
|||
|
|
normalizeTags: false,
|
|||
|
|
attrkey: "$",
|
|||
|
|
charkey: "_",
|
|||
|
|
explicitArray: true,
|
|||
|
|
ignoreAttrs: false,
|
|||
|
|
mergeAttrs: false,
|
|||
|
|
explicitRoot: true,
|
|||
|
|
validator: null,
|
|||
|
|
xmlns: false,
|
|||
|
|
explicitChildren: false,
|
|||
|
|
preserveChildrenOrder: false,
|
|||
|
|
childkey: "$$",
|
|||
|
|
charsAsChildren: false,
|
|||
|
|
includeWhiteChars: false,
|
|||
|
|
async: false,
|
|||
|
|
strict: true,
|
|||
|
|
attrNameProcessors: null,
|
|||
|
|
attrValueProcessors: null,
|
|||
|
|
tagNameProcessors: null,
|
|||
|
|
valueProcessors: null,
|
|||
|
|
rootName: "root",
|
|||
|
|
xmldec: {
|
|||
|
|
"version": "1.0",
|
|||
|
|
"encoding": "UTF-8",
|
|||
|
|
"standalone": true
|
|||
|
|
},
|
|||
|
|
doctype: null,
|
|||
|
|
renderOpts: {
|
|||
|
|
"pretty": true,
|
|||
|
|
"indent": " ",
|
|||
|
|
"newline": "\n"
|
|||
|
|
},
|
|||
|
|
headless: false,
|
|||
|
|
chunkSize: 1e4,
|
|||
|
|
emptyTag: "",
|
|||
|
|
cdata: false
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/Utility.js
|
|||
|
|
var require_Utility = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/Utility.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject, slice = [].slice, hasProp = {}.hasOwnProperty;
|
|||
|
|
assign = function() {
|
|||
|
|
var i, key, len, source, sources, target;
|
|||
|
|
target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
|||
|
|
if (isFunction(Object.assign)) {
|
|||
|
|
Object.assign.apply(null, arguments);
|
|||
|
|
} else {
|
|||
|
|
for (i = 0, len = sources.length; i < len; i++) {
|
|||
|
|
source = sources[i];
|
|||
|
|
if (source != null) {
|
|||
|
|
for (key in source) {
|
|||
|
|
if (!hasProp.call(source, key))
|
|||
|
|
continue;
|
|||
|
|
target[key] = source[key];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return target;
|
|||
|
|
};
|
|||
|
|
isFunction = function(val) {
|
|||
|
|
return !!val && Object.prototype.toString.call(val) === "[object Function]";
|
|||
|
|
};
|
|||
|
|
isObject = function(val) {
|
|||
|
|
var ref;
|
|||
|
|
return !!val && ((ref = typeof val) === "function" || ref === "object");
|
|||
|
|
};
|
|||
|
|
isArray = function(val) {
|
|||
|
|
if (isFunction(Array.isArray)) {
|
|||
|
|
return Array.isArray(val);
|
|||
|
|
} else {
|
|||
|
|
return Object.prototype.toString.call(val) === "[object Array]";
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
isEmpty = function(val) {
|
|||
|
|
var key;
|
|||
|
|
if (isArray(val)) {
|
|||
|
|
return !val.length;
|
|||
|
|
} else {
|
|||
|
|
for (key in val) {
|
|||
|
|
if (!hasProp.call(val, key))
|
|||
|
|
continue;
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
isPlainObject = function(val) {
|
|||
|
|
var ctor, proto;
|
|||
|
|
return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
|
|||
|
|
};
|
|||
|
|
getValue = function(obj) {
|
|||
|
|
if (isFunction(obj.valueOf)) {
|
|||
|
|
return obj.valueOf();
|
|||
|
|
} else {
|
|||
|
|
return obj;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
module2.exports.assign = assign;
|
|||
|
|
module2.exports.isFunction = isFunction;
|
|||
|
|
module2.exports.isObject = isObject;
|
|||
|
|
module2.exports.isArray = isArray;
|
|||
|
|
module2.exports.isEmpty = isEmpty;
|
|||
|
|
module2.exports.isPlainObject = isPlainObject;
|
|||
|
|
module2.exports.getValue = getValue;
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDOMImplementation.js
|
|||
|
|
var require_XMLDOMImplementation = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDOMImplementation.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLDOMImplementation;
|
|||
|
|
module2.exports = XMLDOMImplementation = function() {
|
|||
|
|
function XMLDOMImplementation2() {
|
|||
|
|
}
|
|||
|
|
XMLDOMImplementation2.prototype.hasFeature = function(feature, version) {
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
XMLDOMImplementation2.prototype.createDocumentType = function(qualifiedName, publicId, systemId) {
|
|||
|
|
throw new Error("This DOM method is not implemented.");
|
|||
|
|
};
|
|||
|
|
XMLDOMImplementation2.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) {
|
|||
|
|
throw new Error("This DOM method is not implemented.");
|
|||
|
|
};
|
|||
|
|
XMLDOMImplementation2.prototype.createHTMLDocument = function(title) {
|
|||
|
|
throw new Error("This DOM method is not implemented.");
|
|||
|
|
};
|
|||
|
|
XMLDOMImplementation2.prototype.getFeature = function(feature, version) {
|
|||
|
|
throw new Error("This DOM method is not implemented.");
|
|||
|
|
};
|
|||
|
|
return XMLDOMImplementation2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDOMErrorHandler.js
|
|||
|
|
var require_XMLDOMErrorHandler = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDOMErrorHandler.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLDOMErrorHandler;
|
|||
|
|
module2.exports = XMLDOMErrorHandler = function() {
|
|||
|
|
function XMLDOMErrorHandler2() {
|
|||
|
|
}
|
|||
|
|
XMLDOMErrorHandler2.prototype.handleError = function(error) {
|
|||
|
|
throw new Error(error);
|
|||
|
|
};
|
|||
|
|
return XMLDOMErrorHandler2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDOMStringList.js
|
|||
|
|
var require_XMLDOMStringList = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDOMStringList.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLDOMStringList;
|
|||
|
|
module2.exports = XMLDOMStringList = function() {
|
|||
|
|
function XMLDOMStringList2(arr) {
|
|||
|
|
this.arr = arr || [];
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLDOMStringList2.prototype, "length", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.arr.length;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLDOMStringList2.prototype.item = function(index) {
|
|||
|
|
return this.arr[index] || null;
|
|||
|
|
};
|
|||
|
|
XMLDOMStringList2.prototype.contains = function(str) {
|
|||
|
|
return this.arr.indexOf(str) !== -1;
|
|||
|
|
};
|
|||
|
|
return XMLDOMStringList2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDOMConfiguration.js
|
|||
|
|
var require_XMLDOMConfiguration = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDOMConfiguration.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
|
|||
|
|
XMLDOMErrorHandler = require_XMLDOMErrorHandler();
|
|||
|
|
XMLDOMStringList = require_XMLDOMStringList();
|
|||
|
|
module2.exports = XMLDOMConfiguration = function() {
|
|||
|
|
function XMLDOMConfiguration2() {
|
|||
|
|
var clonedSelf;
|
|||
|
|
this.defaultParams = {
|
|||
|
|
"canonical-form": false,
|
|||
|
|
"cdata-sections": false,
|
|||
|
|
"comments": false,
|
|||
|
|
"datatype-normalization": false,
|
|||
|
|
"element-content-whitespace": true,
|
|||
|
|
"entities": true,
|
|||
|
|
"error-handler": new XMLDOMErrorHandler(),
|
|||
|
|
"infoset": true,
|
|||
|
|
"validate-if-schema": false,
|
|||
|
|
"namespaces": true,
|
|||
|
|
"namespace-declarations": true,
|
|||
|
|
"normalize-characters": false,
|
|||
|
|
"schema-location": "",
|
|||
|
|
"schema-type": "",
|
|||
|
|
"split-cdata-sections": true,
|
|||
|
|
"validate": false,
|
|||
|
|
"well-formed": true
|
|||
|
|
};
|
|||
|
|
this.params = clonedSelf = Object.create(this.defaultParams);
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLDOMConfiguration2.prototype, "parameterNames", {
|
|||
|
|
get: function() {
|
|||
|
|
return new XMLDOMStringList(Object.keys(this.defaultParams));
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLDOMConfiguration2.prototype.getParameter = function(name) {
|
|||
|
|
if (this.params.hasOwnProperty(name)) {
|
|||
|
|
return this.params[name];
|
|||
|
|
} else {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLDOMConfiguration2.prototype.canSetParameter = function(name, value) {
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
XMLDOMConfiguration2.prototype.setParameter = function(name, value) {
|
|||
|
|
if (value != null) {
|
|||
|
|
return this.params[name] = value;
|
|||
|
|
} else {
|
|||
|
|
return delete this.params[name];
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
return XMLDOMConfiguration2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/NodeType.js
|
|||
|
|
var require_NodeType = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/NodeType.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
module2.exports = {
|
|||
|
|
Element: 1,
|
|||
|
|
Attribute: 2,
|
|||
|
|
Text: 3,
|
|||
|
|
CData: 4,
|
|||
|
|
EntityReference: 5,
|
|||
|
|
EntityDeclaration: 6,
|
|||
|
|
ProcessingInstruction: 7,
|
|||
|
|
Comment: 8,
|
|||
|
|
Document: 9,
|
|||
|
|
DocType: 10,
|
|||
|
|
DocumentFragment: 11,
|
|||
|
|
NotationDeclaration: 12,
|
|||
|
|
Declaration: 201,
|
|||
|
|
Raw: 202,
|
|||
|
|
AttributeDeclaration: 203,
|
|||
|
|
ElementDeclaration: 204,
|
|||
|
|
Dummy: 205
|
|||
|
|
};
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLAttribute.js
|
|||
|
|
var require_XMLAttribute = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLAttribute.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLAttribute, XMLNode;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
module2.exports = XMLAttribute = function() {
|
|||
|
|
function XMLAttribute2(parent, name, value) {
|
|||
|
|
this.parent = parent;
|
|||
|
|
if (this.parent) {
|
|||
|
|
this.options = this.parent.options;
|
|||
|
|
this.stringify = this.parent.stringify;
|
|||
|
|
}
|
|||
|
|
if (name == null) {
|
|||
|
|
throw new Error("Missing attribute name. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
this.name = this.stringify.name(name);
|
|||
|
|
this.value = this.stringify.attValue(value);
|
|||
|
|
this.type = NodeType.Attribute;
|
|||
|
|
this.isId = false;
|
|||
|
|
this.schemaTypeInfo = null;
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLAttribute2.prototype, "nodeType", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.type;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLAttribute2.prototype, "ownerElement", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.parent;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLAttribute2.prototype, "textContent", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.value;
|
|||
|
|
},
|
|||
|
|
set: function(value) {
|
|||
|
|
return this.value = value || "";
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLAttribute2.prototype, "namespaceURI", {
|
|||
|
|
get: function() {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLAttribute2.prototype, "prefix", {
|
|||
|
|
get: function() {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLAttribute2.prototype, "localName", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.name;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLAttribute2.prototype, "specified", {
|
|||
|
|
get: function() {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLAttribute2.prototype.clone = function() {
|
|||
|
|
return Object.create(this);
|
|||
|
|
};
|
|||
|
|
XMLAttribute2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
XMLAttribute2.prototype.debugInfo = function(name) {
|
|||
|
|
name = name || this.name;
|
|||
|
|
if (name == null) {
|
|||
|
|
return "parent: <" + this.parent.name + ">";
|
|||
|
|
} else {
|
|||
|
|
return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLAttribute2.prototype.isEqualNode = function(node) {
|
|||
|
|
if (node.namespaceURI !== this.namespaceURI) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.prefix !== this.prefix) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.localName !== this.localName) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.value !== this.value) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
return XMLAttribute2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLNamedNodeMap.js
|
|||
|
|
var require_XMLNamedNodeMap = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLNamedNodeMap.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLNamedNodeMap;
|
|||
|
|
module2.exports = XMLNamedNodeMap = function() {
|
|||
|
|
function XMLNamedNodeMap2(nodes) {
|
|||
|
|
this.nodes = nodes;
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLNamedNodeMap2.prototype, "length", {
|
|||
|
|
get: function() {
|
|||
|
|
return Object.keys(this.nodes).length || 0;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLNamedNodeMap2.prototype.clone = function() {
|
|||
|
|
return this.nodes = null;
|
|||
|
|
};
|
|||
|
|
XMLNamedNodeMap2.prototype.getNamedItem = function(name) {
|
|||
|
|
return this.nodes[name];
|
|||
|
|
};
|
|||
|
|
XMLNamedNodeMap2.prototype.setNamedItem = function(node) {
|
|||
|
|
var oldNode;
|
|||
|
|
oldNode = this.nodes[node.nodeName];
|
|||
|
|
this.nodes[node.nodeName] = node;
|
|||
|
|
return oldNode || null;
|
|||
|
|
};
|
|||
|
|
XMLNamedNodeMap2.prototype.removeNamedItem = function(name) {
|
|||
|
|
var oldNode;
|
|||
|
|
oldNode = this.nodes[name];
|
|||
|
|
delete this.nodes[name];
|
|||
|
|
return oldNode || null;
|
|||
|
|
};
|
|||
|
|
XMLNamedNodeMap2.prototype.item = function(index) {
|
|||
|
|
return this.nodes[Object.keys(this.nodes)[index]] || null;
|
|||
|
|
};
|
|||
|
|
XMLNamedNodeMap2.prototype.getNamedItemNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented.");
|
|||
|
|
};
|
|||
|
|
XMLNamedNodeMap2.prototype.setNamedItemNS = function(node) {
|
|||
|
|
throw new Error("This DOM method is not implemented.");
|
|||
|
|
};
|
|||
|
|
XMLNamedNodeMap2.prototype.removeNamedItemNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented.");
|
|||
|
|
};
|
|||
|
|
return XMLNamedNodeMap2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLElement.js
|
|||
|
|
var require_XMLElement = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLElement.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, ref, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
ref = require_Utility(), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLAttribute = require_XMLAttribute();
|
|||
|
|
XMLNamedNodeMap = require_XMLNamedNodeMap();
|
|||
|
|
module2.exports = XMLElement = function(superClass) {
|
|||
|
|
extend(XMLElement2, superClass);
|
|||
|
|
function XMLElement2(parent, name, attributes) {
|
|||
|
|
var child, j, len, ref1;
|
|||
|
|
XMLElement2.__super__.constructor.call(this, parent);
|
|||
|
|
if (name == null) {
|
|||
|
|
throw new Error("Missing element name. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
this.name = this.stringify.name(name);
|
|||
|
|
this.type = NodeType.Element;
|
|||
|
|
this.attribs = {};
|
|||
|
|
this.schemaTypeInfo = null;
|
|||
|
|
if (attributes != null) {
|
|||
|
|
this.attribute(attributes);
|
|||
|
|
}
|
|||
|
|
if (parent.type === NodeType.Document) {
|
|||
|
|
this.isRoot = true;
|
|||
|
|
this.documentObject = parent;
|
|||
|
|
parent.rootObject = this;
|
|||
|
|
if (parent.children) {
|
|||
|
|
ref1 = parent.children;
|
|||
|
|
for (j = 0, len = ref1.length; j < len; j++) {
|
|||
|
|
child = ref1[j];
|
|||
|
|
if (child.type === NodeType.DocType) {
|
|||
|
|
child.name = this.name;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLElement2.prototype, "tagName", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.name;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLElement2.prototype, "namespaceURI", {
|
|||
|
|
get: function() {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLElement2.prototype, "prefix", {
|
|||
|
|
get: function() {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLElement2.prototype, "localName", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.name;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLElement2.prototype, "id", {
|
|||
|
|
get: function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLElement2.prototype, "className", {
|
|||
|
|
get: function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLElement2.prototype, "classList", {
|
|||
|
|
get: function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLElement2.prototype, "attributes", {
|
|||
|
|
get: function() {
|
|||
|
|
if (!this.attributeMap || !this.attributeMap.nodes) {
|
|||
|
|
this.attributeMap = new XMLNamedNodeMap(this.attribs);
|
|||
|
|
}
|
|||
|
|
return this.attributeMap;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLElement2.prototype.clone = function() {
|
|||
|
|
var att, attName, clonedSelf, ref1;
|
|||
|
|
clonedSelf = Object.create(this);
|
|||
|
|
if (clonedSelf.isRoot) {
|
|||
|
|
clonedSelf.documentObject = null;
|
|||
|
|
}
|
|||
|
|
clonedSelf.attribs = {};
|
|||
|
|
ref1 = this.attribs;
|
|||
|
|
for (attName in ref1) {
|
|||
|
|
if (!hasProp.call(ref1, attName))
|
|||
|
|
continue;
|
|||
|
|
att = ref1[attName];
|
|||
|
|
clonedSelf.attribs[attName] = att.clone();
|
|||
|
|
}
|
|||
|
|
clonedSelf.children = [];
|
|||
|
|
this.children.forEach(function(child) {
|
|||
|
|
var clonedChild;
|
|||
|
|
clonedChild = child.clone();
|
|||
|
|
clonedChild.parent = clonedSelf;
|
|||
|
|
return clonedSelf.children.push(clonedChild);
|
|||
|
|
});
|
|||
|
|
return clonedSelf;
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.attribute = function(name, value) {
|
|||
|
|
var attName, attValue;
|
|||
|
|
if (name != null) {
|
|||
|
|
name = getValue(name);
|
|||
|
|
}
|
|||
|
|
if (isObject(name)) {
|
|||
|
|
for (attName in name) {
|
|||
|
|
if (!hasProp.call(name, attName))
|
|||
|
|
continue;
|
|||
|
|
attValue = name[attName];
|
|||
|
|
this.attribute(attName, attValue);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
if (isFunction(value)) {
|
|||
|
|
value = value.apply();
|
|||
|
|
}
|
|||
|
|
if (this.options.keepNullAttributes && value == null) {
|
|||
|
|
this.attribs[name] = new XMLAttribute(this, name, "");
|
|||
|
|
} else if (value != null) {
|
|||
|
|
this.attribs[name] = new XMLAttribute(this, name, value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.removeAttribute = function(name) {
|
|||
|
|
var attName, j, len;
|
|||
|
|
if (name == null) {
|
|||
|
|
throw new Error("Missing attribute name. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
name = getValue(name);
|
|||
|
|
if (Array.isArray(name)) {
|
|||
|
|
for (j = 0, len = name.length; j < len; j++) {
|
|||
|
|
attName = name[j];
|
|||
|
|
delete this.attribs[attName];
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
delete this.attribs[name];
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.element(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.att = function(name, value) {
|
|||
|
|
return this.attribute(name, value);
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.a = function(name, value) {
|
|||
|
|
return this.attribute(name, value);
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getAttribute = function(name) {
|
|||
|
|
if (this.attribs.hasOwnProperty(name)) {
|
|||
|
|
return this.attribs[name].value;
|
|||
|
|
} else {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.setAttribute = function(name, value) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getAttributeNode = function(name) {
|
|||
|
|
if (this.attribs.hasOwnProperty(name)) {
|
|||
|
|
return this.attribs[name];
|
|||
|
|
} else {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.setAttributeNode = function(newAttr) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.removeAttributeNode = function(oldAttr) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getElementsByTagName = function(name) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getAttributeNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.removeAttributeNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getAttributeNodeNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.setAttributeNodeNS = function(newAttr) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.hasAttribute = function(name) {
|
|||
|
|
return this.attribs.hasOwnProperty(name);
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.hasAttributeNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.setIdAttribute = function(name, isId) {
|
|||
|
|
if (this.attribs.hasOwnProperty(name)) {
|
|||
|
|
return this.attribs[name].isId;
|
|||
|
|
} else {
|
|||
|
|
return isId;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.setIdAttributeNode = function(idAttr, isId) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getElementsByTagName = function(tagname) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.getElementsByClassName = function(classNames) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLElement2.prototype.isEqualNode = function(node) {
|
|||
|
|
var i, j, ref1;
|
|||
|
|
if (!XMLElement2.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.namespaceURI !== this.namespaceURI) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.prefix !== this.prefix) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.localName !== this.localName) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.attribs.length !== this.attribs.length) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
|
|||
|
|
if (!this.attribs[i].isEqualNode(node.attribs[i])) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
return XMLElement2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLCharacterData.js
|
|||
|
|
var require_XMLCharacterData = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLCharacterData.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLCharacterData, XMLNode, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
module2.exports = XMLCharacterData = function(superClass) {
|
|||
|
|
extend(XMLCharacterData2, superClass);
|
|||
|
|
function XMLCharacterData2(parent) {
|
|||
|
|
XMLCharacterData2.__super__.constructor.call(this, parent);
|
|||
|
|
this.value = "";
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLCharacterData2.prototype, "data", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.value;
|
|||
|
|
},
|
|||
|
|
set: function(value) {
|
|||
|
|
return this.value = value || "";
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLCharacterData2.prototype, "length", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.value.length;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLCharacterData2.prototype, "textContent", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.value;
|
|||
|
|
},
|
|||
|
|
set: function(value) {
|
|||
|
|
return this.value = value || "";
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLCharacterData2.prototype.clone = function() {
|
|||
|
|
return Object.create(this);
|
|||
|
|
};
|
|||
|
|
XMLCharacterData2.prototype.substringData = function(offset2, count) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLCharacterData2.prototype.appendData = function(arg) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLCharacterData2.prototype.insertData = function(offset2, arg) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLCharacterData2.prototype.deleteData = function(offset2, count) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLCharacterData2.prototype.replaceData = function(offset2, count, arg) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLCharacterData2.prototype.isEqualNode = function(node) {
|
|||
|
|
if (!XMLCharacterData2.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.data !== this.data) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
return XMLCharacterData2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLCData.js
|
|||
|
|
var require_XMLCData = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLCData.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLCData, XMLCharacterData, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLCharacterData = require_XMLCharacterData();
|
|||
|
|
module2.exports = XMLCData = function(superClass) {
|
|||
|
|
extend(XMLCData2, superClass);
|
|||
|
|
function XMLCData2(parent, text) {
|
|||
|
|
XMLCData2.__super__.constructor.call(this, parent);
|
|||
|
|
if (text == null) {
|
|||
|
|
throw new Error("Missing CDATA text. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
this.name = "#cdata-section";
|
|||
|
|
this.type = NodeType.CData;
|
|||
|
|
this.value = this.stringify.cdata(text);
|
|||
|
|
}
|
|||
|
|
XMLCData2.prototype.clone = function() {
|
|||
|
|
return Object.create(this);
|
|||
|
|
};
|
|||
|
|
XMLCData2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
return XMLCData2;
|
|||
|
|
}(XMLCharacterData);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLComment.js
|
|||
|
|
var require_XMLComment = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLComment.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLCharacterData, XMLComment, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLCharacterData = require_XMLCharacterData();
|
|||
|
|
module2.exports = XMLComment = function(superClass) {
|
|||
|
|
extend(XMLComment2, superClass);
|
|||
|
|
function XMLComment2(parent, text) {
|
|||
|
|
XMLComment2.__super__.constructor.call(this, parent);
|
|||
|
|
if (text == null) {
|
|||
|
|
throw new Error("Missing comment text. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
this.name = "#comment";
|
|||
|
|
this.type = NodeType.Comment;
|
|||
|
|
this.value = this.stringify.comment(text);
|
|||
|
|
}
|
|||
|
|
XMLComment2.prototype.clone = function() {
|
|||
|
|
return Object.create(this);
|
|||
|
|
};
|
|||
|
|
XMLComment2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.comment(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
return XMLComment2;
|
|||
|
|
}(XMLCharacterData);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDeclaration.js
|
|||
|
|
var require_XMLDeclaration = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDeclaration.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLDeclaration, XMLNode, isObject, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
isObject = require_Utility().isObject;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
module2.exports = XMLDeclaration = function(superClass) {
|
|||
|
|
extend(XMLDeclaration2, superClass);
|
|||
|
|
function XMLDeclaration2(parent, version, encoding, standalone) {
|
|||
|
|
var ref;
|
|||
|
|
XMLDeclaration2.__super__.constructor.call(this, parent);
|
|||
|
|
if (isObject(version)) {
|
|||
|
|
ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
|
|||
|
|
}
|
|||
|
|
if (!version) {
|
|||
|
|
version = "1.0";
|
|||
|
|
}
|
|||
|
|
this.type = NodeType.Declaration;
|
|||
|
|
this.version = this.stringify.xmlVersion(version);
|
|||
|
|
if (encoding != null) {
|
|||
|
|
this.encoding = this.stringify.xmlEncoding(encoding);
|
|||
|
|
}
|
|||
|
|
if (standalone != null) {
|
|||
|
|
this.standalone = this.stringify.xmlStandalone(standalone);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
XMLDeclaration2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
return XMLDeclaration2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDTDAttList.js
|
|||
|
|
var require_XMLDTDAttList = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDTDAttList.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLDTDAttList, XMLNode, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
module2.exports = XMLDTDAttList = function(superClass) {
|
|||
|
|
extend(XMLDTDAttList2, superClass);
|
|||
|
|
function XMLDTDAttList2(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
|||
|
|
XMLDTDAttList2.__super__.constructor.call(this, parent);
|
|||
|
|
if (elementName == null) {
|
|||
|
|
throw new Error("Missing DTD element name. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
if (attributeName == null) {
|
|||
|
|
throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
|
|||
|
|
}
|
|||
|
|
if (!attributeType) {
|
|||
|
|
throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
|
|||
|
|
}
|
|||
|
|
if (!defaultValueType) {
|
|||
|
|
throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
|
|||
|
|
}
|
|||
|
|
if (defaultValueType.indexOf("#") !== 0) {
|
|||
|
|
defaultValueType = "#" + defaultValueType;
|
|||
|
|
}
|
|||
|
|
if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
|
|||
|
|
throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
|
|||
|
|
}
|
|||
|
|
if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
|
|||
|
|
throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
|
|||
|
|
}
|
|||
|
|
this.elementName = this.stringify.name(elementName);
|
|||
|
|
this.type = NodeType.AttributeDeclaration;
|
|||
|
|
this.attributeName = this.stringify.name(attributeName);
|
|||
|
|
this.attributeType = this.stringify.dtdAttType(attributeType);
|
|||
|
|
if (defaultValue) {
|
|||
|
|
this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
|
|||
|
|
}
|
|||
|
|
this.defaultValueType = defaultValueType;
|
|||
|
|
}
|
|||
|
|
XMLDTDAttList2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
return XMLDTDAttList2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDTDEntity.js
|
|||
|
|
var require_XMLDTDEntity = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDTDEntity.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLDTDEntity, XMLNode, isObject, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
isObject = require_Utility().isObject;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
module2.exports = XMLDTDEntity = function(superClass) {
|
|||
|
|
extend(XMLDTDEntity2, superClass);
|
|||
|
|
function XMLDTDEntity2(parent, pe, name, value) {
|
|||
|
|
XMLDTDEntity2.__super__.constructor.call(this, parent);
|
|||
|
|
if (name == null) {
|
|||
|
|
throw new Error("Missing DTD entity name. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
if (value == null) {
|
|||
|
|
throw new Error("Missing DTD entity value. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
this.pe = !!pe;
|
|||
|
|
this.name = this.stringify.name(name);
|
|||
|
|
this.type = NodeType.EntityDeclaration;
|
|||
|
|
if (!isObject(value)) {
|
|||
|
|
this.value = this.stringify.dtdEntityValue(value);
|
|||
|
|
this.internal = true;
|
|||
|
|
} else {
|
|||
|
|
if (!value.pubID && !value.sysID) {
|
|||
|
|
throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
if (value.pubID && !value.sysID) {
|
|||
|
|
throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
this.internal = false;
|
|||
|
|
if (value.pubID != null) {
|
|||
|
|
this.pubID = this.stringify.dtdPubID(value.pubID);
|
|||
|
|
}
|
|||
|
|
if (value.sysID != null) {
|
|||
|
|
this.sysID = this.stringify.dtdSysID(value.sysID);
|
|||
|
|
}
|
|||
|
|
if (value.nData != null) {
|
|||
|
|
this.nData = this.stringify.dtdNData(value.nData);
|
|||
|
|
}
|
|||
|
|
if (this.pe && this.nData) {
|
|||
|
|
throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLDTDEntity2.prototype, "publicId", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.pubID;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDTDEntity2.prototype, "systemId", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.sysID;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDTDEntity2.prototype, "notationName", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.nData || null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDTDEntity2.prototype, "inputEncoding", {
|
|||
|
|
get: function() {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDTDEntity2.prototype, "xmlEncoding", {
|
|||
|
|
get: function() {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDTDEntity2.prototype, "xmlVersion", {
|
|||
|
|
get: function() {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLDTDEntity2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
return XMLDTDEntity2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDTDElement.js
|
|||
|
|
var require_XMLDTDElement = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDTDElement.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLDTDElement, XMLNode, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
module2.exports = XMLDTDElement = function(superClass) {
|
|||
|
|
extend(XMLDTDElement2, superClass);
|
|||
|
|
function XMLDTDElement2(parent, name, value) {
|
|||
|
|
XMLDTDElement2.__super__.constructor.call(this, parent);
|
|||
|
|
if (name == null) {
|
|||
|
|
throw new Error("Missing DTD element name. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
if (!value) {
|
|||
|
|
value = "(#PCDATA)";
|
|||
|
|
}
|
|||
|
|
if (Array.isArray(value)) {
|
|||
|
|
value = "(" + value.join(",") + ")";
|
|||
|
|
}
|
|||
|
|
this.name = this.stringify.name(name);
|
|||
|
|
this.type = NodeType.ElementDeclaration;
|
|||
|
|
this.value = this.stringify.dtdElementValue(value);
|
|||
|
|
}
|
|||
|
|
XMLDTDElement2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
return XMLDTDElement2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDTDNotation.js
|
|||
|
|
var require_XMLDTDNotation = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDTDNotation.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLDTDNotation, XMLNode, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
module2.exports = XMLDTDNotation = function(superClass) {
|
|||
|
|
extend(XMLDTDNotation2, superClass);
|
|||
|
|
function XMLDTDNotation2(parent, name, value) {
|
|||
|
|
XMLDTDNotation2.__super__.constructor.call(this, parent);
|
|||
|
|
if (name == null) {
|
|||
|
|
throw new Error("Missing DTD notation name. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
if (!value.pubID && !value.sysID) {
|
|||
|
|
throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
this.name = this.stringify.name(name);
|
|||
|
|
this.type = NodeType.NotationDeclaration;
|
|||
|
|
if (value.pubID != null) {
|
|||
|
|
this.pubID = this.stringify.dtdPubID(value.pubID);
|
|||
|
|
}
|
|||
|
|
if (value.sysID != null) {
|
|||
|
|
this.sysID = this.stringify.dtdSysID(value.sysID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLDTDNotation2.prototype, "publicId", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.pubID;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDTDNotation2.prototype, "systemId", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.sysID;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLDTDNotation2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
return XMLDTDNotation2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDocType.js
|
|||
|
|
var require_XMLDocType = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDocType.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
isObject = require_Utility().isObject;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLDTDAttList = require_XMLDTDAttList();
|
|||
|
|
XMLDTDEntity = require_XMLDTDEntity();
|
|||
|
|
XMLDTDElement = require_XMLDTDElement();
|
|||
|
|
XMLDTDNotation = require_XMLDTDNotation();
|
|||
|
|
XMLNamedNodeMap = require_XMLNamedNodeMap();
|
|||
|
|
module2.exports = XMLDocType = function(superClass) {
|
|||
|
|
extend(XMLDocType2, superClass);
|
|||
|
|
function XMLDocType2(parent, pubID, sysID) {
|
|||
|
|
var child, i, len, ref, ref1, ref2;
|
|||
|
|
XMLDocType2.__super__.constructor.call(this, parent);
|
|||
|
|
this.type = NodeType.DocType;
|
|||
|
|
if (parent.children) {
|
|||
|
|
ref = parent.children;
|
|||
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|||
|
|
child = ref[i];
|
|||
|
|
if (child.type === NodeType.Element) {
|
|||
|
|
this.name = child.name;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
this.documentObject = parent;
|
|||
|
|
if (isObject(pubID)) {
|
|||
|
|
ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID;
|
|||
|
|
}
|
|||
|
|
if (sysID == null) {
|
|||
|
|
ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1];
|
|||
|
|
}
|
|||
|
|
if (pubID != null) {
|
|||
|
|
this.pubID = this.stringify.dtdPubID(pubID);
|
|||
|
|
}
|
|||
|
|
if (sysID != null) {
|
|||
|
|
this.sysID = this.stringify.dtdSysID(sysID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLDocType2.prototype, "entities", {
|
|||
|
|
get: function() {
|
|||
|
|
var child, i, len, nodes, ref;
|
|||
|
|
nodes = {};
|
|||
|
|
ref = this.children;
|
|||
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|||
|
|
child = ref[i];
|
|||
|
|
if (child.type === NodeType.EntityDeclaration && !child.pe) {
|
|||
|
|
nodes[child.name] = child;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return new XMLNamedNodeMap(nodes);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocType2.prototype, "notations", {
|
|||
|
|
get: function() {
|
|||
|
|
var child, i, len, nodes, ref;
|
|||
|
|
nodes = {};
|
|||
|
|
ref = this.children;
|
|||
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|||
|
|
child = ref[i];
|
|||
|
|
if (child.type === NodeType.NotationDeclaration) {
|
|||
|
|
nodes[child.name] = child;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return new XMLNamedNodeMap(nodes);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocType2.prototype, "publicId", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.pubID;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocType2.prototype, "systemId", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.sysID;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocType2.prototype, "internalSubset", {
|
|||
|
|
get: function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLDocType2.prototype.element = function(name, value) {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLDTDElement(this, name, value);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.entity = function(name, value) {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLDTDEntity(this, false, name, value);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.pEntity = function(name, value) {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLDTDEntity(this, true, name, value);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.notation = function(name, value) {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLDTDNotation(this, name, value);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.docType(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.ele = function(name, value) {
|
|||
|
|
return this.element(name, value);
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
|||
|
|
return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.ent = function(name, value) {
|
|||
|
|
return this.entity(name, value);
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.pent = function(name, value) {
|
|||
|
|
return this.pEntity(name, value);
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.not = function(name, value) {
|
|||
|
|
return this.notation(name, value);
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.up = function() {
|
|||
|
|
return this.root() || this.documentObject;
|
|||
|
|
};
|
|||
|
|
XMLDocType2.prototype.isEqualNode = function(node) {
|
|||
|
|
if (!XMLDocType2.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.name !== this.name) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.publicId !== this.publicId) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.systemId !== this.systemId) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
return XMLDocType2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLRaw.js
|
|||
|
|
var require_XMLRaw = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLRaw.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLNode, XMLRaw, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
module2.exports = XMLRaw = function(superClass) {
|
|||
|
|
extend(XMLRaw2, superClass);
|
|||
|
|
function XMLRaw2(parent, text) {
|
|||
|
|
XMLRaw2.__super__.constructor.call(this, parent);
|
|||
|
|
if (text == null) {
|
|||
|
|
throw new Error("Missing raw text. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
this.type = NodeType.Raw;
|
|||
|
|
this.value = this.stringify.raw(text);
|
|||
|
|
}
|
|||
|
|
XMLRaw2.prototype.clone = function() {
|
|||
|
|
return Object.create(this);
|
|||
|
|
};
|
|||
|
|
XMLRaw2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.raw(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
return XMLRaw2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLText.js
|
|||
|
|
var require_XMLText = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLText.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLCharacterData, XMLText, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLCharacterData = require_XMLCharacterData();
|
|||
|
|
module2.exports = XMLText = function(superClass) {
|
|||
|
|
extend(XMLText2, superClass);
|
|||
|
|
function XMLText2(parent, text) {
|
|||
|
|
XMLText2.__super__.constructor.call(this, parent);
|
|||
|
|
if (text == null) {
|
|||
|
|
throw new Error("Missing element text. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
this.name = "#text";
|
|||
|
|
this.type = NodeType.Text;
|
|||
|
|
this.value = this.stringify.text(text);
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLText2.prototype, "isElementContentWhitespace", {
|
|||
|
|
get: function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLText2.prototype, "wholeText", {
|
|||
|
|
get: function() {
|
|||
|
|
var next, prev, str;
|
|||
|
|
str = "";
|
|||
|
|
prev = this.previousSibling;
|
|||
|
|
while (prev) {
|
|||
|
|
str = prev.data + str;
|
|||
|
|
prev = prev.previousSibling;
|
|||
|
|
}
|
|||
|
|
str += this.data;
|
|||
|
|
next = this.nextSibling;
|
|||
|
|
while (next) {
|
|||
|
|
str = str + next.data;
|
|||
|
|
next = next.nextSibling;
|
|||
|
|
}
|
|||
|
|
return str;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLText2.prototype.clone = function() {
|
|||
|
|
return Object.create(this);
|
|||
|
|
};
|
|||
|
|
XMLText2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.text(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
XMLText2.prototype.splitText = function(offset2) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLText2.prototype.replaceWholeText = function(content) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
return XMLText2;
|
|||
|
|
}(XMLCharacterData);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLProcessingInstruction.js
|
|||
|
|
var require_XMLProcessingInstruction = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLProcessingInstruction.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLCharacterData, XMLProcessingInstruction, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLCharacterData = require_XMLCharacterData();
|
|||
|
|
module2.exports = XMLProcessingInstruction = function(superClass) {
|
|||
|
|
extend(XMLProcessingInstruction2, superClass);
|
|||
|
|
function XMLProcessingInstruction2(parent, target, value) {
|
|||
|
|
XMLProcessingInstruction2.__super__.constructor.call(this, parent);
|
|||
|
|
if (target == null) {
|
|||
|
|
throw new Error("Missing instruction target. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
this.type = NodeType.ProcessingInstruction;
|
|||
|
|
this.target = this.stringify.insTarget(target);
|
|||
|
|
this.name = this.target;
|
|||
|
|
if (value) {
|
|||
|
|
this.value = this.stringify.insValue(value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
XMLProcessingInstruction2.prototype.clone = function() {
|
|||
|
|
return Object.create(this);
|
|||
|
|
};
|
|||
|
|
XMLProcessingInstruction2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
XMLProcessingInstruction2.prototype.isEqualNode = function(node) {
|
|||
|
|
if (!XMLProcessingInstruction2.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.target !== this.target) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
return XMLProcessingInstruction2;
|
|||
|
|
}(XMLCharacterData);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDummy.js
|
|||
|
|
var require_XMLDummy = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDummy.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLDummy, XMLNode, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
module2.exports = XMLDummy = function(superClass) {
|
|||
|
|
extend(XMLDummy2, superClass);
|
|||
|
|
function XMLDummy2(parent) {
|
|||
|
|
XMLDummy2.__super__.constructor.call(this, parent);
|
|||
|
|
this.type = NodeType.Dummy;
|
|||
|
|
}
|
|||
|
|
XMLDummy2.prototype.clone = function() {
|
|||
|
|
return Object.create(this);
|
|||
|
|
};
|
|||
|
|
XMLDummy2.prototype.toString = function(options) {
|
|||
|
|
return "";
|
|||
|
|
};
|
|||
|
|
return XMLDummy2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLNodeList.js
|
|||
|
|
var require_XMLNodeList = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLNodeList.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLNodeList;
|
|||
|
|
module2.exports = XMLNodeList = function() {
|
|||
|
|
function XMLNodeList2(nodes) {
|
|||
|
|
this.nodes = nodes;
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLNodeList2.prototype, "length", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.nodes.length || 0;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLNodeList2.prototype.clone = function() {
|
|||
|
|
return this.nodes = null;
|
|||
|
|
};
|
|||
|
|
XMLNodeList2.prototype.item = function(index) {
|
|||
|
|
return this.nodes[index] || null;
|
|||
|
|
};
|
|||
|
|
return XMLNodeList2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/DocumentPosition.js
|
|||
|
|
var require_DocumentPosition = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/DocumentPosition.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
module2.exports = {
|
|||
|
|
Disconnected: 1,
|
|||
|
|
Preceding: 2,
|
|||
|
|
Following: 4,
|
|||
|
|
Contains: 8,
|
|||
|
|
ContainedBy: 16,
|
|||
|
|
ImplementationSpecific: 32
|
|||
|
|
};
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLNode.js
|
|||
|
|
var require_XMLNode = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLNode.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1, hasProp = {}.hasOwnProperty;
|
|||
|
|
ref1 = require_Utility(), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
|
|||
|
|
XMLElement = null;
|
|||
|
|
XMLCData = null;
|
|||
|
|
XMLComment = null;
|
|||
|
|
XMLDeclaration = null;
|
|||
|
|
XMLDocType = null;
|
|||
|
|
XMLRaw = null;
|
|||
|
|
XMLText = null;
|
|||
|
|
XMLProcessingInstruction = null;
|
|||
|
|
XMLDummy = null;
|
|||
|
|
NodeType = null;
|
|||
|
|
XMLNodeList = null;
|
|||
|
|
XMLNamedNodeMap = null;
|
|||
|
|
DocumentPosition = null;
|
|||
|
|
module2.exports = XMLNode = function() {
|
|||
|
|
function XMLNode2(parent1) {
|
|||
|
|
this.parent = parent1;
|
|||
|
|
if (this.parent) {
|
|||
|
|
this.options = this.parent.options;
|
|||
|
|
this.stringify = this.parent.stringify;
|
|||
|
|
}
|
|||
|
|
this.value = null;
|
|||
|
|
this.children = [];
|
|||
|
|
this.baseURI = null;
|
|||
|
|
if (!XMLElement) {
|
|||
|
|
XMLElement = require_XMLElement();
|
|||
|
|
XMLCData = require_XMLCData();
|
|||
|
|
XMLComment = require_XMLComment();
|
|||
|
|
XMLDeclaration = require_XMLDeclaration();
|
|||
|
|
XMLDocType = require_XMLDocType();
|
|||
|
|
XMLRaw = require_XMLRaw();
|
|||
|
|
XMLText = require_XMLText();
|
|||
|
|
XMLProcessingInstruction = require_XMLProcessingInstruction();
|
|||
|
|
XMLDummy = require_XMLDummy();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLNodeList = require_XMLNodeList();
|
|||
|
|
XMLNamedNodeMap = require_XMLNamedNodeMap();
|
|||
|
|
DocumentPosition = require_DocumentPosition();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "nodeName", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.name;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "nodeType", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.type;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "nodeValue", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.value;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "parentNode", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.parent;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "childNodes", {
|
|||
|
|
get: function() {
|
|||
|
|
if (!this.childNodeList || !this.childNodeList.nodes) {
|
|||
|
|
this.childNodeList = new XMLNodeList(this.children);
|
|||
|
|
}
|
|||
|
|
return this.childNodeList;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "firstChild", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.children[0] || null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "lastChild", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.children[this.children.length - 1] || null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "previousSibling", {
|
|||
|
|
get: function() {
|
|||
|
|
var i;
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
return this.parent.children[i - 1] || null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "nextSibling", {
|
|||
|
|
get: function() {
|
|||
|
|
var i;
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
return this.parent.children[i + 1] || null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "ownerDocument", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.document() || null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLNode2.prototype, "textContent", {
|
|||
|
|
get: function() {
|
|||
|
|
var child, j, len, ref2, str;
|
|||
|
|
if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
|
|||
|
|
str = "";
|
|||
|
|
ref2 = this.children;
|
|||
|
|
for (j = 0, len = ref2.length; j < len; j++) {
|
|||
|
|
child = ref2[j];
|
|||
|
|
if (child.textContent) {
|
|||
|
|
str += child.textContent;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return str;
|
|||
|
|
} else {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
set: function(value) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLNode2.prototype.setParent = function(parent) {
|
|||
|
|
var child, j, len, ref2, results;
|
|||
|
|
this.parent = parent;
|
|||
|
|
if (parent) {
|
|||
|
|
this.options = parent.options;
|
|||
|
|
this.stringify = parent.stringify;
|
|||
|
|
}
|
|||
|
|
ref2 = this.children;
|
|||
|
|
results = [];
|
|||
|
|
for (j = 0, len = ref2.length; j < len; j++) {
|
|||
|
|
child = ref2[j];
|
|||
|
|
results.push(child.setParent(this));
|
|||
|
|
}
|
|||
|
|
return results;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.element = function(name, attributes, text) {
|
|||
|
|
var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val;
|
|||
|
|
lastChild = null;
|
|||
|
|
if (attributes === null && text == null) {
|
|||
|
|
ref2 = [{}, null], attributes = ref2[0], text = ref2[1];
|
|||
|
|
}
|
|||
|
|
if (attributes == null) {
|
|||
|
|
attributes = {};
|
|||
|
|
}
|
|||
|
|
attributes = getValue(attributes);
|
|||
|
|
if (!isObject(attributes)) {
|
|||
|
|
ref3 = [attributes, text], text = ref3[0], attributes = ref3[1];
|
|||
|
|
}
|
|||
|
|
if (name != null) {
|
|||
|
|
name = getValue(name);
|
|||
|
|
}
|
|||
|
|
if (Array.isArray(name)) {
|
|||
|
|
for (j = 0, len = name.length; j < len; j++) {
|
|||
|
|
item = name[j];
|
|||
|
|
lastChild = this.element(item);
|
|||
|
|
}
|
|||
|
|
} else if (isFunction(name)) {
|
|||
|
|
lastChild = this.element(name.apply());
|
|||
|
|
} else if (isObject(name)) {
|
|||
|
|
for (key in name) {
|
|||
|
|
if (!hasProp.call(name, key))
|
|||
|
|
continue;
|
|||
|
|
val = name[key];
|
|||
|
|
if (isFunction(val)) {
|
|||
|
|
val = val.apply();
|
|||
|
|
}
|
|||
|
|
if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
|
|||
|
|
lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
|
|||
|
|
} else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
|
|||
|
|
lastChild = this.dummy();
|
|||
|
|
} else if (isObject(val) && isEmpty(val)) {
|
|||
|
|
lastChild = this.element(key);
|
|||
|
|
} else if (!this.options.keepNullNodes && val == null) {
|
|||
|
|
lastChild = this.dummy();
|
|||
|
|
} else if (!this.options.separateArrayItems && Array.isArray(val)) {
|
|||
|
|
for (k = 0, len1 = val.length; k < len1; k++) {
|
|||
|
|
item = val[k];
|
|||
|
|
childNode = {};
|
|||
|
|
childNode[key] = item;
|
|||
|
|
lastChild = this.element(childNode);
|
|||
|
|
}
|
|||
|
|
} else if (isObject(val)) {
|
|||
|
|
if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
|
|||
|
|
lastChild = this.element(val);
|
|||
|
|
} else {
|
|||
|
|
lastChild = this.element(key);
|
|||
|
|
lastChild.element(val);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
lastChild = this.element(key, val);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else if (!this.options.keepNullNodes && text === null) {
|
|||
|
|
lastChild = this.dummy();
|
|||
|
|
} else {
|
|||
|
|
if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
|
|||
|
|
lastChild = this.text(text);
|
|||
|
|
} else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
|
|||
|
|
lastChild = this.cdata(text);
|
|||
|
|
} else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
|
|||
|
|
lastChild = this.comment(text);
|
|||
|
|
} else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
|
|||
|
|
lastChild = this.raw(text);
|
|||
|
|
} else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
|
|||
|
|
lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
|
|||
|
|
} else {
|
|||
|
|
lastChild = this.node(name, attributes, text);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (lastChild == null) {
|
|||
|
|
throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
return lastChild;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.insertBefore = function(name, attributes, text) {
|
|||
|
|
var child, i, newChild, refChild, removed;
|
|||
|
|
if (name != null ? name.type : void 0) {
|
|||
|
|
newChild = name;
|
|||
|
|
refChild = attributes;
|
|||
|
|
newChild.setParent(this);
|
|||
|
|
if (refChild) {
|
|||
|
|
i = children.indexOf(refChild);
|
|||
|
|
removed = children.splice(i);
|
|||
|
|
children.push(newChild);
|
|||
|
|
Array.prototype.push.apply(children, removed);
|
|||
|
|
} else {
|
|||
|
|
children.push(newChild);
|
|||
|
|
}
|
|||
|
|
return newChild;
|
|||
|
|
} else {
|
|||
|
|
if (this.isRoot) {
|
|||
|
|
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
removed = this.parent.children.splice(i);
|
|||
|
|
child = this.parent.element(name, attributes, text);
|
|||
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|||
|
|
return child;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.insertAfter = function(name, attributes, text) {
|
|||
|
|
var child, i, removed;
|
|||
|
|
if (this.isRoot) {
|
|||
|
|
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
removed = this.parent.children.splice(i + 1);
|
|||
|
|
child = this.parent.element(name, attributes, text);
|
|||
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|||
|
|
return child;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.remove = function() {
|
|||
|
|
var i, ref2;
|
|||
|
|
if (this.isRoot) {
|
|||
|
|
throw new Error("Cannot remove the root element. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
[].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
|
|||
|
|
return this.parent;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.node = function(name, attributes, text) {
|
|||
|
|
var child, ref2;
|
|||
|
|
if (name != null) {
|
|||
|
|
name = getValue(name);
|
|||
|
|
}
|
|||
|
|
attributes || (attributes = {});
|
|||
|
|
attributes = getValue(attributes);
|
|||
|
|
if (!isObject(attributes)) {
|
|||
|
|
ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
|
|||
|
|
}
|
|||
|
|
child = new XMLElement(this, name, attributes);
|
|||
|
|
if (text != null) {
|
|||
|
|
child.text(text);
|
|||
|
|
}
|
|||
|
|
this.children.push(child);
|
|||
|
|
return child;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.text = function(value) {
|
|||
|
|
var child;
|
|||
|
|
if (isObject(value)) {
|
|||
|
|
this.element(value);
|
|||
|
|
}
|
|||
|
|
child = new XMLText(this, value);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.cdata = function(value) {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLCData(this, value);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.comment = function(value) {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLComment(this, value);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.commentBefore = function(value) {
|
|||
|
|
var child, i, removed;
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
removed = this.parent.children.splice(i);
|
|||
|
|
child = this.parent.comment(value);
|
|||
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.commentAfter = function(value) {
|
|||
|
|
var child, i, removed;
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
removed = this.parent.children.splice(i + 1);
|
|||
|
|
child = this.parent.comment(value);
|
|||
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.raw = function(value) {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLRaw(this, value);
|
|||
|
|
this.children.push(child);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.dummy = function() {
|
|||
|
|
var child;
|
|||
|
|
child = new XMLDummy(this);
|
|||
|
|
return child;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.instruction = function(target, value) {
|
|||
|
|
var insTarget, insValue, instruction, j, len;
|
|||
|
|
if (target != null) {
|
|||
|
|
target = getValue(target);
|
|||
|
|
}
|
|||
|
|
if (value != null) {
|
|||
|
|
value = getValue(value);
|
|||
|
|
}
|
|||
|
|
if (Array.isArray(target)) {
|
|||
|
|
for (j = 0, len = target.length; j < len; j++) {
|
|||
|
|
insTarget = target[j];
|
|||
|
|
this.instruction(insTarget);
|
|||
|
|
}
|
|||
|
|
} else if (isObject(target)) {
|
|||
|
|
for (insTarget in target) {
|
|||
|
|
if (!hasProp.call(target, insTarget))
|
|||
|
|
continue;
|
|||
|
|
insValue = target[insTarget];
|
|||
|
|
this.instruction(insTarget, insValue);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
if (isFunction(value)) {
|
|||
|
|
value = value.apply();
|
|||
|
|
}
|
|||
|
|
instruction = new XMLProcessingInstruction(this, target, value);
|
|||
|
|
this.children.push(instruction);
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.instructionBefore = function(target, value) {
|
|||
|
|
var child, i, removed;
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
removed = this.parent.children.splice(i);
|
|||
|
|
child = this.parent.instruction(target, value);
|
|||
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.instructionAfter = function(target, value) {
|
|||
|
|
var child, i, removed;
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
removed = this.parent.children.splice(i + 1);
|
|||
|
|
child = this.parent.instruction(target, value);
|
|||
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.declaration = function(version, encoding, standalone) {
|
|||
|
|
var doc, xmldec;
|
|||
|
|
doc = this.document();
|
|||
|
|
xmldec = new XMLDeclaration(doc, version, encoding, standalone);
|
|||
|
|
if (doc.children.length === 0) {
|
|||
|
|
doc.children.unshift(xmldec);
|
|||
|
|
} else if (doc.children[0].type === NodeType.Declaration) {
|
|||
|
|
doc.children[0] = xmldec;
|
|||
|
|
} else {
|
|||
|
|
doc.children.unshift(xmldec);
|
|||
|
|
}
|
|||
|
|
return doc.root() || doc;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.dtd = function(pubID, sysID) {
|
|||
|
|
var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
|
|||
|
|
doc = this.document();
|
|||
|
|
doctype = new XMLDocType(doc, pubID, sysID);
|
|||
|
|
ref2 = doc.children;
|
|||
|
|
for (i = j = 0, len = ref2.length; j < len; i = ++j) {
|
|||
|
|
child = ref2[i];
|
|||
|
|
if (child.type === NodeType.DocType) {
|
|||
|
|
doc.children[i] = doctype;
|
|||
|
|
return doctype;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
ref3 = doc.children;
|
|||
|
|
for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
|
|||
|
|
child = ref3[i];
|
|||
|
|
if (child.isRoot) {
|
|||
|
|
doc.children.splice(i, 0, doctype);
|
|||
|
|
return doctype;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
doc.children.push(doctype);
|
|||
|
|
return doctype;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.up = function() {
|
|||
|
|
if (this.isRoot) {
|
|||
|
|
throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
|
|||
|
|
}
|
|||
|
|
return this.parent;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.root = function() {
|
|||
|
|
var node;
|
|||
|
|
node = this;
|
|||
|
|
while (node) {
|
|||
|
|
if (node.type === NodeType.Document) {
|
|||
|
|
return node.rootObject;
|
|||
|
|
} else if (node.isRoot) {
|
|||
|
|
return node;
|
|||
|
|
} else {
|
|||
|
|
node = node.parent;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.document = function() {
|
|||
|
|
var node;
|
|||
|
|
node = this;
|
|||
|
|
while (node) {
|
|||
|
|
if (node.type === NodeType.Document) {
|
|||
|
|
return node;
|
|||
|
|
} else {
|
|||
|
|
node = node.parent;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.end = function(options) {
|
|||
|
|
return this.document().end(options);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.prev = function() {
|
|||
|
|
var i;
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
if (i < 1) {
|
|||
|
|
throw new Error("Already at the first node. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
return this.parent.children[i - 1];
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.next = function() {
|
|||
|
|
var i;
|
|||
|
|
i = this.parent.children.indexOf(this);
|
|||
|
|
if (i === -1 || i === this.parent.children.length - 1) {
|
|||
|
|
throw new Error("Already at the last node. " + this.debugInfo());
|
|||
|
|
}
|
|||
|
|
return this.parent.children[i + 1];
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.importDocument = function(doc) {
|
|||
|
|
var clonedRoot;
|
|||
|
|
clonedRoot = doc.root().clone();
|
|||
|
|
clonedRoot.parent = this;
|
|||
|
|
clonedRoot.isRoot = false;
|
|||
|
|
this.children.push(clonedRoot);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.debugInfo = function(name) {
|
|||
|
|
var ref2, ref3;
|
|||
|
|
name = name || this.name;
|
|||
|
|
if (name == null && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
|
|||
|
|
return "";
|
|||
|
|
} else if (name == null) {
|
|||
|
|
return "parent: <" + this.parent.name + ">";
|
|||
|
|
} else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
|
|||
|
|
return "node: <" + name + ">";
|
|||
|
|
} else {
|
|||
|
|
return "node: <" + name + ">, parent: <" + this.parent.name + ">";
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.ele = function(name, attributes, text) {
|
|||
|
|
return this.element(name, attributes, text);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.nod = function(name, attributes, text) {
|
|||
|
|
return this.node(name, attributes, text);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.txt = function(value) {
|
|||
|
|
return this.text(value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.dat = function(value) {
|
|||
|
|
return this.cdata(value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.com = function(value) {
|
|||
|
|
return this.comment(value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.ins = function(target, value) {
|
|||
|
|
return this.instruction(target, value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.doc = function() {
|
|||
|
|
return this.document();
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.dec = function(version, encoding, standalone) {
|
|||
|
|
return this.declaration(version, encoding, standalone);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.e = function(name, attributes, text) {
|
|||
|
|
return this.element(name, attributes, text);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.n = function(name, attributes, text) {
|
|||
|
|
return this.node(name, attributes, text);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.t = function(value) {
|
|||
|
|
return this.text(value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.d = function(value) {
|
|||
|
|
return this.cdata(value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.c = function(value) {
|
|||
|
|
return this.comment(value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.r = function(value) {
|
|||
|
|
return this.raw(value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.i = function(target, value) {
|
|||
|
|
return this.instruction(target, value);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.u = function() {
|
|||
|
|
return this.up();
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.importXMLBuilder = function(doc) {
|
|||
|
|
return this.importDocument(doc);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.replaceChild = function(newChild, oldChild) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.removeChild = function(oldChild) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.appendChild = function(newChild) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.hasChildNodes = function() {
|
|||
|
|
return this.children.length !== 0;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.cloneNode = function(deep) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.normalize = function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.isSupported = function(feature, version) {
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.hasAttributes = function() {
|
|||
|
|
return this.attribs.length !== 0;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.compareDocumentPosition = function(other) {
|
|||
|
|
var ref, res;
|
|||
|
|
ref = this;
|
|||
|
|
if (ref === other) {
|
|||
|
|
return 0;
|
|||
|
|
} else if (this.document() !== other.document()) {
|
|||
|
|
res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
|
|||
|
|
if (Math.random() < 0.5) {
|
|||
|
|
res |= DocumentPosition.Preceding;
|
|||
|
|
} else {
|
|||
|
|
res |= DocumentPosition.Following;
|
|||
|
|
}
|
|||
|
|
return res;
|
|||
|
|
} else if (ref.isAncestor(other)) {
|
|||
|
|
return DocumentPosition.Contains | DocumentPosition.Preceding;
|
|||
|
|
} else if (ref.isDescendant(other)) {
|
|||
|
|
return DocumentPosition.Contains | DocumentPosition.Following;
|
|||
|
|
} else if (ref.isPreceding(other)) {
|
|||
|
|
return DocumentPosition.Preceding;
|
|||
|
|
} else {
|
|||
|
|
return DocumentPosition.Following;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.isSameNode = function(other) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.lookupPrefix = function(namespaceURI) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.isDefaultNamespace = function(namespaceURI) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.lookupNamespaceURI = function(prefix) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.isEqualNode = function(node) {
|
|||
|
|
var i, j, ref2;
|
|||
|
|
if (node.nodeType !== this.nodeType) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (node.children.length !== this.children.length) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
|
|||
|
|
if (!this.children[i].isEqualNode(node.children[i])) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.getFeature = function(feature, version) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.setUserData = function(key, data, handler) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.getUserData = function(key) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.contains = function(other) {
|
|||
|
|
if (!other) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return other === this || this.isDescendant(other);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.isDescendant = function(node) {
|
|||
|
|
var child, isDescendantChild, j, len, ref2;
|
|||
|
|
ref2 = this.children;
|
|||
|
|
for (j = 0, len = ref2.length; j < len; j++) {
|
|||
|
|
child = ref2[j];
|
|||
|
|
if (node === child) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
isDescendantChild = child.isDescendant(node);
|
|||
|
|
if (isDescendantChild) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.isAncestor = function(node) {
|
|||
|
|
return node.isDescendant(this);
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.isPreceding = function(node) {
|
|||
|
|
var nodePos, thisPos;
|
|||
|
|
nodePos = this.treePosition(node);
|
|||
|
|
thisPos = this.treePosition(this);
|
|||
|
|
if (nodePos === -1 || thisPos === -1) {
|
|||
|
|
return false;
|
|||
|
|
} else {
|
|||
|
|
return nodePos < thisPos;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.isFollowing = function(node) {
|
|||
|
|
var nodePos, thisPos;
|
|||
|
|
nodePos = this.treePosition(node);
|
|||
|
|
thisPos = this.treePosition(this);
|
|||
|
|
if (nodePos === -1 || thisPos === -1) {
|
|||
|
|
return false;
|
|||
|
|
} else {
|
|||
|
|
return nodePos > thisPos;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.treePosition = function(node) {
|
|||
|
|
var found, pos;
|
|||
|
|
pos = 0;
|
|||
|
|
found = false;
|
|||
|
|
this.foreachTreeNode(this.document(), function(childNode) {
|
|||
|
|
pos++;
|
|||
|
|
if (!found && childNode === node) {
|
|||
|
|
return found = true;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
if (found) {
|
|||
|
|
return pos;
|
|||
|
|
} else {
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLNode2.prototype.foreachTreeNode = function(node, func) {
|
|||
|
|
var child, j, len, ref2, res;
|
|||
|
|
node || (node = this.document());
|
|||
|
|
ref2 = node.children;
|
|||
|
|
for (j = 0, len = ref2.length; j < len; j++) {
|
|||
|
|
child = ref2[j];
|
|||
|
|
if (res = func(child)) {
|
|||
|
|
return res;
|
|||
|
|
} else {
|
|||
|
|
res = this.foreachTreeNode(child, func);
|
|||
|
|
if (res) {
|
|||
|
|
return res;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
return XMLNode2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLStringifier.js
|
|||
|
|
var require_XMLStringifier = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLStringifier.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLStringifier, bind = function(fn2, me) {
|
|||
|
|
return function() {
|
|||
|
|
return fn2.apply(me, arguments);
|
|||
|
|
};
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
module2.exports = XMLStringifier = function() {
|
|||
|
|
function XMLStringifier2(options) {
|
|||
|
|
this.assertLegalName = bind(this.assertLegalName, this);
|
|||
|
|
this.assertLegalChar = bind(this.assertLegalChar, this);
|
|||
|
|
var key, ref, value;
|
|||
|
|
options || (options = {});
|
|||
|
|
this.options = options;
|
|||
|
|
if (!this.options.version) {
|
|||
|
|
this.options.version = "1.0";
|
|||
|
|
}
|
|||
|
|
ref = options.stringify || {};
|
|||
|
|
for (key in ref) {
|
|||
|
|
if (!hasProp.call(ref, key))
|
|||
|
|
continue;
|
|||
|
|
value = ref[key];
|
|||
|
|
this[key] = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
XMLStringifier2.prototype.name = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalName("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.text = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar(this.textEscape("" + val || ""));
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.cdata = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
val = "" + val || "";
|
|||
|
|
val = val.replace("]]>", "]]]]><![CDATA[>");
|
|||
|
|
return this.assertLegalChar(val);
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.comment = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
val = "" + val || "";
|
|||
|
|
if (val.match(/--/)) {
|
|||
|
|
throw new Error("Comment text cannot contain double-hypen: " + val);
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar(val);
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.raw = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return "" + val || "";
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.attValue = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar(this.attEscape(val = "" + val || ""));
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.insTarget = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.insValue = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
val = "" + val || "";
|
|||
|
|
if (val.match(/\?>/)) {
|
|||
|
|
throw new Error("Invalid processing instruction value: " + val);
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar(val);
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.xmlVersion = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
val = "" + val || "";
|
|||
|
|
if (!val.match(/1\.[0-9]+/)) {
|
|||
|
|
throw new Error("Invalid version number: " + val);
|
|||
|
|
}
|
|||
|
|
return val;
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.xmlEncoding = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
val = "" + val || "";
|
|||
|
|
if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
|
|||
|
|
throw new Error("Invalid encoding: " + val);
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar(val);
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.xmlStandalone = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
if (val) {
|
|||
|
|
return "yes";
|
|||
|
|
} else {
|
|||
|
|
return "no";
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.dtdPubID = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.dtdSysID = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.dtdElementValue = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.dtdAttType = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.dtdAttDefault = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.dtdEntityValue = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.dtdNData = function(val) {
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return val;
|
|||
|
|
}
|
|||
|
|
return this.assertLegalChar("" + val || "");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.convertAttKey = "@";
|
|||
|
|
XMLStringifier2.prototype.convertPIKey = "?";
|
|||
|
|
XMLStringifier2.prototype.convertTextKey = "#text";
|
|||
|
|
XMLStringifier2.prototype.convertCDataKey = "#cdata";
|
|||
|
|
XMLStringifier2.prototype.convertCommentKey = "#comment";
|
|||
|
|
XMLStringifier2.prototype.convertRawKey = "#raw";
|
|||
|
|
XMLStringifier2.prototype.assertLegalChar = function(str) {
|
|||
|
|
var regex, res;
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return str;
|
|||
|
|
}
|
|||
|
|
regex = "";
|
|||
|
|
if (this.options.version === "1.0") {
|
|||
|
|
regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|||
|
|
if (res = str.match(regex)) {
|
|||
|
|
throw new Error("Invalid character in string: " + str + " at index " + res.index);
|
|||
|
|
}
|
|||
|
|
} else if (this.options.version === "1.1") {
|
|||
|
|
regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|||
|
|
if (res = str.match(regex)) {
|
|||
|
|
throw new Error("Invalid character in string: " + str + " at index " + res.index);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return str;
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.assertLegalName = function(str) {
|
|||
|
|
var regex;
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return str;
|
|||
|
|
}
|
|||
|
|
this.assertLegalChar(str);
|
|||
|
|
regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
|
|||
|
|
if (!str.match(regex)) {
|
|||
|
|
throw new Error("Invalid character in name");
|
|||
|
|
}
|
|||
|
|
return str;
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.textEscape = function(str) {
|
|||
|
|
var ampregex;
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return str;
|
|||
|
|
}
|
|||
|
|
ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
|
|||
|
|
return str.replace(ampregex, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|||
|
|
};
|
|||
|
|
XMLStringifier2.prototype.attEscape = function(str) {
|
|||
|
|
var ampregex;
|
|||
|
|
if (this.options.noValidation) {
|
|||
|
|
return str;
|
|||
|
|
}
|
|||
|
|
ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
|
|||
|
|
return str.replace(ampregex, "&").replace(/</g, "<").replace(/"/g, """).replace(/\t/g, "	").replace(/\n/g, "
").replace(/\r/g, "
");
|
|||
|
|
};
|
|||
|
|
return XMLStringifier2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/WriterState.js
|
|||
|
|
var require_WriterState = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/WriterState.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
module2.exports = {
|
|||
|
|
None: 0,
|
|||
|
|
OpenTag: 1,
|
|||
|
|
InsideTag: 2,
|
|||
|
|
CloseTag: 3
|
|||
|
|
};
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLWriterBase.js
|
|||
|
|
var require_XMLWriterBase = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLWriterBase.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign, hasProp = {}.hasOwnProperty;
|
|||
|
|
assign = require_Utility().assign;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLDeclaration = require_XMLDeclaration();
|
|||
|
|
XMLDocType = require_XMLDocType();
|
|||
|
|
XMLCData = require_XMLCData();
|
|||
|
|
XMLComment = require_XMLComment();
|
|||
|
|
XMLElement = require_XMLElement();
|
|||
|
|
XMLRaw = require_XMLRaw();
|
|||
|
|
XMLText = require_XMLText();
|
|||
|
|
XMLProcessingInstruction = require_XMLProcessingInstruction();
|
|||
|
|
XMLDummy = require_XMLDummy();
|
|||
|
|
XMLDTDAttList = require_XMLDTDAttList();
|
|||
|
|
XMLDTDElement = require_XMLDTDElement();
|
|||
|
|
XMLDTDEntity = require_XMLDTDEntity();
|
|||
|
|
XMLDTDNotation = require_XMLDTDNotation();
|
|||
|
|
WriterState = require_WriterState();
|
|||
|
|
module2.exports = XMLWriterBase = function() {
|
|||
|
|
function XMLWriterBase2(options) {
|
|||
|
|
var key, ref, value;
|
|||
|
|
options || (options = {});
|
|||
|
|
this.options = options;
|
|||
|
|
ref = options.writer || {};
|
|||
|
|
for (key in ref) {
|
|||
|
|
if (!hasProp.call(ref, key))
|
|||
|
|
continue;
|
|||
|
|
value = ref[key];
|
|||
|
|
this["_" + key] = this[key];
|
|||
|
|
this[key] = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
XMLWriterBase2.prototype.filterOptions = function(options) {
|
|||
|
|
var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6;
|
|||
|
|
options || (options = {});
|
|||
|
|
options = assign({}, this.options, options);
|
|||
|
|
filteredOptions = {
|
|||
|
|
writer: this
|
|||
|
|
};
|
|||
|
|
filteredOptions.pretty = options.pretty || false;
|
|||
|
|
filteredOptions.allowEmpty = options.allowEmpty || false;
|
|||
|
|
filteredOptions.indent = (ref = options.indent) != null ? ref : " ";
|
|||
|
|
filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : "\n";
|
|||
|
|
filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
|
|||
|
|
filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0;
|
|||
|
|
filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : "";
|
|||
|
|
if (filteredOptions.spaceBeforeSlash === true) {
|
|||
|
|
filteredOptions.spaceBeforeSlash = " ";
|
|||
|
|
}
|
|||
|
|
filteredOptions.suppressPrettyCount = 0;
|
|||
|
|
filteredOptions.user = {};
|
|||
|
|
filteredOptions.state = WriterState.None;
|
|||
|
|
return filteredOptions;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.indent = function(node, options, level) {
|
|||
|
|
var indentLevel;
|
|||
|
|
if (!options.pretty || options.suppressPrettyCount) {
|
|||
|
|
return "";
|
|||
|
|
} else if (options.pretty) {
|
|||
|
|
indentLevel = (level || 0) + options.offset + 1;
|
|||
|
|
if (indentLevel > 0) {
|
|||
|
|
return new Array(indentLevel).join(options.indent);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return "";
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.endline = function(node, options, level) {
|
|||
|
|
if (!options.pretty || options.suppressPrettyCount) {
|
|||
|
|
return "";
|
|||
|
|
} else {
|
|||
|
|
return options.newline;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.attribute = function(att, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openAttribute(att, options, level);
|
|||
|
|
r = " " + att.name + '="' + att.value + '"';
|
|||
|
|
this.closeAttribute(att, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.cdata = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level) + "<![CDATA[";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += node.value;
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += "]]>" + this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.comment = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level) + "<!-- ";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += node.value;
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += " -->" + this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.declaration = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level) + "<?xml";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += ' version="' + node.version + '"';
|
|||
|
|
if (node.encoding != null) {
|
|||
|
|
r += ' encoding="' + node.encoding + '"';
|
|||
|
|
}
|
|||
|
|
if (node.standalone != null) {
|
|||
|
|
r += ' standalone="' + node.standalone + '"';
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += options.spaceBeforeSlash + "?>";
|
|||
|
|
r += this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.docType = function(node, options, level) {
|
|||
|
|
var child, i, len, r, ref;
|
|||
|
|
level || (level = 0);
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level);
|
|||
|
|
r += "<!DOCTYPE " + node.root().name;
|
|||
|
|
if (node.pubID && node.sysID) {
|
|||
|
|
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
|
|||
|
|
} else if (node.sysID) {
|
|||
|
|
r += ' SYSTEM "' + node.sysID + '"';
|
|||
|
|
}
|
|||
|
|
if (node.children.length > 0) {
|
|||
|
|
r += " [";
|
|||
|
|
r += this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
ref = node.children;
|
|||
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|||
|
|
child = ref[i];
|
|||
|
|
r += this.writeChildNode(child, options, level + 1);
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += "]";
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += options.spaceBeforeSlash + ">";
|
|||
|
|
r += this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.element = function(node, options, level) {
|
|||
|
|
var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
|
|||
|
|
level || (level = 0);
|
|||
|
|
prettySuppressed = false;
|
|||
|
|
r = "";
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r += this.indent(node, options, level) + "<" + node.name;
|
|||
|
|
ref = node.attribs;
|
|||
|
|
for (name in ref) {
|
|||
|
|
if (!hasProp.call(ref, name))
|
|||
|
|
continue;
|
|||
|
|
att = ref[name];
|
|||
|
|
r += this.attribute(att, options, level);
|
|||
|
|
}
|
|||
|
|
childNodeCount = node.children.length;
|
|||
|
|
firstChildNode = childNodeCount === 0 ? null : node.children[0];
|
|||
|
|
if (childNodeCount === 0 || node.children.every(function(e) {
|
|||
|
|
return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === "";
|
|||
|
|
})) {
|
|||
|
|
if (options.allowEmpty) {
|
|||
|
|
r += ">";
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += "</" + node.name + ">" + this.endline(node, options, level);
|
|||
|
|
} else {
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += options.spaceBeforeSlash + "/>" + this.endline(node, options, level);
|
|||
|
|
}
|
|||
|
|
} else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) {
|
|||
|
|
r += ">";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
options.suppressPrettyCount++;
|
|||
|
|
prettySuppressed = true;
|
|||
|
|
r += this.writeChildNode(firstChildNode, options, level + 1);
|
|||
|
|
options.suppressPrettyCount--;
|
|||
|
|
prettySuppressed = false;
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += "</" + node.name + ">" + this.endline(node, options, level);
|
|||
|
|
} else {
|
|||
|
|
if (options.dontPrettyTextNodes) {
|
|||
|
|
ref1 = node.children;
|
|||
|
|
for (i = 0, len = ref1.length; i < len; i++) {
|
|||
|
|
child = ref1[i];
|
|||
|
|
if ((child.type === NodeType.Text || child.type === NodeType.Raw) && child.value != null) {
|
|||
|
|
options.suppressPrettyCount++;
|
|||
|
|
prettySuppressed = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
r += ">" + this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
ref2 = node.children;
|
|||
|
|
for (j = 0, len1 = ref2.length; j < len1; j++) {
|
|||
|
|
child = ref2[j];
|
|||
|
|
r += this.writeChildNode(child, options, level + 1);
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += this.indent(node, options, level) + "</" + node.name + ">";
|
|||
|
|
if (prettySuppressed) {
|
|||
|
|
options.suppressPrettyCount--;
|
|||
|
|
}
|
|||
|
|
r += this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
}
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.writeChildNode = function(node, options, level) {
|
|||
|
|
switch (node.type) {
|
|||
|
|
case NodeType.CData:
|
|||
|
|
return this.cdata(node, options, level);
|
|||
|
|
case NodeType.Comment:
|
|||
|
|
return this.comment(node, options, level);
|
|||
|
|
case NodeType.Element:
|
|||
|
|
return this.element(node, options, level);
|
|||
|
|
case NodeType.Raw:
|
|||
|
|
return this.raw(node, options, level);
|
|||
|
|
case NodeType.Text:
|
|||
|
|
return this.text(node, options, level);
|
|||
|
|
case NodeType.ProcessingInstruction:
|
|||
|
|
return this.processingInstruction(node, options, level);
|
|||
|
|
case NodeType.Dummy:
|
|||
|
|
return "";
|
|||
|
|
case NodeType.Declaration:
|
|||
|
|
return this.declaration(node, options, level);
|
|||
|
|
case NodeType.DocType:
|
|||
|
|
return this.docType(node, options, level);
|
|||
|
|
case NodeType.AttributeDeclaration:
|
|||
|
|
return this.dtdAttList(node, options, level);
|
|||
|
|
case NodeType.ElementDeclaration:
|
|||
|
|
return this.dtdElement(node, options, level);
|
|||
|
|
case NodeType.EntityDeclaration:
|
|||
|
|
return this.dtdEntity(node, options, level);
|
|||
|
|
case NodeType.NotationDeclaration:
|
|||
|
|
return this.dtdNotation(node, options, level);
|
|||
|
|
default:
|
|||
|
|
throw new Error("Unknown XML node type: " + node.constructor.name);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.processingInstruction = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level) + "<?";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += node.target;
|
|||
|
|
if (node.value) {
|
|||
|
|
r += " " + node.value;
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += options.spaceBeforeSlash + "?>";
|
|||
|
|
r += this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.raw = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level);
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += node.value;
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.text = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level);
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += node.value;
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.dtdAttList = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level) + "<!ATTLIST";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += " " + node.elementName + " " + node.attributeName + " " + node.attributeType;
|
|||
|
|
if (node.defaultValueType !== "#DEFAULT") {
|
|||
|
|
r += " " + node.defaultValueType;
|
|||
|
|
}
|
|||
|
|
if (node.defaultValue) {
|
|||
|
|
r += ' "' + node.defaultValue + '"';
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += options.spaceBeforeSlash + ">" + this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.dtdElement = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level) + "<!ELEMENT";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += " " + node.name + " " + node.value;
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += options.spaceBeforeSlash + ">" + this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.dtdEntity = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level) + "<!ENTITY";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
if (node.pe) {
|
|||
|
|
r += " %";
|
|||
|
|
}
|
|||
|
|
r += " " + node.name;
|
|||
|
|
if (node.value) {
|
|||
|
|
r += ' "' + node.value + '"';
|
|||
|
|
} else {
|
|||
|
|
if (node.pubID && node.sysID) {
|
|||
|
|
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
|
|||
|
|
} else if (node.sysID) {
|
|||
|
|
r += ' SYSTEM "' + node.sysID + '"';
|
|||
|
|
}
|
|||
|
|
if (node.nData) {
|
|||
|
|
r += " NDATA " + node.nData;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += options.spaceBeforeSlash + ">" + this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.dtdNotation = function(node, options, level) {
|
|||
|
|
var r;
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
r = this.indent(node, options, level) + "<!NOTATION";
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
r += " " + node.name;
|
|||
|
|
if (node.pubID && node.sysID) {
|
|||
|
|
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
|
|||
|
|
} else if (node.pubID) {
|
|||
|
|
r += ' PUBLIC "' + node.pubID + '"';
|
|||
|
|
} else if (node.sysID) {
|
|||
|
|
r += ' SYSTEM "' + node.sysID + '"';
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
r += options.spaceBeforeSlash + ">" + this.endline(node, options, level);
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
this.closeNode(node, options, level);
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.openNode = function(node, options, level) {
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.closeNode = function(node, options, level) {
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.openAttribute = function(att, options, level) {
|
|||
|
|
};
|
|||
|
|
XMLWriterBase2.prototype.closeAttribute = function(att, options, level) {
|
|||
|
|
};
|
|||
|
|
return XMLWriterBase2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLStringWriter.js
|
|||
|
|
var require_XMLStringWriter = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLStringWriter.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var XMLStringWriter, XMLWriterBase, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
XMLWriterBase = require_XMLWriterBase();
|
|||
|
|
module2.exports = XMLStringWriter = function(superClass) {
|
|||
|
|
extend(XMLStringWriter2, superClass);
|
|||
|
|
function XMLStringWriter2(options) {
|
|||
|
|
XMLStringWriter2.__super__.constructor.call(this, options);
|
|||
|
|
}
|
|||
|
|
XMLStringWriter2.prototype.document = function(doc, options) {
|
|||
|
|
var child, i, len, r, ref;
|
|||
|
|
options = this.filterOptions(options);
|
|||
|
|
r = "";
|
|||
|
|
ref = doc.children;
|
|||
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|||
|
|
child = ref[i];
|
|||
|
|
r += this.writeChildNode(child, options, 0);
|
|||
|
|
}
|
|||
|
|
if (options.pretty && r.slice(-options.newline.length) === options.newline) {
|
|||
|
|
r = r.slice(0, -options.newline.length);
|
|||
|
|
}
|
|||
|
|
return r;
|
|||
|
|
};
|
|||
|
|
return XMLStringWriter2;
|
|||
|
|
}(XMLWriterBase);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDocument.js
|
|||
|
|
var require_XMLDocument = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDocument.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
isPlainObject = require_Utility().isPlainObject;
|
|||
|
|
XMLDOMImplementation = require_XMLDOMImplementation();
|
|||
|
|
XMLDOMConfiguration = require_XMLDOMConfiguration();
|
|||
|
|
XMLNode = require_XMLNode();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLStringifier = require_XMLStringifier();
|
|||
|
|
XMLStringWriter = require_XMLStringWriter();
|
|||
|
|
module2.exports = XMLDocument = function(superClass) {
|
|||
|
|
extend(XMLDocument2, superClass);
|
|||
|
|
function XMLDocument2(options) {
|
|||
|
|
XMLDocument2.__super__.constructor.call(this, null);
|
|||
|
|
this.name = "#document";
|
|||
|
|
this.type = NodeType.Document;
|
|||
|
|
this.documentURI = null;
|
|||
|
|
this.domConfig = new XMLDOMConfiguration();
|
|||
|
|
options || (options = {});
|
|||
|
|
if (!options.writer) {
|
|||
|
|
options.writer = new XMLStringWriter();
|
|||
|
|
}
|
|||
|
|
this.options = options;
|
|||
|
|
this.stringify = new XMLStringifier(options);
|
|||
|
|
}
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "implementation", {
|
|||
|
|
value: new XMLDOMImplementation()
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "doctype", {
|
|||
|
|
get: function() {
|
|||
|
|
var child, i, len, ref;
|
|||
|
|
ref = this.children;
|
|||
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|||
|
|
child = ref[i];
|
|||
|
|
if (child.type === NodeType.DocType) {
|
|||
|
|
return child;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "documentElement", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.rootObject || null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "inputEncoding", {
|
|||
|
|
get: function() {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "strictErrorChecking", {
|
|||
|
|
get: function() {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "xmlEncoding", {
|
|||
|
|
get: function() {
|
|||
|
|
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
|
|||
|
|
return this.children[0].encoding;
|
|||
|
|
} else {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "xmlStandalone", {
|
|||
|
|
get: function() {
|
|||
|
|
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
|
|||
|
|
return this.children[0].standalone === "yes";
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "xmlVersion", {
|
|||
|
|
get: function() {
|
|||
|
|
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
|
|||
|
|
return this.children[0].version;
|
|||
|
|
} else {
|
|||
|
|
return "1.0";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "URL", {
|
|||
|
|
get: function() {
|
|||
|
|
return this.documentURI;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "origin", {
|
|||
|
|
get: function() {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "compatMode", {
|
|||
|
|
get: function() {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "characterSet", {
|
|||
|
|
get: function() {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
Object.defineProperty(XMLDocument2.prototype, "contentType", {
|
|||
|
|
get: function() {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
XMLDocument2.prototype.end = function(writer) {
|
|||
|
|
var writerOptions;
|
|||
|
|
writerOptions = {};
|
|||
|
|
if (!writer) {
|
|||
|
|
writer = this.options.writer;
|
|||
|
|
} else if (isPlainObject(writer)) {
|
|||
|
|
writerOptions = writer;
|
|||
|
|
writer = this.options.writer;
|
|||
|
|
}
|
|||
|
|
return writer.document(this, writer.filterOptions(writerOptions));
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.toString = function(options) {
|
|||
|
|
return this.options.writer.document(this, this.options.writer.filterOptions(options));
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createElement = function(tagName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createDocumentFragment = function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createTextNode = function(data) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createComment = function(data) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createCDATASection = function(data) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createProcessingInstruction = function(target, data) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createAttribute = function(name) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createEntityReference = function(name) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.getElementsByTagName = function(tagname) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.importNode = function(importedNode, deep) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createElementNS = function(namespaceURI, qualifiedName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.getElementById = function(elementId) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.adoptNode = function(source) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.normalizeDocument = function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.renameNode = function(node, namespaceURI, qualifiedName) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.getElementsByClassName = function(classNames) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createEvent = function(eventInterface) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createRange = function() {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createNodeIterator = function(root, whatToShow, filter) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
XMLDocument2.prototype.createTreeWalker = function(root, whatToShow, filter) {
|
|||
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|||
|
|
};
|
|||
|
|
return XMLDocument2;
|
|||
|
|
}(XMLNode);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLDocumentCB.js
|
|||
|
|
var require_XMLDocumentCB = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLDocumentCB.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject, ref, hasProp = {}.hasOwnProperty;
|
|||
|
|
ref = require_Utility(), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLDocument = require_XMLDocument();
|
|||
|
|
XMLElement = require_XMLElement();
|
|||
|
|
XMLCData = require_XMLCData();
|
|||
|
|
XMLComment = require_XMLComment();
|
|||
|
|
XMLRaw = require_XMLRaw();
|
|||
|
|
XMLText = require_XMLText();
|
|||
|
|
XMLProcessingInstruction = require_XMLProcessingInstruction();
|
|||
|
|
XMLDeclaration = require_XMLDeclaration();
|
|||
|
|
XMLDocType = require_XMLDocType();
|
|||
|
|
XMLDTDAttList = require_XMLDTDAttList();
|
|||
|
|
XMLDTDEntity = require_XMLDTDEntity();
|
|||
|
|
XMLDTDElement = require_XMLDTDElement();
|
|||
|
|
XMLDTDNotation = require_XMLDTDNotation();
|
|||
|
|
XMLAttribute = require_XMLAttribute();
|
|||
|
|
XMLStringifier = require_XMLStringifier();
|
|||
|
|
XMLStringWriter = require_XMLStringWriter();
|
|||
|
|
WriterState = require_WriterState();
|
|||
|
|
module2.exports = XMLDocumentCB = function() {
|
|||
|
|
function XMLDocumentCB2(options, onData, onEnd) {
|
|||
|
|
var writerOptions;
|
|||
|
|
this.name = "?xml";
|
|||
|
|
this.type = NodeType.Document;
|
|||
|
|
options || (options = {});
|
|||
|
|
writerOptions = {};
|
|||
|
|
if (!options.writer) {
|
|||
|
|
options.writer = new XMLStringWriter();
|
|||
|
|
} else if (isPlainObject(options.writer)) {
|
|||
|
|
writerOptions = options.writer;
|
|||
|
|
options.writer = new XMLStringWriter();
|
|||
|
|
}
|
|||
|
|
this.options = options;
|
|||
|
|
this.writer = options.writer;
|
|||
|
|
this.writerOptions = this.writer.filterOptions(writerOptions);
|
|||
|
|
this.stringify = new XMLStringifier(options);
|
|||
|
|
this.onDataCallback = onData || function() {
|
|||
|
|
};
|
|||
|
|
this.onEndCallback = onEnd || function() {
|
|||
|
|
};
|
|||
|
|
this.currentNode = null;
|
|||
|
|
this.currentLevel = -1;
|
|||
|
|
this.openTags = {};
|
|||
|
|
this.documentStarted = false;
|
|||
|
|
this.documentCompleted = false;
|
|||
|
|
this.root = null;
|
|||
|
|
}
|
|||
|
|
XMLDocumentCB2.prototype.createChildNode = function(node) {
|
|||
|
|
var att, attName, attributes, child, i, len, ref1, ref2;
|
|||
|
|
switch (node.type) {
|
|||
|
|
case NodeType.CData:
|
|||
|
|
this.cdata(node.value);
|
|||
|
|
break;
|
|||
|
|
case NodeType.Comment:
|
|||
|
|
this.comment(node.value);
|
|||
|
|
break;
|
|||
|
|
case NodeType.Element:
|
|||
|
|
attributes = {};
|
|||
|
|
ref1 = node.attribs;
|
|||
|
|
for (attName in ref1) {
|
|||
|
|
if (!hasProp.call(ref1, attName))
|
|||
|
|
continue;
|
|||
|
|
att = ref1[attName];
|
|||
|
|
attributes[attName] = att.value;
|
|||
|
|
}
|
|||
|
|
this.node(node.name, attributes);
|
|||
|
|
break;
|
|||
|
|
case NodeType.Dummy:
|
|||
|
|
this.dummy();
|
|||
|
|
break;
|
|||
|
|
case NodeType.Raw:
|
|||
|
|
this.raw(node.value);
|
|||
|
|
break;
|
|||
|
|
case NodeType.Text:
|
|||
|
|
this.text(node.value);
|
|||
|
|
break;
|
|||
|
|
case NodeType.ProcessingInstruction:
|
|||
|
|
this.instruction(node.target, node.value);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
|
|||
|
|
}
|
|||
|
|
ref2 = node.children;
|
|||
|
|
for (i = 0, len = ref2.length; i < len; i++) {
|
|||
|
|
child = ref2[i];
|
|||
|
|
this.createChildNode(child);
|
|||
|
|
if (child.type === NodeType.Element) {
|
|||
|
|
this.up();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.dummy = function() {
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.node = function(name, attributes, text) {
|
|||
|
|
var ref1;
|
|||
|
|
if (name == null) {
|
|||
|
|
throw new Error("Missing node name.");
|
|||
|
|
}
|
|||
|
|
if (this.root && this.currentLevel === -1) {
|
|||
|
|
throw new Error("Document can only have one root node. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
this.openCurrent();
|
|||
|
|
name = getValue(name);
|
|||
|
|
if (attributes == null) {
|
|||
|
|
attributes = {};
|
|||
|
|
}
|
|||
|
|
attributes = getValue(attributes);
|
|||
|
|
if (!isObject(attributes)) {
|
|||
|
|
ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
|
|||
|
|
}
|
|||
|
|
this.currentNode = new XMLElement(this, name, attributes);
|
|||
|
|
this.currentNode.children = false;
|
|||
|
|
this.currentLevel++;
|
|||
|
|
this.openTags[this.currentLevel] = this.currentNode;
|
|||
|
|
if (text != null) {
|
|||
|
|
this.text(text);
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.element = function(name, attributes, text) {
|
|||
|
|
var child, i, len, oldValidationFlag, ref1, root;
|
|||
|
|
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
|
|||
|
|
this.dtdElement.apply(this, arguments);
|
|||
|
|
} else {
|
|||
|
|
if (Array.isArray(name) || isObject(name) || isFunction(name)) {
|
|||
|
|
oldValidationFlag = this.options.noValidation;
|
|||
|
|
this.options.noValidation = true;
|
|||
|
|
root = new XMLDocument(this.options).element("TEMP_ROOT");
|
|||
|
|
root.element(name);
|
|||
|
|
this.options.noValidation = oldValidationFlag;
|
|||
|
|
ref1 = root.children;
|
|||
|
|
for (i = 0, len = ref1.length; i < len; i++) {
|
|||
|
|
child = ref1[i];
|
|||
|
|
this.createChildNode(child);
|
|||
|
|
if (child.type === NodeType.Element) {
|
|||
|
|
this.up();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
this.node(name, attributes, text);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.attribute = function(name, value) {
|
|||
|
|
var attName, attValue;
|
|||
|
|
if (!this.currentNode || this.currentNode.children) {
|
|||
|
|
throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
|
|||
|
|
}
|
|||
|
|
if (name != null) {
|
|||
|
|
name = getValue(name);
|
|||
|
|
}
|
|||
|
|
if (isObject(name)) {
|
|||
|
|
for (attName in name) {
|
|||
|
|
if (!hasProp.call(name, attName))
|
|||
|
|
continue;
|
|||
|
|
attValue = name[attName];
|
|||
|
|
this.attribute(attName, attValue);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
if (isFunction(value)) {
|
|||
|
|
value = value.apply();
|
|||
|
|
}
|
|||
|
|
if (this.options.keepNullAttributes && value == null) {
|
|||
|
|
this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
|
|||
|
|
} else if (value != null) {
|
|||
|
|
this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.text = function(value) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLText(this, value);
|
|||
|
|
this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.cdata = function(value) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLCData(this, value);
|
|||
|
|
this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.comment = function(value) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLComment(this, value);
|
|||
|
|
this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.raw = function(value) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLRaw(this, value);
|
|||
|
|
this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.instruction = function(target, value) {
|
|||
|
|
var i, insTarget, insValue, len, node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
if (target != null) {
|
|||
|
|
target = getValue(target);
|
|||
|
|
}
|
|||
|
|
if (value != null) {
|
|||
|
|
value = getValue(value);
|
|||
|
|
}
|
|||
|
|
if (Array.isArray(target)) {
|
|||
|
|
for (i = 0, len = target.length; i < len; i++) {
|
|||
|
|
insTarget = target[i];
|
|||
|
|
this.instruction(insTarget);
|
|||
|
|
}
|
|||
|
|
} else if (isObject(target)) {
|
|||
|
|
for (insTarget in target) {
|
|||
|
|
if (!hasProp.call(target, insTarget))
|
|||
|
|
continue;
|
|||
|
|
insValue = target[insTarget];
|
|||
|
|
this.instruction(insTarget, insValue);
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
if (isFunction(value)) {
|
|||
|
|
value = value.apply();
|
|||
|
|
}
|
|||
|
|
node = new XMLProcessingInstruction(this, target, value);
|
|||
|
|
this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.declaration = function(version, encoding, standalone) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
if (this.documentStarted) {
|
|||
|
|
throw new Error("declaration() must be the first node.");
|
|||
|
|
}
|
|||
|
|
node = new XMLDeclaration(this, version, encoding, standalone);
|
|||
|
|
this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.doctype = function(root, pubID, sysID) {
|
|||
|
|
this.openCurrent();
|
|||
|
|
if (root == null) {
|
|||
|
|
throw new Error("Missing root node name.");
|
|||
|
|
}
|
|||
|
|
if (this.root) {
|
|||
|
|
throw new Error("dtd() must come before the root node.");
|
|||
|
|
}
|
|||
|
|
this.currentNode = new XMLDocType(this, pubID, sysID);
|
|||
|
|
this.currentNode.rootNodeName = root;
|
|||
|
|
this.currentNode.children = false;
|
|||
|
|
this.currentLevel++;
|
|||
|
|
this.openTags[this.currentLevel] = this.currentNode;
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.dtdElement = function(name, value) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLDTDElement(this, name, value);
|
|||
|
|
this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
|||
|
|
this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.entity = function(name, value) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLDTDEntity(this, false, name, value);
|
|||
|
|
this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.pEntity = function(name, value) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLDTDEntity(this, true, name, value);
|
|||
|
|
this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.notation = function(name, value) {
|
|||
|
|
var node;
|
|||
|
|
this.openCurrent();
|
|||
|
|
node = new XMLDTDNotation(this, name, value);
|
|||
|
|
this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.up = function() {
|
|||
|
|
if (this.currentLevel < 0) {
|
|||
|
|
throw new Error("The document node has no parent.");
|
|||
|
|
}
|
|||
|
|
if (this.currentNode) {
|
|||
|
|
if (this.currentNode.children) {
|
|||
|
|
this.closeNode(this.currentNode);
|
|||
|
|
} else {
|
|||
|
|
this.openNode(this.currentNode);
|
|||
|
|
}
|
|||
|
|
this.currentNode = null;
|
|||
|
|
} else {
|
|||
|
|
this.closeNode(this.openTags[this.currentLevel]);
|
|||
|
|
}
|
|||
|
|
delete this.openTags[this.currentLevel];
|
|||
|
|
this.currentLevel--;
|
|||
|
|
return this;
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.end = function() {
|
|||
|
|
while (this.currentLevel >= 0) {
|
|||
|
|
this.up();
|
|||
|
|
}
|
|||
|
|
return this.onEnd();
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.openCurrent = function() {
|
|||
|
|
if (this.currentNode) {
|
|||
|
|
this.currentNode.children = true;
|
|||
|
|
return this.openNode(this.currentNode);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.openNode = function(node) {
|
|||
|
|
var att, chunk, name, ref1;
|
|||
|
|
if (!node.isOpen) {
|
|||
|
|
if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
|
|||
|
|
this.root = node;
|
|||
|
|
}
|
|||
|
|
chunk = "";
|
|||
|
|
if (node.type === NodeType.Element) {
|
|||
|
|
this.writerOptions.state = WriterState.OpenTag;
|
|||
|
|
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + "<" + node.name;
|
|||
|
|
ref1 = node.attribs;
|
|||
|
|
for (name in ref1) {
|
|||
|
|
if (!hasProp.call(ref1, name))
|
|||
|
|
continue;
|
|||
|
|
att = ref1[name];
|
|||
|
|
chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
|
|||
|
|
}
|
|||
|
|
chunk += (node.children ? ">" : "/>") + this.writer.endline(node, this.writerOptions, this.currentLevel);
|
|||
|
|
this.writerOptions.state = WriterState.InsideTag;
|
|||
|
|
} else {
|
|||
|
|
this.writerOptions.state = WriterState.OpenTag;
|
|||
|
|
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + "<!DOCTYPE " + node.rootNodeName;
|
|||
|
|
if (node.pubID && node.sysID) {
|
|||
|
|
chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
|
|||
|
|
} else if (node.sysID) {
|
|||
|
|
chunk += ' SYSTEM "' + node.sysID + '"';
|
|||
|
|
}
|
|||
|
|
if (node.children) {
|
|||
|
|
chunk += " [";
|
|||
|
|
this.writerOptions.state = WriterState.InsideTag;
|
|||
|
|
} else {
|
|||
|
|
this.writerOptions.state = WriterState.CloseTag;
|
|||
|
|
chunk += ">";
|
|||
|
|
}
|
|||
|
|
chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
|
|||
|
|
}
|
|||
|
|
this.onData(chunk, this.currentLevel);
|
|||
|
|
return node.isOpen = true;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.closeNode = function(node) {
|
|||
|
|
var chunk;
|
|||
|
|
if (!node.isClosed) {
|
|||
|
|
chunk = "";
|
|||
|
|
this.writerOptions.state = WriterState.CloseTag;
|
|||
|
|
if (node.type === NodeType.Element) {
|
|||
|
|
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + "</" + node.name + ">" + this.writer.endline(node, this.writerOptions, this.currentLevel);
|
|||
|
|
} else {
|
|||
|
|
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + "]>" + this.writer.endline(node, this.writerOptions, this.currentLevel);
|
|||
|
|
}
|
|||
|
|
this.writerOptions.state = WriterState.None;
|
|||
|
|
this.onData(chunk, this.currentLevel);
|
|||
|
|
return node.isClosed = true;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.onData = function(chunk, level) {
|
|||
|
|
this.documentStarted = true;
|
|||
|
|
return this.onDataCallback(chunk, level + 1);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.onEnd = function() {
|
|||
|
|
this.documentCompleted = true;
|
|||
|
|
return this.onEndCallback();
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.debugInfo = function(name) {
|
|||
|
|
if (name == null) {
|
|||
|
|
return "";
|
|||
|
|
} else {
|
|||
|
|
return "node: <" + name + ">";
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.ele = function() {
|
|||
|
|
return this.element.apply(this, arguments);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.nod = function(name, attributes, text) {
|
|||
|
|
return this.node(name, attributes, text);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.txt = function(value) {
|
|||
|
|
return this.text(value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.dat = function(value) {
|
|||
|
|
return this.cdata(value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.com = function(value) {
|
|||
|
|
return this.comment(value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.ins = function(target, value) {
|
|||
|
|
return this.instruction(target, value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.dec = function(version, encoding, standalone) {
|
|||
|
|
return this.declaration(version, encoding, standalone);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.dtd = function(root, pubID, sysID) {
|
|||
|
|
return this.doctype(root, pubID, sysID);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.e = function(name, attributes, text) {
|
|||
|
|
return this.element(name, attributes, text);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.n = function(name, attributes, text) {
|
|||
|
|
return this.node(name, attributes, text);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.t = function(value) {
|
|||
|
|
return this.text(value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.d = function(value) {
|
|||
|
|
return this.cdata(value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.c = function(value) {
|
|||
|
|
return this.comment(value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.r = function(value) {
|
|||
|
|
return this.raw(value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.i = function(target, value) {
|
|||
|
|
return this.instruction(target, value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.att = function() {
|
|||
|
|
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
|
|||
|
|
return this.attList.apply(this, arguments);
|
|||
|
|
} else {
|
|||
|
|
return this.attribute.apply(this, arguments);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.a = function() {
|
|||
|
|
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
|
|||
|
|
return this.attList.apply(this, arguments);
|
|||
|
|
} else {
|
|||
|
|
return this.attribute.apply(this, arguments);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.ent = function(name, value) {
|
|||
|
|
return this.entity(name, value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.pent = function(name, value) {
|
|||
|
|
return this.pEntity(name, value);
|
|||
|
|
};
|
|||
|
|
XMLDocumentCB2.prototype.not = function(name, value) {
|
|||
|
|
return this.notation(name, value);
|
|||
|
|
};
|
|||
|
|
return XMLDocumentCB2;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/XMLStreamWriter.js
|
|||
|
|
var require_XMLStreamWriter = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/XMLStreamWriter.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, WriterState, XMLStreamWriter, XMLWriterBase, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
XMLWriterBase = require_XMLWriterBase();
|
|||
|
|
WriterState = require_WriterState();
|
|||
|
|
module2.exports = XMLStreamWriter = function(superClass) {
|
|||
|
|
extend(XMLStreamWriter2, superClass);
|
|||
|
|
function XMLStreamWriter2(stream, options) {
|
|||
|
|
this.stream = stream;
|
|||
|
|
XMLStreamWriter2.__super__.constructor.call(this, options);
|
|||
|
|
}
|
|||
|
|
XMLStreamWriter2.prototype.endline = function(node, options, level) {
|
|||
|
|
if (node.isLastRootNode && options.state === WriterState.CloseTag) {
|
|||
|
|
return "";
|
|||
|
|
} else {
|
|||
|
|
return XMLStreamWriter2.__super__.endline.call(this, node, options, level);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.document = function(doc, options) {
|
|||
|
|
var child, i, j, k, len, len1, ref, ref1, results;
|
|||
|
|
ref = doc.children;
|
|||
|
|
for (i = j = 0, len = ref.length; j < len; i = ++j) {
|
|||
|
|
child = ref[i];
|
|||
|
|
child.isLastRootNode = i === doc.children.length - 1;
|
|||
|
|
}
|
|||
|
|
options = this.filterOptions(options);
|
|||
|
|
ref1 = doc.children;
|
|||
|
|
results = [];
|
|||
|
|
for (k = 0, len1 = ref1.length; k < len1; k++) {
|
|||
|
|
child = ref1[k];
|
|||
|
|
results.push(this.writeChildNode(child, options, 0));
|
|||
|
|
}
|
|||
|
|
return results;
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.attribute = function(att, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.attribute.call(this, att, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.cdata = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.cdata.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.comment = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.comment.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.declaration = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.declaration.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.docType = function(node, options, level) {
|
|||
|
|
var child, j, len, ref;
|
|||
|
|
level || (level = 0);
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
this.stream.write(this.indent(node, options, level));
|
|||
|
|
this.stream.write("<!DOCTYPE " + node.root().name);
|
|||
|
|
if (node.pubID && node.sysID) {
|
|||
|
|
this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
|
|||
|
|
} else if (node.sysID) {
|
|||
|
|
this.stream.write(' SYSTEM "' + node.sysID + '"');
|
|||
|
|
}
|
|||
|
|
if (node.children.length > 0) {
|
|||
|
|
this.stream.write(" [");
|
|||
|
|
this.stream.write(this.endline(node, options, level));
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
ref = node.children;
|
|||
|
|
for (j = 0, len = ref.length; j < len; j++) {
|
|||
|
|
child = ref[j];
|
|||
|
|
this.writeChildNode(child, options, level + 1);
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
this.stream.write("]");
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
this.stream.write(options.spaceBeforeSlash + ">");
|
|||
|
|
this.stream.write(this.endline(node, options, level));
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
return this.closeNode(node, options, level);
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.element = function(node, options, level) {
|
|||
|
|
var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1;
|
|||
|
|
level || (level = 0);
|
|||
|
|
this.openNode(node, options, level);
|
|||
|
|
options.state = WriterState.OpenTag;
|
|||
|
|
this.stream.write(this.indent(node, options, level) + "<" + node.name);
|
|||
|
|
ref = node.attribs;
|
|||
|
|
for (name in ref) {
|
|||
|
|
if (!hasProp.call(ref, name))
|
|||
|
|
continue;
|
|||
|
|
att = ref[name];
|
|||
|
|
this.attribute(att, options, level);
|
|||
|
|
}
|
|||
|
|
childNodeCount = node.children.length;
|
|||
|
|
firstChildNode = childNodeCount === 0 ? null : node.children[0];
|
|||
|
|
if (childNodeCount === 0 || node.children.every(function(e) {
|
|||
|
|
return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === "";
|
|||
|
|
})) {
|
|||
|
|
if (options.allowEmpty) {
|
|||
|
|
this.stream.write(">");
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
this.stream.write("</" + node.name + ">");
|
|||
|
|
} else {
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
this.stream.write(options.spaceBeforeSlash + "/>");
|
|||
|
|
}
|
|||
|
|
} else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) {
|
|||
|
|
this.stream.write(">");
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
options.suppressPrettyCount++;
|
|||
|
|
prettySuppressed = true;
|
|||
|
|
this.writeChildNode(firstChildNode, options, level + 1);
|
|||
|
|
options.suppressPrettyCount--;
|
|||
|
|
prettySuppressed = false;
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
this.stream.write("</" + node.name + ">");
|
|||
|
|
} else {
|
|||
|
|
this.stream.write(">" + this.endline(node, options, level));
|
|||
|
|
options.state = WriterState.InsideTag;
|
|||
|
|
ref1 = node.children;
|
|||
|
|
for (j = 0, len = ref1.length; j < len; j++) {
|
|||
|
|
child = ref1[j];
|
|||
|
|
this.writeChildNode(child, options, level + 1);
|
|||
|
|
}
|
|||
|
|
options.state = WriterState.CloseTag;
|
|||
|
|
this.stream.write(this.indent(node, options, level) + "</" + node.name + ">");
|
|||
|
|
}
|
|||
|
|
this.stream.write(this.endline(node, options, level));
|
|||
|
|
options.state = WriterState.None;
|
|||
|
|
return this.closeNode(node, options, level);
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.processingInstruction = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.processingInstruction.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.raw = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.raw.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.text = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.text.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.dtdAttList = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.dtdAttList.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.dtdElement = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.dtdElement.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.dtdEntity = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.dtdEntity.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
XMLStreamWriter2.prototype.dtdNotation = function(node, options, level) {
|
|||
|
|
return this.stream.write(XMLStreamWriter2.__super__.dtdNotation.call(this, node, options, level));
|
|||
|
|
};
|
|||
|
|
return XMLStreamWriter2;
|
|||
|
|
}(XMLWriterBase);
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xmlbuilder/lib/index.js
|
|||
|
|
var require_lib = __commonJS({
|
|||
|
|
"node_modules/xmlbuilder/lib/index.js"(exports, module2) {
|
|||
|
|
(function() {
|
|||
|
|
var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
|
|||
|
|
ref = require_Utility(), assign = ref.assign, isFunction = ref.isFunction;
|
|||
|
|
XMLDOMImplementation = require_XMLDOMImplementation();
|
|||
|
|
XMLDocument = require_XMLDocument();
|
|||
|
|
XMLDocumentCB = require_XMLDocumentCB();
|
|||
|
|
XMLStringWriter = require_XMLStringWriter();
|
|||
|
|
XMLStreamWriter = require_XMLStreamWriter();
|
|||
|
|
NodeType = require_NodeType();
|
|||
|
|
WriterState = require_WriterState();
|
|||
|
|
module2.exports.create = function(name, xmldec, doctype, options) {
|
|||
|
|
var doc, root;
|
|||
|
|
if (name == null) {
|
|||
|
|
throw new Error("Root element needs a name.");
|
|||
|
|
}
|
|||
|
|
options = assign({}, xmldec, doctype, options);
|
|||
|
|
doc = new XMLDocument(options);
|
|||
|
|
root = doc.element(name);
|
|||
|
|
if (!options.headless) {
|
|||
|
|
doc.declaration(options);
|
|||
|
|
if (options.pubID != null || options.sysID != null) {
|
|||
|
|
doc.dtd(options);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return root;
|
|||
|
|
};
|
|||
|
|
module2.exports.begin = function(options, onData, onEnd) {
|
|||
|
|
var ref1;
|
|||
|
|
if (isFunction(options)) {
|
|||
|
|
ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
|
|||
|
|
options = {};
|
|||
|
|
}
|
|||
|
|
if (onData) {
|
|||
|
|
return new XMLDocumentCB(options, onData, onEnd);
|
|||
|
|
} else {
|
|||
|
|
return new XMLDocument(options);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
module2.exports.stringWriter = function(options) {
|
|||
|
|
return new XMLStringWriter(options);
|
|||
|
|
};
|
|||
|
|
module2.exports.streamWriter = function(stream, options) {
|
|||
|
|
return new XMLStreamWriter(stream, options);
|
|||
|
|
};
|
|||
|
|
module2.exports.implementation = new XMLDOMImplementation();
|
|||
|
|
module2.exports.nodeType = NodeType;
|
|||
|
|
module2.exports.writerState = WriterState;
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xml2js/lib/builder.js
|
|||
|
|
var require_builder = __commonJS({
|
|||
|
|
"node_modules/xml2js/lib/builder.js"(exports) {
|
|||
|
|
(function() {
|
|||
|
|
"use strict";
|
|||
|
|
var builder, defaults, escapeCDATA, requiresCDATA, wrapCDATA, hasProp = {}.hasOwnProperty;
|
|||
|
|
builder = require_lib();
|
|||
|
|
defaults = require_defaults().defaults;
|
|||
|
|
requiresCDATA = function(entry) {
|
|||
|
|
return typeof entry === "string" && (entry.indexOf("&") >= 0 || entry.indexOf(">") >= 0 || entry.indexOf("<") >= 0);
|
|||
|
|
};
|
|||
|
|
wrapCDATA = function(entry) {
|
|||
|
|
return "<![CDATA[" + escapeCDATA(entry) + "]]>";
|
|||
|
|
};
|
|||
|
|
escapeCDATA = function(entry) {
|
|||
|
|
return entry.replace("]]>", "]]]]><![CDATA[>");
|
|||
|
|
};
|
|||
|
|
exports.Builder = function() {
|
|||
|
|
function Builder(opts) {
|
|||
|
|
var key, ref, value;
|
|||
|
|
this.options = {};
|
|||
|
|
ref = defaults["0.2"];
|
|||
|
|
for (key in ref) {
|
|||
|
|
if (!hasProp.call(ref, key))
|
|||
|
|
continue;
|
|||
|
|
value = ref[key];
|
|||
|
|
this.options[key] = value;
|
|||
|
|
}
|
|||
|
|
for (key in opts) {
|
|||
|
|
if (!hasProp.call(opts, key))
|
|||
|
|
continue;
|
|||
|
|
value = opts[key];
|
|||
|
|
this.options[key] = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Builder.prototype.buildObject = function(rootObj) {
|
|||
|
|
var attrkey, charkey, render, rootElement, rootName;
|
|||
|
|
attrkey = this.options.attrkey;
|
|||
|
|
charkey = this.options.charkey;
|
|||
|
|
if (Object.keys(rootObj).length === 1 && this.options.rootName === defaults["0.2"].rootName) {
|
|||
|
|
rootName = Object.keys(rootObj)[0];
|
|||
|
|
rootObj = rootObj[rootName];
|
|||
|
|
} else {
|
|||
|
|
rootName = this.options.rootName;
|
|||
|
|
}
|
|||
|
|
render = function(_this) {
|
|||
|
|
return function(element, obj) {
|
|||
|
|
var attr, child, entry, index, key, value;
|
|||
|
|
if (typeof obj !== "object") {
|
|||
|
|
if (_this.options.cdata && requiresCDATA(obj)) {
|
|||
|
|
element.raw(wrapCDATA(obj));
|
|||
|
|
} else {
|
|||
|
|
element.txt(obj);
|
|||
|
|
}
|
|||
|
|
} else if (Array.isArray(obj)) {
|
|||
|
|
for (index in obj) {
|
|||
|
|
if (!hasProp.call(obj, index))
|
|||
|
|
continue;
|
|||
|
|
child = obj[index];
|
|||
|
|
for (key in child) {
|
|||
|
|
entry = child[key];
|
|||
|
|
element = render(element.ele(key), entry).up();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
for (key in obj) {
|
|||
|
|
if (!hasProp.call(obj, key))
|
|||
|
|
continue;
|
|||
|
|
child = obj[key];
|
|||
|
|
if (key === attrkey) {
|
|||
|
|
if (typeof child === "object") {
|
|||
|
|
for (attr in child) {
|
|||
|
|
value = child[attr];
|
|||
|
|
element = element.att(attr, value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else if (key === charkey) {
|
|||
|
|
if (_this.options.cdata && requiresCDATA(child)) {
|
|||
|
|
element = element.raw(wrapCDATA(child));
|
|||
|
|
} else {
|
|||
|
|
element = element.txt(child);
|
|||
|
|
}
|
|||
|
|
} else if (Array.isArray(child)) {
|
|||
|
|
for (index in child) {
|
|||
|
|
if (!hasProp.call(child, index))
|
|||
|
|
continue;
|
|||
|
|
entry = child[index];
|
|||
|
|
if (typeof entry === "string") {
|
|||
|
|
if (_this.options.cdata && requiresCDATA(entry)) {
|
|||
|
|
element = element.ele(key).raw(wrapCDATA(entry)).up();
|
|||
|
|
} else {
|
|||
|
|
element = element.ele(key, entry).up();
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
element = render(element.ele(key), entry).up();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else if (typeof child === "object") {
|
|||
|
|
element = render(element.ele(key), child).up();
|
|||
|
|
} else {
|
|||
|
|
if (typeof child === "string" && _this.options.cdata && requiresCDATA(child)) {
|
|||
|
|
element = element.ele(key).raw(wrapCDATA(child)).up();
|
|||
|
|
} else {
|
|||
|
|
if (child == null) {
|
|||
|
|
child = "";
|
|||
|
|
}
|
|||
|
|
element = element.ele(key, child.toString()).up();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return element;
|
|||
|
|
};
|
|||
|
|
}(this);
|
|||
|
|
rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
|
|||
|
|
headless: this.options.headless,
|
|||
|
|
allowSurrogateChars: this.options.allowSurrogateChars
|
|||
|
|
});
|
|||
|
|
return render(rootElement, rootObj).end(this.options.renderOpts);
|
|||
|
|
};
|
|||
|
|
return Builder;
|
|||
|
|
}();
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/sax/lib/sax.js
|
|||
|
|
var require_sax = __commonJS({
|
|||
|
|
"node_modules/sax/lib/sax.js"(exports) {
|
|||
|
|
(function(sax) {
|
|||
|
|
sax.parser = function(strict, opt) {
|
|||
|
|
return new SAXParser(strict, opt);
|
|||
|
|
};
|
|||
|
|
sax.SAXParser = SAXParser;
|
|||
|
|
sax.SAXStream = SAXStream;
|
|||
|
|
sax.createStream = createStream;
|
|||
|
|
sax.MAX_BUFFER_LENGTH = 64 * 1024;
|
|||
|
|
var buffers = [
|
|||
|
|
"comment",
|
|||
|
|
"sgmlDecl",
|
|||
|
|
"textNode",
|
|||
|
|
"tagName",
|
|||
|
|
"doctype",
|
|||
|
|
"procInstName",
|
|||
|
|
"procInstBody",
|
|||
|
|
"entity",
|
|||
|
|
"attribName",
|
|||
|
|
"attribValue",
|
|||
|
|
"cdata",
|
|||
|
|
"script"
|
|||
|
|
];
|
|||
|
|
sax.EVENTS = [
|
|||
|
|
"text",
|
|||
|
|
"processinginstruction",
|
|||
|
|
"sgmldeclaration",
|
|||
|
|
"doctype",
|
|||
|
|
"comment",
|
|||
|
|
"opentagstart",
|
|||
|
|
"attribute",
|
|||
|
|
"opentag",
|
|||
|
|
"closetag",
|
|||
|
|
"opencdata",
|
|||
|
|
"cdata",
|
|||
|
|
"closecdata",
|
|||
|
|
"error",
|
|||
|
|
"end",
|
|||
|
|
"ready",
|
|||
|
|
"script",
|
|||
|
|
"opennamespace",
|
|||
|
|
"closenamespace"
|
|||
|
|
];
|
|||
|
|
function SAXParser(strict, opt) {
|
|||
|
|
if (!(this instanceof SAXParser)) {
|
|||
|
|
return new SAXParser(strict, opt);
|
|||
|
|
}
|
|||
|
|
var parser = this;
|
|||
|
|
clearBuffers(parser);
|
|||
|
|
parser.q = parser.c = "";
|
|||
|
|
parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH;
|
|||
|
|
parser.opt = opt || {};
|
|||
|
|
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
|
|||
|
|
parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase";
|
|||
|
|
parser.tags = [];
|
|||
|
|
parser.closed = parser.closedRoot = parser.sawRoot = false;
|
|||
|
|
parser.tag = parser.error = null;
|
|||
|
|
parser.strict = !!strict;
|
|||
|
|
parser.noscript = !!(strict || parser.opt.noscript);
|
|||
|
|
parser.state = S.BEGIN;
|
|||
|
|
parser.strictEntities = parser.opt.strictEntities;
|
|||
|
|
parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES);
|
|||
|
|
parser.attribList = [];
|
|||
|
|
if (parser.opt.xmlns) {
|
|||
|
|
parser.ns = Object.create(rootNS);
|
|||
|
|
}
|
|||
|
|
parser.trackPosition = parser.opt.position !== false;
|
|||
|
|
if (parser.trackPosition) {
|
|||
|
|
parser.position = parser.line = parser.column = 0;
|
|||
|
|
}
|
|||
|
|
emit(parser, "onready");
|
|||
|
|
}
|
|||
|
|
if (!Object.create) {
|
|||
|
|
Object.create = function(o) {
|
|||
|
|
function F() {
|
|||
|
|
}
|
|||
|
|
F.prototype = o;
|
|||
|
|
var newf = new F();
|
|||
|
|
return newf;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
if (!Object.keys) {
|
|||
|
|
Object.keys = function(o) {
|
|||
|
|
var a = [];
|
|||
|
|
for (var i in o)
|
|||
|
|
if (o.hasOwnProperty(i))
|
|||
|
|
a.push(i);
|
|||
|
|
return a;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
function checkBufferLength(parser) {
|
|||
|
|
var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10);
|
|||
|
|
var maxActual = 0;
|
|||
|
|
for (var i = 0, l = buffers.length; i < l; i++) {
|
|||
|
|
var len = parser[buffers[i]].length;
|
|||
|
|
if (len > maxAllowed) {
|
|||
|
|
switch (buffers[i]) {
|
|||
|
|
case "textNode":
|
|||
|
|
closeText(parser);
|
|||
|
|
break;
|
|||
|
|
case "cdata":
|
|||
|
|
emitNode(parser, "oncdata", parser.cdata);
|
|||
|
|
parser.cdata = "";
|
|||
|
|
break;
|
|||
|
|
case "script":
|
|||
|
|
emitNode(parser, "onscript", parser.script);
|
|||
|
|
parser.script = "";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
error(parser, "Max buffer length exceeded: " + buffers[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
maxActual = Math.max(maxActual, len);
|
|||
|
|
}
|
|||
|
|
var m = sax.MAX_BUFFER_LENGTH - maxActual;
|
|||
|
|
parser.bufferCheckPosition = m + parser.position;
|
|||
|
|
}
|
|||
|
|
function clearBuffers(parser) {
|
|||
|
|
for (var i = 0, l = buffers.length; i < l; i++) {
|
|||
|
|
parser[buffers[i]] = "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
function flushBuffers(parser) {
|
|||
|
|
closeText(parser);
|
|||
|
|
if (parser.cdata !== "") {
|
|||
|
|
emitNode(parser, "oncdata", parser.cdata);
|
|||
|
|
parser.cdata = "";
|
|||
|
|
}
|
|||
|
|
if (parser.script !== "") {
|
|||
|
|
emitNode(parser, "onscript", parser.script);
|
|||
|
|
parser.script = "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
SAXParser.prototype = {
|
|||
|
|
end: function() {
|
|||
|
|
end2(this);
|
|||
|
|
},
|
|||
|
|
write: write2,
|
|||
|
|
resume: function() {
|
|||
|
|
this.error = null;
|
|||
|
|
return this;
|
|||
|
|
},
|
|||
|
|
close: function() {
|
|||
|
|
return this.write(null);
|
|||
|
|
},
|
|||
|
|
flush: function() {
|
|||
|
|
flushBuffers(this);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
var Stream;
|
|||
|
|
try {
|
|||
|
|
Stream = require("stream").Stream;
|
|||
|
|
} catch (ex) {
|
|||
|
|
Stream = function() {
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
if (!Stream)
|
|||
|
|
Stream = function() {
|
|||
|
|
};
|
|||
|
|
var streamWraps = sax.EVENTS.filter(function(ev) {
|
|||
|
|
return ev !== "error" && ev !== "end";
|
|||
|
|
});
|
|||
|
|
function createStream(strict, opt) {
|
|||
|
|
return new SAXStream(strict, opt);
|
|||
|
|
}
|
|||
|
|
function SAXStream(strict, opt) {
|
|||
|
|
if (!(this instanceof SAXStream)) {
|
|||
|
|
return new SAXStream(strict, opt);
|
|||
|
|
}
|
|||
|
|
Stream.apply(this);
|
|||
|
|
this._parser = new SAXParser(strict, opt);
|
|||
|
|
this.writable = true;
|
|||
|
|
this.readable = true;
|
|||
|
|
var me = this;
|
|||
|
|
this._parser.onend = function() {
|
|||
|
|
me.emit("end");
|
|||
|
|
};
|
|||
|
|
this._parser.onerror = function(er) {
|
|||
|
|
me.emit("error", er);
|
|||
|
|
me._parser.error = null;
|
|||
|
|
};
|
|||
|
|
this._decoder = null;
|
|||
|
|
streamWraps.forEach(function(ev) {
|
|||
|
|
Object.defineProperty(me, "on" + ev, {
|
|||
|
|
get: function() {
|
|||
|
|
return me._parser["on" + ev];
|
|||
|
|
},
|
|||
|
|
set: function(h) {
|
|||
|
|
if (!h) {
|
|||
|
|
me.removeAllListeners(ev);
|
|||
|
|
me._parser["on" + ev] = h;
|
|||
|
|
return h;
|
|||
|
|
}
|
|||
|
|
me.on(ev, h);
|
|||
|
|
},
|
|||
|
|
enumerable: true,
|
|||
|
|
configurable: false
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
SAXStream.prototype = Object.create(Stream.prototype, {
|
|||
|
|
constructor: {
|
|||
|
|
value: SAXStream
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
SAXStream.prototype.write = function(data) {
|
|||
|
|
if (typeof Buffer === "function" && typeof Buffer.isBuffer === "function" && Buffer.isBuffer(data)) {
|
|||
|
|
if (!this._decoder) {
|
|||
|
|
var SD = require("string_decoder").StringDecoder;
|
|||
|
|
this._decoder = new SD("utf8");
|
|||
|
|
}
|
|||
|
|
data = this._decoder.write(data);
|
|||
|
|
}
|
|||
|
|
this._parser.write(data.toString());
|
|||
|
|
this.emit("data", data);
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
SAXStream.prototype.end = function(chunk) {
|
|||
|
|
if (chunk && chunk.length) {
|
|||
|
|
this.write(chunk);
|
|||
|
|
}
|
|||
|
|
this._parser.end();
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
SAXStream.prototype.on = function(ev, handler) {
|
|||
|
|
var me = this;
|
|||
|
|
if (!me._parser["on" + ev] && streamWraps.indexOf(ev) !== -1) {
|
|||
|
|
me._parser["on" + ev] = function() {
|
|||
|
|
var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
|
|||
|
|
args.splice(0, 0, ev);
|
|||
|
|
me.emit.apply(me, args);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
return Stream.prototype.on.call(me, ev, handler);
|
|||
|
|
};
|
|||
|
|
var CDATA = "[CDATA[";
|
|||
|
|
var DOCTYPE = "DOCTYPE";
|
|||
|
|
var XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
|
|||
|
|
var XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
|
|||
|
|
var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE };
|
|||
|
|
var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
|||
|
|
var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|||
|
|
var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
|||
|
|
var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|||
|
|
function isWhitespace(c) {
|
|||
|
|
return c === " " || c === "\n" || c === "\r" || c === " ";
|
|||
|
|
}
|
|||
|
|
function isQuote(c) {
|
|||
|
|
return c === '"' || c === "'";
|
|||
|
|
}
|
|||
|
|
function isAttribEnd(c) {
|
|||
|
|
return c === ">" || isWhitespace(c);
|
|||
|
|
}
|
|||
|
|
function isMatch(regex, c) {
|
|||
|
|
return regex.test(c);
|
|||
|
|
}
|
|||
|
|
function notMatch(regex, c) {
|
|||
|
|
return !isMatch(regex, c);
|
|||
|
|
}
|
|||
|
|
var S = 0;
|
|||
|
|
sax.STATE = {
|
|||
|
|
BEGIN: S++,
|
|||
|
|
// leading byte order mark or whitespace
|
|||
|
|
BEGIN_WHITESPACE: S++,
|
|||
|
|
// leading whitespace
|
|||
|
|
TEXT: S++,
|
|||
|
|
// general stuff
|
|||
|
|
TEXT_ENTITY: S++,
|
|||
|
|
// & and such.
|
|||
|
|
OPEN_WAKA: S++,
|
|||
|
|
// <
|
|||
|
|
SGML_DECL: S++,
|
|||
|
|
// <!BLARG
|
|||
|
|
SGML_DECL_QUOTED: S++,
|
|||
|
|
// <!BLARG foo "bar
|
|||
|
|
DOCTYPE: S++,
|
|||
|
|
// <!DOCTYPE
|
|||
|
|
DOCTYPE_QUOTED: S++,
|
|||
|
|
// <!DOCTYPE "//blah
|
|||
|
|
DOCTYPE_DTD: S++,
|
|||
|
|
// <!DOCTYPE "//blah" [ ...
|
|||
|
|
DOCTYPE_DTD_QUOTED: S++,
|
|||
|
|
// <!DOCTYPE "//blah" [ "foo
|
|||
|
|
COMMENT_STARTING: S++,
|
|||
|
|
// <!-
|
|||
|
|
COMMENT: S++,
|
|||
|
|
// <!--
|
|||
|
|
COMMENT_ENDING: S++,
|
|||
|
|
// <!-- blah -
|
|||
|
|
COMMENT_ENDED: S++,
|
|||
|
|
// <!-- blah --
|
|||
|
|
CDATA: S++,
|
|||
|
|
// <![CDATA[ something
|
|||
|
|
CDATA_ENDING: S++,
|
|||
|
|
// ]
|
|||
|
|
CDATA_ENDING_2: S++,
|
|||
|
|
// ]]
|
|||
|
|
PROC_INST: S++,
|
|||
|
|
// <?hi
|
|||
|
|
PROC_INST_BODY: S++,
|
|||
|
|
// <?hi there
|
|||
|
|
PROC_INST_ENDING: S++,
|
|||
|
|
// <?hi "there" ?
|
|||
|
|
OPEN_TAG: S++,
|
|||
|
|
// <strong
|
|||
|
|
OPEN_TAG_SLASH: S++,
|
|||
|
|
// <strong /
|
|||
|
|
ATTRIB: S++,
|
|||
|
|
// <a
|
|||
|
|
ATTRIB_NAME: S++,
|
|||
|
|
// <a foo
|
|||
|
|
ATTRIB_NAME_SAW_WHITE: S++,
|
|||
|
|
// <a foo _
|
|||
|
|
ATTRIB_VALUE: S++,
|
|||
|
|
// <a foo=
|
|||
|
|
ATTRIB_VALUE_QUOTED: S++,
|
|||
|
|
// <a foo="bar
|
|||
|
|
ATTRIB_VALUE_CLOSED: S++,
|
|||
|
|
// <a foo="bar"
|
|||
|
|
ATTRIB_VALUE_UNQUOTED: S++,
|
|||
|
|
// <a foo=bar
|
|||
|
|
ATTRIB_VALUE_ENTITY_Q: S++,
|
|||
|
|
// <foo bar="""
|
|||
|
|
ATTRIB_VALUE_ENTITY_U: S++,
|
|||
|
|
// <foo bar="
|
|||
|
|
CLOSE_TAG: S++,
|
|||
|
|
// </a
|
|||
|
|
CLOSE_TAG_SAW_WHITE: S++,
|
|||
|
|
// </a >
|
|||
|
|
SCRIPT: S++,
|
|||
|
|
// <script> ...
|
|||
|
|
SCRIPT_ENDING: S++
|
|||
|
|
// <script> ... <
|
|||
|
|
};
|
|||
|
|
sax.XML_ENTITIES = {
|
|||
|
|
"amp": "&",
|
|||
|
|
"gt": ">",
|
|||
|
|
"lt": "<",
|
|||
|
|
"quot": '"',
|
|||
|
|
"apos": "'"
|
|||
|
|
};
|
|||
|
|
sax.ENTITIES = {
|
|||
|
|
"amp": "&",
|
|||
|
|
"gt": ">",
|
|||
|
|
"lt": "<",
|
|||
|
|
"quot": '"',
|
|||
|
|
"apos": "'",
|
|||
|
|
"AElig": 198,
|
|||
|
|
"Aacute": 193,
|
|||
|
|
"Acirc": 194,
|
|||
|
|
"Agrave": 192,
|
|||
|
|
"Aring": 197,
|
|||
|
|
"Atilde": 195,
|
|||
|
|
"Auml": 196,
|
|||
|
|
"Ccedil": 199,
|
|||
|
|
"ETH": 208,
|
|||
|
|
"Eacute": 201,
|
|||
|
|
"Ecirc": 202,
|
|||
|
|
"Egrave": 200,
|
|||
|
|
"Euml": 203,
|
|||
|
|
"Iacute": 205,
|
|||
|
|
"Icirc": 206,
|
|||
|
|
"Igrave": 204,
|
|||
|
|
"Iuml": 207,
|
|||
|
|
"Ntilde": 209,
|
|||
|
|
"Oacute": 211,
|
|||
|
|
"Ocirc": 212,
|
|||
|
|
"Ograve": 210,
|
|||
|
|
"Oslash": 216,
|
|||
|
|
"Otilde": 213,
|
|||
|
|
"Ouml": 214,
|
|||
|
|
"THORN": 222,
|
|||
|
|
"Uacute": 218,
|
|||
|
|
"Ucirc": 219,
|
|||
|
|
"Ugrave": 217,
|
|||
|
|
"Uuml": 220,
|
|||
|
|
"Yacute": 221,
|
|||
|
|
"aacute": 225,
|
|||
|
|
"acirc": 226,
|
|||
|
|
"aelig": 230,
|
|||
|
|
"agrave": 224,
|
|||
|
|
"aring": 229,
|
|||
|
|
"atilde": 227,
|
|||
|
|
"auml": 228,
|
|||
|
|
"ccedil": 231,
|
|||
|
|
"eacute": 233,
|
|||
|
|
"ecirc": 234,
|
|||
|
|
"egrave": 232,
|
|||
|
|
"eth": 240,
|
|||
|
|
"euml": 235,
|
|||
|
|
"iacute": 237,
|
|||
|
|
"icirc": 238,
|
|||
|
|
"igrave": 236,
|
|||
|
|
"iuml": 239,
|
|||
|
|
"ntilde": 241,
|
|||
|
|
"oacute": 243,
|
|||
|
|
"ocirc": 244,
|
|||
|
|
"ograve": 242,
|
|||
|
|
"oslash": 248,
|
|||
|
|
"otilde": 245,
|
|||
|
|
"ouml": 246,
|
|||
|
|
"szlig": 223,
|
|||
|
|
"thorn": 254,
|
|||
|
|
"uacute": 250,
|
|||
|
|
"ucirc": 251,
|
|||
|
|
"ugrave": 249,
|
|||
|
|
"uuml": 252,
|
|||
|
|
"yacute": 253,
|
|||
|
|
"yuml": 255,
|
|||
|
|
"copy": 169,
|
|||
|
|
"reg": 174,
|
|||
|
|
"nbsp": 160,
|
|||
|
|
"iexcl": 161,
|
|||
|
|
"cent": 162,
|
|||
|
|
"pound": 163,
|
|||
|
|
"curren": 164,
|
|||
|
|
"yen": 165,
|
|||
|
|
"brvbar": 166,
|
|||
|
|
"sect": 167,
|
|||
|
|
"uml": 168,
|
|||
|
|
"ordf": 170,
|
|||
|
|
"laquo": 171,
|
|||
|
|
"not": 172,
|
|||
|
|
"shy": 173,
|
|||
|
|
"macr": 175,
|
|||
|
|
"deg": 176,
|
|||
|
|
"plusmn": 177,
|
|||
|
|
"sup1": 185,
|
|||
|
|
"sup2": 178,
|
|||
|
|
"sup3": 179,
|
|||
|
|
"acute": 180,
|
|||
|
|
"micro": 181,
|
|||
|
|
"para": 182,
|
|||
|
|
"middot": 183,
|
|||
|
|
"cedil": 184,
|
|||
|
|
"ordm": 186,
|
|||
|
|
"raquo": 187,
|
|||
|
|
"frac14": 188,
|
|||
|
|
"frac12": 189,
|
|||
|
|
"frac34": 190,
|
|||
|
|
"iquest": 191,
|
|||
|
|
"times": 215,
|
|||
|
|
"divide": 247,
|
|||
|
|
"OElig": 338,
|
|||
|
|
"oelig": 339,
|
|||
|
|
"Scaron": 352,
|
|||
|
|
"scaron": 353,
|
|||
|
|
"Yuml": 376,
|
|||
|
|
"fnof": 402,
|
|||
|
|
"circ": 710,
|
|||
|
|
"tilde": 732,
|
|||
|
|
"Alpha": 913,
|
|||
|
|
"Beta": 914,
|
|||
|
|
"Gamma": 915,
|
|||
|
|
"Delta": 916,
|
|||
|
|
"Epsilon": 917,
|
|||
|
|
"Zeta": 918,
|
|||
|
|
"Eta": 919,
|
|||
|
|
"Theta": 920,
|
|||
|
|
"Iota": 921,
|
|||
|
|
"Kappa": 922,
|
|||
|
|
"Lambda": 923,
|
|||
|
|
"Mu": 924,
|
|||
|
|
"Nu": 925,
|
|||
|
|
"Xi": 926,
|
|||
|
|
"Omicron": 927,
|
|||
|
|
"Pi": 928,
|
|||
|
|
"Rho": 929,
|
|||
|
|
"Sigma": 931,
|
|||
|
|
"Tau": 932,
|
|||
|
|
"Upsilon": 933,
|
|||
|
|
"Phi": 934,
|
|||
|
|
"Chi": 935,
|
|||
|
|
"Psi": 936,
|
|||
|
|
"Omega": 937,
|
|||
|
|
"alpha": 945,
|
|||
|
|
"beta": 946,
|
|||
|
|
"gamma": 947,
|
|||
|
|
"delta": 948,
|
|||
|
|
"epsilon": 949,
|
|||
|
|
"zeta": 950,
|
|||
|
|
"eta": 951,
|
|||
|
|
"theta": 952,
|
|||
|
|
"iota": 953,
|
|||
|
|
"kappa": 954,
|
|||
|
|
"lambda": 955,
|
|||
|
|
"mu": 956,
|
|||
|
|
"nu": 957,
|
|||
|
|
"xi": 958,
|
|||
|
|
"omicron": 959,
|
|||
|
|
"pi": 960,
|
|||
|
|
"rho": 961,
|
|||
|
|
"sigmaf": 962,
|
|||
|
|
"sigma": 963,
|
|||
|
|
"tau": 964,
|
|||
|
|
"upsilon": 965,
|
|||
|
|
"phi": 966,
|
|||
|
|
"chi": 967,
|
|||
|
|
"psi": 968,
|
|||
|
|
"omega": 969,
|
|||
|
|
"thetasym": 977,
|
|||
|
|
"upsih": 978,
|
|||
|
|
"piv": 982,
|
|||
|
|
"ensp": 8194,
|
|||
|
|
"emsp": 8195,
|
|||
|
|
"thinsp": 8201,
|
|||
|
|
"zwnj": 8204,
|
|||
|
|
"zwj": 8205,
|
|||
|
|
"lrm": 8206,
|
|||
|
|
"rlm": 8207,
|
|||
|
|
"ndash": 8211,
|
|||
|
|
"mdash": 8212,
|
|||
|
|
"lsquo": 8216,
|
|||
|
|
"rsquo": 8217,
|
|||
|
|
"sbquo": 8218,
|
|||
|
|
"ldquo": 8220,
|
|||
|
|
"rdquo": 8221,
|
|||
|
|
"bdquo": 8222,
|
|||
|
|
"dagger": 8224,
|
|||
|
|
"Dagger": 8225,
|
|||
|
|
"bull": 8226,
|
|||
|
|
"hellip": 8230,
|
|||
|
|
"permil": 8240,
|
|||
|
|
"prime": 8242,
|
|||
|
|
"Prime": 8243,
|
|||
|
|
"lsaquo": 8249,
|
|||
|
|
"rsaquo": 8250,
|
|||
|
|
"oline": 8254,
|
|||
|
|
"frasl": 8260,
|
|||
|
|
"euro": 8364,
|
|||
|
|
"image": 8465,
|
|||
|
|
"weierp": 8472,
|
|||
|
|
"real": 8476,
|
|||
|
|
"trade": 8482,
|
|||
|
|
"alefsym": 8501,
|
|||
|
|
"larr": 8592,
|
|||
|
|
"uarr": 8593,
|
|||
|
|
"rarr": 8594,
|
|||
|
|
"darr": 8595,
|
|||
|
|
"harr": 8596,
|
|||
|
|
"crarr": 8629,
|
|||
|
|
"lArr": 8656,
|
|||
|
|
"uArr": 8657,
|
|||
|
|
"rArr": 8658,
|
|||
|
|
"dArr": 8659,
|
|||
|
|
"hArr": 8660,
|
|||
|
|
"forall": 8704,
|
|||
|
|
"part": 8706,
|
|||
|
|
"exist": 8707,
|
|||
|
|
"empty": 8709,
|
|||
|
|
"nabla": 8711,
|
|||
|
|
"isin": 8712,
|
|||
|
|
"notin": 8713,
|
|||
|
|
"ni": 8715,
|
|||
|
|
"prod": 8719,
|
|||
|
|
"sum": 8721,
|
|||
|
|
"minus": 8722,
|
|||
|
|
"lowast": 8727,
|
|||
|
|
"radic": 8730,
|
|||
|
|
"prop": 8733,
|
|||
|
|
"infin": 8734,
|
|||
|
|
"ang": 8736,
|
|||
|
|
"and": 8743,
|
|||
|
|
"or": 8744,
|
|||
|
|
"cap": 8745,
|
|||
|
|
"cup": 8746,
|
|||
|
|
"int": 8747,
|
|||
|
|
"there4": 8756,
|
|||
|
|
"sim": 8764,
|
|||
|
|
"cong": 8773,
|
|||
|
|
"asymp": 8776,
|
|||
|
|
"ne": 8800,
|
|||
|
|
"equiv": 8801,
|
|||
|
|
"le": 8804,
|
|||
|
|
"ge": 8805,
|
|||
|
|
"sub": 8834,
|
|||
|
|
"sup": 8835,
|
|||
|
|
"nsub": 8836,
|
|||
|
|
"sube": 8838,
|
|||
|
|
"supe": 8839,
|
|||
|
|
"oplus": 8853,
|
|||
|
|
"otimes": 8855,
|
|||
|
|
"perp": 8869,
|
|||
|
|
"sdot": 8901,
|
|||
|
|
"lceil": 8968,
|
|||
|
|
"rceil": 8969,
|
|||
|
|
"lfloor": 8970,
|
|||
|
|
"rfloor": 8971,
|
|||
|
|
"lang": 9001,
|
|||
|
|
"rang": 9002,
|
|||
|
|
"loz": 9674,
|
|||
|
|
"spades": 9824,
|
|||
|
|
"clubs": 9827,
|
|||
|
|
"hearts": 9829,
|
|||
|
|
"diams": 9830
|
|||
|
|
};
|
|||
|
|
Object.keys(sax.ENTITIES).forEach(function(key) {
|
|||
|
|
var e = sax.ENTITIES[key];
|
|||
|
|
var s2 = typeof e === "number" ? String.fromCharCode(e) : e;
|
|||
|
|
sax.ENTITIES[key] = s2;
|
|||
|
|
});
|
|||
|
|
for (var s in sax.STATE) {
|
|||
|
|
sax.STATE[sax.STATE[s]] = s;
|
|||
|
|
}
|
|||
|
|
S = sax.STATE;
|
|||
|
|
function emit(parser, event, data) {
|
|||
|
|
parser[event] && parser[event](data);
|
|||
|
|
}
|
|||
|
|
function emitNode(parser, nodeType, data) {
|
|||
|
|
if (parser.textNode)
|
|||
|
|
closeText(parser);
|
|||
|
|
emit(parser, nodeType, data);
|
|||
|
|
}
|
|||
|
|
function closeText(parser) {
|
|||
|
|
parser.textNode = textopts(parser.opt, parser.textNode);
|
|||
|
|
if (parser.textNode)
|
|||
|
|
emit(parser, "ontext", parser.textNode);
|
|||
|
|
parser.textNode = "";
|
|||
|
|
}
|
|||
|
|
function textopts(opt, text) {
|
|||
|
|
if (opt.trim)
|
|||
|
|
text = text.trim();
|
|||
|
|
if (opt.normalize)
|
|||
|
|
text = text.replace(/\s+/g, " ");
|
|||
|
|
return text;
|
|||
|
|
}
|
|||
|
|
function error(parser, er) {
|
|||
|
|
closeText(parser);
|
|||
|
|
if (parser.trackPosition) {
|
|||
|
|
er += "\nLine: " + parser.line + "\nColumn: " + parser.column + "\nChar: " + parser.c;
|
|||
|
|
}
|
|||
|
|
er = new Error(er);
|
|||
|
|
parser.error = er;
|
|||
|
|
emit(parser, "onerror", er);
|
|||
|
|
return parser;
|
|||
|
|
}
|
|||
|
|
function end2(parser) {
|
|||
|
|
if (parser.sawRoot && !parser.closedRoot)
|
|||
|
|
strictFail(parser, "Unclosed root tag");
|
|||
|
|
if (parser.state !== S.BEGIN && parser.state !== S.BEGIN_WHITESPACE && parser.state !== S.TEXT) {
|
|||
|
|
error(parser, "Unexpected end");
|
|||
|
|
}
|
|||
|
|
closeText(parser);
|
|||
|
|
parser.c = "";
|
|||
|
|
parser.closed = true;
|
|||
|
|
emit(parser, "onend");
|
|||
|
|
SAXParser.call(parser, parser.strict, parser.opt);
|
|||
|
|
return parser;
|
|||
|
|
}
|
|||
|
|
function strictFail(parser, message) {
|
|||
|
|
if (typeof parser !== "object" || !(parser instanceof SAXParser)) {
|
|||
|
|
throw new Error("bad call to strictFail");
|
|||
|
|
}
|
|||
|
|
if (parser.strict) {
|
|||
|
|
error(parser, message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
function newTag(parser) {
|
|||
|
|
if (!parser.strict)
|
|||
|
|
parser.tagName = parser.tagName[parser.looseCase]();
|
|||
|
|
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|||
|
|
var tag = parser.tag = { name: parser.tagName, attributes: {} };
|
|||
|
|
if (parser.opt.xmlns) {
|
|||
|
|
tag.ns = parent.ns;
|
|||
|
|
}
|
|||
|
|
parser.attribList.length = 0;
|
|||
|
|
emitNode(parser, "onopentagstart", tag);
|
|||
|
|
}
|
|||
|
|
function qname(name, attribute) {
|
|||
|
|
var i = name.indexOf(":");
|
|||
|
|
var qualName = i < 0 ? ["", name] : name.split(":");
|
|||
|
|
var prefix = qualName[0];
|
|||
|
|
var local = qualName[1];
|
|||
|
|
if (attribute && name === "xmlns") {
|
|||
|
|
prefix = "xmlns";
|
|||
|
|
local = "";
|
|||
|
|
}
|
|||
|
|
return { prefix, local };
|
|||
|
|
}
|
|||
|
|
function attrib(parser) {
|
|||
|
|
if (!parser.strict) {
|
|||
|
|
parser.attribName = parser.attribName[parser.looseCase]();
|
|||
|
|
}
|
|||
|
|
if (parser.attribList.indexOf(parser.attribName) !== -1 || parser.tag.attributes.hasOwnProperty(parser.attribName)) {
|
|||
|
|
parser.attribName = parser.attribValue = "";
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (parser.opt.xmlns) {
|
|||
|
|
var qn = qname(parser.attribName, true);
|
|||
|
|
var prefix = qn.prefix;
|
|||
|
|
var local = qn.local;
|
|||
|
|
if (prefix === "xmlns") {
|
|||
|
|
if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
|
|||
|
|
strictFail(
|
|||
|
|
parser,
|
|||
|
|
"xml: prefix must be bound to " + XML_NAMESPACE + "\nActual: " + parser.attribValue
|
|||
|
|
);
|
|||
|
|
} else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
|
|||
|
|
strictFail(
|
|||
|
|
parser,
|
|||
|
|
"xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\nActual: " + parser.attribValue
|
|||
|
|
);
|
|||
|
|
} else {
|
|||
|
|
var tag = parser.tag;
|
|||
|
|
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|||
|
|
if (tag.ns === parent.ns) {
|
|||
|
|
tag.ns = Object.create(parent.ns);
|
|||
|
|
}
|
|||
|
|
tag.ns[local] = parser.attribValue;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
parser.attribList.push([parser.attribName, parser.attribValue]);
|
|||
|
|
} else {
|
|||
|
|
parser.tag.attributes[parser.attribName] = parser.attribValue;
|
|||
|
|
emitNode(parser, "onattribute", {
|
|||
|
|
name: parser.attribName,
|
|||
|
|
value: parser.attribValue
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
parser.attribName = parser.attribValue = "";
|
|||
|
|
}
|
|||
|
|
function openTag(parser, selfClosing) {
|
|||
|
|
if (parser.opt.xmlns) {
|
|||
|
|
var tag = parser.tag;
|
|||
|
|
var qn = qname(parser.tagName);
|
|||
|
|
tag.prefix = qn.prefix;
|
|||
|
|
tag.local = qn.local;
|
|||
|
|
tag.uri = tag.ns[qn.prefix] || "";
|
|||
|
|
if (tag.prefix && !tag.uri) {
|
|||
|
|
strictFail(parser, "Unbound namespace prefix: " + JSON.stringify(parser.tagName));
|
|||
|
|
tag.uri = qn.prefix;
|
|||
|
|
}
|
|||
|
|
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|||
|
|
if (tag.ns && parent.ns !== tag.ns) {
|
|||
|
|
Object.keys(tag.ns).forEach(function(p) {
|
|||
|
|
emitNode(parser, "onopennamespace", {
|
|||
|
|
prefix: p,
|
|||
|
|
uri: tag.ns[p]
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
for (var i = 0, l = parser.attribList.length; i < l; i++) {
|
|||
|
|
var nv = parser.attribList[i];
|
|||
|
|
var name = nv[0];
|
|||
|
|
var value = nv[1];
|
|||
|
|
var qualName = qname(name, true);
|
|||
|
|
var prefix = qualName.prefix;
|
|||
|
|
var local = qualName.local;
|
|||
|
|
var uri = prefix === "" ? "" : tag.ns[prefix] || "";
|
|||
|
|
var a = {
|
|||
|
|
name,
|
|||
|
|
value,
|
|||
|
|
prefix,
|
|||
|
|
local,
|
|||
|
|
uri
|
|||
|
|
};
|
|||
|
|
if (prefix && prefix !== "xmlns" && !uri) {
|
|||
|
|
strictFail(parser, "Unbound namespace prefix: " + JSON.stringify(prefix));
|
|||
|
|
a.uri = prefix;
|
|||
|
|
}
|
|||
|
|
parser.tag.attributes[name] = a;
|
|||
|
|
emitNode(parser, "onattribute", a);
|
|||
|
|
}
|
|||
|
|
parser.attribList.length = 0;
|
|||
|
|
}
|
|||
|
|
parser.tag.isSelfClosing = !!selfClosing;
|
|||
|
|
parser.sawRoot = true;
|
|||
|
|
parser.tags.push(parser.tag);
|
|||
|
|
emitNode(parser, "onopentag", parser.tag);
|
|||
|
|
if (!selfClosing) {
|
|||
|
|
if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
|
|||
|
|
parser.state = S.SCRIPT;
|
|||
|
|
} else {
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
}
|
|||
|
|
parser.tag = null;
|
|||
|
|
parser.tagName = "";
|
|||
|
|
}
|
|||
|
|
parser.attribName = parser.attribValue = "";
|
|||
|
|
parser.attribList.length = 0;
|
|||
|
|
}
|
|||
|
|
function closeTag(parser) {
|
|||
|
|
if (!parser.tagName) {
|
|||
|
|
strictFail(parser, "Weird empty close tag.");
|
|||
|
|
parser.textNode += "</>";
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (parser.script) {
|
|||
|
|
if (parser.tagName !== "script") {
|
|||
|
|
parser.script += "</" + parser.tagName + ">";
|
|||
|
|
parser.tagName = "";
|
|||
|
|
parser.state = S.SCRIPT;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
emitNode(parser, "onscript", parser.script);
|
|||
|
|
parser.script = "";
|
|||
|
|
}
|
|||
|
|
var t = parser.tags.length;
|
|||
|
|
var tagName = parser.tagName;
|
|||
|
|
if (!parser.strict) {
|
|||
|
|
tagName = tagName[parser.looseCase]();
|
|||
|
|
}
|
|||
|
|
var closeTo = tagName;
|
|||
|
|
while (t--) {
|
|||
|
|
var close = parser.tags[t];
|
|||
|
|
if (close.name !== closeTo) {
|
|||
|
|
strictFail(parser, "Unexpected close tag");
|
|||
|
|
} else {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (t < 0) {
|
|||
|
|
strictFail(parser, "Unmatched closing tag: " + parser.tagName);
|
|||
|
|
parser.textNode += "</" + parser.tagName + ">";
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
parser.tagName = tagName;
|
|||
|
|
var s2 = parser.tags.length;
|
|||
|
|
while (s2-- > t) {
|
|||
|
|
var tag = parser.tag = parser.tags.pop();
|
|||
|
|
parser.tagName = parser.tag.name;
|
|||
|
|
emitNode(parser, "onclosetag", parser.tagName);
|
|||
|
|
var x = {};
|
|||
|
|
for (var i in tag.ns) {
|
|||
|
|
x[i] = tag.ns[i];
|
|||
|
|
}
|
|||
|
|
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|||
|
|
if (parser.opt.xmlns && tag.ns !== parent.ns) {
|
|||
|
|
Object.keys(tag.ns).forEach(function(p) {
|
|||
|
|
var n = tag.ns[p];
|
|||
|
|
emitNode(parser, "onclosenamespace", { prefix: p, uri: n });
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (t === 0)
|
|||
|
|
parser.closedRoot = true;
|
|||
|
|
parser.tagName = parser.attribValue = parser.attribName = "";
|
|||
|
|
parser.attribList.length = 0;
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
}
|
|||
|
|
function parseEntity(parser) {
|
|||
|
|
var entity = parser.entity;
|
|||
|
|
var entityLC = entity.toLowerCase();
|
|||
|
|
var num;
|
|||
|
|
var numStr = "";
|
|||
|
|
if (parser.ENTITIES[entity]) {
|
|||
|
|
return parser.ENTITIES[entity];
|
|||
|
|
}
|
|||
|
|
if (parser.ENTITIES[entityLC]) {
|
|||
|
|
return parser.ENTITIES[entityLC];
|
|||
|
|
}
|
|||
|
|
entity = entityLC;
|
|||
|
|
if (entity.charAt(0) === "#") {
|
|||
|
|
if (entity.charAt(1) === "x") {
|
|||
|
|
entity = entity.slice(2);
|
|||
|
|
num = parseInt(entity, 16);
|
|||
|
|
numStr = num.toString(16);
|
|||
|
|
} else {
|
|||
|
|
entity = entity.slice(1);
|
|||
|
|
num = parseInt(entity, 10);
|
|||
|
|
numStr = num.toString(10);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
entity = entity.replace(/^0+/, "");
|
|||
|
|
if (isNaN(num) || numStr.toLowerCase() !== entity) {
|
|||
|
|
strictFail(parser, "Invalid character entity");
|
|||
|
|
return "&" + parser.entity + ";";
|
|||
|
|
}
|
|||
|
|
return String.fromCodePoint(num);
|
|||
|
|
}
|
|||
|
|
function beginWhiteSpace(parser, c) {
|
|||
|
|
if (c === "<") {
|
|||
|
|
parser.state = S.OPEN_WAKA;
|
|||
|
|
parser.startTagPosition = parser.position;
|
|||
|
|
} else if (!isWhitespace(c)) {
|
|||
|
|
strictFail(parser, "Non-whitespace before first tag.");
|
|||
|
|
parser.textNode = c;
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
function charAt(chunk, i) {
|
|||
|
|
var result = "";
|
|||
|
|
if (i < chunk.length) {
|
|||
|
|
result = chunk.charAt(i);
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
function write2(chunk) {
|
|||
|
|
var parser = this;
|
|||
|
|
if (this.error) {
|
|||
|
|
throw this.error;
|
|||
|
|
}
|
|||
|
|
if (parser.closed) {
|
|||
|
|
return error(
|
|||
|
|
parser,
|
|||
|
|
"Cannot write after close. Assign an onready handler."
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
if (chunk === null) {
|
|||
|
|
return end2(parser);
|
|||
|
|
}
|
|||
|
|
if (typeof chunk === "object") {
|
|||
|
|
chunk = chunk.toString();
|
|||
|
|
}
|
|||
|
|
var i = 0;
|
|||
|
|
var c = "";
|
|||
|
|
while (true) {
|
|||
|
|
c = charAt(chunk, i++);
|
|||
|
|
parser.c = c;
|
|||
|
|
if (!c) {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if (parser.trackPosition) {
|
|||
|
|
parser.position++;
|
|||
|
|
if (c === "\n") {
|
|||
|
|
parser.line++;
|
|||
|
|
parser.column = 0;
|
|||
|
|
} else {
|
|||
|
|
parser.column++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
switch (parser.state) {
|
|||
|
|
case S.BEGIN:
|
|||
|
|
parser.state = S.BEGIN_WHITESPACE;
|
|||
|
|
if (c === "\uFEFF") {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
beginWhiteSpace(parser, c);
|
|||
|
|
continue;
|
|||
|
|
case S.BEGIN_WHITESPACE:
|
|||
|
|
beginWhiteSpace(parser, c);
|
|||
|
|
continue;
|
|||
|
|
case S.TEXT:
|
|||
|
|
if (parser.sawRoot && !parser.closedRoot) {
|
|||
|
|
var starti = i - 1;
|
|||
|
|
while (c && c !== "<" && c !== "&") {
|
|||
|
|
c = charAt(chunk, i++);
|
|||
|
|
if (c && parser.trackPosition) {
|
|||
|
|
parser.position++;
|
|||
|
|
if (c === "\n") {
|
|||
|
|
parser.line++;
|
|||
|
|
parser.column = 0;
|
|||
|
|
} else {
|
|||
|
|
parser.column++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
parser.textNode += chunk.substring(starti, i - 1);
|
|||
|
|
}
|
|||
|
|
if (c === "<" && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
|
|||
|
|
parser.state = S.OPEN_WAKA;
|
|||
|
|
parser.startTagPosition = parser.position;
|
|||
|
|
} else {
|
|||
|
|
if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
|
|||
|
|
strictFail(parser, "Text data outside of root node.");
|
|||
|
|
}
|
|||
|
|
if (c === "&") {
|
|||
|
|
parser.state = S.TEXT_ENTITY;
|
|||
|
|
} else {
|
|||
|
|
parser.textNode += c;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.SCRIPT:
|
|||
|
|
if (c === "<") {
|
|||
|
|
parser.state = S.SCRIPT_ENDING;
|
|||
|
|
} else {
|
|||
|
|
parser.script += c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.SCRIPT_ENDING:
|
|||
|
|
if (c === "/") {
|
|||
|
|
parser.state = S.CLOSE_TAG;
|
|||
|
|
} else {
|
|||
|
|
parser.script += "<" + c;
|
|||
|
|
parser.state = S.SCRIPT;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.OPEN_WAKA:
|
|||
|
|
if (c === "!") {
|
|||
|
|
parser.state = S.SGML_DECL;
|
|||
|
|
parser.sgmlDecl = "";
|
|||
|
|
} else if (isWhitespace(c)) {
|
|||
|
|
} else if (isMatch(nameStart, c)) {
|
|||
|
|
parser.state = S.OPEN_TAG;
|
|||
|
|
parser.tagName = c;
|
|||
|
|
} else if (c === "/") {
|
|||
|
|
parser.state = S.CLOSE_TAG;
|
|||
|
|
parser.tagName = "";
|
|||
|
|
} else if (c === "?") {
|
|||
|
|
parser.state = S.PROC_INST;
|
|||
|
|
parser.procInstName = parser.procInstBody = "";
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Unencoded <");
|
|||
|
|
if (parser.startTagPosition + 1 < parser.position) {
|
|||
|
|
var pad = parser.position - parser.startTagPosition;
|
|||
|
|
c = new Array(pad).join(" ") + c;
|
|||
|
|
}
|
|||
|
|
parser.textNode += "<" + c;
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.SGML_DECL:
|
|||
|
|
if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
|
|||
|
|
emitNode(parser, "onopencdata");
|
|||
|
|
parser.state = S.CDATA;
|
|||
|
|
parser.sgmlDecl = "";
|
|||
|
|
parser.cdata = "";
|
|||
|
|
} else if (parser.sgmlDecl + c === "--") {
|
|||
|
|
parser.state = S.COMMENT;
|
|||
|
|
parser.comment = "";
|
|||
|
|
parser.sgmlDecl = "";
|
|||
|
|
} else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
|
|||
|
|
parser.state = S.DOCTYPE;
|
|||
|
|
if (parser.doctype || parser.sawRoot) {
|
|||
|
|
strictFail(
|
|||
|
|
parser,
|
|||
|
|
"Inappropriately located doctype declaration"
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
parser.doctype = "";
|
|||
|
|
parser.sgmlDecl = "";
|
|||
|
|
} else if (c === ">") {
|
|||
|
|
emitNode(parser, "onsgmldeclaration", parser.sgmlDecl);
|
|||
|
|
parser.sgmlDecl = "";
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
} else if (isQuote(c)) {
|
|||
|
|
parser.state = S.SGML_DECL_QUOTED;
|
|||
|
|
parser.sgmlDecl += c;
|
|||
|
|
} else {
|
|||
|
|
parser.sgmlDecl += c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.SGML_DECL_QUOTED:
|
|||
|
|
if (c === parser.q) {
|
|||
|
|
parser.state = S.SGML_DECL;
|
|||
|
|
parser.q = "";
|
|||
|
|
}
|
|||
|
|
parser.sgmlDecl += c;
|
|||
|
|
continue;
|
|||
|
|
case S.DOCTYPE:
|
|||
|
|
if (c === ">") {
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
emitNode(parser, "ondoctype", parser.doctype);
|
|||
|
|
parser.doctype = true;
|
|||
|
|
} else {
|
|||
|
|
parser.doctype += c;
|
|||
|
|
if (c === "[") {
|
|||
|
|
parser.state = S.DOCTYPE_DTD;
|
|||
|
|
} else if (isQuote(c)) {
|
|||
|
|
parser.state = S.DOCTYPE_QUOTED;
|
|||
|
|
parser.q = c;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.DOCTYPE_QUOTED:
|
|||
|
|
parser.doctype += c;
|
|||
|
|
if (c === parser.q) {
|
|||
|
|
parser.q = "";
|
|||
|
|
parser.state = S.DOCTYPE;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.DOCTYPE_DTD:
|
|||
|
|
parser.doctype += c;
|
|||
|
|
if (c === "]") {
|
|||
|
|
parser.state = S.DOCTYPE;
|
|||
|
|
} else if (isQuote(c)) {
|
|||
|
|
parser.state = S.DOCTYPE_DTD_QUOTED;
|
|||
|
|
parser.q = c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.DOCTYPE_DTD_QUOTED:
|
|||
|
|
parser.doctype += c;
|
|||
|
|
if (c === parser.q) {
|
|||
|
|
parser.state = S.DOCTYPE_DTD;
|
|||
|
|
parser.q = "";
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.COMMENT:
|
|||
|
|
if (c === "-") {
|
|||
|
|
parser.state = S.COMMENT_ENDING;
|
|||
|
|
} else {
|
|||
|
|
parser.comment += c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.COMMENT_ENDING:
|
|||
|
|
if (c === "-") {
|
|||
|
|
parser.state = S.COMMENT_ENDED;
|
|||
|
|
parser.comment = textopts(parser.opt, parser.comment);
|
|||
|
|
if (parser.comment) {
|
|||
|
|
emitNode(parser, "oncomment", parser.comment);
|
|||
|
|
}
|
|||
|
|
parser.comment = "";
|
|||
|
|
} else {
|
|||
|
|
parser.comment += "-" + c;
|
|||
|
|
parser.state = S.COMMENT;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.COMMENT_ENDED:
|
|||
|
|
if (c !== ">") {
|
|||
|
|
strictFail(parser, "Malformed comment");
|
|||
|
|
parser.comment += "--" + c;
|
|||
|
|
parser.state = S.COMMENT;
|
|||
|
|
} else {
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.CDATA:
|
|||
|
|
if (c === "]") {
|
|||
|
|
parser.state = S.CDATA_ENDING;
|
|||
|
|
} else {
|
|||
|
|
parser.cdata += c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.CDATA_ENDING:
|
|||
|
|
if (c === "]") {
|
|||
|
|
parser.state = S.CDATA_ENDING_2;
|
|||
|
|
} else {
|
|||
|
|
parser.cdata += "]" + c;
|
|||
|
|
parser.state = S.CDATA;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.CDATA_ENDING_2:
|
|||
|
|
if (c === ">") {
|
|||
|
|
if (parser.cdata) {
|
|||
|
|
emitNode(parser, "oncdata", parser.cdata);
|
|||
|
|
}
|
|||
|
|
emitNode(parser, "onclosecdata");
|
|||
|
|
parser.cdata = "";
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
} else if (c === "]") {
|
|||
|
|
parser.cdata += "]";
|
|||
|
|
} else {
|
|||
|
|
parser.cdata += "]]" + c;
|
|||
|
|
parser.state = S.CDATA;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.PROC_INST:
|
|||
|
|
if (c === "?") {
|
|||
|
|
parser.state = S.PROC_INST_ENDING;
|
|||
|
|
} else if (isWhitespace(c)) {
|
|||
|
|
parser.state = S.PROC_INST_BODY;
|
|||
|
|
} else {
|
|||
|
|
parser.procInstName += c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.PROC_INST_BODY:
|
|||
|
|
if (!parser.procInstBody && isWhitespace(c)) {
|
|||
|
|
continue;
|
|||
|
|
} else if (c === "?") {
|
|||
|
|
parser.state = S.PROC_INST_ENDING;
|
|||
|
|
} else {
|
|||
|
|
parser.procInstBody += c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.PROC_INST_ENDING:
|
|||
|
|
if (c === ">") {
|
|||
|
|
emitNode(parser, "onprocessinginstruction", {
|
|||
|
|
name: parser.procInstName,
|
|||
|
|
body: parser.procInstBody
|
|||
|
|
});
|
|||
|
|
parser.procInstName = parser.procInstBody = "";
|
|||
|
|
parser.state = S.TEXT;
|
|||
|
|
} else {
|
|||
|
|
parser.procInstBody += "?" + c;
|
|||
|
|
parser.state = S.PROC_INST_BODY;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.OPEN_TAG:
|
|||
|
|
if (isMatch(nameBody, c)) {
|
|||
|
|
parser.tagName += c;
|
|||
|
|
} else {
|
|||
|
|
newTag(parser);
|
|||
|
|
if (c === ">") {
|
|||
|
|
openTag(parser);
|
|||
|
|
} else if (c === "/") {
|
|||
|
|
parser.state = S.OPEN_TAG_SLASH;
|
|||
|
|
} else {
|
|||
|
|
if (!isWhitespace(c)) {
|
|||
|
|
strictFail(parser, "Invalid character in tag name");
|
|||
|
|
}
|
|||
|
|
parser.state = S.ATTRIB;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.OPEN_TAG_SLASH:
|
|||
|
|
if (c === ">") {
|
|||
|
|
openTag(parser, true);
|
|||
|
|
closeTag(parser);
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Forward-slash in opening tag not followed by >");
|
|||
|
|
parser.state = S.ATTRIB;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.ATTRIB:
|
|||
|
|
if (isWhitespace(c)) {
|
|||
|
|
continue;
|
|||
|
|
} else if (c === ">") {
|
|||
|
|
openTag(parser);
|
|||
|
|
} else if (c === "/") {
|
|||
|
|
parser.state = S.OPEN_TAG_SLASH;
|
|||
|
|
} else if (isMatch(nameStart, c)) {
|
|||
|
|
parser.attribName = c;
|
|||
|
|
parser.attribValue = "";
|
|||
|
|
parser.state = S.ATTRIB_NAME;
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Invalid attribute name");
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.ATTRIB_NAME:
|
|||
|
|
if (c === "=") {
|
|||
|
|
parser.state = S.ATTRIB_VALUE;
|
|||
|
|
} else if (c === ">") {
|
|||
|
|
strictFail(parser, "Attribute without value");
|
|||
|
|
parser.attribValue = parser.attribName;
|
|||
|
|
attrib(parser);
|
|||
|
|
openTag(parser);
|
|||
|
|
} else if (isWhitespace(c)) {
|
|||
|
|
parser.state = S.ATTRIB_NAME_SAW_WHITE;
|
|||
|
|
} else if (isMatch(nameBody, c)) {
|
|||
|
|
parser.attribName += c;
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Invalid attribute name");
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.ATTRIB_NAME_SAW_WHITE:
|
|||
|
|
if (c === "=") {
|
|||
|
|
parser.state = S.ATTRIB_VALUE;
|
|||
|
|
} else if (isWhitespace(c)) {
|
|||
|
|
continue;
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Attribute without value");
|
|||
|
|
parser.tag.attributes[parser.attribName] = "";
|
|||
|
|
parser.attribValue = "";
|
|||
|
|
emitNode(parser, "onattribute", {
|
|||
|
|
name: parser.attribName,
|
|||
|
|
value: ""
|
|||
|
|
});
|
|||
|
|
parser.attribName = "";
|
|||
|
|
if (c === ">") {
|
|||
|
|
openTag(parser);
|
|||
|
|
} else if (isMatch(nameStart, c)) {
|
|||
|
|
parser.attribName = c;
|
|||
|
|
parser.state = S.ATTRIB_NAME;
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Invalid attribute name");
|
|||
|
|
parser.state = S.ATTRIB;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.ATTRIB_VALUE:
|
|||
|
|
if (isWhitespace(c)) {
|
|||
|
|
continue;
|
|||
|
|
} else if (isQuote(c)) {
|
|||
|
|
parser.q = c;
|
|||
|
|
parser.state = S.ATTRIB_VALUE_QUOTED;
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Unquoted attribute value");
|
|||
|
|
parser.state = S.ATTRIB_VALUE_UNQUOTED;
|
|||
|
|
parser.attribValue = c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.ATTRIB_VALUE_QUOTED:
|
|||
|
|
if (c !== parser.q) {
|
|||
|
|
if (c === "&") {
|
|||
|
|
parser.state = S.ATTRIB_VALUE_ENTITY_Q;
|
|||
|
|
} else {
|
|||
|
|
parser.attribValue += c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
attrib(parser);
|
|||
|
|
parser.q = "";
|
|||
|
|
parser.state = S.ATTRIB_VALUE_CLOSED;
|
|||
|
|
continue;
|
|||
|
|
case S.ATTRIB_VALUE_CLOSED:
|
|||
|
|
if (isWhitespace(c)) {
|
|||
|
|
parser.state = S.ATTRIB;
|
|||
|
|
} else if (c === ">") {
|
|||
|
|
openTag(parser);
|
|||
|
|
} else if (c === "/") {
|
|||
|
|
parser.state = S.OPEN_TAG_SLASH;
|
|||
|
|
} else if (isMatch(nameStart, c)) {
|
|||
|
|
strictFail(parser, "No whitespace between attributes");
|
|||
|
|
parser.attribName = c;
|
|||
|
|
parser.attribValue = "";
|
|||
|
|
parser.state = S.ATTRIB_NAME;
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Invalid attribute name");
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.ATTRIB_VALUE_UNQUOTED:
|
|||
|
|
if (!isAttribEnd(c)) {
|
|||
|
|
if (c === "&") {
|
|||
|
|
parser.state = S.ATTRIB_VALUE_ENTITY_U;
|
|||
|
|
} else {
|
|||
|
|
parser.attribValue += c;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
attrib(parser);
|
|||
|
|
if (c === ">") {
|
|||
|
|
openTag(parser);
|
|||
|
|
} else {
|
|||
|
|
parser.state = S.ATTRIB;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.CLOSE_TAG:
|
|||
|
|
if (!parser.tagName) {
|
|||
|
|
if (isWhitespace(c)) {
|
|||
|
|
continue;
|
|||
|
|
} else if (notMatch(nameStart, c)) {
|
|||
|
|
if (parser.script) {
|
|||
|
|
parser.script += "</" + c;
|
|||
|
|
parser.state = S.SCRIPT;
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Invalid tagname in closing tag.");
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
parser.tagName = c;
|
|||
|
|
}
|
|||
|
|
} else if (c === ">") {
|
|||
|
|
closeTag(parser);
|
|||
|
|
} else if (isMatch(nameBody, c)) {
|
|||
|
|
parser.tagName += c;
|
|||
|
|
} else if (parser.script) {
|
|||
|
|
parser.script += "</" + parser.tagName;
|
|||
|
|
parser.tagName = "";
|
|||
|
|
parser.state = S.SCRIPT;
|
|||
|
|
} else {
|
|||
|
|
if (!isWhitespace(c)) {
|
|||
|
|
strictFail(parser, "Invalid tagname in closing tag");
|
|||
|
|
}
|
|||
|
|
parser.state = S.CLOSE_TAG_SAW_WHITE;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.CLOSE_TAG_SAW_WHITE:
|
|||
|
|
if (isWhitespace(c)) {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
if (c === ">") {
|
|||
|
|
closeTag(parser);
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Invalid characters in closing tag");
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
case S.TEXT_ENTITY:
|
|||
|
|
case S.ATTRIB_VALUE_ENTITY_Q:
|
|||
|
|
case S.ATTRIB_VALUE_ENTITY_U:
|
|||
|
|
var returnState;
|
|||
|
|
var buffer;
|
|||
|
|
switch (parser.state) {
|
|||
|
|
case S.TEXT_ENTITY:
|
|||
|
|
returnState = S.TEXT;
|
|||
|
|
buffer = "textNode";
|
|||
|
|
break;
|
|||
|
|
case S.ATTRIB_VALUE_ENTITY_Q:
|
|||
|
|
returnState = S.ATTRIB_VALUE_QUOTED;
|
|||
|
|
buffer = "attribValue";
|
|||
|
|
break;
|
|||
|
|
case S.ATTRIB_VALUE_ENTITY_U:
|
|||
|
|
returnState = S.ATTRIB_VALUE_UNQUOTED;
|
|||
|
|
buffer = "attribValue";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if (c === ";") {
|
|||
|
|
if (parser.opt.unparsedEntities) {
|
|||
|
|
var parsedEntity = parseEntity(parser);
|
|||
|
|
parser.entity = "";
|
|||
|
|
parser.state = returnState;
|
|||
|
|
parser.write(parsedEntity);
|
|||
|
|
} else {
|
|||
|
|
parser[buffer] += parseEntity(parser);
|
|||
|
|
parser.entity = "";
|
|||
|
|
parser.state = returnState;
|
|||
|
|
}
|
|||
|
|
} else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
|
|||
|
|
parser.entity += c;
|
|||
|
|
} else {
|
|||
|
|
strictFail(parser, "Invalid character in entity name");
|
|||
|
|
parser[buffer] += "&" + parser.entity + c;
|
|||
|
|
parser.entity = "";
|
|||
|
|
parser.state = returnState;
|
|||
|
|
}
|
|||
|
|
continue;
|
|||
|
|
default: {
|
|||
|
|
throw new Error(parser, "Unknown state: " + parser.state);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (parser.position >= parser.bufferCheckPosition) {
|
|||
|
|
checkBufferLength(parser);
|
|||
|
|
}
|
|||
|
|
return parser;
|
|||
|
|
}
|
|||
|
|
if (!String.fromCodePoint) {
|
|||
|
|
(function() {
|
|||
|
|
var stringFromCharCode = String.fromCharCode;
|
|||
|
|
var floor = Math.floor;
|
|||
|
|
var fromCodePoint = function() {
|
|||
|
|
var MAX_SIZE = 16384;
|
|||
|
|
var codeUnits = [];
|
|||
|
|
var highSurrogate;
|
|||
|
|
var lowSurrogate;
|
|||
|
|
var index = -1;
|
|||
|
|
var length = arguments.length;
|
|||
|
|
if (!length) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
var result = "";
|
|||
|
|
while (++index < length) {
|
|||
|
|
var codePoint = Number(arguments[index]);
|
|||
|
|
if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
|||
|
|
codePoint < 0 || // not a valid Unicode code point
|
|||
|
|
codePoint > 1114111 || // not a valid Unicode code point
|
|||
|
|
floor(codePoint) !== codePoint) {
|
|||
|
|
throw RangeError("Invalid code point: " + codePoint);
|
|||
|
|
}
|
|||
|
|
if (codePoint <= 65535) {
|
|||
|
|
codeUnits.push(codePoint);
|
|||
|
|
} else {
|
|||
|
|
codePoint -= 65536;
|
|||
|
|
highSurrogate = (codePoint >> 10) + 55296;
|
|||
|
|
lowSurrogate = codePoint % 1024 + 56320;
|
|||
|
|
codeUnits.push(highSurrogate, lowSurrogate);
|
|||
|
|
}
|
|||
|
|
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
|
|||
|
|
result += stringFromCharCode.apply(null, codeUnits);
|
|||
|
|
codeUnits.length = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
};
|
|||
|
|
if (Object.defineProperty) {
|
|||
|
|
Object.defineProperty(String, "fromCodePoint", {
|
|||
|
|
value: fromCodePoint,
|
|||
|
|
configurable: true,
|
|||
|
|
writable: true
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
String.fromCodePoint = fromCodePoint;
|
|||
|
|
}
|
|||
|
|
})();
|
|||
|
|
}
|
|||
|
|
})(typeof exports === "undefined" ? exports.sax = {} : exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xml2js/lib/bom.js
|
|||
|
|
var require_bom = __commonJS({
|
|||
|
|
"node_modules/xml2js/lib/bom.js"(exports) {
|
|||
|
|
(function() {
|
|||
|
|
"use strict";
|
|||
|
|
exports.stripBOM = function(str) {
|
|||
|
|
if (str[0] === "\uFEFF") {
|
|||
|
|
return str.substring(1);
|
|||
|
|
} else {
|
|||
|
|
return str;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xml2js/lib/processors.js
|
|||
|
|
var require_processors = __commonJS({
|
|||
|
|
"node_modules/xml2js/lib/processors.js"(exports) {
|
|||
|
|
(function() {
|
|||
|
|
"use strict";
|
|||
|
|
var prefixMatch;
|
|||
|
|
prefixMatch = new RegExp(/(?!xmlns)^.*:/);
|
|||
|
|
exports.normalize = function(str) {
|
|||
|
|
return str.toLowerCase();
|
|||
|
|
};
|
|||
|
|
exports.firstCharLowerCase = function(str) {
|
|||
|
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|||
|
|
};
|
|||
|
|
exports.stripPrefix = function(str) {
|
|||
|
|
return str.replace(prefixMatch, "");
|
|||
|
|
};
|
|||
|
|
exports.parseNumbers = function(str) {
|
|||
|
|
if (!isNaN(str)) {
|
|||
|
|
str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
|
|||
|
|
}
|
|||
|
|
return str;
|
|||
|
|
};
|
|||
|
|
exports.parseBooleans = function(str) {
|
|||
|
|
if (/^(?:true|false)$/i.test(str)) {
|
|||
|
|
str = str.toLowerCase() === "true";
|
|||
|
|
}
|
|||
|
|
return str;
|
|||
|
|
};
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xml2js/lib/parser.js
|
|||
|
|
var require_parser = __commonJS({
|
|||
|
|
"node_modules/xml2js/lib/parser.js"(exports) {
|
|||
|
|
(function() {
|
|||
|
|
"use strict";
|
|||
|
|
var bom, defaults, events, isEmpty, processItem, processors, sax, setImmediate, bind = function(fn2, me) {
|
|||
|
|
return function() {
|
|||
|
|
return fn2.apply(me, arguments);
|
|||
|
|
};
|
|||
|
|
}, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
sax = require_sax();
|
|||
|
|
events = require("events");
|
|||
|
|
bom = require_bom();
|
|||
|
|
processors = require_processors();
|
|||
|
|
setImmediate = require("timers").setImmediate;
|
|||
|
|
defaults = require_defaults().defaults;
|
|||
|
|
isEmpty = function(thing) {
|
|||
|
|
return typeof thing === "object" && thing != null && Object.keys(thing).length === 0;
|
|||
|
|
};
|
|||
|
|
processItem = function(processors2, item, key) {
|
|||
|
|
var i, len, process;
|
|||
|
|
for (i = 0, len = processors2.length; i < len; i++) {
|
|||
|
|
process = processors2[i];
|
|||
|
|
item = process(item, key);
|
|||
|
|
}
|
|||
|
|
return item;
|
|||
|
|
};
|
|||
|
|
exports.Parser = function(superClass) {
|
|||
|
|
extend(Parser2, superClass);
|
|||
|
|
function Parser2(opts) {
|
|||
|
|
this.parseStringPromise = bind(this.parseStringPromise, this);
|
|||
|
|
this.parseString = bind(this.parseString, this);
|
|||
|
|
this.reset = bind(this.reset, this);
|
|||
|
|
this.assignOrPush = bind(this.assignOrPush, this);
|
|||
|
|
this.processAsync = bind(this.processAsync, this);
|
|||
|
|
var key, ref, value;
|
|||
|
|
if (!(this instanceof exports.Parser)) {
|
|||
|
|
return new exports.Parser(opts);
|
|||
|
|
}
|
|||
|
|
this.options = {};
|
|||
|
|
ref = defaults["0.2"];
|
|||
|
|
for (key in ref) {
|
|||
|
|
if (!hasProp.call(ref, key))
|
|||
|
|
continue;
|
|||
|
|
value = ref[key];
|
|||
|
|
this.options[key] = value;
|
|||
|
|
}
|
|||
|
|
for (key in opts) {
|
|||
|
|
if (!hasProp.call(opts, key))
|
|||
|
|
continue;
|
|||
|
|
value = opts[key];
|
|||
|
|
this.options[key] = value;
|
|||
|
|
}
|
|||
|
|
if (this.options.xmlns) {
|
|||
|
|
this.options.xmlnskey = this.options.attrkey + "ns";
|
|||
|
|
}
|
|||
|
|
if (this.options.normalizeTags) {
|
|||
|
|
if (!this.options.tagNameProcessors) {
|
|||
|
|
this.options.tagNameProcessors = [];
|
|||
|
|
}
|
|||
|
|
this.options.tagNameProcessors.unshift(processors.normalize);
|
|||
|
|
}
|
|||
|
|
this.reset();
|
|||
|
|
}
|
|||
|
|
Parser2.prototype.processAsync = function() {
|
|||
|
|
var chunk, err;
|
|||
|
|
try {
|
|||
|
|
if (this.remaining.length <= this.options.chunkSize) {
|
|||
|
|
chunk = this.remaining;
|
|||
|
|
this.remaining = "";
|
|||
|
|
this.saxParser = this.saxParser.write(chunk);
|
|||
|
|
return this.saxParser.close();
|
|||
|
|
} else {
|
|||
|
|
chunk = this.remaining.substr(0, this.options.chunkSize);
|
|||
|
|
this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
|
|||
|
|
this.saxParser = this.saxParser.write(chunk);
|
|||
|
|
return setImmediate(this.processAsync);
|
|||
|
|
}
|
|||
|
|
} catch (error1) {
|
|||
|
|
err = error1;
|
|||
|
|
if (!this.saxParser.errThrown) {
|
|||
|
|
this.saxParser.errThrown = true;
|
|||
|
|
return this.emit(err);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
Parser2.prototype.assignOrPush = function(obj, key, newValue) {
|
|||
|
|
if (!(key in obj)) {
|
|||
|
|
if (!this.options.explicitArray) {
|
|||
|
|
return obj[key] = newValue;
|
|||
|
|
} else {
|
|||
|
|
return obj[key] = [newValue];
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
if (!(obj[key] instanceof Array)) {
|
|||
|
|
obj[key] = [obj[key]];
|
|||
|
|
}
|
|||
|
|
return obj[key].push(newValue);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
Parser2.prototype.reset = function() {
|
|||
|
|
var attrkey, charkey, ontext, stack;
|
|||
|
|
this.removeAllListeners();
|
|||
|
|
this.saxParser = sax.parser(this.options.strict, {
|
|||
|
|
trim: false,
|
|||
|
|
normalize: false,
|
|||
|
|
xmlns: this.options.xmlns
|
|||
|
|
});
|
|||
|
|
this.saxParser.errThrown = false;
|
|||
|
|
this.saxParser.onerror = function(_this) {
|
|||
|
|
return function(error) {
|
|||
|
|
_this.saxParser.resume();
|
|||
|
|
if (!_this.saxParser.errThrown) {
|
|||
|
|
_this.saxParser.errThrown = true;
|
|||
|
|
return _this.emit("error", error);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}(this);
|
|||
|
|
this.saxParser.onend = function(_this) {
|
|||
|
|
return function() {
|
|||
|
|
if (!_this.saxParser.ended) {
|
|||
|
|
_this.saxParser.ended = true;
|
|||
|
|
return _this.emit("end", _this.resultObject);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}(this);
|
|||
|
|
this.saxParser.ended = false;
|
|||
|
|
this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
|
|||
|
|
this.resultObject = null;
|
|||
|
|
stack = [];
|
|||
|
|
attrkey = this.options.attrkey;
|
|||
|
|
charkey = this.options.charkey;
|
|||
|
|
this.saxParser.onopentag = function(_this) {
|
|||
|
|
return function(node) {
|
|||
|
|
var key, newValue, obj, processedKey, ref;
|
|||
|
|
obj = /* @__PURE__ */ Object.create(null);
|
|||
|
|
obj[charkey] = "";
|
|||
|
|
if (!_this.options.ignoreAttrs) {
|
|||
|
|
ref = node.attributes;
|
|||
|
|
for (key in ref) {
|
|||
|
|
if (!hasProp.call(ref, key))
|
|||
|
|
continue;
|
|||
|
|
if (!(attrkey in obj) && !_this.options.mergeAttrs) {
|
|||
|
|
obj[attrkey] = /* @__PURE__ */ Object.create(null);
|
|||
|
|
}
|
|||
|
|
newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
|
|||
|
|
processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
|
|||
|
|
if (_this.options.mergeAttrs) {
|
|||
|
|
_this.assignOrPush(obj, processedKey, newValue);
|
|||
|
|
} else {
|
|||
|
|
obj[attrkey][processedKey] = newValue;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
|
|||
|
|
if (_this.options.xmlns) {
|
|||
|
|
obj[_this.options.xmlnskey] = {
|
|||
|
|
uri: node.uri,
|
|||
|
|
local: node.local
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
return stack.push(obj);
|
|||
|
|
};
|
|||
|
|
}(this);
|
|||
|
|
this.saxParser.onclosetag = function(_this) {
|
|||
|
|
return function() {
|
|||
|
|
var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
|
|||
|
|
obj = stack.pop();
|
|||
|
|
nodeName = obj["#name"];
|
|||
|
|
if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
|
|||
|
|
delete obj["#name"];
|
|||
|
|
}
|
|||
|
|
if (obj.cdata === true) {
|
|||
|
|
cdata = obj.cdata;
|
|||
|
|
delete obj.cdata;
|
|||
|
|
}
|
|||
|
|
s = stack[stack.length - 1];
|
|||
|
|
if (obj[charkey].match(/^\s*$/) && !cdata) {
|
|||
|
|
emptyStr = obj[charkey];
|
|||
|
|
delete obj[charkey];
|
|||
|
|
} else {
|
|||
|
|
if (_this.options.trim) {
|
|||
|
|
obj[charkey] = obj[charkey].trim();
|
|||
|
|
}
|
|||
|
|
if (_this.options.normalize) {
|
|||
|
|
obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
|
|||
|
|
}
|
|||
|
|
obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
|
|||
|
|
if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
|
|||
|
|
obj = obj[charkey];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (isEmpty(obj)) {
|
|||
|
|
if (typeof _this.options.emptyTag === "function") {
|
|||
|
|
obj = _this.options.emptyTag();
|
|||
|
|
} else {
|
|||
|
|
obj = _this.options.emptyTag !== "" ? _this.options.emptyTag : emptyStr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (_this.options.validator != null) {
|
|||
|
|
xpath = "/" + function() {
|
|||
|
|
var i, len, results;
|
|||
|
|
results = [];
|
|||
|
|
for (i = 0, len = stack.length; i < len; i++) {
|
|||
|
|
node = stack[i];
|
|||
|
|
results.push(node["#name"]);
|
|||
|
|
}
|
|||
|
|
return results;
|
|||
|
|
}().concat(nodeName).join("/");
|
|||
|
|
(function() {
|
|||
|
|
var err;
|
|||
|
|
try {
|
|||
|
|
return obj = _this.options.validator(xpath, s && s[nodeName], obj);
|
|||
|
|
} catch (error1) {
|
|||
|
|
err = error1;
|
|||
|
|
return _this.emit("error", err);
|
|||
|
|
}
|
|||
|
|
})();
|
|||
|
|
}
|
|||
|
|
if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === "object") {
|
|||
|
|
if (!_this.options.preserveChildrenOrder) {
|
|||
|
|
node = /* @__PURE__ */ Object.create(null);
|
|||
|
|
if (_this.options.attrkey in obj) {
|
|||
|
|
node[_this.options.attrkey] = obj[_this.options.attrkey];
|
|||
|
|
delete obj[_this.options.attrkey];
|
|||
|
|
}
|
|||
|
|
if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
|
|||
|
|
node[_this.options.charkey] = obj[_this.options.charkey];
|
|||
|
|
delete obj[_this.options.charkey];
|
|||
|
|
}
|
|||
|
|
if (Object.getOwnPropertyNames(obj).length > 0) {
|
|||
|
|
node[_this.options.childkey] = obj;
|
|||
|
|
}
|
|||
|
|
obj = node;
|
|||
|
|
} else if (s) {
|
|||
|
|
s[_this.options.childkey] = s[_this.options.childkey] || [];
|
|||
|
|
objClone = /* @__PURE__ */ Object.create(null);
|
|||
|
|
for (key in obj) {
|
|||
|
|
if (!hasProp.call(obj, key))
|
|||
|
|
continue;
|
|||
|
|
objClone[key] = obj[key];
|
|||
|
|
}
|
|||
|
|
s[_this.options.childkey].push(objClone);
|
|||
|
|
delete obj["#name"];
|
|||
|
|
if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
|
|||
|
|
obj = obj[charkey];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (stack.length > 0) {
|
|||
|
|
return _this.assignOrPush(s, nodeName, obj);
|
|||
|
|
} else {
|
|||
|
|
if (_this.options.explicitRoot) {
|
|||
|
|
old = obj;
|
|||
|
|
obj = /* @__PURE__ */ Object.create(null);
|
|||
|
|
obj[nodeName] = old;
|
|||
|
|
}
|
|||
|
|
_this.resultObject = obj;
|
|||
|
|
_this.saxParser.ended = true;
|
|||
|
|
return _this.emit("end", _this.resultObject);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}(this);
|
|||
|
|
ontext = function(_this) {
|
|||
|
|
return function(text) {
|
|||
|
|
var charChild, s;
|
|||
|
|
s = stack[stack.length - 1];
|
|||
|
|
if (s) {
|
|||
|
|
s[charkey] += text;
|
|||
|
|
if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, "").trim() !== "")) {
|
|||
|
|
s[_this.options.childkey] = s[_this.options.childkey] || [];
|
|||
|
|
charChild = {
|
|||
|
|
"#name": "__text__"
|
|||
|
|
};
|
|||
|
|
charChild[charkey] = text;
|
|||
|
|
if (_this.options.normalize) {
|
|||
|
|
charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
|
|||
|
|
}
|
|||
|
|
s[_this.options.childkey].push(charChild);
|
|||
|
|
}
|
|||
|
|
return s;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}(this);
|
|||
|
|
this.saxParser.ontext = ontext;
|
|||
|
|
return this.saxParser.oncdata = function(_this) {
|
|||
|
|
return function(text) {
|
|||
|
|
var s;
|
|||
|
|
s = ontext(text);
|
|||
|
|
if (s) {
|
|||
|
|
return s.cdata = true;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}(this);
|
|||
|
|
};
|
|||
|
|
Parser2.prototype.parseString = function(str, cb) {
|
|||
|
|
var err;
|
|||
|
|
if (cb != null && typeof cb === "function") {
|
|||
|
|
this.on("end", function(result) {
|
|||
|
|
this.reset();
|
|||
|
|
return cb(null, result);
|
|||
|
|
});
|
|||
|
|
this.on("error", function(err2) {
|
|||
|
|
this.reset();
|
|||
|
|
return cb(err2);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
try {
|
|||
|
|
str = str.toString();
|
|||
|
|
if (str.trim() === "") {
|
|||
|
|
this.emit("end", null);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
str = bom.stripBOM(str);
|
|||
|
|
if (this.options.async) {
|
|||
|
|
this.remaining = str;
|
|||
|
|
setImmediate(this.processAsync);
|
|||
|
|
return this.saxParser;
|
|||
|
|
}
|
|||
|
|
return this.saxParser.write(str).close();
|
|||
|
|
} catch (error1) {
|
|||
|
|
err = error1;
|
|||
|
|
if (!(this.saxParser.errThrown || this.saxParser.ended)) {
|
|||
|
|
this.emit("error", err);
|
|||
|
|
return this.saxParser.errThrown = true;
|
|||
|
|
} else if (this.saxParser.ended) {
|
|||
|
|
throw err;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
Parser2.prototype.parseStringPromise = function(str) {
|
|||
|
|
return new Promise(function(_this) {
|
|||
|
|
return function(resolve, reject) {
|
|||
|
|
return _this.parseString(str, function(err, value) {
|
|||
|
|
if (err) {
|
|||
|
|
return reject(err);
|
|||
|
|
} else {
|
|||
|
|
return resolve(value);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
}(this));
|
|||
|
|
};
|
|||
|
|
return Parser2;
|
|||
|
|
}(events);
|
|||
|
|
exports.parseString = function(str, a, b) {
|
|||
|
|
var cb, options, parser;
|
|||
|
|
if (b != null) {
|
|||
|
|
if (typeof b === "function") {
|
|||
|
|
cb = b;
|
|||
|
|
}
|
|||
|
|
if (typeof a === "object") {
|
|||
|
|
options = a;
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
if (typeof a === "function") {
|
|||
|
|
cb = a;
|
|||
|
|
}
|
|||
|
|
options = {};
|
|||
|
|
}
|
|||
|
|
parser = new exports.Parser(options);
|
|||
|
|
return parser.parseString(str, cb);
|
|||
|
|
};
|
|||
|
|
exports.parseStringPromise = function(str, a) {
|
|||
|
|
var options, parser;
|
|||
|
|
if (typeof a === "object") {
|
|||
|
|
options = a;
|
|||
|
|
}
|
|||
|
|
parser = new exports.Parser(options);
|
|||
|
|
return parser.parseStringPromise(str);
|
|||
|
|
};
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/xml2js/lib/xml2js.js
|
|||
|
|
var require_xml2js = __commonJS({
|
|||
|
|
"node_modules/xml2js/lib/xml2js.js"(exports) {
|
|||
|
|
(function() {
|
|||
|
|
"use strict";
|
|||
|
|
var builder, defaults, parser, processors, extend = function(child, parent) {
|
|||
|
|
for (var key in parent) {
|
|||
|
|
if (hasProp.call(parent, key))
|
|||
|
|
child[key] = parent[key];
|
|||
|
|
}
|
|||
|
|
function ctor() {
|
|||
|
|
this.constructor = child;
|
|||
|
|
}
|
|||
|
|
ctor.prototype = parent.prototype;
|
|||
|
|
child.prototype = new ctor();
|
|||
|
|
child.__super__ = parent.prototype;
|
|||
|
|
return child;
|
|||
|
|
}, hasProp = {}.hasOwnProperty;
|
|||
|
|
defaults = require_defaults();
|
|||
|
|
builder = require_builder();
|
|||
|
|
parser = require_parser();
|
|||
|
|
processors = require_processors();
|
|||
|
|
exports.defaults = defaults.defaults;
|
|||
|
|
exports.processors = processors;
|
|||
|
|
exports.ValidationError = function(superClass) {
|
|||
|
|
extend(ValidationError, superClass);
|
|||
|
|
function ValidationError(message) {
|
|||
|
|
this.message = message;
|
|||
|
|
}
|
|||
|
|
return ValidationError;
|
|||
|
|
}(Error);
|
|||
|
|
exports.Builder = builder.Builder;
|
|||
|
|
exports.Parser = parser.Parser;
|
|||
|
|
exports.parseString = parser.parseString;
|
|||
|
|
exports.parseStringPromise = parser.parseStringPromise;
|
|||
|
|
}).call(exports);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/rss-parser/lib/fields.js
|
|||
|
|
var require_fields = __commonJS({
|
|||
|
|
"node_modules/rss-parser/lib/fields.js"(exports, module2) {
|
|||
|
|
var fields = module2.exports = {};
|
|||
|
|
fields.feed = [
|
|||
|
|
["author", "creator"],
|
|||
|
|
["dc:publisher", "publisher"],
|
|||
|
|
["dc:creator", "creator"],
|
|||
|
|
["dc:source", "source"],
|
|||
|
|
["dc:title", "title"],
|
|||
|
|
["dc:type", "type"],
|
|||
|
|
"title",
|
|||
|
|
"description",
|
|||
|
|
"author",
|
|||
|
|
"pubDate",
|
|||
|
|
"webMaster",
|
|||
|
|
"managingEditor",
|
|||
|
|
"generator",
|
|||
|
|
"link",
|
|||
|
|
"language",
|
|||
|
|
"copyright",
|
|||
|
|
"lastBuildDate",
|
|||
|
|
"docs",
|
|||
|
|
"generator",
|
|||
|
|
"ttl",
|
|||
|
|
"rating",
|
|||
|
|
"skipHours",
|
|||
|
|
"skipDays"
|
|||
|
|
];
|
|||
|
|
fields.item = [
|
|||
|
|
["author", "creator"],
|
|||
|
|
["dc:creator", "creator"],
|
|||
|
|
["dc:date", "date"],
|
|||
|
|
["dc:language", "language"],
|
|||
|
|
["dc:rights", "rights"],
|
|||
|
|
["dc:source", "source"],
|
|||
|
|
["dc:title", "title"],
|
|||
|
|
"title",
|
|||
|
|
"link",
|
|||
|
|
"pubDate",
|
|||
|
|
"author",
|
|||
|
|
"summary",
|
|||
|
|
["content:encoded", "content:encoded", { includeSnippet: true }],
|
|||
|
|
"enclosure",
|
|||
|
|
"dc:creator",
|
|||
|
|
"dc:date",
|
|||
|
|
"comments"
|
|||
|
|
];
|
|||
|
|
var mapItunesField = function(f) {
|
|||
|
|
return ["itunes:" + f, f];
|
|||
|
|
};
|
|||
|
|
fields.podcastFeed = [
|
|||
|
|
"author",
|
|||
|
|
"subtitle",
|
|||
|
|
"summary",
|
|||
|
|
"explicit"
|
|||
|
|
].map(mapItunesField);
|
|||
|
|
fields.podcastItem = [
|
|||
|
|
"author",
|
|||
|
|
"subtitle",
|
|||
|
|
"summary",
|
|||
|
|
"explicit",
|
|||
|
|
"duration",
|
|||
|
|
"image",
|
|||
|
|
"episode",
|
|||
|
|
"image",
|
|||
|
|
"season",
|
|||
|
|
"keywords",
|
|||
|
|
"episodeType"
|
|||
|
|
].map(mapItunesField);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/entities/lib/maps/entities.json
|
|||
|
|
var require_entities = __commonJS({
|
|||
|
|
"node_modules/entities/lib/maps/entities.json"(exports, module2) {
|
|||
|
|
module2.exports = { Aacute: "\xC1", aacute: "\xE1", Abreve: "\u0102", abreve: "\u0103", ac: "\u223E", acd: "\u223F", acE: "\u223E\u0333", Acirc: "\xC2", acirc: "\xE2", acute: "\xB4", Acy: "\u0410", acy: "\u0430", AElig: "\xC6", aelig: "\xE6", af: "\u2061", Afr: "\u{1D504}", afr: "\u{1D51E}", Agrave: "\xC0", agrave: "\xE0", alefsym: "\u2135", aleph: "\u2135", Alpha: "\u0391", alpha: "\u03B1", Amacr: "\u0100", amacr: "\u0101", amalg: "\u2A3F", amp: "&", AMP: "&", andand: "\u2A55", And: "\u2A53", and: "\u2227", andd: "\u2A5C", andslope: "\u2A58", andv: "\u2A5A", ang: "\u2220", ange: "\u29A4", angle: "\u2220", angmsdaa: "\u29A8", angmsdab: "\u29A9", angmsdac: "\u29AA", angmsdad: "\u29AB", angmsdae: "\u29AC", angmsdaf: "\u29AD", angmsdag: "\u29AE", angmsdah: "\u29AF", angmsd: "\u2221", angrt: "\u221F", angrtvb: "\u22BE", angrtvbd: "\u299D", angsph: "\u2222", angst: "\xC5", angzarr: "\u237C", Aogon: "\u0104", aogon: "\u0105", Aopf: "\u{1D538}", aopf: "\u{1D552}", apacir: "\u2A6F", ap: "\u2248", apE: "\u2A70", ape: "\u224A", apid: "\u224B", apos: "'", ApplyFunction: "\u2061", approx: "\u2248", approxeq: "\u224A", Aring: "\xC5", aring: "\xE5", Ascr: "\u{1D49C}", ascr: "\u{1D4B6}", Assign: "\u2254", ast: "*", asymp: "\u2248", asympeq: "\u224D", Atilde: "\xC3", atilde: "\xE3", Auml: "\xC4", auml: "\xE4", awconint: "\u2233", awint: "\u2A11", backcong: "\u224C", backepsilon: "\u03F6", backprime: "\u2035", backsim: "\u223D", backsimeq: "\u22CD", Backslash: "\u2216", Barv: "\u2AE7", barvee: "\u22BD", barwed: "\u2305", Barwed: "\u2306", barwedge: "\u2305", bbrk: "\u23B5", bbrktbrk: "\u23B6", bcong: "\u224C", Bcy: "\u0411", bcy: "\u0431", bdquo: "\u201E", becaus: "\u2235", because: "\u2235", Because: "\u2235", bemptyv: "\u29B0", bepsi: "\u03F6", bernou: "\u212C", Bernoullis: "\u212C", Beta: "\u0392", beta: "\u03B2", beth: "\u2136", between: "\u226C", Bfr: "\u{1D505}", bfr: "\u{1D51F}", bigcap: "\u22C2", bigcirc: "\u25EF", bigcup: "\u22C3", bigodot: "\u2A00", bigoplus: "\u2A01", bigotimes: "\u2A02", bigsqcup: "\u2A06", bigstar: "\u2605", bigtriangledown: "\u25BD", bigtriangleup: "\u25B3", biguplus: "\u2A04", bigvee: "\u22C1", bigwedge: "\u22C0", bkarow: "\u290D", blacklozenge: "\u29EB", blacksquare: "\u25AA", blacktriangle: "\u25B4", blacktriangledown: "\u25BE", blacktriangleleft: "\u25C2", blacktriangleright: "\u25B8", blank: "\u2423", blk12: "\u2592", blk14: "\u2591", blk34: "\u2593", block: "\u2588", bne: "=\u20E5", bnequiv: "\u2261\u20E5", bNot: "\u2AED", bnot: "\u2310", Bopf: "\u{1D539}", bopf: "\u{1D553}", bot: "\u22A5", bottom: "\u22A5", bowtie: "\u22C8", boxbox: "\u29C9", boxdl: "\u2510", boxdL: "\u2555", boxDl: "\u2556", boxDL: "\u2557", boxdr: "\u250C", boxdR: "\u2552", boxDr: "\u2553", boxDR: "\u2554", boxh: "\u2500", boxH: "\u2550", boxhd: "\u252C", boxHd: "\u2564", boxhD: "\u2565", boxHD: "\u2566", boxhu: "\u2534", boxHu: "\u2567", boxhU: "\u2568", boxHU: "\u2569", boxminus: "\u229F", boxplus: "\u229E", boxtimes: "\u22A0", boxul: "\u2518", boxuL: "\u255B", boxUl: "\u255C", boxUL: "\u255D", boxur: "\u2514", boxuR: "\u2558", boxUr: "\u2559", boxUR: "\u255A", boxv: "\u2502", boxV: "\u2551", boxvh: "\u253C", boxvH: "\u256A", boxVh: "\u256B", boxVH: "\u256C", boxvl: "\u2524", boxvL: "\u2561", boxVl: "\u2562", boxVL: "\u2563", boxvr: "\u251C", boxvR: "\u255E", boxVr: "\u255F", boxVR: "\u2560", bprime: "\u2035", breve: "\u02D8", Breve: "\u02D8", brvbar: "\xA6", bscr: "\u{1D4B7}", Bscr: "\u212C", bsemi: "\u204F", bsim: "\u223D", bsime: "\u22CD", bsolb: "\u29C5", bsol: "\\", bsolhsub: "\u27C8", bull: "\u2022", bullet: "\u2022", bump: "\u224E", bumpE: "\u2AAE", bumpe: "\u224F", Bumpeq: "\u224E", bumpeq: "\u224F", Cacute: "\u0106", cacute: "\u0107", capand: "\u2A44", capbrcup: "\u2A49", capcap: "\u2A4B", cap: "\u2229", Cap: "\u22D2", capcup: "\u2A47", capdot: "\u2A40", CapitalDifferentialD: "\u2145", caps: "\u2229\uFE00", caret: "\u2041", caron: "\u02C7", Cayleys: "\u212D", ccaps: "\u2A4D", Ccaron: "\u010C", ccaron: "\u010D", Ccedil: "\xC7", ccedil: "\xE7", Ccirc: "\u0108", ccirc: "\u0109", Cconint: "\u2230", ccups: "\u2A4C", ccup
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/entities/lib/maps/legacy.json
|
|||
|
|
var require_legacy = __commonJS({
|
|||
|
|
"node_modules/entities/lib/maps/legacy.json"(exports, module2) {
|
|||
|
|
module2.exports = { Aacute: "\xC1", aacute: "\xE1", Acirc: "\xC2", acirc: "\xE2", acute: "\xB4", AElig: "\xC6", aelig: "\xE6", Agrave: "\xC0", agrave: "\xE0", amp: "&", AMP: "&", Aring: "\xC5", aring: "\xE5", Atilde: "\xC3", atilde: "\xE3", Auml: "\xC4", auml: "\xE4", brvbar: "\xA6", Ccedil: "\xC7", ccedil: "\xE7", cedil: "\xB8", cent: "\xA2", copy: "\xA9", COPY: "\xA9", curren: "\xA4", deg: "\xB0", divide: "\xF7", Eacute: "\xC9", eacute: "\xE9", Ecirc: "\xCA", ecirc: "\xEA", Egrave: "\xC8", egrave: "\xE8", ETH: "\xD0", eth: "\xF0", Euml: "\xCB", euml: "\xEB", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE", gt: ">", GT: ">", Iacute: "\xCD", iacute: "\xED", Icirc: "\xCE", icirc: "\xEE", iexcl: "\xA1", Igrave: "\xCC", igrave: "\xEC", iquest: "\xBF", Iuml: "\xCF", iuml: "\xEF", laquo: "\xAB", lt: "<", LT: "<", macr: "\xAF", micro: "\xB5", middot: "\xB7", nbsp: "\xA0", not: "\xAC", Ntilde: "\xD1", ntilde: "\xF1", Oacute: "\xD3", oacute: "\xF3", Ocirc: "\xD4", ocirc: "\xF4", Ograve: "\xD2", ograve: "\xF2", ordf: "\xAA", ordm: "\xBA", Oslash: "\xD8", oslash: "\xF8", Otilde: "\xD5", otilde: "\xF5", Ouml: "\xD6", ouml: "\xF6", para: "\xB6", plusmn: "\xB1", pound: "\xA3", quot: '"', QUOT: '"', raquo: "\xBB", reg: "\xAE", REG: "\xAE", sect: "\xA7", shy: "\xAD", sup1: "\xB9", sup2: "\xB2", sup3: "\xB3", szlig: "\xDF", THORN: "\xDE", thorn: "\xFE", times: "\xD7", Uacute: "\xDA", uacute: "\xFA", Ucirc: "\xDB", ucirc: "\xFB", Ugrave: "\xD9", ugrave: "\xF9", uml: "\xA8", Uuml: "\xDC", uuml: "\xFC", Yacute: "\xDD", yacute: "\xFD", yen: "\xA5", yuml: "\xFF" };
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/entities/lib/maps/xml.json
|
|||
|
|
var require_xml = __commonJS({
|
|||
|
|
"node_modules/entities/lib/maps/xml.json"(exports, module2) {
|
|||
|
|
module2.exports = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' };
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/entities/lib/maps/decode.json
|
|||
|
|
var require_decode = __commonJS({
|
|||
|
|
"node_modules/entities/lib/maps/decode.json"(exports, module2) {
|
|||
|
|
module2.exports = { "0": 65533, "128": 8364, "130": 8218, "131": 402, "132": 8222, "133": 8230, "134": 8224, "135": 8225, "136": 710, "137": 8240, "138": 352, "139": 8249, "140": 338, "142": 381, "145": 8216, "146": 8217, "147": 8220, "148": 8221, "149": 8226, "150": 8211, "151": 8212, "152": 732, "153": 8482, "154": 353, "155": 8250, "156": 339, "158": 382, "159": 376 };
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/entities/lib/decode_codepoint.js
|
|||
|
|
var require_decode_codepoint = __commonJS({
|
|||
|
|
"node_modules/entities/lib/decode_codepoint.js"(exports) {
|
|||
|
|
"use strict";
|
|||
|
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
|
};
|
|||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
|
var decode_json_1 = __importDefault(require_decode());
|
|||
|
|
var fromCodePoint = (
|
|||
|
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|||
|
|
String.fromCodePoint || function(codePoint) {
|
|||
|
|
var output = "";
|
|||
|
|
if (codePoint > 65535) {
|
|||
|
|
codePoint -= 65536;
|
|||
|
|
output += String.fromCharCode(codePoint >>> 10 & 1023 | 55296);
|
|||
|
|
codePoint = 56320 | codePoint & 1023;
|
|||
|
|
}
|
|||
|
|
output += String.fromCharCode(codePoint);
|
|||
|
|
return output;
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
function decodeCodePoint(codePoint) {
|
|||
|
|
if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) {
|
|||
|
|
return "\uFFFD";
|
|||
|
|
}
|
|||
|
|
if (codePoint in decode_json_1.default) {
|
|||
|
|
codePoint = decode_json_1.default[codePoint];
|
|||
|
|
}
|
|||
|
|
return fromCodePoint(codePoint);
|
|||
|
|
}
|
|||
|
|
exports.default = decodeCodePoint;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/entities/lib/decode.js
|
|||
|
|
var require_decode2 = __commonJS({
|
|||
|
|
"node_modules/entities/lib/decode.js"(exports) {
|
|||
|
|
"use strict";
|
|||
|
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
|
};
|
|||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
|
exports.decodeHTML = exports.decodeHTMLStrict = exports.decodeXML = void 0;
|
|||
|
|
var entities_json_1 = __importDefault(require_entities());
|
|||
|
|
var legacy_json_1 = __importDefault(require_legacy());
|
|||
|
|
var xml_json_1 = __importDefault(require_xml());
|
|||
|
|
var decode_codepoint_1 = __importDefault(require_decode_codepoint());
|
|||
|
|
var strictEntityRe = /&(?:[a-zA-Z0-9]+|#[xX][\da-fA-F]+|#\d+);/g;
|
|||
|
|
exports.decodeXML = getStrictDecoder(xml_json_1.default);
|
|||
|
|
exports.decodeHTMLStrict = getStrictDecoder(entities_json_1.default);
|
|||
|
|
function getStrictDecoder(map) {
|
|||
|
|
var replace = getReplacer(map);
|
|||
|
|
return function(str) {
|
|||
|
|
return String(str).replace(strictEntityRe, replace);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
var sorter = function(a, b) {
|
|||
|
|
return a < b ? 1 : -1;
|
|||
|
|
};
|
|||
|
|
exports.decodeHTML = function() {
|
|||
|
|
var legacy = Object.keys(legacy_json_1.default).sort(sorter);
|
|||
|
|
var keys = Object.keys(entities_json_1.default).sort(sorter);
|
|||
|
|
for (var i = 0, j = 0; i < keys.length; i++) {
|
|||
|
|
if (legacy[j] === keys[i]) {
|
|||
|
|
keys[i] += ";?";
|
|||
|
|
j++;
|
|||
|
|
} else {
|
|||
|
|
keys[i] += ";";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var re = new RegExp("&(?:" + keys.join("|") + "|#[xX][\\da-fA-F]+;?|#\\d+;?)", "g");
|
|||
|
|
var replace = getReplacer(entities_json_1.default);
|
|||
|
|
function replacer(str) {
|
|||
|
|
if (str.substr(-1) !== ";")
|
|||
|
|
str += ";";
|
|||
|
|
return replace(str);
|
|||
|
|
}
|
|||
|
|
return function(str) {
|
|||
|
|
return String(str).replace(re, replacer);
|
|||
|
|
};
|
|||
|
|
}();
|
|||
|
|
function getReplacer(map) {
|
|||
|
|
return function replace(str) {
|
|||
|
|
if (str.charAt(1) === "#") {
|
|||
|
|
var secondChar = str.charAt(2);
|
|||
|
|
if (secondChar === "X" || secondChar === "x") {
|
|||
|
|
return decode_codepoint_1.default(parseInt(str.substr(3), 16));
|
|||
|
|
}
|
|||
|
|
return decode_codepoint_1.default(parseInt(str.substr(2), 10));
|
|||
|
|
}
|
|||
|
|
return map[str.slice(1, -1)] || str;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/entities/lib/encode.js
|
|||
|
|
var require_encode = __commonJS({
|
|||
|
|
"node_modules/entities/lib/encode.js"(exports) {
|
|||
|
|
"use strict";
|
|||
|
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|||
|
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|||
|
|
};
|
|||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
|
exports.escapeUTF8 = exports.escape = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.encodeXML = void 0;
|
|||
|
|
var xml_json_1 = __importDefault(require_xml());
|
|||
|
|
var inverseXML = getInverseObj(xml_json_1.default);
|
|||
|
|
var xmlReplacer = getInverseReplacer(inverseXML);
|
|||
|
|
exports.encodeXML = getASCIIEncoder(inverseXML);
|
|||
|
|
var entities_json_1 = __importDefault(require_entities());
|
|||
|
|
var inverseHTML = getInverseObj(entities_json_1.default);
|
|||
|
|
var htmlReplacer = getInverseReplacer(inverseHTML);
|
|||
|
|
exports.encodeHTML = getInverse(inverseHTML, htmlReplacer);
|
|||
|
|
exports.encodeNonAsciiHTML = getASCIIEncoder(inverseHTML);
|
|||
|
|
function getInverseObj(obj) {
|
|||
|
|
return Object.keys(obj).sort().reduce(function(inverse, name) {
|
|||
|
|
inverse[obj[name]] = "&" + name + ";";
|
|||
|
|
return inverse;
|
|||
|
|
}, {});
|
|||
|
|
}
|
|||
|
|
function getInverseReplacer(inverse) {
|
|||
|
|
var single = [];
|
|||
|
|
var multiple = [];
|
|||
|
|
for (var _i = 0, _a = Object.keys(inverse); _i < _a.length; _i++) {
|
|||
|
|
var k = _a[_i];
|
|||
|
|
if (k.length === 1) {
|
|||
|
|
single.push("\\" + k);
|
|||
|
|
} else {
|
|||
|
|
multiple.push(k);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
single.sort();
|
|||
|
|
for (var start2 = 0; start2 < single.length - 1; start2++) {
|
|||
|
|
var end2 = start2;
|
|||
|
|
while (end2 < single.length - 1 && single[end2].charCodeAt(1) + 1 === single[end2 + 1].charCodeAt(1)) {
|
|||
|
|
end2 += 1;
|
|||
|
|
}
|
|||
|
|
var count = 1 + end2 - start2;
|
|||
|
|
if (count < 3)
|
|||
|
|
continue;
|
|||
|
|
single.splice(start2, count, single[start2] + "-" + single[end2]);
|
|||
|
|
}
|
|||
|
|
multiple.unshift("[" + single.join("") + "]");
|
|||
|
|
return new RegExp(multiple.join("|"), "g");
|
|||
|
|
}
|
|||
|
|
var reNonASCII = /(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;
|
|||
|
|
var getCodePoint = (
|
|||
|
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|||
|
|
String.prototype.codePointAt != null ? (
|
|||
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|||
|
|
function(str) {
|
|||
|
|
return str.codePointAt(0);
|
|||
|
|
}
|
|||
|
|
) : (
|
|||
|
|
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|||
|
|
function(c) {
|
|||
|
|
return (c.charCodeAt(0) - 55296) * 1024 + c.charCodeAt(1) - 56320 + 65536;
|
|||
|
|
}
|
|||
|
|
)
|
|||
|
|
);
|
|||
|
|
function singleCharReplacer(c) {
|
|||
|
|
return "&#x" + (c.length > 1 ? getCodePoint(c) : c.charCodeAt(0)).toString(16).toUpperCase() + ";";
|
|||
|
|
}
|
|||
|
|
function getInverse(inverse, re) {
|
|||
|
|
return function(data) {
|
|||
|
|
return data.replace(re, function(name) {
|
|||
|
|
return inverse[name];
|
|||
|
|
}).replace(reNonASCII, singleCharReplacer);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
var reEscapeChars = new RegExp(xmlReplacer.source + "|" + reNonASCII.source, "g");
|
|||
|
|
function escape(data) {
|
|||
|
|
return data.replace(reEscapeChars, singleCharReplacer);
|
|||
|
|
}
|
|||
|
|
exports.escape = escape;
|
|||
|
|
function escapeUTF8(data) {
|
|||
|
|
return data.replace(xmlReplacer, singleCharReplacer);
|
|||
|
|
}
|
|||
|
|
exports.escapeUTF8 = escapeUTF8;
|
|||
|
|
function getASCIIEncoder(obj) {
|
|||
|
|
return function(data) {
|
|||
|
|
return data.replace(reEscapeChars, function(c) {
|
|||
|
|
return obj[c] || singleCharReplacer(c);
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/entities/lib/index.js
|
|||
|
|
var require_lib2 = __commonJS({
|
|||
|
|
"node_modules/entities/lib/index.js"(exports) {
|
|||
|
|
"use strict";
|
|||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|||
|
|
exports.decodeXMLStrict = exports.decodeHTML5Strict = exports.decodeHTML4Strict = exports.decodeHTML5 = exports.decodeHTML4 = exports.decodeHTMLStrict = exports.decodeHTML = exports.decodeXML = exports.encodeHTML5 = exports.encodeHTML4 = exports.escapeUTF8 = exports.escape = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.encodeXML = exports.encode = exports.decodeStrict = exports.decode = void 0;
|
|||
|
|
var decode_1 = require_decode2();
|
|||
|
|
var encode_1 = require_encode();
|
|||
|
|
function decode(data, level) {
|
|||
|
|
return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTML)(data);
|
|||
|
|
}
|
|||
|
|
exports.decode = decode;
|
|||
|
|
function decodeStrict(data, level) {
|
|||
|
|
return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTMLStrict)(data);
|
|||
|
|
}
|
|||
|
|
exports.decodeStrict = decodeStrict;
|
|||
|
|
function encode(data, level) {
|
|||
|
|
return (!level || level <= 0 ? encode_1.encodeXML : encode_1.encodeHTML)(data);
|
|||
|
|
}
|
|||
|
|
exports.encode = encode;
|
|||
|
|
var encode_2 = require_encode();
|
|||
|
|
Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function() {
|
|||
|
|
return encode_2.encodeXML;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "encodeHTML", { enumerable: true, get: function() {
|
|||
|
|
return encode_2.encodeHTML;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "encodeNonAsciiHTML", { enumerable: true, get: function() {
|
|||
|
|
return encode_2.encodeNonAsciiHTML;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "escape", { enumerable: true, get: function() {
|
|||
|
|
return encode_2.escape;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "escapeUTF8", { enumerable: true, get: function() {
|
|||
|
|
return encode_2.escapeUTF8;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "encodeHTML4", { enumerable: true, get: function() {
|
|||
|
|
return encode_2.encodeHTML;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "encodeHTML5", { enumerable: true, get: function() {
|
|||
|
|
return encode_2.encodeHTML;
|
|||
|
|
} });
|
|||
|
|
var decode_2 = require_decode2();
|
|||
|
|
Object.defineProperty(exports, "decodeXML", { enumerable: true, get: function() {
|
|||
|
|
return decode_2.decodeXML;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function() {
|
|||
|
|
return decode_2.decodeHTML;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "decodeHTMLStrict", { enumerable: true, get: function() {
|
|||
|
|
return decode_2.decodeHTMLStrict;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "decodeHTML4", { enumerable: true, get: function() {
|
|||
|
|
return decode_2.decodeHTML;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "decodeHTML5", { enumerable: true, get: function() {
|
|||
|
|
return decode_2.decodeHTML;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "decodeHTML4Strict", { enumerable: true, get: function() {
|
|||
|
|
return decode_2.decodeHTMLStrict;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "decodeHTML5Strict", { enumerable: true, get: function() {
|
|||
|
|
return decode_2.decodeHTMLStrict;
|
|||
|
|
} });
|
|||
|
|
Object.defineProperty(exports, "decodeXMLStrict", { enumerable: true, get: function() {
|
|||
|
|
return decode_2.decodeXML;
|
|||
|
|
} });
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/rss-parser/lib/utils.js
|
|||
|
|
var require_utils = __commonJS({
|
|||
|
|
"node_modules/rss-parser/lib/utils.js"(exports, module2) {
|
|||
|
|
var utils = module2.exports = {};
|
|||
|
|
var entities = require_lib2();
|
|||
|
|
var xml2js = require_xml2js();
|
|||
|
|
utils.stripHtml = function(str) {
|
|||
|
|
str = str.replace(/([^\n])<\/?(h|br|p|ul|ol|li|blockquote|section|table|tr|div)(?:.|\n)*?>([^\n])/gm, "$1\n$3");
|
|||
|
|
str = str.replace(/<(?:.|\n)*?>/gm, "");
|
|||
|
|
return str;
|
|||
|
|
};
|
|||
|
|
utils.getSnippet = function(str) {
|
|||
|
|
return entities.decodeHTML(utils.stripHtml(str)).trim();
|
|||
|
|
};
|
|||
|
|
utils.getLink = function(links, rel, fallbackIdx) {
|
|||
|
|
if (!links)
|
|||
|
|
return;
|
|||
|
|
for (let i = 0; i < links.length; ++i) {
|
|||
|
|
if (links[i].$.rel === rel)
|
|||
|
|
return links[i].$.href;
|
|||
|
|
}
|
|||
|
|
if (links[fallbackIdx])
|
|||
|
|
return links[fallbackIdx].$.href;
|
|||
|
|
};
|
|||
|
|
utils.getContent = function(content) {
|
|||
|
|
if (typeof content._ === "string") {
|
|||
|
|
return content._;
|
|||
|
|
} else if (typeof content === "object") {
|
|||
|
|
let builder = new xml2js.Builder({ headless: true, explicitRoot: true, rootName: "div", renderOpts: { pretty: false } });
|
|||
|
|
return builder.buildObject(content);
|
|||
|
|
} else {
|
|||
|
|
return content;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
utils.copyFromXML = function(xml, dest, fields) {
|
|||
|
|
fields.forEach(function(f) {
|
|||
|
|
let from = f;
|
|||
|
|
let to = f;
|
|||
|
|
let options = {};
|
|||
|
|
if (Array.isArray(f)) {
|
|||
|
|
from = f[0];
|
|||
|
|
to = f[1];
|
|||
|
|
if (f.length > 2) {
|
|||
|
|
options = f[2];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
const { keepArray, includeSnippet } = options;
|
|||
|
|
if (xml[from] !== void 0) {
|
|||
|
|
dest[to] = keepArray ? xml[from] : xml[from][0];
|
|||
|
|
}
|
|||
|
|
if (dest[to] && typeof dest[to]._ === "string") {
|
|||
|
|
dest[to] = dest[to]._;
|
|||
|
|
}
|
|||
|
|
if (includeSnippet && dest[to] && typeof dest[to] === "string") {
|
|||
|
|
dest[to + "Snippet"] = utils.getSnippet(dest[to]);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
utils.maybePromisify = function(callback, promise) {
|
|||
|
|
if (!callback)
|
|||
|
|
return promise;
|
|||
|
|
return promise.then(
|
|||
|
|
(data) => setTimeout(() => callback(null, data)),
|
|||
|
|
(err) => setTimeout(() => callback(err))
|
|||
|
|
);
|
|||
|
|
};
|
|||
|
|
var DEFAULT_ENCODING = "utf8";
|
|||
|
|
var ENCODING_REGEX = /(encoding|charset)\s*=\s*(\S+)/;
|
|||
|
|
var SUPPORTED_ENCODINGS = ["ascii", "utf8", "utf16le", "ucs2", "base64", "latin1", "binary", "hex"];
|
|||
|
|
var ENCODING_ALIASES = {
|
|||
|
|
"utf-8": "utf8",
|
|||
|
|
"iso-8859-1": "latin1"
|
|||
|
|
};
|
|||
|
|
utils.getEncodingFromContentType = function(contentType) {
|
|||
|
|
contentType = contentType || "";
|
|||
|
|
let match = contentType.match(ENCODING_REGEX);
|
|||
|
|
let encoding = (match || [])[2] || "";
|
|||
|
|
encoding = encoding.toLowerCase();
|
|||
|
|
encoding = ENCODING_ALIASES[encoding] || encoding;
|
|||
|
|
if (!encoding || SUPPORTED_ENCODINGS.indexOf(encoding) === -1) {
|
|||
|
|
encoding = DEFAULT_ENCODING;
|
|||
|
|
}
|
|||
|
|
return encoding;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/rss-parser/lib/parser.js
|
|||
|
|
var require_parser2 = __commonJS({
|
|||
|
|
"node_modules/rss-parser/lib/parser.js"(exports, module2) {
|
|||
|
|
"use strict";
|
|||
|
|
var http = require("http");
|
|||
|
|
var https = require("https");
|
|||
|
|
var xml2js = require_xml2js();
|
|||
|
|
var url = require("url");
|
|||
|
|
var fields = require_fields();
|
|||
|
|
var utils = require_utils();
|
|||
|
|
var DEFAULT_HEADERS = {
|
|||
|
|
"User-Agent": "rss-parser",
|
|||
|
|
"Accept": "application/rss+xml"
|
|||
|
|
};
|
|||
|
|
var DEFAULT_MAX_REDIRECTS = 5;
|
|||
|
|
var DEFAULT_TIMEOUT = 6e4;
|
|||
|
|
var Parser2 = class {
|
|||
|
|
constructor(options = {}) {
|
|||
|
|
options.headers = options.headers || {};
|
|||
|
|
options.xml2js = options.xml2js || {};
|
|||
|
|
options.customFields = options.customFields || {};
|
|||
|
|
options.customFields.item = options.customFields.item || [];
|
|||
|
|
options.customFields.feed = options.customFields.feed || [];
|
|||
|
|
options.requestOptions = options.requestOptions || {};
|
|||
|
|
if (!options.maxRedirects)
|
|||
|
|
options.maxRedirects = DEFAULT_MAX_REDIRECTS;
|
|||
|
|
if (!options.timeout)
|
|||
|
|
options.timeout = DEFAULT_TIMEOUT;
|
|||
|
|
this.options = options;
|
|||
|
|
this.xmlParser = new xml2js.Parser(this.options.xml2js);
|
|||
|
|
}
|
|||
|
|
parseString(xml, callback) {
|
|||
|
|
let prom = new Promise((resolve, reject) => {
|
|||
|
|
this.xmlParser.parseString(xml, (err, result) => {
|
|||
|
|
if (err)
|
|||
|
|
return reject(err);
|
|||
|
|
if (!result) {
|
|||
|
|
return reject(new Error("Unable to parse XML."));
|
|||
|
|
}
|
|||
|
|
let feed = null;
|
|||
|
|
if (result.feed) {
|
|||
|
|
feed = this.buildAtomFeed(result);
|
|||
|
|
} else if (result.rss && result.rss.$ && result.rss.$.version && result.rss.$.version.match(/^2/)) {
|
|||
|
|
feed = this.buildRSS2(result);
|
|||
|
|
} else if (result["rdf:RDF"]) {
|
|||
|
|
feed = this.buildRSS1(result);
|
|||
|
|
} else if (result.rss && result.rss.$ && result.rss.$.version && result.rss.$.version.match(/0\.9/)) {
|
|||
|
|
feed = this.buildRSS0_9(result);
|
|||
|
|
} else if (result.rss && this.options.defaultRSS) {
|
|||
|
|
switch (this.options.defaultRSS) {
|
|||
|
|
case 0.9:
|
|||
|
|
feed = this.buildRSS0_9(result);
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
feed = this.buildRSS1(result);
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
feed = this.buildRSS2(result);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
return reject(new Error("default RSS version not recognized."));
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
return reject(new Error("Feed not recognized as RSS 1 or 2."));
|
|||
|
|
}
|
|||
|
|
resolve(feed);
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
prom = utils.maybePromisify(callback, prom);
|
|||
|
|
return prom;
|
|||
|
|
}
|
|||
|
|
parseURL(feedUrl, callback, redirectCount = 0) {
|
|||
|
|
let xml = "";
|
|||
|
|
let get = feedUrl.indexOf("https") === 0 ? https.get : http.get;
|
|||
|
|
let urlParts = url.parse(feedUrl);
|
|||
|
|
let headers = Object.assign({}, DEFAULT_HEADERS, this.options.headers);
|
|||
|
|
let timeout = null;
|
|||
|
|
let prom = new Promise((resolve, reject) => {
|
|||
|
|
const requestOpts = Object.assign({ headers }, urlParts, this.options.requestOptions);
|
|||
|
|
let req = get(requestOpts, (res) => {
|
|||
|
|
if (this.options.maxRedirects && res.statusCode >= 300 && res.statusCode < 400 && res.headers["location"]) {
|
|||
|
|
if (redirectCount === this.options.maxRedirects) {
|
|||
|
|
return reject(new Error("Too many redirects"));
|
|||
|
|
} else {
|
|||
|
|
const newLocation = url.resolve(feedUrl, res.headers["location"]);
|
|||
|
|
return this.parseURL(newLocation, null, redirectCount + 1).then(resolve, reject);
|
|||
|
|
}
|
|||
|
|
} else if (res.statusCode >= 300) {
|
|||
|
|
return reject(new Error("Status code " + res.statusCode));
|
|||
|
|
}
|
|||
|
|
let encoding = utils.getEncodingFromContentType(res.headers["content-type"]);
|
|||
|
|
res.setEncoding(encoding);
|
|||
|
|
res.on("data", (chunk) => {
|
|||
|
|
xml += chunk;
|
|||
|
|
});
|
|||
|
|
res.on("end", () => {
|
|||
|
|
return this.parseString(xml).then(resolve, reject);
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
req.on("error", reject);
|
|||
|
|
timeout = setTimeout(() => {
|
|||
|
|
return reject(new Error("Request timed out after " + this.options.timeout + "ms"));
|
|||
|
|
}, this.options.timeout);
|
|||
|
|
}).then((data) => {
|
|||
|
|
clearTimeout(timeout);
|
|||
|
|
return Promise.resolve(data);
|
|||
|
|
}, (e) => {
|
|||
|
|
clearTimeout(timeout);
|
|||
|
|
return Promise.reject(e);
|
|||
|
|
});
|
|||
|
|
prom = utils.maybePromisify(callback, prom);
|
|||
|
|
return prom;
|
|||
|
|
}
|
|||
|
|
buildAtomFeed(xmlObj) {
|
|||
|
|
let feed = { items: [] };
|
|||
|
|
utils.copyFromXML(xmlObj.feed, feed, this.options.customFields.feed);
|
|||
|
|
if (xmlObj.feed.link) {
|
|||
|
|
feed.link = utils.getLink(xmlObj.feed.link, "alternate", 0);
|
|||
|
|
feed.feedUrl = utils.getLink(xmlObj.feed.link, "self", 1);
|
|||
|
|
}
|
|||
|
|
if (xmlObj.feed.title) {
|
|||
|
|
let title = xmlObj.feed.title[0] || "";
|
|||
|
|
if (title._)
|
|||
|
|
title = title._;
|
|||
|
|
if (title)
|
|||
|
|
feed.title = title;
|
|||
|
|
}
|
|||
|
|
if (xmlObj.feed.updated) {
|
|||
|
|
feed.lastBuildDate = xmlObj.feed.updated[0];
|
|||
|
|
}
|
|||
|
|
feed.items = (xmlObj.feed.entry || []).map((entry) => this.parseItemAtom(entry));
|
|||
|
|
return feed;
|
|||
|
|
}
|
|||
|
|
parseItemAtom(entry) {
|
|||
|
|
let item = {};
|
|||
|
|
utils.copyFromXML(entry, item, this.options.customFields.item);
|
|||
|
|
if (entry.title) {
|
|||
|
|
let title = entry.title[0] || "";
|
|||
|
|
if (title._)
|
|||
|
|
title = title._;
|
|||
|
|
if (title)
|
|||
|
|
item.title = title;
|
|||
|
|
}
|
|||
|
|
if (entry.link && entry.link.length) {
|
|||
|
|
item.link = utils.getLink(entry.link, "alternate", 0);
|
|||
|
|
}
|
|||
|
|
if (entry.published && entry.published.length && entry.published[0].length)
|
|||
|
|
item.pubDate = new Date(entry.published[0]).toISOString();
|
|||
|
|
if (!item.pubDate && entry.updated && entry.updated.length && entry.updated[0].length)
|
|||
|
|
item.pubDate = new Date(entry.updated[0]).toISOString();
|
|||
|
|
if (entry.author && entry.author.length && entry.author[0].name && entry.author[0].name.length)
|
|||
|
|
item.author = entry.author[0].name[0];
|
|||
|
|
if (entry.content && entry.content.length) {
|
|||
|
|
item.content = utils.getContent(entry.content[0]);
|
|||
|
|
item.contentSnippet = utils.getSnippet(item.content);
|
|||
|
|
}
|
|||
|
|
if (entry.summary && entry.summary.length) {
|
|||
|
|
item.summary = utils.getContent(entry.summary[0]);
|
|||
|
|
}
|
|||
|
|
if (entry.id) {
|
|||
|
|
item.id = entry.id[0];
|
|||
|
|
}
|
|||
|
|
this.setISODate(item);
|
|||
|
|
return item;
|
|||
|
|
}
|
|||
|
|
buildRSS0_9(xmlObj) {
|
|||
|
|
var channel = xmlObj.rss.channel[0];
|
|||
|
|
var items = channel.item;
|
|||
|
|
return this.buildRSS(channel, items);
|
|||
|
|
}
|
|||
|
|
buildRSS1(xmlObj) {
|
|||
|
|
xmlObj = xmlObj["rdf:RDF"];
|
|||
|
|
let channel = xmlObj.channel[0];
|
|||
|
|
let items = xmlObj.item;
|
|||
|
|
return this.buildRSS(channel, items);
|
|||
|
|
}
|
|||
|
|
buildRSS2(xmlObj) {
|
|||
|
|
let channel = xmlObj.rss.channel[0];
|
|||
|
|
let items = channel.item;
|
|||
|
|
let feed = this.buildRSS(channel, items);
|
|||
|
|
if (xmlObj.rss.$ && xmlObj.rss.$["xmlns:itunes"]) {
|
|||
|
|
this.decorateItunes(feed, channel);
|
|||
|
|
}
|
|||
|
|
return feed;
|
|||
|
|
}
|
|||
|
|
buildRSS(channel, items) {
|
|||
|
|
items = items || [];
|
|||
|
|
let feed = { items: [] };
|
|||
|
|
let feedFields = fields.feed.concat(this.options.customFields.feed);
|
|||
|
|
let itemFields = fields.item.concat(this.options.customFields.item);
|
|||
|
|
if (channel["atom:link"] && channel["atom:link"][0] && channel["atom:link"][0].$) {
|
|||
|
|
feed.feedUrl = channel["atom:link"][0].$.href;
|
|||
|
|
}
|
|||
|
|
if (channel.image && channel.image[0] && channel.image[0].url) {
|
|||
|
|
feed.image = {};
|
|||
|
|
let image = channel.image[0];
|
|||
|
|
if (image.link)
|
|||
|
|
feed.image.link = image.link[0];
|
|||
|
|
if (image.url)
|
|||
|
|
feed.image.url = image.url[0];
|
|||
|
|
if (image.title)
|
|||
|
|
feed.image.title = image.title[0];
|
|||
|
|
if (image.width)
|
|||
|
|
feed.image.width = image.width[0];
|
|||
|
|
if (image.height)
|
|||
|
|
feed.image.height = image.height[0];
|
|||
|
|
}
|
|||
|
|
const paginationLinks = this.generatePaginationLinks(channel);
|
|||
|
|
if (Object.keys(paginationLinks).length) {
|
|||
|
|
feed.paginationLinks = paginationLinks;
|
|||
|
|
}
|
|||
|
|
utils.copyFromXML(channel, feed, feedFields);
|
|||
|
|
feed.items = items.map((xmlItem) => this.parseItemRss(xmlItem, itemFields));
|
|||
|
|
return feed;
|
|||
|
|
}
|
|||
|
|
parseItemRss(xmlItem, itemFields) {
|
|||
|
|
let item = {};
|
|||
|
|
utils.copyFromXML(xmlItem, item, itemFields);
|
|||
|
|
if (xmlItem.enclosure) {
|
|||
|
|
item.enclosure = xmlItem.enclosure[0].$;
|
|||
|
|
}
|
|||
|
|
if (xmlItem.description) {
|
|||
|
|
item.content = utils.getContent(xmlItem.description[0]);
|
|||
|
|
item.contentSnippet = utils.getSnippet(item.content);
|
|||
|
|
}
|
|||
|
|
if (xmlItem.guid) {
|
|||
|
|
item.guid = xmlItem.guid[0];
|
|||
|
|
if (item.guid._)
|
|||
|
|
item.guid = item.guid._;
|
|||
|
|
}
|
|||
|
|
if (xmlItem.$ && xmlItem.$["rdf:about"]) {
|
|||
|
|
item["rdf:about"] = xmlItem.$["rdf:about"];
|
|||
|
|
}
|
|||
|
|
if (xmlItem.category)
|
|||
|
|
item.categories = xmlItem.category;
|
|||
|
|
this.setISODate(item);
|
|||
|
|
return item;
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Add iTunes specific fields from XML to extracted JSON
|
|||
|
|
*
|
|||
|
|
* @access public
|
|||
|
|
* @param {object} feed extracted
|
|||
|
|
* @param {object} channel parsed XML
|
|||
|
|
*/
|
|||
|
|
decorateItunes(feed, channel) {
|
|||
|
|
let items = channel.item || [];
|
|||
|
|
let categories = [];
|
|||
|
|
feed.itunes = {};
|
|||
|
|
if (channel["itunes:owner"]) {
|
|||
|
|
let owner = {};
|
|||
|
|
if (channel["itunes:owner"][0]["itunes:name"]) {
|
|||
|
|
owner.name = channel["itunes:owner"][0]["itunes:name"][0];
|
|||
|
|
}
|
|||
|
|
if (channel["itunes:owner"][0]["itunes:email"]) {
|
|||
|
|
owner.email = channel["itunes:owner"][0]["itunes:email"][0];
|
|||
|
|
}
|
|||
|
|
feed.itunes.owner = owner;
|
|||
|
|
}
|
|||
|
|
if (channel["itunes:image"]) {
|
|||
|
|
let image;
|
|||
|
|
let hasImageHref = channel["itunes:image"][0] && channel["itunes:image"][0].$ && channel["itunes:image"][0].$.href;
|
|||
|
|
image = hasImageHref ? channel["itunes:image"][0].$.href : null;
|
|||
|
|
if (image) {
|
|||
|
|
feed.itunes.image = image;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (channel["itunes:category"]) {
|
|||
|
|
const categoriesWithSubs = channel["itunes:category"].map((category) => {
|
|||
|
|
return {
|
|||
|
|
name: category && category.$ && category.$.text,
|
|||
|
|
subs: category["itunes:category"] ? category["itunes:category"].map((subcategory) => ({
|
|||
|
|
name: subcategory && subcategory.$ && subcategory.$.text
|
|||
|
|
})) : null
|
|||
|
|
};
|
|||
|
|
});
|
|||
|
|
feed.itunes.categories = categoriesWithSubs.map((category) => category.name);
|
|||
|
|
feed.itunes.categoriesWithSubs = categoriesWithSubs;
|
|||
|
|
}
|
|||
|
|
if (channel["itunes:keywords"]) {
|
|||
|
|
if (channel["itunes:keywords"].length > 1) {
|
|||
|
|
feed.itunes.keywords = channel["itunes:keywords"].map(
|
|||
|
|
(keyword) => keyword && keyword.$ && keyword.$.text
|
|||
|
|
);
|
|||
|
|
} else {
|
|||
|
|
let keywords = channel["itunes:keywords"][0];
|
|||
|
|
if (keywords && typeof keywords._ === "string") {
|
|||
|
|
keywords = keywords._;
|
|||
|
|
}
|
|||
|
|
if (keywords && keywords.$ && keywords.$.text) {
|
|||
|
|
feed.itunes.keywords = keywords.$.text.split(",");
|
|||
|
|
} else if (typeof keywords === "string") {
|
|||
|
|
feed.itunes.keywords = keywords.split(",");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
utils.copyFromXML(channel, feed.itunes, fields.podcastFeed);
|
|||
|
|
items.forEach((item, index) => {
|
|||
|
|
let entry = feed.items[index];
|
|||
|
|
entry.itunes = {};
|
|||
|
|
utils.copyFromXML(item, entry.itunes, fields.podcastItem);
|
|||
|
|
let image = item["itunes:image"];
|
|||
|
|
if (image && image[0] && image[0].$ && image[0].$.href) {
|
|||
|
|
entry.itunes.image = image[0].$.href;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
setISODate(item) {
|
|||
|
|
let date = item.pubDate || item.date;
|
|||
|
|
if (date) {
|
|||
|
|
try {
|
|||
|
|
item.isoDate = new Date(date.trim()).toISOString();
|
|||
|
|
} catch (e) {
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Generates a pagination object where the rel attribute is the key and href attribute is the value
|
|||
|
|
* { self: 'self-url', first: 'first-url', ... }
|
|||
|
|
*
|
|||
|
|
* @access private
|
|||
|
|
* @param {Object} channel parsed XML
|
|||
|
|
* @returns {Object}
|
|||
|
|
*/
|
|||
|
|
generatePaginationLinks(channel) {
|
|||
|
|
if (!channel["atom:link"]) {
|
|||
|
|
return {};
|
|||
|
|
}
|
|||
|
|
const paginationRelAttributes = ["self", "first", "next", "prev", "last"];
|
|||
|
|
return channel["atom:link"].reduce((paginationLinks, link) => {
|
|||
|
|
if (!link.$ || !paginationRelAttributes.includes(link.$.rel)) {
|
|||
|
|
return paginationLinks;
|
|||
|
|
}
|
|||
|
|
paginationLinks[link.$.rel] = link.$.href;
|
|||
|
|
return paginationLinks;
|
|||
|
|
}, {});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
module2.exports = Parser2;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/rss-parser/index.js
|
|||
|
|
var require_rss_parser = __commonJS({
|
|||
|
|
"node_modules/rss-parser/index.js"(exports, module2) {
|
|||
|
|
"use strict";
|
|||
|
|
module2.exports = require_parser2();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// node_modules/mustache/mustache.js
|
|||
|
|
var require_mustache = __commonJS({
|
|||
|
|
"node_modules/mustache/mustache.js"(exports, module2) {
|
|||
|
|
(function(global, factory) {
|
|||
|
|
typeof exports === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = global || self, global.Mustache = factory());
|
|||
|
|
})(exports, function() {
|
|||
|
|
"use strict";
|
|||
|
|
var objectToString = Object.prototype.toString;
|
|||
|
|
var isArray = Array.isArray || function isArrayPolyfill(object) {
|
|||
|
|
return objectToString.call(object) === "[object Array]";
|
|||
|
|
};
|
|||
|
|
function isFunction(object) {
|
|||
|
|
return typeof object === "function";
|
|||
|
|
}
|
|||
|
|
function typeStr(obj) {
|
|||
|
|
return isArray(obj) ? "array" : typeof obj;
|
|||
|
|
}
|
|||
|
|
function escapeRegExp(string) {
|
|||
|
|
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|||
|
|
}
|
|||
|
|
function hasProperty(obj, propName) {
|
|||
|
|
return obj != null && typeof obj === "object" && propName in obj;
|
|||
|
|
}
|
|||
|
|
function primitiveHasOwnProperty(primitive, propName) {
|
|||
|
|
return primitive != null && typeof primitive !== "object" && primitive.hasOwnProperty && primitive.hasOwnProperty(propName);
|
|||
|
|
}
|
|||
|
|
var regExpTest = RegExp.prototype.test;
|
|||
|
|
function testRegExp(re, string) {
|
|||
|
|
return regExpTest.call(re, string);
|
|||
|
|
}
|
|||
|
|
var nonSpaceRe = /\S/;
|
|||
|
|
function isWhitespace(string) {
|
|||
|
|
return !testRegExp(nonSpaceRe, string);
|
|||
|
|
}
|
|||
|
|
var entityMap = {
|
|||
|
|
"&": "&",
|
|||
|
|
"<": "<",
|
|||
|
|
">": ">",
|
|||
|
|
'"': """,
|
|||
|
|
"'": "'",
|
|||
|
|
"/": "/",
|
|||
|
|
"`": "`",
|
|||
|
|
"=": "="
|
|||
|
|
};
|
|||
|
|
function escapeHtml(string) {
|
|||
|
|
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) {
|
|||
|
|
return entityMap[s];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
var whiteRe = /\s*/;
|
|||
|
|
var spaceRe = /\s+/;
|
|||
|
|
var equalsRe = /\s*=/;
|
|||
|
|
var curlyRe = /\s*\}/;
|
|||
|
|
var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
|||
|
|
function parseTemplate(template, tags) {
|
|||
|
|
if (!template)
|
|||
|
|
return [];
|
|||
|
|
var lineHasNonSpace = false;
|
|||
|
|
var sections = [];
|
|||
|
|
var tokens = [];
|
|||
|
|
var spaces = [];
|
|||
|
|
var hasTag = false;
|
|||
|
|
var nonSpace = false;
|
|||
|
|
var indentation = "";
|
|||
|
|
var tagIndex = 0;
|
|||
|
|
function stripSpace() {
|
|||
|
|
if (hasTag && !nonSpace) {
|
|||
|
|
while (spaces.length)
|
|||
|
|
delete tokens[spaces.pop()];
|
|||
|
|
} else {
|
|||
|
|
spaces = [];
|
|||
|
|
}
|
|||
|
|
hasTag = false;
|
|||
|
|
nonSpace = false;
|
|||
|
|
}
|
|||
|
|
var openingTagRe, closingTagRe, closingCurlyRe;
|
|||
|
|
function compileTags(tagsToCompile) {
|
|||
|
|
if (typeof tagsToCompile === "string")
|
|||
|
|
tagsToCompile = tagsToCompile.split(spaceRe, 2);
|
|||
|
|
if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
|
|||
|
|
throw new Error("Invalid tags: " + tagsToCompile);
|
|||
|
|
openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + "\\s*");
|
|||
|
|
closingTagRe = new RegExp("\\s*" + escapeRegExp(tagsToCompile[1]));
|
|||
|
|
closingCurlyRe = new RegExp("\\s*" + escapeRegExp("}" + tagsToCompile[1]));
|
|||
|
|
}
|
|||
|
|
compileTags(tags || mustache.tags);
|
|||
|
|
var scanner = new Scanner(template);
|
|||
|
|
var start2, type, value, chr, token, openSection;
|
|||
|
|
while (!scanner.eos()) {
|
|||
|
|
start2 = scanner.pos;
|
|||
|
|
value = scanner.scanUntil(openingTagRe);
|
|||
|
|
if (value) {
|
|||
|
|
for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
|
|||
|
|
chr = value.charAt(i);
|
|||
|
|
if (isWhitespace(chr)) {
|
|||
|
|
spaces.push(tokens.length);
|
|||
|
|
indentation += chr;
|
|||
|
|
} else {
|
|||
|
|
nonSpace = true;
|
|||
|
|
lineHasNonSpace = true;
|
|||
|
|
indentation += " ";
|
|||
|
|
}
|
|||
|
|
tokens.push(["text", chr, start2, start2 + 1]);
|
|||
|
|
start2 += 1;
|
|||
|
|
if (chr === "\n") {
|
|||
|
|
stripSpace();
|
|||
|
|
indentation = "";
|
|||
|
|
tagIndex = 0;
|
|||
|
|
lineHasNonSpace = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!scanner.scan(openingTagRe))
|
|||
|
|
break;
|
|||
|
|
hasTag = true;
|
|||
|
|
type = scanner.scan(tagRe) || "name";
|
|||
|
|
scanner.scan(whiteRe);
|
|||
|
|
if (type === "=") {
|
|||
|
|
value = scanner.scanUntil(equalsRe);
|
|||
|
|
scanner.scan(equalsRe);
|
|||
|
|
scanner.scanUntil(closingTagRe);
|
|||
|
|
} else if (type === "{") {
|
|||
|
|
value = scanner.scanUntil(closingCurlyRe);
|
|||
|
|
scanner.scan(curlyRe);
|
|||
|
|
scanner.scanUntil(closingTagRe);
|
|||
|
|
type = "&";
|
|||
|
|
} else {
|
|||
|
|
value = scanner.scanUntil(closingTagRe);
|
|||
|
|
}
|
|||
|
|
if (!scanner.scan(closingTagRe))
|
|||
|
|
throw new Error("Unclosed tag at " + scanner.pos);
|
|||
|
|
if (type == ">") {
|
|||
|
|
token = [type, value, start2, scanner.pos, indentation, tagIndex, lineHasNonSpace];
|
|||
|
|
} else {
|
|||
|
|
token = [type, value, start2, scanner.pos];
|
|||
|
|
}
|
|||
|
|
tagIndex++;
|
|||
|
|
tokens.push(token);
|
|||
|
|
if (type === "#" || type === "^") {
|
|||
|
|
sections.push(token);
|
|||
|
|
} else if (type === "/") {
|
|||
|
|
openSection = sections.pop();
|
|||
|
|
if (!openSection)
|
|||
|
|
throw new Error('Unopened section "' + value + '" at ' + start2);
|
|||
|
|
if (openSection[1] !== value)
|
|||
|
|
throw new Error('Unclosed section "' + openSection[1] + '" at ' + start2);
|
|||
|
|
} else if (type === "name" || type === "{" || type === "&") {
|
|||
|
|
nonSpace = true;
|
|||
|
|
} else if (type === "=") {
|
|||
|
|
compileTags(value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
stripSpace();
|
|||
|
|
openSection = sections.pop();
|
|||
|
|
if (openSection)
|
|||
|
|
throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
|
|||
|
|
return nestTokens(squashTokens(tokens));
|
|||
|
|
}
|
|||
|
|
function squashTokens(tokens) {
|
|||
|
|
var squashedTokens = [];
|
|||
|
|
var token, lastToken;
|
|||
|
|
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|||
|
|
token = tokens[i];
|
|||
|
|
if (token) {
|
|||
|
|
if (token[0] === "text" && lastToken && lastToken[0] === "text") {
|
|||
|
|
lastToken[1] += token[1];
|
|||
|
|
lastToken[3] = token[3];
|
|||
|
|
} else {
|
|||
|
|
squashedTokens.push(token);
|
|||
|
|
lastToken = token;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return squashedTokens;
|
|||
|
|
}
|
|||
|
|
function nestTokens(tokens) {
|
|||
|
|
var nestedTokens = [];
|
|||
|
|
var collector = nestedTokens;
|
|||
|
|
var sections = [];
|
|||
|
|
var token, section;
|
|||
|
|
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|||
|
|
token = tokens[i];
|
|||
|
|
switch (token[0]) {
|
|||
|
|
case "#":
|
|||
|
|
case "^":
|
|||
|
|
collector.push(token);
|
|||
|
|
sections.push(token);
|
|||
|
|
collector = token[4] = [];
|
|||
|
|
break;
|
|||
|
|
case "/":
|
|||
|
|
section = sections.pop();
|
|||
|
|
section[5] = token[2];
|
|||
|
|
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
collector.push(token);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return nestedTokens;
|
|||
|
|
}
|
|||
|
|
function Scanner(string) {
|
|||
|
|
this.string = string;
|
|||
|
|
this.tail = string;
|
|||
|
|
this.pos = 0;
|
|||
|
|
}
|
|||
|
|
Scanner.prototype.eos = function eos() {
|
|||
|
|
return this.tail === "";
|
|||
|
|
};
|
|||
|
|
Scanner.prototype.scan = function scan(re) {
|
|||
|
|
var match = this.tail.match(re);
|
|||
|
|
if (!match || match.index !== 0)
|
|||
|
|
return "";
|
|||
|
|
var string = match[0];
|
|||
|
|
this.tail = this.tail.substring(string.length);
|
|||
|
|
this.pos += string.length;
|
|||
|
|
return string;
|
|||
|
|
};
|
|||
|
|
Scanner.prototype.scanUntil = function scanUntil(re) {
|
|||
|
|
var index = this.tail.search(re), match;
|
|||
|
|
switch (index) {
|
|||
|
|
case -1:
|
|||
|
|
match = this.tail;
|
|||
|
|
this.tail = "";
|
|||
|
|
break;
|
|||
|
|
case 0:
|
|||
|
|
match = "";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
match = this.tail.substring(0, index);
|
|||
|
|
this.tail = this.tail.substring(index);
|
|||
|
|
}
|
|||
|
|
this.pos += match.length;
|
|||
|
|
return match;
|
|||
|
|
};
|
|||
|
|
function Context(view, parentContext) {
|
|||
|
|
this.view = view;
|
|||
|
|
this.cache = { ".": this.view };
|
|||
|
|
this.parent = parentContext;
|
|||
|
|
}
|
|||
|
|
Context.prototype.push = function push(view) {
|
|||
|
|
return new Context(view, this);
|
|||
|
|
};
|
|||
|
|
Context.prototype.lookup = function lookup(name) {
|
|||
|
|
var cache = this.cache;
|
|||
|
|
var value;
|
|||
|
|
if (cache.hasOwnProperty(name)) {
|
|||
|
|
value = cache[name];
|
|||
|
|
} else {
|
|||
|
|
var context = this, intermediateValue, names, index, lookupHit = false;
|
|||
|
|
while (context) {
|
|||
|
|
if (name.indexOf(".") > 0) {
|
|||
|
|
intermediateValue = context.view;
|
|||
|
|
names = name.split(".");
|
|||
|
|
index = 0;
|
|||
|
|
while (intermediateValue != null && index < names.length) {
|
|||
|
|
if (index === names.length - 1)
|
|||
|
|
lookupHit = hasProperty(intermediateValue, names[index]) || primitiveHasOwnProperty(intermediateValue, names[index]);
|
|||
|
|
intermediateValue = intermediateValue[names[index++]];
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
intermediateValue = context.view[name];
|
|||
|
|
lookupHit = hasProperty(context.view, name);
|
|||
|
|
}
|
|||
|
|
if (lookupHit) {
|
|||
|
|
value = intermediateValue;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
context = context.parent;
|
|||
|
|
}
|
|||
|
|
cache[name] = value;
|
|||
|
|
}
|
|||
|
|
if (isFunction(value))
|
|||
|
|
value = value.call(this.view);
|
|||
|
|
return value;
|
|||
|
|
};
|
|||
|
|
function Writer() {
|
|||
|
|
this.templateCache = {
|
|||
|
|
_cache: {},
|
|||
|
|
set: function set(key, value) {
|
|||
|
|
this._cache[key] = value;
|
|||
|
|
},
|
|||
|
|
get: function get(key) {
|
|||
|
|
return this._cache[key];
|
|||
|
|
},
|
|||
|
|
clear: function clear() {
|
|||
|
|
this._cache = {};
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
Writer.prototype.clearCache = function clearCache() {
|
|||
|
|
if (typeof this.templateCache !== "undefined") {
|
|||
|
|
this.templateCache.clear();
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
Writer.prototype.parse = function parse(template, tags) {
|
|||
|
|
var cache = this.templateCache;
|
|||
|
|
var cacheKey = template + ":" + (tags || mustache.tags).join(":");
|
|||
|
|
var isCacheEnabled = typeof cache !== "undefined";
|
|||
|
|
var tokens = isCacheEnabled ? cache.get(cacheKey) : void 0;
|
|||
|
|
if (tokens == void 0) {
|
|||
|
|
tokens = parseTemplate(template, tags);
|
|||
|
|
isCacheEnabled && cache.set(cacheKey, tokens);
|
|||
|
|
}
|
|||
|
|
return tokens;
|
|||
|
|
};
|
|||
|
|
Writer.prototype.render = function render(template, view, partials, config) {
|
|||
|
|
var tags = this.getConfigTags(config);
|
|||
|
|
var tokens = this.parse(template, tags);
|
|||
|
|
var context = view instanceof Context ? view : new Context(view, void 0);
|
|||
|
|
return this.renderTokens(tokens, context, partials, template, config);
|
|||
|
|
};
|
|||
|
|
Writer.prototype.renderTokens = function renderTokens(tokens, context, partials, originalTemplate, config) {
|
|||
|
|
var buffer = "";
|
|||
|
|
var token, symbol, value;
|
|||
|
|
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|||
|
|
value = void 0;
|
|||
|
|
token = tokens[i];
|
|||
|
|
symbol = token[0];
|
|||
|
|
if (symbol === "#")
|
|||
|
|
value = this.renderSection(token, context, partials, originalTemplate, config);
|
|||
|
|
else if (symbol === "^")
|
|||
|
|
value = this.renderInverted(token, context, partials, originalTemplate, config);
|
|||
|
|
else if (symbol === ">")
|
|||
|
|
value = this.renderPartial(token, context, partials, config);
|
|||
|
|
else if (symbol === "&")
|
|||
|
|
value = this.unescapedValue(token, context);
|
|||
|
|
else if (symbol === "name")
|
|||
|
|
value = this.escapedValue(token, context, config);
|
|||
|
|
else if (symbol === "text")
|
|||
|
|
value = this.rawValue(token);
|
|||
|
|
if (value !== void 0)
|
|||
|
|
buffer += value;
|
|||
|
|
}
|
|||
|
|
return buffer;
|
|||
|
|
};
|
|||
|
|
Writer.prototype.renderSection = function renderSection(token, context, partials, originalTemplate, config) {
|
|||
|
|
var self2 = this;
|
|||
|
|
var buffer = "";
|
|||
|
|
var value = context.lookup(token[1]);
|
|||
|
|
function subRender(template) {
|
|||
|
|
return self2.render(template, context, partials, config);
|
|||
|
|
}
|
|||
|
|
if (!value)
|
|||
|
|
return;
|
|||
|
|
if (isArray(value)) {
|
|||
|
|
for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
|
|||
|
|
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
|
|||
|
|
}
|
|||
|
|
} else if (typeof value === "object" || typeof value === "string" || typeof value === "number") {
|
|||
|
|
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
|
|||
|
|
} else if (isFunction(value)) {
|
|||
|
|
if (typeof originalTemplate !== "string")
|
|||
|
|
throw new Error("Cannot use higher-order sections without the original template");
|
|||
|
|
value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
|
|||
|
|
if (value != null)
|
|||
|
|
buffer += value;
|
|||
|
|
} else {
|
|||
|
|
buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
|
|||
|
|
}
|
|||
|
|
return buffer;
|
|||
|
|
};
|
|||
|
|
Writer.prototype.renderInverted = function renderInverted(token, context, partials, originalTemplate, config) {
|
|||
|
|
var value = context.lookup(token[1]);
|
|||
|
|
if (!value || isArray(value) && value.length === 0)
|
|||
|
|
return this.renderTokens(token[4], context, partials, originalTemplate, config);
|
|||
|
|
};
|
|||
|
|
Writer.prototype.indentPartial = function indentPartial(partial, indentation, lineHasNonSpace) {
|
|||
|
|
var filteredIndentation = indentation.replace(/[^ \t]/g, "");
|
|||
|
|
var partialByNl = partial.split("\n");
|
|||
|
|
for (var i = 0; i < partialByNl.length; i++) {
|
|||
|
|
if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) {
|
|||
|
|
partialByNl[i] = filteredIndentation + partialByNl[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return partialByNl.join("\n");
|
|||
|
|
};
|
|||
|
|
Writer.prototype.renderPartial = function renderPartial(token, context, partials, config) {
|
|||
|
|
if (!partials)
|
|||
|
|
return;
|
|||
|
|
var tags = this.getConfigTags(config);
|
|||
|
|
var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
|||
|
|
if (value != null) {
|
|||
|
|
var lineHasNonSpace = token[6];
|
|||
|
|
var tagIndex = token[5];
|
|||
|
|
var indentation = token[4];
|
|||
|
|
var indentedValue = value;
|
|||
|
|
if (tagIndex == 0 && indentation) {
|
|||
|
|
indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
|
|||
|
|
}
|
|||
|
|
var tokens = this.parse(indentedValue, tags);
|
|||
|
|
return this.renderTokens(tokens, context, partials, indentedValue, config);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
Writer.prototype.unescapedValue = function unescapedValue(token, context) {
|
|||
|
|
var value = context.lookup(token[1]);
|
|||
|
|
if (value != null)
|
|||
|
|
return value;
|
|||
|
|
};
|
|||
|
|
Writer.prototype.escapedValue = function escapedValue(token, context, config) {
|
|||
|
|
var escape = this.getConfigEscape(config) || mustache.escape;
|
|||
|
|
var value = context.lookup(token[1]);
|
|||
|
|
if (value != null)
|
|||
|
|
return typeof value === "number" && escape === mustache.escape ? String(value) : escape(value);
|
|||
|
|
};
|
|||
|
|
Writer.prototype.rawValue = function rawValue(token) {
|
|||
|
|
return token[1];
|
|||
|
|
};
|
|||
|
|
Writer.prototype.getConfigTags = function getConfigTags(config) {
|
|||
|
|
if (isArray(config)) {
|
|||
|
|
return config;
|
|||
|
|
} else if (config && typeof config === "object") {
|
|||
|
|
return config.tags;
|
|||
|
|
} else {
|
|||
|
|
return void 0;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
Writer.prototype.getConfigEscape = function getConfigEscape(config) {
|
|||
|
|
if (config && typeof config === "object" && !isArray(config)) {
|
|||
|
|
return config.escape;
|
|||
|
|
} else {
|
|||
|
|
return void 0;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
var mustache = {
|
|||
|
|
name: "mustache.js",
|
|||
|
|
version: "4.2.0",
|
|||
|
|
tags: ["{{", "}}"],
|
|||
|
|
clearCache: void 0,
|
|||
|
|
escape: void 0,
|
|||
|
|
parse: void 0,
|
|||
|
|
render: void 0,
|
|||
|
|
Scanner: void 0,
|
|||
|
|
Context: void 0,
|
|||
|
|
Writer: void 0,
|
|||
|
|
/**
|
|||
|
|
* Allows a user to override the default caching strategy, by providing an
|
|||
|
|
* object with set, get and clear methods. This can also be used to disable
|
|||
|
|
* the cache by setting it to the literal `undefined`.
|
|||
|
|
*/
|
|||
|
|
set templateCache(cache) {
|
|||
|
|
defaultWriter.templateCache = cache;
|
|||
|
|
},
|
|||
|
|
/**
|
|||
|
|
* Gets the default or overridden caching object from the default writer.
|
|||
|
|
*/
|
|||
|
|
get templateCache() {
|
|||
|
|
return defaultWriter.templateCache;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
var defaultWriter = new Writer();
|
|||
|
|
mustache.clearCache = function clearCache() {
|
|||
|
|
return defaultWriter.clearCache();
|
|||
|
|
};
|
|||
|
|
mustache.parse = function parse(template, tags) {
|
|||
|
|
return defaultWriter.parse(template, tags);
|
|||
|
|
};
|
|||
|
|
mustache.render = function render(template, view, partials, config) {
|
|||
|
|
if (typeof template !== "string") {
|
|||
|
|
throw new TypeError('Invalid template! Template should be a "string" but "' + typeStr(template) + '" was given as the first argument for mustache#render(template, view, partials)');
|
|||
|
|
}
|
|||
|
|
return defaultWriter.render(template, view, partials, config);
|
|||
|
|
};
|
|||
|
|
mustache.escape = escapeHtml;
|
|||
|
|
mustache.Scanner = Scanner;
|
|||
|
|
mustache.Context = Context;
|
|||
|
|
mustache.Writer = Writer;
|
|||
|
|
return mustache;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// main.ts
|
|||
|
|
var main_exports = {};
|
|||
|
|
__export(main_exports, {
|
|||
|
|
default: () => SimpleRSSPlugin
|
|||
|
|
});
|
|||
|
|
module.exports = __toCommonJS(main_exports);
|
|||
|
|
var import_obsidian7 = require("obsidian");
|
|||
|
|
|
|||
|
|
// src/Settings/SimpleRSSSettingTab.ts
|
|||
|
|
var import_obsidian5 = require("obsidian");
|
|||
|
|
|
|||
|
|
// src/Settings/SimpleRSSFeddPanel.ts
|
|||
|
|
var import_obsidian3 = require("obsidian");
|
|||
|
|
|
|||
|
|
// src/Library/FolderSuggestor.ts
|
|||
|
|
var import_obsidian2 = require("obsidian");
|
|||
|
|
|
|||
|
|
// src/Library/suggest.ts
|
|||
|
|
var import_obsidian = require("obsidian");
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/enums.js
|
|||
|
|
var top = "top";
|
|||
|
|
var bottom = "bottom";
|
|||
|
|
var right = "right";
|
|||
|
|
var left = "left";
|
|||
|
|
var auto = "auto";
|
|||
|
|
var basePlacements = [top, bottom, right, left];
|
|||
|
|
var start = "start";
|
|||
|
|
var end = "end";
|
|||
|
|
var clippingParents = "clippingParents";
|
|||
|
|
var viewport = "viewport";
|
|||
|
|
var popper = "popper";
|
|||
|
|
var reference = "reference";
|
|||
|
|
var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
|
|||
|
|
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
|||
|
|
}, []);
|
|||
|
|
var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
|
|||
|
|
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
|||
|
|
}, []);
|
|||
|
|
var beforeRead = "beforeRead";
|
|||
|
|
var read = "read";
|
|||
|
|
var afterRead = "afterRead";
|
|||
|
|
var beforeMain = "beforeMain";
|
|||
|
|
var main = "main";
|
|||
|
|
var afterMain = "afterMain";
|
|||
|
|
var beforeWrite = "beforeWrite";
|
|||
|
|
var write = "write";
|
|||
|
|
var afterWrite = "afterWrite";
|
|||
|
|
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getNodeName.js
|
|||
|
|
function getNodeName(element) {
|
|||
|
|
return element ? (element.nodeName || "").toLowerCase() : null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getWindow.js
|
|||
|
|
function getWindow(node) {
|
|||
|
|
if (node == null) {
|
|||
|
|
return window;
|
|||
|
|
}
|
|||
|
|
if (node.toString() !== "[object Window]") {
|
|||
|
|
var ownerDocument = node.ownerDocument;
|
|||
|
|
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|||
|
|
}
|
|||
|
|
return node;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/instanceOf.js
|
|||
|
|
function isElement(node) {
|
|||
|
|
var OwnElement = getWindow(node).Element;
|
|||
|
|
return node instanceof OwnElement || node instanceof Element;
|
|||
|
|
}
|
|||
|
|
function isHTMLElement(node) {
|
|||
|
|
var OwnElement = getWindow(node).HTMLElement;
|
|||
|
|
return node instanceof OwnElement || node instanceof HTMLElement;
|
|||
|
|
}
|
|||
|
|
function isShadowRoot(node) {
|
|||
|
|
if (typeof ShadowRoot === "undefined") {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
var OwnElement = getWindow(node).ShadowRoot;
|
|||
|
|
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/applyStyles.js
|
|||
|
|
function applyStyles(_ref) {
|
|||
|
|
var state = _ref.state;
|
|||
|
|
Object.keys(state.elements).forEach(function(name) {
|
|||
|
|
var style = state.styles[name] || {};
|
|||
|
|
var attributes = state.attributes[name] || {};
|
|||
|
|
var element = state.elements[name];
|
|||
|
|
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
Object.assign(element.style, style);
|
|||
|
|
Object.keys(attributes).forEach(function(name2) {
|
|||
|
|
var value = attributes[name2];
|
|||
|
|
if (value === false) {
|
|||
|
|
element.removeAttribute(name2);
|
|||
|
|
} else {
|
|||
|
|
element.setAttribute(name2, value === true ? "" : value);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
function effect(_ref2) {
|
|||
|
|
var state = _ref2.state;
|
|||
|
|
var initialStyles = {
|
|||
|
|
popper: {
|
|||
|
|
position: state.options.strategy,
|
|||
|
|
left: "0",
|
|||
|
|
top: "0",
|
|||
|
|
margin: "0"
|
|||
|
|
},
|
|||
|
|
arrow: {
|
|||
|
|
position: "absolute"
|
|||
|
|
},
|
|||
|
|
reference: {}
|
|||
|
|
};
|
|||
|
|
Object.assign(state.elements.popper.style, initialStyles.popper);
|
|||
|
|
state.styles = initialStyles;
|
|||
|
|
if (state.elements.arrow) {
|
|||
|
|
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
|||
|
|
}
|
|||
|
|
return function() {
|
|||
|
|
Object.keys(state.elements).forEach(function(name) {
|
|||
|
|
var element = state.elements[name];
|
|||
|
|
var attributes = state.attributes[name] || {};
|
|||
|
|
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
|
|||
|
|
var style = styleProperties.reduce(function(style2, property) {
|
|||
|
|
style2[property] = "";
|
|||
|
|
return style2;
|
|||
|
|
}, {});
|
|||
|
|
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
Object.assign(element.style, style);
|
|||
|
|
Object.keys(attributes).forEach(function(attribute) {
|
|||
|
|
element.removeAttribute(attribute);
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
var applyStyles_default = {
|
|||
|
|
name: "applyStyles",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "write",
|
|||
|
|
fn: applyStyles,
|
|||
|
|
effect,
|
|||
|
|
requires: ["computeStyles"]
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/getBasePlacement.js
|
|||
|
|
function getBasePlacement(placement) {
|
|||
|
|
return placement.split("-")[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/math.js
|
|||
|
|
var max = Math.max;
|
|||
|
|
var min = Math.min;
|
|||
|
|
var round = Math.round;
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/userAgent.js
|
|||
|
|
function getUAString() {
|
|||
|
|
var uaData = navigator.userAgentData;
|
|||
|
|
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
|||
|
|
return uaData.brands.map(function(item) {
|
|||
|
|
return item.brand + "/" + item.version;
|
|||
|
|
}).join(" ");
|
|||
|
|
}
|
|||
|
|
return navigator.userAgent;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js
|
|||
|
|
function isLayoutViewport() {
|
|||
|
|
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js
|
|||
|
|
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|||
|
|
if (includeScale === void 0) {
|
|||
|
|
includeScale = false;
|
|||
|
|
}
|
|||
|
|
if (isFixedStrategy === void 0) {
|
|||
|
|
isFixedStrategy = false;
|
|||
|
|
}
|
|||
|
|
var clientRect = element.getBoundingClientRect();
|
|||
|
|
var scaleX = 1;
|
|||
|
|
var scaleY = 1;
|
|||
|
|
if (includeScale && isHTMLElement(element)) {
|
|||
|
|
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|||
|
|
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|||
|
|
}
|
|||
|
|
var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
|
|||
|
|
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|||
|
|
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|||
|
|
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|||
|
|
var width = clientRect.width / scaleX;
|
|||
|
|
var height = clientRect.height / scaleY;
|
|||
|
|
return {
|
|||
|
|
width,
|
|||
|
|
height,
|
|||
|
|
top: y,
|
|||
|
|
right: x + width,
|
|||
|
|
bottom: y + height,
|
|||
|
|
left: x,
|
|||
|
|
x,
|
|||
|
|
y
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js
|
|||
|
|
function getLayoutRect(element) {
|
|||
|
|
var clientRect = getBoundingClientRect(element);
|
|||
|
|
var width = element.offsetWidth;
|
|||
|
|
var height = element.offsetHeight;
|
|||
|
|
if (Math.abs(clientRect.width - width) <= 1) {
|
|||
|
|
width = clientRect.width;
|
|||
|
|
}
|
|||
|
|
if (Math.abs(clientRect.height - height) <= 1) {
|
|||
|
|
height = clientRect.height;
|
|||
|
|
}
|
|||
|
|
return {
|
|||
|
|
x: element.offsetLeft,
|
|||
|
|
y: element.offsetTop,
|
|||
|
|
width,
|
|||
|
|
height
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/contains.js
|
|||
|
|
function contains(parent, child) {
|
|||
|
|
var rootNode = child.getRootNode && child.getRootNode();
|
|||
|
|
if (parent.contains(child)) {
|
|||
|
|
return true;
|
|||
|
|
} else if (rootNode && isShadowRoot(rootNode)) {
|
|||
|
|
var next = child;
|
|||
|
|
do {
|
|||
|
|
if (next && parent.isSameNode(next)) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
next = next.parentNode || next.host;
|
|||
|
|
} while (next);
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js
|
|||
|
|
function getComputedStyle(element) {
|
|||
|
|
return getWindow(element).getComputedStyle(element);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/isTableElement.js
|
|||
|
|
function isTableElement(element) {
|
|||
|
|
return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js
|
|||
|
|
function getDocumentElement(element) {
|
|||
|
|
return ((isElement(element) ? element.ownerDocument : (
|
|||
|
|
// $FlowFixMe[prop-missing]
|
|||
|
|
element.document
|
|||
|
|
)) || window.document).documentElement;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getParentNode.js
|
|||
|
|
function getParentNode(element) {
|
|||
|
|
if (getNodeName(element) === "html") {
|
|||
|
|
return element;
|
|||
|
|
}
|
|||
|
|
return (
|
|||
|
|
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|||
|
|
// $FlowFixMe[incompatible-return]
|
|||
|
|
// $FlowFixMe[prop-missing]
|
|||
|
|
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|||
|
|
element.parentNode || // DOM Element detected
|
|||
|
|
(isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
|||
|
|
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
|||
|
|
getDocumentElement(element)
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js
|
|||
|
|
function getTrueOffsetParent(element) {
|
|||
|
|
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
|||
|
|
getComputedStyle(element).position === "fixed") {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
return element.offsetParent;
|
|||
|
|
}
|
|||
|
|
function getContainingBlock(element) {
|
|||
|
|
var isFirefox = /firefox/i.test(getUAString());
|
|||
|
|
var isIE = /Trident/i.test(getUAString());
|
|||
|
|
if (isIE && isHTMLElement(element)) {
|
|||
|
|
var elementCss = getComputedStyle(element);
|
|||
|
|
if (elementCss.position === "fixed") {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var currentNode = getParentNode(element);
|
|||
|
|
if (isShadowRoot(currentNode)) {
|
|||
|
|
currentNode = currentNode.host;
|
|||
|
|
}
|
|||
|
|
while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
|
|||
|
|
var css = getComputedStyle(currentNode);
|
|||
|
|
if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
|
|||
|
|
return currentNode;
|
|||
|
|
} else {
|
|||
|
|
currentNode = currentNode.parentNode;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
function getOffsetParent(element) {
|
|||
|
|
var window2 = getWindow(element);
|
|||
|
|
var offsetParent = getTrueOffsetParent(element);
|
|||
|
|
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
|
|||
|
|
offsetParent = getTrueOffsetParent(offsetParent);
|
|||
|
|
}
|
|||
|
|
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static")) {
|
|||
|
|
return window2;
|
|||
|
|
}
|
|||
|
|
return offsetParent || getContainingBlock(element) || window2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js
|
|||
|
|
function getMainAxisFromPlacement(placement) {
|
|||
|
|
return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/within.js
|
|||
|
|
function within(min2, value, max2) {
|
|||
|
|
return max(min2, min(value, max2));
|
|||
|
|
}
|
|||
|
|
function withinMaxClamp(min2, value, max2) {
|
|||
|
|
var v = within(min2, value, max2);
|
|||
|
|
return v > max2 ? max2 : v;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/getFreshSideObject.js
|
|||
|
|
function getFreshSideObject() {
|
|||
|
|
return {
|
|||
|
|
top: 0,
|
|||
|
|
right: 0,
|
|||
|
|
bottom: 0,
|
|||
|
|
left: 0
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/mergePaddingObject.js
|
|||
|
|
function mergePaddingObject(paddingObject) {
|
|||
|
|
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/expandToHashMap.js
|
|||
|
|
function expandToHashMap(value, keys) {
|
|||
|
|
return keys.reduce(function(hashMap, key) {
|
|||
|
|
hashMap[key] = value;
|
|||
|
|
return hashMap;
|
|||
|
|
}, {});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/arrow.js
|
|||
|
|
var toPaddingObject = function toPaddingObject2(padding, state) {
|
|||
|
|
padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
|
|||
|
|
placement: state.placement
|
|||
|
|
})) : padding;
|
|||
|
|
return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
|||
|
|
};
|
|||
|
|
function arrow(_ref) {
|
|||
|
|
var _state$modifiersData$;
|
|||
|
|
var state = _ref.state, name = _ref.name, options = _ref.options;
|
|||
|
|
var arrowElement = state.elements.arrow;
|
|||
|
|
var popperOffsets2 = state.modifiersData.popperOffsets;
|
|||
|
|
var basePlacement = getBasePlacement(state.placement);
|
|||
|
|
var axis = getMainAxisFromPlacement(basePlacement);
|
|||
|
|
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
|||
|
|
var len = isVertical ? "height" : "width";
|
|||
|
|
if (!arrowElement || !popperOffsets2) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var paddingObject = toPaddingObject(options.padding, state);
|
|||
|
|
var arrowRect = getLayoutRect(arrowElement);
|
|||
|
|
var minProp = axis === "y" ? top : left;
|
|||
|
|
var maxProp = axis === "y" ? bottom : right;
|
|||
|
|
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
|
|||
|
|
var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
|
|||
|
|
var arrowOffsetParent = getOffsetParent(arrowElement);
|
|||
|
|
var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|||
|
|
var centerToReference = endDiff / 2 - startDiff / 2;
|
|||
|
|
var min2 = paddingObject[minProp];
|
|||
|
|
var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
|
|||
|
|
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
|||
|
|
var offset2 = within(min2, center, max2);
|
|||
|
|
var axisProp = axis;
|
|||
|
|
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$);
|
|||
|
|
}
|
|||
|
|
function effect2(_ref2) {
|
|||
|
|
var state = _ref2.state, options = _ref2.options;
|
|||
|
|
var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
|
|||
|
|
if (arrowElement == null) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (typeof arrowElement === "string") {
|
|||
|
|
arrowElement = state.elements.popper.querySelector(arrowElement);
|
|||
|
|
if (!arrowElement) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!contains(state.elements.popper, arrowElement)) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
state.elements.arrow = arrowElement;
|
|||
|
|
}
|
|||
|
|
var arrow_default = {
|
|||
|
|
name: "arrow",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "main",
|
|||
|
|
fn: arrow,
|
|||
|
|
effect: effect2,
|
|||
|
|
requires: ["popperOffsets"],
|
|||
|
|
requiresIfExists: ["preventOverflow"]
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/getVariation.js
|
|||
|
|
function getVariation(placement) {
|
|||
|
|
return placement.split("-")[1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/computeStyles.js
|
|||
|
|
var unsetSides = {
|
|||
|
|
top: "auto",
|
|||
|
|
right: "auto",
|
|||
|
|
bottom: "auto",
|
|||
|
|
left: "auto"
|
|||
|
|
};
|
|||
|
|
function roundOffsetsByDPR(_ref, win) {
|
|||
|
|
var x = _ref.x, y = _ref.y;
|
|||
|
|
var dpr = win.devicePixelRatio || 1;
|
|||
|
|
return {
|
|||
|
|
x: round(x * dpr) / dpr || 0,
|
|||
|
|
y: round(y * dpr) / dpr || 0
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
function mapToStyles(_ref2) {
|
|||
|
|
var _Object$assign2;
|
|||
|
|
var popper2 = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
|
|||
|
|
var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
|
|||
|
|
var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
|
|||
|
|
x,
|
|||
|
|
y
|
|||
|
|
}) : {
|
|||
|
|
x,
|
|||
|
|
y
|
|||
|
|
};
|
|||
|
|
x = _ref3.x;
|
|||
|
|
y = _ref3.y;
|
|||
|
|
var hasX = offsets.hasOwnProperty("x");
|
|||
|
|
var hasY = offsets.hasOwnProperty("y");
|
|||
|
|
var sideX = left;
|
|||
|
|
var sideY = top;
|
|||
|
|
var win = window;
|
|||
|
|
if (adaptive) {
|
|||
|
|
var offsetParent = getOffsetParent(popper2);
|
|||
|
|
var heightProp = "clientHeight";
|
|||
|
|
var widthProp = "clientWidth";
|
|||
|
|
if (offsetParent === getWindow(popper2)) {
|
|||
|
|
offsetParent = getDocumentElement(popper2);
|
|||
|
|
if (getComputedStyle(offsetParent).position !== "static" && position === "absolute") {
|
|||
|
|
heightProp = "scrollHeight";
|
|||
|
|
widthProp = "scrollWidth";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
offsetParent = offsetParent;
|
|||
|
|
if (placement === top || (placement === left || placement === right) && variation === end) {
|
|||
|
|
sideY = bottom;
|
|||
|
|
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
|
|||
|
|
// $FlowFixMe[prop-missing]
|
|||
|
|
offsetParent[heightProp]
|
|||
|
|
);
|
|||
|
|
y -= offsetY - popperRect.height;
|
|||
|
|
y *= gpuAcceleration ? 1 : -1;
|
|||
|
|
}
|
|||
|
|
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
|||
|
|
sideX = right;
|
|||
|
|
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
|
|||
|
|
// $FlowFixMe[prop-missing]
|
|||
|
|
offsetParent[widthProp]
|
|||
|
|
);
|
|||
|
|
x -= offsetX - popperRect.width;
|
|||
|
|
x *= gpuAcceleration ? 1 : -1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var commonStyles = Object.assign({
|
|||
|
|
position
|
|||
|
|
}, adaptive && unsetSides);
|
|||
|
|
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
|||
|
|
x,
|
|||
|
|
y
|
|||
|
|
}, getWindow(popper2)) : {
|
|||
|
|
x,
|
|||
|
|
y
|
|||
|
|
};
|
|||
|
|
x = _ref4.x;
|
|||
|
|
y = _ref4.y;
|
|||
|
|
if (gpuAcceleration) {
|
|||
|
|
var _Object$assign;
|
|||
|
|
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
|||
|
|
}
|
|||
|
|
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
|
|||
|
|
}
|
|||
|
|
function computeStyles(_ref5) {
|
|||
|
|
var state = _ref5.state, options = _ref5.options;
|
|||
|
|
var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
|||
|
|
var commonStyles = {
|
|||
|
|
placement: getBasePlacement(state.placement),
|
|||
|
|
variation: getVariation(state.placement),
|
|||
|
|
popper: state.elements.popper,
|
|||
|
|
popperRect: state.rects.popper,
|
|||
|
|
gpuAcceleration,
|
|||
|
|
isFixed: state.options.strategy === "fixed"
|
|||
|
|
};
|
|||
|
|
if (state.modifiersData.popperOffsets != null) {
|
|||
|
|
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
|||
|
|
offsets: state.modifiersData.popperOffsets,
|
|||
|
|
position: state.options.strategy,
|
|||
|
|
adaptive,
|
|||
|
|
roundOffsets
|
|||
|
|
})));
|
|||
|
|
}
|
|||
|
|
if (state.modifiersData.arrow != null) {
|
|||
|
|
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
|||
|
|
offsets: state.modifiersData.arrow,
|
|||
|
|
position: "absolute",
|
|||
|
|
adaptive: false,
|
|||
|
|
roundOffsets
|
|||
|
|
})));
|
|||
|
|
}
|
|||
|
|
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|||
|
|
"data-popper-placement": state.placement
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
var computeStyles_default = {
|
|||
|
|
name: "computeStyles",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "beforeWrite",
|
|||
|
|
fn: computeStyles,
|
|||
|
|
data: {}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/eventListeners.js
|
|||
|
|
var passive = {
|
|||
|
|
passive: true
|
|||
|
|
};
|
|||
|
|
function effect3(_ref) {
|
|||
|
|
var state = _ref.state, instance = _ref.instance, options = _ref.options;
|
|||
|
|
var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
|
|||
|
|
var window2 = getWindow(state.elements.popper);
|
|||
|
|
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
|||
|
|
if (scroll) {
|
|||
|
|
scrollParents.forEach(function(scrollParent) {
|
|||
|
|
scrollParent.addEventListener("scroll", instance.update, passive);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
if (resize) {
|
|||
|
|
window2.addEventListener("resize", instance.update, passive);
|
|||
|
|
}
|
|||
|
|
return function() {
|
|||
|
|
if (scroll) {
|
|||
|
|
scrollParents.forEach(function(scrollParent) {
|
|||
|
|
scrollParent.removeEventListener("scroll", instance.update, passive);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
if (resize) {
|
|||
|
|
window2.removeEventListener("resize", instance.update, passive);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
var eventListeners_default = {
|
|||
|
|
name: "eventListeners",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "write",
|
|||
|
|
fn: function fn() {
|
|||
|
|
},
|
|||
|
|
effect: effect3,
|
|||
|
|
data: {}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/getOppositePlacement.js
|
|||
|
|
var hash = {
|
|||
|
|
left: "right",
|
|||
|
|
right: "left",
|
|||
|
|
bottom: "top",
|
|||
|
|
top: "bottom"
|
|||
|
|
};
|
|||
|
|
function getOppositePlacement(placement) {
|
|||
|
|
return placement.replace(/left|right|bottom|top/g, function(matched) {
|
|||
|
|
return hash[matched];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js
|
|||
|
|
var hash2 = {
|
|||
|
|
start: "end",
|
|||
|
|
end: "start"
|
|||
|
|
};
|
|||
|
|
function getOppositeVariationPlacement(placement) {
|
|||
|
|
return placement.replace(/start|end/g, function(matched) {
|
|||
|
|
return hash2[matched];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js
|
|||
|
|
function getWindowScroll(node) {
|
|||
|
|
var win = getWindow(node);
|
|||
|
|
var scrollLeft = win.pageXOffset;
|
|||
|
|
var scrollTop = win.pageYOffset;
|
|||
|
|
return {
|
|||
|
|
scrollLeft,
|
|||
|
|
scrollTop
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js
|
|||
|
|
function getWindowScrollBarX(element) {
|
|||
|
|
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js
|
|||
|
|
function getViewportRect(element, strategy) {
|
|||
|
|
var win = getWindow(element);
|
|||
|
|
var html = getDocumentElement(element);
|
|||
|
|
var visualViewport = win.visualViewport;
|
|||
|
|
var width = html.clientWidth;
|
|||
|
|
var height = html.clientHeight;
|
|||
|
|
var x = 0;
|
|||
|
|
var y = 0;
|
|||
|
|
if (visualViewport) {
|
|||
|
|
width = visualViewport.width;
|
|||
|
|
height = visualViewport.height;
|
|||
|
|
var layoutViewport = isLayoutViewport();
|
|||
|
|
if (layoutViewport || !layoutViewport && strategy === "fixed") {
|
|||
|
|
x = visualViewport.offsetLeft;
|
|||
|
|
y = visualViewport.offsetTop;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return {
|
|||
|
|
width,
|
|||
|
|
height,
|
|||
|
|
x: x + getWindowScrollBarX(element),
|
|||
|
|
y
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js
|
|||
|
|
function getDocumentRect(element) {
|
|||
|
|
var _element$ownerDocumen;
|
|||
|
|
var html = getDocumentElement(element);
|
|||
|
|
var winScroll = getWindowScroll(element);
|
|||
|
|
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|||
|
|
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|||
|
|
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|||
|
|
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
|||
|
|
var y = -winScroll.scrollTop;
|
|||
|
|
if (getComputedStyle(body || html).direction === "rtl") {
|
|||
|
|
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|||
|
|
}
|
|||
|
|
return {
|
|||
|
|
width,
|
|||
|
|
height,
|
|||
|
|
x,
|
|||
|
|
y
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js
|
|||
|
|
function isScrollParent(element) {
|
|||
|
|
var _getComputedStyle = getComputedStyle(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
|
|||
|
|
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js
|
|||
|
|
function getScrollParent(node) {
|
|||
|
|
if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
|
|||
|
|
return node.ownerDocument.body;
|
|||
|
|
}
|
|||
|
|
if (isHTMLElement(node) && isScrollParent(node)) {
|
|||
|
|
return node;
|
|||
|
|
}
|
|||
|
|
return getScrollParent(getParentNode(node));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js
|
|||
|
|
function listScrollParents(element, list) {
|
|||
|
|
var _element$ownerDocumen;
|
|||
|
|
if (list === void 0) {
|
|||
|
|
list = [];
|
|||
|
|
}
|
|||
|
|
var scrollParent = getScrollParent(element);
|
|||
|
|
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
|||
|
|
var win = getWindow(scrollParent);
|
|||
|
|
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|||
|
|
var updatedList = list.concat(target);
|
|||
|
|
return isBody ? updatedList : (
|
|||
|
|
// $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
|||
|
|
updatedList.concat(listScrollParents(getParentNode(target)))
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/rectToClientRect.js
|
|||
|
|
function rectToClientRect(rect) {
|
|||
|
|
return Object.assign({}, rect, {
|
|||
|
|
left: rect.x,
|
|||
|
|
top: rect.y,
|
|||
|
|
right: rect.x + rect.width,
|
|||
|
|
bottom: rect.y + rect.height
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js
|
|||
|
|
function getInnerBoundingClientRect(element, strategy) {
|
|||
|
|
var rect = getBoundingClientRect(element, false, strategy === "fixed");
|
|||
|
|
rect.top = rect.top + element.clientTop;
|
|||
|
|
rect.left = rect.left + element.clientLeft;
|
|||
|
|
rect.bottom = rect.top + element.clientHeight;
|
|||
|
|
rect.right = rect.left + element.clientWidth;
|
|||
|
|
rect.width = element.clientWidth;
|
|||
|
|
rect.height = element.clientHeight;
|
|||
|
|
rect.x = rect.left;
|
|||
|
|
rect.y = rect.top;
|
|||
|
|
return rect;
|
|||
|
|
}
|
|||
|
|
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|||
|
|
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|||
|
|
}
|
|||
|
|
function getClippingParents(element) {
|
|||
|
|
var clippingParents2 = listScrollParents(getParentNode(element));
|
|||
|
|
var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle(element).position) >= 0;
|
|||
|
|
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|||
|
|
if (!isElement(clipperElement)) {
|
|||
|
|
return [];
|
|||
|
|
}
|
|||
|
|
return clippingParents2.filter(function(clippingParent) {
|
|||
|
|
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|||
|
|
var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
|
|||
|
|
var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
|
|||
|
|
var firstClippingParent = clippingParents2[0];
|
|||
|
|
var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
|
|||
|
|
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|||
|
|
accRect.top = max(rect.top, accRect.top);
|
|||
|
|
accRect.right = min(rect.right, accRect.right);
|
|||
|
|
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|||
|
|
accRect.left = max(rect.left, accRect.left);
|
|||
|
|
return accRect;
|
|||
|
|
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|||
|
|
clippingRect.width = clippingRect.right - clippingRect.left;
|
|||
|
|
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|||
|
|
clippingRect.x = clippingRect.left;
|
|||
|
|
clippingRect.y = clippingRect.top;
|
|||
|
|
return clippingRect;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/computeOffsets.js
|
|||
|
|
function computeOffsets(_ref) {
|
|||
|
|
var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement;
|
|||
|
|
var basePlacement = placement ? getBasePlacement(placement) : null;
|
|||
|
|
var variation = placement ? getVariation(placement) : null;
|
|||
|
|
var commonX = reference2.x + reference2.width / 2 - element.width / 2;
|
|||
|
|
var commonY = reference2.y + reference2.height / 2 - element.height / 2;
|
|||
|
|
var offsets;
|
|||
|
|
switch (basePlacement) {
|
|||
|
|
case top:
|
|||
|
|
offsets = {
|
|||
|
|
x: commonX,
|
|||
|
|
y: reference2.y - element.height
|
|||
|
|
};
|
|||
|
|
break;
|
|||
|
|
case bottom:
|
|||
|
|
offsets = {
|
|||
|
|
x: commonX,
|
|||
|
|
y: reference2.y + reference2.height
|
|||
|
|
};
|
|||
|
|
break;
|
|||
|
|
case right:
|
|||
|
|
offsets = {
|
|||
|
|
x: reference2.x + reference2.width,
|
|||
|
|
y: commonY
|
|||
|
|
};
|
|||
|
|
break;
|
|||
|
|
case left:
|
|||
|
|
offsets = {
|
|||
|
|
x: reference2.x - element.width,
|
|||
|
|
y: commonY
|
|||
|
|
};
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
offsets = {
|
|||
|
|
x: reference2.x,
|
|||
|
|
y: reference2.y
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
|||
|
|
if (mainAxis != null) {
|
|||
|
|
var len = mainAxis === "y" ? "height" : "width";
|
|||
|
|
switch (variation) {
|
|||
|
|
case start:
|
|||
|
|
offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2);
|
|||
|
|
break;
|
|||
|
|
case end:
|
|||
|
|
offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return offsets;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/detectOverflow.js
|
|||
|
|
function detectOverflow(state, options) {
|
|||
|
|
if (options === void 0) {
|
|||
|
|
options = {};
|
|||
|
|
}
|
|||
|
|
var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
|
|||
|
|
var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
|||
|
|
var altContext = elementContext === popper ? reference : popper;
|
|||
|
|
var popperRect = state.rects.popper;
|
|||
|
|
var element = state.elements[altBoundary ? altContext : elementContext];
|
|||
|
|
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|||
|
|
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|||
|
|
var popperOffsets2 = computeOffsets({
|
|||
|
|
reference: referenceClientRect,
|
|||
|
|
element: popperRect,
|
|||
|
|
strategy: "absolute",
|
|||
|
|
placement
|
|||
|
|
});
|
|||
|
|
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
|
|||
|
|
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
|
|||
|
|
var overflowOffsets = {
|
|||
|
|
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|||
|
|
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|||
|
|
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|||
|
|
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|||
|
|
};
|
|||
|
|
var offsetData = state.modifiersData.offset;
|
|||
|
|
if (elementContext === popper && offsetData) {
|
|||
|
|
var offset2 = offsetData[placement];
|
|||
|
|
Object.keys(overflowOffsets).forEach(function(key) {
|
|||
|
|
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|||
|
|
var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
|
|||
|
|
overflowOffsets[key] += offset2[axis] * multiply;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
return overflowOffsets;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js
|
|||
|
|
function computeAutoPlacement(state, options) {
|
|||
|
|
if (options === void 0) {
|
|||
|
|
options = {};
|
|||
|
|
}
|
|||
|
|
var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
|||
|
|
var variation = getVariation(placement);
|
|||
|
|
var placements2 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
|
|||
|
|
return getVariation(placement2) === variation;
|
|||
|
|
}) : basePlacements;
|
|||
|
|
var allowedPlacements = placements2.filter(function(placement2) {
|
|||
|
|
return allowedAutoPlacements.indexOf(placement2) >= 0;
|
|||
|
|
});
|
|||
|
|
if (allowedPlacements.length === 0) {
|
|||
|
|
allowedPlacements = placements2;
|
|||
|
|
}
|
|||
|
|
var overflows = allowedPlacements.reduce(function(acc, placement2) {
|
|||
|
|
acc[placement2] = detectOverflow(state, {
|
|||
|
|
placement: placement2,
|
|||
|
|
boundary,
|
|||
|
|
rootBoundary,
|
|||
|
|
padding
|
|||
|
|
})[getBasePlacement(placement2)];
|
|||
|
|
return acc;
|
|||
|
|
}, {});
|
|||
|
|
return Object.keys(overflows).sort(function(a, b) {
|
|||
|
|
return overflows[a] - overflows[b];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/flip.js
|
|||
|
|
function getExpandedFallbackPlacements(placement) {
|
|||
|
|
if (getBasePlacement(placement) === auto) {
|
|||
|
|
return [];
|
|||
|
|
}
|
|||
|
|
var oppositePlacement = getOppositePlacement(placement);
|
|||
|
|
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
|||
|
|
}
|
|||
|
|
function flip(_ref) {
|
|||
|
|
var state = _ref.state, options = _ref.options, name = _ref.name;
|
|||
|
|
if (state.modifiersData[name]._skip) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
|
|||
|
|
var preferredPlacement = state.options.placement;
|
|||
|
|
var basePlacement = getBasePlacement(preferredPlacement);
|
|||
|
|
var isBasePlacement = basePlacement === preferredPlacement;
|
|||
|
|
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
|||
|
|
var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
|
|||
|
|
return acc.concat(getBasePlacement(placement2) === auto ? computeAutoPlacement(state, {
|
|||
|
|
placement: placement2,
|
|||
|
|
boundary,
|
|||
|
|
rootBoundary,
|
|||
|
|
padding,
|
|||
|
|
flipVariations,
|
|||
|
|
allowedAutoPlacements
|
|||
|
|
}) : placement2);
|
|||
|
|
}, []);
|
|||
|
|
var referenceRect = state.rects.reference;
|
|||
|
|
var popperRect = state.rects.popper;
|
|||
|
|
var checksMap = /* @__PURE__ */ new Map();
|
|||
|
|
var makeFallbackChecks = true;
|
|||
|
|
var firstFittingPlacement = placements2[0];
|
|||
|
|
for (var i = 0; i < placements2.length; i++) {
|
|||
|
|
var placement = placements2[i];
|
|||
|
|
var _basePlacement = getBasePlacement(placement);
|
|||
|
|
var isStartVariation = getVariation(placement) === start;
|
|||
|
|
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
|||
|
|
var len = isVertical ? "width" : "height";
|
|||
|
|
var overflow = detectOverflow(state, {
|
|||
|
|
placement,
|
|||
|
|
boundary,
|
|||
|
|
rootBoundary,
|
|||
|
|
altBoundary,
|
|||
|
|
padding
|
|||
|
|
});
|
|||
|
|
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
|||
|
|
if (referenceRect[len] > popperRect[len]) {
|
|||
|
|
mainVariationSide = getOppositePlacement(mainVariationSide);
|
|||
|
|
}
|
|||
|
|
var altVariationSide = getOppositePlacement(mainVariationSide);
|
|||
|
|
var checks = [];
|
|||
|
|
if (checkMainAxis) {
|
|||
|
|
checks.push(overflow[_basePlacement] <= 0);
|
|||
|
|
}
|
|||
|
|
if (checkAltAxis) {
|
|||
|
|
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
|||
|
|
}
|
|||
|
|
if (checks.every(function(check) {
|
|||
|
|
return check;
|
|||
|
|
})) {
|
|||
|
|
firstFittingPlacement = placement;
|
|||
|
|
makeFallbackChecks = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
checksMap.set(placement, checks);
|
|||
|
|
}
|
|||
|
|
if (makeFallbackChecks) {
|
|||
|
|
var numberOfChecks = flipVariations ? 3 : 1;
|
|||
|
|
var _loop = function _loop2(_i2) {
|
|||
|
|
var fittingPlacement = placements2.find(function(placement2) {
|
|||
|
|
var checks2 = checksMap.get(placement2);
|
|||
|
|
if (checks2) {
|
|||
|
|
return checks2.slice(0, _i2).every(function(check) {
|
|||
|
|
return check;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
if (fittingPlacement) {
|
|||
|
|
firstFittingPlacement = fittingPlacement;
|
|||
|
|
return "break";
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
for (var _i = numberOfChecks; _i > 0; _i--) {
|
|||
|
|
var _ret = _loop(_i);
|
|||
|
|
if (_ret === "break")
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (state.placement !== firstFittingPlacement) {
|
|||
|
|
state.modifiersData[name]._skip = true;
|
|||
|
|
state.placement = firstFittingPlacement;
|
|||
|
|
state.reset = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
var flip_default = {
|
|||
|
|
name: "flip",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "main",
|
|||
|
|
fn: flip,
|
|||
|
|
requiresIfExists: ["offset"],
|
|||
|
|
data: {
|
|||
|
|
_skip: false
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/hide.js
|
|||
|
|
function getSideOffsets(overflow, rect, preventedOffsets) {
|
|||
|
|
if (preventedOffsets === void 0) {
|
|||
|
|
preventedOffsets = {
|
|||
|
|
x: 0,
|
|||
|
|
y: 0
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
return {
|
|||
|
|
top: overflow.top - rect.height - preventedOffsets.y,
|
|||
|
|
right: overflow.right - rect.width + preventedOffsets.x,
|
|||
|
|
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
|||
|
|
left: overflow.left - rect.width - preventedOffsets.x
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
function isAnySideFullyClipped(overflow) {
|
|||
|
|
return [top, right, bottom, left].some(function(side) {
|
|||
|
|
return overflow[side] >= 0;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
function hide(_ref) {
|
|||
|
|
var state = _ref.state, name = _ref.name;
|
|||
|
|
var referenceRect = state.rects.reference;
|
|||
|
|
var popperRect = state.rects.popper;
|
|||
|
|
var preventedOffsets = state.modifiersData.preventOverflow;
|
|||
|
|
var referenceOverflow = detectOverflow(state, {
|
|||
|
|
elementContext: "reference"
|
|||
|
|
});
|
|||
|
|
var popperAltOverflow = detectOverflow(state, {
|
|||
|
|
altBoundary: true
|
|||
|
|
});
|
|||
|
|
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
|||
|
|
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
|||
|
|
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
|||
|
|
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
|||
|
|
state.modifiersData[name] = {
|
|||
|
|
referenceClippingOffsets,
|
|||
|
|
popperEscapeOffsets,
|
|||
|
|
isReferenceHidden,
|
|||
|
|
hasPopperEscaped
|
|||
|
|
};
|
|||
|
|
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|||
|
|
"data-popper-reference-hidden": isReferenceHidden,
|
|||
|
|
"data-popper-escaped": hasPopperEscaped
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
var hide_default = {
|
|||
|
|
name: "hide",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "main",
|
|||
|
|
requiresIfExists: ["preventOverflow"],
|
|||
|
|
fn: hide
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/offset.js
|
|||
|
|
function distanceAndSkiddingToXY(placement, rects, offset2) {
|
|||
|
|
var basePlacement = getBasePlacement(placement);
|
|||
|
|
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
|||
|
|
var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
|
|||
|
|
placement
|
|||
|
|
})) : offset2, skidding = _ref[0], distance = _ref[1];
|
|||
|
|
skidding = skidding || 0;
|
|||
|
|
distance = (distance || 0) * invertDistance;
|
|||
|
|
return [left, right].indexOf(basePlacement) >= 0 ? {
|
|||
|
|
x: distance,
|
|||
|
|
y: skidding
|
|||
|
|
} : {
|
|||
|
|
x: skidding,
|
|||
|
|
y: distance
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
function offset(_ref2) {
|
|||
|
|
var state = _ref2.state, options = _ref2.options, name = _ref2.name;
|
|||
|
|
var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
|
|||
|
|
var data = placements.reduce(function(acc, placement) {
|
|||
|
|
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
|
|||
|
|
return acc;
|
|||
|
|
}, {});
|
|||
|
|
var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
|
|||
|
|
if (state.modifiersData.popperOffsets != null) {
|
|||
|
|
state.modifiersData.popperOffsets.x += x;
|
|||
|
|
state.modifiersData.popperOffsets.y += y;
|
|||
|
|
}
|
|||
|
|
state.modifiersData[name] = data;
|
|||
|
|
}
|
|||
|
|
var offset_default = {
|
|||
|
|
name: "offset",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "main",
|
|||
|
|
requires: ["popperOffsets"],
|
|||
|
|
fn: offset
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/popperOffsets.js
|
|||
|
|
function popperOffsets(_ref) {
|
|||
|
|
var state = _ref.state, name = _ref.name;
|
|||
|
|
state.modifiersData[name] = computeOffsets({
|
|||
|
|
reference: state.rects.reference,
|
|||
|
|
element: state.rects.popper,
|
|||
|
|
strategy: "absolute",
|
|||
|
|
placement: state.placement
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
var popperOffsets_default = {
|
|||
|
|
name: "popperOffsets",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "read",
|
|||
|
|
fn: popperOffsets,
|
|||
|
|
data: {}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/getAltAxis.js
|
|||
|
|
function getAltAxis(axis) {
|
|||
|
|
return axis === "x" ? "y" : "x";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/modifiers/preventOverflow.js
|
|||
|
|
function preventOverflow(_ref) {
|
|||
|
|
var state = _ref.state, options = _ref.options, name = _ref.name;
|
|||
|
|
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
|||
|
|
var overflow = detectOverflow(state, {
|
|||
|
|
boundary,
|
|||
|
|
rootBoundary,
|
|||
|
|
padding,
|
|||
|
|
altBoundary
|
|||
|
|
});
|
|||
|
|
var basePlacement = getBasePlacement(state.placement);
|
|||
|
|
var variation = getVariation(state.placement);
|
|||
|
|
var isBasePlacement = !variation;
|
|||
|
|
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
|||
|
|
var altAxis = getAltAxis(mainAxis);
|
|||
|
|
var popperOffsets2 = state.modifiersData.popperOffsets;
|
|||
|
|
var referenceRect = state.rects.reference;
|
|||
|
|
var popperRect = state.rects.popper;
|
|||
|
|
var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
|
|||
|
|
placement: state.placement
|
|||
|
|
})) : tetherOffset;
|
|||
|
|
var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
|
|||
|
|
mainAxis: tetherOffsetValue,
|
|||
|
|
altAxis: tetherOffsetValue
|
|||
|
|
} : Object.assign({
|
|||
|
|
mainAxis: 0,
|
|||
|
|
altAxis: 0
|
|||
|
|
}, tetherOffsetValue);
|
|||
|
|
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
|||
|
|
var data = {
|
|||
|
|
x: 0,
|
|||
|
|
y: 0
|
|||
|
|
};
|
|||
|
|
if (!popperOffsets2) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (checkMainAxis) {
|
|||
|
|
var _offsetModifierState$;
|
|||
|
|
var mainSide = mainAxis === "y" ? top : left;
|
|||
|
|
var altSide = mainAxis === "y" ? bottom : right;
|
|||
|
|
var len = mainAxis === "y" ? "height" : "width";
|
|||
|
|
var offset2 = popperOffsets2[mainAxis];
|
|||
|
|
var min2 = offset2 + overflow[mainSide];
|
|||
|
|
var max2 = offset2 - overflow[altSide];
|
|||
|
|
var additive = tether ? -popperRect[len] / 2 : 0;
|
|||
|
|
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
|||
|
|
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
|
|||
|
|
var arrowElement = state.elements.arrow;
|
|||
|
|
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
|||
|
|
width: 0,
|
|||
|
|
height: 0
|
|||
|
|
};
|
|||
|
|
var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
|
|||
|
|
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
|||
|
|
var arrowPaddingMax = arrowPaddingObject[altSide];
|
|||
|
|
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
|||
|
|
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
|||
|
|
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
|||
|
|
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
|||
|
|
var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
|||
|
|
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
|||
|
|
var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
|
|||
|
|
var tetherMax = offset2 + maxOffset - offsetModifierValue;
|
|||
|
|
var preventedOffset = within(tether ? min(min2, tetherMin) : min2, offset2, tether ? max(max2, tetherMax) : max2);
|
|||
|
|
popperOffsets2[mainAxis] = preventedOffset;
|
|||
|
|
data[mainAxis] = preventedOffset - offset2;
|
|||
|
|
}
|
|||
|
|
if (checkAltAxis) {
|
|||
|
|
var _offsetModifierState$2;
|
|||
|
|
var _mainSide = mainAxis === "x" ? top : left;
|
|||
|
|
var _altSide = mainAxis === "x" ? bottom : right;
|
|||
|
|
var _offset = popperOffsets2[altAxis];
|
|||
|
|
var _len = altAxis === "y" ? "height" : "width";
|
|||
|
|
var _min = _offset + overflow[_mainSide];
|
|||
|
|
var _max = _offset - overflow[_altSide];
|
|||
|
|
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
|||
|
|
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
|||
|
|
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
|||
|
|
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
|||
|
|
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
|||
|
|
popperOffsets2[altAxis] = _preventedOffset;
|
|||
|
|
data[altAxis] = _preventedOffset - _offset;
|
|||
|
|
}
|
|||
|
|
state.modifiersData[name] = data;
|
|||
|
|
}
|
|||
|
|
var preventOverflow_default = {
|
|||
|
|
name: "preventOverflow",
|
|||
|
|
enabled: true,
|
|||
|
|
phase: "main",
|
|||
|
|
fn: preventOverflow,
|
|||
|
|
requiresIfExists: ["offset"]
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js
|
|||
|
|
function getHTMLElementScroll(element) {
|
|||
|
|
return {
|
|||
|
|
scrollLeft: element.scrollLeft,
|
|||
|
|
scrollTop: element.scrollTop
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js
|
|||
|
|
function getNodeScroll(node) {
|
|||
|
|
if (node === getWindow(node) || !isHTMLElement(node)) {
|
|||
|
|
return getWindowScroll(node);
|
|||
|
|
} else {
|
|||
|
|
return getHTMLElementScroll(node);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js
|
|||
|
|
function isElementScaled(element) {
|
|||
|
|
var rect = element.getBoundingClientRect();
|
|||
|
|
var scaleX = round(rect.width) / element.offsetWidth || 1;
|
|||
|
|
var scaleY = round(rect.height) / element.offsetHeight || 1;
|
|||
|
|
return scaleX !== 1 || scaleY !== 1;
|
|||
|
|
}
|
|||
|
|
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|||
|
|
if (isFixed === void 0) {
|
|||
|
|
isFixed = false;
|
|||
|
|
}
|
|||
|
|
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|||
|
|
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|||
|
|
var documentElement = getDocumentElement(offsetParent);
|
|||
|
|
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|||
|
|
var scroll = {
|
|||
|
|
scrollLeft: 0,
|
|||
|
|
scrollTop: 0
|
|||
|
|
};
|
|||
|
|
var offsets = {
|
|||
|
|
x: 0,
|
|||
|
|
y: 0
|
|||
|
|
};
|
|||
|
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|||
|
|
if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
|
|||
|
|
isScrollParent(documentElement)) {
|
|||
|
|
scroll = getNodeScroll(offsetParent);
|
|||
|
|
}
|
|||
|
|
if (isHTMLElement(offsetParent)) {
|
|||
|
|
offsets = getBoundingClientRect(offsetParent, true);
|
|||
|
|
offsets.x += offsetParent.clientLeft;
|
|||
|
|
offsets.y += offsetParent.clientTop;
|
|||
|
|
} else if (documentElement) {
|
|||
|
|
offsets.x = getWindowScrollBarX(documentElement);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return {
|
|||
|
|
x: rect.left + scroll.scrollLeft - offsets.x,
|
|||
|
|
y: rect.top + scroll.scrollTop - offsets.y,
|
|||
|
|
width: rect.width,
|
|||
|
|
height: rect.height
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/orderModifiers.js
|
|||
|
|
function order(modifiers) {
|
|||
|
|
var map = /* @__PURE__ */ new Map();
|
|||
|
|
var visited = /* @__PURE__ */ new Set();
|
|||
|
|
var result = [];
|
|||
|
|
modifiers.forEach(function(modifier) {
|
|||
|
|
map.set(modifier.name, modifier);
|
|||
|
|
});
|
|||
|
|
function sort(modifier) {
|
|||
|
|
visited.add(modifier.name);
|
|||
|
|
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
|||
|
|
requires.forEach(function(dep) {
|
|||
|
|
if (!visited.has(dep)) {
|
|||
|
|
var depModifier = map.get(dep);
|
|||
|
|
if (depModifier) {
|
|||
|
|
sort(depModifier);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
result.push(modifier);
|
|||
|
|
}
|
|||
|
|
modifiers.forEach(function(modifier) {
|
|||
|
|
if (!visited.has(modifier.name)) {
|
|||
|
|
sort(modifier);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
function orderModifiers(modifiers) {
|
|||
|
|
var orderedModifiers = order(modifiers);
|
|||
|
|
return modifierPhases.reduce(function(acc, phase) {
|
|||
|
|
return acc.concat(orderedModifiers.filter(function(modifier) {
|
|||
|
|
return modifier.phase === phase;
|
|||
|
|
}));
|
|||
|
|
}, []);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/debounce.js
|
|||
|
|
function debounce(fn2) {
|
|||
|
|
var pending;
|
|||
|
|
return function() {
|
|||
|
|
if (!pending) {
|
|||
|
|
pending = new Promise(function(resolve) {
|
|||
|
|
Promise.resolve().then(function() {
|
|||
|
|
pending = void 0;
|
|||
|
|
resolve(fn2());
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
return pending;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/utils/mergeByName.js
|
|||
|
|
function mergeByName(modifiers) {
|
|||
|
|
var merged = modifiers.reduce(function(merged2, current) {
|
|||
|
|
var existing = merged2[current.name];
|
|||
|
|
merged2[current.name] = existing ? Object.assign({}, existing, current, {
|
|||
|
|
options: Object.assign({}, existing.options, current.options),
|
|||
|
|
data: Object.assign({}, existing.data, current.data)
|
|||
|
|
}) : current;
|
|||
|
|
return merged2;
|
|||
|
|
}, {});
|
|||
|
|
return Object.keys(merged).map(function(key) {
|
|||
|
|
return merged[key];
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/createPopper.js
|
|||
|
|
var DEFAULT_OPTIONS = {
|
|||
|
|
placement: "bottom",
|
|||
|
|
modifiers: [],
|
|||
|
|
strategy: "absolute"
|
|||
|
|
};
|
|||
|
|
function areValidElements() {
|
|||
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|||
|
|
args[_key] = arguments[_key];
|
|||
|
|
}
|
|||
|
|
return !args.some(function(element) {
|
|||
|
|
return !(element && typeof element.getBoundingClientRect === "function");
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
function popperGenerator(generatorOptions) {
|
|||
|
|
if (generatorOptions === void 0) {
|
|||
|
|
generatorOptions = {};
|
|||
|
|
}
|
|||
|
|
var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
|||
|
|
return function createPopper2(reference2, popper2, options) {
|
|||
|
|
if (options === void 0) {
|
|||
|
|
options = defaultOptions;
|
|||
|
|
}
|
|||
|
|
var state = {
|
|||
|
|
placement: "bottom",
|
|||
|
|
orderedModifiers: [],
|
|||
|
|
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
|||
|
|
modifiersData: {},
|
|||
|
|
elements: {
|
|||
|
|
reference: reference2,
|
|||
|
|
popper: popper2
|
|||
|
|
},
|
|||
|
|
attributes: {},
|
|||
|
|
styles: {}
|
|||
|
|
};
|
|||
|
|
var effectCleanupFns = [];
|
|||
|
|
var isDestroyed = false;
|
|||
|
|
var instance = {
|
|||
|
|
state,
|
|||
|
|
setOptions: function setOptions(setOptionsAction) {
|
|||
|
|
var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
|
|||
|
|
cleanupModifierEffects();
|
|||
|
|
state.options = Object.assign({}, defaultOptions, state.options, options2);
|
|||
|
|
state.scrollParents = {
|
|||
|
|
reference: isElement(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
|
|||
|
|
popper: listScrollParents(popper2)
|
|||
|
|
};
|
|||
|
|
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
|
|||
|
|
state.orderedModifiers = orderedModifiers.filter(function(m) {
|
|||
|
|
return m.enabled;
|
|||
|
|
});
|
|||
|
|
runModifierEffects();
|
|||
|
|
return instance.update();
|
|||
|
|
},
|
|||
|
|
// Sync update – it will always be executed, even if not necessary. This
|
|||
|
|
// is useful for low frequency updates where sync behavior simplifies the
|
|||
|
|
// logic.
|
|||
|
|
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
|||
|
|
// prefer the async Popper#update method
|
|||
|
|
forceUpdate: function forceUpdate() {
|
|||
|
|
if (isDestroyed) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
|
|||
|
|
if (!areValidElements(reference3, popper3)) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
state.rects = {
|
|||
|
|
reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
|
|||
|
|
popper: getLayoutRect(popper3)
|
|||
|
|
};
|
|||
|
|
state.reset = false;
|
|||
|
|
state.placement = state.options.placement;
|
|||
|
|
state.orderedModifiers.forEach(function(modifier) {
|
|||
|
|
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
|||
|
|
});
|
|||
|
|
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
|||
|
|
if (state.reset === true) {
|
|||
|
|
state.reset = false;
|
|||
|
|
index = -1;
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
|
|||
|
|
if (typeof fn2 === "function") {
|
|||
|
|
state = fn2({
|
|||
|
|
state,
|
|||
|
|
options: _options,
|
|||
|
|
name,
|
|||
|
|
instance
|
|||
|
|
}) || state;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
// Async and optimistically optimized update – it will not be executed if
|
|||
|
|
// not necessary (debounced to run at most once-per-tick)
|
|||
|
|
update: debounce(function() {
|
|||
|
|
return new Promise(function(resolve) {
|
|||
|
|
instance.forceUpdate();
|
|||
|
|
resolve(state);
|
|||
|
|
});
|
|||
|
|
}),
|
|||
|
|
destroy: function destroy() {
|
|||
|
|
cleanupModifierEffects();
|
|||
|
|
isDestroyed = true;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
if (!areValidElements(reference2, popper2)) {
|
|||
|
|
return instance;
|
|||
|
|
}
|
|||
|
|
instance.setOptions(options).then(function(state2) {
|
|||
|
|
if (!isDestroyed && options.onFirstUpdate) {
|
|||
|
|
options.onFirstUpdate(state2);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
function runModifierEffects() {
|
|||
|
|
state.orderedModifiers.forEach(function(_ref) {
|
|||
|
|
var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect4 = _ref.effect;
|
|||
|
|
if (typeof effect4 === "function") {
|
|||
|
|
var cleanupFn = effect4({
|
|||
|
|
state,
|
|||
|
|
name,
|
|||
|
|
instance,
|
|||
|
|
options: options2
|
|||
|
|
});
|
|||
|
|
var noopFn = function noopFn2() {
|
|||
|
|
};
|
|||
|
|
effectCleanupFns.push(cleanupFn || noopFn);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
function cleanupModifierEffects() {
|
|||
|
|
effectCleanupFns.forEach(function(fn2) {
|
|||
|
|
return fn2();
|
|||
|
|
});
|
|||
|
|
effectCleanupFns = [];
|
|||
|
|
}
|
|||
|
|
return instance;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/@popperjs/core/lib/popper.js
|
|||
|
|
var defaultModifiers = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default, offset_default, flip_default, preventOverflow_default, arrow_default, hide_default];
|
|||
|
|
var createPopper = /* @__PURE__ */ popperGenerator({
|
|||
|
|
defaultModifiers
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// src/Library/suggest.ts
|
|||
|
|
var wrapAround = (value, size) => {
|
|||
|
|
return (value % size + size) % size;
|
|||
|
|
};
|
|||
|
|
var Suggest = class {
|
|||
|
|
constructor(owner, containerEl, scope) {
|
|||
|
|
this.owner = owner;
|
|||
|
|
this.containerEl = containerEl;
|
|||
|
|
containerEl.on(
|
|||
|
|
"click",
|
|||
|
|
".suggestion-item",
|
|||
|
|
this.onSuggestionClick.bind(this)
|
|||
|
|
);
|
|||
|
|
containerEl.on(
|
|||
|
|
"mousemove",
|
|||
|
|
".suggestion-item",
|
|||
|
|
this.onSuggestionMouseover.bind(this)
|
|||
|
|
);
|
|||
|
|
scope.register([], "ArrowUp", (event) => {
|
|||
|
|
if (!event.isComposing) {
|
|||
|
|
this.setSelectedItem(this.selectedItem - 1, true);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
scope.register([], "ArrowDown", (event) => {
|
|||
|
|
if (!event.isComposing) {
|
|||
|
|
this.setSelectedItem(this.selectedItem + 1, true);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
scope.register([], "Enter", (event) => {
|
|||
|
|
if (!event.isComposing) {
|
|||
|
|
this.useSelectedItem(event);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
onSuggestionClick(event, el) {
|
|||
|
|
event.preventDefault();
|
|||
|
|
const item = this.suggestions.indexOf(el);
|
|||
|
|
this.setSelectedItem(item, false);
|
|||
|
|
this.useSelectedItem(event);
|
|||
|
|
}
|
|||
|
|
onSuggestionMouseover(_event, el) {
|
|||
|
|
const item = this.suggestions.indexOf(el);
|
|||
|
|
this.setSelectedItem(item, false);
|
|||
|
|
}
|
|||
|
|
setSuggestions(values) {
|
|||
|
|
this.containerEl.empty();
|
|||
|
|
const suggestionEls = [];
|
|||
|
|
values.forEach((value) => {
|
|||
|
|
const suggestionEl = this.containerEl.createDiv("suggestion-item");
|
|||
|
|
this.owner.renderSuggestion(value, suggestionEl);
|
|||
|
|
suggestionEls.push(suggestionEl);
|
|||
|
|
});
|
|||
|
|
this.values = values;
|
|||
|
|
this.suggestions = suggestionEls;
|
|||
|
|
this.setSelectedItem(0, false);
|
|||
|
|
}
|
|||
|
|
useSelectedItem(event) {
|
|||
|
|
const currentValue = this.values[this.selectedItem];
|
|||
|
|
if (currentValue) {
|
|||
|
|
this.owner.selectSuggestion(currentValue, event);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
setSelectedItem(selectedIndex, scrollIntoView) {
|
|||
|
|
const normalizedIndex = wrapAround(
|
|||
|
|
selectedIndex,
|
|||
|
|
this.suggestions.length
|
|||
|
|
);
|
|||
|
|
const prevSelectedSuggestion = this.suggestions[this.selectedItem];
|
|||
|
|
const selectedSuggestion = this.suggestions[normalizedIndex];
|
|||
|
|
prevSelectedSuggestion == null ? void 0 : prevSelectedSuggestion.removeClass("is-selected");
|
|||
|
|
selectedSuggestion == null ? void 0 : selectedSuggestion.addClass("is-selected");
|
|||
|
|
this.selectedItem = normalizedIndex;
|
|||
|
|
if (scrollIntoView) {
|
|||
|
|
selectedSuggestion.scrollIntoView(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
var TextInputSuggest = class {
|
|||
|
|
constructor(app, inputEl) {
|
|||
|
|
this.app = app;
|
|||
|
|
this.inputEl = inputEl;
|
|||
|
|
this.scope = new import_obsidian.Scope();
|
|||
|
|
this.suggestEl = createDiv("suggestion-container");
|
|||
|
|
const suggestion = this.suggestEl.createDiv("suggestion");
|
|||
|
|
this.suggest = new Suggest(this, suggestion, this.scope);
|
|||
|
|
this.scope.register([], "Escape", this.close.bind(this));
|
|||
|
|
this.inputEl.addEventListener("input", this.onInputChanged.bind(this));
|
|||
|
|
this.inputEl.addEventListener("focus", this.onInputChanged.bind(this));
|
|||
|
|
this.inputEl.addEventListener("blur", this.close.bind(this));
|
|||
|
|
this.suggestEl.on(
|
|||
|
|
"mousedown",
|
|||
|
|
".suggestion-container",
|
|||
|
|
(event) => {
|
|||
|
|
event.preventDefault();
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
onInputChanged() {
|
|||
|
|
const inputStr = this.inputEl.value;
|
|||
|
|
const suggestions = this.getSuggestions(inputStr);
|
|||
|
|
if (!suggestions) {
|
|||
|
|
this.close();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (suggestions.length > 0) {
|
|||
|
|
this.suggest.setSuggestions(suggestions);
|
|||
|
|
this.open(this.app.dom.appContainerEl, this.inputEl);
|
|||
|
|
} else {
|
|||
|
|
this.close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
open(container, inputEl) {
|
|||
|
|
this.app.keymap.pushScope(this.scope);
|
|||
|
|
container.appendChild(this.suggestEl);
|
|||
|
|
this.popper = createPopper(inputEl, this.suggestEl, {
|
|||
|
|
placement: "bottom-start",
|
|||
|
|
modifiers: [
|
|||
|
|
{
|
|||
|
|
name: "sameWidth",
|
|||
|
|
enabled: true,
|
|||
|
|
fn: ({ state, instance }) => {
|
|||
|
|
const targetWidth = `${state.rects.reference.width}px`;
|
|||
|
|
if (state.styles.popper.width === targetWidth) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
state.styles.popper.width = targetWidth;
|
|||
|
|
instance.update();
|
|||
|
|
},
|
|||
|
|
phase: "beforeWrite",
|
|||
|
|
requires: ["computeStyles"]
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
close() {
|
|||
|
|
this.app.keymap.popScope(this.scope);
|
|||
|
|
this.suggest.setSuggestions([]);
|
|||
|
|
if (this.popper)
|
|||
|
|
this.popper.destroy();
|
|||
|
|
this.suggestEl.detach();
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// src/Library/FolderSuggestor.ts
|
|||
|
|
var FolderSuggest = class extends TextInputSuggest {
|
|||
|
|
getSuggestions(inputStr) {
|
|||
|
|
const abstractFiles = this.app.vault.getAllLoadedFiles();
|
|||
|
|
const folders = [];
|
|||
|
|
const lowerCaseInputStr = inputStr.toLowerCase();
|
|||
|
|
abstractFiles.forEach((folder) => {
|
|||
|
|
if (folder instanceof import_obsidian2.TFolder && folder.path.toLowerCase().contains(lowerCaseInputStr)) {
|
|||
|
|
folders.push(folder);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return folders;
|
|||
|
|
}
|
|||
|
|
renderSuggestion(file, el) {
|
|||
|
|
el.setText(file.path);
|
|||
|
|
}
|
|||
|
|
selectSuggestion(file) {
|
|||
|
|
this.inputEl.value = file.path;
|
|||
|
|
this.inputEl.trigger("input");
|
|||
|
|
this.close();
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// src/Settings/SimpleRSSFeddPanel.ts
|
|||
|
|
var SimpleRSSFeedPanel = class {
|
|||
|
|
constructor(app, plugin) {
|
|||
|
|
this.app = app;
|
|||
|
|
this.plugin = plugin;
|
|||
|
|
}
|
|||
|
|
display(containerEl) {
|
|||
|
|
containerEl.empty();
|
|||
|
|
containerEl.createEl("h1", { text: "Feeds" });
|
|||
|
|
new import_obsidian3.Setting(containerEl).addButton((button) => {
|
|||
|
|
button.setIcon("plus").setTooltip("Add feed").onClick(async () => {
|
|||
|
|
console.log("Add Feed");
|
|||
|
|
this.plugin.settings.feeds.push({
|
|||
|
|
name: "",
|
|||
|
|
url: "",
|
|||
|
|
title: "{{item.title}}",
|
|||
|
|
path: void 0,
|
|||
|
|
feedTypeId: void 0
|
|||
|
|
});
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
this.display(containerEl);
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
this.plugin.settings.feeds.forEach((feed, index) => {
|
|||
|
|
containerEl.createEl("h2", {
|
|||
|
|
text: "Feed #" + index + ":" + feed.name
|
|||
|
|
});
|
|||
|
|
new import_obsidian3.Setting(containerEl).setName("Name").addText(
|
|||
|
|
(text) => text.setPlaceholder("Name").setValue(feed.name).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feeds[index].name = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
})
|
|||
|
|
);
|
|||
|
|
new import_obsidian3.Setting(containerEl).setName("URL").addText(
|
|||
|
|
(text) => text.setPlaceholder("URL").setValue(feed.url).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feeds[index].url = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
})
|
|||
|
|
);
|
|||
|
|
new import_obsidian3.Setting(containerEl).setName("Type").addDropdown((dropdown) => {
|
|||
|
|
var _a, _b;
|
|||
|
|
dropdown.addOption("", "~Generic~").addOptions(
|
|||
|
|
this.plugin.settings.feedTypes.map((feedType) => {
|
|||
|
|
return {
|
|||
|
|
name: feedType.name,
|
|||
|
|
value: feedType.id.toString()
|
|||
|
|
};
|
|||
|
|
}).reduce((acc, obj) => {
|
|||
|
|
acc[obj.value] = obj.name;
|
|||
|
|
return acc;
|
|||
|
|
}, {})
|
|||
|
|
).setValue((_b = (_a = feed.feedTypeId) == null ? void 0 : _a.toString()) != null ? _b : "").onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feeds[index].feedTypeId = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
new import_obsidian3.Setting(containerEl).setName("Path").addSearch(async (search) => {
|
|||
|
|
var _a;
|
|||
|
|
new FolderSuggest(this.app, search.inputEl);
|
|||
|
|
search.setValue((_a = feed.path) != null ? _a : "").setPlaceholder(this.plugin.settings.defaultPath).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feeds[index].path = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
new import_obsidian3.Setting(containerEl).setName("Title").addText(
|
|||
|
|
(text) => {
|
|||
|
|
var _a;
|
|||
|
|
return text.setPlaceholder("Title").setValue((_a = feed.title) != null ? _a : "").onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feeds[index].title = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
new import_obsidian3.Setting(containerEl).setName("Template").addTextArea(
|
|||
|
|
(text) => {
|
|||
|
|
var _a;
|
|||
|
|
return text.setPlaceholder("Template").setValue((_a = feed.template) != null ? _a : "").onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feeds[index].template = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
new import_obsidian3.Setting(containerEl).addButton((button) => {
|
|||
|
|
button.setIcon("trash").setTooltip("Delete this feed").onClick(async () => {
|
|||
|
|
console.log("Delete Feed");
|
|||
|
|
this.plugin.settings.feeds.splice(index, 1);
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
this.display(containerEl);
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/uuid/dist/esm-browser/rng.js
|
|||
|
|
var getRandomValues;
|
|||
|
|
var rnds8 = new Uint8Array(16);
|
|||
|
|
function rng() {
|
|||
|
|
if (!getRandomValues) {
|
|||
|
|
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|||
|
|
if (!getRandomValues) {
|
|||
|
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return getRandomValues(rnds8);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/uuid/dist/esm-browser/stringify.js
|
|||
|
|
var byteToHex = [];
|
|||
|
|
for (let i = 0; i < 256; ++i) {
|
|||
|
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|||
|
|
}
|
|||
|
|
function unsafeStringify(arr, offset2 = 0) {
|
|||
|
|
return byteToHex[arr[offset2 + 0]] + byteToHex[arr[offset2 + 1]] + byteToHex[arr[offset2 + 2]] + byteToHex[arr[offset2 + 3]] + "-" + byteToHex[arr[offset2 + 4]] + byteToHex[arr[offset2 + 5]] + "-" + byteToHex[arr[offset2 + 6]] + byteToHex[arr[offset2 + 7]] + "-" + byteToHex[arr[offset2 + 8]] + byteToHex[arr[offset2 + 9]] + "-" + byteToHex[arr[offset2 + 10]] + byteToHex[arr[offset2 + 11]] + byteToHex[arr[offset2 + 12]] + byteToHex[arr[offset2 + 13]] + byteToHex[arr[offset2 + 14]] + byteToHex[arr[offset2 + 15]];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// node_modules/uuid/dist/esm-browser/native.js
|
|||
|
|
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|||
|
|
var native_default = {
|
|||
|
|
randomUUID
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// node_modules/uuid/dist/esm-browser/v4.js
|
|||
|
|
function v4(options, buf, offset2) {
|
|||
|
|
if (native_default.randomUUID && !buf && !options) {
|
|||
|
|
return native_default.randomUUID();
|
|||
|
|
}
|
|||
|
|
options = options || {};
|
|||
|
|
const rnds = options.random || (options.rng || rng)();
|
|||
|
|
rnds[6] = rnds[6] & 15 | 64;
|
|||
|
|
rnds[8] = rnds[8] & 63 | 128;
|
|||
|
|
if (buf) {
|
|||
|
|
offset2 = offset2 || 0;
|
|||
|
|
for (let i = 0; i < 16; ++i) {
|
|||
|
|
buf[offset2 + i] = rnds[i];
|
|||
|
|
}
|
|||
|
|
return buf;
|
|||
|
|
}
|
|||
|
|
return unsafeStringify(rnds);
|
|||
|
|
}
|
|||
|
|
var v4_default = v4;
|
|||
|
|
|
|||
|
|
// src/Settings/SimpleRSSFeddTypePanel.ts
|
|||
|
|
var import_obsidian4 = require("obsidian");
|
|||
|
|
var SimpleRSSFeedTypePanel = class {
|
|||
|
|
constructor(app, plugin) {
|
|||
|
|
this.app = app;
|
|||
|
|
this.plugin = plugin;
|
|||
|
|
}
|
|||
|
|
display(containerEl) {
|
|||
|
|
containerEl.empty();
|
|||
|
|
containerEl.createEl("h1", { text: "Feed Types" });
|
|||
|
|
new import_obsidian4.Setting(containerEl).addButton((button) => {
|
|||
|
|
button.setIcon("plus").setTooltip("Add feed type").onClick(async () => {
|
|||
|
|
console.log("Add Feed type");
|
|||
|
|
this.plugin.settings.feedTypes.push({
|
|||
|
|
name: "",
|
|||
|
|
feed: [],
|
|||
|
|
item: [],
|
|||
|
|
id: v4_default()
|
|||
|
|
});
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
this.display(containerEl);
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
this.plugin.settings.feedTypes.forEach((feedType, index) => {
|
|||
|
|
containerEl.createEl("h2", {
|
|||
|
|
text: "Feed Types #" + index + ":" + feedType.name
|
|||
|
|
});
|
|||
|
|
new import_obsidian4.Setting(containerEl).setName("Name").addText(
|
|||
|
|
(text) => text.setPlaceholder("Name").setValue(feedType.name).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feedTypes[index].name = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
})
|
|||
|
|
);
|
|||
|
|
new import_obsidian4.Setting(containerEl).setName("Feed Field").addText((text) => {
|
|||
|
|
const feeds = feedType.feed.join(",");
|
|||
|
|
return text.setPlaceholder("Separator: ,").setValue(feeds).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feedTypes[index].feed = value.split(",");
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
new import_obsidian4.Setting(containerEl).setName("Item Field").addText((text) => {
|
|||
|
|
const items = feedType.item.join(",");
|
|||
|
|
return text.setPlaceholder("Separator: ,").setValue(items).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.feedTypes[index].item = value.split(",");
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
new import_obsidian4.Setting(containerEl).addButton((button) => {
|
|||
|
|
button.setIcon("trash").setTooltip("Delete this feed type").onClick(async () => {
|
|||
|
|
console.log("Delete Feed");
|
|||
|
|
this.plugin.settings.feedTypes.splice(index, 1);
|
|||
|
|
this.plugin.settings.feeds = this.plugin.settings.feeds.map((feed) => {
|
|||
|
|
return {
|
|||
|
|
feedType: feed.feedTypeId !== feedType.id ? feed.feedTypeId : void 0,
|
|||
|
|
...feed
|
|||
|
|
};
|
|||
|
|
});
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
this.display(containerEl);
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// src/Settings/SimpleRSSSettingTab.ts
|
|||
|
|
var SimpleRSSSettingTab = class extends import_obsidian5.PluginSettingTab {
|
|||
|
|
constructor(app, plugin) {
|
|||
|
|
super(app, plugin);
|
|||
|
|
this.plugin = plugin;
|
|||
|
|
this.feedPanel = new SimpleRSSFeedPanel(app, plugin);
|
|||
|
|
this.feedTypePanel = new SimpleRSSFeedTypePanel(app, plugin);
|
|||
|
|
}
|
|||
|
|
display() {
|
|||
|
|
const { containerEl } = this;
|
|||
|
|
containerEl.empty();
|
|||
|
|
containerEl.createEl("h1", { text: "Synchronisation" });
|
|||
|
|
new import_obsidian5.Setting(containerEl).setName("Pull").setDesc("Pull the feeds on periodic basis. (Restart required)").addToggle(
|
|||
|
|
(toggle) => toggle.setValue(this.plugin.settings.autoPull).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.autoPull = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
})
|
|||
|
|
);
|
|||
|
|
new import_obsidian5.Setting(containerEl).setName("Time interval").setDesc(
|
|||
|
|
"Time interval between each pull in minutes. (Restart required)"
|
|||
|
|
).addText(
|
|||
|
|
(text) => text.setPlaceholder("Time Interval").setValue(this.plugin.settings.timeInterval.toString()).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.timeInterval = parseInt(value);
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
})
|
|||
|
|
);
|
|||
|
|
containerEl.createEl("h1", { text: "Defaults" });
|
|||
|
|
new import_obsidian5.Setting(containerEl).setName("Default path").setDesc("This is the default path for all feed.").addSearch(
|
|||
|
|
(search) => search.setPlaceholder("/").setValue(this.plugin.settings.defaultPath).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.defaultPath = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
})
|
|||
|
|
);
|
|||
|
|
new import_obsidian5.Setting(containerEl).setName("Default template").setDesc("This is the default template for all feed.").addTextArea(
|
|||
|
|
(text) => text.setPlaceholder("{{&item.title}}").setValue(this.plugin.settings.defaultTemplate).onChange(async (value) => {
|
|||
|
|
this.plugin.settings.defaultTemplate = value;
|
|||
|
|
await this.plugin.saveSettings();
|
|||
|
|
})
|
|||
|
|
);
|
|||
|
|
this.feedPanel.display(containerEl.createEl("div", { cls: "Feeds" }));
|
|||
|
|
this.feedTypePanel.display(
|
|||
|
|
containerEl.createEl("div", { cls: "FeedTypes" })
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// src/Settings/SimpleRSSPluginSettings.ts
|
|||
|
|
var DEFAULT_SETTINGS = {
|
|||
|
|
defaultPath: "",
|
|||
|
|
defaultTemplate: "Source: {{item.link}}\n\n{{item.description}}",
|
|||
|
|
autoPull: false,
|
|||
|
|
timeInterval: 60,
|
|||
|
|
feeds: [],
|
|||
|
|
feedTypes: [
|
|||
|
|
{
|
|||
|
|
name: "Youtube",
|
|||
|
|
feed: ["yt:channelId"],
|
|||
|
|
item: ["yt:videoId", "yt:channelId", "media:group"],
|
|||
|
|
id: v4_default()
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// src/sources/Feeds.ts
|
|||
|
|
var import_obsidian6 = require("obsidian");
|
|||
|
|
var import_rss_parser = __toESM(require_rss_parser());
|
|||
|
|
var Feeds = class {
|
|||
|
|
constructor() {
|
|||
|
|
this.feeds = [];
|
|||
|
|
this.feedTypes = [];
|
|||
|
|
this.defaultPath = "";
|
|||
|
|
this.defaultTemplate = "";
|
|||
|
|
this.Mustache = require_mustache();
|
|||
|
|
this.feeds = [];
|
|||
|
|
this.feedTypes = [];
|
|||
|
|
}
|
|||
|
|
setFeeds(feeds) {
|
|||
|
|
this.feeds = feeds;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
setFeedTypes(feedTypes) {
|
|||
|
|
this.feedTypes = feedTypes;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
setDefaultTemplate(defaultTemplate) {
|
|||
|
|
this.defaultTemplate = defaultTemplate;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
setDefaultPath(defaultPath) {
|
|||
|
|
this.defaultPath = defaultPath;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
syncFeeds(vault) {
|
|||
|
|
this.feeds.forEach((feed) => {
|
|||
|
|
const feedType = this.feedTypes.find(
|
|||
|
|
(feedType2) => feedType2.id === feed.feedTypeId
|
|||
|
|
);
|
|||
|
|
this.syncOneFeed(vault, feed, feedType);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
async syncOneFeed(vault, feed, feedType) {
|
|||
|
|
new import_obsidian6.Notice("Sync Feed: " + feed.name);
|
|||
|
|
const content = await this.getUrlContent(feed.url, feedType);
|
|||
|
|
content.items.forEach((item) => {
|
|||
|
|
var _a, _b;
|
|||
|
|
const path = (_a = feed.path) != null ? _a : this.defaultPath;
|
|||
|
|
const title = feed.title ? this.parseItem(feed.title, item, content) : item.title;
|
|||
|
|
const text = this.parseItem(
|
|||
|
|
(_b = feed.template) != null ? _b : this.defaultTemplate,
|
|||
|
|
item,
|
|||
|
|
content
|
|||
|
|
);
|
|||
|
|
const sanitizedTitle = title.replace(/[*"\\<>/:|?#\r\n^]/gi, "");
|
|||
|
|
vault.create(path + "/" + sanitizedTitle + ".md", text).then((file) => {
|
|||
|
|
console.log("Note created :" + path + "/" + title);
|
|||
|
|
new import_obsidian6.Notice("Note created :" + path + "/" + title);
|
|||
|
|
}).catch((error) => {
|
|||
|
|
if (!error.message.includes("File already exists")) {
|
|||
|
|
console.error(error);
|
|||
|
|
new import_obsidian6.Notice("Error creating note :" + error);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
getUrlContent(url, feedType) {
|
|||
|
|
const myFeedType = feedType ? {
|
|||
|
|
customFields: {
|
|||
|
|
feed: feedType.feed,
|
|||
|
|
item: feedType.item
|
|||
|
|
}
|
|||
|
|
} : void 0;
|
|||
|
|
const parser = new import_rss_parser.default(myFeedType);
|
|||
|
|
return parser.parseURL(url);
|
|||
|
|
}
|
|||
|
|
getValue(data, keys) {
|
|||
|
|
if (typeof keys === "string") {
|
|||
|
|
keys = keys.split(".");
|
|||
|
|
}
|
|||
|
|
var key = keys.shift();
|
|||
|
|
var keyData = data[key != null ? key : ""];
|
|||
|
|
if (!keyData) {
|
|||
|
|
return void 0;
|
|||
|
|
}
|
|||
|
|
if (keys.length === 0) {
|
|||
|
|
return keyData;
|
|||
|
|
}
|
|||
|
|
return this.getValue(Object.assign({}, keyData), keys);
|
|||
|
|
}
|
|||
|
|
replaceField(template, kind, values) {
|
|||
|
|
const regex = new RegExp("{{" + kind + "\\.[^}]+}}", "g");
|
|||
|
|
let result = template;
|
|||
|
|
let match;
|
|||
|
|
match = regex.exec(result);
|
|||
|
|
match == null ? void 0 : match.forEach((m) => {
|
|||
|
|
var _a;
|
|||
|
|
const key = m.replace("{{" + kind + ".", "").replace("}}", "");
|
|||
|
|
result = result.replaceAll(m, (_a = this.getValue(values, key)) != null ? _a : "");
|
|||
|
|
});
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
replaceFieldsMustache(template, values) {
|
|||
|
|
return this.Mustache.render(template, values);
|
|||
|
|
}
|
|||
|
|
parseItem(template, item, feed) {
|
|||
|
|
let categories = "";
|
|||
|
|
if (item.categories) {
|
|||
|
|
item.categories.forEach((category) => {
|
|||
|
|
categories += "- " + category + "\n";
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
let result = template.replaceAll("{{item.categories}}", categories);
|
|||
|
|
result = this.replaceFieldsMustache(result, { feed, item });
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// main.ts
|
|||
|
|
var SimpleRSSPlugin = class extends import_obsidian7.Plugin {
|
|||
|
|
async onload() {
|
|||
|
|
await this.loadSettings();
|
|||
|
|
if (this.settings.autoPull) {
|
|||
|
|
this.registerInterval(
|
|||
|
|
window.setInterval(
|
|||
|
|
() => this.feeds.syncFeeds(this.app.vault),
|
|||
|
|
1e3 * 60 * this.settings.timeInterval
|
|||
|
|
)
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
const ribbonIconEl = this.addRibbonIcon(
|
|||
|
|
"refresh-cw",
|
|||
|
|
"Simple RSS",
|
|||
|
|
(evt) => {
|
|||
|
|
this.feeds.syncFeeds(this.app.vault);
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
ribbonIconEl.addClass("simple-rss-ribbon-class");
|
|||
|
|
this.addSettingTab(new SimpleRSSSettingTab(this.app, this));
|
|||
|
|
}
|
|||
|
|
onunload() {
|
|||
|
|
}
|
|||
|
|
async loadSettings() {
|
|||
|
|
this.settings = Object.assign(
|
|||
|
|
{},
|
|||
|
|
DEFAULT_SETTINGS,
|
|||
|
|
await this.loadData()
|
|||
|
|
);
|
|||
|
|
this.feeds = new Feeds().setFeeds(this.settings.feeds).setFeedTypes(this.settings.feedTypes).setDefaultPath(this.settings.defaultPath).setDefaultTemplate(this.settings.defaultTemplate);
|
|||
|
|
}
|
|||
|
|
async saveSettings() {
|
|||
|
|
await this.saveData(this.settings);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
/*! Bundled license information:
|
|||
|
|
|
|||
|
|
sax/lib/sax.js:
|
|||
|
|
(*! http://mths.be/fromcodepoint v0.1.0 by @mathias *)
|
|||
|
|
|
|||
|
|
mustache/mustache.js:
|
|||
|
|
(*!
|
|||
|
|
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|||
|
|
* http://github.com/janl/mustache.js
|
|||
|
|
*)
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/* nosourcemap */
|