From 1a3cd386c6af2962b1902a3f31b6603fd2575145 Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Thu, 8 Jun 2023 12:15:00 +0200 Subject: [PATCH 1/4] Update Oracle JDK URL calculation --- __tests__/distributors/oracle-installer.test.ts | 11 ++++------- src/distributions/oracle/installer.ts | 11 ++--------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/__tests__/distributors/oracle-installer.test.ts b/__tests__/distributors/oracle-installer.test.ts index 2f133fc93..baf1d8e41 100644 --- a/__tests__/distributors/oracle-installer.test.ts +++ b/__tests__/distributors/oracle-installer.test.ts @@ -25,7 +25,7 @@ describe('findPackageForDownload', () => { [ '20', '20', - 'https://download.oracle.com/java/20/latest/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' + 'https://download.oracle.com/java/20/archive/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' ], [ '20.0.1', @@ -35,7 +35,7 @@ describe('findPackageForDownload', () => { [ '17', '17', - 'https://download.oracle.com/java/17/latest/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' + 'https://download.oracle.com/java/17/archive/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' ], [ '17.0.1', @@ -43,7 +43,7 @@ describe('findPackageForDownload', () => { 'https://download.oracle.com/java/17/archive/jdk-17.0.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' ] ])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => { - /* Needed only for this particular test because /latest/ urls tend to change */ + /* Needed only for this particular test because some urls might change */ spyHttpClient = jest.spyOn(HttpClient.prototype, 'head'); spyHttpClient.mockReturnValue( Promise.resolve({ @@ -89,7 +89,7 @@ describe('findPackageForDownload', () => { } const archiveType = getDownloadArchiveExtension(); const result = await distro['findPackageForDownload'](version); - const expectedUrl = `https://download.oracle.com/java/17/latest/jdk-17_${osType}-${distroArch}_bin.${archiveType}`; + const expectedUrl = `https://download.oracle.com/java/17/archive/jdk-17_${osType}-${distroArch}_bin.${archiveType}`; expect(result.url).toBe(expectedUrl); } @@ -102,8 +102,5 @@ describe('findPackageForDownload', () => { await expect(distribution['findPackageForDownload']('11')).rejects.toThrow( /Oracle JDK is only supported for JDK 17 and later/ ); - await expect(distribution['findPackageForDownload']('18')).rejects.toThrow( - /Could not find Oracle JDK for SemVer */ - ); }); }); diff --git a/src/distributions/oracle/installer.ts b/src/distributions/oracle/installer.ts index 2093339a8..8f68d9ddc 100644 --- a/src/distributions/oracle/installer.ts +++ b/src/distributions/oracle/installer.ts @@ -65,15 +65,8 @@ export class OracleDistribution extends JavaBase { const platform = this.getPlatform(); const extension = getDownloadArchiveExtension(); - let major; - let fileUrl; - if (range.includes('.')) { - major = range.split('.')[0]; - fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`; - } else { - major = range; - fileUrl = `${ORACLE_DL_BASE}/${range}/latest/jdk-${range}_${platform}-${arch}_bin.${extension}`; - } + const major = range.includes('.') ? range.split('.')[0] : range; + const fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`; if (parseInt(major) < 17) { throw new Error('Oracle JDK is only supported for JDK 17 and later'); From 46099e1f1434da2fd6d38ff0fb5b45d3a7e87494 Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Thu, 8 Jun 2023 12:48:46 +0200 Subject: [PATCH 2/4] Build --- dist/setup/index.js | 19184 +++++++++++++++++++++--------------------- 1 file changed, 9588 insertions(+), 9596 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 66a0a3c57..abf3c354d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -90720,4466 +90720,4458 @@ module.exports = v4; /***/ }), -/***/ 2839: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - module.exports = { - Disconnected: 1, - Preceding: 2, - Following: 4, - Contains: 8, - ContainedBy: 16, - ImplementationSpecific: 32 - }; - -}).call(this); - - -/***/ }), - -/***/ 9267: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - module.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(this); - - -/***/ }), - -/***/ 8229: -/***/ (function(module) { +/***/ 5696: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -// Generated by CoffeeScript 1.12.7 -(function() { - var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject, - slice = [].slice, - hasProp = {}.hasOwnProperty; +"use strict"; - 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]; - } +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var util_2 = __nccwpck_require__(5282); +var _1 = __nccwpck_require__(4260); +var dom_1 = __nccwpck_require__(770); +/** @inheritdoc */ +function builder(p1, p2) { + var options = formatBuilderOptions(isXMLBuilderCreateOptions(p1) ? p1 : interfaces_1.DefaultBuilderOptions); + var nodes = util_2.Guard.isNode(p1) || util_1.isArray(p1) ? p1 : p2; + if (nodes === undefined) { + throw new Error("Invalid arguments."); + } + if (util_1.isArray(nodes)) { + var builders = []; + for (var i = 0; i < nodes.length; i++) { + var builder_1 = new _1.XMLBuilderImpl(nodes[i]); + builder_1.set(options); + builders.push(builder_1); } - } + return builders; } - 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]'; + else { + var builder_2 = new _1.XMLBuilderImpl(nodes); + builder_2.set(options); + return builder_2; } - }; - - isEmpty = function(val) { - var key; - if (isArray(val)) { - return !val.length; - } else { - for (key in val) { - if (!hasProp.call(val, key)) continue; +} +exports.builder = builder; +/** @inheritdoc */ +function create(p1, p2) { + var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? + p1 : interfaces_1.DefaultBuilderOptions); + var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; + var doc = dom_1.createDocument(); + setOptions(doc, options); + var builder = new _1.XMLBuilderImpl(doc); + if (contents !== undefined) { + // parse contents + builder.ele(contents); + } + return builder; +} +exports.create = create; +/** @inheritdoc */ +function fragment(p1, p2) { + var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? + p1 : interfaces_1.DefaultBuilderOptions); + var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; + var doc = dom_1.createDocument(); + setOptions(doc, options, true); + var builder = new _1.XMLBuilderImpl(doc.createDocumentFragment()); + if (contents !== undefined) { + // parse contents + builder.ele(contents); + } + return builder; +} +exports.fragment = fragment; +/** @inheritdoc */ +function convert(p1, p2, p3) { + var builderOptions; + var contents; + var convertOptions; + if (isXMLBuilderCreateOptions(p1) && p2 !== undefined) { + builderOptions = p1; + contents = p2; + convertOptions = p3; + } + else { + builderOptions = interfaces_1.DefaultBuilderOptions; + contents = p1; + convertOptions = p2 || undefined; + } + return create(builderOptions, contents).end(convertOptions); +} +exports.convert = convert; +function isXMLBuilderCreateOptions(obj) { + if (!util_1.isPlainObject(obj)) return false; - } - return true; + for (var key in obj) { + /* istanbul ignore else */ + if (obj.hasOwnProperty(key)) { + if (!interfaces_1.XMLBuilderOptionKeys.has(key)) + return false; + } } - }; - - 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; + return true; +} +function formatBuilderOptions(createOptions) { + if (createOptions === void 0) { createOptions = {}; } + var options = util_1.applyDefaults(createOptions, interfaces_1.DefaultBuilderOptions); + if (options.convert.att.length === 0 || + options.convert.ins.length === 0 || + options.convert.text.length === 0 || + options.convert.cdata.length === 0 || + options.convert.comment.length === 0) { + throw new Error("JS object converter strings cannot be zero length."); } - }; + return options; +} +function setOptions(doc, options, isFragment) { + var docWithSettings = doc; + docWithSettings._xmlBuilderOptions = options; + docWithSettings._isFragment = isFragment; +} +//# sourceMappingURL=BuilderFunctions.js.map - module.exports.assign = assign; +/***/ }), - module.exports.isFunction = isFunction; +/***/ 268: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - module.exports.isObject = isObject; +"use strict"; - module.exports.isArray = isArray; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var _1 = __nccwpck_require__(4260); +/** + * Creates an XML builder which serializes the document in chunks. + * + * @param options - callback builder options + * + * @returns callback builder + */ +function createCB(options) { + return new _1.XMLBuilderCBImpl(options); +} +exports.createCB = createCB; +/** + * Creates an XML builder which serializes the fragment in chunks. + * + * @param options - callback builder options + * + * @returns callback builder + */ +function fragmentCB(options) { + return new _1.XMLBuilderCBImpl(options, true); +} +exports.fragmentCB = fragmentCB; +//# sourceMappingURL=BuilderFunctionsCB.js.map - module.exports.isEmpty = isEmpty; +/***/ }), - module.exports.isPlainObject = isPlainObject; +/***/ 1438: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports.getValue = getValue; +"use strict"; -}).call(this); - - -/***/ }), - -/***/ 9766: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - module.exports = { - None: 0, - OpenTag: 1, - InsideTag: 2, - CloseTag: 3 - }; - -}).call(this); - - -/***/ }), - -/***/ 8376: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLAttribute, XMLNode; - - NodeType = __nccwpck_require__(9267); - - XMLNode = __nccwpck_require__(7608); - - module.exports = XMLAttribute = (function() { - function XMLAttribute(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(XMLAttribute.prototype, 'nodeType', { - get: function() { - return this.type; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'ownerElement', { - get: function() { - return this.parent; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'textContent', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'prefix', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'localName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'specified', { - get: function() { - return true; - } - }); - - XMLAttribute.prototype.clone = function() { - return Object.create(this); - }; - - XMLAttribute.prototype.toString = function(options) { - return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLAttribute.prototype.debugInfo = function(name) { - name = name || this.name; - if (name == null) { - return "parent: <" + this.parent.name + ">"; - } else { - return "attribute: {" + name + "}, parent: <" + this.parent.name + ">"; - } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLAttribute.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; +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } }; - - return XMLAttribute; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 333: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLCData = (function(superClass) { - extend(XMLCData, superClass); - - function XMLCData(parent, text) { - XMLCData.__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); + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } - - XMLCData.prototype.clone = function() { - return Object.create(this); - }; - - XMLCData.prototype.toString = function(options) { - return this.options.writer.cdata(this, this.options.writer.filterOptions(options)); - }; - - return XMLCData; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 7709: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); - - module.exports = XMLCharacterData = (function(superClass) { - extend(XMLCharacterData, superClass); - - function XMLCharacterData(parent) { - XMLCharacterData.__super__.constructor.call(this, parent); - this.value = ''; + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } } - - Object.defineProperty(XMLCharacterData.prototype, 'data', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); - - Object.defineProperty(XMLCharacterData.prototype, 'length', { - get: function() { - return this.value.length; - } - }); - - Object.defineProperty(XMLCharacterData.prototype, 'textContent', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); - - XMLCharacterData.prototype.clone = function() { - return Object.create(this); - }; - - XMLCharacterData.prototype.substringData = function(offset, count) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + return ar; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var BuilderFunctions_1 = __nccwpck_require__(5696); +var algorithm_1 = __nccwpck_require__(61); +var infra_1 = __nccwpck_require__(4251); +var NamespacePrefixMap_1 = __nccwpck_require__(283); +var LocalNameSet_1 = __nccwpck_require__(9049); +var util_2 = __nccwpck_require__(5282); +var XMLCBWriter_1 = __nccwpck_require__(7572); +var JSONCBWriter_1 = __nccwpck_require__(7525); +var YAMLCBWriter_1 = __nccwpck_require__(2444); +var events_1 = __nccwpck_require__(2361); +/** + * Represents a readable XML document stream. + */ +var XMLBuilderCBImpl = /** @class */ (function (_super) { + __extends(XMLBuilderCBImpl, _super); + /** + * Initializes a new instance of `XMLStream`. + * + * @param options - stream writer options + * @param fragment - whether to create fragment stream or a document stream + * + * @returns XML stream + */ + function XMLBuilderCBImpl(options, fragment) { + if (fragment === void 0) { fragment = false; } + var _this = _super.call(this) || this; + _this._hasDeclaration = false; + _this._docTypeName = ""; + _this._hasDocumentElement = false; + _this._currentElementSerialized = false; + _this._openTags = []; + _this._ended = false; + _this._fragment = fragment; + // provide default options + _this._options = util_1.applyDefaults(options || {}, interfaces_1.DefaultXMLBuilderCBOptions); + _this._builderOptions = { + defaultNamespace: _this._options.defaultNamespace, + namespaceAlias: _this._options.namespaceAlias + }; + if (_this._options.format === "json") { + _this._writer = new JSONCBWriter_1.JSONCBWriter(_this._options); + } + else if (_this._options.format === "yaml") { + _this._writer = new YAMLCBWriter_1.YAMLCBWriter(_this._options); + } + else { + _this._writer = new XMLCBWriter_1.XMLCBWriter(_this._options); + } + // automatically create listeners for callbacks passed via options + if (_this._options.data !== undefined) { + _this.on("data", _this._options.data); + } + if (_this._options.end !== undefined) { + _this.on("end", _this._options.end); + } + if (_this._options.error !== undefined) { + _this.on("error", _this._options.error); + } + _this._prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); + _this._prefixMap.set("xml", infra_1.namespace.XML); + _this._prefixIndex = { value: 1 }; + _this._push(_this._writer.frontMatter()); + return _this; + } + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.ele = function (p1, p2, p3) { + var e_1, _a; + // parse if JS object or XML or JSON string + if (util_1.isObject(p1) || (util_1.isString(p1) && (/^\s*/g, '>'); + } + else { + for (var i = 0; i < node.data.length; i++) { + var c = node.data[i]; + if (c === "&") + markup += "&"; + else if (c === "<") + markup += "<"; + else if (c === ">") + markup += ">"; + else + markup += c; + } + } + this._push(this._writer.text(markup)); + return this; }; - - XMLCharacterData.prototype.replaceData = function(offset, count, arg) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.ins = function (target, content) { + if (content === void 0) { content = ''; } + this._serializeOpenTag(true); + var node; + try { + node = BuilderFunctions_1.fragment(this._builderOptions).ins(target, content).first().node; + } + catch (err) { + /* istanbul ignore next */ + this.emit("error", err); + /* istanbul ignore next */ + return this; + } + if (this._options.wellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { + this.emit("error", new Error("Processing instruction target contains invalid characters (well-formed required).")); + return this; + } + if (this._options.wellFormed && !algorithm_1.xml_isLegalChar(node.data)) { + this.emit("error", Error("Processing instruction data contains invalid characters (well-formed required).")); + return this; + } + this._push(this._writer.instruction(node.target, node.data)); + return this; }; - - XMLCharacterData.prototype.isEqualNode = function(node) { - if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { - return false; - } - if (node.data !== this.data) { - return false; - } - return true; + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dat = function (content) { + this._serializeOpenTag(true); + var node; + try { + node = BuilderFunctions_1.fragment(this._builderOptions).dat(content).first().node; + } + catch (err) { + this.emit("error", err); + return this; + } + this._push(this._writer.cdata(node.data)); + return this; }; - - return XMLCharacterData; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 4407: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLComment = (function(superClass) { - extend(XMLComment, superClass); - - function XMLComment(parent, text) { - XMLComment.__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); - } - - XMLComment.prototype.clone = function() { - return Object.create(this); - }; - - XMLComment.prototype.toString = function(options) { - return this.options.writer.comment(this, this.options.writer.filterOptions(options)); - }; - - return XMLComment; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 7465: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList; - - XMLDOMErrorHandler = __nccwpck_require__(6744); - - XMLDOMStringList = __nccwpck_require__(7028); - - module.exports = XMLDOMConfiguration = (function() { - function XMLDOMConfiguration() { - 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(XMLDOMConfiguration.prototype, 'parameterNames', { - get: function() { - return new XMLDOMStringList(Object.keys(this.defaultParams)); - } - }); - - XMLDOMConfiguration.prototype.getParameter = function(name) { - if (this.params.hasOwnProperty(name)) { - return this.params[name]; - } else { - return null; - } - }; - - XMLDOMConfiguration.prototype.canSetParameter = function(name, value) { - return true; - }; - - XMLDOMConfiguration.prototype.setParameter = function(name, value) { - if (value != null) { - return this.params[name] = value; - } else { - return delete this.params[name]; - } - }; - - return XMLDOMConfiguration; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 6744: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLDOMErrorHandler; - - module.exports = XMLDOMErrorHandler = (function() { - function XMLDOMErrorHandler() {} - - XMLDOMErrorHandler.prototype.handleError = function(error) { - throw new Error(error); - }; - - return XMLDOMErrorHandler; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 8310: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLDOMImplementation; - - module.exports = XMLDOMImplementation = (function() { - function XMLDOMImplementation() {} - - XMLDOMImplementation.prototype.hasFeature = function(feature, version) { - return true; - }; - - XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) { - throw new Error("This DOM method is not implemented."); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dec = function (options) { + if (options === void 0) { options = { version: "1.0" }; } + if (this._fragment) { + this.emit("error", Error("Cannot insert an XML declaration into a document fragment.")); + return this; + } + if (this._hasDeclaration) { + this.emit("error", Error("XML declaration is already inserted.")); + return this; + } + this._push(this._writer.declaration(options.version || "1.0", options.encoding, options.standalone)); + this._hasDeclaration = true; + return this; }; - - XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) { - throw new Error("This DOM method is not implemented."); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dtd = function (options) { + if (this._fragment) { + this.emit("error", Error("Cannot insert a DocType declaration into a document fragment.")); + return this; + } + if (this._docTypeName !== "") { + this.emit("error", new Error("DocType declaration is already inserted.")); + return this; + } + if (this._hasDocumentElement) { + this.emit("error", new Error("Cannot insert DocType declaration after document element.")); + return this; + } + var node; + try { + node = BuilderFunctions_1.create().dtd(options).first().node; + } + catch (err) { + this.emit("error", err); + return this; + } + if (this._options.wellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { + this.emit("error", new Error("DocType public identifier does not match PubidChar construct (well-formed required).")); + return this; + } + if (this._options.wellFormed && + (!algorithm_1.xml_isLegalChar(node.systemId) || + (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { + this.emit("error", new Error("DocType system identifier contains invalid characters (well-formed required).")); + return this; + } + this._docTypeName = options.name; + this._push(this._writer.docType(options.name, node.publicId, node.systemId)); + return this; }; - - XMLDOMImplementation.prototype.createHTMLDocument = function(title) { - throw new Error("This DOM method is not implemented."); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.up = function () { + this._serializeOpenTag(false); + this._serializeCloseTag(); + return this; }; - - XMLDOMImplementation.prototype.getFeature = function(feature, version) { - throw new Error("This DOM method is not implemented."); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.end = function () { + this._serializeOpenTag(false); + while (this._openTags.length > 0) { + this._serializeCloseTag(); + } + this._push(null); + return this; }; - - return XMLDOMImplementation; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 7028: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLDOMStringList; - - module.exports = XMLDOMStringList = (function() { - function XMLDOMStringList(arr) { - this.arr = arr || []; - } - - Object.defineProperty(XMLDOMStringList.prototype, 'length', { - get: function() { - return this.arr.length; - } - }); - - XMLDOMStringList.prototype.item = function(index) { - return this.arr[index] || null; - }; - - XMLDOMStringList.prototype.contains = function(str) { - return this.arr.indexOf(str) !== -1; - }; - - return XMLDOMStringList; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 1015: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDAttList = (function(superClass) { - extend(XMLDTDAttList, superClass); - - function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { - XMLDTDAttList.__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; - } - - XMLDTDAttList.prototype.toString = function(options) { - return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options)); - }; - - return XMLDTDAttList; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 2421: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDElement = (function(superClass) { - extend(XMLDTDElement, superClass); - - function XMLDTDElement(parent, name, value) { - XMLDTDElement.__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); - } - - XMLDTDElement.prototype.toString = function(options) { - return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options)); - }; - - return XMLDTDElement; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 53: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = (__nccwpck_require__(8229).isObject); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDEntity = (function(superClass) { - extend(XMLDTDEntity, superClass); - - function XMLDTDEntity(parent, pe, name, value) { - XMLDTDEntity.__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)); + /** + * Serializes the opening tag of an element node. + * + * @param hasChildren - whether the element node has child nodes + */ + XMLBuilderCBImpl.prototype._serializeOpenTag = function (hasChildren) { + if (this._currentElementSerialized) + return; + if (this._currentElement === undefined) + return; + var node = this._currentElement.node; + if (this._options.wellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + this.emit("error", new Error("Node local name contains invalid characters (well-formed required).")); + return; } - this.internal = false; - if (value.pubID != null) { - this.pubID = this.stringify.dtdPubID(value.pubID); + var qualifiedName = ""; + var ignoreNamespaceDefinitionAttribute = false; + var map = this._prefixMap.copy(); + var localPrefixesMap = {}; + var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); + var inheritedNS = this._openTags.length === 0 ? null : this._openTags[this._openTags.length - 1][1]; + var ns = node.namespaceURI; + if (ns === null) + ns = inheritedNS; + if (inheritedNS === ns) { + if (localDefaultNamespace !== null) { + ignoreNamespaceDefinitionAttribute = true; + } + if (ns === infra_1.namespace.XML) { + qualifiedName = "xml:" + node.localName; + } + else { + qualifiedName = node.localName; + } + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); } - if (value.sysID != null) { - this.sysID = this.stringify.dtdSysID(value.sysID); + else { + var prefix = node.prefix; + var candidatePrefix = null; + if (prefix !== null || ns !== localDefaultNamespace) { + candidatePrefix = map.get(prefix, ns); + } + if (prefix === "xmlns") { + if (this._options.wellFormed) { + this.emit("error", new Error("An element cannot have the 'xmlns' prefix (well-formed required).")); + return; + } + candidatePrefix = prefix; + } + if (candidatePrefix !== null) { + qualifiedName = candidatePrefix + ':' + node.localName; + if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { + inheritedNS = localDefaultNamespace || null; + } + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + } + else if (prefix !== null) { + if (prefix in localPrefixesMap) { + prefix = this._generatePrefix(ns, map, this._prefixIndex); + } + map.set(prefix, ns); + qualifiedName += prefix + ':' + node.localName; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + this._push(this._writer.attribute("xmlns:" + prefix, this._serializeAttributeValue(ns, this._options.wellFormed))); + if (localDefaultNamespace !== null) { + inheritedNS = localDefaultNamespace || null; + } + } + else if (localDefaultNamespace === null || + (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { + ignoreNamespaceDefinitionAttribute = true; + qualifiedName += node.localName; + inheritedNS = ns; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + this._push(this._writer.attribute("xmlns", this._serializeAttributeValue(ns, this._options.wellFormed))); + } + else { + qualifiedName += node.localName; + inheritedNS = ns; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + } } - if (value.nData != null) { - this.nData = this.stringify.dtdNData(value.nData); + this._serializeAttributes(node, map, this._prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, this._options.wellFormed); + var isHTML = (ns === infra_1.namespace.HTML); + if (isHTML && !hasChildren && + XMLBuilderCBImpl._VoidElementNames.has(node.localName)) { + this._push(this._writer.openTagEnd(qualifiedName, true, true)); + this._writer.endElement(qualifiedName); } - if (this.pe && this.nData) { - throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name)); + else if (!isHTML && !hasChildren) { + this._push(this._writer.openTagEnd(qualifiedName, true, false)); + this._writer.endElement(qualifiedName); } - } - } - - Object.defineProperty(XMLDTDEntity.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'notationName', { - get: function() { - return this.nData || null; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', { - get: function() { - return null; - } - }); - - XMLDTDEntity.prototype.toString = function(options) { - return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options)); + else { + this._push(this._writer.openTagEnd(qualifiedName, false, false)); + } + this._currentElementSerialized = true; + /** + * Save qualified name, original inherited ns, original prefix map, and + * hasChildren flag. + */ + this._openTags.push([qualifiedName, inheritedNS, this._prefixMap, hasChildren]); + /** + * New values of inherited namespace and prefix map will be used while + * serializing child nodes. They will be returned to their original values + * when this node is closed using the _openTags array item we saved above. + */ + if (this._isPrefixMapModified(this._prefixMap, map)) { + this._prefixMap = map; + } + /** + * Calls following this will either serialize child nodes or close this tag. + */ + this._writer.level++; }; - - return XMLDTDEntity; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 2837: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDNotation = (function(superClass) { - extend(XMLDTDNotation, superClass); - - function XMLDTDNotation(parent, name, value) { - XMLDTDNotation.__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(XMLDTDNotation.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); - - Object.defineProperty(XMLDTDNotation.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); - - XMLDTDNotation.prototype.toString = function(options) { - return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options)); + /** + * Serializes the closing tag of an element node. + */ + XMLBuilderCBImpl.prototype._serializeCloseTag = function () { + this._writer.level--; + var lastEle = this._openTags.pop(); + /* istanbul ignore next */ + if (lastEle === undefined) { + this.emit("error", new Error("Last element is undefined.")); + return; + } + var _a = __read(lastEle, 4), qualifiedName = _a[0], ns = _a[1], map = _a[2], hasChildren = _a[3]; + /** + * Restore original values of inherited namespace and prefix map. + */ + this._prefixMap = map; + if (!hasChildren) + return; + this._push(this._writer.closeTag(qualifiedName)); + this._writer.endElement(qualifiedName); }; - - return XMLDTDNotation; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 6364: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = (__nccwpck_require__(8229).isObject); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDeclaration = (function(superClass) { - extend(XMLDeclaration, superClass); - - function XMLDeclaration(parent, version, encoding, standalone) { - var ref; - XMLDeclaration.__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); - } - } - - XMLDeclaration.prototype.toString = function(options) { - return this.options.writer.declaration(this, this.options.writer.filterOptions(options)); + /** + * Pushes data to internal buffer. + * + * @param data - data + */ + XMLBuilderCBImpl.prototype._push = function (data) { + if (data === null) { + this._ended = true; + this.emit("end"); + } + else if (this._ended) { + this.emit("error", new Error("Cannot push to ended stream.")); + } + else if (data.length !== 0) { + this._writer.hasData = true; + this.emit("data", data, this._writer.level); + } }; - - return XMLDeclaration; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 1801: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = (__nccwpck_require__(8229).isObject); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - XMLDTDAttList = __nccwpck_require__(1015); - - XMLDTDEntity = __nccwpck_require__(53); - - XMLDTDElement = __nccwpck_require__(2421); - - XMLDTDNotation = __nccwpck_require__(2837); - - XMLNamedNodeMap = __nccwpck_require__(4361); - - module.exports = XMLDocType = (function(superClass) { - extend(XMLDocType, superClass); - - function XMLDocType(parent, pubID, sysID) { - var child, i, len, ref, ref1, ref2; - XMLDocType.__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; - } + /** + * Reads and serializes an XML tree. + * + * @param node - root node + */ + XMLBuilderCBImpl.prototype._fromNode = function (node) { + var e_2, _a, e_3, _b; + if (util_2.Guard.isElementNode(node)) { + var name = node.prefix ? node.prefix + ":" + node.localName : node.localName; + if (node.namespaceURI !== null) { + this.ele(node.namespaceURI, name); + } + else { + this.ele(name); + } + try { + for (var _c = __values(node.attributes), _d = _c.next(); !_d.done; _d = _c.next()) { + var attr = _d.value; + var name_1 = attr.prefix ? attr.prefix + ":" + attr.localName : attr.localName; + if (attr.namespaceURI !== null) { + this.att(attr.namespaceURI, name_1, attr.value); + } + else { + this.att(name_1, attr.value); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_2) throw e_2.error; } + } + try { + for (var _e = __values(node.childNodes), _f = _e.next(); !_f.done; _f = _e.next()) { + var child = _f.value; + this._fromNode(child); + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + } + finally { if (e_3) throw e_3.error; } + } + this.up(); } - } - 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(XMLDocType.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; - } + else if (util_2.Guard.isExclusiveTextNode(node) && node.data) { + this.txt(node.data); } - return new XMLNamedNodeMap(nodes); - } - }); - - Object.defineProperty(XMLDocType.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; - } + else if (util_2.Guard.isCommentNode(node)) { + this.com(node.data); + } + else if (util_2.Guard.isCDATASectionNode(node)) { + this.dat(node.data); + } + else if (util_2.Guard.isProcessingInstructionNode(node)) { + this.ins(node.target, node.data); } - return new XMLNamedNodeMap(nodes); - } - }); - - Object.defineProperty(XMLDocType.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); - - Object.defineProperty(XMLDocType.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); - - Object.defineProperty(XMLDocType.prototype, 'internalSubset', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - XMLDocType.prototype.element = function(name, value) { - var child; - child = new XMLDTDElement(this, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.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; - }; - - XMLDocType.prototype.entity = function(name, value) { - var child; - child = new XMLDTDEntity(this, false, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.pEntity = function(name, value) { - var child; - child = new XMLDTDEntity(this, true, name, value); - this.children.push(child); - return this; }; - - XMLDocType.prototype.notation = function(name, value) { - var child; - child = new XMLDTDNotation(this, name, value); - this.children.push(child); - return this; + /** + * Produces an XML serialization of the attributes of an element node. + * + * @param node - node to serialize + * @param map - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param localPrefixesMap - local prefixes map + * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace + * attributes + * @param requireWellFormed - whether to check conformance + */ + XMLBuilderCBImpl.prototype._serializeAttributes = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed) { + var e_4, _a; + var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; + try { + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + // Optimize common case + if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { + this._push(this._writer.attribute(attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); + continue; + } + if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { + this.emit("error", new Error("Element contains duplicate attributes (well-formed required).")); + return; + } + if (requireWellFormed && localNameSet) + localNameSet.set(attr.namespaceURI, attr.localName); + var attributeNamespace = attr.namespaceURI; + var candidatePrefix = null; + if (attributeNamespace !== null) { + candidatePrefix = map.get(attr.prefix, attributeNamespace); + if (attributeNamespace === infra_1.namespace.XMLNS) { + if (attr.value === infra_1.namespace.XML || + (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || + (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || + localPrefixesMap[attr.localName] !== attr.value) && + map.has(attr.localName, attr.value))) + continue; + if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { + this.emit("error", new Error("XMLNS namespace is reserved (well-formed required).")); + return; + } + if (requireWellFormed && attr.value === '') { + this.emit("error", new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).")); + return; + } + if (attr.prefix === 'xmlns') + candidatePrefix = 'xmlns'; + /** + * _Note:_ The (candidatePrefix === null) check is not in the spec. + * We deviate from the spec here. Otherwise a prefix is generated for + * all attributes with namespaces. + */ + } + else if (candidatePrefix === null) { + if (attr.prefix !== null && + (!map.hasPrefix(attr.prefix) || + map.has(attr.prefix, attributeNamespace))) { + /** + * Check if we can use the attribute's own prefix. + * We deviate from the spec here. + * TODO: This is not an efficient way of searching for prefixes. + * Follow developments to the spec. + */ + candidatePrefix = attr.prefix; + } + else { + candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); + } + this._push(this._writer.attribute("xmlns:" + candidatePrefix, this._serializeAttributeValue(attributeNamespace, this._options.wellFormed))); + } + } + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName) || + (attr.localName === "xmlns" && attributeNamespace === null))) { + this.emit("error", new Error("Attribute local name contains invalid characters (well-formed required).")); + return; + } + this._push(this._writer.attribute((candidatePrefix !== null ? candidatePrefix + ":" : "") + attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_4) throw e_4.error; } + } }; - - XMLDocType.prototype.toString = function(options) { - return this.options.writer.docType(this, this.options.writer.filterOptions(options)); - }; - - XMLDocType.prototype.ele = function(name, value) { - return this.element(name, value); - }; - - XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); - }; - - XMLDocType.prototype.ent = function(name, value) { - return this.entity(name, value); - }; - - XMLDocType.prototype.pent = function(name, value) { - return this.pEntity(name, value); + /** + * Produces an XML serialization of an attribute value. + * + * @param value - attribute value + * @param requireWellFormed - whether to check conformance + */ + XMLBuilderCBImpl.prototype._serializeAttributeValue = function (value, requireWellFormed) { + if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { + this.emit("error", new Error("Invalid characters in attribute value.")); + return ""; + } + if (value === null) + return ""; + if (this._options.noDoubleEncoding) { + return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + } + else { + var result = ""; + for (var i = 0; i < value.length; i++) { + var c = value[i]; + if (c === "\"") + result += """; + else if (c === "&") + result += "&"; + else if (c === "<") + result += "<"; + else if (c === ">") + result += ">"; + else + result += c; + } + return result; + } }; - - XMLDocType.prototype.not = function(name, value) { - return this.notation(name, value); + /** + * Records namespace information for the given element and returns the + * default namespace attribute value. + * + * @param node - element node to process + * @param map - namespace prefix map + * @param localPrefixesMap - local prefixes map + */ + XMLBuilderCBImpl.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { + var e_5, _a; + var defaultNamespaceAttrValue = null; + try { + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + var attributeNamespace = attr.namespaceURI; + var attributePrefix = attr.prefix; + if (attributeNamespace === infra_1.namespace.XMLNS) { + if (attributePrefix === null) { + defaultNamespaceAttrValue = attr.value; + continue; + } + else { + var prefixDefinition = attr.localName; + var namespaceDefinition = attr.value; + if (namespaceDefinition === infra_1.namespace.XML) { + continue; + } + if (namespaceDefinition === '') { + namespaceDefinition = null; + } + if (map.has(prefixDefinition, namespaceDefinition)) { + continue; + } + map.set(prefixDefinition, namespaceDefinition); + localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; + } + } + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_5) throw e_5.error; } + } + return defaultNamespaceAttrValue; }; - - XMLDocType.prototype.up = function() { - return this.root() || this.documentObject; + /** + * Generates a new prefix for the given namespace. + * + * @param newNamespace - a namespace to generate prefix for + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + */ + XMLBuilderCBImpl.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { + var generatedPrefix = "ns" + prefixIndex.value; + prefixIndex.value++; + prefixMap.set(generatedPrefix, newNamespace); + return generatedPrefix; }; - - XMLDocType.prototype.isEqualNode = function(node) { - if (!XMLDocType.__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) { + /** + * Determines if the namespace prefix map was modified from its original. + * + * @param originalMap - original namespace prefix map + * @param newMap - new namespace prefix map + */ + XMLBuilderCBImpl.prototype._isPrefixMapModified = function (originalMap, newMap) { + var items1 = originalMap._items; + var items2 = newMap._items; + var nullItems1 = originalMap._nullItems; + var nullItems2 = newMap._nullItems; + for (var key in items2) { + var arr1 = items1[key]; + if (arr1 === undefined) + return true; + var arr2 = items2[key]; + if (arr1.length !== arr2.length) + return true; + for (var i = 0; i < arr1.length; i++) { + if (arr1[i] !== arr2[i]) + return true; + } + } + if (nullItems1.length !== nullItems2.length) + return true; + for (var i = 0; i < nullItems1.length; i++) { + if (nullItems1[i] !== nullItems2[i]) + return true; + } return false; - } - return true; }; - - return XMLDocType; - - })(XMLNode); - -}).call(this); - + XMLBuilderCBImpl._VoidElementNames = new Set(['area', 'base', 'basefont', + 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', + 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); + return XMLBuilderCBImpl; +}(events_1.EventEmitter)); +exports.XMLBuilderCBImpl = XMLBuilderCBImpl; +//# sourceMappingURL=XMLBuilderCBImpl.js.map /***/ }), -/***/ 3730: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = (__nccwpck_require__(8229).isPlainObject); - - XMLDOMImplementation = __nccwpck_require__(8310); - - XMLDOMConfiguration = __nccwpck_require__(7465); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - XMLStringifier = __nccwpck_require__(8594); - - XMLStringWriter = __nccwpck_require__(5913); +/***/ 8248: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports = XMLDocument = (function(superClass) { - extend(XMLDocument, superClass); +"use strict"; - function XMLDocument(options) { - XMLDocument.__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); +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } - - Object.defineProperty(XMLDocument.prototype, 'implementation', { - value: new XMLDOMImplementation() - }); - - Object.defineProperty(XMLDocument.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; - } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); } - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'documentElement', { - get: function() { - return this.rootObject || null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'inputEncoding', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', { - get: function() { - return false; - } - }); - - Object.defineProperty(XMLDocument.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(XMLDocument.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(XMLDocument.prototype, 'xmlVersion', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].version; - } else { - return "1.0"; + finally { if (e) throw e.error; } + } + return ar; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } - } - }); - - Object.defineProperty(XMLDocument.prototype, 'URL', { - get: function() { - return this.documentURI; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'origin', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'compatMode', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'characterSet', { - get: function() { - return null; - } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var writers_1 = __nccwpck_require__(7476); +var interfaces_2 = __nccwpck_require__(7305); +var util_2 = __nccwpck_require__(5282); +var algorithm_1 = __nccwpck_require__(61); +var dom_1 = __nccwpck_require__(770); +var infra_1 = __nccwpck_require__(4251); +var readers_1 = __nccwpck_require__(560); +/** + * Represents a wrapper that extends XML nodes to implement easy to use and + * chainable document builder methods. + */ +var XMLBuilderImpl = /** @class */ (function () { + /** + * Initializes a new instance of `XMLBuilderNodeImpl`. + * + * @param domNode - the DOM node to wrap + */ + function XMLBuilderImpl(domNode) { + this._domNode = domNode; + } + Object.defineProperty(XMLBuilderImpl.prototype, "node", { + /** @inheritdoc */ + get: function () { return this._domNode; }, + enumerable: true, + configurable: true }); - - Object.defineProperty(XMLDocument.prototype, 'contentType', { - get: function() { - return null; - } + Object.defineProperty(XMLBuilderImpl.prototype, "options", { + /** @inheritdoc */ + get: function () { return this._options; }, + enumerable: true, + configurable: true }); - - XMLDocument.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)); - }; - - XMLDocument.prototype.toString = function(options) { - return this.options.writer.document(this, this.options.writer.filterOptions(options)); - }; - - XMLDocument.prototype.createElement = function(tagName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createDocumentFragment = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createTextNode = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createComment = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createCDATASection = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createProcessingInstruction = function(target, data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createAttribute = function(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createEntityReference = function(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.getElementsByTagName = function(tagname) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.importNode = function(importedNode, deep) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.getElementById = function(elementId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.adoptNode = function(source) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderImpl.prototype.set = function (options) { + this._options = util_1.applyDefaults(util_1.applyDefaults(this._options, options, true), // apply user settings + interfaces_1.DefaultBuilderOptions); // provide defaults + return this; }; - - XMLDocument.prototype.normalizeDocument = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderImpl.prototype.ele = function (p1, p2, p3) { + var _a, _b, _c; + var namespace; + var name; + var attributes; + if (util_1.isObject(p1)) { + // ele(obj: ExpandObject) + return new readers_1.ObjectReader(this._options).parse(this, p1); + } + else if (p1 !== null && /^\s*= 0) { - this.up(); - } - return this.onEnd(); - }; - - XMLDocumentCB.prototype.openCurrent = function() { - if (this.currentNode) { - this.currentNode.children = true; - return this.openNode(this.currentNode); - } - }; - - XMLDocumentCB.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; + else if (util_2.Guard.isDocumentFragmentNode(importedNode)) { + try { + // import child nodes + for (var _c = __values(importedNode.childNodes), _d = _c.next(); !_d.done; _d = _c.next()) { + var childNode = _d.value; + var clone = hostDoc.importNode(childNode, true); + hostNode.appendChild(clone); + if (util_2.Guard.isElementNode(clone)) { + var _e = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _e[0]; + var namespace = hostNode.lookupNamespaceURI(prefix); + new XMLBuilderImpl(clone)._updateNamespace(namespace); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_1) throw e_1.error; } + } } - 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) + ''; - } - chunk += this.writer.endline(node, this.writerOptions, this.currentLevel); + else { + // import node + var clone = hostDoc.importNode(importedNode, true); + hostNode.appendChild(clone); + if (util_2.Guard.isElementNode(clone)) { + var _f = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _f[0]; + var namespace = hostNode.lookupNamespaceURI(prefix); + new XMLBuilderImpl(clone)._updateNamespace(namespace); + } } - this.onData(chunk, this.currentLevel); - return node.isOpen = true; - } + return this; }; - - XMLDocumentCB.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) + '' + 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); + /** @inheritdoc */ + XMLBuilderImpl.prototype.doc = function () { + if (this._doc._isFragment) { + var node = this.node; + while (node && node.nodeType !== interfaces_2.NodeType.DocumentFragment) { + node = node.parentNode; + } + /* istanbul ignore next */ + if (node === null) { + throw new Error("Node has no parent node while searching for document fragment ancestor. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); + } + else { + return new XMLBuilderImpl(this._doc); } - this.writerOptions.state = WriterState.None; - this.onData(chunk, this.currentLevel); - return node.isClosed = true; - } }; - - XMLDocumentCB.prototype.onData = function(chunk, level) { - this.documentStarted = true; - return this.onDataCallback(chunk, level + 1); + /** @inheritdoc */ + XMLBuilderImpl.prototype.root = function () { + var ele = this._doc.documentElement; + if (!ele) { + throw new Error("Document root element is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(ele); }; - - XMLDocumentCB.prototype.onEnd = function() { - this.documentCompleted = true; - return this.onEndCallback(); + /** @inheritdoc */ + XMLBuilderImpl.prototype.up = function () { + var parent = this._domNode.parentNode; + if (!parent) { + throw new Error("Parent node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(parent); }; - - XMLDocumentCB.prototype.debugInfo = function(name) { - if (name == null) { - return ""; - } else { - return "node: <" + name + ">"; - } + /** @inheritdoc */ + XMLBuilderImpl.prototype.prev = function () { + var node = this._domNode.previousSibling; + if (!node) { + throw new Error("Previous sibling node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); }; - - XMLDocumentCB.prototype.ele = function() { - return this.element.apply(this, arguments); + /** @inheritdoc */ + XMLBuilderImpl.prototype.next = function () { + var node = this._domNode.nextSibling; + if (!node) { + throw new Error("Next sibling node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); }; - - XMLDocumentCB.prototype.nod = function(name, attributes, text) { - return this.node(name, attributes, text); + /** @inheritdoc */ + XMLBuilderImpl.prototype.first = function () { + var node = this._domNode.firstChild; + if (!node) { + throw new Error("First child node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); }; - - XMLDocumentCB.prototype.txt = function(value) { - return this.text(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.last = function () { + var node = this._domNode.lastChild; + if (!node) { + throw new Error("Last child node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); }; - - XMLDocumentCB.prototype.dat = function(value) { - return this.cdata(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.each = function (callback, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = this._getFirstDescendantNode(this._domNode, self, recursive); + while (result[0]) { + var nextResult = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + callback.call(thisArg, new XMLBuilderImpl(result[0]), result[1], result[2]); + result = nextResult; + } + return this; }; - - XMLDocumentCB.prototype.com = function(value) { - return this.comment(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.map = function (callback, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = []; + this.each(function (node, index, level) { + return result.push(callback.call(thisArg, node, index, level)); + }, self, recursive); + return result; }; - - XMLDocumentCB.prototype.ins = function(target, value) { - return this.instruction(target, value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.reduce = function (callback, initialValue, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var value = initialValue; + this.each(function (node, index, level) { + return value = callback.call(thisArg, value, node, index, level); + }, self, recursive); + return value; }; - - XMLDocumentCB.prototype.dec = function(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - }; - - XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) { - return this.doctype(root, pubID, sysID); - }; - - XMLDocumentCB.prototype.e = function(name, attributes, text) { - return this.element(name, attributes, text); + /** @inheritdoc */ + XMLBuilderImpl.prototype.find = function (predicate, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = this._getFirstDescendantNode(this._domNode, self, recursive); + while (result[0]) { + var builder = new XMLBuilderImpl(result[0]); + if (predicate.call(thisArg, builder, result[1], result[2])) { + return builder; + } + result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + } + return undefined; }; - - XMLDocumentCB.prototype.n = function(name, attributes, text) { - return this.node(name, attributes, text); + /** @inheritdoc */ + XMLBuilderImpl.prototype.filter = function (predicate, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = []; + this.each(function (node, index, level) { + if (predicate.call(thisArg, node, index, level)) { + result.push(node); + } + }, self, recursive); + return result; }; - - XMLDocumentCB.prototype.t = function(value) { - return this.text(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.every = function (predicate, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = this._getFirstDescendantNode(this._domNode, self, recursive); + while (result[0]) { + var builder = new XMLBuilderImpl(result[0]); + if (!predicate.call(thisArg, builder, result[1], result[2])) { + return false; + } + result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + } + return true; }; - - XMLDocumentCB.prototype.d = function(value) { - return this.cdata(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.some = function (predicate, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = this._getFirstDescendantNode(this._domNode, self, recursive); + while (result[0]) { + var builder = new XMLBuilderImpl(result[0]); + if (predicate.call(thisArg, builder, result[1], result[2])) { + return true; + } + result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + } + return false; }; - - XMLDocumentCB.prototype.c = function(value) { - return this.comment(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.toArray = function (self, recursive) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = []; + this.each(function (node) { return result.push(node); }, self, recursive); + return result; }; - - XMLDocumentCB.prototype.r = function(value) { - return this.raw(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.toString = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "xml"; + } + return this._serialize(writerOptions); }; - - XMLDocumentCB.prototype.i = function(target, value) { - return this.instruction(target, value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.toObject = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "object"; + } + return this._serialize(writerOptions); }; - - XMLDocumentCB.prototype.att = function() { - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - return this.attList.apply(this, arguments); - } else { - return this.attribute.apply(this, arguments); - } + /** @inheritdoc */ + XMLBuilderImpl.prototype.end = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "xml"; + } + return this.doc()._serialize(writerOptions); }; - - XMLDocumentCB.prototype.a = function() { - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - return this.attList.apply(this, arguments); - } else { - return this.attribute.apply(this, arguments); - } + /** + * Gets the next descendant of the given node of the tree rooted at `root` + * in depth-first pre-order. Returns a three-tuple with + * [descendant, descendant_index, descendant_level]. + * + * @param root - root node of the tree + * @param self - whether to visit the current node along with child nodes + * @param recursive - whether to visit all descendant nodes in tree-order or + * only the immediate child nodes + */ + XMLBuilderImpl.prototype._getFirstDescendantNode = function (root, self, recursive) { + if (self) + return [this._domNode, 0, 0]; + else if (recursive) + return this._getNextDescendantNode(root, root, recursive, 0, 0); + else + return [this._domNode.firstChild, 0, 1]; }; - - XMLDocumentCB.prototype.ent = function(name, value) { - return this.entity(name, value); + /** + * Gets the next descendant of the given node of the tree rooted at `root` + * in depth-first pre-order. Returns a three-tuple with + * [descendant, descendant_index, descendant_level]. + * + * @param root - root node of the tree + * @param node - current node + * @param recursive - whether to visit all descendant nodes in tree-order or + * only the immediate child nodes + * @param index - child node index + * @param level - current depth of the XML tree + */ + XMLBuilderImpl.prototype._getNextDescendantNode = function (root, node, recursive, index, level) { + if (recursive) { + // traverse child nodes + if (node.firstChild) + return [node.firstChild, 0, level + 1]; + if (node === root) + return [null, -1, -1]; + // traverse siblings + if (node.nextSibling) + return [node.nextSibling, index + 1, level]; + // traverse parent's next sibling + var parent = node.parentNode; + while (parent && parent !== root) { + if (parent.nextSibling) + return [parent.nextSibling, algorithm_1.tree_index(parent.nextSibling), level - 1]; + parent = parent.parentNode; + level--; + } + } + else { + if (root === node) + return [node.firstChild, 0, level + 1]; + else + return [node.nextSibling, index + 1, level]; + } + return [null, -1, -1]; }; - - XMLDocumentCB.prototype.pent = function(name, value) { - return this.pEntity(name, value); + /** + * Converts the node into its string or object representation. + * + * @param options - serialization options + */ + XMLBuilderImpl.prototype._serialize = function (writerOptions) { + if (writerOptions.format === "xml") { + var writer = new writers_1.XMLWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "map") { + var writer = new writers_1.MapWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "object") { + var writer = new writers_1.ObjectWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "json") { + var writer = new writers_1.JSONWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "yaml") { + var writer = new writers_1.YAMLWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else { + throw new Error("Invalid writer format: " + writerOptions.format + ". " + this._debugInfo()); + } }; - - XMLDocumentCB.prototype.not = function(name, value) { - return this.notation(name, value); + /** + * Extracts a namespace and name from the given string. + * + * @param namespace - namespace + * @param name - a string containing both a name and namespace separated by an + * `'@'` character + * @param ele - `true` if this is an element namespace; otherwise `false` + */ + XMLBuilderImpl.prototype._extractNamespace = function (namespace, name, ele) { + // extract from name + var atIndex = name.indexOf("@"); + if (atIndex > 0) { + if (namespace === undefined) + namespace = name.slice(atIndex + 1); + name = name.slice(0, atIndex); + } + if (namespace === undefined) { + // look-up default namespace + namespace = (ele ? this._options.defaultNamespace.ele : this._options.defaultNamespace.att); + } + else if (namespace !== null && namespace[0] === "@") { + // look-up namespace aliases + var alias = namespace.slice(1); + namespace = this._options.namespaceAlias[alias]; + if (namespace === undefined) { + throw new Error("Namespace alias `" + alias + "` is not defined. " + this._debugInfo()); + } + } + return [namespace, name]; }; + /** + * Updates the element's namespace. + * + * @param ns - new namespace + */ + XMLBuilderImpl.prototype._updateNamespace = function (ns) { + var e_2, _a, e_3, _b; + var ele = this._domNode; + if (util_2.Guard.isElementNode(ele) && ns !== null && ele.namespaceURI !== ns) { + var _c = __read(algorithm_1.namespace_extractQName(ele.prefix ? ele.prefix + ':' + ele.localName : ele.localName), 2), elePrefix = _c[0], eleLocalName = _c[1]; + // re-create the element node if its namespace changed + // we can't simply change the namespaceURI since its read-only + var newEle = algorithm_1.create_element(this._doc, eleLocalName, ns, elePrefix); + try { + for (var _d = __values(ele.attributes), _e = _d.next(); !_e.done; _e = _d.next()) { + var attr = _e.value; + var attrQName = attr.prefix ? attr.prefix + ':' + attr.localName : attr.localName; + var _f = __read(algorithm_1.namespace_extractQName(attrQName), 1), attrPrefix = _f[0]; + var newAttrNS = attr.namespaceURI; + if (newAttrNS === null && attrPrefix !== null) { + newAttrNS = ele.lookupNamespaceURI(attrPrefix); + } + if (newAttrNS === null) { + newEle.setAttribute(attrQName, attr.value); + } + else { + newEle.setAttributeNS(newAttrNS, attrQName, attr.value); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_e && !_e.done && (_a = _d.return)) _a.call(_d); + } + finally { if (e_2) throw e_2.error; } + } + // replace the new node in parent node + var parent = ele.parentNode; + /* istanbul ignore next */ + if (parent === null) { + throw new Error("Parent node is null." + this._debugInfo()); + } + parent.replaceChild(newEle, ele); + this._domNode = newEle; + try { + // check child nodes + for (var _g = __values(ele.childNodes), _h = _g.next(); !_h.done; _h = _g.next()) { + var childNode = _h.value; + var newChildNode = childNode.cloneNode(true); + newEle.appendChild(newChildNode); + if (util_2.Guard.isElementNode(newChildNode)) { + var _j = __read(algorithm_1.namespace_extractQName(newChildNode.prefix ? newChildNode.prefix + ':' + newChildNode.localName : newChildNode.localName), 1), newChildNodePrefix = _j[0]; + var newChildNodeNS = newEle.lookupNamespaceURI(newChildNodePrefix); + new XMLBuilderImpl(newChildNode)._updateNamespace(newChildNodeNS); + } + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_h && !_h.done && (_b = _g.return)) _b.call(_g); + } + finally { if (e_3) throw e_3.error; } + } + } + }; + Object.defineProperty(XMLBuilderImpl.prototype, "_doc", { + /** + * Returns the document owning this node. + */ + get: function () { + var node = this.node; + if (util_2.Guard.isDocumentNode(node)) { + return node; + } + else { + var docNode = node.ownerDocument; + /* istanbul ignore next */ + if (!docNode) + throw new Error("Owner document is null. " + this._debugInfo()); + return docNode; + } + }, + enumerable: true, + configurable: true + }); + /** + * Returns debug information for this node. + * + * @param name - node name + */ + XMLBuilderImpl.prototype._debugInfo = function (name) { + var node = this.node; + var parentNode = node.parentNode; + name = name || node.nodeName; + var parentName = parentNode ? parentNode.nodeName : ''; + if (!parentName) { + return "node: <" + name + ">"; + } + else { + return "node: <" + name + ">, parent: <" + parentName + ">"; + } + }; + Object.defineProperty(XMLBuilderImpl.prototype, "_options", { + /** + * Gets or sets builder options. + */ + get: function () { + var doc = this._doc; + /* istanbul ignore next */ + if (doc._xmlBuilderOptions === undefined) { + throw new Error("Builder options is not set."); + } + return doc._xmlBuilderOptions; + }, + set: function (value) { + var doc = this._doc; + doc._xmlBuilderOptions = value; + }, + enumerable: true, + configurable: true + }); + return XMLBuilderImpl; +}()); +exports.XMLBuilderImpl = XMLBuilderImpl; +//# sourceMappingURL=XMLBuilderImpl.js.map - return XMLDocumentCB; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 3590: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); +/***/ }), - NodeType = __nccwpck_require__(9267); +/***/ 770: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - module.exports = XMLDummy = (function(superClass) { - extend(XMLDummy, superClass); +"use strict"; - function XMLDummy(parent) { - XMLDummy.__super__.constructor.call(this, parent); - this.type = NodeType.Dummy; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var dom_1 = __nccwpck_require__(4646); +var dom_2 = __nccwpck_require__(633); +var util_1 = __nccwpck_require__(6195); +dom_2.dom.setFeatures(false); +/** + * Creates an XML document without any child nodes. + */ +function createDocument() { + var impl = new dom_1.DOMImplementation(); + var doc = impl.createDocument(null, 'root', null); + /* istanbul ignore else */ + if (doc.documentElement) { + doc.removeChild(doc.documentElement); } + return doc; +} +exports.createDocument = createDocument; +/** + * Sanitizes input strings with user supplied replacement characters. + * + * @param str - input string + * @param replacement - replacement character or function + */ +function sanitizeInput(str, replacement) { + if (str == null) { + return str; + } + else if (replacement === undefined) { + return str + ""; + } + else { + var result = ""; + str = str + ""; + for (var i = 0; i < str.length; i++) { + var n = str.charCodeAt(i); + // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] + if (n === 0x9 || n === 0xA || n === 0xD || + (n >= 0x20 && n <= 0xD7FF) || + (n >= 0xE000 && n <= 0xFFFD)) { + // valid character - not surrogate pair + result += str.charAt(i); + } + else if (n >= 0xD800 && n <= 0xDBFF && i < str.length - 1) { + var n2 = str.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + // valid surrogate pair + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + result += String.fromCodePoint(n); + i++; + } + else { + // invalid lone surrogate + result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); + } + } + else { + // invalid character + result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); + } + } + return result; + } +} +exports.sanitizeInput = sanitizeInput; +//# sourceMappingURL=dom.js.map - XMLDummy.prototype.clone = function() { - return Object.create(this); - }; - - XMLDummy.prototype.toString = function(options) { - return ''; - }; - - return XMLDummy; +/***/ }), - })(XMLNode); +/***/ 4260: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -}).call(this); +"use strict"; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var XMLBuilderImpl_1 = __nccwpck_require__(8248); +exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; +var XMLBuilderCBImpl_1 = __nccwpck_require__(1438); +exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; +var BuilderFunctions_1 = __nccwpck_require__(5696); +exports.builder = BuilderFunctions_1.builder; +exports.create = BuilderFunctions_1.create; +exports.fragment = BuilderFunctions_1.fragment; +exports.convert = BuilderFunctions_1.convert; +var BuilderFunctionsCB_1 = __nccwpck_require__(268); +exports.createCB = BuilderFunctionsCB_1.createCB; +exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; +//# sourceMappingURL=index.js.map /***/ }), -/***/ 9437: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +/***/ 151: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -// Generated by CoffeeScript 1.12.7 -(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; +"use strict"; - ref = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var builder_1 = __nccwpck_require__(4260); +exports.builder = builder_1.builder; +exports.create = builder_1.create; +exports.fragment = builder_1.fragment; +exports.convert = builder_1.convert; +exports.createCB = builder_1.createCB; +exports.fragmentCB = builder_1.fragmentCB; +//# sourceMappingURL=index.js.map - XMLNode = __nccwpck_require__(7608); +/***/ }), - NodeType = __nccwpck_require__(9267); - - XMLAttribute = __nccwpck_require__(8376); - - XMLNamedNodeMap = __nccwpck_require__(4361); +/***/ 6417: +/***/ ((__unused_webpack_module, exports) => { - module.exports = XMLElement = (function(superClass) { - extend(XMLElement, superClass); +"use strict"; - function XMLElement(parent, name, attributes) { - var child, j, len, ref1; - XMLElement.__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(exports, "__esModule", ({ value: true })); +/** + * Defines default values for builder options. + */ +exports.DefaultBuilderOptions = { + version: "1.0", + encoding: undefined, + standalone: undefined, + keepNullNodes: false, + keepNullAttributes: false, + ignoreConverters: false, + convert: { + att: "@", + ins: "?", + text: "#", + cdata: "$", + comment: "!" + }, + defaultNamespace: { + ele: undefined, + att: undefined + }, + namespaceAlias: { + html: "http://www.w3.org/1999/xhtml", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/", + mathml: "http://www.w3.org/1998/Math/MathML", + svg: "http://www.w3.org/2000/svg", + xlink: "http://www.w3.org/1999/xlink" + }, + invalidCharReplacement: undefined, + parser: undefined +}; +/** + * Contains keys of `XMLBuilderOptions`. + */ +exports.XMLBuilderOptionKeys = new Set(Object.keys(exports.DefaultBuilderOptions)); +/** + * Defines default values for builder options. + */ +exports.DefaultXMLBuilderCBOptions = { + format: "xml", + wellFormed: false, + prettyPrint: false, + indent: " ", + newline: "\n", + offset: 0, + width: 0, + allowEmptyTags: false, + spaceBeforeSlash: false, + keepNullNodes: false, + keepNullAttributes: false, + ignoreConverters: false, + convert: { + att: "@", + ins: "?", + text: "#", + cdata: "$", + comment: "!" + }, + defaultNamespace: { + ele: undefined, + att: undefined + }, + namespaceAlias: { + html: "http://www.w3.org/1999/xhtml", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/", + mathml: "http://www.w3.org/1998/Math/MathML", + svg: "http://www.w3.org/2000/svg", + xlink: "http://www.w3.org/1999/xlink" } +}; +//# sourceMappingURL=interfaces.js.map - Object.defineProperty(XMLElement.prototype, 'tagName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLElement.prototype, 'namespaceURI', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLElement.prototype, 'prefix', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLElement.prototype, 'localName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLElement.prototype, 'id', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +/***/ }), - Object.defineProperty(XMLElement.prototype, 'className', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +/***/ 3396: +/***/ ((__unused_webpack_module, exports) => { - Object.defineProperty(XMLElement.prototype, 'classList', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +"use strict"; - Object.defineProperty(XMLElement.prototype, 'attributes', { - get: function() { - if (!this.attributeMap || !this.attributeMap.nodes) { - this.attributeMap = new XMLNamedNodeMap(this.attribs); +Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * Pre-serializes XML nodes. + */ +var BaseReader = /** @class */ (function () { + /** + * Initializes a new instance of `BaseReader`. + * + * @param builderOptions - XML builder options + */ + function BaseReader(builderOptions) { + this._builderOptions = builderOptions; + if (builderOptions.parser) { + Object.assign(this, builderOptions.parser); } - return this.attributeMap; - } - }); - - XMLElement.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; + } + BaseReader.prototype._docType = function (parent, name, publicId, systemId) { + return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); }; - - XMLElement.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; + BaseReader.prototype._comment = function (parent, data) { + return parent.com(data); }; - - XMLElement.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; + BaseReader.prototype._text = function (parent, data) { + return parent.txt(data); }; - - XMLElement.prototype.toString = function(options) { - return this.options.writer.element(this, this.options.writer.filterOptions(options)); + BaseReader.prototype._instruction = function (parent, target, data) { + return parent.ins(target, data); }; - - XMLElement.prototype.att = function(name, value) { - return this.attribute(name, value); + BaseReader.prototype._cdata = function (parent, data) { + return parent.dat(data); }; - - XMLElement.prototype.a = function(name, value) { - return this.attribute(name, value); - }; - - XMLElement.prototype.getAttribute = function(name) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name].value; - } else { - return null; - } + BaseReader.prototype._element = function (parent, namespace, name) { + return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); }; - - XMLElement.prototype.setAttribute = function(name, value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + BaseReader.prototype._attribute = function (parent, namespace, name, value) { + return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); }; - - XMLElement.prototype.getAttributeNode = function(name) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name]; - } else { - return null; - } + /** + * Main parser function which parses the given object and returns an XMLBuilder. + * + * @param node - node to recieve parsed content + * @param obj - object to parse + */ + BaseReader.prototype.parse = function (node, obj) { + return this._parse(node, obj); }; - - XMLElement.prototype.setAttributeNode = function(newAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Creates a DocType node. + * The node will be skipped if the function returns `undefined`. + * + * @param name - node name + * @param publicId - public identifier + * @param systemId - system identifier + */ + BaseReader.prototype.docType = function (parent, name, publicId, systemId) { + return this._docType(parent, name, publicId, systemId); }; - - XMLElement.prototype.removeAttributeNode = function(oldAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Creates a comment node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.comment = function (parent, data) { + return this._comment(parent, data); }; - - XMLElement.prototype.getElementsByTagName = function(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Creates a text node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.text = function (parent, data) { + return this._text(parent, data); }; - - XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Creates a processing instruction node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param target - instruction target + * @param data - node data + */ + BaseReader.prototype.instruction = function (parent, target, data) { + return this._instruction(parent, target, data); }; - - XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Creates a CData section node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.cdata = function (parent, data) { + return this._cdata(parent, data); }; - - XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Creates an element node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param namespace - node namespace + * @param name - node name + */ + BaseReader.prototype.element = function (parent, namespace, name) { + return this._element(parent, namespace, name); }; - - XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Creates an attribute or namespace declaration. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param namespace - node namespace + * @param name - node name + * @param value - node value + */ + BaseReader.prototype.attribute = function (parent, namespace, name, value) { + return this._attribute(parent, namespace, name, value); }; + return BaseReader; +}()); +exports.BaseReader = BaseReader; +//# sourceMappingURL=BaseReader.js.map - XMLElement.prototype.setAttributeNodeNS = function(newAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +/***/ }), - XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +/***/ 3518: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLElement.prototype.hasAttribute = function(name) { - return this.attribs.hasOwnProperty(name); - }; +"use strict"; - XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLElement.prototype.setIdAttribute = function(name, isId) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name].isId; - } else { - return isId; - } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectReader_1 = __nccwpck_require__(768); +var BaseReader_1 = __nccwpck_require__(3396); +/** + * Parses XML nodes from a JSON string. + */ +var JSONReader = /** @class */ (function (_super) { + __extends(JSONReader, _super); + function JSONReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - JSON string to parse + */ + JSONReader.prototype._parse = function (node, str) { + return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, JSON.parse(str)); }; + return JSONReader; +}(BaseReader_1.BaseReader)); +exports.JSONReader = JSONReader; +//# sourceMappingURL=JSONReader.js.map - XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +/***/ }), - XMLElement.prototype.getElementsByTagName = function(tagname) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +/***/ 768: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +"use strict"; - XMLElement.prototype.getElementsByClassName = function(classNames) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLElement.prototype.isEqualNode = function(node) { - var i, j, ref1; - if (!XMLElement.__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 function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - return XMLElement; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 4361: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLNamedNodeMap; - - module.exports = XMLNamedNodeMap = (function() { - function XMLNamedNodeMap(nodes) { - this.nodes = nodes; - } - - Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { - get: function() { - return Object.keys(this.nodes).length || 0; - } - }); - - XMLNamedNodeMap.prototype.clone = function() { - return this.nodes = null; - }; - - XMLNamedNodeMap.prototype.getNamedItem = function(name) { - return this.nodes[name]; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var BaseReader_1 = __nccwpck_require__(3396); +var dom_1 = __nccwpck_require__(770); +/** + * Parses XML nodes from objects and arrays. + * ES6 maps and sets are also supoorted. + */ +var ObjectReader = /** @class */ (function (_super) { + __extends(ObjectReader, _super); + function ObjectReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param obj - object to parse + */ + ObjectReader.prototype._parse = function (node, obj) { + var _this = this; + var options = this._builderOptions; + // sanitizes input characters + var invalidCharReplacement = options.invalidCharReplacement; + var s = function (str) { + return dom_1.sanitizeInput(str, invalidCharReplacement); + }; + var lastChild = null; + if (util_1.isFunction(obj)) { + // evaluate if function + lastChild = this.parse(node, obj.apply(this)); + } + else if (util_1.isArray(obj) || util_1.isSet(obj)) { + util_1.forEachArray(obj, function (item) { return lastChild = _this.parse(node, item); }, this); + } + else /* if (isMap(obj) || isObject(obj)) */ { + // expand if object + util_1.forEachObject(obj, function (key, val) { + if (util_1.isFunction(val)) { + // evaluate if function + val = val.apply(_this); + } + if (!options.ignoreConverters && key.indexOf(options.convert.att) === 0) { + // assign attributes + if (key === options.convert.att) { + if (util_1.isArray(val) || util_1.isSet(val)) { + throw new Error("Invalid attribute: " + val.toString() + ". " + node._debugInfo()); + } + else /* if (isMap(val) || isObject(val)) */ { + util_1.forEachObject(val, function (attrKey, attrVal) { + lastChild = _this.attribute(node, undefined, s(attrKey), s(attrVal)) || lastChild; + }); + } + } + else { + lastChild = _this.attribute(node, undefined, s(key.substr(options.convert.att.length)), s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.text) === 0) { + // text node + if (util_1.isMap(val) || util_1.isObject(val)) { + // if the key is #text expand child nodes under this node to support mixed content + lastChild = _this.parse(node, val); + } + else { + lastChild = _this.text(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.cdata) === 0) { + // cdata node + if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { return lastChild = _this.cdata(node, s(item)) || lastChild; }, _this); + } + else { + lastChild = _this.cdata(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.comment) === 0) { + // comment node + if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { return lastChild = _this.comment(node, s(item)) || lastChild; }, _this); + } + else { + lastChild = _this.comment(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.ins) === 0) { + // processing instruction + if (util_1.isString(val)) { + var insIndex = val.indexOf(' '); + var insTarget = (insIndex === -1 ? val : val.substr(0, insIndex)); + var insValue = (insIndex === -1 ? '' : val.substr(insIndex + 1)); + lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; + } + else if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { + var insIndex = item.indexOf(' '); + var insTarget = (insIndex === -1 ? item : item.substr(0, insIndex)); + var insValue = (insIndex === -1 ? '' : item.substr(insIndex + 1)); + lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; + }, _this); + } + else /* if (isMap(target) || isObject(target)) */ { + util_1.forEachObject(val, function (insTarget, insValue) { return lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; }, _this); + } + } + else if ((util_1.isArray(val) || util_1.isSet(val)) && util_1.isEmpty(val)) { + // skip empty arrays + } + else if ((util_1.isMap(val) || util_1.isObject(val)) && util_1.isEmpty(val)) { + // empty objects produce one node + lastChild = _this.element(node, undefined, s(key)) || lastChild; + } + else if (!options.keepNullNodes && (val == null)) { + // skip null and undefined nodes + } + else if (util_1.isArray(val) || util_1.isSet(val)) { + // expand list by creating child nodes + util_1.forEachArray(val, function (item) { + var childNode = {}; + childNode[key] = item; + lastChild = _this.parse(node, childNode); + }, _this); + } + else if (util_1.isMap(val) || util_1.isObject(val)) { + // create a parent node + var parent = _this.element(node, undefined, key); + if (parent) { + lastChild = parent; + // expand child nodes under parent + _this.parse(parent, val); + } + } + else if (val != null && val !== '') { + // leaf element node with a single text node + var parent = _this.element(node, undefined, key); + if (parent) { + lastChild = parent; + _this.text(parent, s(val)); + } + } + else { + // leaf element node + lastChild = _this.element(node, undefined, s(key)) || lastChild; + } + }, this); + } + return lastChild || node; }; + return ObjectReader; +}(BaseReader_1.BaseReader)); +exports.ObjectReader = ObjectReader; +//# sourceMappingURL=ObjectReader.js.map - XMLNamedNodeMap.prototype.setNamedItem = function(node) { - var oldNode; - oldNode = this.nodes[node.nodeName]; - this.nodes[node.nodeName] = node; - return oldNode || null; - }; +/***/ }), - XMLNamedNodeMap.prototype.removeNamedItem = function(name) { - var oldNode; - oldNode = this.nodes[name]; - delete this.nodes[name]; - return oldNode || null; - }; +/***/ 5044: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLNamedNodeMap.prototype.item = function(index) { - return this.nodes[Object.keys(this.nodes)[index]] || null; - }; +"use strict"; - XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented."); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLNamedNodeMap.prototype.setNamedItemNS = function(node) { - throw new Error("This DOM method is not implemented."); + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented."); +})(); +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var XMLStringLexer_1 = __nccwpck_require__(7061); +var interfaces_1 = __nccwpck_require__(7707); +var infra_1 = __nccwpck_require__(4251); +var algorithm_1 = __nccwpck_require__(61); +var dom_1 = __nccwpck_require__(770); +var BaseReader_1 = __nccwpck_require__(3396); +/** + * Parses XML nodes from an XML document string. + */ +var XMLReader = /** @class */ (function (_super) { + __extends(XMLReader, _super); + function XMLReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - XML document string to parse + */ + XMLReader.prototype._parse = function (node, str) { + var e_1, _a, e_2, _b; + var lexer = new XMLStringLexer_1.XMLStringLexer(str, { skipWhitespaceOnlyText: true }); + // sanitizes input characters + var invalidCharReplacement = this._builderOptions.invalidCharReplacement; + var s = function (str) { + return dom_1.sanitizeInput(str, invalidCharReplacement); + }; + var context = node; + var token = lexer.nextToken(); + while (token.type !== interfaces_1.TokenType.EOF) { + switch (token.type) { + case interfaces_1.TokenType.Declaration: + var declaration = token; + var version = s(declaration.version); + if (version !== "1.0") { + throw new Error("Invalid xml version: " + version); + } + var builderOptions = { + version: version + }; + if (declaration.encoding) { + builderOptions.encoding = s(declaration.encoding); + } + if (declaration.standalone) { + builderOptions.standalone = (s(declaration.standalone) === "yes"); + } + context.set(builderOptions); + break; + case interfaces_1.TokenType.DocType: + var doctype = token; + context = this.docType(context, s(doctype.name), s(doctype.pubId), s(doctype.sysId)) || context; + break; + case interfaces_1.TokenType.CDATA: + var cdata = token; + context = this.cdata(context, s(cdata.data)) || context; + break; + case interfaces_1.TokenType.Comment: + var comment = token; + context = this.comment(context, s(comment.data)) || context; + break; + case interfaces_1.TokenType.PI: + var pi = token; + context = this.instruction(context, s(pi.target), s(pi.data)) || context; + break; + case interfaces_1.TokenType.Text: + var text = token; + context = this.text(context, s(text.data)) || context; + break; + case interfaces_1.TokenType.Element: + var element = token; + var elementName = s(element.name); + // inherit namespace from parent + var _c = __read(algorithm_1.namespace_extractQName(elementName), 1), prefix = _c[0]; + var namespace = context.node.lookupNamespaceURI(prefix); + // override namespace if there is a namespace declaration + // attribute + // also lookup namespace declaration attributes + var nsDeclarations = {}; + try { + for (var _d = (e_1 = void 0, __values(element.attributes)), _e = _d.next(); !_e.done; _e = _d.next()) { + var _f = __read(_e.value, 2), attName = _f[0], attValue = _f[1]; + attName = s(attName); + attValue = s(attValue); + if (attName === "xmlns") { + namespace = attValue; + } + else { + var _g = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _g[0], attLocalName = _g[1]; + if (attPrefix === "xmlns") { + if (attLocalName === prefix) { + namespace = attValue; + } + nsDeclarations[attLocalName] = attValue; + } + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_e && !_e.done && (_a = _d.return)) _a.call(_d); + } + finally { if (e_1) throw e_1.error; } + } + // create the DOM element node + var elementNode = (namespace !== null ? + this.element(context, namespace, elementName) : + this.element(context, undefined, elementName)); + if (elementNode === undefined) + break; + try { + // assign attributes + for (var _h = (e_2 = void 0, __values(element.attributes)), _j = _h.next(); !_j.done; _j = _h.next()) { + var _k = __read(_j.value, 2), attName = _k[0], attValue = _k[1]; + attName = s(attName); + attValue = s(attValue); + var _l = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _l[0], attLocalName = _l[1]; + var attNamespace = null; + if (attPrefix === "xmlns" || (attPrefix === null && attLocalName === "xmlns")) { + // namespace declaration attribute + attNamespace = infra_1.namespace.XMLNS; + } + else { + attNamespace = elementNode.node.lookupNamespaceURI(attPrefix); + if (attNamespace !== null && elementNode.node.isDefaultNamespace(attNamespace)) { + attNamespace = null; + } + else if (attNamespace === null && attPrefix !== null) { + attNamespace = nsDeclarations[attPrefix] || null; + } + } + if (attNamespace !== null) + this.attribute(elementNode, attNamespace, attName, attValue); + else + this.attribute(elementNode, undefined, attName, attValue); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_j && !_j.done && (_b = _h.return)) _b.call(_h); + } + finally { if (e_2) throw e_2.error; } + } + if (!element.selfClosing) { + context = elementNode; + } + break; + case interfaces_1.TokenType.ClosingTag: + /* istanbul ignore else */ + if (context.node.parentNode) { + context = context.up(); + } + break; + } + token = lexer.nextToken(); + } + return context; + }; + return XMLReader; +}(BaseReader_1.BaseReader)); +exports.XMLReader = XMLReader; +//# sourceMappingURL=XMLReader.js.map - return XMLNamedNodeMap; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 7608: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1, - hasProp = {}.hasOwnProperty; - - ref1 = __nccwpck_require__(8229), 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; +/***/ 2475: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - NodeType = null; +"use strict"; - XMLNodeList = null; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectReader_1 = __nccwpck_require__(768); +var BaseReader_1 = __nccwpck_require__(3396); +var js_yaml_1 = __nccwpck_require__(1917); +/** + * Parses XML nodes from a YAML string. + */ +var YAMLReader = /** @class */ (function (_super) { + __extends(YAMLReader, _super); + function YAMLReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - YAML string to parse + */ + YAMLReader.prototype._parse = function (node, str) { + var result = js_yaml_1.safeLoad(str); + /* istanbul ignore next */ + if (result === undefined) { + throw new Error("Unable to parse YAML document."); + } + return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, result); + }; + return YAMLReader; +}(BaseReader_1.BaseReader)); +exports.YAMLReader = YAMLReader; +//# sourceMappingURL=YAMLReader.js.map - XMLNamedNodeMap = null; +/***/ }), - DocumentPosition = null; +/***/ 560: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - module.exports = XMLNode = (function() { - function XMLNode(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 = __nccwpck_require__(9437); - XMLCData = __nccwpck_require__(333); - XMLComment = __nccwpck_require__(4407); - XMLDeclaration = __nccwpck_require__(6364); - XMLDocType = __nccwpck_require__(1801); - XMLRaw = __nccwpck_require__(6329); - XMLText = __nccwpck_require__(1318); - XMLProcessingInstruction = __nccwpck_require__(6939); - XMLDummy = __nccwpck_require__(3590); - NodeType = __nccwpck_require__(9267); - XMLNodeList = __nccwpck_require__(6768); - XMLNamedNodeMap = __nccwpck_require__(4361); - DocumentPosition = __nccwpck_require__(2839); - } - } +"use strict"; - Object.defineProperty(XMLNode.prototype, 'nodeName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLNode.prototype, 'nodeType', { - get: function() { - return this.type; - } - }); - - Object.defineProperty(XMLNode.prototype, 'nodeValue', { - get: function() { - return this.value; - } - }); - - Object.defineProperty(XMLNode.prototype, 'parentNode', { - get: function() { - return this.parent; - } - }); - - Object.defineProperty(XMLNode.prototype, 'childNodes', { - get: function() { - if (!this.childNodeList || !this.childNodeList.nodes) { - this.childNodeList = new XMLNodeList(this.children); - } - return this.childNodeList; - } - }); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var XMLReader_1 = __nccwpck_require__(5044); +exports.XMLReader = XMLReader_1.XMLReader; +var ObjectReader_1 = __nccwpck_require__(768); +exports.ObjectReader = ObjectReader_1.ObjectReader; +var JSONReader_1 = __nccwpck_require__(3518); +exports.JSONReader = JSONReader_1.JSONReader; +var YAMLReader_1 = __nccwpck_require__(2475); +exports.YAMLReader = YAMLReader_1.YAMLReader; +//# sourceMappingURL=index.js.map - Object.defineProperty(XMLNode.prototype, 'firstChild', { - get: function() { - return this.children[0] || null; - } - }); +/***/ }), - Object.defineProperty(XMLNode.prototype, 'lastChild', { - get: function() { - return this.children[this.children.length - 1] || null; - } - }); +/***/ 708: +/***/ ((__unused_webpack_module, exports) => { - Object.defineProperty(XMLNode.prototype, 'previousSibling', { - get: function() { - var i; - i = this.parent.children.indexOf(this); - return this.parent.children[i - 1] || null; - } - }); +"use strict"; - Object.defineProperty(XMLNode.prototype, 'nextSibling', { - get: function() { - var i; - i = this.parent.children.indexOf(this); - return this.parent.children[i + 1] || null; - } - }); +Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * Pre-serializes XML nodes. + */ +var BaseCBWriter = /** @class */ (function () { + /** + * Initializes a new instance of `BaseCBWriter`. + * + * @param builderOptions - XML builder options + */ + function BaseCBWriter(builderOptions) { + /** + * Gets the current depth of the XML tree. + */ + this.level = 0; + this._builderOptions = builderOptions; + this._writerOptions = builderOptions; + } + return BaseCBWriter; +}()); +exports.BaseCBWriter = BaseCBWriter; +//# sourceMappingURL=BaseCBWriter.js.map - Object.defineProperty(XMLNode.prototype, 'ownerDocument', { - get: function() { - return this.document() || null; - } - }); +/***/ }), - Object.defineProperty(XMLNode.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()); - } - }); +/***/ 7644: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLNode.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; - }; +"use strict"; - XMLNode.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); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } - } - if (lastChild == null) { - throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo()); - } - return lastChild; }; - - XMLNode.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)); + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); } - 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; - } - }; - - XMLNode.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; - }; - - XMLNode.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; - }; - - XMLNode.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; - }; - - XMLNode.prototype.text = function(value) { - var child; - if (isObject(value)) { - this.element(value); - } - child = new XMLText(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.cdata = function(value) { - var child; - child = new XMLCData(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.comment = function(value) { - var child; - child = new XMLComment(this, value); - this.children.push(child); - return this; - }; - - XMLNode.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; - }; - - XMLNode.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; - }; - - XMLNode.prototype.raw = function(value) { - var child; - child = new XMLRaw(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.dummy = function() { - var child; - child = new XMLDummy(this); - return child; - }; - - XMLNode.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); + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(7305); +var LocalNameSet_1 = __nccwpck_require__(9049); +var NamespacePrefixMap_1 = __nccwpck_require__(283); +var infra_1 = __nccwpck_require__(4251); +var algorithm_1 = __nccwpck_require__(61); +/** + * Pre-serializes XML nodes. + */ +var BaseWriter = /** @class */ (function () { + /** + * Initializes a new instance of `BaseWriter`. + * + * @param builderOptions - XML builder options + */ + function BaseWriter(builderOptions) { + /** + * Gets the current depth of the XML tree. + */ + this.level = 0; + this._builderOptions = builderOptions; + } + /** + * Used by derived classes to serialize the XML declaration. + * + * @param version - a version number string + * @param encoding - encoding declaration + * @param standalone - standalone document declaration + */ + BaseWriter.prototype.declaration = function (version, encoding, standalone) { }; + /** + * Used by derived classes to serialize a DocType node. + * + * @param name - node name + * @param publicId - public identifier + * @param systemId - system identifier + */ + BaseWriter.prototype.docType = function (name, publicId, systemId) { }; + /** + * Used by derived classes to serialize a comment node. + * + * @param data - node data + */ + BaseWriter.prototype.comment = function (data) { }; + /** + * Used by derived classes to serialize a text node. + * + * @param data - node data + */ + BaseWriter.prototype.text = function (data) { }; + /** + * Used by derived classes to serialize a processing instruction node. + * + * @param target - instruction target + * @param data - node data + */ + BaseWriter.prototype.instruction = function (target, data) { }; + /** + * Used by derived classes to serialize a CData section node. + * + * @param data - node data + */ + BaseWriter.prototype.cdata = function (data) { }; + /** + * Used by derived classes to serialize the beginning of the opening tag of an + * element node. + * + * @param name - node name + */ + BaseWriter.prototype.openTagBegin = function (name) { }; + /** + * Used by derived classes to serialize the ending of the opening tag of an + * element node. + * + * @param name - node name + * @param selfClosing - whether the element node is self closing + * @param voidElement - whether the element node is a HTML void element + */ + BaseWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { }; + /** + * Used by derived classes to serialize the closing tag of an element node. + * + * @param name - node name + */ + BaseWriter.prototype.closeTag = function (name) { }; + /** + * Used by derived classes to serialize attributes or namespace declarations. + * + * @param attributes - attribute array + */ + BaseWriter.prototype.attributes = function (attributes) { + var e_1, _a; + try { + for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) { + var attr = attributes_1_1.value; + this.attribute(attr[1] === null ? attr[2] : attr[1] + ':' + attr[2], attr[3]); + } } - } else { - if (isFunction(value)) { - value = value.apply(); + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1); + } + finally { if (e_1) throw e_1.error; } } - instruction = new XMLProcessingInstruction(this, target, value); - this.children.push(instruction); - } - return this; - }; - - XMLNode.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; - }; - - XMLNode.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; }; - - XMLNode.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; - }; - - XMLNode.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; + /** + * Used by derived classes to serialize an attribute or namespace declaration. + * + * @param name - node name + * @param value - node value + */ + BaseWriter.prototype.attribute = function (name, value) { }; + /** + * Used by derived classes to perform any pre-processing steps before starting + * serializing an element node. + * + * @param name - node name + */ + BaseWriter.prototype.beginElement = function (name) { }; + /** + * Used by derived classes to perform any post-processing steps after + * completing serializing an element node. + * + * @param name - node name + */ + BaseWriter.prototype.endElement = function (name) { }; + /** + * Produces an XML serialization of the given node. The pre-serializer inserts + * namespace declarations where necessary and produces qualified names for + * nodes and attributes. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype.serializeNode = function (node, requireWellFormed, noDoubleEncoding) { + var hasNamespaces = (node._nodeDocument !== undefined && node._nodeDocument._hasNamespaces); + this.level = 0; + this.currentNode = node; + if (hasNamespaces) { + /** From: https://w3c.github.io/DOM-Parsing/#xml-serialization + * + * 1. Let namespace be a context namespace with value null. + * The context namespace tracks the XML serialization algorithm's current + * default namespace. The context namespace is changed when either an Element + * Node has a default namespace declaration, or the algorithm generates a + * default namespace declaration for the Element Node to match its own + * namespace. The algorithm assumes no namespace (null) to start. + * 2. Let prefix map be a new namespace prefix map. + * 3. Add the XML namespace with prefix value "xml" to prefix map. + * 4. Let prefix index be a generated namespace prefix index with value 1. + * The generated namespace prefix index is used to generate a new unique + * prefix value when no suitable existing namespace prefix is available to + * serialize a node's namespaceURI (or the namespaceURI of one of node's + * attributes). See the generate a prefix algorithm. + */ + var namespace = null; + var prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); + prefixMap.set("xml", infra_1.namespace.XML); + var prefixIndex = { value: 1 }; + /** + * 5. Return the result of running the XML serialization algorithm on node + * passing the context namespace namespace, namespace prefix map prefix map, + * generated namespace prefix index reference to prefix index, and the + * flag require well-formed. If an exception occurs during the execution + * of the algorithm, then catch that exception and throw an + * "InvalidStateError" DOMException. + */ + this._serializeNodeNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); } - } - 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; + else { + this._serializeNode(node, requireWellFormed, noDoubleEncoding); } - } - doc.children.push(doctype); - return doctype; - }; - - XMLNode.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; }; - - XMLNode.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; + /** + * Produces an XML serialization of a node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeNodeNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + this.currentNode = node; + switch (node.nodeType) { + case interfaces_1.NodeType.Element: + this._serializeElementNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Document: + this._serializeDocumentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Comment: + this._serializeComment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Text: + this._serializeText(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentFragment: + this._serializeDocumentFragmentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentType: + this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.ProcessingInstruction: + this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.CData: + this._serializeCData(node, requireWellFormed, noDoubleEncoding); + break; + default: + throw new Error("Unknown node type: " + node.nodeType); } - } }; - - XMLNode.prototype.document = function() { - var node; - node = this; - while (node) { - if (node.type === NodeType.Document) { - return node; - } else { - node = node.parent; + /** + * Produces an XML serialization of a node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeNode = function (node, requireWellFormed, noDoubleEncoding) { + this.currentNode = node; + switch (node.nodeType) { + case interfaces_1.NodeType.Element: + this._serializeElement(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Document: + this._serializeDocument(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Comment: + this._serializeComment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Text: + this._serializeText(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentFragment: + this._serializeDocumentFragment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentType: + this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.ProcessingInstruction: + this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.CData: + this._serializeCData(node, requireWellFormed, noDoubleEncoding); + break; + default: + throw new Error("Unknown node type: " + node.nodeType); } - } - }; - - XMLNode.prototype.end = function(options) { - return this.document().end(options); - }; - - XMLNode.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]; - }; - - XMLNode.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]; - }; - - XMLNode.prototype.importDocument = function(doc) { - var clonedRoot; - clonedRoot = doc.root().clone(); - clonedRoot.parent = this; - clonedRoot.isRoot = false; - this.children.push(clonedRoot); - return this; - }; - - XMLNode.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 + ">"; - } - }; - - XMLNode.prototype.ele = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLNode.prototype.nod = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLNode.prototype.txt = function(value) { - return this.text(value); - }; - - XMLNode.prototype.dat = function(value) { - return this.cdata(value); }; - - XMLNode.prototype.com = function(value) { - return this.comment(value); - }; - - XMLNode.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; - - XMLNode.prototype.doc = function() { - return this.document(); - }; - - XMLNode.prototype.dec = function(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - }; - - XMLNode.prototype.e = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLNode.prototype.n = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLNode.prototype.t = function(value) { - return this.text(value); - }; - - XMLNode.prototype.d = function(value) { - return this.cdata(value); - }; - - XMLNode.prototype.c = function(value) { - return this.comment(value); - }; - - XMLNode.prototype.r = function(value) { - return this.raw(value); - }; - - XMLNode.prototype.i = function(target, value) { - return this.instruction(target, value); - }; - - XMLNode.prototype.u = function() { - return this.up(); - }; - - XMLNode.prototype.importXMLBuilder = function(doc) { - return this.importDocument(doc); - }; - - XMLNode.prototype.replaceChild = function(newChild, oldChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.removeChild = function(oldChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.appendChild = function(newChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.hasChildNodes = function() { - return this.children.length !== 0; - }; - - XMLNode.prototype.cloneNode = function(deep) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.normalize = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.isSupported = function(feature, version) { - return true; - }; - - XMLNode.prototype.hasAttributes = function() { - return this.attribs.length !== 0; - }; - - XMLNode.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; - } - }; - - XMLNode.prototype.isSameNode = function(other) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.lookupPrefix = function(namespaceURI) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.isDefaultNamespace = function(namespaceURI) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.lookupNamespaceURI = function(prefix) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.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; - }; - - XMLNode.prototype.getFeature = function(feature, version) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.setUserData = function(key, data, handler) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.getUserData = function(key) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.contains = function(other) { - if (!other) { - return false; - } - return other === this || this.isDescendant(other); - }; - - XMLNode.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; + /** + * Produces an XML serialization of an element node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeElementNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_2, _a; + var attributes = []; + /** + * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node + * + * 1. If the require well-formed flag is set (its value is true), and this + * node's localName attribute contains the character ":" (U+003A COLON) or + * does not match the XML Name production, then throw an exception; the + * serialization of this node would not be a well-formed element. + */ + if (requireWellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + throw new Error("Node local name contains invalid characters (well-formed required)."); } - isDescendantChild = child.isDescendant(node); - if (isDescendantChild) { - return true; + /** + * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). + * 3. Let qualified name be an empty string. + * 4. Let skip end tag be a boolean flag with value false. + * 5. Let ignore namespace definition attribute be a boolean flag with value + * false. + * 6. Given prefix map, copy a namespace prefix map and let map be the + * result. + * 7. Let local prefixes map be an empty map. The map has unique Node prefix + * strings as its keys, with corresponding namespaceURI Node values as the + * map's key values (in this map, the null namespace is represented by the + * empty string). + * + * _Note:_ This map is local to each element. It is used to ensure there + * are no conflicting prefixes should a new namespace prefix attribute need + * to be generated. It is also used to enable skipping of duplicate prefix + * definitions when writing an element's attributes: the map allows the + * algorithm to distinguish between a prefix in the namespace prefix map + * that might be locally-defined (to the current Element) and one that is + * not. + * 8. Let local default namespace be the result of recording the namespace + * information for node given map and local prefixes map. + * + * _Note:_ The above step will update map with any found namespace prefix + * definitions, add the found prefix definitions to the local prefixes map + * and return a local default namespace value defined by a default namespace + * attribute if one exists. Otherwise it returns null. + * 9. Let inherited ns be a copy of namespace. + * 10. Let ns be the value of node's namespaceURI attribute. + */ + var qualifiedName = ''; + var skipEndTag = false; + var ignoreNamespaceDefinitionAttribute = false; + var map = prefixMap.copy(); + var localPrefixesMap = {}; + var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); + var inheritedNS = namespace; + var ns = node.namespaceURI; + /** 11. If inherited ns is equal to ns, then: */ + if (inheritedNS === ns) { + /** + * 11.1. If local default namespace is not null, then set ignore + * namespace definition attribute to true. + */ + if (localDefaultNamespace !== null) { + ignoreNamespaceDefinitionAttribute = true; + } + /** + * 11.2. If ns is the XML namespace, then append to qualified name the + * concatenation of the string "xml:" and the value of node's localName. + * 11.3. Otherwise, append to qualified name the value of node's + * localName. The node's prefix if it exists, is dropped. + */ + if (ns === infra_1.namespace.XML) { + qualifiedName = 'xml:' + node.localName; + } + else { + qualifiedName = node.localName; + } + /** 11.4. Append the value of qualified name to markup. */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); } - } - return false; - }; - - XMLNode.prototype.isAncestor = function(node) { - return node.isDescendant(this); - }; - - XMLNode.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; - } - }; - - XMLNode.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; - } - }; - - XMLNode.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; - } - }; - - XMLNode.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; - } + else { + /** + * 12. Otherwise, inherited ns is not equal to ns (the node's own + * namespace is different from the context namespace of its parent). + * Run these sub-steps: + * + * 12.1. Let prefix be the value of node's prefix attribute. + * 12.2. Let candidate prefix be the result of retrieving a preferred + * prefix string prefix from map given namespace ns. The above may return + * null if no namespace key ns exists in map. + */ + var prefix = node.prefix; + /** + * We don't need to run "retrieving a preferred prefix string" algorithm if + * the element has no prefix and its namespace matches to the default + * namespace. + * See: https://github.com/web-platform-tests/wpt/pull/16703 + */ + var candidatePrefix = null; + if (prefix !== null || ns !== localDefaultNamespace) { + candidatePrefix = map.get(prefix, ns); + } + /** + * 12.3. If the value of prefix matches "xmlns", then run the following + * steps: + */ + if (prefix === "xmlns") { + /** + * 12.3.1. If the require well-formed flag is set, then throw an error. + * An Element with prefix "xmlns" will not legally round-trip in a + * conforming XML parser. + */ + if (requireWellFormed) { + throw new Error("An element cannot have the 'xmlns' prefix (well-formed required)."); + } + /** + * 12.3.2. Let candidate prefix be the value of prefix. + */ + candidatePrefix = prefix; + } + /** + * 12.4.Found a suitable namespace prefix: if candidate prefix is not + * null (a namespace prefix is defined which maps to ns), then: + */ + if (candidatePrefix !== null) { + /** + * The following may serialize a different prefix than the Element's + * existing prefix if it already had one. However, the retrieving a + * preferred prefix string algorithm already tried to match the + * existing prefix if possible. + * + * 12.4.1. Append to qualified name the concatenation of candidate + * prefix, ":" (U+003A COLON), and node's localName. There exists on + * this node or the node's ancestry a namespace prefix definition that + * defines the node's namespace. + * 12.4.2. If the local default namespace is not null (there exists a + * locally-defined default namespace declaration attribute) and its + * value is not the XML namespace, then let inherited ns get the value + * of local default namespace unless the local default namespace is the + * empty string in which case let it get null (the context namespace + * is changed to the declared default, rather than this node's own + * namespace). + * + * _Note:_ Any default namespace definitions or namespace prefixes that + * define the XML namespace are omitted when serializing this node's + * attributes. + */ + qualifiedName = candidatePrefix + ':' + node.localName; + if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { + inheritedNS = localDefaultNamespace || null; + } + /** + * 12.4.3. Append the value of qualified name to markup. + */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** 12.5. Otherwise, if prefix is not null, then: */ + } + else if (prefix !== null) { + /** + * _Note:_ By this step, there is no namespace or prefix mapping + * declaration in this node (or any parent node visited by this + * algorithm) that defines prefix otherwise the step labelled Found + * a suitable namespace prefix would have been followed. The sub-steps + * that follow will create a new namespace prefix declaration for prefix + * and ensure that prefix does not conflict with an existing namespace + * prefix declaration of the same localName in node's attribute list. + * + * 12.5.1. If the local prefixes map contains a key matching prefix, + * then let prefix be the result of generating a prefix providing as + * input map, ns, and prefix index. + */ + if (prefix in localPrefixesMap) { + prefix = this._generatePrefix(ns, map, prefixIndex); + } + /** + * 12.5.2. Add prefix to map given namespace ns. + * 12.5.3. Append to qualified name the concatenation of prefix, ":" + * (U+003A COLON), and node's localName. + * 12.5.4. Append the value of qualified name to markup. + */ + map.set(prefix, ns); + qualifiedName += prefix + ':' + node.localName; + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 12.5.5. Append the following to markup, in the order listed: + * + * _Note:_ The following serializes a namespace prefix declaration for + * prefix which was just added to the map. + * + * 12.5.5.1. " " (U+0020 SPACE); + * 12.5.5.2. The string "xmlns:"; + * 12.5.5.3. The value of prefix; + * 12.5.5.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 12.5.5.5. The result of serializing an attribute value given ns and + * the require well-formed flag as input; + * 12.5.5.6. """ (U+0022 QUOTATION MARK). + */ + attributes.push([null, 'xmlns', prefix, + this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); + /** + * 12.5.5.7. If local default namespace is not null (there exists a + * locally-defined default namespace declaration attribute), then + * let inherited ns get the value of local default namespace unless the + * local default namespace is the empty string in which case let it get + * null. + */ + if (localDefaultNamespace !== null) { + inheritedNS = localDefaultNamespace || null; + } + /** + * 12.6. Otherwise, if local default namespace is null, or local + * default namespace is not null and its value is not equal to ns, then: + */ + } + else if (localDefaultNamespace === null || + (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { + /** + * _Note:_ At this point, the namespace for this node still needs to be + * serialized, but there's no prefix (or candidate prefix) available; the + * following uses the default namespace declaration to define the + * namespace--optionally replacing an existing default declaration + * if present. + * + * 12.6.1. Set the ignore namespace definition attribute flag to true. + * 12.6.2. Append to qualified name the value of node's localName. + * 12.6.3. Let the value of inherited ns be ns. + * + * _Note:_ The new default namespace will be used in the serialization + * to define this node's namespace and act as the context namespace for + * its children. + */ + ignoreNamespaceDefinitionAttribute = true; + qualifiedName += node.localName; + inheritedNS = ns; + /** + * 12.6.4. Append the value of qualified name to markup. + */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 12.6.5. Append the following to markup, in the order listed: + * + * _Note:_ The following serializes the new (or replacement) default + * namespace definition. + * + * 12.6.5.1. " " (U+0020 SPACE); + * 12.6.5.2. The string "xmlns"; + * 12.6.5.3. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 12.6.5.4. The result of serializing an attribute value given ns + * and the require well-formed flag as input; + * 12.6.5.5. """ (U+0022 QUOTATION MARK). + */ + attributes.push([null, null, 'xmlns', + this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); + /** + * 12.7. Otherwise, the node has a local default namespace that matches + * ns. Append to qualified name the value of node's localName, let the + * value of inherited ns be ns, and append the value of qualified name + * to markup. + */ + } + else { + qualifiedName += node.localName; + inheritedNS = ns; + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + } } - } - }; - - return XMLNode; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 6768: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLNodeList; - - module.exports = XMLNodeList = (function() { - function XMLNodeList(nodes) { - this.nodes = nodes; - } - - Object.defineProperty(XMLNodeList.prototype, 'length', { - get: function() { - return this.nodes.length || 0; - } - }); - - XMLNodeList.prototype.clone = function() { - return this.nodes = null; + /** + * 13. Append to markup the result of the XML serialization of node's + * attributes given map, prefix index, local prefixes map, ignore namespace + * definition attribute flag, and require well-formed flag. + */ + attributes.push.apply(attributes, __spread(this._serializeAttributesNS(node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding))); + this.attributes(attributes); + /** + * 14. If ns is the HTML namespace, and the node's list of children is + * empty, and the node's localName matches any one of the following void + * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", + * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", + * "param", "source", "track", "wbr"; then append the following to markup, + * in the order listed: + * 14.1. " " (U+0020 SPACE); + * 14.2. "/" (U+002F SOLIDUS). + * and set the skip end tag flag to true. + * 15. If ns is not the HTML namespace, and the node's list of children is + * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end + * tag flag to true. + * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. + */ + var isHTML = (ns === infra_1.namespace.HTML); + if (isHTML && node.childNodes.length === 0 && + BaseWriter._VoidElementNames.has(node.localName)) { + this.openTagEnd(qualifiedName, true, true); + this.endElement(qualifiedName); + skipEndTag = true; + } + else if (!isHTML && node.childNodes.length === 0) { + this.openTagEnd(qualifiedName, true, false); + this.endElement(qualifiedName); + skipEndTag = true; + } + else { + this.openTagEnd(qualifiedName, false, false); + } + /** + * 17. If the value of skip end tag is true, then return the value of markup + * and skip the remaining steps. The node is a leaf-node. + */ + if (skipEndTag) + return; + /** + * 18. If ns is the HTML namespace, and the node's localName matches the + * string "template", then this is a template element. Append to markup the + * result of XML serializing a DocumentFragment node given the template + * element's template contents (a DocumentFragment), providing inherited + * ns, map, prefix index, and the require well-formed flag. + * + * _Note:_ This allows template content to round-trip, given the rules for + * parsing XHTML documents. + * + * 19. Otherwise, append to markup the result of running the XML + * serialization algorithm on each of node's children, in tree order, + * providing inherited ns, map, prefix index, and the require well-formed + * flag. + */ + if (isHTML && node.localName === "template") { + // TODO: serialize template contents + } + else { + try { + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this.level++; + this._serializeNodeNS(childNode, inheritedNS, map, prefixIndex, requireWellFormed, noDoubleEncoding); + this.level--; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + } + /** + * 20. Append the following to markup, in the order listed: + * 20.1. "" (U+003E GREATER-THAN SIGN). + * 21. Return the value of markup. + */ + this.closeTag(qualifiedName); + this.endElement(qualifiedName); }; - - XMLNodeList.prototype.item = function(index) { - return this.nodes[index] || null; + /** + * Produces an XML serialization of an element node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeElement = function (node, requireWellFormed, noDoubleEncoding) { + var e_3, _a; + /** + * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node + * + * 1. If the require well-formed flag is set (its value is true), and this + * node's localName attribute contains the character ":" (U+003A COLON) or + * does not match the XML Name production, then throw an exception; the + * serialization of this node would not be a well-formed element. + */ + if (requireWellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + throw new Error("Node local name contains invalid characters (well-formed required)."); + } + /** + * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). + * 3. Let qualified name be an empty string. + * 4. Let skip end tag be a boolean flag with value false. + * 5. Let ignore namespace definition attribute be a boolean flag with value + * false. + * 6. Given prefix map, copy a namespace prefix map and let map be the + * result. + * 7. Let local prefixes map be an empty map. The map has unique Node prefix + * strings as its keys, with corresponding namespaceURI Node values as the + * map's key values (in this map, the null namespace is represented by the + * empty string). + * + * _Note:_ This map is local to each element. It is used to ensure there + * are no conflicting prefixes should a new namespace prefix attribute need + * to be generated. It is also used to enable skipping of duplicate prefix + * definitions when writing an element's attributes: the map allows the + * algorithm to distinguish between a prefix in the namespace prefix map + * that might be locally-defined (to the current Element) and one that is + * not. + * 8. Let local default namespace be the result of recording the namespace + * information for node given map and local prefixes map. + * + * _Note:_ The above step will update map with any found namespace prefix + * definitions, add the found prefix definitions to the local prefixes map + * and return a local default namespace value defined by a default namespace + * attribute if one exists. Otherwise it returns null. + * 9. Let inherited ns be a copy of namespace. + * 10. Let ns be the value of node's namespaceURI attribute. + */ + var skipEndTag = false; + /** 11. If inherited ns is equal to ns, then: */ + /** + * 11.1. If local default namespace is not null, then set ignore + * namespace definition attribute to true. + */ + /** + * 11.2. If ns is the XML namespace, then append to qualified name the + * concatenation of the string "xml:" and the value of node's localName. + * 11.3. Otherwise, append to qualified name the value of node's + * localName. The node's prefix if it exists, is dropped. + */ + var qualifiedName = node.localName; + /** 11.4. Append the value of qualified name to markup. */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 13. Append to markup the result of the XML serialization of node's + * attributes given map, prefix index, local prefixes map, ignore namespace + * definition attribute flag, and require well-formed flag. + */ + var attributes = this._serializeAttributes(node, requireWellFormed, noDoubleEncoding); + this.attributes(attributes); + /** + * 14. If ns is the HTML namespace, and the node's list of children is + * empty, and the node's localName matches any one of the following void + * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", + * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", + * "param", "source", "track", "wbr"; then append the following to markup, + * in the order listed: + * 14.1. " " (U+0020 SPACE); + * 14.2. "/" (U+002F SOLIDUS). + * and set the skip end tag flag to true. + * 15. If ns is not the HTML namespace, and the node's list of children is + * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end + * tag flag to true. + * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. + */ + if (!node.hasChildNodes()) { + this.openTagEnd(qualifiedName, true, false); + this.endElement(qualifiedName); + skipEndTag = true; + } + else { + this.openTagEnd(qualifiedName, false, false); + } + /** + * 17. If the value of skip end tag is true, then return the value of markup + * and skip the remaining steps. The node is a leaf-node. + */ + if (skipEndTag) + return; + try { + /** + * 18. If ns is the HTML namespace, and the node's localName matches the + * string "template", then this is a template element. Append to markup the + * result of XML serializing a DocumentFragment node given the template + * element's template contents (a DocumentFragment), providing inherited + * ns, map, prefix index, and the require well-formed flag. + * + * _Note:_ This allows template content to round-trip, given the rules for + * parsing XHTML documents. + * + * 19. Otherwise, append to markup the result of running the XML + * serialization algorithm on each of node's children, in tree order, + * providing inherited ns, map, prefix index, and the require well-formed + * flag. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this.level++; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + this.level--; + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_3) throw e_3.error; } + } + /** + * 20. Append the following to markup, in the order listed: + * 20.1. "" (U+003E GREATER-THAN SIGN). + * 21. Return the value of markup. + */ + this.closeTag(qualifiedName); + this.endElement(qualifiedName); }; - - return XMLNodeList; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 6939: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLProcessingInstruction = (function(superClass) { - extend(XMLProcessingInstruction, superClass); - - function XMLProcessingInstruction(parent, target, value) { - XMLProcessingInstruction.__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); - } - } - - XMLProcessingInstruction.prototype.clone = function() { - return Object.create(this); - }; - - XMLProcessingInstruction.prototype.toString = function(options) { - return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options)); + /** + * Produces an XML serialization of a document node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_4, _a; + /** + * If the require well-formed flag is set (its value is true), and this node + * has no documentElement (the documentElement attribute's value is null), + * then throw an exception; the serialization of this node would not be a + * well-formed document. + */ + if (requireWellFormed && node.documentElement === null) { + throw new Error("Missing document element (well-formed required)."); + } + try { + /** + * Otherwise, run the following steps: + * 1. Let serialized document be an empty string. + * 2. For each child child of node, in tree order, run the XML + * serialization algorithm on the child passing along the provided + * arguments, and append the result to serialized document. + * + * _Note:_ This will serialize any number of ProcessingInstruction and + * Comment nodes both before and after the Document's documentElement node, + * including at most one DocumentType node. (Text nodes are not allowed as + * children of the Document.) + * + * 3. Return the value of serialized document. + */ + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_4) throw e_4.error; } + } }; - - XMLProcessingInstruction.prototype.isEqualNode = function(node) { - if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { - return false; - } - if (node.target !== this.target) { - return false; - } - return true; + /** + * Produces an XML serialization of a document node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocument = function (node, requireWellFormed, noDoubleEncoding) { + var e_5, _a; + /** + * If the require well-formed flag is set (its value is true), and this node + * has no documentElement (the documentElement attribute's value is null), + * then throw an exception; the serialization of this node would not be a + * well-formed document. + */ + if (requireWellFormed && node.documentElement === null) { + throw new Error("Missing document element (well-formed required)."); + } + try { + /** + * Otherwise, run the following steps: + * 1. Let serialized document be an empty string. + * 2. For each child child of node, in tree order, run the XML + * serialization algorithm on the child passing along the provided + * arguments, and append the result to serialized document. + * + * _Note:_ This will serialize any number of ProcessingInstruction and + * Comment nodes both before and after the Document's documentElement node, + * including at most one DocumentType node. (Text nodes are not allowed as + * children of the Document.) + * + * 3. Return the value of serialized document. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_5) throw e_5.error; } + } }; - - return XMLProcessingInstruction; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 6329: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLNode = __nccwpck_require__(7608); - - module.exports = XMLRaw = (function(superClass) { - extend(XMLRaw, superClass); - - function XMLRaw(parent, text) { - XMLRaw.__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); - } - - XMLRaw.prototype.clone = function() { - return Object.create(this); + /** + * Produces an XML serialization of a comment node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeComment = function (node, requireWellFormed, noDoubleEncoding) { + /** + * If the require well-formed flag is set (its value is true), and node's + * data contains characters that are not matched by the XML Char production + * or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that + * ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception; + * the serialization of this node's data would not be well-formed. + */ + if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || + node.data.indexOf("--") !== -1 || node.data.endsWith("-"))) { + throw new Error("Comment data contains invalid characters (well-formed required)."); + } + /** + * Otherwise, return the concatenation of "". + */ + this.comment(node.data); }; - - XMLRaw.prototype.toString = function(options) { - return this.options.writer.raw(this, this.options.writer.filterOptions(options)); + /** + * Produces an XML serialization of a text node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + * @param level - current depth of the XML tree + */ + BaseWriter.prototype._serializeText = function (node, requireWellFormed, noDoubleEncoding) { + /** + * 1. If the require well-formed flag is set (its value is true), and + * node's data contains characters that are not matched by the XML Char + * production, then throw an exception; the serialization of this node's + * data would not be well-formed. + */ + if (requireWellFormed && !algorithm_1.xml_isLegalChar(node.data)) { + throw new Error("Text data contains invalid characters (well-formed required)."); + } + /** + * 2. Let markup be the value of node's data. + * 3. Replace any occurrences of "&" in markup by "&". + * 4. Replace any occurrences of "<" in markup by "<". + * 5. Replace any occurrences of ">" in markup by ">". + * 6. Return the value of markup. + */ + var markup = ""; + if (noDoubleEncoding) { + markup = node.data.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') + .replace(//g, '>'); + } + else { + for (var i = 0; i < node.data.length; i++) { + var c = node.data[i]; + if (c === "&") + markup += "&"; + else if (c === "<") + markup += "<"; + else if (c === ">") + markup += ">"; + else + markup += c; + } + } + this.text(markup); }; - - return XMLRaw; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 8601: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLWriterBase = __nccwpck_require__(6752); - - WriterState = __nccwpck_require__(9766); - - module.exports = XMLStreamWriter = (function(superClass) { - extend(XMLStreamWriter, superClass); - - function XMLStreamWriter(stream, options) { - this.stream = stream; - XMLStreamWriter.__super__.constructor.call(this, options); - } - - XMLStreamWriter.prototype.endline = function(node, options, level) { - if (node.isLastRootNode && options.state === WriterState.CloseTag) { - return ''; - } else { - return XMLStreamWriter.__super__.endline.call(this, node, options, level); - } - }; - - XMLStreamWriter.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; - }; - - XMLStreamWriter.prototype.attribute = function(att, options, level) { - return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level)); - }; - - XMLStreamWriter.prototype.cdata = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.comment = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.declaration = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level)); + /** + * Produces an XML serialization of a document fragment node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentFragmentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_6, _a; + try { + /** + * 1. Let markup the empty string. + * 2. For each child child of node, in tree order, run the XML serialization + * algorithm on the child given namespace, prefix map, a reference to prefix + * index, and flag require well-formed. Concatenate the result to markup. + * 3. Return the value of markup. + */ + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + } + } + catch (e_6_1) { e_6 = { error: e_6_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_6) throw e_6.error; } + } }; - - XMLStreamWriter.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(' 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); + /** + * Produces an XML serialization of a document fragment node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentFragment = function (node, requireWellFormed, noDoubleEncoding) { + var e_7, _a; + try { + /** + * 1. Let markup the empty string. + * 2. For each child child of node, in tree order, run the XML serialization + * algorithm on the child given namespace, prefix map, a reference to prefix + * index, and flag require well-formed. Concatenate the result to markup. + * 3. Return the value of markup. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + } + } + catch (e_7_1) { e_7 = { error: e_7_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_7) throw e_7.error; } } - 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); }; - - XMLStreamWriter.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(''); - } else { - options.state = WriterState.CloseTag; - this.stream.write(options.spaceBeforeSlash + '/>'); + /** + * Produces an XML serialization of a document type node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentType = function (node, requireWellFormed, noDoubleEncoding) { + /** + * 1. If the require well-formed flag is true and the node's publicId + * attribute contains characters that are not matched by the XML PubidChar + * production, then throw an exception; the serialization of this node + * would not be a well-formed document type declaration. + */ + if (requireWellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { + throw new Error("DocType public identifier does not match PubidChar construct (well-formed required)."); } - } 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(''); - } 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); + /** + * 2. If the require well-formed flag is true and the node's systemId + * attribute contains characters that are not matched by the XML Char + * production or that contains both a """ (U+0022 QUOTATION MARK) and a + * "'" (U+0027 APOSTROPHE), then throw an exception; the serialization + * of this node would not be a well-formed document type declaration. + */ + if (requireWellFormed && + (!algorithm_1.xml_isLegalChar(node.systemId) || + (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { + throw new Error("DocType system identifier contains invalid characters (well-formed required)."); } - options.state = WriterState.CloseTag; - this.stream.write(this.indent(node, options, level) + ''); - } - this.stream.write(this.endline(node, options, level)); - options.state = WriterState.None; - return this.closeNode(node, options, level); + /** + * 3. Let markup be an empty string. + * 4. Append the string "" (U+003E GREATER-THAN SIGN) to markup. + * 11. Return the value of markup. + */ + this.docType(node.name, node.publicId, node.systemId); }; - - XMLStreamWriter.prototype.processingInstruction = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.raw = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.text = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.dtdAttList = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.dtdElement = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.dtdEntity = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.dtdNotation = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level)); - }; - - return XMLStreamWriter; - - })(XMLWriterBase); - -}).call(this); - - -/***/ }), - -/***/ 5913: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(6752); - - module.exports = XMLStringWriter = (function(superClass) { - extend(XMLStringWriter, superClass); - - function XMLStringWriter(options) { - XMLStringWriter.__super__.constructor.call(this, options); - } - - XMLStringWriter.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 XMLStringWriter; - - })(XMLWriterBase); - -}).call(this); - - -/***/ }), - -/***/ 8594: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLStringifier, - bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - hasProp = {}.hasOwnProperty; - - module.exports = XMLStringifier = (function() { - function XMLStringifier(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; - } - } - - XMLStringifier.prototype.name = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalName('' + val || ''); - }; - - XMLStringifier.prototype.text = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar(this.textEscape('' + val || '')); - }; - - XMLStringifier.prototype.cdata = function(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - val = val.replace(']]>', ']]]]>'); - return this.assertLegalChar(val); - }; - - XMLStringifier.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); - }; - - XMLStringifier.prototype.raw = function(val) { - if (this.options.noValidation) { - return val; - } - return '' + val || ''; - }; - - XMLStringifier.prototype.attValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar(this.attEscape(val = '' + val || '')); - }; - - XMLStringifier.prototype.insTarget = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.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); - }; - - XMLStringifier.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; - }; - - XMLStringifier.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); + /** + * Produces an XML serialization of a processing instruction node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeProcessingInstruction = function (node, requireWellFormed, noDoubleEncoding) { + /** + * 1. If the require well-formed flag is set (its value is true), and node's + * target contains a ":" (U+003A COLON) character or is an ASCII + * case-insensitive match for the string "xml", then throw an exception; + * the serialization of this node's target would not be well-formed. + */ + if (requireWellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { + throw new Error("Processing instruction target contains invalid characters (well-formed required)."); + } + /** + * 2. If the require well-formed flag is set (its value is true), and node's + * data contains characters that are not matched by the XML Char production + * or contains the string "?>" (U+003F QUESTION MARK, + * U+003E GREATER-THAN SIGN), then throw an exception; the serialization of + * this node's data would not be well-formed. + */ + if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || + node.data.indexOf("?>") !== -1)) { + throw new Error("Processing instruction data contains invalid characters (well-formed required)."); + } + /** + * 3. Let markup be the concatenation of the following, in the order listed: + * 3.1. "" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN). + * 4. Return the value of markup. + */ + this.instruction(node.target, node.data); }; - - XMLStringifier.prototype.xmlStandalone = function(val) { - if (this.options.noValidation) { - return val; - } - if (val) { - return "yes"; - } else { - return "no"; - } + /** + * Produces an XML serialization of a CDATA node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeCData = function (node, requireWellFormed, noDoubleEncoding) { + if (requireWellFormed && (node.data.indexOf("]]>") !== -1)) { + throw new Error("CDATA contains invalid characters (well-formed required)."); + } + this.cdata(node.data); }; - - XMLStringifier.prototype.dtdPubID = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdSysID = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdElementValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdAttType = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdAttDefault = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdEntityValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); + /** + * Produces an XML serialization of the attributes of an element node. + * + * @param node - node to serialize + * @param map - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param localPrefixesMap - local prefixes map + * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace + * attributes + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeAttributesNS = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding) { + var e_8, _a; + /** + * 1. Let result be the empty string. + * 2. Let localname set be a new empty namespace localname set. This + * localname set will contain tuples of unique attribute namespaceURI and + * localName pairs, and is populated as each attr is processed. This set is + * used to [optionally] enforce the well-formed constraint that an element + * cannot have two attributes with the same namespaceURI and localName. + * This can occur when two otherwise identical attributes on the same + * element differ only by their prefix values. + */ + var result = []; + var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; + try { + /** + * 3. Loop: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + // Optimize common case + if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + continue; + } + /** + * 3.1. If the require well-formed flag is set (its value is true), and the + * localname set contains a tuple whose values match those of a new tuple + * consisting of attr's namespaceURI attribute and localName attribute, + * then throw an exception; the serialization of this attr would fail to + * produce a well-formed element serialization. + */ + if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { + throw new Error("Element contains duplicate attributes (well-formed required)."); + } + /** + * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and + * localName attribute, and add it to the localname set. + * 3.3. Let attribute namespace be the value of attr's namespaceURI value. + * 3.4. Let candidate prefix be null. + */ + if (requireWellFormed && localNameSet) + localNameSet.set(attr.namespaceURI, attr.localName); + var attributeNamespace = attr.namespaceURI; + var candidatePrefix = null; + /** 3.5. If attribute namespace is not null, then run these sub-steps: */ + if (attributeNamespace !== null) { + /** + * 3.5.1. Let candidate prefix be the result of retrieving a preferred + * prefix string from map given namespace attribute namespace with + * preferred prefix being attr's prefix value. + */ + candidatePrefix = map.get(attr.prefix, attributeNamespace); + /** + * 3.5.2. If the value of attribute namespace is the XMLNS namespace, + * then run these steps: + */ + if (attributeNamespace === infra_1.namespace.XMLNS) { + /** + * 3.5.2.1. If any of the following are true, then stop running these + * steps and goto Loop to visit the next attribute: + * - the attr's value is the XML namespace; + * _Note:_ The XML namespace cannot be redeclared and survive + * round-tripping (unless it defines the prefix "xml"). To avoid this + * problem, this algorithm always prefixes elements in the XML + * namespace with "xml" and drops any related definitions as seen + * in the above condition. + * - the attr's prefix is null and the ignore namespace definition + * attribute flag is true (the Element's default namespace attribute + * should be skipped); + * - the attr's prefix is not null and either + * * the attr's localName is not a key contained in the local + * prefixes map, or + * * the attr's localName is present in the local prefixes map but + * the value of the key does not match attr's value + * and furthermore that the attr's localName (as the prefix to find) + * is found in the namespace prefix map given the namespace consisting + * of the attr's value (the current namespace prefix definition was + * exactly defined previously--on an ancestor element not the current + * element whose attributes are being processed). + */ + if (attr.value === infra_1.namespace.XML || + (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || + (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || + localPrefixesMap[attr.localName] !== attr.value) && + map.has(attr.localName, attr.value))) + continue; + /** + * 3.5.2.2. If the require well-formed flag is set (its value is true), + * and the value of attr's value attribute matches the XMLNS + * namespace, then throw an exception; the serialization of this + * attribute would produce invalid XML because the XMLNS namespace + * is reserved and cannot be applied as an element's namespace via + * XML parsing. + * + * _Note:_ DOM APIs do allow creation of elements in the XMLNS + * namespace but with strict qualifications. + */ + if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { + throw new Error("XMLNS namespace is reserved (well-formed required)."); + } + /** + * 3.5.2.3. If the require well-formed flag is set (its value is true), + * and the value of attr's value attribute is the empty string, then + * throw an exception; namespace prefix declarations cannot be used + * to undeclare a namespace (use a default namespace declaration + * instead). + */ + if (requireWellFormed && attr.value === '') { + throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required)."); + } + /** + * 3.5.2.4. the attr's prefix matches the string "xmlns", then let + * candidate prefix be the string "xmlns". + */ + if (attr.prefix === 'xmlns') + candidatePrefix = 'xmlns'; + /** + * 3.5.3. Otherwise, the attribute namespace is not the XMLNS namespace. + * Run these steps: + * + * _Note:_ The (candidatePrefix === null) check is not in the spec. + * We deviate from the spec here. Otherwise a prefix is generated for + * all attributes with namespaces. + */ + } + else if (candidatePrefix === null) { + if (attr.prefix !== null && + (!map.hasPrefix(attr.prefix) || + map.has(attr.prefix, attributeNamespace))) { + /** + * Check if we can use the attribute's own prefix. + * We deviate from the spec here. + * TODO: This is not an efficient way of searching for prefixes. + * Follow developments to the spec. + */ + candidatePrefix = attr.prefix; + } + else { + /** + * 3.5.3.1. Let candidate prefix be the result of generating a prefix + * providing map, attribute namespace, and prefix index as input. + */ + candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); + } + /** + * 3.5.3.2. Append the following to result, in the order listed: + * 3.5.3.2.1. " " (U+0020 SPACE); + * 3.5.3.2.2. The string "xmlns:"; + * 3.5.3.2.3. The value of candidate prefix; + * 3.5.3.2.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.5.3.2.5. The result of serializing an attribute value given + * attribute namespace and the require well-formed flag as input; + * 3.5.3.2.6. """ (U+0022 QUOTATION MARK). + */ + result.push([null, "xmlns", candidatePrefix, + this._serializeAttributeValue(attributeNamespace, requireWellFormed, noDoubleEncoding)]); + } + } + /** + * 3.6. Append a " " (U+0020 SPACE) to result. + * 3.7. If candidate prefix is not null, then append to result the + * concatenation of candidate prefix with ":" (U+003A COLON). + */ + var attrName = ''; + if (candidatePrefix !== null) { + attrName = candidatePrefix; + } + /** + * 3.8. If the require well-formed flag is set (its value is true), and + * this attr's localName attribute contains the character + * ":" (U+003A COLON) or does not match the XML Name production or + * equals "xmlns" and attribute namespace is null, then throw an + * exception; the serialization of this attr would not be a + * well-formed attribute. + */ + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName) || + (attr.localName === "xmlns" && attributeNamespace === null))) { + throw new Error("Attribute local name contains invalid characters (well-formed required)."); + } + /** + * 3.9. Append the following strings to result, in the order listed: + * 3.9.1. The value of attr's localName; + * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.9.3. The result of serializing an attribute value given attr's value + * attribute and the require well-formed flag as input; + * 3.9.4. """ (U+0022 QUOTATION MARK). + */ + result.push([attributeNamespace, candidatePrefix, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + } + } + catch (e_8_1) { e_8 = { error: e_8_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_8) throw e_8.error; } + } + /** + * 4. Return the value of result. + */ + return result; }; - - XMLStringifier.prototype.dtdNData = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.convertAttKey = '@'; - - XMLStringifier.prototype.convertPIKey = '?'; - - XMLStringifier.prototype.convertTextKey = '#text'; - - XMLStringifier.prototype.convertCDataKey = '#cdata'; - - XMLStringifier.prototype.convertCommentKey = '#comment'; - - XMLStringifier.prototype.convertRawKey = '#raw'; - - XMLStringifier.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); + /** + * Produces an XML serialization of the attributes of an element node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeAttributes = function (node, requireWellFormed, noDoubleEncoding) { + var e_9, _a; + /** + * 1. Let result be the empty string. + * 2. Let localname set be a new empty namespace localname set. This + * localname set will contain tuples of unique attribute namespaceURI and + * localName pairs, and is populated as each attr is processed. This set is + * used to [optionally] enforce the well-formed constraint that an element + * cannot have two attributes with the same namespaceURI and localName. + * This can occur when two otherwise identical attributes on the same + * element differ only by their prefix values. + */ + var result = []; + var localNameSet = requireWellFormed ? {} : undefined; + try { + /** + * 3. Loop: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + // Optimize common case + if (!requireWellFormed) { + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + continue; + } + /** + * 3.1. If the require well-formed flag is set (its value is true), and the + * localname set contains a tuple whose values match those of a new tuple + * consisting of attr's namespaceURI attribute and localName attribute, + * then throw an exception; the serialization of this attr would fail to + * produce a well-formed element serialization. + */ + if (requireWellFormed && localNameSet && (attr.localName in localNameSet)) { + throw new Error("Element contains duplicate attributes (well-formed required)."); + } + /** + * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and + * localName attribute, and add it to the localname set. + * 3.3. Let attribute namespace be the value of attr's namespaceURI value. + * 3.4. Let candidate prefix be null. + */ + /* istanbul ignore else */ + if (requireWellFormed && localNameSet) + localNameSet[attr.localName] = true; + /** 3.5. If attribute namespace is not null, then run these sub-steps: */ + /** + * 3.6. Append a " " (U+0020 SPACE) to result. + * 3.7. If candidate prefix is not null, then append to result the + * concatenation of candidate prefix with ":" (U+003A COLON). + */ + /** + * 3.8. If the require well-formed flag is set (its value is true), and + * this attr's localName attribute contains the character + * ":" (U+003A COLON) or does not match the XML Name production or + * equals "xmlns" and attribute namespace is null, then throw an + * exception; the serialization of this attr would not be a + * well-formed attribute. + */ + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName))) { + throw new Error("Attribute local name contains invalid characters (well-formed required)."); + } + /** + * 3.9. Append the following strings to result, in the order listed: + * 3.9.1. The value of attr's localName; + * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.9.3. The result of serializing an attribute value given attr's value + * attribute and the require well-formed flag as input; + * 3.9.4. """ (U+0022 QUOTATION MARK). + */ + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + } } - } 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); + catch (e_9_1) { e_9 = { error: e_9_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_9) throw e_9.error; } } - } - return str; + /** + * 4. Return the value of result. + */ + return result; }; - - XMLStringifier.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; + /** + * Records namespace information for the given element and returns the + * default namespace attribute value. + * + * @param node - element node to process + * @param map - namespace prefix map + * @param localPrefixesMap - local prefixes map + */ + BaseWriter.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { + var e_10, _a; + /** + * 1. Let default namespace attr value be null. + */ + var defaultNamespaceAttrValue = null; + try { + /** + * 2. Main: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + /** + * _Note:_ The following conditional steps find namespace prefixes. Only + * attributes in the XMLNS namespace are considered (e.g., attributes made + * to look like namespace declarations via + * setAttribute("xmlns:pretend-prefix", "pretend-namespace") are not + * included). + */ + /** 2.1. Let attribute namespace be the value of attr's namespaceURI value. */ + var attributeNamespace = attr.namespaceURI; + /** 2.2. Let attribute prefix be the value of attr's prefix. */ + var attributePrefix = attr.prefix; + /** 2.3. If the attribute namespace is the XMLNS namespace, then: */ + if (attributeNamespace === infra_1.namespace.XMLNS) { + /** + * 2.3.1. If attribute prefix is null, then attr is a default namespace + * declaration. Set the default namespace attr value to attr's value and + * stop running these steps, returning to Main to visit the next + * attribute. + */ + if (attributePrefix === null) { + defaultNamespaceAttrValue = attr.value; + continue; + /** + * 2.3.2. Otherwise, the attribute prefix is not null and attr is a + * namespace prefix definition. Run the following steps: + */ + } + else { + /** 2.3.2.1. Let prefix definition be the value of attr's localName. */ + var prefixDefinition = attr.localName; + /** 2.3.2.2. Let namespace definition be the value of attr's value. */ + var namespaceDefinition = attr.value; + /** + * 2.3.2.3. If namespace definition is the XML namespace, then stop + * running these steps, and return to Main to visit the next + * attribute. + * + * _Note:_ XML namespace definitions in prefixes are completely + * ignored (in order to avoid unnecessary work when there might be + * prefix conflicts). XML namespaced elements are always handled + * uniformly by prefixing (and overriding if necessary) the element's + * localname with the reserved "xml" prefix. + */ + if (namespaceDefinition === infra_1.namespace.XML) { + continue; + } + /** + * 2.3.2.4. If namespace definition is the empty string (the + * declarative form of having no namespace), then let namespace + * definition be null instead. + */ + if (namespaceDefinition === '') { + namespaceDefinition = null; + } + /** + * 2.3.2.5. If prefix definition is found in map given the namespace + * namespace definition, then stop running these steps, and return to + * Main to visit the next attribute. + * + * _Note:_ This step avoids adding duplicate prefix definitions for + * the same namespace in the map. This has the side-effect of avoiding + * later serialization of duplicate namespace prefix declarations in + * any descendant nodes. + */ + if (map.has(prefixDefinition, namespaceDefinition)) { + continue; + } + /** + * 2.3.2.6. Add the prefix prefix definition to map given namespace + * namespace definition. + */ + map.set(prefixDefinition, namespaceDefinition); + /** + * 2.3.2.7. Add the value of prefix definition as a new key to the + * local prefixes map, with the namespace definition as the key's + * value replacing the value of null with the empty string if + * applicable. + */ + localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; + } + } + } + } + catch (e_10_1) { e_10 = { error: e_10_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_10) throw e_10.error; } + } + /** + * 3. Return the value of default namespace attr value. + * + * _Note:_ The empty string is a legitimate return value and is not + * converted to null. + */ + return defaultNamespaceAttrValue; }; - - XMLStringifier.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(/\r/g, ' '); + /** + * Generates a new prefix for the given namespace. + * + * @param newNamespace - a namespace to generate prefix for + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + */ + BaseWriter.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { + /** + * 1. Let generated prefix be the concatenation of the string "ns" and the + * current numerical value of prefix index. + * 2. Let the value of prefix index be incremented by one. + * 3. Add to map the generated prefix given the new namespace namespace. + * 4. Return the value of generated prefix. + */ + var generatedPrefix = "ns" + prefixIndex.value.toString(); + prefixIndex.value++; + prefixMap.set(generatedPrefix, newNamespace); + return generatedPrefix; }; - - XMLStringifier.prototype.attEscape = function(str) { - var ampregex; - if (this.options.noValidation) { - return str; - } - ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; - return str.replace(ampregex, '&').replace(/" with ">" + * NOTE + * This matches behavior present in browsers, and goes above and beyond the + * grammar requirement in the XML specification's AttValue production by + * also replacing ">" characters. + */ + if (noDoubleEncoding) { + return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + } + else { + var result = ""; + for (var i = 0; i < value.length; i++) { + var c = value[i]; + if (c === "\"") + result += """; + else if (c === "&") + result += "&"; + else if (c === "<") + result += "<"; + else if (c === ">") + result += ">"; + else + result += c; + } + return result; + } }; - - return XMLStringifier; - - })(); - -}).call(this); - + BaseWriter._VoidElementNames = new Set(['area', 'base', 'basefont', + 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', + 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); + return BaseWriter; +}()); +exports.BaseWriter = BaseWriter; +//# sourceMappingURL=BaseWriter.js.map /***/ }), -/***/ 1318: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); +/***/ 7525: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports = XMLText = (function(superClass) { - extend(XMLText, superClass); +"use strict"; - function XMLText(parent, text) { - XMLText.__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); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var BaseCBWriter_1 = __nccwpck_require__(708); +/** + * Serializes XML nodes. + */ +var JSONCBWriter = /** @class */ (function (_super) { + __extends(JSONCBWriter, _super); + /** + * Initializes a new instance of `JSONCBWriter`. + * + * @param builderOptions - XML builder options + */ + function JSONCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._hasChildren = []; + _this._additionalLevel = 0; + return _this; } - - Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - Object.defineProperty(XMLText.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; - } - }); - - XMLText.prototype.clone = function() { - return Object.create(this); + /** @inheritdoc */ + JSONCBWriter.prototype.frontMatter = function () { + return ""; }; - - XMLText.prototype.toString = function(options) { - return this.options.writer.text(this, this.options.writer.filterOptions(options)); + /** @inheritdoc */ + JSONCBWriter.prototype.declaration = function (version, encoding, standalone) { + return ""; }; - - XMLText.prototype.splitText = function(offset) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + JSONCBWriter.prototype.docType = function (name, publicId, systemId) { + return ""; }; - - XMLText.prototype.replaceWholeText = function(content) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + JSONCBWriter.prototype.comment = function (data) { + // { "!": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.comment) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - return XMLText; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 6752: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign, - hasProp = {}.hasOwnProperty; - - assign = (__nccwpck_require__(8229).assign); - - NodeType = __nccwpck_require__(9267); - - XMLDeclaration = __nccwpck_require__(6364); - - XMLDocType = __nccwpck_require__(1801); - - XMLCData = __nccwpck_require__(333); - - XMLComment = __nccwpck_require__(4407); - - XMLElement = __nccwpck_require__(9437); - - XMLRaw = __nccwpck_require__(6329); - - XMLText = __nccwpck_require__(1318); - - XMLProcessingInstruction = __nccwpck_require__(6939); - - XMLDummy = __nccwpck_require__(3590); - - XMLDTDAttList = __nccwpck_require__(1015); - - XMLDTDElement = __nccwpck_require__(2421); - - XMLDTDEntity = __nccwpck_require__(53); - - XMLDTDNotation = __nccwpck_require__(2837); - - WriterState = __nccwpck_require__(9766); - - module.exports = XMLWriterBase = (function() { - function XMLWriterBase(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; - } - } - - XMLWriterBase.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; + /** @inheritdoc */ + JSONCBWriter.prototype.text = function (data) { + // { "#": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.text) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - XMLWriterBase.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 ''; + /** @inheritdoc */ + JSONCBWriter.prototype.instruction = function (target, data) { + // { "?": "target hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.ins) + this._sep() + + this._val(data ? target + " " + data : target) + this._sep() + "}"; }; - - XMLWriterBase.prototype.endline = function(node, options, level) { - if (!options.pretty || options.suppressPrettyCount) { - return ''; - } else { - return options.newline; - } + /** @inheritdoc */ + JSONCBWriter.prototype.cdata = function (data) { + // { "$": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.cdata) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - XMLWriterBase.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; + /** @inheritdoc */ + JSONCBWriter.prototype.attribute = function (name, value) { + // { "@name": "val" } + return this._comma() + this._beginLine(1) + "{" + this._sep() + + this._key(this._builderOptions.convert.att + name) + this._sep() + + this._val(value) + this._sep() + "}"; }; - - XMLWriterBase.prototype.cdata = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** @inheritdoc */ + JSONCBWriter.prototype.openTagBegin = function (name) { + // { "node": { "#": [ + var str = this._comma() + this._beginLine() + "{" + this._sep() + this._key(name) + this._sep() + "{"; + this._additionalLevel++; + this.hasData = true; + str += this._beginLine() + this._key(this._builderOptions.convert.text) + this._sep() + "["; + this._hasChildren.push(false); + return str; }; - - XMLWriterBase.prototype.comment = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** @inheritdoc */ + JSONCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (selfClosing) { + var str = this._sep() + "]"; + this._additionalLevel--; + str += this._beginLine() + "}" + this._sep() + "}"; + return str; + } + else { + return ""; + } }; - - XMLWriterBase.prototype.declaration = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + ''; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** @inheritdoc */ + JSONCBWriter.prototype.closeTag = function (name) { + // ] } } + var str = this._beginLine() + "]"; + this._additionalLevel--; + str += this._beginLine() + "}" + this._sep() + "}"; + return str; }; - - XMLWriterBase.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 += ' 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); + /** @inheritdoc */ + JSONCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + JSONCBWriter.prototype.endElement = function (name) { this._hasChildren.pop(); }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + JSONCBWriter.prototype._beginLine = function (additionalOffset) { + if (additionalOffset === void 0) { additionalOffset = 0; } + if (this._writerOptions.prettyPrint) { + return (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level + additionalOffset); + } + else { + return ""; } - 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; }; - - XMLWriterBase.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 += '' + this.endline(node, options, level); - } else { - options.state = WriterState.CloseTag; - r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level); + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + JSONCBWriter.prototype._indent = function (level) { + if (level + this._additionalLevel <= 0) { + return ""; } - } 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 += '' + 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); + else { + return this._writerOptions.indent.repeat(level + this._additionalLevel); } - options.state = WriterState.CloseTag; - r += this.indent(node, options, level) + ''; - if (prettySuppressed) { - options.suppressPrettyCount--; + }; + /** + * Produces a comma before a child node if it has previous siblings. + */ + JSONCBWriter.prototype._comma = function () { + var str = (this._hasChildren[this._hasChildren.length - 1] ? "," : ""); + if (this._hasChildren.length > 0) { + this._hasChildren[this._hasChildren.length - 1] = true; } - r += this.endline(node, options, level); - options.state = WriterState.None; - } - this.closeNode(node, options, level); - return r; + return str; }; - - XMLWriterBase.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); - } + /** + * Produces a separator string. + */ + JSONCBWriter.prototype._sep = function () { + return (this._writerOptions.prettyPrint ? " " : ""); }; - - XMLWriterBase.prototype.processingInstruction = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + ''; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** + * Produces a JSON key string delimited with double quotes. + */ + JSONCBWriter.prototype._key = function (key) { + return "\"" + key + "\":"; }; - - XMLWriterBase.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; + /** + * Produces a JSON value string delimited with double quotes. + */ + JSONCBWriter.prototype._val = function (val) { + return JSON.stringify(val); }; + return JSONCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.JSONCBWriter = JSONCBWriter; +//# sourceMappingURL=JSONCBWriter.js.map - XMLWriterBase.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; - }; +/***/ }), - XMLWriterBase.prototype.dtdAttList = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; +/***/ 7510: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLWriterBase.prototype.dtdElement = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; +"use strict"; - XMLWriterBase.prototype.dtdEntity = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLWriterBase.prototype.dtdNotation = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; - - XMLWriterBase.prototype.openNode = function(node, options, level) {}; - - XMLWriterBase.prototype.closeNode = function(node, options, level) {}; - - XMLWriterBase.prototype.openAttribute = function(att, options, level) {}; - - XMLWriterBase.prototype.closeAttribute = function(att, options, level) {}; - - return XMLWriterBase; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 2958: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref; - - ref = __nccwpck_require__(8229), assign = ref.assign, isFunction = ref.isFunction; - - XMLDOMImplementation = __nccwpck_require__(8310); - - XMLDocument = __nccwpck_require__(3730); - - XMLDocumentCB = __nccwpck_require__(7356); - - XMLStringWriter = __nccwpck_require__(5913); - - XMLStreamWriter = __nccwpck_require__(8601); - - NodeType = __nccwpck_require__(9267); - - WriterState = __nccwpck_require__(9766); - - module.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; - }; - - module.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); - } - }; - - module.exports.stringWriter = function(options) { - return new XMLStringWriter(options); - }; - - module.exports.streamWriter = function(stream, options) { - return new XMLStreamWriter(stream, options); - }; - - module.exports.implementation = new XMLDOMImplementation(); - - module.exports.nodeType = NodeType; - - module.exports.writerState = WriterState; - -}).call(this); - - -/***/ }), - -/***/ 5696: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(6417); -var util_1 = __nccwpck_require__(6195); -var util_2 = __nccwpck_require__(5282); -var _1 = __nccwpck_require__(4260); -var dom_1 = __nccwpck_require__(770); -/** @inheritdoc */ -function builder(p1, p2) { - var options = formatBuilderOptions(isXMLBuilderCreateOptions(p1) ? p1 : interfaces_1.DefaultBuilderOptions); - var nodes = util_2.Guard.isNode(p1) || util_1.isArray(p1) ? p1 : p2; - if (nodes === undefined) { - throw new Error("Invalid arguments."); - } - if (util_1.isArray(nodes)) { - var builders = []; - for (var i = 0; i < nodes.length; i++) { - var builder_1 = new _1.XMLBuilderImpl(nodes[i]); - builder_1.set(options); - builders.push(builder_1); - } - return builders; - } - else { - var builder_2 = new _1.XMLBuilderImpl(nodes); - builder_2.set(options); - return builder_2; - } -} -exports.builder = builder; -/** @inheritdoc */ -function create(p1, p2) { - var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? - p1 : interfaces_1.DefaultBuilderOptions); - var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; - var doc = dom_1.createDocument(); - setOptions(doc, options); - var builder = new _1.XMLBuilderImpl(doc); - if (contents !== undefined) { - // parse contents - builder.ele(contents); - } - return builder; -} -exports.create = create; -/** @inheritdoc */ -function fragment(p1, p2) { - var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? - p1 : interfaces_1.DefaultBuilderOptions); - var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; - var doc = dom_1.createDocument(); - setOptions(doc, options, true); - var builder = new _1.XMLBuilderImpl(doc.createDocumentFragment()); - if (contents !== undefined) { - // parse contents - builder.ele(contents); - } - return builder; -} -exports.fragment = fragment; -/** @inheritdoc */ -function convert(p1, p2, p3) { - var builderOptions; - var contents; - var convertOptions; - if (isXMLBuilderCreateOptions(p1) && p2 !== undefined) { - builderOptions = p1; - contents = p2; - convertOptions = p3; - } - else { - builderOptions = interfaces_1.DefaultBuilderOptions; - contents = p1; - convertOptions = p2 || undefined; - } - return create(builderOptions, contents).end(convertOptions); -} -exports.convert = convert; -function isXMLBuilderCreateOptions(obj) { - if (!util_1.isPlainObject(obj)) - return false; - for (var key in obj) { - /* istanbul ignore else */ - if (obj.hasOwnProperty(key)) { - if (!interfaces_1.XMLBuilderOptionKeys.has(key)) - return false; - } - } - return true; -} -function formatBuilderOptions(createOptions) { - if (createOptions === void 0) { createOptions = {}; } - var options = util_1.applyDefaults(createOptions, interfaces_1.DefaultBuilderOptions); - if (options.convert.att.length === 0 || - options.convert.ins.length === 0 || - options.convert.text.length === 0 || - options.convert.cdata.length === 0 || - options.convert.comment.length === 0) { - throw new Error("JS object converter strings cannot be zero length."); - } - return options; -} -function setOptions(doc, options, isFragment) { - var docWithSettings = doc; - docWithSettings._xmlBuilderOptions = options; - docWithSettings._isFragment = isFragment; -} -//# sourceMappingURL=BuilderFunctions.js.map - -/***/ }), - -/***/ 268: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -var _1 = __nccwpck_require__(4260); -/** - * Creates an XML builder which serializes the document in chunks. - * - * @param options - callback builder options - * - * @returns callback builder - */ -function createCB(options) { - return new _1.XMLBuilderCBImpl(options); -} -exports.createCB = createCB; -/** - * Creates an XML builder which serializes the fragment in chunks. - * - * @param options - callback builder options - * - * @returns callback builder - */ -function fragmentCB(options) { - return new _1.XMLBuilderCBImpl(options, true); -} -exports.fragmentCB = fragmentCB; -//# sourceMappingURL=BuilderFunctionsCB.js.map - -/***/ }), - -/***/ 1438: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __values = (this && this.__values) || function(o) { @@ -95193,5876 +95185,5884 @@ var __values = (this && this.__values) || function(o) { }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(6417); +var ObjectWriter_1 = __nccwpck_require__(243); var util_1 = __nccwpck_require__(6195); -var BuilderFunctions_1 = __nccwpck_require__(5696); -var algorithm_1 = __nccwpck_require__(61); -var infra_1 = __nccwpck_require__(4251); -var NamespacePrefixMap_1 = __nccwpck_require__(283); -var LocalNameSet_1 = __nccwpck_require__(9049); -var util_2 = __nccwpck_require__(5282); -var XMLCBWriter_1 = __nccwpck_require__(7572); -var JSONCBWriter_1 = __nccwpck_require__(7525); -var YAMLCBWriter_1 = __nccwpck_require__(2444); -var events_1 = __nccwpck_require__(2361); +var BaseWriter_1 = __nccwpck_require__(7644); /** - * Represents a readable XML document stream. + * Serializes XML nodes into a JSON string. */ -var XMLBuilderCBImpl = /** @class */ (function (_super) { - __extends(XMLBuilderCBImpl, _super); - /** - * Initializes a new instance of `XMLStream`. - * - * @param options - stream writer options - * @param fragment - whether to create fragment stream or a document stream +var JSONWriter = /** @class */ (function (_super) { + __extends(JSONWriter, _super); + /** + * Initializes a new instance of `JSONWriter`. * - * @returns XML stream + * @param builderOptions - XML builder options + * @param writerOptions - serialization options */ - function XMLBuilderCBImpl(options, fragment) { - if (fragment === void 0) { fragment = false; } - var _this = _super.call(this) || this; - _this._hasDeclaration = false; - _this._docTypeName = ""; - _this._hasDocumentElement = false; - _this._currentElementSerialized = false; - _this._openTags = []; - _this._ended = false; - _this._fragment = fragment; + function JSONWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; // provide default options - _this._options = util_1.applyDefaults(options || {}, interfaces_1.DefaultXMLBuilderCBOptions); - _this._builderOptions = { - defaultNamespace: _this._options.defaultNamespace, - namespaceAlias: _this._options.namespaceAlias - }; - if (_this._options.format === "json") { - _this._writer = new JSONCBWriter_1.JSONCBWriter(_this._options); - } - else if (_this._options.format === "yaml") { - _this._writer = new YAMLCBWriter_1.YAMLCBWriter(_this._options); - } - else { - _this._writer = new XMLCBWriter_1.XMLCBWriter(_this._options); - } - // automatically create listeners for callbacks passed via options - if (_this._options.data !== undefined) { - _this.on("data", _this._options.data); - } - if (_this._options.end !== undefined) { - _this.on("end", _this._options.end); - } - if (_this._options.error !== undefined) { - _this.on("error", _this._options.error); - } - _this._prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); - _this._prefixMap.set("xml", infra_1.namespace.XML); - _this._prefixIndex = { value: 1 }; - _this._push(_this._writer.frontMatter()); + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + prettyPrint: false, + indent: ' ', + newline: '\n', + offset: 0, + group: false, + verbose: false + }); return _this; } - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.ele = function (p1, p2, p3) { + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + * @param writerOptions - serialization options + */ + JSONWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + // recursively convert object into JSON string + return this._beginLine(this._writerOptions, 0) + this._convertObject(val, this._writerOptions); + }; + /** + * Produces an XML serialization of the given object. + * + * @param obj - object to serialize + * @param options - serialization options + * @param level - depth of the XML tree + */ + JSONWriter.prototype._convertObject = function (obj, options, level) { var e_1, _a; - // parse if JS object or XML or JSON string - if (util_1.isObject(p1) || (util_1.isString(p1) && (/^\s* 0) { + return new Array(indentLevel).join(options.indent); + } } - this._currentElementSerialized = false; - if (!this._fragment) { - this._hasDocumentElement = true; + return ''; + }; + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + * @param level - current depth of the XML tree + */ + JSONWriter.prototype._endLine = function (options, level) { + if (!options.prettyPrint) { + return ''; + } + else { + return options.newline; } - return this; }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.att = function (p1, p2, p3) { - if (this._currentElement === undefined) { - this.emit("error", new Error("Cannot insert an attribute node as child of a document node.")); - return this; + /** + * Produces a JSON key string delimited with double quotes. + */ + JSONWriter.prototype._key = function (key) { + return "\"" + key + "\":"; + }; + /** + * Produces a JSON value string delimited with double quotes. + */ + JSONWriter.prototype._val = function (val) { + return JSON.stringify(val); + }; + /** + * Determines if an object is a leaf node. + * + * @param obj + */ + JSONWriter.prototype._isLeafNode = function (obj) { + return this._descendantCount(obj) <= 1; + }; + /** + * Counts the number of descendants of the given object. + * + * @param obj + * @param count + */ + JSONWriter.prototype._descendantCount = function (obj, count) { + var _this = this; + if (count === void 0) { count = 0; } + if (util_1.isArray(obj)) { + util_1.forEachArray(obj, function (val) { return count += _this._descendantCount(val, count); }, this); } - try { - this._currentElement.att(p1, p2, p3); + else if (util_1.isObject(obj)) { + util_1.forEachObject(obj, function (key, val) { return count += _this._descendantCount(val, count); }, this); } - catch (err) { - this.emit("error", err); - return this; + else { + count++; } - return this; + return count; }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.com = function (content) { - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).com(content).first().node; - } - catch (err) { - /* istanbul ignore next */ - this.emit("error", err); - /* istanbul ignore next */ - return this; - } - if (this._options.wellFormed && (!algorithm_1.xml_isLegalChar(node.data) || - node.data.indexOf("--") !== -1 || node.data.endsWith("-"))) { - this.emit("error", new Error("Comment data contains invalid characters (well-formed required).")); - return this; - } - this._push(this._writer.comment(node.data)); - return this; + return JSONWriter; +}(BaseWriter_1.BaseWriter)); +exports.JSONWriter = JSONWriter; +//# sourceMappingURL=JSONWriter.js.map + +/***/ }), + +/***/ 1397: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.txt = function (content) { - if (!this._fragment && this._currentElement === undefined) { - this.emit("error", new Error("Cannot insert a text node as child of a document node.")); - return this; - } - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).txt(content).first().node; - } - catch (err) { - /* istanbul ignore next */ - this.emit("error", err); - /* istanbul ignore next */ - return this; - } - if (this._options.wellFormed && !algorithm_1.xml_isLegalChar(node.data)) { - this.emit("error", new Error("Text data contains invalid characters (well-formed required).")); - return this; - } - var markup = ""; - if (this._options.noDoubleEncoding) { - markup = node.data.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>'); - } - else { - for (var i = 0; i < node.data.length; i++) { - var c = node.data[i]; - if (c === "&") - markup += "&"; - else if (c === "<") - markup += "<"; - else if (c === ">") - markup += ">"; - else - markup += c; - } - } - this._push(this._writer.text(markup)); - return this; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.ins = function (target, content) { - if (content === void 0) { content = ''; } - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).ins(target, content).first().node; - } - catch (err) { - /* istanbul ignore next */ - this.emit("error", err); - /* istanbul ignore next */ - return this; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var ObjectWriter_1 = __nccwpck_require__(243); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into ES6 maps and arrays. + */ +var MapWriter = /** @class */ (function (_super) { + __extends(MapWriter, _super); + /** + * Initializes a new instance of `MapWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function MapWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + format: "map", + wellFormed: false, + noDoubleEncoding: false, + group: false, + verbose: false + }); + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + */ + MapWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + verbose: false + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + // recursively convert object into Map + return this._convertObject(val); + }; + /** + * Recursively converts a JS object into an ES5 map. + * + * @param obj - a JS object + */ + MapWriter.prototype._convertObject = function (obj) { + if (util_1.isArray(obj)) { + for (var i = 0; i < obj.length; i++) { + obj[i] = this._convertObject(obj[i]); + } + return obj; } - if (this._options.wellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { - this.emit("error", new Error("Processing instruction target contains invalid characters (well-formed required).")); - return this; + else if (util_1.isObject(obj)) { + var map = new Map(); + for (var key in obj) { + map.set(key, this._convertObject(obj[key])); + } + return map; } - if (this._options.wellFormed && !algorithm_1.xml_isLegalChar(node.data)) { - this.emit("error", Error("Processing instruction data contains invalid characters (well-formed required).")); - return this; + else { + return obj; } - this._push(this._writer.instruction(node.target, node.data)); - return this; }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dat = function (content) { - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).dat(content).first().node; - } - catch (err) { - this.emit("error", err); - return this; - } - this._push(this._writer.cdata(node.data)); - return this; + return MapWriter; +}(BaseWriter_1.BaseWriter)); +exports.MapWriter = MapWriter; +//# sourceMappingURL=MapWriter.js.map + +/***/ }), + +/***/ 243: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dec = function (options) { - if (options === void 0) { options = { version: "1.0" }; } - if (this._fragment) { - this.emit("error", Error("Cannot insert an XML declaration into a document fragment.")); - return this; - } - if (this._hasDeclaration) { - this.emit("error", Error("XML declaration is already inserted.")); - return this; - } - this._push(this._writer.declaration(options.version || "1.0", options.encoding, options.standalone)); - this._hasDeclaration = true; - return this; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dtd = function (options) { - if (this._fragment) { - this.emit("error", Error("Cannot insert a DocType declaration into a document fragment.")); - return this; - } - if (this._docTypeName !== "") { - this.emit("error", new Error("DocType declaration is already inserted.")); - return this; - } - if (this._hasDocumentElement) { - this.emit("error", new Error("Cannot insert DocType declaration after document element.")); - return this; - } - var node; - try { - node = BuilderFunctions_1.create().dtd(options).first().node; - } - catch (err) { - this.emit("error", err); - return this; - } - if (this._options.wellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { - this.emit("error", new Error("DocType public identifier does not match PubidChar construct (well-formed required).")); - return this; - } - if (this._options.wellFormed && - (!algorithm_1.xml_isLegalChar(node.systemId) || - (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { - this.emit("error", new Error("DocType system identifier contains invalid characters (well-formed required).")); - return this; +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } - this._docTypeName = options.name; - this._push(this._writer.docType(options.name, node.publicId, node.systemId)); - return this; - }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.up = function () { - this._serializeOpenTag(false); - this._serializeCloseTag(); - return this; - }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.end = function () { - this._serializeOpenTag(false); - while (this._openTags.length > 0) { - this._serializeCloseTag(); - } - this._push(null); - return this; }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var interfaces_1 = __nccwpck_require__(7305); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into objects and arrays. + */ +var ObjectWriter = /** @class */ (function (_super) { + __extends(ObjectWriter, _super); /** - * Serializes the opening tag of an element node. + * Initializes a new instance of `ObjectWriter`. * - * @param hasChildren - whether the element node has child nodes + * @param builderOptions - XML builder options + * @param writerOptions - serialization options */ - XMLBuilderCBImpl.prototype._serializeOpenTag = function (hasChildren) { - if (this._currentElementSerialized) - return; - if (this._currentElement === undefined) - return; - var node = this._currentElement.node; - if (this._options.wellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - this.emit("error", new Error("Node local name contains invalid characters (well-formed required).")); - return; - } - var qualifiedName = ""; - var ignoreNamespaceDefinitionAttribute = false; - var map = this._prefixMap.copy(); - var localPrefixesMap = {}; - var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); - var inheritedNS = this._openTags.length === 0 ? null : this._openTags[this._openTags.length - 1][1]; - var ns = node.namespaceURI; - if (ns === null) - ns = inheritedNS; - if (inheritedNS === ns) { - if (localDefaultNamespace !== null) { - ignoreNamespaceDefinitionAttribute = true; - } - if (ns === infra_1.namespace.XML) { - qualifiedName = "xml:" + node.localName; - } - else { - qualifiedName = node.localName; - } - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - else { - var prefix = node.prefix; - var candidatePrefix = null; - if (prefix !== null || ns !== localDefaultNamespace) { - candidatePrefix = map.get(prefix, ns); - } - if (prefix === "xmlns") { - if (this._options.wellFormed) { - this.emit("error", new Error("An element cannot have the 'xmlns' prefix (well-formed required).")); - return; - } - candidatePrefix = prefix; - } - if (candidatePrefix !== null) { - qualifiedName = candidatePrefix + ':' + node.localName; - if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { - inheritedNS = localDefaultNamespace || null; - } - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - else if (prefix !== null) { - if (prefix in localPrefixesMap) { - prefix = this._generatePrefix(ns, map, this._prefixIndex); - } - map.set(prefix, ns); - qualifiedName += prefix + ':' + node.localName; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - this._push(this._writer.attribute("xmlns:" + prefix, this._serializeAttributeValue(ns, this._options.wellFormed))); - if (localDefaultNamespace !== null) { - inheritedNS = localDefaultNamespace || null; - } - } - else if (localDefaultNamespace === null || - (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { - ignoreNamespaceDefinitionAttribute = true; - qualifiedName += node.localName; - inheritedNS = ns; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - this._push(this._writer.attribute("xmlns", this._serializeAttributeValue(ns, this._options.wellFormed))); - } - else { - qualifiedName += node.localName; - inheritedNS = ns; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - } - this._serializeAttributes(node, map, this._prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, this._options.wellFormed); - var isHTML = (ns === infra_1.namespace.HTML); - if (isHTML && !hasChildren && - XMLBuilderCBImpl._VoidElementNames.has(node.localName)) { - this._push(this._writer.openTagEnd(qualifiedName, true, true)); - this._writer.endElement(qualifiedName); - } - else if (!isHTML && !hasChildren) { - this._push(this._writer.openTagEnd(qualifiedName, true, false)); - this._writer.endElement(qualifiedName); - } - else { - this._push(this._writer.openTagEnd(qualifiedName, false, false)); - } - this._currentElementSerialized = true; - /** - * Save qualified name, original inherited ns, original prefix map, and - * hasChildren flag. - */ - this._openTags.push([qualifiedName, inheritedNS, this._prefixMap, hasChildren]); + function ObjectWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._writerOptions = util_1.applyDefaults(writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + group: false, + verbose: false + }); + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + */ + ObjectWriter.prototype.serialize = function (node) { + this._currentList = []; + this._currentIndex = 0; + this._listRegister = [this._currentList]; /** - * New values of inherited namespace and prefix map will be used while - * serializing child nodes. They will be returned to their original values - * when this node is closed using the _openTags array item we saved above. + * First pass, serialize nodes + * This creates a list of nodes grouped under node types while preserving + * insertion order. For example: + * [ + * root: [ + * node: [ + * { "@" : { "att1": "val1", "att2": "val2" } + * { "#": "node text" } + * { childNode: [] } + * { "#": "more text" } + * ], + * node: [ + * { "@" : { "att": "val" } + * { "#": [ "text line1", "text line2" ] } + * ] + * ] + * ] */ - if (this._isPrefixMapModified(this._prefixMap, map)) { - this._prefixMap = map; - } + this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); /** - * Calls following this will either serialize child nodes or close this tag. + * Second pass, process node lists. Above example becomes: + * { + * root: { + * node: [ + * { + * "@att1": "val1", + * "@att2": "val2", + * "#1": "node text", + * childNode: {}, + * "#2": "more text" + * }, + * { + * "@att": "val", + * "#": [ "text line1", "text line2" ] + * } + * ] + * } + * } */ - this._writer.level++; + return this._process(this._currentList, this._writerOptions); }; - /** - * Serializes the closing tag of an element node. - */ - XMLBuilderCBImpl.prototype._serializeCloseTag = function () { - this._writer.level--; - var lastEle = this._openTags.pop(); - /* istanbul ignore next */ - if (lastEle === undefined) { - this.emit("error", new Error("Last element is undefined.")); - return; + ObjectWriter.prototype._process = function (items, options) { + var _a, _b, _c, _d, _e, _f, _g; + if (items.length === 0) + return {}; + // determine if there are non-unique element names + var namesSeen = {}; + var hasNonUniqueNames = false; + var textCount = 0; + var commentCount = 0; + var instructionCount = 0; + var cdataCount = 0; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + continue; + case "#": + textCount++; + break; + case "!": + commentCount++; + break; + case "?": + instructionCount++; + break; + case "$": + cdataCount++; + break; + default: + if (namesSeen[key]) { + hasNonUniqueNames = true; + } + else { + namesSeen[key] = true; + } + break; + } } - var _a = __read(lastEle, 4), qualifiedName = _a[0], ns = _a[1], map = _a[2], hasChildren = _a[3]; - /** - * Restore original values of inherited namespace and prefix map. - */ - this._prefixMap = map; - if (!hasChildren) - return; - this._push(this._writer.closeTag(qualifiedName)); - this._writer.endElement(qualifiedName); - }; - /** - * Pushes data to internal buffer. - * - * @param data - data - */ - XMLBuilderCBImpl.prototype._push = function (data) { - if (data === null) { - this._ended = true; - this.emit("end"); - } - else if (this._ended) { - this.emit("error", new Error("Cannot push to ended stream.")); - } - else if (data.length !== 0) { - this._writer.hasData = true; - this.emit("data", data, this._writer.level); + var defAttrKey = this._getAttrKey(); + var defTextKey = this._getNodeKey(interfaces_1.NodeType.Text); + var defCommentKey = this._getNodeKey(interfaces_1.NodeType.Comment); + var defInstructionKey = this._getNodeKey(interfaces_1.NodeType.ProcessingInstruction); + var defCdataKey = this._getNodeKey(interfaces_1.NodeType.CData); + if (textCount === 1 && items.length === 1 && util_1.isString(items[0]["#"])) { + // special case of an element node with a single text node + return items[0]["#"]; } - }; - /** - * Reads and serializes an XML tree. - * - * @param node - root node - */ - XMLBuilderCBImpl.prototype._fromNode = function (node) { - var e_2, _a, e_3, _b; - if (util_2.Guard.isElementNode(node)) { - var name = node.prefix ? node.prefix + ":" + node.localName : node.localName; - if (node.namespaceURI !== null) { - this.ele(node.namespaceURI, name); - } - else { - this.ele(name); - } - try { - for (var _c = __values(node.attributes), _d = _c.next(); !_d.done; _d = _c.next()) { - var attr = _d.value; - var name_1 = attr.prefix ? attr.prefix + ":" + attr.localName : attr.localName; - if (attr.namespaceURI !== null) { - this.att(attr.namespaceURI, name_1, attr.value); + else if (hasNonUniqueNames) { + var obj = {}; + // process attributes first + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + if (key === "@") { + var attrs = item["@"]; + var attrKeys = Object.keys(attrs); + if (attrKeys.length === 1) { + obj[defAttrKey + attrKeys[0]] = attrs[attrKeys[0]]; } else { - this.att(name_1, attr.value); + obj[defAttrKey] = item["@"]; } } } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + // list contains element nodes with non-unique names + // return an array with mixed content notation + var result = []; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + // attributes were processed above + break; + case "#": + result.push((_a = {}, _a[defTextKey] = item["#"], _a)); + break; + case "!": + result.push((_b = {}, _b[defCommentKey] = item["!"], _b)); + break; + case "?": + result.push((_c = {}, _c[defInstructionKey] = item["?"], _c)); + break; + case "$": + result.push((_d = {}, _d[defCdataKey] = item["$"], _d)); + break; + default: + // element node + var ele = item; + if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { + // group of element nodes + var eleGroup = []; + var listOfLists = ele[key]; + for (var i_1 = 0; i_1 < listOfLists.length; i_1++) { + eleGroup.push(this._process(listOfLists[i_1], options)); + } + result.push((_e = {}, _e[key] = eleGroup, _e)); + } + else { + // single element node + if (options.verbose) { + result.push((_f = {}, _f[key] = [this._process(ele[key], options)], _f)); + } + else { + result.push((_g = {}, _g[key] = this._process(ele[key], options), _g)); + } + } + break; + } + } + obj[defTextKey] = result; + return obj; + } + else { + // all element nodes have unique names + // return an object while prefixing data node keys + var textId = 1; + var commentId = 1; + var instructionId = 1; + var cdataId = 1; + var obj = {}; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + var attrs = item["@"]; + var attrKeys = Object.keys(attrs); + if (!options.group || attrKeys.length === 1) { + for (var attrName in attrs) { + obj[defAttrKey + attrName] = attrs[attrName]; + } + } + else { + obj[defAttrKey] = attrs; + } + break; + case "#": + textId = this._processSpecItem(item["#"], obj, options.group, defTextKey, textCount, textId); + break; + case "!": + commentId = this._processSpecItem(item["!"], obj, options.group, defCommentKey, commentCount, commentId); + break; + case "?": + instructionId = this._processSpecItem(item["?"], obj, options.group, defInstructionKey, instructionCount, instructionId); + break; + case "$": + cdataId = this._processSpecItem(item["$"], obj, options.group, defCdataKey, cdataCount, cdataId); + break; + default: + // element node + var ele = item; + if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { + // group of element nodes + var eleGroup = []; + var listOfLists = ele[key]; + for (var i_2 = 0; i_2 < listOfLists.length; i_2++) { + eleGroup.push(this._process(listOfLists[i_2], options)); + } + obj[key] = eleGroup; + } + else { + // single element node + if (options.verbose) { + obj[key] = [this._process(ele[key], options)]; + } + else { + obj[key] = this._process(ele[key], options); + } + } + break; } - finally { if (e_2) throw e_2.error; } } + return obj; + } + }; + ObjectWriter.prototype._processSpecItem = function (item, obj, group, defKey, count, id) { + var e_1, _a; + if (!group && util_1.isArray(item) && count + item.length > 2) { try { - for (var _e = __values(node.childNodes), _f = _e.next(); !_f.done; _f = _e.next()) { - var child = _f.value; - this._fromNode(child); + for (var item_1 = __values(item), item_1_1 = item_1.next(); !item_1_1.done; item_1_1 = item_1.next()) { + var subItem = item_1_1.value; + var key = defKey + (id++).toString(); + obj[key] = subItem; } } - catch (e_3_1) { e_3 = { error: e_3_1 }; } + catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); } - finally { if (e_3) throw e_3.error; } + finally { if (e_1) throw e_1.error; } } - this.up(); } - else if (util_2.Guard.isExclusiveTextNode(node) && node.data) { - this.txt(node.data); + else { + var key = count > 1 ? defKey + (id++).toString() : defKey; + obj[key] = item; } - else if (util_2.Guard.isCommentNode(node)) { - this.com(node.data); + return id; + }; + /** @inheritdoc */ + ObjectWriter.prototype.beginElement = function (name) { + var _a, _b; + var childItems = []; + if (this._currentList.length === 0) { + this._currentList.push((_a = {}, _a[name] = childItems, _a)); } - else if (util_2.Guard.isCDATASectionNode(node)) { - this.dat(node.data); + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isElementNode(lastItem, name)) { + if (lastItem[name].length !== 0 && util_1.isArray(lastItem[name][0])) { + var listOfLists = lastItem[name]; + listOfLists.push(childItems); + } + else { + lastItem[name] = [lastItem[name], childItems]; + } + } + else { + this._currentList.push((_b = {}, _b[name] = childItems, _b)); + } } - else if (util_2.Guard.isProcessingInstructionNode(node)) { - this.ins(node.target, node.data); + this._currentIndex++; + if (this._listRegister.length > this._currentIndex) { + this._listRegister[this._currentIndex] = childItems; + } + else { + this._listRegister.push(childItems); } + this._currentList = childItems; }; - /** - * Produces an XML serialization of the attributes of an element node. - * - * @param node - node to serialize - * @param map - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param localPrefixesMap - local prefixes map - * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace - * attributes - * @param requireWellFormed - whether to check conformance - */ - XMLBuilderCBImpl.prototype._serializeAttributes = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed) { - var e_4, _a; - var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; - try { - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - // Optimize common case - if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { - this._push(this._writer.attribute(attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); - continue; - } - if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { - this.emit("error", new Error("Element contains duplicate attributes (well-formed required).")); - return; - } - if (requireWellFormed && localNameSet) - localNameSet.set(attr.namespaceURI, attr.localName); - var attributeNamespace = attr.namespaceURI; - var candidatePrefix = null; - if (attributeNamespace !== null) { - candidatePrefix = map.get(attr.prefix, attributeNamespace); - if (attributeNamespace === infra_1.namespace.XMLNS) { - if (attr.value === infra_1.namespace.XML || - (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || - (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || - localPrefixesMap[attr.localName] !== attr.value) && - map.has(attr.localName, attr.value))) - continue; - if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { - this.emit("error", new Error("XMLNS namespace is reserved (well-formed required).")); - return; - } - if (requireWellFormed && attr.value === '') { - this.emit("error", new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).")); - return; - } - if (attr.prefix === 'xmlns') - candidatePrefix = 'xmlns'; - /** - * _Note:_ The (candidatePrefix === null) check is not in the spec. - * We deviate from the spec here. Otherwise a prefix is generated for - * all attributes with namespaces. - */ - } - else if (candidatePrefix === null) { - if (attr.prefix !== null && - (!map.hasPrefix(attr.prefix) || - map.has(attr.prefix, attributeNamespace))) { - /** - * Check if we can use the attribute's own prefix. - * We deviate from the spec here. - * TODO: This is not an efficient way of searching for prefixes. - * Follow developments to the spec. - */ - candidatePrefix = attr.prefix; - } - else { - candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); - } - this._push(this._writer.attribute("xmlns:" + candidatePrefix, this._serializeAttributeValue(attributeNamespace, this._options.wellFormed))); - } + /** @inheritdoc */ + ObjectWriter.prototype.endElement = function () { + this._currentList = this._listRegister[--this._currentIndex]; + }; + /** @inheritdoc */ + ObjectWriter.prototype.attribute = function (name, value) { + var _a, _b; + if (this._currentList.length === 0) { + this._currentList.push({ "@": (_a = {}, _a[name] = value, _a) }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + /* istanbul ignore else */ + if (this._isAttrNode(lastItem)) { + lastItem["@"][name] = value; + } + else { + this._currentList.push({ "@": (_b = {}, _b[name] = value, _b) }); + } + } + }; + /** @inheritdoc */ + ObjectWriter.prototype.comment = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "!": data }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isCommentNode(lastItem)) { + if (util_1.isArray(lastItem["!"])) { + lastItem["!"].push(data); } - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName) || - (attr.localName === "xmlns" && attributeNamespace === null))) { - this.emit("error", new Error("Attribute local name contains invalid characters (well-formed required).")); - return; + else { + lastItem["!"] = [lastItem["!"], data]; } - this._push(this._writer.attribute((candidatePrefix !== null ? candidatePrefix + ":" : "") + attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); } - } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + else { + this._currentList.push({ "!": data }); } - finally { if (e_4) throw e_4.error; } } }; - /** - * Produces an XML serialization of an attribute value. - * - * @param value - attribute value - * @param requireWellFormed - whether to check conformance - */ - XMLBuilderCBImpl.prototype._serializeAttributeValue = function (value, requireWellFormed) { - if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { - this.emit("error", new Error("Invalid characters in attribute value.")); - return ""; - } - if (value === null) - return ""; - if (this._options.noDoubleEncoding) { - return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); + /** @inheritdoc */ + ObjectWriter.prototype.text = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "#": data }); } else { - var result = ""; - for (var i = 0; i < value.length; i++) { - var c = value[i]; - if (c === "\"") - result += """; - else if (c === "&") - result += "&"; - else if (c === "<") - result += "<"; - else if (c === ">") - result += ">"; - else - result += c; + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isTextNode(lastItem)) { + if (util_1.isArray(lastItem["#"])) { + lastItem["#"].push(data); + } + else { + lastItem["#"] = [lastItem["#"], data]; + } + } + else { + this._currentList.push({ "#": data }); } - return result; } }; - /** - * Records namespace information for the given element and returns the - * default namespace attribute value. - * - * @param node - element node to process - * @param map - namespace prefix map - * @param localPrefixesMap - local prefixes map - */ - XMLBuilderCBImpl.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { - var e_5, _a; - var defaultNamespaceAttrValue = null; - try { - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - var attributeNamespace = attr.namespaceURI; - var attributePrefix = attr.prefix; - if (attributeNamespace === infra_1.namespace.XMLNS) { - if (attributePrefix === null) { - defaultNamespaceAttrValue = attr.value; - continue; - } - else { - var prefixDefinition = attr.localName; - var namespaceDefinition = attr.value; - if (namespaceDefinition === infra_1.namespace.XML) { - continue; - } - if (namespaceDefinition === '') { - namespaceDefinition = null; - } - if (map.has(prefixDefinition, namespaceDefinition)) { - continue; - } - map.set(prefixDefinition, namespaceDefinition); - localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; - } + /** @inheritdoc */ + ObjectWriter.prototype.instruction = function (target, data) { + var value = (data === "" ? target : target + " " + data); + if (this._currentList.length === 0) { + this._currentList.push({ "?": value }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isInstructionNode(lastItem)) { + if (util_1.isArray(lastItem["?"])) { + lastItem["?"].push(value); } + else { + lastItem["?"] = [lastItem["?"], value]; + } + } + else { + this._currentList.push({ "?": value }); } } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + }; + /** @inheritdoc */ + ObjectWriter.prototype.cdata = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "$": data }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isCDATANode(lastItem)) { + if (util_1.isArray(lastItem["$"])) { + lastItem["$"].push(data); + } + else { + lastItem["$"] = [lastItem["$"], data]; + } + } + else { + this._currentList.push({ "$": data }); } - finally { if (e_5) throw e_5.error; } } - return defaultNamespaceAttrValue; + }; + ObjectWriter.prototype._isAttrNode = function (x) { + return "@" in x; + }; + ObjectWriter.prototype._isTextNode = function (x) { + return "#" in x; + }; + ObjectWriter.prototype._isCommentNode = function (x) { + return "!" in x; + }; + ObjectWriter.prototype._isInstructionNode = function (x) { + return "?" in x; + }; + ObjectWriter.prototype._isCDATANode = function (x) { + return "$" in x; + }; + ObjectWriter.prototype._isElementNode = function (x, name) { + return name in x; }; /** - * Generates a new prefix for the given namespace. - * - * @param newNamespace - a namespace to generate prefix for - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index + * Returns an object key for an attribute or namespace declaration. */ - XMLBuilderCBImpl.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { - var generatedPrefix = "ns" + prefixIndex.value; - prefixIndex.value++; - prefixMap.set(generatedPrefix, newNamespace); - return generatedPrefix; + ObjectWriter.prototype._getAttrKey = function () { + return this._builderOptions.convert.att; }; /** - * Determines if the namespace prefix map was modified from its original. + * Returns an object key for the given node type. * - * @param originalMap - original namespace prefix map - * @param newMap - new namespace prefix map + * @param nodeType - node type to get a key for */ - XMLBuilderCBImpl.prototype._isPrefixMapModified = function (originalMap, newMap) { - var items1 = originalMap._items; - var items2 = newMap._items; - var nullItems1 = originalMap._nullItems; - var nullItems2 = newMap._nullItems; - for (var key in items2) { - var arr1 = items1[key]; - if (arr1 === undefined) - return true; - var arr2 = items2[key]; - if (arr1.length !== arr2.length) - return true; - for (var i = 0; i < arr1.length; i++) { - if (arr1[i] !== arr2[i]) - return true; - } - } - if (nullItems1.length !== nullItems2.length) - return true; - for (var i = 0; i < nullItems1.length; i++) { - if (nullItems1[i] !== nullItems2[i]) - return true; + ObjectWriter.prototype._getNodeKey = function (nodeType) { + switch (nodeType) { + case interfaces_1.NodeType.Comment: + return this._builderOptions.convert.comment; + case interfaces_1.NodeType.Text: + return this._builderOptions.convert.text; + case interfaces_1.NodeType.ProcessingInstruction: + return this._builderOptions.convert.ins; + case interfaces_1.NodeType.CData: + return this._builderOptions.convert.cdata; + /* istanbul ignore next */ + default: + throw new Error("Invalid node type."); } - return false; }; - XMLBuilderCBImpl._VoidElementNames = new Set(['area', 'base', 'basefont', - 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', - 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); - return XMLBuilderCBImpl; -}(events_1.EventEmitter)); -exports.XMLBuilderCBImpl = XMLBuilderCBImpl; -//# sourceMappingURL=XMLBuilderCBImpl.js.map + return ObjectWriter; +}(BaseWriter_1.BaseWriter)); +exports.ObjectWriter = ObjectWriter; +//# sourceMappingURL=ObjectWriter.js.map /***/ }), -/***/ 8248: +/***/ 7572: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(6417); -var util_1 = __nccwpck_require__(6195); -var writers_1 = __nccwpck_require__(7476); -var interfaces_2 = __nccwpck_require__(7305); -var util_2 = __nccwpck_require__(5282); -var algorithm_1 = __nccwpck_require__(61); -var dom_1 = __nccwpck_require__(770); -var infra_1 = __nccwpck_require__(4251); -var readers_1 = __nccwpck_require__(560); +var BaseCBWriter_1 = __nccwpck_require__(708); /** - * Represents a wrapper that extends XML nodes to implement easy to use and - * chainable document builder methods. + * Serializes XML nodes. */ -var XMLBuilderImpl = /** @class */ (function () { +var XMLCBWriter = /** @class */ (function (_super) { + __extends(XMLCBWriter, _super); /** - * Initializes a new instance of `XMLBuilderNodeImpl`. + * Initializes a new instance of `XMLCBWriter`. * - * @param domNode - the DOM node to wrap + * @param builderOptions - XML builder options */ - function XMLBuilderImpl(domNode) { - this._domNode = domNode; + function XMLCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._lineLength = 0; + return _this; } - Object.defineProperty(XMLBuilderImpl.prototype, "node", { - /** @inheritdoc */ - get: function () { return this._domNode; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(XMLBuilderImpl.prototype, "options", { - /** @inheritdoc */ - get: function () { return this._options; }, - enumerable: true, - configurable: true - }); /** @inheritdoc */ - XMLBuilderImpl.prototype.set = function (options) { - this._options = util_1.applyDefaults(util_1.applyDefaults(this._options, options, true), // apply user settings - interfaces_1.DefaultBuilderOptions); // provide defaults - return this; + XMLCBWriter.prototype.frontMatter = function () { + return ""; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.ele = function (p1, p2, p3) { - var _a, _b, _c; - var namespace; - var name; - var attributes; - if (util_1.isObject(p1)) { - // ele(obj: ExpandObject) - return new readers_1.ObjectReader(this._options).parse(this, p1); - } - else if (p1 !== null && /^\s*"; + return markup; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.docType = function (name, publicId, systemId) { + var markup = this._beginLine(); + if (publicId && systemId) { + markup += ""; } - if ((p1 === null || util_1.isString(p1)) && util_1.isString(p2)) { - // ele(namespace: string, name: string, attributes?: AttributesObject) - _a = __read([p1, p2, p3], 3), namespace = _a[0], name = _a[1], attributes = _a[2]; + else if (publicId) { + markup += ""; } - else if (p1 !== null) { - // ele(name: string, attributes?: AttributesObject) - _b = __read([undefined, p1, util_1.isObject(p2) ? p2 : undefined], 3), namespace = _b[0], name = _b[1], attributes = _b[2]; + else if (systemId) { + markup += ""; } else { - throw new Error("Element name cannot be null. " + this._debugInfo()); + markup += ""; } - if (attributes) { - attributes = util_1.getValue(attributes); + return markup; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.comment = function (data) { + return this._beginLine() + ""; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.text = function (data) { + return this._beginLine() + data; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.instruction = function (target, data) { + if (data) { + return this._beginLine() + ""; } - _c = __read(this._extractNamespace(dom_1.sanitizeInput(namespace, this._options.invalidCharReplacement), dom_1.sanitizeInput(name, this._options.invalidCharReplacement), true), 2), namespace = _c[0], name = _c[1]; - // inherit namespace from parent - if (namespace === undefined) { - var _d = __read(algorithm_1.namespace_extractQName(name), 1), prefix = _d[0]; - namespace = this.node.lookupNamespaceURI(prefix); + else { + return this._beginLine() + ""; } - // create a child element node - var childNode = (namespace !== undefined && namespace !== null ? - this._doc.createElementNS(namespace, name) : - this._doc.createElement(name)); - this.node.appendChild(childNode); - var builder = new XMLBuilderImpl(childNode); - // update doctype node if the new node is the document element node - var oldDocType = this._doc.doctype; - if (childNode === this._doc.documentElement && oldDocType !== null) { - var docType = this._doc.implementation.createDocumentType(this._doc.documentElement.tagName, oldDocType.publicId, oldDocType.systemId); - this._doc.replaceChild(docType, oldDocType); + }; + /** @inheritdoc */ + XMLCBWriter.prototype.cdata = function (data) { + return this._beginLine() + ""; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.openTagBegin = function (name) { + this._lineLength += 1 + name.length; + return this._beginLine() + "<" + name; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (voidElement) { + return " />"; } - // create attributes - if (attributes && !util_1.isEmpty(attributes)) { - builder.att(attributes); + else if (selfClosing) { + if (this._writerOptions.allowEmptyTags) { + return ">"; + } + else if (this._writerOptions.spaceBeforeSlash) { + return " />"; + } + else { + return "/>"; + } + } + else { + return ">"; } - return builder; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.remove = function () { - var parent = this.up(); - parent.node.removeChild(this.node); - return parent; + XMLCBWriter.prototype.closeTag = function (name) { + return this._beginLine() + ""; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.att = function (p1, p2, p3) { - var _a, _b, _c; - var _this = this; - if (util_1.isMap(p1) || util_1.isObject(p1)) { - // att(obj: AttributesObject) - // expand if object - util_1.forEachObject(p1, function (attName, attValue) { return _this.att(attName, attValue); }, this); - return this; - } - // get primitive values - if (p1 !== undefined && p1 !== null) - p1 = util_1.getValue(p1 + ""); - if (p2 !== undefined && p2 !== null) - p2 = util_1.getValue(p2 + ""); - if (p3 !== undefined && p3 !== null) - p3 = util_1.getValue(p3 + ""); - var namespace; - var name; - var value; - if ((p1 === null || util_1.isString(p1)) && util_1.isString(p2) && (p3 === null || util_1.isString(p3))) { - // att(namespace: string, name: string, value: string) - _a = __read([p1, p2, p3], 3), namespace = _a[0], name = _a[1], value = _a[2]; - } - else if (util_1.isString(p1) && (p2 == null || util_1.isString(p2))) { - // ele(name: string, value: string) - _b = __read([undefined, p1, p2], 3), namespace = _b[0], name = _b[1], value = _b[2]; + XMLCBWriter.prototype.attribute = function (name, value) { + var str = name + "=\"" + value + "\""; + if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && + this._lineLength + 1 + str.length > this._writerOptions.width) { + str = this._beginLine() + this._indent(1) + str; + this._lineLength = str.length; + return str; } else { - throw new Error("Attribute name and value not specified. " + this._debugInfo()); - } - if (this._options.keepNullAttributes && (value == null)) { - // keep null attributes - value = ""; - } - else if (value == null) { - // skip null|undefined attributes - return this; - } - if (!util_2.Guard.isElementNode(this.node)) { - throw new Error("An attribute can only be assigned to an element node."); - } - var ele = this.node; - _c = __read(this._extractNamespace(namespace, name, false), 2), namespace = _c[0], name = _c[1]; - name = dom_1.sanitizeInput(name, this._options.invalidCharReplacement); - namespace = dom_1.sanitizeInput(namespace, this._options.invalidCharReplacement); - value = dom_1.sanitizeInput(value, this._options.invalidCharReplacement); - var _d = __read(algorithm_1.namespace_extractQName(name), 2), prefix = _d[0], localName = _d[1]; - var _e = __read(algorithm_1.namespace_extractQName(ele.prefix ? ele.prefix + ':' + ele.localName : ele.localName), 1), elePrefix = _e[0]; - // check if this is a namespace declaration attribute - // assign a new element namespace if it wasn't previously assigned - var eleNamespace = null; - if (prefix === "xmlns") { - namespace = infra_1.namespace.XMLNS; - if (ele.namespaceURI === null && elePrefix === localName) { - eleNamespace = value; - } + this._lineLength += 1 + str.length; + return " " + str; } - else if (prefix === null && localName === "xmlns" && elePrefix === null) { - namespace = infra_1.namespace.XMLNS; - eleNamespace = value; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + XMLCBWriter.prototype.endElement = function (name) { }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + XMLCBWriter.prototype._beginLine = function () { + if (this._writerOptions.prettyPrint) { + var str = (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level); + this._lineLength = str.length; + return str; } - // re-create the element node if its namespace changed - // we can't simply change the namespaceURI since its read-only - if (eleNamespace !== null) { - this._updateNamespace(eleNamespace); - ele = this.node; + else { + return ""; } - if (namespace !== undefined) { - ele.setAttributeNS(namespace, name, value); + }; + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + XMLCBWriter.prototype._indent = function (level) { + if (level <= 0) { + return ""; } else { - ele.setAttribute(name, value); + return this._writerOptions.indent.repeat(level); } - return this; }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.removeAtt = function (p1, p2) { - var _this = this; - if (!util_2.Guard.isElementNode(this.node)) { - throw new Error("An attribute can only be removed from an element node."); + return XMLCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.XMLCBWriter = XMLCBWriter; +//# sourceMappingURL=XMLCBWriter.js.map + +/***/ }), + +/***/ 9606: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var interfaces_1 = __nccwpck_require__(7305); +var BaseWriter_1 = __nccwpck_require__(7644); +var util_2 = __nccwpck_require__(5282); +/** + * Serializes XML nodes into strings. + */ +var XMLWriter = /** @class */ (function (_super) { + __extends(XMLWriter, _super); + /** + * Initializes a new instance of `XMLWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function XMLWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._indentation = {}; + _this._lengthToLastNewline = 0; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + headless: false, + prettyPrint: false, + indent: " ", + newline: "\n", + offset: 0, + width: 0, + allowEmptyTags: false, + indentTextOnlyNodes: false, + spaceBeforeSlash: false + }); + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + */ + XMLWriter.prototype.serialize = function (node) { + this._refs = { suppressPretty: false, emptyNode: false, markup: "" }; + // Serialize XML declaration + if (node.nodeType === interfaces_1.NodeType.Document && !this._writerOptions.headless) { + this.declaration(this._builderOptions.version, this._builderOptions.encoding, this._builderOptions.standalone); } - // get primitive values - p1 = util_1.getValue(p1); - if (p2 !== undefined) { - p2 = util_1.getValue(p2); + // recursively serialize node + this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); + // remove trailing newline + if (this._writerOptions.prettyPrint && + this._refs.markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { + this._refs.markup = this._refs.markup.slice(0, -this._writerOptions.newline.length); } - var namespace; - var name; - if (p1 !== null && p2 === undefined) { - name = p1; + return this._refs.markup; + }; + /** @inheritdoc */ + XMLWriter.prototype.declaration = function (version, encoding, standalone) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); + }; + /** @inheritdoc */ + XMLWriter.prototype.docType = function (name, publicId, systemId) { + this._beginLine(); + if (publicId && systemId) { + this._refs.markup += ""; } - if (util_1.isArray(name) || util_1.isSet(name)) { - // removeAtt(names: string[]) - // removeAtt(namespace: string, names: string[]) - util_1.forEachArray(name, function (attName) { - return namespace === undefined ? _this.removeAtt(attName) : _this.removeAtt(namespace, attName); - }, this); + else if (publicId) { + this._refs.markup += ""; } - else if (namespace !== undefined) { - // removeAtt(namespace: string, name: string) - name = dom_1.sanitizeInput(name, this._options.invalidCharReplacement); - namespace = dom_1.sanitizeInput(namespace, this._options.invalidCharReplacement); - this.node.removeAttributeNS(namespace, name); + else if (systemId) { + this._refs.markup += ""; } else { - // removeAtt(name: string) - name = dom_1.sanitizeInput(name, this._options.invalidCharReplacement); - this.node.removeAttribute(name); + this._refs.markup += ""; } - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.txt = function (content) { - var child = this._doc.createTextNode(dom_1.sanitizeInput(content, this._options.invalidCharReplacement)); - this.node.appendChild(child); - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.com = function (content) { - var child = this._doc.createComment(dom_1.sanitizeInput(content, this._options.invalidCharReplacement)); - this.node.appendChild(child); - return this; + this._endLine(); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.dat = function (content) { - var child = this._doc.createCDATASection(dom_1.sanitizeInput(content, this._options.invalidCharReplacement)); - this.node.appendChild(child); - return this; + XMLWriter.prototype.openTagBegin = function (name) { + this._beginLine(); + this._refs.markup += "<" + name; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.ins = function (target, content) { - var _this = this; - if (content === void 0) { content = ''; } - if (util_1.isArray(target) || util_1.isSet(target)) { - util_1.forEachArray(target, function (item) { - item += ""; - var insIndex = item.indexOf(' '); - var insTarget = (insIndex === -1 ? item : item.substr(0, insIndex)); - var insValue = (insIndex === -1 ? '' : item.substr(insIndex + 1)); - _this.ins(insTarget, insValue); - }, this); - } - else if (util_1.isMap(target) || util_1.isObject(target)) { - util_1.forEachObject(target, function (insTarget, insValue) { return _this.ins(insTarget, insValue); }, this); - } - else { - var child = this._doc.createProcessingInstruction(dom_1.sanitizeInput(target, this._options.invalidCharReplacement), dom_1.sanitizeInput(content, this._options.invalidCharReplacement)); - this.node.appendChild(child); - } - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.dec = function (options) { - this._options.version = options.version || "1.0"; - this._options.encoding = options.encoding; - this._options.standalone = options.standalone; - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.dtd = function (options) { - var name = dom_1.sanitizeInput((options && options.name) || (this._doc.documentElement ? this._doc.documentElement.tagName : "ROOT"), this._options.invalidCharReplacement); - var pubID = dom_1.sanitizeInput((options && options.pubID) || "", this._options.invalidCharReplacement); - var sysID = dom_1.sanitizeInput((options && options.sysID) || "", this._options.invalidCharReplacement); - // name must match document element - if (this._doc.documentElement !== null && name !== this._doc.documentElement.tagName) { - throw new Error("DocType name does not match document element name."); + XMLWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + // do not indent text only elements or elements with empty text nodes + this._refs.suppressPretty = false; + this._refs.emptyNode = false; + if (this._writerOptions.prettyPrint && !selfClosing && !voidElement) { + var textOnlyNode = true; + var emptyNode = true; + var childNode = this.currentNode.firstChild; + var cdataCount = 0; + var textCount = 0; + while (childNode) { + if (util_2.Guard.isExclusiveTextNode(childNode)) { + textCount++; + } + else if (util_2.Guard.isCDATASectionNode(childNode)) { + cdataCount++; + } + else { + textOnlyNode = false; + emptyNode = false; + break; + } + if (childNode.data !== '') { + emptyNode = false; + } + childNode = childNode.nextSibling; + } + this._refs.suppressPretty = !this._writerOptions.indentTextOnlyNodes && textOnlyNode && ((cdataCount <= 1 && textCount === 0) || cdataCount === 0); + this._refs.emptyNode = emptyNode; } - // create doctype node - var docType = this._doc.implementation.createDocumentType(name, pubID, sysID); - if (this._doc.doctype !== null) { - // replace existing doctype - this._doc.replaceChild(docType, this._doc.doctype); + if ((voidElement || selfClosing || this._refs.emptyNode) && this._writerOptions.allowEmptyTags) { + this._refs.markup += ">"; } else { - // insert before document element node or append to end - this._doc.insertBefore(docType, this._doc.documentElement); + this._refs.markup += voidElement ? " />" : + (selfClosing || this._refs.emptyNode) ? (this._writerOptions.spaceBeforeSlash ? " />" : "/>") : ">"; } - return this; + this._endLine(); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.import = function (node) { - var e_1, _a; - var hostNode = this._domNode; - var hostDoc = this._doc; - var importedNode = node.node; - if (util_2.Guard.isDocumentNode(importedNode)) { - // import document node - var elementNode = importedNode.documentElement; - if (elementNode === null) { - throw new Error("Imported document has no document element node. " + this._debugInfo()); - } - var clone = hostDoc.importNode(elementNode, true); - hostNode.appendChild(clone); - var _b = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _b[0]; - var namespace = hostNode.lookupNamespaceURI(prefix); - new XMLBuilderImpl(clone)._updateNamespace(namespace); - } - else if (util_2.Guard.isDocumentFragmentNode(importedNode)) { - try { - // import child nodes - for (var _c = __values(importedNode.childNodes), _d = _c.next(); !_d.done; _d = _c.next()) { - var childNode = _d.value; - var clone = hostDoc.importNode(childNode, true); - hostNode.appendChild(clone); - if (util_2.Guard.isElementNode(clone)) { - var _e = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _e[0]; - var namespace = hostNode.lookupNamespaceURI(prefix); - new XMLBuilderImpl(clone)._updateNamespace(namespace); - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); - } - finally { if (e_1) throw e_1.error; } - } - } - else { - // import node - var clone = hostDoc.importNode(importedNode, true); - hostNode.appendChild(clone); - if (util_2.Guard.isElementNode(clone)) { - var _f = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _f[0]; - var namespace = hostNode.lookupNamespaceURI(prefix); - new XMLBuilderImpl(clone)._updateNamespace(namespace); - } + XMLWriter.prototype.closeTag = function (name) { + if (!this._refs.emptyNode) { + this._beginLine(); + this._refs.markup += ""; } - return this; + this._refs.suppressPretty = false; + this._refs.emptyNode = false; + this._endLine(); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.doc = function () { - if (this._doc._isFragment) { - var node = this.node; - while (node && node.nodeType !== interfaces_2.NodeType.DocumentFragment) { - node = node.parentNode; - } - /* istanbul ignore next */ - if (node === null) { - throw new Error("Node has no parent node while searching for document fragment ancestor. " + this._debugInfo()); - } - return new XMLBuilderImpl(node); + XMLWriter.prototype.attribute = function (name, value) { + var str = name + "=\"" + value + "\""; + if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && + this._refs.markup.length - this._lengthToLastNewline + 1 + str.length > this._writerOptions.width) { + this._endLine(); + this._beginLine(); + this._refs.markup += this._indent(1) + str; } else { - return new XMLBuilderImpl(this._doc); + this._refs.markup += " " + str; } }; /** @inheritdoc */ - XMLBuilderImpl.prototype.root = function () { - var ele = this._doc.documentElement; - if (!ele) { - throw new Error("Document root element is null. " + this._debugInfo()); + XMLWriter.prototype.text = function (data) { + if (data !== '') { + this._beginLine(); + this._refs.markup += data; + this._endLine(); } - return new XMLBuilderImpl(ele); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.up = function () { - var parent = this._domNode.parentNode; - if (!parent) { - throw new Error("Parent node is null. " + this._debugInfo()); + XMLWriter.prototype.cdata = function (data) { + if (data !== '') { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); } - return new XMLBuilderImpl(parent); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.prev = function () { - var node = this._domNode.previousSibling; - if (!node) { - throw new Error("Previous sibling node is null. " + this._debugInfo()); - } - return new XMLBuilderImpl(node); + XMLWriter.prototype.comment = function (data) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.next = function () { - var node = this._domNode.nextSibling; - if (!node) { - throw new Error("Next sibling node is null. " + this._debugInfo()); - } - return new XMLBuilderImpl(node); + XMLWriter.prototype.instruction = function (target, data) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.first = function () { - var node = this._domNode.firstChild; - if (!node) { - throw new Error("First child node is null. " + this._debugInfo()); + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + XMLWriter.prototype._beginLine = function () { + if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) { + this._refs.markup += this._indent(this._writerOptions.offset + this.level); } - return new XMLBuilderImpl(node); }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.last = function () { - var node = this._domNode.lastChild; - if (!node) { - throw new Error("Last child node is null. " + this._debugInfo()); + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + */ + XMLWriter.prototype._endLine = function () { + if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) { + this._refs.markup += this._writerOptions.newline; + this._lengthToLastNewline = this._refs.markup.length; } - return new XMLBuilderImpl(node); }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.each = function (callback, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = this._getFirstDescendantNode(this._domNode, self, recursive); - while (result[0]) { - var nextResult = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); - callback.call(thisArg, new XMLBuilderImpl(result[0]), result[1], result[2]); - result = nextResult; + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + XMLWriter.prototype._indent = function (level) { + if (level <= 0) { + return ""; + } + else if (this._indentation[level] !== undefined) { + return this._indentation[level]; + } + else { + var str = this._writerOptions.indent.repeat(level); + this._indentation[level] = str; + return str; } - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.map = function (callback, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = []; - this.each(function (node, index, level) { - return result.push(callback.call(thisArg, node, index, level)); - }, self, recursive); - return result; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.reduce = function (callback, initialValue, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var value = initialValue; - this.each(function (node, index, level) { - return value = callback.call(thisArg, value, node, index, level); - }, self, recursive); - return value; }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.find = function (predicate, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = this._getFirstDescendantNode(this._domNode, self, recursive); - while (result[0]) { - var builder = new XMLBuilderImpl(result[0]); - if (predicate.call(thisArg, builder, result[1], result[2])) { - return builder; - } - result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + return XMLWriter; +}(BaseWriter_1.BaseWriter)); +exports.XMLWriter = XMLWriter; +//# sourceMappingURL=XMLWriter.js.map + +/***/ }), + +/***/ 2444: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var BaseCBWriter_1 = __nccwpck_require__(708); +/** + * Serializes XML nodes. + */ +var YAMLCBWriter = /** @class */ (function (_super) { + __extends(YAMLCBWriter, _super); + /** + * Initializes a new instance of `BaseCBWriter`. + * + * @param builderOptions - XML builder options + */ + function YAMLCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._rootWritten = false; + _this._additionalLevel = 0; + if (builderOptions.indent.length < 2) { + throw new Error("YAML indententation string must be at least two characters long."); } - return undefined; + if (builderOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); + } + return _this; + } + /** @inheritdoc */ + YAMLCBWriter.prototype.frontMatter = function () { + return this._beginLine() + "---"; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.filter = function (predicate, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = []; - this.each(function (node, index, level) { - if (predicate.call(thisArg, node, index, level)) { - result.push(node); - } - }, self, recursive); - return result; + YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { + return ""; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.every = function (predicate, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = this._getFirstDescendantNode(this._domNode, self, recursive); - while (result[0]) { - var builder = new XMLBuilderImpl(result[0]); - if (!predicate.call(thisArg, builder, result[1], result[2])) { - return false; - } - result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); - } - return true; + YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { + return ""; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.some = function (predicate, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = this._getFirstDescendantNode(this._domNode, self, recursive); - while (result[0]) { - var builder = new XMLBuilderImpl(result[0]); - if (predicate.call(thisArg, builder, result[1], result[2])) { - return true; - } - result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); - } - return false; + YAMLCBWriter.prototype.comment = function (data) { + // "!": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.comment) + " " + + this._val(data); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.toArray = function (self, recursive) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = []; - this.each(function (node) { return result.push(node); }, self, recursive); - return result; + YAMLCBWriter.prototype.text = function (data) { + // "#": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.text) + " " + + this._val(data); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.toString = function (writerOptions) { - writerOptions = writerOptions || {}; - if (writerOptions.format === undefined) { - writerOptions.format = "xml"; - } - return this._serialize(writerOptions); + YAMLCBWriter.prototype.instruction = function (target, data) { + // "?": "target hello" + return this._beginLine() + + this._key(this._builderOptions.convert.ins) + " " + + this._val(data ? target + " " + data : target); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.toObject = function (writerOptions) { - writerOptions = writerOptions || {}; - if (writerOptions.format === undefined) { - writerOptions.format = "object"; + YAMLCBWriter.prototype.cdata = function (data) { + // "$": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.cdata) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.attribute = function (name, value) { + // "@name": "val" + this._additionalLevel++; + var str = this._beginLine() + + this._key(this._builderOptions.convert.att + name) + " " + + this._val(value); + this._additionalLevel--; + return str; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.openTagBegin = function (name) { + // "node": + // "#": + // - + var str = this._beginLine() + this._key(name); + if (!this._rootWritten) { + this._rootWritten = true; } - return this._serialize(writerOptions); + this.hasData = true; + this._additionalLevel++; + str += this._beginLine(true) + this._key(this._builderOptions.convert.text); + return str; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.end = function (writerOptions) { - writerOptions = writerOptions || {}; - if (writerOptions.format === undefined) { - writerOptions.format = "xml"; + YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (selfClosing) { + return " " + this._val(""); } - return this.doc()._serialize(writerOptions); + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.closeTag = function (name) { + this._additionalLevel--; + return ""; }; + /** @inheritdoc */ + YAMLCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + YAMLCBWriter.prototype.endElement = function (name) { }; /** - * Gets the next descendant of the given node of the tree rooted at `root` - * in depth-first pre-order. Returns a three-tuple with - * [descendant, descendant_index, descendant_level]. - * - * @param root - root node of the tree - * @param self - whether to visit the current node along with child nodes - * @param recursive - whether to visit all descendant nodes in tree-order or - * only the immediate child nodes + * Produces characters to be prepended to a line of string in pretty-print + * mode. */ - XMLBuilderImpl.prototype._getFirstDescendantNode = function (root, self, recursive) { - if (self) - return [this._domNode, 0, 0]; - else if (recursive) - return this._getNextDescendantNode(root, root, recursive, 0, 0); - else - return [this._domNode.firstChild, 0, 1]; + YAMLCBWriter.prototype._beginLine = function (suppressArray) { + if (suppressArray === void 0) { suppressArray = false; } + return (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level, suppressArray); }; /** - * Gets the next descendant of the given node of the tree rooted at `root` - * in depth-first pre-order. Returns a three-tuple with - * [descendant, descendant_index, descendant_level]. + * Produces an indentation string. * - * @param root - root node of the tree - * @param node - current node - * @param recursive - whether to visit all descendant nodes in tree-order or - * only the immediate child nodes - * @param index - child node index - * @param level - current depth of the XML tree + * @param level - depth of the tree + * @param suppressArray - whether the suppress array marker */ - XMLBuilderImpl.prototype._getNextDescendantNode = function (root, node, recursive, index, level) { - if (recursive) { - // traverse child nodes - if (node.firstChild) - return [node.firstChild, 0, level + 1]; - if (node === root) - return [null, -1, -1]; - // traverse siblings - if (node.nextSibling) - return [node.nextSibling, index + 1, level]; - // traverse parent's next sibling - var parent = node.parentNode; - while (parent && parent !== root) { - if (parent.nextSibling) - return [parent.nextSibling, algorithm_1.tree_index(parent.nextSibling), level - 1]; - parent = parent.parentNode; - level--; - } + YAMLCBWriter.prototype._indent = function (level, suppressArray) { + if (level + this._additionalLevel <= 0) { + return ""; } else { - if (root === node) - return [node.firstChild, 0, level + 1]; - else - return [node.nextSibling, index + 1, level]; + var chars = this._writerOptions.indent.repeat(level + this._additionalLevel); + if (!suppressArray && this._rootWritten) { + return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); + } + return chars; } - return [null, -1, -1]; }; /** - * Converts the node into its string or object representation. - * - * @param options - serialization options + * Produces a YAML key string delimited with double quotes. */ - XMLBuilderImpl.prototype._serialize = function (writerOptions) { - if (writerOptions.format === "xml") { - var writer = new writers_1.XMLWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else if (writerOptions.format === "map") { - var writer = new writers_1.MapWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else if (writerOptions.format === "object") { - var writer = new writers_1.ObjectWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else if (writerOptions.format === "json") { - var writer = new writers_1.JSONWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else if (writerOptions.format === "yaml") { - var writer = new writers_1.YAMLWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else { - throw new Error("Invalid writer format: " + writerOptions.format + ". " + this._debugInfo()); + YAMLCBWriter.prototype._key = function (key) { + return "\"" + key + "\":"; + }; + /** + * Produces a YAML value string delimited with double quotes. + */ + YAMLCBWriter.prototype._val = function (val) { + return JSON.stringify(val); + }; + return YAMLCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.YAMLCBWriter = YAMLCBWriter; +//# sourceMappingURL=YAMLCBWriter.js.map + +/***/ }), + +/***/ 6517: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectWriter_1 = __nccwpck_require__(243); +var util_1 = __nccwpck_require__(6195); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into a YAML string. + */ +var YAMLWriter = /** @class */ (function (_super) { + __extends(YAMLWriter, _super); /** - * Extracts a namespace and name from the given string. + * Initializes a new instance of `YAMLWriter`. * - * @param namespace - namespace - * @param name - a string containing both a name and namespace separated by an - * `'@'` character - * @param ele - `true` if this is an element namespace; otherwise `false` + * @param builderOptions - XML builder options + * @param writerOptions - serialization options */ - XMLBuilderImpl.prototype._extractNamespace = function (namespace, name, ele) { - // extract from name - var atIndex = name.indexOf("@"); - if (atIndex > 0) { - if (namespace === undefined) - namespace = name.slice(atIndex + 1); - name = name.slice(0, atIndex); + function YAMLWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + indent: ' ', + newline: '\n', + offset: 0, + group: false, + verbose: false + }); + if (_this._writerOptions.indent.length < 2) { + throw new Error("YAML indententation string must be at least two characters long."); } - if (namespace === undefined) { - // look-up default namespace - namespace = (ele ? this._options.defaultNamespace.ele : this._options.defaultNamespace.att); + if (_this._writerOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); } - else if (namespace !== null && namespace[0] === "@") { - // look-up namespace aliases - var alias = namespace.slice(1); - namespace = this._options.namespaceAlias[alias]; - if (namespace === undefined) { - throw new Error("Namespace alias `" + alias + "` is not defined. " + this._debugInfo()); - } + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + * @param writerOptions - serialization options + */ + YAMLWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + var markup = this._beginLine(this._writerOptions, 0) + '---' + this._endLine(this._writerOptions) + + this._convertObject(val, this._writerOptions, 0); + // remove trailing newline + /* istanbul ignore else */ + if (markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { + markup = markup.slice(0, -this._writerOptions.newline.length); } - return [namespace, name]; + return markup; }; /** - * Updates the element's namespace. + * Produces an XML serialization of the given object. * - * @param ns - new namespace + * @param obj - object to serialize + * @param options - serialization options + * @param level - depth of the XML tree + * @param indentLeaf - indents leaf nodes */ - XMLBuilderImpl.prototype._updateNamespace = function (ns) { - var e_2, _a, e_3, _b; - var ele = this._domNode; - if (util_2.Guard.isElementNode(ele) && ns !== null && ele.namespaceURI !== ns) { - var _c = __read(algorithm_1.namespace_extractQName(ele.prefix ? ele.prefix + ':' + ele.localName : ele.localName), 2), elePrefix = _c[0], eleLocalName = _c[1]; - // re-create the element node if its namespace changed - // we can't simply change the namespaceURI since its read-only - var newEle = algorithm_1.create_element(this._doc, eleLocalName, ns, elePrefix); + YAMLWriter.prototype._convertObject = function (obj, options, level, suppressIndent) { + var e_1, _a; + var _this = this; + if (suppressIndent === void 0) { suppressIndent = false; } + var markup = ''; + if (util_1.isArray(obj)) { try { - for (var _d = __values(ele.attributes), _e = _d.next(); !_e.done; _e = _d.next()) { - var attr = _e.value; - var attrQName = attr.prefix ? attr.prefix + ':' + attr.localName : attr.localName; - var _f = __read(algorithm_1.namespace_extractQName(attrQName), 1), attrPrefix = _f[0]; - var newAttrNS = attr.namespaceURI; - if (newAttrNS === null && attrPrefix !== null) { - newAttrNS = ele.lookupNamespaceURI(attrPrefix); + for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { + var val = obj_1_1.value; + markup += this._beginLine(options, level, true); + if (!util_1.isObject(val)) { + markup += this._val(val) + this._endLine(options); } - if (newAttrNS === null) { - newEle.setAttribute(attrQName, attr.value); + else if (util_1.isEmpty(val)) { + markup += '""' + this._endLine(options); } else { - newEle.setAttributeNS(newAttrNS, attrQName, attr.value); + markup += this._convertObject(val, options, level, true); } } } - catch (e_2_1) { e_2 = { error: e_2_1 }; } + catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_e && !_e.done && (_a = _d.return)) _a.call(_d); + if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); } - finally { if (e_2) throw e_2.error; } - } - // replace the new node in parent node - var parent = ele.parentNode; - /* istanbul ignore next */ - if (parent === null) { - throw new Error("Parent node is null." + this._debugInfo()); + finally { if (e_1) throw e_1.error; } } - parent.replaceChild(newEle, ele); - this._domNode = newEle; - try { - // check child nodes - for (var _g = __values(ele.childNodes), _h = _g.next(); !_h.done; _h = _g.next()) { - var childNode = _h.value; - var newChildNode = childNode.cloneNode(true); - newEle.appendChild(newChildNode); - if (util_2.Guard.isElementNode(newChildNode)) { - var _j = __read(algorithm_1.namespace_extractQName(newChildNode.prefix ? newChildNode.prefix + ':' + newChildNode.localName : newChildNode.localName), 1), newChildNodePrefix = _j[0]; - var newChildNodeNS = newEle.lookupNamespaceURI(newChildNodePrefix); - new XMLBuilderImpl(newChildNode)._updateNamespace(newChildNodeNS); - } + } + else /* if (isObject(obj)) */ { + util_1.forEachObject(obj, function (key, val) { + if (suppressIndent) { + markup += _this._key(key); + suppressIndent = false; } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_h && !_h.done && (_b = _g.return)) _b.call(_g); + else { + markup += _this._beginLine(options, level) + _this._key(key); } - finally { if (e_3) throw e_3.error; } - } + if (!util_1.isObject(val)) { + markup += ' ' + _this._val(val) + _this._endLine(options); + } + else if (util_1.isEmpty(val)) { + markup += ' ""' + _this._endLine(options); + } + else { + markup += _this._endLine(options) + + _this._convertObject(val, options, level + 1); + } + }, this); } + return markup; }; - Object.defineProperty(XMLBuilderImpl.prototype, "_doc", { - /** - * Returns the document owning this node. - */ - get: function () { - var node = this.node; - if (util_2.Guard.isDocumentNode(node)) { - return node; - } - else { - var docNode = node.ownerDocument; - /* istanbul ignore next */ - if (!docNode) - throw new Error("Owner document is null. " + this._debugInfo()); - return docNode; - } - }, - enumerable: true, - configurable: true - }); /** - * Returns debug information for this node. + * Produces characters to be prepended to a line of string in pretty-print + * mode. * - * @param name - node name + * @param options - serialization options + * @param level - current depth of the XML tree + * @param isArray - whether this line is an array item */ - XMLBuilderImpl.prototype._debugInfo = function (name) { - var node = this.node; - var parentNode = node.parentNode; - name = name || node.nodeName; - var parentName = parentNode ? parentNode.nodeName : ''; - if (!parentName) { - return "node: <" + name + ">"; + YAMLWriter.prototype._beginLine = function (options, level, isArray) { + if (isArray === void 0) { isArray = false; } + var indentLevel = options.offset + level + 1; + var chars = new Array(indentLevel).join(options.indent); + if (isArray) { + return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); } else { - return "node: <" + name + ">, parent: <" + parentName + ">"; + return chars; } }; - Object.defineProperty(XMLBuilderImpl.prototype, "_options", { - /** - * Gets or sets builder options. - */ - get: function () { - var doc = this._doc; - /* istanbul ignore next */ - if (doc._xmlBuilderOptions === undefined) { - throw new Error("Builder options is not set."); - } - return doc._xmlBuilderOptions; - }, - set: function (value) { - var doc = this._doc; - doc._xmlBuilderOptions = value; - }, - enumerable: true, - configurable: true - }); - return XMLBuilderImpl; -}()); -exports.XMLBuilderImpl = XMLBuilderImpl; -//# sourceMappingURL=XMLBuilderImpl.js.map + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + */ + YAMLWriter.prototype._endLine = function (options) { + return options.newline; + }; + /** + * Produces a YAML key string delimited with double quotes. + */ + YAMLWriter.prototype._key = function (key) { + return "\"" + key + "\":"; + }; + /** + * Produces a YAML value string delimited with double quotes. + */ + YAMLWriter.prototype._val = function (val) { + return JSON.stringify(val); + }; + return YAMLWriter; +}(BaseWriter_1.BaseWriter)); +exports.YAMLWriter = YAMLWriter; +//# sourceMappingURL=YAMLWriter.js.map /***/ }), -/***/ 770: +/***/ 7476: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -var dom_1 = __nccwpck_require__(4646); -var dom_2 = __nccwpck_require__(633); -var util_1 = __nccwpck_require__(6195); -dom_2.dom.setFeatures(false); -/** - * Creates an XML document without any child nodes. - */ -function createDocument() { - var impl = new dom_1.DOMImplementation(); - var doc = impl.createDocument(null, 'root', null); - /* istanbul ignore else */ - if (doc.documentElement) { - doc.removeChild(doc.documentElement); - } - return doc; -} -exports.createDocument = createDocument; -/** - * Sanitizes input strings with user supplied replacement characters. - * - * @param str - input string - * @param replacement - replacement character or function - */ -function sanitizeInput(str, replacement) { - if (str == null) { - return str; - } - else if (replacement === undefined) { - return str + ""; - } - else { - var result = ""; - str = str + ""; - for (var i = 0; i < str.length; i++) { - var n = str.charCodeAt(i); - // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] - if (n === 0x9 || n === 0xA || n === 0xD || - (n >= 0x20 && n <= 0xD7FF) || - (n >= 0xE000 && n <= 0xFFFD)) { - // valid character - not surrogate pair - result += str.charAt(i); - } - else if (n >= 0xD800 && n <= 0xDBFF && i < str.length - 1) { - var n2 = str.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - // valid surrogate pair - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - result += String.fromCodePoint(n); - i++; - } - else { - // invalid lone surrogate - result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); - } - } - else { - // invalid character - result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); - } - } - return result; - } -} -exports.sanitizeInput = sanitizeInput; -//# sourceMappingURL=dom.js.map +var MapWriter_1 = __nccwpck_require__(1397); +exports.MapWriter = MapWriter_1.MapWriter; +var XMLWriter_1 = __nccwpck_require__(9606); +exports.XMLWriter = XMLWriter_1.XMLWriter; +var ObjectWriter_1 = __nccwpck_require__(243); +exports.ObjectWriter = ObjectWriter_1.ObjectWriter; +var JSONWriter_1 = __nccwpck_require__(7510); +exports.JSONWriter = JSONWriter_1.JSONWriter; +var YAMLWriter_1 = __nccwpck_require__(6517); +exports.YAMLWriter = YAMLWriter_1.YAMLWriter; +//# sourceMappingURL=index.js.map /***/ }), -/***/ 4260: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 2839: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + module.exports = { + Disconnected: 1, + Preceding: 2, + Following: 4, + Contains: 8, + ContainedBy: 16, + ImplementationSpecific: 32 + }; + +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var XMLBuilderImpl_1 = __nccwpck_require__(8248); -exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; -var XMLBuilderCBImpl_1 = __nccwpck_require__(1438); -exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; -var BuilderFunctions_1 = __nccwpck_require__(5696); -exports.builder = BuilderFunctions_1.builder; -exports.create = BuilderFunctions_1.create; -exports.fragment = BuilderFunctions_1.fragment; -exports.convert = BuilderFunctions_1.convert; -var BuilderFunctionsCB_1 = __nccwpck_require__(268); -exports.createCB = BuilderFunctionsCB_1.createCB; -exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; -//# sourceMappingURL=index.js.map /***/ }), -/***/ 151: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 9267: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + module.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(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var builder_1 = __nccwpck_require__(4260); -exports.builder = builder_1.builder; -exports.create = builder_1.create; -exports.fragment = builder_1.fragment; -exports.convert = builder_1.convert; -exports.createCB = builder_1.createCB; -exports.fragmentCB = builder_1.fragmentCB; -//# sourceMappingURL=index.js.map /***/ }), -/***/ 6417: -/***/ ((__unused_webpack_module, exports) => { +/***/ 8229: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject, + slice = [].slice, + hasProp = {}.hasOwnProperty; -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Defines default values for builder options. - */ -exports.DefaultBuilderOptions = { - version: "1.0", - encoding: undefined, - standalone: undefined, - keepNullNodes: false, - keepNullAttributes: false, - ignoreConverters: false, - convert: { - att: "@", - ins: "?", - text: "#", - cdata: "$", - comment: "!" - }, - defaultNamespace: { - ele: undefined, - att: undefined - }, - namespaceAlias: { - html: "http://www.w3.org/1999/xhtml", - xml: "http://www.w3.org/XML/1998/namespace", - xmlns: "http://www.w3.org/2000/xmlns/", - mathml: "http://www.w3.org/1998/Math/MathML", - svg: "http://www.w3.org/2000/svg", - xlink: "http://www.w3.org/1999/xlink" - }, - invalidCharReplacement: undefined, - parser: undefined -}; -/** - * Contains keys of `XMLBuilderOptions`. - */ -exports.XMLBuilderOptionKeys = new Set(Object.keys(exports.DefaultBuilderOptions)); -/** - * Defines default values for builder options. - */ -exports.DefaultXMLBuilderCBOptions = { - format: "xml", - wellFormed: false, - prettyPrint: false, - indent: " ", - newline: "\n", - offset: 0, - width: 0, - allowEmptyTags: false, - spaceBeforeSlash: false, - keepNullNodes: false, - keepNullAttributes: false, - ignoreConverters: false, - convert: { - att: "@", - ins: "?", - text: "#", - cdata: "$", - comment: "!" - }, - defaultNamespace: { - ele: undefined, - att: undefined - }, - namespaceAlias: { - html: "http://www.w3.org/1999/xhtml", - xml: "http://www.w3.org/XML/1998/namespace", - xmlns: "http://www.w3.org/2000/xmlns/", - mathml: "http://www.w3.org/1998/Math/MathML", - svg: "http://www.w3.org/2000/svg", - xlink: "http://www.w3.org/1999/xlink" + 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]; + } + } + } } -}; -//# sourceMappingURL=interfaces.js.map - -/***/ }), + return target; + }; -/***/ 3396: -/***/ ((__unused_webpack_module, exports) => { + isFunction = function(val) { + return !!val && Object.prototype.toString.call(val) === '[object Function]'; + }; -"use strict"; + isObject = function(val) { + var ref; + return !!val && ((ref = typeof val) === 'function' || ref === 'object'); + }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Pre-serializes XML nodes. - */ -var BaseReader = /** @class */ (function () { - /** - * Initializes a new instance of `BaseReader`. - * - * @param builderOptions - XML builder options - */ - function BaseReader(builderOptions) { - this._builderOptions = builderOptions; - if (builderOptions.parser) { - Object.assign(this, builderOptions.parser); - } + isArray = function(val) { + if (isFunction(Array.isArray)) { + return Array.isArray(val); + } else { + return Object.prototype.toString.call(val) === '[object Array]'; } - BaseReader.prototype._docType = function (parent, name, publicId, systemId) { - return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); - }; - BaseReader.prototype._comment = function (parent, data) { - return parent.com(data); - }; - BaseReader.prototype._text = function (parent, data) { - return parent.txt(data); - }; - BaseReader.prototype._instruction = function (parent, target, data) { - return parent.ins(target, data); - }; - BaseReader.prototype._cdata = function (parent, data) { - return parent.dat(data); - }; - BaseReader.prototype._element = function (parent, namespace, name) { - return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); - }; - BaseReader.prototype._attribute = function (parent, namespace, name, value) { - return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); - }; - /** - * Main parser function which parses the given object and returns an XMLBuilder. - * - * @param node - node to recieve parsed content - * @param obj - object to parse - */ - BaseReader.prototype.parse = function (node, obj) { - return this._parse(node, obj); - }; - /** - * Creates a DocType node. - * The node will be skipped if the function returns `undefined`. - * - * @param name - node name - * @param publicId - public identifier - * @param systemId - system identifier - */ - BaseReader.prototype.docType = function (parent, name, publicId, systemId) { - return this._docType(parent, name, publicId, systemId); - }; - /** - * Creates a comment node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.comment = function (parent, data) { - return this._comment(parent, data); - }; - /** - * Creates a text node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.text = function (parent, data) { - return this._text(parent, data); - }; - /** - * Creates a processing instruction node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param target - instruction target - * @param data - node data - */ - BaseReader.prototype.instruction = function (parent, target, data) { - return this._instruction(parent, target, data); - }; - /** - * Creates a CData section node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.cdata = function (parent, data) { - return this._cdata(parent, data); - }; - /** - * Creates an element node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param namespace - node namespace - * @param name - node name - */ - BaseReader.prototype.element = function (parent, namespace, name) { - return this._element(parent, namespace, name); - }; - /** - * Creates an attribute or namespace declaration. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param namespace - node namespace - * @param name - node name - * @param value - node value - */ - BaseReader.prototype.attribute = function (parent, namespace, name, value) { - return this._attribute(parent, namespace, name, value); - }; - return BaseReader; -}()); -exports.BaseReader = BaseReader; -//# sourceMappingURL=BaseReader.js.map - -/***/ }), + }; -/***/ 3518: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + 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; + } + }; -"use strict"; + 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)); + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectReader_1 = __nccwpck_require__(768); -var BaseReader_1 = __nccwpck_require__(3396); -/** - * Parses XML nodes from a JSON string. - */ -var JSONReader = /** @class */ (function (_super) { - __extends(JSONReader, _super); - function JSONReader() { - return _super !== null && _super.apply(this, arguments) || this; + getValue = function(obj) { + if (isFunction(obj.valueOf)) { + return obj.valueOf(); + } else { + return obj; } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - JSON string to parse - */ - JSONReader.prototype._parse = function (node, str) { - return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, JSON.parse(str)); - }; - return JSONReader; -}(BaseReader_1.BaseReader)); -exports.JSONReader = JSONReader; -//# sourceMappingURL=JSONReader.js.map + }; -/***/ }), + module.exports.assign = assign; -/***/ 768: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + module.exports.isFunction = isFunction; -"use strict"; + module.exports.isObject = isObject; + + module.exports.isArray = isArray; + + module.exports.isEmpty = isEmpty; + + module.exports.isPlainObject = isPlainObject; + + module.exports.getValue = getValue; + +}).call(this); -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var BaseReader_1 = __nccwpck_require__(3396); -var dom_1 = __nccwpck_require__(770); -/** - * Parses XML nodes from objects and arrays. - * ES6 maps and sets are also supoorted. - */ -var ObjectReader = /** @class */ (function (_super) { - __extends(ObjectReader, _super); - function ObjectReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param obj - object to parse - */ - ObjectReader.prototype._parse = function (node, obj) { - var _this = this; - var options = this._builderOptions; - // sanitizes input characters - var invalidCharReplacement = options.invalidCharReplacement; - var s = function (str) { - return dom_1.sanitizeInput(str, invalidCharReplacement); - }; - var lastChild = null; - if (util_1.isFunction(obj)) { - // evaluate if function - lastChild = this.parse(node, obj.apply(this)); - } - else if (util_1.isArray(obj) || util_1.isSet(obj)) { - util_1.forEachArray(obj, function (item) { return lastChild = _this.parse(node, item); }, this); - } - else /* if (isMap(obj) || isObject(obj)) */ { - // expand if object - util_1.forEachObject(obj, function (key, val) { - if (util_1.isFunction(val)) { - // evaluate if function - val = val.apply(_this); - } - if (!options.ignoreConverters && key.indexOf(options.convert.att) === 0) { - // assign attributes - if (key === options.convert.att) { - if (util_1.isArray(val) || util_1.isSet(val)) { - throw new Error("Invalid attribute: " + val.toString() + ". " + node._debugInfo()); - } - else /* if (isMap(val) || isObject(val)) */ { - util_1.forEachObject(val, function (attrKey, attrVal) { - lastChild = _this.attribute(node, undefined, s(attrKey), s(attrVal)) || lastChild; - }); - } - } - else { - lastChild = _this.attribute(node, undefined, s(key.substr(options.convert.att.length)), s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.text) === 0) { - // text node - if (util_1.isMap(val) || util_1.isObject(val)) { - // if the key is #text expand child nodes under this node to support mixed content - lastChild = _this.parse(node, val); - } - else { - lastChild = _this.text(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.cdata) === 0) { - // cdata node - if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { return lastChild = _this.cdata(node, s(item)) || lastChild; }, _this); - } - else { - lastChild = _this.cdata(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.comment) === 0) { - // comment node - if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { return lastChild = _this.comment(node, s(item)) || lastChild; }, _this); - } - else { - lastChild = _this.comment(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.ins) === 0) { - // processing instruction - if (util_1.isString(val)) { - var insIndex = val.indexOf(' '); - var insTarget = (insIndex === -1 ? val : val.substr(0, insIndex)); - var insValue = (insIndex === -1 ? '' : val.substr(insIndex + 1)); - lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; - } - else if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { - var insIndex = item.indexOf(' '); - var insTarget = (insIndex === -1 ? item : item.substr(0, insIndex)); - var insValue = (insIndex === -1 ? '' : item.substr(insIndex + 1)); - lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; - }, _this); - } - else /* if (isMap(target) || isObject(target)) */ { - util_1.forEachObject(val, function (insTarget, insValue) { return lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; }, _this); - } - } - else if ((util_1.isArray(val) || util_1.isSet(val)) && util_1.isEmpty(val)) { - // skip empty arrays - } - else if ((util_1.isMap(val) || util_1.isObject(val)) && util_1.isEmpty(val)) { - // empty objects produce one node - lastChild = _this.element(node, undefined, s(key)) || lastChild; - } - else if (!options.keepNullNodes && (val == null)) { - // skip null and undefined nodes - } - else if (util_1.isArray(val) || util_1.isSet(val)) { - // expand list by creating child nodes - util_1.forEachArray(val, function (item) { - var childNode = {}; - childNode[key] = item; - lastChild = _this.parse(node, childNode); - }, _this); - } - else if (util_1.isMap(val) || util_1.isObject(val)) { - // create a parent node - var parent = _this.element(node, undefined, key); - if (parent) { - lastChild = parent; - // expand child nodes under parent - _this.parse(parent, val); - } - } - else if (val != null && val !== '') { - // leaf element node with a single text node - var parent = _this.element(node, undefined, key); - if (parent) { - lastChild = parent; - _this.text(parent, s(val)); - } - } - else { - // leaf element node - lastChild = _this.element(node, undefined, s(key)) || lastChild; - } - }, this); - } - return lastChild || node; - }; - return ObjectReader; -}(BaseReader_1.BaseReader)); -exports.ObjectReader = ObjectReader; -//# sourceMappingURL=ObjectReader.js.map /***/ }), -/***/ 5044: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 9766: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + module.exports = { + None: 0, + OpenTag: 1, + InsideTag: 2, + CloseTag: 3 + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } +}).call(this); + + +/***/ }), + +/***/ 8376: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLAttribute, XMLNode; + + NodeType = __nccwpck_require__(9267); + + XMLNode = __nccwpck_require__(7608); + + module.exports = XMLAttribute = (function() { + function XMLAttribute(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; } - return ar; -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var XMLStringLexer_1 = __nccwpck_require__(7061); -var interfaces_1 = __nccwpck_require__(7707); -var infra_1 = __nccwpck_require__(4251); -var algorithm_1 = __nccwpck_require__(61); -var dom_1 = __nccwpck_require__(770); -var BaseReader_1 = __nccwpck_require__(3396); -/** - * Parses XML nodes from an XML document string. - */ -var XMLReader = /** @class */ (function (_super) { - __extends(XMLReader, _super); - function XMLReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - XML document string to parse - */ - XMLReader.prototype._parse = function (node, str) { - var e_1, _a, e_2, _b; - var lexer = new XMLStringLexer_1.XMLStringLexer(str, { skipWhitespaceOnlyText: true }); - // sanitizes input characters - var invalidCharReplacement = this._builderOptions.invalidCharReplacement; - var s = function (str) { - return dom_1.sanitizeInput(str, invalidCharReplacement); - }; - var context = node; - var token = lexer.nextToken(); - while (token.type !== interfaces_1.TokenType.EOF) { - switch (token.type) { - case interfaces_1.TokenType.Declaration: - var declaration = token; - var version = s(declaration.version); - if (version !== "1.0") { - throw new Error("Invalid xml version: " + version); - } - var builderOptions = { - version: version - }; - if (declaration.encoding) { - builderOptions.encoding = s(declaration.encoding); - } - if (declaration.standalone) { - builderOptions.standalone = (s(declaration.standalone) === "yes"); - } - context.set(builderOptions); - break; - case interfaces_1.TokenType.DocType: - var doctype = token; - context = this.docType(context, s(doctype.name), s(doctype.pubId), s(doctype.sysId)) || context; - break; - case interfaces_1.TokenType.CDATA: - var cdata = token; - context = this.cdata(context, s(cdata.data)) || context; - break; - case interfaces_1.TokenType.Comment: - var comment = token; - context = this.comment(context, s(comment.data)) || context; - break; - case interfaces_1.TokenType.PI: - var pi = token; - context = this.instruction(context, s(pi.target), s(pi.data)) || context; - break; - case interfaces_1.TokenType.Text: - var text = token; - context = this.text(context, s(text.data)) || context; - break; - case interfaces_1.TokenType.Element: - var element = token; - var elementName = s(element.name); - // inherit namespace from parent - var _c = __read(algorithm_1.namespace_extractQName(elementName), 1), prefix = _c[0]; - var namespace = context.node.lookupNamespaceURI(prefix); - // override namespace if there is a namespace declaration - // attribute - // also lookup namespace declaration attributes - var nsDeclarations = {}; - try { - for (var _d = (e_1 = void 0, __values(element.attributes)), _e = _d.next(); !_e.done; _e = _d.next()) { - var _f = __read(_e.value, 2), attName = _f[0], attValue = _f[1]; - attName = s(attName); - attValue = s(attValue); - if (attName === "xmlns") { - namespace = attValue; - } - else { - var _g = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _g[0], attLocalName = _g[1]; - if (attPrefix === "xmlns") { - if (attLocalName === prefix) { - namespace = attValue; - } - nsDeclarations[attLocalName] = attValue; - } - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_e && !_e.done && (_a = _d.return)) _a.call(_d); - } - finally { if (e_1) throw e_1.error; } - } - // create the DOM element node - var elementNode = (namespace !== null ? - this.element(context, namespace, elementName) : - this.element(context, undefined, elementName)); - if (elementNode === undefined) - break; - try { - // assign attributes - for (var _h = (e_2 = void 0, __values(element.attributes)), _j = _h.next(); !_j.done; _j = _h.next()) { - var _k = __read(_j.value, 2), attName = _k[0], attValue = _k[1]; - attName = s(attName); - attValue = s(attValue); - var _l = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _l[0], attLocalName = _l[1]; - var attNamespace = null; - if (attPrefix === "xmlns" || (attPrefix === null && attLocalName === "xmlns")) { - // namespace declaration attribute - attNamespace = infra_1.namespace.XMLNS; - } - else { - attNamespace = elementNode.node.lookupNamespaceURI(attPrefix); - if (attNamespace !== null && elementNode.node.isDefaultNamespace(attNamespace)) { - attNamespace = null; - } - else if (attNamespace === null && attPrefix !== null) { - attNamespace = nsDeclarations[attPrefix] || null; - } - } - if (attNamespace !== null) - this.attribute(elementNode, attNamespace, attName, attValue); - else - this.attribute(elementNode, undefined, attName, attValue); - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_j && !_j.done && (_b = _h.return)) _b.call(_h); - } - finally { if (e_2) throw e_2.error; } - } - if (!element.selfClosing) { - context = elementNode; - } - break; - case interfaces_1.TokenType.ClosingTag: - /* istanbul ignore else */ - if (context.node.parentNode) { - context = context.up(); - } - break; - } - token = lexer.nextToken(); - } - return context; - }; - return XMLReader; -}(BaseReader_1.BaseReader)); -exports.XMLReader = XMLReader; -//# sourceMappingURL=XMLReader.js.map - -/***/ }), -/***/ 2475: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + Object.defineProperty(XMLAttribute.prototype, 'nodeType', { + get: function() { + return this.type; + } + }); -"use strict"; + Object.defineProperty(XMLAttribute.prototype, 'ownerElement', { + get: function() { + return this.parent; + } + }); -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectReader_1 = __nccwpck_require__(768); -var BaseReader_1 = __nccwpck_require__(3396); -var js_yaml_1 = __nccwpck_require__(1917); -/** - * Parses XML nodes from a YAML string. - */ -var YAMLReader = /** @class */ (function (_super) { - __extends(YAMLReader, _super); - function YAMLReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - YAML string to parse - */ - YAMLReader.prototype._parse = function (node, str) { - var result = js_yaml_1.safeLoad(str); - /* istanbul ignore next */ - if (result === undefined) { - throw new Error("Unable to parse YAML document."); - } - return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, result); - }; - return YAMLReader; -}(BaseReader_1.BaseReader)); -exports.YAMLReader = YAMLReader; -//# sourceMappingURL=YAMLReader.js.map + Object.defineProperty(XMLAttribute.prototype, 'textContent', { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ''; + } + }); -/***/ }), + Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', { + get: function() { + return ''; + } + }); -/***/ 560: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + Object.defineProperty(XMLAttribute.prototype, 'prefix', { + get: function() { + return ''; + } + }); -"use strict"; + Object.defineProperty(XMLAttribute.prototype, 'localName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLAttribute.prototype, 'specified', { + get: function() { + return true; + } + }); + + XMLAttribute.prototype.clone = function() { + return Object.create(this); + }; + + XMLAttribute.prototype.toString = function(options) { + return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); + }; + + XMLAttribute.prototype.debugInfo = function(name) { + name = name || this.name; + if (name == null) { + return "parent: <" + this.parent.name + ">"; + } else { + return "attribute: {" + name + "}, parent: <" + this.parent.name + ">"; + } + }; + + XMLAttribute.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 XMLAttribute; + + })(); + +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var XMLReader_1 = __nccwpck_require__(5044); -exports.XMLReader = XMLReader_1.XMLReader; -var ObjectReader_1 = __nccwpck_require__(768); -exports.ObjectReader = ObjectReader_1.ObjectReader; -var JSONReader_1 = __nccwpck_require__(3518); -exports.JSONReader = JSONReader_1.JSONReader; -var YAMLReader_1 = __nccwpck_require__(2475); -exports.YAMLReader = YAMLReader_1.YAMLReader; -//# sourceMappingURL=index.js.map /***/ }), -/***/ 708: -/***/ ((__unused_webpack_module, exports) => { +/***/ 333: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(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; -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Pre-serializes XML nodes. - */ -var BaseCBWriter = /** @class */ (function () { - /** - * Initializes a new instance of `BaseCBWriter`. - * - * @param builderOptions - XML builder options - */ - function BaseCBWriter(builderOptions) { - /** - * Gets the current depth of the XML tree. - */ - this.level = 0; - this._builderOptions = builderOptions; - this._writerOptions = builderOptions; + NodeType = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLCData = (function(superClass) { + extend(XMLCData, superClass); + + function XMLCData(parent, text) { + XMLCData.__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); } - return BaseCBWriter; -}()); -exports.BaseCBWriter = BaseCBWriter; -//# sourceMappingURL=BaseCBWriter.js.map + + XMLCData.prototype.clone = function() { + return Object.create(this); + }; + + XMLCData.prototype.toString = function(options) { + return this.options.writer.cdata(this, this.options.writer.filterOptions(options)); + }; + + return XMLCData; + + })(XMLCharacterData); + +}).call(this); + /***/ }), -/***/ 7644: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 7709: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(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; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + XMLNode = __nccwpck_require__(7608); + + module.exports = XMLCharacterData = (function(superClass) { + extend(XMLCharacterData, superClass); + + function XMLCharacterData(parent) { + XMLCharacterData.__super__.constructor.call(this, parent); + this.value = ''; } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } + + Object.defineProperty(XMLCharacterData.prototype, 'data', { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ''; + } + }); + + Object.defineProperty(XMLCharacterData.prototype, 'length', { + get: function() { + return this.value.length; + } + }); + + Object.defineProperty(XMLCharacterData.prototype, 'textContent', { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ''; + } + }); + + XMLCharacterData.prototype.clone = function() { + return Object.create(this); + }; + + XMLCharacterData.prototype.substringData = function(offset, count) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.appendData = function(arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.insertData = function(offset, arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.deleteData = function(offset, count) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.replaceData = function(offset, count, arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.isEqualNode = function(node) { + if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.data !== this.data) { + return false; + } + return true; + }; + + return XMLCharacterData; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 4407: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLComment = (function(superClass) { + extend(XMLComment, superClass); + + function XMLComment(parent, text) { + XMLComment.__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); } - return ar; -}; -var __spread = (this && this.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(7305); -var LocalNameSet_1 = __nccwpck_require__(9049); -var NamespacePrefixMap_1 = __nccwpck_require__(283); -var infra_1 = __nccwpck_require__(4251); -var algorithm_1 = __nccwpck_require__(61); -/** - * Pre-serializes XML nodes. - */ -var BaseWriter = /** @class */ (function () { - /** - * Initializes a new instance of `BaseWriter`. - * - * @param builderOptions - XML builder options - */ - function BaseWriter(builderOptions) { - /** - * Gets the current depth of the XML tree. - */ - this.level = 0; - this._builderOptions = builderOptions; + + XMLComment.prototype.clone = function() { + return Object.create(this); + }; + + XMLComment.prototype.toString = function(options) { + return this.options.writer.comment(this, this.options.writer.filterOptions(options)); + }; + + return XMLComment; + + })(XMLCharacterData); + +}).call(this); + + +/***/ }), + +/***/ 7465: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList; + + XMLDOMErrorHandler = __nccwpck_require__(6744); + + XMLDOMStringList = __nccwpck_require__(7028); + + module.exports = XMLDOMConfiguration = (function() { + function XMLDOMConfiguration() { + 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); } - /** - * Used by derived classes to serialize the XML declaration. - * - * @param version - a version number string - * @param encoding - encoding declaration - * @param standalone - standalone document declaration - */ - BaseWriter.prototype.declaration = function (version, encoding, standalone) { }; - /** - * Used by derived classes to serialize a DocType node. - * - * @param name - node name - * @param publicId - public identifier - * @param systemId - system identifier - */ - BaseWriter.prototype.docType = function (name, publicId, systemId) { }; - /** - * Used by derived classes to serialize a comment node. - * - * @param data - node data - */ - BaseWriter.prototype.comment = function (data) { }; - /** - * Used by derived classes to serialize a text node. - * - * @param data - node data - */ - BaseWriter.prototype.text = function (data) { }; - /** - * Used by derived classes to serialize a processing instruction node. - * - * @param target - instruction target - * @param data - node data - */ - BaseWriter.prototype.instruction = function (target, data) { }; - /** - * Used by derived classes to serialize a CData section node. - * - * @param data - node data - */ - BaseWriter.prototype.cdata = function (data) { }; - /** - * Used by derived classes to serialize the beginning of the opening tag of an - * element node. - * - * @param name - node name - */ - BaseWriter.prototype.openTagBegin = function (name) { }; - /** - * Used by derived classes to serialize the ending of the opening tag of an - * element node. - * - * @param name - node name - * @param selfClosing - whether the element node is self closing - * @param voidElement - whether the element node is a HTML void element - */ - BaseWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { }; - /** - * Used by derived classes to serialize the closing tag of an element node. - * - * @param name - node name - */ - BaseWriter.prototype.closeTag = function (name) { }; - /** - * Used by derived classes to serialize attributes or namespace declarations. - * - * @param attributes - attribute array - */ - BaseWriter.prototype.attributes = function (attributes) { - var e_1, _a; - try { - for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) { - var attr = attributes_1_1.value; - this.attribute(attr[1] === null ? attr[2] : attr[1] + ':' + attr[2], attr[3]); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1); - } - finally { if (e_1) throw e_1.error; } - } + + Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', { + get: function() { + return new XMLDOMStringList(Object.keys(this.defaultParams)); + } + }); + + XMLDOMConfiguration.prototype.getParameter = function(name) { + if (this.params.hasOwnProperty(name)) { + return this.params[name]; + } else { + return null; + } }; - /** - * Used by derived classes to serialize an attribute or namespace declaration. - * - * @param name - node name - * @param value - node value - */ - BaseWriter.prototype.attribute = function (name, value) { }; - /** - * Used by derived classes to perform any pre-processing steps before starting - * serializing an element node. - * - * @param name - node name - */ - BaseWriter.prototype.beginElement = function (name) { }; - /** - * Used by derived classes to perform any post-processing steps after - * completing serializing an element node. - * - * @param name - node name - */ - BaseWriter.prototype.endElement = function (name) { }; - /** - * Produces an XML serialization of the given node. The pre-serializer inserts - * namespace declarations where necessary and produces qualified names for - * nodes and attributes. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype.serializeNode = function (node, requireWellFormed, noDoubleEncoding) { - var hasNamespaces = (node._nodeDocument !== undefined && node._nodeDocument._hasNamespaces); - this.level = 0; - this.currentNode = node; - if (hasNamespaces) { - /** From: https://w3c.github.io/DOM-Parsing/#xml-serialization - * - * 1. Let namespace be a context namespace with value null. - * The context namespace tracks the XML serialization algorithm's current - * default namespace. The context namespace is changed when either an Element - * Node has a default namespace declaration, or the algorithm generates a - * default namespace declaration for the Element Node to match its own - * namespace. The algorithm assumes no namespace (null) to start. - * 2. Let prefix map be a new namespace prefix map. - * 3. Add the XML namespace with prefix value "xml" to prefix map. - * 4. Let prefix index be a generated namespace prefix index with value 1. - * The generated namespace prefix index is used to generate a new unique - * prefix value when no suitable existing namespace prefix is available to - * serialize a node's namespaceURI (or the namespaceURI of one of node's - * attributes). See the generate a prefix algorithm. - */ - var namespace = null; - var prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); - prefixMap.set("xml", infra_1.namespace.XML); - var prefixIndex = { value: 1 }; - /** - * 5. Return the result of running the XML serialization algorithm on node - * passing the context namespace namespace, namespace prefix map prefix map, - * generated namespace prefix index reference to prefix index, and the - * flag require well-formed. If an exception occurs during the execution - * of the algorithm, then catch that exception and throw an - * "InvalidStateError" DOMException. - */ - this._serializeNodeNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - } - else { - this._serializeNode(node, requireWellFormed, noDoubleEncoding); - } + + XMLDOMConfiguration.prototype.canSetParameter = function(name, value) { + return true; }; - /** - * Produces an XML serialization of a node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeNodeNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - this.currentNode = node; - switch (node.nodeType) { - case interfaces_1.NodeType.Element: - this._serializeElementNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Document: - this._serializeDocumentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Comment: - this._serializeComment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Text: - this._serializeText(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentFragment: - this._serializeDocumentFragmentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentType: - this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.ProcessingInstruction: - this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.CData: - this._serializeCData(node, requireWellFormed, noDoubleEncoding); - break; - default: - throw new Error("Unknown node type: " + node.nodeType); - } + + XMLDOMConfiguration.prototype.setParameter = function(name, value) { + if (value != null) { + return this.params[name] = value; + } else { + return delete this.params[name]; + } }; - /** - * Produces an XML serialization of a node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeNode = function (node, requireWellFormed, noDoubleEncoding) { - this.currentNode = node; - switch (node.nodeType) { - case interfaces_1.NodeType.Element: - this._serializeElement(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Document: - this._serializeDocument(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Comment: - this._serializeComment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Text: - this._serializeText(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentFragment: - this._serializeDocumentFragment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentType: - this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.ProcessingInstruction: - this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.CData: - this._serializeCData(node, requireWellFormed, noDoubleEncoding); - break; - default: - throw new Error("Unknown node type: " + node.nodeType); - } + + return XMLDOMConfiguration; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 6744: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMErrorHandler; + + module.exports = XMLDOMErrorHandler = (function() { + function XMLDOMErrorHandler() {} + + XMLDOMErrorHandler.prototype.handleError = function(error) { + throw new Error(error); }; - /** - * Produces an XML serialization of an element node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeElementNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_2, _a; - var attributes = []; - /** - * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node - * - * 1. If the require well-formed flag is set (its value is true), and this - * node's localName attribute contains the character ":" (U+003A COLON) or - * does not match the XML Name production, then throw an exception; the - * serialization of this node would not be a well-formed element. - */ - if (requireWellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - throw new Error("Node local name contains invalid characters (well-formed required)."); - } - /** - * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). - * 3. Let qualified name be an empty string. - * 4. Let skip end tag be a boolean flag with value false. - * 5. Let ignore namespace definition attribute be a boolean flag with value - * false. - * 6. Given prefix map, copy a namespace prefix map and let map be the - * result. - * 7. Let local prefixes map be an empty map. The map has unique Node prefix - * strings as its keys, with corresponding namespaceURI Node values as the - * map's key values (in this map, the null namespace is represented by the - * empty string). - * - * _Note:_ This map is local to each element. It is used to ensure there - * are no conflicting prefixes should a new namespace prefix attribute need - * to be generated. It is also used to enable skipping of duplicate prefix - * definitions when writing an element's attributes: the map allows the - * algorithm to distinguish between a prefix in the namespace prefix map - * that might be locally-defined (to the current Element) and one that is - * not. - * 8. Let local default namespace be the result of recording the namespace - * information for node given map and local prefixes map. - * - * _Note:_ The above step will update map with any found namespace prefix - * definitions, add the found prefix definitions to the local prefixes map - * and return a local default namespace value defined by a default namespace - * attribute if one exists. Otherwise it returns null. - * 9. Let inherited ns be a copy of namespace. - * 10. Let ns be the value of node's namespaceURI attribute. - */ - var qualifiedName = ''; - var skipEndTag = false; - var ignoreNamespaceDefinitionAttribute = false; - var map = prefixMap.copy(); - var localPrefixesMap = {}; - var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); - var inheritedNS = namespace; - var ns = node.namespaceURI; - /** 11. If inherited ns is equal to ns, then: */ - if (inheritedNS === ns) { - /** - * 11.1. If local default namespace is not null, then set ignore - * namespace definition attribute to true. - */ - if (localDefaultNamespace !== null) { - ignoreNamespaceDefinitionAttribute = true; - } - /** - * 11.2. If ns is the XML namespace, then append to qualified name the - * concatenation of the string "xml:" and the value of node's localName. - * 11.3. Otherwise, append to qualified name the value of node's - * localName. The node's prefix if it exists, is dropped. - */ - if (ns === infra_1.namespace.XML) { - qualifiedName = 'xml:' + node.localName; - } - else { - qualifiedName = node.localName; - } - /** 11.4. Append the value of qualified name to markup. */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - } - else { - /** - * 12. Otherwise, inherited ns is not equal to ns (the node's own - * namespace is different from the context namespace of its parent). - * Run these sub-steps: - * - * 12.1. Let prefix be the value of node's prefix attribute. - * 12.2. Let candidate prefix be the result of retrieving a preferred - * prefix string prefix from map given namespace ns. The above may return - * null if no namespace key ns exists in map. - */ - var prefix = node.prefix; - /** - * We don't need to run "retrieving a preferred prefix string" algorithm if - * the element has no prefix and its namespace matches to the default - * namespace. - * See: https://github.com/web-platform-tests/wpt/pull/16703 - */ - var candidatePrefix = null; - if (prefix !== null || ns !== localDefaultNamespace) { - candidatePrefix = map.get(prefix, ns); - } - /** - * 12.3. If the value of prefix matches "xmlns", then run the following - * steps: - */ - if (prefix === "xmlns") { - /** - * 12.3.1. If the require well-formed flag is set, then throw an error. - * An Element with prefix "xmlns" will not legally round-trip in a - * conforming XML parser. - */ - if (requireWellFormed) { - throw new Error("An element cannot have the 'xmlns' prefix (well-formed required)."); - } - /** - * 12.3.2. Let candidate prefix be the value of prefix. - */ - candidatePrefix = prefix; - } - /** - * 12.4.Found a suitable namespace prefix: if candidate prefix is not - * null (a namespace prefix is defined which maps to ns), then: - */ - if (candidatePrefix !== null) { - /** - * The following may serialize a different prefix than the Element's - * existing prefix if it already had one. However, the retrieving a - * preferred prefix string algorithm already tried to match the - * existing prefix if possible. - * - * 12.4.1. Append to qualified name the concatenation of candidate - * prefix, ":" (U+003A COLON), and node's localName. There exists on - * this node or the node's ancestry a namespace prefix definition that - * defines the node's namespace. - * 12.4.2. If the local default namespace is not null (there exists a - * locally-defined default namespace declaration attribute) and its - * value is not the XML namespace, then let inherited ns get the value - * of local default namespace unless the local default namespace is the - * empty string in which case let it get null (the context namespace - * is changed to the declared default, rather than this node's own - * namespace). - * - * _Note:_ Any default namespace definitions or namespace prefixes that - * define the XML namespace are omitted when serializing this node's - * attributes. - */ - qualifiedName = candidatePrefix + ':' + node.localName; - if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { - inheritedNS = localDefaultNamespace || null; - } - /** - * 12.4.3. Append the value of qualified name to markup. - */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** 12.5. Otherwise, if prefix is not null, then: */ - } - else if (prefix !== null) { - /** - * _Note:_ By this step, there is no namespace or prefix mapping - * declaration in this node (or any parent node visited by this - * algorithm) that defines prefix otherwise the step labelled Found - * a suitable namespace prefix would have been followed. The sub-steps - * that follow will create a new namespace prefix declaration for prefix - * and ensure that prefix does not conflict with an existing namespace - * prefix declaration of the same localName in node's attribute list. - * - * 12.5.1. If the local prefixes map contains a key matching prefix, - * then let prefix be the result of generating a prefix providing as - * input map, ns, and prefix index. - */ - if (prefix in localPrefixesMap) { - prefix = this._generatePrefix(ns, map, prefixIndex); - } - /** - * 12.5.2. Add prefix to map given namespace ns. - * 12.5.3. Append to qualified name the concatenation of prefix, ":" - * (U+003A COLON), and node's localName. - * 12.5.4. Append the value of qualified name to markup. - */ - map.set(prefix, ns); - qualifiedName += prefix + ':' + node.localName; - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 12.5.5. Append the following to markup, in the order listed: - * - * _Note:_ The following serializes a namespace prefix declaration for - * prefix which was just added to the map. - * - * 12.5.5.1. " " (U+0020 SPACE); - * 12.5.5.2. The string "xmlns:"; - * 12.5.5.3. The value of prefix; - * 12.5.5.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 12.5.5.5. The result of serializing an attribute value given ns and - * the require well-formed flag as input; - * 12.5.5.6. """ (U+0022 QUOTATION MARK). - */ - attributes.push([null, 'xmlns', prefix, - this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); - /** - * 12.5.5.7. If local default namespace is not null (there exists a - * locally-defined default namespace declaration attribute), then - * let inherited ns get the value of local default namespace unless the - * local default namespace is the empty string in which case let it get - * null. - */ - if (localDefaultNamespace !== null) { - inheritedNS = localDefaultNamespace || null; - } - /** - * 12.6. Otherwise, if local default namespace is null, or local - * default namespace is not null and its value is not equal to ns, then: - */ - } - else if (localDefaultNamespace === null || - (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { - /** - * _Note:_ At this point, the namespace for this node still needs to be - * serialized, but there's no prefix (or candidate prefix) available; the - * following uses the default namespace declaration to define the - * namespace--optionally replacing an existing default declaration - * if present. - * - * 12.6.1. Set the ignore namespace definition attribute flag to true. - * 12.6.2. Append to qualified name the value of node's localName. - * 12.6.3. Let the value of inherited ns be ns. - * - * _Note:_ The new default namespace will be used in the serialization - * to define this node's namespace and act as the context namespace for - * its children. - */ - ignoreNamespaceDefinitionAttribute = true; - qualifiedName += node.localName; - inheritedNS = ns; - /** - * 12.6.4. Append the value of qualified name to markup. - */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 12.6.5. Append the following to markup, in the order listed: - * - * _Note:_ The following serializes the new (or replacement) default - * namespace definition. - * - * 12.6.5.1. " " (U+0020 SPACE); - * 12.6.5.2. The string "xmlns"; - * 12.6.5.3. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 12.6.5.4. The result of serializing an attribute value given ns - * and the require well-formed flag as input; - * 12.6.5.5. """ (U+0022 QUOTATION MARK). - */ - attributes.push([null, null, 'xmlns', - this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); - /** - * 12.7. Otherwise, the node has a local default namespace that matches - * ns. Append to qualified name the value of node's localName, let the - * value of inherited ns be ns, and append the value of qualified name - * to markup. - */ - } - else { - qualifiedName += node.localName; - inheritedNS = ns; - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - } - } - /** - * 13. Append to markup the result of the XML serialization of node's - * attributes given map, prefix index, local prefixes map, ignore namespace - * definition attribute flag, and require well-formed flag. - */ - attributes.push.apply(attributes, __spread(this._serializeAttributesNS(node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding))); - this.attributes(attributes); - /** - * 14. If ns is the HTML namespace, and the node's list of children is - * empty, and the node's localName matches any one of the following void - * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", - * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", - * "param", "source", "track", "wbr"; then append the following to markup, - * in the order listed: - * 14.1. " " (U+0020 SPACE); - * 14.2. "/" (U+002F SOLIDUS). - * and set the skip end tag flag to true. - * 15. If ns is not the HTML namespace, and the node's list of children is - * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end - * tag flag to true. - * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. - */ - var isHTML = (ns === infra_1.namespace.HTML); - if (isHTML && node.childNodes.length === 0 && - BaseWriter._VoidElementNames.has(node.localName)) { - this.openTagEnd(qualifiedName, true, true); - this.endElement(qualifiedName); - skipEndTag = true; - } - else if (!isHTML && node.childNodes.length === 0) { - this.openTagEnd(qualifiedName, true, false); - this.endElement(qualifiedName); - skipEndTag = true; - } - else { - this.openTagEnd(qualifiedName, false, false); - } - /** - * 17. If the value of skip end tag is true, then return the value of markup - * and skip the remaining steps. The node is a leaf-node. - */ - if (skipEndTag) - return; - /** - * 18. If ns is the HTML namespace, and the node's localName matches the - * string "template", then this is a template element. Append to markup the - * result of XML serializing a DocumentFragment node given the template - * element's template contents (a DocumentFragment), providing inherited - * ns, map, prefix index, and the require well-formed flag. - * - * _Note:_ This allows template content to round-trip, given the rules for - * parsing XHTML documents. - * - * 19. Otherwise, append to markup the result of running the XML - * serialization algorithm on each of node's children, in tree order, - * providing inherited ns, map, prefix index, and the require well-formed - * flag. - */ - if (isHTML && node.localName === "template") { - // TODO: serialize template contents - } - else { - try { - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this.level++; - this._serializeNodeNS(childNode, inheritedNS, map, prefixIndex, requireWellFormed, noDoubleEncoding); - this.level--; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_2) throw e_2.error; } - } - } - /** - * 20. Append the following to markup, in the order listed: - * 20.1. "" (U+003E GREATER-THAN SIGN). - * 21. Return the value of markup. - */ - this.closeTag(qualifiedName); - this.endElement(qualifiedName); + + return XMLDOMErrorHandler; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 8310: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMImplementation; + + module.exports = XMLDOMImplementation = (function() { + function XMLDOMImplementation() {} + + XMLDOMImplementation.prototype.hasFeature = function(feature, version) { + return true; + }; + + XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) { + throw new Error("This DOM method is not implemented."); + }; + + XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) { + throw new Error("This DOM method is not implemented."); + }; + + XMLDOMImplementation.prototype.createHTMLDocument = function(title) { + throw new Error("This DOM method is not implemented."); + }; + + XMLDOMImplementation.prototype.getFeature = function(feature, version) { + throw new Error("This DOM method is not implemented."); }; - /** - * Produces an XML serialization of an element node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeElement = function (node, requireWellFormed, noDoubleEncoding) { - var e_3, _a; - /** - * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node - * - * 1. If the require well-formed flag is set (its value is true), and this - * node's localName attribute contains the character ":" (U+003A COLON) or - * does not match the XML Name production, then throw an exception; the - * serialization of this node would not be a well-formed element. - */ - if (requireWellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - throw new Error("Node local name contains invalid characters (well-formed required)."); - } - /** - * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). - * 3. Let qualified name be an empty string. - * 4. Let skip end tag be a boolean flag with value false. - * 5. Let ignore namespace definition attribute be a boolean flag with value - * false. - * 6. Given prefix map, copy a namespace prefix map and let map be the - * result. - * 7. Let local prefixes map be an empty map. The map has unique Node prefix - * strings as its keys, with corresponding namespaceURI Node values as the - * map's key values (in this map, the null namespace is represented by the - * empty string). - * - * _Note:_ This map is local to each element. It is used to ensure there - * are no conflicting prefixes should a new namespace prefix attribute need - * to be generated. It is also used to enable skipping of duplicate prefix - * definitions when writing an element's attributes: the map allows the - * algorithm to distinguish between a prefix in the namespace prefix map - * that might be locally-defined (to the current Element) and one that is - * not. - * 8. Let local default namespace be the result of recording the namespace - * information for node given map and local prefixes map. - * - * _Note:_ The above step will update map with any found namespace prefix - * definitions, add the found prefix definitions to the local prefixes map - * and return a local default namespace value defined by a default namespace - * attribute if one exists. Otherwise it returns null. - * 9. Let inherited ns be a copy of namespace. - * 10. Let ns be the value of node's namespaceURI attribute. - */ - var skipEndTag = false; - /** 11. If inherited ns is equal to ns, then: */ - /** - * 11.1. If local default namespace is not null, then set ignore - * namespace definition attribute to true. - */ - /** - * 11.2. If ns is the XML namespace, then append to qualified name the - * concatenation of the string "xml:" and the value of node's localName. - * 11.3. Otherwise, append to qualified name the value of node's - * localName. The node's prefix if it exists, is dropped. - */ - var qualifiedName = node.localName; - /** 11.4. Append the value of qualified name to markup. */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 13. Append to markup the result of the XML serialization of node's - * attributes given map, prefix index, local prefixes map, ignore namespace - * definition attribute flag, and require well-formed flag. - */ - var attributes = this._serializeAttributes(node, requireWellFormed, noDoubleEncoding); - this.attributes(attributes); - /** - * 14. If ns is the HTML namespace, and the node's list of children is - * empty, and the node's localName matches any one of the following void - * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", - * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", - * "param", "source", "track", "wbr"; then append the following to markup, - * in the order listed: - * 14.1. " " (U+0020 SPACE); - * 14.2. "/" (U+002F SOLIDUS). - * and set the skip end tag flag to true. - * 15. If ns is not the HTML namespace, and the node's list of children is - * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end - * tag flag to true. - * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. - */ - if (!node.hasChildNodes()) { - this.openTagEnd(qualifiedName, true, false); - this.endElement(qualifiedName); - skipEndTag = true; + + return XMLDOMImplementation; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 7028: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMStringList; + + module.exports = XMLDOMStringList = (function() { + function XMLDOMStringList(arr) { + this.arr = arr || []; + } + + Object.defineProperty(XMLDOMStringList.prototype, 'length', { + get: function() { + return this.arr.length; + } + }); + + XMLDOMStringList.prototype.item = function(index) { + return this.arr[index] || null; + }; + + XMLDOMStringList.prototype.contains = function(str) { + return this.arr.indexOf(str) !== -1; + }; + + return XMLDOMStringList; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 1015: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDTDAttList = (function(superClass) { + extend(XMLDTDAttList, superClass); + + function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { + XMLDTDAttList.__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; + } + + XMLDTDAttList.prototype.toString = function(options) { + return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options)); + }; + + return XMLDTDAttList; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 2421: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDTDElement = (function(superClass) { + extend(XMLDTDElement, superClass); + + function XMLDTDElement(parent, name, value) { + XMLDTDElement.__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); + } + + XMLDTDElement.prototype.toString = function(options) { + return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options)); + }; + + return XMLDTDElement; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 53: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = (__nccwpck_require__(8229).isObject); + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDTDEntity = (function(superClass) { + extend(XMLDTDEntity, superClass); + + function XMLDTDEntity(parent, pe, name, value) { + XMLDTDEntity.__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)); } - else { - this.openTagEnd(qualifiedName, false, false); + if (value.pubID && !value.sysID) { + throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name)); } - /** - * 17. If the value of skip end tag is true, then return the value of markup - * and skip the remaining steps. The node is a leaf-node. - */ - if (skipEndTag) - return; - try { - /** - * 18. If ns is the HTML namespace, and the node's localName matches the - * string "template", then this is a template element. Append to markup the - * result of XML serializing a DocumentFragment node given the template - * element's template contents (a DocumentFragment), providing inherited - * ns, map, prefix index, and the require well-formed flag. - * - * _Note:_ This allows template content to round-trip, given the rules for - * parsing XHTML documents. - * - * 19. Otherwise, append to markup the result of running the XML - * serialization algorithm on each of node's children, in tree order, - * providing inherited ns, map, prefix index, and the require well-formed - * flag. - */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this.level++; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); - this.level--; - } + this.internal = false; + if (value.pubID != null) { + this.pubID = this.stringify.dtdPubID(value.pubID); } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_3) throw e_3.error; } + 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(XMLDTDEntity.prototype, 'publicId', { + get: function() { + return this.pubID; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'systemId', { + get: function() { + return this.sysID; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'notationName', { + get: function() { + return this.nData || null; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', { + get: function() { + return null; + } + }); + + XMLDTDEntity.prototype.toString = function(options) { + return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options)); + }; + + return XMLDTDEntity; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 2837: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDTDNotation = (function(superClass) { + extend(XMLDTDNotation, superClass); + + function XMLDTDNotation(parent, name, value) { + XMLDTDNotation.__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(XMLDTDNotation.prototype, 'publicId', { + get: function() { + return this.pubID; + } + }); + + Object.defineProperty(XMLDTDNotation.prototype, 'systemId', { + get: function() { + return this.sysID; + } + }); + + XMLDTDNotation.prototype.toString = function(options) { + return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options)); + }; + + return XMLDTDNotation; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 6364: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = (__nccwpck_require__(8229).isObject); + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDeclaration = (function(superClass) { + extend(XMLDeclaration, superClass); + + function XMLDeclaration(parent, version, encoding, standalone) { + var ref; + XMLDeclaration.__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); + } + } + + XMLDeclaration.prototype.toString = function(options) { + return this.options.writer.declaration(this, this.options.writer.filterOptions(options)); + }; + + return XMLDeclaration; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 1801: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = (__nccwpck_require__(8229).isObject); + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + XMLDTDAttList = __nccwpck_require__(1015); + + XMLDTDEntity = __nccwpck_require__(53); + + XMLDTDElement = __nccwpck_require__(2421); + + XMLDTDNotation = __nccwpck_require__(2837); + + XMLNamedNodeMap = __nccwpck_require__(4361); + + module.exports = XMLDocType = (function(superClass) { + extend(XMLDocType, superClass); + + function XMLDocType(parent, pubID, sysID) { + var child, i, len, ref, ref1, ref2; + XMLDocType.__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; + } } - /** - * 20. Append the following to markup, in the order listed: - * 20.1. "" (U+003E GREATER-THAN SIGN). - * 21. Return the value of markup. - */ - this.closeTag(qualifiedName); - this.endElement(qualifiedName); - }; - /** - * Produces an XML serialization of a document node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_4, _a; - /** - * If the require well-formed flag is set (its value is true), and this node - * has no documentElement (the documentElement attribute's value is null), - * then throw an exception; the serialization of this node would not be a - * well-formed document. - */ - if (requireWellFormed && node.documentElement === null) { - throw new Error("Missing document element (well-formed required)."); + } + 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(XMLDocType.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; + } } - try { - /** - * Otherwise, run the following steps: - * 1. Let serialized document be an empty string. - * 2. For each child child of node, in tree order, run the XML - * serialization algorithm on the child passing along the provided - * arguments, and append the result to serialized document. - * - * _Note:_ This will serialize any number of ProcessingInstruction and - * Comment nodes both before and after the Document's documentElement node, - * including at most one DocumentType node. (Text nodes are not allowed as - * children of the Document.) - * - * 3. Return the value of serialized document. - */ - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - } + return new XMLNamedNodeMap(nodes); + } + }); + + Object.defineProperty(XMLDocType.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; + } } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_4) throw e_4.error; } + return new XMLNamedNodeMap(nodes); + } + }); + + Object.defineProperty(XMLDocType.prototype, 'publicId', { + get: function() { + return this.pubID; + } + }); + + Object.defineProperty(XMLDocType.prototype, 'systemId', { + get: function() { + return this.sysID; + } + }); + + Object.defineProperty(XMLDocType.prototype, 'internalSubset', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + XMLDocType.prototype.element = function(name, value) { + var child; + child = new XMLDTDElement(this, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.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; + }; + + XMLDocType.prototype.entity = function(name, value) { + var child; + child = new XMLDTDEntity(this, false, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.pEntity = function(name, value) { + var child; + child = new XMLDTDEntity(this, true, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.notation = function(name, value) { + var child; + child = new XMLDTDNotation(this, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.toString = function(options) { + return this.options.writer.docType(this, this.options.writer.filterOptions(options)); + }; + + XMLDocType.prototype.ele = function(name, value) { + return this.element(name, value); + }; + + XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); + }; + + XMLDocType.prototype.ent = function(name, value) { + return this.entity(name, value); + }; + + XMLDocType.prototype.pent = function(name, value) { + return this.pEntity(name, value); + }; + + XMLDocType.prototype.not = function(name, value) { + return this.notation(name, value); + }; + + XMLDocType.prototype.up = function() { + return this.root() || this.documentObject; + }; + + XMLDocType.prototype.isEqualNode = function(node) { + if (!XMLDocType.__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 XMLDocType; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 3730: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = (__nccwpck_require__(8229).isPlainObject); + + XMLDOMImplementation = __nccwpck_require__(8310); + + XMLDOMConfiguration = __nccwpck_require__(7465); + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + XMLStringifier = __nccwpck_require__(8594); + + XMLStringWriter = __nccwpck_require__(5913); + + module.exports = XMLDocument = (function(superClass) { + extend(XMLDocument, superClass); + + function XMLDocument(options) { + XMLDocument.__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(XMLDocument.prototype, 'implementation', { + value: new XMLDOMImplementation() + }); + + Object.defineProperty(XMLDocument.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; + } } - }; - /** - * Produces an XML serialization of a document node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocument = function (node, requireWellFormed, noDoubleEncoding) { - var e_5, _a; - /** - * If the require well-formed flag is set (its value is true), and this node - * has no documentElement (the documentElement attribute's value is null), - * then throw an exception; the serialization of this node would not be a - * well-formed document. - */ - if (requireWellFormed && node.documentElement === null) { - throw new Error("Missing document element (well-formed required)."); + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'documentElement', { + get: function() { + return this.rootObject || null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'inputEncoding', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', { + get: function() { + return false; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', { + get: function() { + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { + return this.children[0].encoding; + } else { + return null; } - try { - /** - * Otherwise, run the following steps: - * 1. Let serialized document be an empty string. - * 2. For each child child of node, in tree order, run the XML - * serialization algorithm on the child passing along the provided - * arguments, and append the result to serialized document. - * - * _Note:_ This will serialize any number of ProcessingInstruction and - * Comment nodes both before and after the Document's documentElement node, - * including at most one DocumentType node. (Text nodes are not allowed as - * children of the Document.) - * - * 3. Return the value of serialized document. - */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); - } + } + }); + + Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', { + get: function() { + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { + return this.children[0].standalone === 'yes'; + } else { + return false; } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_5) throw e_5.error; } + } + }); + + Object.defineProperty(XMLDocument.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(XMLDocument.prototype, 'URL', { + get: function() { + return this.documentURI; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'origin', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'compatMode', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'characterSet', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'contentType', { + get: function() { + return null; + } + }); + + XMLDocument.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)); }; - /** - * Produces an XML serialization of a comment node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeComment = function (node, requireWellFormed, noDoubleEncoding) { - /** - * If the require well-formed flag is set (its value is true), and node's - * data contains characters that are not matched by the XML Char production - * or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that - * ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception; - * the serialization of this node's data would not be well-formed. - */ - if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || - node.data.indexOf("--") !== -1 || node.data.endsWith("-"))) { - throw new Error("Comment data contains invalid characters (well-formed required)."); - } - /** - * Otherwise, return the concatenation of "". - */ - this.comment(node.data); + + XMLDocument.prototype.toString = function(options) { + return this.options.writer.document(this, this.options.writer.filterOptions(options)); + }; + + XMLDocument.prototype.createElement = function(tagName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createDocumentFragment = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createTextNode = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createComment = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createCDATASection = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createProcessingInstruction = function(target, data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createAttribute = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createEntityReference = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementsByTagName = function(tagname) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.importNode = function(importedNode, deep) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementById = function(elementId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.adoptNode = function(source) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.normalizeDocument = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementsByClassName = function(classNames) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createEvent = function(eventInterface) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createRange = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces an XML serialization of a text node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - * @param level - current depth of the XML tree - */ - BaseWriter.prototype._serializeText = function (node, requireWellFormed, noDoubleEncoding) { - /** - * 1. If the require well-formed flag is set (its value is true), and - * node's data contains characters that are not matched by the XML Char - * production, then throw an exception; the serialization of this node's - * data would not be well-formed. - */ - if (requireWellFormed && !algorithm_1.xml_isLegalChar(node.data)) { - throw new Error("Text data contains invalid characters (well-formed required)."); - } - /** - * 2. Let markup be the value of node's data. - * 3. Replace any occurrences of "&" in markup by "&". - * 4. Replace any occurrences of "<" in markup by "<". - * 5. Replace any occurrences of ">" in markup by ">". - * 6. Return the value of markup. - */ - var markup = ""; - if (noDoubleEncoding) { - markup = node.data.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>'); - } - else { - for (var i = 0; i < node.data.length; i++) { - var c = node.data[i]; - if (c === "&") - markup += "&"; - else if (c === "<") - markup += "<"; - else if (c === ">") - markup += ">"; - else - markup += c; - } - } - this.text(markup); + + XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces an XML serialization of a document fragment node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentFragmentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_6, _a; - try { - /** - * 1. Let markup the empty string. - * 2. For each child child of node, in tree order, run the XML serialization - * algorithm on the child given namespace, prefix map, a reference to prefix - * index, and flag require well-formed. Concatenate the result to markup. - * 3. Return the value of markup. - */ - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - } - } - catch (e_6_1) { e_6 = { error: e_6_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_6) throw e_6.error; } + + return XMLDocument; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 7356: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue; + + NodeType = __nccwpck_require__(9267); + + XMLDocument = __nccwpck_require__(3730); + + XMLElement = __nccwpck_require__(9437); + + XMLCData = __nccwpck_require__(333); + + XMLComment = __nccwpck_require__(4407); + + XMLRaw = __nccwpck_require__(6329); + + XMLText = __nccwpck_require__(1318); + + XMLProcessingInstruction = __nccwpck_require__(6939); + + XMLDeclaration = __nccwpck_require__(6364); + + XMLDocType = __nccwpck_require__(1801); + + XMLDTDAttList = __nccwpck_require__(1015); + + XMLDTDEntity = __nccwpck_require__(53); + + XMLDTDElement = __nccwpck_require__(2421); + + XMLDTDNotation = __nccwpck_require__(2837); + + XMLAttribute = __nccwpck_require__(8376); + + XMLStringifier = __nccwpck_require__(8594); + + XMLStringWriter = __nccwpck_require__(5913); + + WriterState = __nccwpck_require__(9766); + + module.exports = XMLDocumentCB = (function() { + function XMLDocumentCB(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; + } + + XMLDocumentCB.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; }; - /** - * Produces an XML serialization of a document fragment node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentFragment = function (node, requireWellFormed, noDoubleEncoding) { - var e_7, _a; - try { - /** - * 1. Let markup the empty string. - * 2. For each child child of node, in tree order, run the XML serialization - * algorithm on the child given namespace, prefix map, a reference to prefix - * index, and flag require well-formed. Concatenate the result to markup. - * 3. Return the value of markup. - */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); - } - } - catch (e_7_1) { e_7 = { error: e_7_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + + XMLDocumentCB.prototype.dummy = function() { + return this; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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(); } - finally { if (e_7) throw e_7.error; } + } + } else { + this.node(name, attributes, text); } + } + return this; }; - /** - * Produces an XML serialization of a document type node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentType = function (node, requireWellFormed, noDoubleEncoding) { - /** - * 1. If the require well-formed flag is true and the node's publicId - * attribute contains characters that are not matched by the XML PubidChar - * production, then throw an exception; the serialization of this node - * would not be a well-formed document type declaration. - */ - if (requireWellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { - throw new Error("DocType public identifier does not match PubidChar construct (well-formed required)."); + + XMLDocumentCB.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); } - /** - * 2. If the require well-formed flag is true and the node's systemId - * attribute contains characters that are not matched by the XML Char - * production or that contains both a """ (U+0022 QUOTATION MARK) and a - * "'" (U+0027 APOSTROPHE), then throw an exception; the serialization - * of this node would not be a well-formed document type declaration. - */ - if (requireWellFormed && - (!algorithm_1.xml_isLegalChar(node.systemId) || - (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { - throw new Error("DocType system identifier contains invalid characters (well-formed required)."); + } else { + if (isFunction(value)) { + value = value.apply(); } - /** - * 3. Let markup be an empty string. - * 4. Append the string "" (U+003E GREATER-THAN SIGN) to markup. - * 11. Return the value of markup. - */ - this.docType(node.name, node.publicId, node.systemId); + 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; }; - /** - * Produces an XML serialization of a processing instruction node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeProcessingInstruction = function (node, requireWellFormed, noDoubleEncoding) { - /** - * 1. If the require well-formed flag is set (its value is true), and node's - * target contains a ":" (U+003A COLON) character or is an ASCII - * case-insensitive match for the string "xml", then throw an exception; - * the serialization of this node's target would not be well-formed. - */ - if (requireWellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { - throw new Error("Processing instruction target contains invalid characters (well-formed required)."); + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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); } - /** - * 2. If the require well-formed flag is set (its value is true), and node's - * data contains characters that are not matched by the XML Char production - * or contains the string "?>" (U+003F QUESTION MARK, - * U+003E GREATER-THAN SIGN), then throw an exception; the serialization of - * this node's data would not be well-formed. - */ - if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || - node.data.indexOf("?>") !== -1)) { - throw new Error("Processing instruction data contains invalid characters (well-formed required)."); + } else if (isObject(target)) { + for (insTarget in target) { + if (!hasProp.call(target, insTarget)) continue; + insValue = target[insTarget]; + this.instruction(insTarget, insValue); } - /** - * 3. Let markup be the concatenation of the following, in the order listed: - * 3.1. "" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN). - * 4. Return the value of markup. - */ - this.instruction(node.target, node.data); + } 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; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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; }; - /** - * Produces an XML serialization of a CDATA node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeCData = function (node, requireWellFormed, noDoubleEncoding) { - if (requireWellFormed && (node.data.indexOf("]]>") !== -1)) { - throw new Error("CDATA contains invalid characters (well-formed required)."); + + XMLDocumentCB.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; + }; + + XMLDocumentCB.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.cdata(node.data); + this.currentNode = null; + } else { + this.closeNode(this.openTags[this.currentLevel]); + } + delete this.openTags[this.currentLevel]; + this.currentLevel--; + return this; }; - /** - * Produces an XML serialization of the attributes of an element node. - * - * @param node - node to serialize - * @param map - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param localPrefixesMap - local prefixes map - * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace - * attributes - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributesNS = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding) { - var e_8, _a; - /** - * 1. Let result be the empty string. - * 2. Let localname set be a new empty namespace localname set. This - * localname set will contain tuples of unique attribute namespaceURI and - * localName pairs, and is populated as each attr is processed. This set is - * used to [optionally] enforce the well-formed constraint that an element - * cannot have two attributes with the same namespaceURI and localName. - * This can occur when two otherwise identical attributes on the same - * element differ only by their prefix values. - */ - var result = []; - var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; - try { - /** - * 3. Loop: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: - */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - // Optimize common case - if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - continue; - } - /** - * 3.1. If the require well-formed flag is set (its value is true), and the - * localname set contains a tuple whose values match those of a new tuple - * consisting of attr's namespaceURI attribute and localName attribute, - * then throw an exception; the serialization of this attr would fail to - * produce a well-formed element serialization. - */ - if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { - throw new Error("Element contains duplicate attributes (well-formed required)."); - } - /** - * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and - * localName attribute, and add it to the localname set. - * 3.3. Let attribute namespace be the value of attr's namespaceURI value. - * 3.4. Let candidate prefix be null. - */ - if (requireWellFormed && localNameSet) - localNameSet.set(attr.namespaceURI, attr.localName); - var attributeNamespace = attr.namespaceURI; - var candidatePrefix = null; - /** 3.5. If attribute namespace is not null, then run these sub-steps: */ - if (attributeNamespace !== null) { - /** - * 3.5.1. Let candidate prefix be the result of retrieving a preferred - * prefix string from map given namespace attribute namespace with - * preferred prefix being attr's prefix value. - */ - candidatePrefix = map.get(attr.prefix, attributeNamespace); - /** - * 3.5.2. If the value of attribute namespace is the XMLNS namespace, - * then run these steps: - */ - if (attributeNamespace === infra_1.namespace.XMLNS) { - /** - * 3.5.2.1. If any of the following are true, then stop running these - * steps and goto Loop to visit the next attribute: - * - the attr's value is the XML namespace; - * _Note:_ The XML namespace cannot be redeclared and survive - * round-tripping (unless it defines the prefix "xml"). To avoid this - * problem, this algorithm always prefixes elements in the XML - * namespace with "xml" and drops any related definitions as seen - * in the above condition. - * - the attr's prefix is null and the ignore namespace definition - * attribute flag is true (the Element's default namespace attribute - * should be skipped); - * - the attr's prefix is not null and either - * * the attr's localName is not a key contained in the local - * prefixes map, or - * * the attr's localName is present in the local prefixes map but - * the value of the key does not match attr's value - * and furthermore that the attr's localName (as the prefix to find) - * is found in the namespace prefix map given the namespace consisting - * of the attr's value (the current namespace prefix definition was - * exactly defined previously--on an ancestor element not the current - * element whose attributes are being processed). - */ - if (attr.value === infra_1.namespace.XML || - (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || - (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || - localPrefixesMap[attr.localName] !== attr.value) && - map.has(attr.localName, attr.value))) - continue; - /** - * 3.5.2.2. If the require well-formed flag is set (its value is true), - * and the value of attr's value attribute matches the XMLNS - * namespace, then throw an exception; the serialization of this - * attribute would produce invalid XML because the XMLNS namespace - * is reserved and cannot be applied as an element's namespace via - * XML parsing. - * - * _Note:_ DOM APIs do allow creation of elements in the XMLNS - * namespace but with strict qualifications. - */ - if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { - throw new Error("XMLNS namespace is reserved (well-formed required)."); - } - /** - * 3.5.2.3. If the require well-formed flag is set (its value is true), - * and the value of attr's value attribute is the empty string, then - * throw an exception; namespace prefix declarations cannot be used - * to undeclare a namespace (use a default namespace declaration - * instead). - */ - if (requireWellFormed && attr.value === '') { - throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required)."); - } - /** - * 3.5.2.4. the attr's prefix matches the string "xmlns", then let - * candidate prefix be the string "xmlns". - */ - if (attr.prefix === 'xmlns') - candidatePrefix = 'xmlns'; - /** - * 3.5.3. Otherwise, the attribute namespace is not the XMLNS namespace. - * Run these steps: - * - * _Note:_ The (candidatePrefix === null) check is not in the spec. - * We deviate from the spec here. Otherwise a prefix is generated for - * all attributes with namespaces. - */ - } - else if (candidatePrefix === null) { - if (attr.prefix !== null && - (!map.hasPrefix(attr.prefix) || - map.has(attr.prefix, attributeNamespace))) { - /** - * Check if we can use the attribute's own prefix. - * We deviate from the spec here. - * TODO: This is not an efficient way of searching for prefixes. - * Follow developments to the spec. - */ - candidatePrefix = attr.prefix; - } - else { - /** - * 3.5.3.1. Let candidate prefix be the result of generating a prefix - * providing map, attribute namespace, and prefix index as input. - */ - candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); - } - /** - * 3.5.3.2. Append the following to result, in the order listed: - * 3.5.3.2.1. " " (U+0020 SPACE); - * 3.5.3.2.2. The string "xmlns:"; - * 3.5.3.2.3. The value of candidate prefix; - * 3.5.3.2.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.5.3.2.5. The result of serializing an attribute value given - * attribute namespace and the require well-formed flag as input; - * 3.5.3.2.6. """ (U+0022 QUOTATION MARK). - */ - result.push([null, "xmlns", candidatePrefix, - this._serializeAttributeValue(attributeNamespace, requireWellFormed, noDoubleEncoding)]); - } - } - /** - * 3.6. Append a " " (U+0020 SPACE) to result. - * 3.7. If candidate prefix is not null, then append to result the - * concatenation of candidate prefix with ":" (U+003A COLON). - */ - var attrName = ''; - if (candidatePrefix !== null) { - attrName = candidatePrefix; - } - /** - * 3.8. If the require well-formed flag is set (its value is true), and - * this attr's localName attribute contains the character - * ":" (U+003A COLON) or does not match the XML Name production or - * equals "xmlns" and attribute namespace is null, then throw an - * exception; the serialization of this attr would not be a - * well-formed attribute. - */ - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName) || - (attr.localName === "xmlns" && attributeNamespace === null))) { - throw new Error("Attribute local name contains invalid characters (well-formed required)."); - } - /** - * 3.9. Append the following strings to result, in the order listed: - * 3.9.1. The value of attr's localName; - * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.9.3. The result of serializing an attribute value given attr's value - * attribute and the require well-formed flag as input; - * 3.9.4. """ (U+0022 QUOTATION MARK). - */ - result.push([attributeNamespace, candidatePrefix, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - } + + XMLDocumentCB.prototype.end = function() { + while (this.currentLevel >= 0) { + this.up(); + } + return this.onEnd(); + }; + + XMLDocumentCB.prototype.openCurrent = function() { + if (this.currentNode) { + this.currentNode.children = true; + return this.openNode(this.currentNode); + } + }; + + XMLDocumentCB.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; } - catch (e_8_1) { e_8 = { error: e_8_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_8) throw e_8.error; } + 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) + ''; + } + chunk += this.writer.endline(node, this.writerOptions, this.currentLevel); } - /** - * 4. Return the value of result. - */ - return result; + this.onData(chunk, this.currentLevel); + return node.isOpen = true; + } }; - /** - * Produces an XML serialization of the attributes of an element node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributes = function (node, requireWellFormed, noDoubleEncoding) { - var e_9, _a; - /** - * 1. Let result be the empty string. - * 2. Let localname set be a new empty namespace localname set. This - * localname set will contain tuples of unique attribute namespaceURI and - * localName pairs, and is populated as each attr is processed. This set is - * used to [optionally] enforce the well-formed constraint that an element - * cannot have two attributes with the same namespaceURI and localName. - * This can occur when two otherwise identical attributes on the same - * element differ only by their prefix values. - */ - var result = []; - var localNameSet = requireWellFormed ? {} : undefined; - try { - /** - * 3. Loop: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: - */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - // Optimize common case - if (!requireWellFormed) { - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - continue; - } - /** - * 3.1. If the require well-formed flag is set (its value is true), and the - * localname set contains a tuple whose values match those of a new tuple - * consisting of attr's namespaceURI attribute and localName attribute, - * then throw an exception; the serialization of this attr would fail to - * produce a well-formed element serialization. - */ - if (requireWellFormed && localNameSet && (attr.localName in localNameSet)) { - throw new Error("Element contains duplicate attributes (well-formed required)."); - } - /** - * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and - * localName attribute, and add it to the localname set. - * 3.3. Let attribute namespace be the value of attr's namespaceURI value. - * 3.4. Let candidate prefix be null. - */ - /* istanbul ignore else */ - if (requireWellFormed && localNameSet) - localNameSet[attr.localName] = true; - /** 3.5. If attribute namespace is not null, then run these sub-steps: */ - /** - * 3.6. Append a " " (U+0020 SPACE) to result. - * 3.7. If candidate prefix is not null, then append to result the - * concatenation of candidate prefix with ":" (U+003A COLON). - */ - /** - * 3.8. If the require well-formed flag is set (its value is true), and - * this attr's localName attribute contains the character - * ":" (U+003A COLON) or does not match the XML Name production or - * equals "xmlns" and attribute namespace is null, then throw an - * exception; the serialization of this attr would not be a - * well-formed attribute. - */ - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName))) { - throw new Error("Attribute local name contains invalid characters (well-formed required)."); - } - /** - * 3.9. Append the following strings to result, in the order listed: - * 3.9.1. The value of attr's localName; - * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.9.3. The result of serializing an attribute value given attr's value - * attribute and the require well-formed flag as input; - * 3.9.4. """ (U+0022 QUOTATION MARK). - */ - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - } - } - catch (e_9_1) { e_9 = { error: e_9_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_9) throw e_9.error; } + + XMLDocumentCB.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) + '' + 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); } - /** - * 4. Return the value of result. - */ - return result; + this.writerOptions.state = WriterState.None; + this.onData(chunk, this.currentLevel); + return node.isClosed = true; + } + }; + + XMLDocumentCB.prototype.onData = function(chunk, level) { + this.documentStarted = true; + return this.onDataCallback(chunk, level + 1); + }; + + XMLDocumentCB.prototype.onEnd = function() { + this.documentCompleted = true; + return this.onEndCallback(); + }; + + XMLDocumentCB.prototype.debugInfo = function(name) { + if (name == null) { + return ""; + } else { + return "node: <" + name + ">"; + } + }; + + XMLDocumentCB.prototype.ele = function() { + return this.element.apply(this, arguments); + }; + + XMLDocumentCB.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLDocumentCB.prototype.txt = function(value) { + return this.text(value); + }; + + XMLDocumentCB.prototype.dat = function(value) { + return this.cdata(value); + }; + + XMLDocumentCB.prototype.com = function(value) { + return this.comment(value); + }; + + XMLDocumentCB.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + + XMLDocumentCB.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); + }; + + XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) { + return this.doctype(root, pubID, sysID); + }; + + XMLDocumentCB.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + + XMLDocumentCB.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLDocumentCB.prototype.t = function(value) { + return this.text(value); + }; + + XMLDocumentCB.prototype.d = function(value) { + return this.cdata(value); + }; + + XMLDocumentCB.prototype.c = function(value) { + return this.comment(value); + }; + + XMLDocumentCB.prototype.r = function(value) { + return this.raw(value); + }; + + XMLDocumentCB.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + + XMLDocumentCB.prototype.att = function() { + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + return this.attList.apply(this, arguments); + } else { + return this.attribute.apply(this, arguments); + } + }; + + XMLDocumentCB.prototype.a = function() { + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + return this.attList.apply(this, arguments); + } else { + return this.attribute.apply(this, arguments); + } + }; + + XMLDocumentCB.prototype.ent = function(name, value) { + return this.entity(name, value); + }; + + XMLDocumentCB.prototype.pent = function(name, value) { + return this.pEntity(name, value); }; - /** - * Records namespace information for the given element and returns the - * default namespace attribute value. - * - * @param node - element node to process - * @param map - namespace prefix map - * @param localPrefixesMap - local prefixes map - */ - BaseWriter.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { - var e_10, _a; - /** - * 1. Let default namespace attr value be null. - */ - var defaultNamespaceAttrValue = null; - try { - /** - * 2. Main: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: - */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - /** - * _Note:_ The following conditional steps find namespace prefixes. Only - * attributes in the XMLNS namespace are considered (e.g., attributes made - * to look like namespace declarations via - * setAttribute("xmlns:pretend-prefix", "pretend-namespace") are not - * included). - */ - /** 2.1. Let attribute namespace be the value of attr's namespaceURI value. */ - var attributeNamespace = attr.namespaceURI; - /** 2.2. Let attribute prefix be the value of attr's prefix. */ - var attributePrefix = attr.prefix; - /** 2.3. If the attribute namespace is the XMLNS namespace, then: */ - if (attributeNamespace === infra_1.namespace.XMLNS) { - /** - * 2.3.1. If attribute prefix is null, then attr is a default namespace - * declaration. Set the default namespace attr value to attr's value and - * stop running these steps, returning to Main to visit the next - * attribute. - */ - if (attributePrefix === null) { - defaultNamespaceAttrValue = attr.value; - continue; - /** - * 2.3.2. Otherwise, the attribute prefix is not null and attr is a - * namespace prefix definition. Run the following steps: - */ - } - else { - /** 2.3.2.1. Let prefix definition be the value of attr's localName. */ - var prefixDefinition = attr.localName; - /** 2.3.2.2. Let namespace definition be the value of attr's value. */ - var namespaceDefinition = attr.value; - /** - * 2.3.2.3. If namespace definition is the XML namespace, then stop - * running these steps, and return to Main to visit the next - * attribute. - * - * _Note:_ XML namespace definitions in prefixes are completely - * ignored (in order to avoid unnecessary work when there might be - * prefix conflicts). XML namespaced elements are always handled - * uniformly by prefixing (and overriding if necessary) the element's - * localname with the reserved "xml" prefix. - */ - if (namespaceDefinition === infra_1.namespace.XML) { - continue; - } - /** - * 2.3.2.4. If namespace definition is the empty string (the - * declarative form of having no namespace), then let namespace - * definition be null instead. - */ - if (namespaceDefinition === '') { - namespaceDefinition = null; - } - /** - * 2.3.2.5. If prefix definition is found in map given the namespace - * namespace definition, then stop running these steps, and return to - * Main to visit the next attribute. - * - * _Note:_ This step avoids adding duplicate prefix definitions for - * the same namespace in the map. This has the side-effect of avoiding - * later serialization of duplicate namespace prefix declarations in - * any descendant nodes. - */ - if (map.has(prefixDefinition, namespaceDefinition)) { - continue; - } - /** - * 2.3.2.6. Add the prefix prefix definition to map given namespace - * namespace definition. - */ - map.set(prefixDefinition, namespaceDefinition); - /** - * 2.3.2.7. Add the value of prefix definition as a new key to the - * local prefixes map, with the namespace definition as the key's - * value replacing the value of null with the empty string if - * applicable. - */ - localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; - } - } + + XMLDocumentCB.prototype.not = function(name, value) { + return this.notation(name, value); + }; + + return XMLDocumentCB; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 3590: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDummy = (function(superClass) { + extend(XMLDummy, superClass); + + function XMLDummy(parent) { + XMLDummy.__super__.constructor.call(this, parent); + this.type = NodeType.Dummy; + } + + XMLDummy.prototype.clone = function() { + return Object.create(this); + }; + + XMLDummy.prototype.toString = function(options) { + return ''; + }; + + return XMLDummy; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 9437: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue; + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + XMLAttribute = __nccwpck_require__(8376); + + XMLNamedNodeMap = __nccwpck_require__(4361); + + module.exports = XMLElement = (function(superClass) { + extend(XMLElement, superClass); + + function XMLElement(parent, name, attributes) { + var child, j, len, ref1; + XMLElement.__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; } + } } - catch (e_10_1) { e_10 = { error: e_10_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_10) throw e_10.error; } + } + } + + Object.defineProperty(XMLElement.prototype, 'tagName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLElement.prototype, 'namespaceURI', { + get: function() { + return ''; + } + }); + + Object.defineProperty(XMLElement.prototype, 'prefix', { + get: function() { + return ''; + } + }); + + Object.defineProperty(XMLElement.prototype, 'localName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLElement.prototype, 'id', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'className', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'classList', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'attributes', { + get: function() { + if (!this.attributeMap || !this.attributeMap.nodes) { + this.attributeMap = new XMLNamedNodeMap(this.attribs); } - /** - * 3. Return the value of default namespace attr value. - * - * _Note:_ The empty string is a legitimate return value and is not - * converted to null. - */ - return defaultNamespaceAttrValue; - }; - /** - * Generates a new prefix for the given namespace. - * - * @param newNamespace - a namespace to generate prefix for - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - */ - BaseWriter.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { - /** - * 1. Let generated prefix be the concatenation of the string "ns" and the - * current numerical value of prefix index. - * 2. Let the value of prefix index be incremented by one. - * 3. Add to map the generated prefix given the new namespace namespace. - * 4. Return the value of generated prefix. - */ - var generatedPrefix = "ns" + prefixIndex.value.toString(); - prefixIndex.value++; - prefixMap.set(generatedPrefix, newNamespace); - return generatedPrefix; + return this.attributeMap; + } + }); + + XMLElement.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; }; - /** - * Produces an XML serialization of an attribute value. - * - * @param value - attribute value - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributeValue = function (value, requireWellFormed, noDoubleEncoding) { - /** - * From: https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value - * - * 1. If the require well-formed flag is set (its value is true), and - * attribute value contains characters that are not matched by the XML Char - * production, then throw an exception; the serialization of this attribute - * value would fail to produce a well-formed element serialization. - */ - if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { - throw new Error("Invalid characters in attribute value."); + + XMLElement.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); } - /** - * 2. If attribute value is null, then return the empty string. - */ - if (value === null) - return ""; - /** - * 3. Otherwise, attribute value is a string. Return the value of attribute - * value, first replacing any occurrences of the following: - * - "&" with "&" - * - """ with """ - * - "<" with "<" - * - ">" with ">" - * NOTE - * This matches behavior present in browsers, and goes above and beyond the - * grammar requirement in the XML specification's AttValue production by - * also replacing ">" characters. - */ - if (noDoubleEncoding) { - return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); + } else { + if (isFunction(value)) { + value = value.apply(); } - else { - var result = ""; - for (var i = 0; i < value.length; i++) { - var c = value[i]; - if (c === "\"") - result += """; - else if (c === "&") - result += "&"; - else if (c === "<") - result += "<"; - else if (c === ">") - result += ">"; - else - result += c; - } - return result; + 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; + }; + + XMLElement.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; + }; + + XMLElement.prototype.toString = function(options) { + return this.options.writer.element(this, this.options.writer.filterOptions(options)); + }; + + XMLElement.prototype.att = function(name, value) { + return this.attribute(name, value); + }; + + XMLElement.prototype.a = function(name, value) { + return this.attribute(name, value); + }; + + XMLElement.prototype.getAttribute = function(name) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name].value; + } else { + return null; + } + }; + + XMLElement.prototype.setAttribute = function(name, value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getAttributeNode = function(name) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name]; + } else { + return null; + } + }; + + XMLElement.prototype.setAttributeNode = function(newAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.removeAttributeNode = function(oldAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getElementsByTagName = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.setAttributeNodeNS = function(newAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.hasAttribute = function(name) { + return this.attribs.hasOwnProperty(name); + }; + + XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.setIdAttribute = function(name, isId) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name].isId; + } else { + return isId; + } + }; + + XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getElementsByTagName = function(tagname) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getElementsByClassName = function(classNames) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.isEqualNode = function(node) { + var i, j, ref1; + if (!XMLElement.__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; }; - BaseWriter._VoidElementNames = new Set(['area', 'base', 'basefont', - 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', - 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); - return BaseWriter; -}()); -exports.BaseWriter = BaseWriter; -//# sourceMappingURL=BaseWriter.js.map + + return XMLElement; + + })(XMLNode); + +}).call(this); + /***/ }), -/***/ 7525: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 4361: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLNamedNodeMap; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var BaseCBWriter_1 = __nccwpck_require__(708); -/** - * Serializes XML nodes. - */ -var JSONCBWriter = /** @class */ (function (_super) { - __extends(JSONCBWriter, _super); - /** - * Initializes a new instance of `JSONCBWriter`. - * - * @param builderOptions - XML builder options - */ - function JSONCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._hasChildren = []; - _this._additionalLevel = 0; - return _this; + module.exports = XMLNamedNodeMap = (function() { + function XMLNamedNodeMap(nodes) { + this.nodes = nodes; } - /** @inheritdoc */ - JSONCBWriter.prototype.frontMatter = function () { - return ""; - }; - /** @inheritdoc */ - JSONCBWriter.prototype.declaration = function (version, encoding, standalone) { - return ""; + + Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { + get: function() { + return Object.keys(this.nodes).length || 0; + } + }); + + XMLNamedNodeMap.prototype.clone = function() { + return this.nodes = null; }; - /** @inheritdoc */ - JSONCBWriter.prototype.docType = function (name, publicId, systemId) { - return ""; + + XMLNamedNodeMap.prototype.getNamedItem = function(name) { + return this.nodes[name]; }; - /** @inheritdoc */ - JSONCBWriter.prototype.comment = function (data) { - // { "!": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.comment) + this._sep() + - this._val(data) + this._sep() + "}"; + + XMLNamedNodeMap.prototype.setNamedItem = function(node) { + var oldNode; + oldNode = this.nodes[node.nodeName]; + this.nodes[node.nodeName] = node; + return oldNode || null; }; - /** @inheritdoc */ - JSONCBWriter.prototype.text = function (data) { - // { "#": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.text) + this._sep() + - this._val(data) + this._sep() + "}"; + + XMLNamedNodeMap.prototype.removeNamedItem = function(name) { + var oldNode; + oldNode = this.nodes[name]; + delete this.nodes[name]; + return oldNode || null; }; - /** @inheritdoc */ - JSONCBWriter.prototype.instruction = function (target, data) { - // { "?": "target hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.ins) + this._sep() + - this._val(data ? target + " " + data : target) + this._sep() + "}"; + + XMLNamedNodeMap.prototype.item = function(index) { + return this.nodes[Object.keys(this.nodes)[index]] || null; }; - /** @inheritdoc */ - JSONCBWriter.prototype.cdata = function (data) { - // { "$": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.cdata) + this._sep() + - this._val(data) + this._sep() + "}"; + + XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented."); }; - /** @inheritdoc */ - JSONCBWriter.prototype.attribute = function (name, value) { - // { "@name": "val" } - return this._comma() + this._beginLine(1) + "{" + this._sep() + - this._key(this._builderOptions.convert.att + name) + this._sep() + - this._val(value) + this._sep() + "}"; + + XMLNamedNodeMap.prototype.setNamedItemNS = function(node) { + throw new Error("This DOM method is not implemented."); }; - /** @inheritdoc */ - JSONCBWriter.prototype.openTagBegin = function (name) { - // { "node": { "#": [ - var str = this._comma() + this._beginLine() + "{" + this._sep() + this._key(name) + this._sep() + "{"; - this._additionalLevel++; - this.hasData = true; - str += this._beginLine() + this._key(this._builderOptions.convert.text) + this._sep() + "["; - this._hasChildren.push(false); - return str; + + XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented."); }; - /** @inheritdoc */ - JSONCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (selfClosing) { - var str = this._sep() + "]"; - this._additionalLevel--; - str += this._beginLine() + "}" + this._sep() + "}"; - return str; + + return XMLNamedNodeMap; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 7608: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1, + hasProp = {}.hasOwnProperty; + + ref1 = __nccwpck_require__(8229), 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; + + module.exports = XMLNode = (function() { + function XMLNode(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 = __nccwpck_require__(9437); + XMLCData = __nccwpck_require__(333); + XMLComment = __nccwpck_require__(4407); + XMLDeclaration = __nccwpck_require__(6364); + XMLDocType = __nccwpck_require__(1801); + XMLRaw = __nccwpck_require__(6329); + XMLText = __nccwpck_require__(1318); + XMLProcessingInstruction = __nccwpck_require__(6939); + XMLDummy = __nccwpck_require__(3590); + NodeType = __nccwpck_require__(9267); + XMLNodeList = __nccwpck_require__(6768); + XMLNamedNodeMap = __nccwpck_require__(4361); + DocumentPosition = __nccwpck_require__(2839); + } + } + + Object.defineProperty(XMLNode.prototype, 'nodeName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLNode.prototype, 'nodeType', { + get: function() { + return this.type; + } + }); + + Object.defineProperty(XMLNode.prototype, 'nodeValue', { + get: function() { + return this.value; + } + }); + + Object.defineProperty(XMLNode.prototype, 'parentNode', { + get: function() { + return this.parent; + } + }); + + Object.defineProperty(XMLNode.prototype, 'childNodes', { + get: function() { + if (!this.childNodeList || !this.childNodeList.nodes) { + this.childNodeList = new XMLNodeList(this.children); } - else { - return ""; + return this.childNodeList; + } + }); + + Object.defineProperty(XMLNode.prototype, 'firstChild', { + get: function() { + return this.children[0] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'lastChild', { + get: function() { + return this.children[this.children.length - 1] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'previousSibling', { + get: function() { + var i; + i = this.parent.children.indexOf(this); + return this.parent.children[i - 1] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'nextSibling', { + get: function() { + var i; + i = this.parent.children.indexOf(this); + return this.parent.children[i + 1] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'ownerDocument', { + get: function() { + return this.document() || null; + } + }); + + Object.defineProperty(XMLNode.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()); + } + }); + + XMLNode.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; }; - /** @inheritdoc */ - JSONCBWriter.prototype.closeTag = function (name) { - // ] } } - var str = this._beginLine() + "]"; - this._additionalLevel--; - str += this._beginLine() + "}" + this._sep() + "}"; - return str; - }; - /** @inheritdoc */ - JSONCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - JSONCBWriter.prototype.endElement = function (name) { this._hasChildren.pop(); }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - JSONCBWriter.prototype._beginLine = function (additionalOffset) { - if (additionalOffset === void 0) { additionalOffset = 0; } - if (this._writerOptions.prettyPrint) { - return (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level + additionalOffset); - } - else { - return ""; + + XMLNode.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); } - }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - */ - JSONCBWriter.prototype._indent = function (level) { - if (level + this._additionalLevel <= 0) { - return ""; + } 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 { - return this._writerOptions.indent.repeat(level + this._additionalLevel); + } 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; }; - /** - * Produces a comma before a child node if it has previous siblings. - */ - JSONCBWriter.prototype._comma = function () { - var str = (this._hasChildren[this._hasChildren.length - 1] ? "," : ""); - if (this._hasChildren.length > 0) { - this._hasChildren[this._hasChildren.length - 1] = true; + + XMLNode.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 str; - }; - /** - * Produces a separator string. - */ - JSONCBWriter.prototype._sep = function () { - return (this._writerOptions.prettyPrint ? " " : ""); - }; - /** - * Produces a JSON key string delimited with double quotes. - */ - JSONCBWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + 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; + } }; - /** - * Produces a JSON value string delimited with double quotes. - */ - JSONCBWriter.prototype._val = function (val) { - return JSON.stringify(val); + + XMLNode.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; }; - return JSONCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.JSONCBWriter = JSONCBWriter; -//# sourceMappingURL=JSONCBWriter.js.map -/***/ }), + XMLNode.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; + }; -/***/ 7510: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLNode.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; + }; -"use strict"; + XMLNode.prototype.text = function(value) { + var child; + if (isObject(value)) { + this.element(value); + } + child = new XMLText(this, value); + this.children.push(child); + return this; + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLNode.prototype.cdata = function(value) { + var child; + child = new XMLCData(this, value); + this.children.push(child); + return this; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLNode.prototype.comment = function(value) { + var child; + child = new XMLComment(this, value); + this.children.push(child); + return this; }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } + + XMLNode.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; }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectWriter_1 = __nccwpck_require__(243); -var util_1 = __nccwpck_require__(6195); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into a JSON string. - */ -var JSONWriter = /** @class */ (function (_super) { - __extends(JSONWriter, _super); - /** - * Initializes a new instance of `JSONWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function JSONWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - prettyPrint: false, - indent: ' ', - newline: '\n', - offset: 0, - group: false, - verbose: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - * @param writerOptions - serialization options - */ - JSONWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - // recursively convert object into JSON string - return this._beginLine(this._writerOptions, 0) + this._convertObject(val, this._writerOptions); + + XMLNode.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; }; - /** - * Produces an XML serialization of the given object. - * - * @param obj - object to serialize - * @param options - serialization options - * @param level - depth of the XML tree - */ - JSONWriter.prototype._convertObject = function (obj, options, level) { - var e_1, _a; - var _this = this; - if (level === void 0) { level = 0; } - var markup = ''; - var isLeaf = this._isLeafNode(obj); - if (util_1.isArray(obj)) { - markup += '['; - var len = obj.length; - var i = 0; - try { - for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { - var val = obj_1_1.value; - markup += this._endLine(options, level + 1) + - this._beginLine(options, level + 1) + - this._convertObject(val, options, level + 1); - if (i < len - 1) { - markup += ','; - } - i++; - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); - } - finally { if (e_1) throw e_1.error; } - } - markup += this._endLine(options, level) + this._beginLine(options, level); - markup += ']'; - } - else if (util_1.isObject(obj)) { - markup += '{'; - var len_1 = util_1.objectLength(obj); - var i_1 = 0; - util_1.forEachObject(obj, function (key, val) { - if (isLeaf && options.prettyPrint) { - markup += ' '; - } - else { - markup += _this._endLine(options, level + 1) + _this._beginLine(options, level + 1); - } - markup += _this._key(key); - if (options.prettyPrint) { - markup += ' '; - } - markup += _this._convertObject(val, options, level + 1); - if (i_1 < len_1 - 1) { - markup += ','; - } - i_1++; - }, this); - if (isLeaf && options.prettyPrint) { - markup += ' '; - } - else { - markup += this._endLine(options, level) + this._beginLine(options, level); - } - markup += '}'; - } - else { - markup += this._val(obj); - } - return markup; + + XMLNode.prototype.raw = function(value) { + var child; + child = new XMLRaw(this, value); + this.children.push(child); + return this; }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - */ - JSONWriter.prototype._beginLine = function (options, level) { - if (!options.prettyPrint) { - return ''; - } - else { - var indentLevel = options.offset + level + 1; - if (indentLevel > 0) { - return new Array(indentLevel).join(options.indent); - } - } - return ''; + + XMLNode.prototype.dummy = function() { + var child; + child = new XMLDummy(this); + return child; }; - /** - * Produces characters to be appended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - */ - JSONWriter.prototype._endLine = function (options, level) { - if (!options.prettyPrint) { - return ''; + + XMLNode.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 { - return options.newline; + } 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; }; - /** - * Produces a JSON key string delimited with double quotes. - */ - JSONWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + + XMLNode.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; }; - /** - * Produces a JSON value string delimited with double quotes. - */ - JSONWriter.prototype._val = function (val) { - return JSON.stringify(val); + + XMLNode.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; }; - /** - * Determines if an object is a leaf node. - * - * @param obj - */ - JSONWriter.prototype._isLeafNode = function (obj) { - return this._descendantCount(obj) <= 1; + + XMLNode.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; }; - /** - * Counts the number of descendants of the given object. - * - * @param obj - * @param count - */ - JSONWriter.prototype._descendantCount = function (obj, count) { - var _this = this; - if (count === void 0) { count = 0; } - if (util_1.isArray(obj)) { - util_1.forEachArray(obj, function (val) { return count += _this._descendantCount(val, count); }, this); - } - else if (util_1.isObject(obj)) { - util_1.forEachObject(obj, function (key, val) { return count += _this._descendantCount(val, count); }, this); + + XMLNode.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; } - else { - count++; + } + 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; } - return count; + } + doc.children.push(doctype); + return doctype; }; - return JSONWriter; -}(BaseWriter_1.BaseWriter)); -exports.JSONWriter = JSONWriter; -//# sourceMappingURL=JSONWriter.js.map -/***/ }), + XMLNode.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; + }; -/***/ 1397: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLNode.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; + } + } + }; -"use strict"; + XMLNode.prototype.document = function() { + var node; + node = this; + while (node) { + if (node.type === NodeType.Document) { + return node; + } else { + node = node.parent; + } + } + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLNode.prototype.end = function(options) { + return this.document().end(options); }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLNode.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]; }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var ObjectWriter_1 = __nccwpck_require__(243); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into ES6 maps and arrays. - */ -var MapWriter = /** @class */ (function (_super) { - __extends(MapWriter, _super); - /** - * Initializes a new instance of `MapWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function MapWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - format: "map", - wellFormed: false, - noDoubleEncoding: false, - group: false, - verbose: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - MapWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - verbose: false - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - // recursively convert object into Map - return this._convertObject(val); + + XMLNode.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]; }; - /** - * Recursively converts a JS object into an ES5 map. - * - * @param obj - a JS object - */ - MapWriter.prototype._convertObject = function (obj) { - if (util_1.isArray(obj)) { - for (var i = 0; i < obj.length; i++) { - obj[i] = this._convertObject(obj[i]); - } - return obj; - } - else if (util_1.isObject(obj)) { - var map = new Map(); - for (var key in obj) { - map.set(key, this._convertObject(obj[key])); - } - return map; - } - else { - return obj; - } + + XMLNode.prototype.importDocument = function(doc) { + var clonedRoot; + clonedRoot = doc.root().clone(); + clonedRoot.parent = this; + clonedRoot.isRoot = false; + this.children.push(clonedRoot); + return this; + }; + + XMLNode.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 + ">"; + } }; - return MapWriter; -}(BaseWriter_1.BaseWriter)); -exports.MapWriter = MapWriter; -//# sourceMappingURL=MapWriter.js.map -/***/ }), + XMLNode.prototype.ele = function(name, attributes, text) { + return this.element(name, attributes, text); + }; -/***/ 243: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLNode.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); + }; -"use strict"; + XMLNode.prototype.txt = function(value) { + return this.text(value); + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLNode.prototype.dat = function(value) { + return this.cdata(value); }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLNode.prototype.com = function(value) { + return this.comment(value); }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } + + XMLNode.prototype.ins = function(target, value) { + return this.instruction(target, value); }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var interfaces_1 = __nccwpck_require__(7305); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into objects and arrays. - */ -var ObjectWriter = /** @class */ (function (_super) { - __extends(ObjectWriter, _super); - /** - * Initializes a new instance of `ObjectWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function ObjectWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._writerOptions = util_1.applyDefaults(writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - group: false, - verbose: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - ObjectWriter.prototype.serialize = function (node) { - this._currentList = []; - this._currentIndex = 0; - this._listRegister = [this._currentList]; - /** - * First pass, serialize nodes - * This creates a list of nodes grouped under node types while preserving - * insertion order. For example: - * [ - * root: [ - * node: [ - * { "@" : { "att1": "val1", "att2": "val2" } - * { "#": "node text" } - * { childNode: [] } - * { "#": "more text" } - * ], - * node: [ - * { "@" : { "att": "val" } - * { "#": [ "text line1", "text line2" ] } - * ] - * ] - * ] - */ - this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); - /** - * Second pass, process node lists. Above example becomes: - * { - * root: { - * node: [ - * { - * "@att1": "val1", - * "@att2": "val2", - * "#1": "node text", - * childNode: {}, - * "#2": "more text" - * }, - * { - * "@att": "val", - * "#": [ "text line1", "text line2" ] - * } - * ] - * } - * } - */ - return this._process(this._currentList, this._writerOptions); + + XMLNode.prototype.doc = function() { + return this.document(); }; - ObjectWriter.prototype._process = function (items, options) { - var _a, _b, _c, _d, _e, _f, _g; - if (items.length === 0) - return {}; - // determine if there are non-unique element names - var namesSeen = {}; - var hasNonUniqueNames = false; - var textCount = 0; - var commentCount = 0; - var instructionCount = 0; - var cdataCount = 0; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - continue; - case "#": - textCount++; - break; - case "!": - commentCount++; - break; - case "?": - instructionCount++; - break; - case "$": - cdataCount++; - break; - default: - if (namesSeen[key]) { - hasNonUniqueNames = true; - } - else { - namesSeen[key] = true; - } - break; - } - } - var defAttrKey = this._getAttrKey(); - var defTextKey = this._getNodeKey(interfaces_1.NodeType.Text); - var defCommentKey = this._getNodeKey(interfaces_1.NodeType.Comment); - var defInstructionKey = this._getNodeKey(interfaces_1.NodeType.ProcessingInstruction); - var defCdataKey = this._getNodeKey(interfaces_1.NodeType.CData); - if (textCount === 1 && items.length === 1 && util_1.isString(items[0]["#"])) { - // special case of an element node with a single text node - return items[0]["#"]; - } - else if (hasNonUniqueNames) { - var obj = {}; - // process attributes first - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - if (key === "@") { - var attrs = item["@"]; - var attrKeys = Object.keys(attrs); - if (attrKeys.length === 1) { - obj[defAttrKey + attrKeys[0]] = attrs[attrKeys[0]]; - } - else { - obj[defAttrKey] = item["@"]; - } - } - } - // list contains element nodes with non-unique names - // return an array with mixed content notation - var result = []; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - // attributes were processed above - break; - case "#": - result.push((_a = {}, _a[defTextKey] = item["#"], _a)); - break; - case "!": - result.push((_b = {}, _b[defCommentKey] = item["!"], _b)); - break; - case "?": - result.push((_c = {}, _c[defInstructionKey] = item["?"], _c)); - break; - case "$": - result.push((_d = {}, _d[defCdataKey] = item["$"], _d)); - break; - default: - // element node - var ele = item; - if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { - // group of element nodes - var eleGroup = []; - var listOfLists = ele[key]; - for (var i_1 = 0; i_1 < listOfLists.length; i_1++) { - eleGroup.push(this._process(listOfLists[i_1], options)); - } - result.push((_e = {}, _e[key] = eleGroup, _e)); - } - else { - // single element node - if (options.verbose) { - result.push((_f = {}, _f[key] = [this._process(ele[key], options)], _f)); - } - else { - result.push((_g = {}, _g[key] = this._process(ele[key], options), _g)); - } - } - break; - } - } - obj[defTextKey] = result; - return obj; + + XMLNode.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); + }; + + XMLNode.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + + XMLNode.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLNode.prototype.t = function(value) { + return this.text(value); + }; + + XMLNode.prototype.d = function(value) { + return this.cdata(value); + }; + + XMLNode.prototype.c = function(value) { + return this.comment(value); + }; + + XMLNode.prototype.r = function(value) { + return this.raw(value); + }; + + XMLNode.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + + XMLNode.prototype.u = function() { + return this.up(); + }; + + XMLNode.prototype.importXMLBuilder = function(doc) { + return this.importDocument(doc); + }; + + XMLNode.prototype.replaceChild = function(newChild, oldChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.removeChild = function(oldChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.appendChild = function(newChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.hasChildNodes = function() { + return this.children.length !== 0; + }; + + XMLNode.prototype.cloneNode = function(deep) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.normalize = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.isSupported = function(feature, version) { + return true; + }; + + XMLNode.prototype.hasAttributes = function() { + return this.attribs.length !== 0; + }; + + XMLNode.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; } - else { - // all element nodes have unique names - // return an object while prefixing data node keys - var textId = 1; - var commentId = 1; - var instructionId = 1; - var cdataId = 1; - var obj = {}; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - var attrs = item["@"]; - var attrKeys = Object.keys(attrs); - if (!options.group || attrKeys.length === 1) { - for (var attrName in attrs) { - obj[defAttrKey + attrName] = attrs[attrName]; - } - } - else { - obj[defAttrKey] = attrs; - } - break; - case "#": - textId = this._processSpecItem(item["#"], obj, options.group, defTextKey, textCount, textId); - break; - case "!": - commentId = this._processSpecItem(item["!"], obj, options.group, defCommentKey, commentCount, commentId); - break; - case "?": - instructionId = this._processSpecItem(item["?"], obj, options.group, defInstructionKey, instructionCount, instructionId); - break; - case "$": - cdataId = this._processSpecItem(item["$"], obj, options.group, defCdataKey, cdataCount, cdataId); - break; - default: - // element node - var ele = item; - if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { - // group of element nodes - var eleGroup = []; - var listOfLists = ele[key]; - for (var i_2 = 0; i_2 < listOfLists.length; i_2++) { - eleGroup.push(this._process(listOfLists[i_2], options)); - } - obj[key] = eleGroup; - } - else { - // single element node - if (options.verbose) { - obj[key] = [this._process(ele[key], options)]; - } - else { - obj[key] = this._process(ele[key], options); - } - } - break; - } - } - return obj; + 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; + } + }; + + XMLNode.prototype.isSameNode = function(other) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.lookupPrefix = function(namespaceURI) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.isDefaultNamespace = function(namespaceURI) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.lookupNamespaceURI = function(prefix) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.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; }; - ObjectWriter.prototype._processSpecItem = function (item, obj, group, defKey, count, id) { - var e_1, _a; - if (!group && util_1.isArray(item) && count + item.length > 2) { - try { - for (var item_1 = __values(item), item_1_1 = item_1.next(); !item_1_1.done; item_1_1 = item_1.next()) { - var subItem = item_1_1.value; - var key = defKey + (id++).toString(); - obj[key] = subItem; - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); - } - finally { if (e_1) throw e_1.error; } - } + + XMLNode.prototype.getFeature = function(feature, version) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.setUserData = function(key, data, handler) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.getUserData = function(key) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.contains = function(other) { + if (!other) { + return false; + } + return other === this || this.isDescendant(other); + }; + + XMLNode.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; } - else { - var key = count > 1 ? defKey + (id++).toString() : defKey; - obj[key] = item; + isDescendantChild = child.isDescendant(node); + if (isDescendantChild) { + return true; + } + } + return false; + }; + + XMLNode.prototype.isAncestor = function(node) { + return node.isDescendant(this); + }; + + XMLNode.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; + } + }; + + XMLNode.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; + } + }; + + XMLNode.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; } - return id; + }); + if (found) { + return pos; + } else { + return -1; + } }; - /** @inheritdoc */ - ObjectWriter.prototype.beginElement = function (name) { - var _a, _b; - var childItems = []; - if (this._currentList.length === 0) { - this._currentList.push((_a = {}, _a[name] = childItems, _a)); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isElementNode(lastItem, name)) { - if (lastItem[name].length !== 0 && util_1.isArray(lastItem[name][0])) { - var listOfLists = lastItem[name]; - listOfLists.push(childItems); - } - else { - lastItem[name] = [lastItem[name], childItems]; - } - } - else { - this._currentList.push((_b = {}, _b[name] = childItems, _b)); - } - } - this._currentIndex++; - if (this._listRegister.length > this._currentIndex) { - this._listRegister[this._currentIndex] = childItems; - } - else { - this._listRegister.push(childItems); + + XMLNode.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; + } } - this._currentList = childItems; + } }; - /** @inheritdoc */ - ObjectWriter.prototype.endElement = function () { - this._currentList = this._listRegister[--this._currentIndex]; + + return XMLNode; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 6768: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLNodeList; + + module.exports = XMLNodeList = (function() { + function XMLNodeList(nodes) { + this.nodes = nodes; + } + + Object.defineProperty(XMLNodeList.prototype, 'length', { + get: function() { + return this.nodes.length || 0; + } + }); + + XMLNodeList.prototype.clone = function() { + return this.nodes = null; }; - /** @inheritdoc */ - ObjectWriter.prototype.attribute = function (name, value) { - var _a, _b; - if (this._currentList.length === 0) { - this._currentList.push({ "@": (_a = {}, _a[name] = value, _a) }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - /* istanbul ignore else */ - if (this._isAttrNode(lastItem)) { - lastItem["@"][name] = value; - } - else { - this._currentList.push({ "@": (_b = {}, _b[name] = value, _b) }); - } - } + + XMLNodeList.prototype.item = function(index) { + return this.nodes[index] || null; + }; + + return XMLNodeList; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 6939: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLProcessingInstruction = (function(superClass) { + extend(XMLProcessingInstruction, superClass); + + function XMLProcessingInstruction(parent, target, value) { + XMLProcessingInstruction.__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); + } + } + + XMLProcessingInstruction.prototype.clone = function() { + return Object.create(this); + }; + + XMLProcessingInstruction.prototype.toString = function(options) { + return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options)); + }; + + XMLProcessingInstruction.prototype.isEqualNode = function(node) { + if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.target !== this.target) { + return false; + } + return true; + }; + + return XMLProcessingInstruction; + + })(XMLCharacterData); + +}).call(this); + + +/***/ }), + +/***/ 6329: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(9267); + + XMLNode = __nccwpck_require__(7608); + + module.exports = XMLRaw = (function(superClass) { + extend(XMLRaw, superClass); + + function XMLRaw(parent, text) { + XMLRaw.__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); + } + + XMLRaw.prototype.clone = function() { + return Object.create(this); + }; + + XMLRaw.prototype.toString = function(options) { + return this.options.writer.raw(this, this.options.writer.filterOptions(options)); + }; + + return XMLRaw; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 8601: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(9267); + + XMLWriterBase = __nccwpck_require__(6752); + + WriterState = __nccwpck_require__(9766); + + module.exports = XMLStreamWriter = (function(superClass) { + extend(XMLStreamWriter, superClass); + + function XMLStreamWriter(stream, options) { + this.stream = stream; + XMLStreamWriter.__super__.constructor.call(this, options); + } + + XMLStreamWriter.prototype.endline = function(node, options, level) { + if (node.isLastRootNode && options.state === WriterState.CloseTag) { + return ''; + } else { + return XMLStreamWriter.__super__.endline.call(this, node, options, level); + } + }; + + XMLStreamWriter.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; }; - /** @inheritdoc */ - ObjectWriter.prototype.comment = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "!": data }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isCommentNode(lastItem)) { - if (util_1.isArray(lastItem["!"])) { - lastItem["!"].push(data); - } - else { - lastItem["!"] = [lastItem["!"], data]; - } - } - else { - this._currentList.push({ "!": data }); - } - } + + XMLStreamWriter.prototype.attribute = function(att, options, level) { + return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level)); }; - /** @inheritdoc */ - ObjectWriter.prototype.text = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "#": data }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isTextNode(lastItem)) { - if (util_1.isArray(lastItem["#"])) { - lastItem["#"].push(data); - } - else { - lastItem["#"] = [lastItem["#"], data]; - } - } - else { - this._currentList.push({ "#": data }); - } - } + + XMLStreamWriter.prototype.cdata = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level)); }; - /** @inheritdoc */ - ObjectWriter.prototype.instruction = function (target, data) { - var value = (data === "" ? target : target + " " + data); - if (this._currentList.length === 0) { - this._currentList.push({ "?": value }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isInstructionNode(lastItem)) { - if (util_1.isArray(lastItem["?"])) { - lastItem["?"].push(value); - } - else { - lastItem["?"] = [lastItem["?"], value]; - } - } - else { - this._currentList.push({ "?": value }); - } + + XMLStreamWriter.prototype.comment = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level)); + }; + + XMLStreamWriter.prototype.declaration = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level)); + }; + + XMLStreamWriter.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(' 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); }; - /** @inheritdoc */ - ObjectWriter.prototype.cdata = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "$": data }); + + XMLStreamWriter.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(''); + } else { + options.state = WriterState.CloseTag; + this.stream.write(options.spaceBeforeSlash + '/>'); } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isCDATANode(lastItem)) { - if (util_1.isArray(lastItem["$"])) { - lastItem["$"].push(data); - } - else { - lastItem["$"] = [lastItem["$"], data]; - } - } - else { - this._currentList.push({ "$": data }); - } + } 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(''); + } 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) + ''); + } + this.stream.write(this.endline(node, options, level)); + options.state = WriterState.None; + return this.closeNode(node, options, level); }; - ObjectWriter.prototype._isAttrNode = function (x) { - return "@" in x; + + XMLStreamWriter.prototype.processingInstruction = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level)); }; - ObjectWriter.prototype._isTextNode = function (x) { - return "#" in x; + + XMLStreamWriter.prototype.raw = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level)); }; - ObjectWriter.prototype._isCommentNode = function (x) { - return "!" in x; + + XMLStreamWriter.prototype.text = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level)); }; - ObjectWriter.prototype._isInstructionNode = function (x) { - return "?" in x; + + XMLStreamWriter.prototype.dtdAttList = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level)); }; - ObjectWriter.prototype._isCDATANode = function (x) { - return "$" in x; + + XMLStreamWriter.prototype.dtdElement = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level)); }; - ObjectWriter.prototype._isElementNode = function (x, name) { - return name in x; + + XMLStreamWriter.prototype.dtdEntity = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level)); }; - /** - * Returns an object key for an attribute or namespace declaration. - */ - ObjectWriter.prototype._getAttrKey = function () { - return this._builderOptions.convert.att; + + XMLStreamWriter.prototype.dtdNotation = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level)); }; - /** - * Returns an object key for the given node type. - * - * @param nodeType - node type to get a key for - */ - ObjectWriter.prototype._getNodeKey = function (nodeType) { - switch (nodeType) { - case interfaces_1.NodeType.Comment: - return this._builderOptions.convert.comment; - case interfaces_1.NodeType.Text: - return this._builderOptions.convert.text; - case interfaces_1.NodeType.ProcessingInstruction: - return this._builderOptions.convert.ins; - case interfaces_1.NodeType.CData: - return this._builderOptions.convert.cdata; - /* istanbul ignore next */ - default: - throw new Error("Invalid node type."); - } + + return XMLStreamWriter; + + })(XMLWriterBase); + +}).call(this); + + +/***/ }), + +/***/ 5913: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(6752); + + module.exports = XMLStringWriter = (function(superClass) { + extend(XMLStringWriter, superClass); + + function XMLStringWriter(options) { + XMLStringWriter.__super__.constructor.call(this, options); + } + + XMLStringWriter.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 ObjectWriter; -}(BaseWriter_1.BaseWriter)); -exports.ObjectWriter = ObjectWriter; -//# sourceMappingURL=ObjectWriter.js.map + + return XMLStringWriter; + + })(XMLWriterBase); + +}).call(this); + /***/ }), -/***/ 7572: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 8594: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLStringifier, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + hasProp = {}.hasOwnProperty; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var BaseCBWriter_1 = __nccwpck_require__(708); -/** - * Serializes XML nodes. - */ -var XMLCBWriter = /** @class */ (function (_super) { - __extends(XMLCBWriter, _super); - /** - * Initializes a new instance of `XMLCBWriter`. - * - * @param builderOptions - XML builder options - */ - function XMLCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._lineLength = 0; - return _this; + module.exports = XMLStringifier = (function() { + function XMLStringifier(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; + } } - /** @inheritdoc */ - XMLCBWriter.prototype.frontMatter = function () { - return ""; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.declaration = function (version, encoding, standalone) { - var markup = this._beginLine() + ""; - return markup; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.docType = function (name, publicId, systemId) { - var markup = this._beginLine(); - if (publicId && systemId) { - markup += ""; - } - else if (publicId) { - markup += ""; - } - else if (systemId) { - markup += ""; - } - else { - markup += ""; - } - return markup; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.comment = function (data) { - return this._beginLine() + ""; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.text = function (data) { - return this._beginLine() + data; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.instruction = function (target, data) { - if (data) { - return this._beginLine() + ""; - } - else { - return this._beginLine() + ""; - } - }; - /** @inheritdoc */ - XMLCBWriter.prototype.cdata = function (data) { - return this._beginLine() + ""; + + XMLStringifier.prototype.name = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalName('' + val || ''); }; - /** @inheritdoc */ - XMLCBWriter.prototype.openTagBegin = function (name) { - this._lineLength += 1 + name.length; - return this._beginLine() + "<" + name; + + XMLStringifier.prototype.text = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar(this.textEscape('' + val || '')); }; - /** @inheritdoc */ - XMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (voidElement) { - return " />"; - } - else if (selfClosing) { - if (this._writerOptions.allowEmptyTags) { - return ">"; - } - else if (this._writerOptions.spaceBeforeSlash) { - return " />"; - } - else { - return "/>"; - } - } - else { - return ">"; - } + + XMLStringifier.prototype.cdata = function(val) { + if (this.options.noValidation) { + return val; + } + val = '' + val || ''; + val = val.replace(']]>', ']]]]>'); + return this.assertLegalChar(val); }; - /** @inheritdoc */ - XMLCBWriter.prototype.closeTag = function (name) { - return this._beginLine() + ""; + + XMLStringifier.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); }; - /** @inheritdoc */ - XMLCBWriter.prototype.attribute = function (name, value) { - var str = name + "=\"" + value + "\""; - if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && - this._lineLength + 1 + str.length > this._writerOptions.width) { - str = this._beginLine() + this._indent(1) + str; - this._lineLength = str.length; - return str; - } - else { - this._lineLength += 1 + str.length; - return " " + str; - } + + XMLStringifier.prototype.raw = function(val) { + if (this.options.noValidation) { + return val; + } + return '' + val || ''; }; - /** @inheritdoc */ - XMLCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - XMLCBWriter.prototype.endElement = function (name) { }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - XMLCBWriter.prototype._beginLine = function () { - if (this._writerOptions.prettyPrint) { - var str = (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level); - this._lineLength = str.length; - return str; - } - else { - return ""; - } + + XMLStringifier.prototype.attValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar(this.attEscape(val = '' + val || '')); }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - */ - XMLCBWriter.prototype._indent = function (level) { - if (level <= 0) { - return ""; - } - else { - return this._writerOptions.indent.repeat(level); - } + + XMLStringifier.prototype.insTarget = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - return XMLCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.XMLCBWriter = XMLCBWriter; -//# sourceMappingURL=XMLCBWriter.js.map -/***/ }), + XMLStringifier.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); + }; -/***/ 9606: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLStringifier.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; + }; -"use strict"; + XMLStringifier.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); + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLStringifier.prototype.xmlStandalone = function(val) { + if (this.options.noValidation) { + return val; + } + if (val) { + return "yes"; + } else { + return "no"; + } }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLStringifier.prototype.dtdPubID = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var interfaces_1 = __nccwpck_require__(7305); -var BaseWriter_1 = __nccwpck_require__(7644); -var util_2 = __nccwpck_require__(5282); -/** - * Serializes XML nodes into strings. - */ -var XMLWriter = /** @class */ (function (_super) { - __extends(XMLWriter, _super); - /** - * Initializes a new instance of `XMLWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function XMLWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._indentation = {}; - _this._lengthToLastNewline = 0; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - headless: false, - prettyPrint: false, - indent: " ", - newline: "\n", - offset: 0, - width: 0, - allowEmptyTags: false, - indentTextOnlyNodes: false, - spaceBeforeSlash: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - XMLWriter.prototype.serialize = function (node) { - this._refs = { suppressPretty: false, emptyNode: false, markup: "" }; - // Serialize XML declaration - if (node.nodeType === interfaces_1.NodeType.Document && !this._writerOptions.headless) { - this.declaration(this._builderOptions.version, this._builderOptions.encoding, this._builderOptions.standalone); - } - // recursively serialize node - this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); - // remove trailing newline - if (this._writerOptions.prettyPrint && - this._refs.markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { - this._refs.markup = this._refs.markup.slice(0, -this._writerOptions.newline.length); - } - return this._refs.markup; + + XMLStringifier.prototype.dtdSysID = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.declaration = function (version, encoding, standalone) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLStringifier.prototype.dtdElementValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.docType = function (name, publicId, systemId) { - this._beginLine(); - if (publicId && systemId) { - this._refs.markup += ""; - } - else if (publicId) { - this._refs.markup += ""; - } - else if (systemId) { - this._refs.markup += ""; - } - else { - this._refs.markup += ""; - } - this._endLine(); + + XMLStringifier.prototype.dtdAttType = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.openTagBegin = function (name) { - this._beginLine(); - this._refs.markup += "<" + name; + + XMLStringifier.prototype.dtdAttDefault = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - // do not indent text only elements or elements with empty text nodes - this._refs.suppressPretty = false; - this._refs.emptyNode = false; - if (this._writerOptions.prettyPrint && !selfClosing && !voidElement) { - var textOnlyNode = true; - var emptyNode = true; - var childNode = this.currentNode.firstChild; - var cdataCount = 0; - var textCount = 0; - while (childNode) { - if (util_2.Guard.isExclusiveTextNode(childNode)) { - textCount++; - } - else if (util_2.Guard.isCDATASectionNode(childNode)) { - cdataCount++; - } - else { - textOnlyNode = false; - emptyNode = false; - break; - } - if (childNode.data !== '') { - emptyNode = false; - } - childNode = childNode.nextSibling; - } - this._refs.suppressPretty = !this._writerOptions.indentTextOnlyNodes && textOnlyNode && ((cdataCount <= 1 && textCount === 0) || cdataCount === 0); - this._refs.emptyNode = emptyNode; - } - if ((voidElement || selfClosing || this._refs.emptyNode) && this._writerOptions.allowEmptyTags) { - this._refs.markup += ">"; - } - else { - this._refs.markup += voidElement ? " />" : - (selfClosing || this._refs.emptyNode) ? (this._writerOptions.spaceBeforeSlash ? " />" : "/>") : ">"; - } - this._endLine(); + + XMLStringifier.prototype.dtdEntityValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.closeTag = function (name) { - if (!this._refs.emptyNode) { - this._beginLine(); - this._refs.markup += ""; - } - this._refs.suppressPretty = false; - this._refs.emptyNode = false; - this._endLine(); + + XMLStringifier.prototype.dtdNData = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.attribute = function (name, value) { - var str = name + "=\"" + value + "\""; - if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && - this._refs.markup.length - this._lengthToLastNewline + 1 + str.length > this._writerOptions.width) { - this._endLine(); - this._beginLine(); - this._refs.markup += this._indent(1) + str; - } - else { - this._refs.markup += " " + str; + + XMLStringifier.prototype.convertAttKey = '@'; + + XMLStringifier.prototype.convertPIKey = '?'; + + XMLStringifier.prototype.convertTextKey = '#text'; + + XMLStringifier.prototype.convertCDataKey = '#cdata'; + + XMLStringifier.prototype.convertCommentKey = '#comment'; + + XMLStringifier.prototype.convertRawKey = '#raw'; + + XMLStringifier.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); } - }; - /** @inheritdoc */ - XMLWriter.prototype.text = function (data) { - if (data !== '') { - this._beginLine(); - this._refs.markup += data; - this._endLine(); + } 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; }; - /** @inheritdoc */ - XMLWriter.prototype.cdata = function (data) { - if (data !== '') { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); - } + + XMLStringifier.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; }; - /** @inheritdoc */ - XMLWriter.prototype.comment = function (data) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLStringifier.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(/\r/g, ' '); }; - /** @inheritdoc */ - XMLWriter.prototype.instruction = function (target, data) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLStringifier.prototype.attEscape = function(str) { + var ampregex; + if (this.options.noValidation) { + return str; + } + ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; + return str.replace(ampregex, '&').replace(/ 0) { + return new Array(indentLevel).join(options.indent); } - return _this; - } - /** @inheritdoc */ - YAMLCBWriter.prototype.frontMatter = function () { - return this._beginLine() + "---"; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.comment = function (data) { - // "!": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.comment) + " " + - this._val(data); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.text = function (data) { - // "#": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.text) + " " + - this._val(data); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.instruction = function (target, data) { - // "?": "target hello" - return this._beginLine() + - this._key(this._builderOptions.convert.ins) + " " + - this._val(data ? target + " " + data : target); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.cdata = function (data) { - // "$": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.cdata) + " " + - this._val(data); + } + return ''; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.attribute = function (name, value) { - // "@name": "val" - this._additionalLevel++; - var str = this._beginLine() + - this._key(this._builderOptions.convert.att + name) + " " + - this._val(value); - this._additionalLevel--; - return str; + + XMLWriterBase.prototype.endline = function(node, options, level) { + if (!options.pretty || options.suppressPrettyCount) { + return ''; + } else { + return options.newline; + } }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagBegin = function (name) { - // "node": - // "#": - // - - var str = this._beginLine() + this._key(name); - if (!this._rootWritten) { - this._rootWritten = true; - } - this.hasData = true; - this._additionalLevel++; - str += this._beginLine(true) + this._key(this._builderOptions.convert.text); - return str; + + XMLWriterBase.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; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (selfClosing) { - return " " + this._val(""); - } - return ""; + + XMLWriterBase.prototype.cdata = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.closeTag = function (name) { - this._additionalLevel--; - return ""; + + XMLWriterBase.prototype.comment = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - YAMLCBWriter.prototype.endElement = function (name) { }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - YAMLCBWriter.prototype._beginLine = function (suppressArray) { - if (suppressArray === void 0) { suppressArray = false; } - return (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level, suppressArray); + + XMLWriterBase.prototype.declaration = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + ''; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - * @param suppressArray - whether the suppress array marker - */ - YAMLCBWriter.prototype._indent = function (level, suppressArray) { - if (level + this._additionalLevel <= 0) { - return ""; - } - else { - var chars = this._writerOptions.indent.repeat(level + this._additionalLevel); - if (!suppressArray && this._rootWritten) { - return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); - } - return chars; + + XMLWriterBase.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 += ' 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; }; - /** - * Produces a YAML key string delimited with double quotes. - */ - YAMLCBWriter.prototype._key = function (key) { - return "\"" + key + "\":"; - }; - /** - * Produces a YAML value string delimited with double quotes. - */ - YAMLCBWriter.prototype._val = function (val) { - return JSON.stringify(val); - }; - return YAMLCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.YAMLCBWriter = YAMLCBWriter; -//# sourceMappingURL=YAMLCBWriter.js.map -/***/ }), - -/***/ 6517: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; + XMLWriterBase.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 += '' + this.endline(node, options, level); + } else { + options.state = WriterState.CloseTag; + r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level); } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectWriter_1 = __nccwpck_require__(243); -var util_1 = __nccwpck_require__(6195); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into a YAML string. - */ -var YAMLWriter = /** @class */ (function (_super) { - __extends(YAMLWriter, _super); - /** - * Initializes a new instance of `YAMLWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function YAMLWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - indent: ' ', - newline: '\n', - offset: 0, - group: false, - verbose: false - }); - if (_this._writerOptions.indent.length < 2) { - throw new Error("YAML indententation string must be at least two characters long."); + } 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 += '' + 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; + } + } } - if (_this._writerOptions.offset < 0) { - throw new Error("YAML offset should be zero or a positive number."); + 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); } - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - * @param writerOptions - serialization options - */ - YAMLWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - var markup = this._beginLine(this._writerOptions, 0) + '---' + this._endLine(this._writerOptions) + - this._convertObject(val, this._writerOptions, 0); - // remove trailing newline - /* istanbul ignore else */ - if (markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { - markup = markup.slice(0, -this._writerOptions.newline.length); + options.state = WriterState.CloseTag; + r += this.indent(node, options, level) + ''; + if (prettySuppressed) { + options.suppressPrettyCount--; } - return markup; + r += this.endline(node, options, level); + options.state = WriterState.None; + } + this.closeNode(node, options, level); + return r; }; - /** - * Produces an XML serialization of the given object. - * - * @param obj - object to serialize - * @param options - serialization options - * @param level - depth of the XML tree - * @param indentLeaf - indents leaf nodes - */ - YAMLWriter.prototype._convertObject = function (obj, options, level, suppressIndent) { - var e_1, _a; - var _this = this; - if (suppressIndent === void 0) { suppressIndent = false; } - var markup = ''; - if (util_1.isArray(obj)) { - try { - for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { - var val = obj_1_1.value; - markup += this._beginLine(options, level, true); - if (!util_1.isObject(val)) { - markup += this._val(val) + this._endLine(options); - } - else if (util_1.isEmpty(val)) { - markup += '""' + this._endLine(options); - } - else { - markup += this._convertObject(val, options, level, true); - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); - } - finally { if (e_1) throw e_1.error; } - } - } - else /* if (isObject(obj)) */ { - util_1.forEachObject(obj, function (key, val) { - if (suppressIndent) { - markup += _this._key(key); - suppressIndent = false; - } - else { - markup += _this._beginLine(options, level) + _this._key(key); - } - if (!util_1.isObject(val)) { - markup += ' ' + _this._val(val) + _this._endLine(options); - } - else if (util_1.isEmpty(val)) { - markup += ' ""' + _this._endLine(options); - } - else { - markup += _this._endLine(options) + - _this._convertObject(val, options, level + 1); - } - }, this); - } - return markup; + + XMLWriterBase.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); + } + }; + + XMLWriterBase.prototype.processingInstruction = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + ''; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - * @param isArray - whether this line is an array item - */ - YAMLWriter.prototype._beginLine = function (options, level, isArray) { - if (isArray === void 0) { isArray = false; } - var indentLevel = options.offset + level + 1; - var chars = new Array(indentLevel).join(options.indent); - if (isArray) { - return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); - } - else { - return chars; - } + + XMLWriterBase.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; }; - /** - * Produces characters to be appended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - */ - YAMLWriter.prototype._endLine = function (options) { - return options.newline; + + XMLWriterBase.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; }; - /** - * Produces a YAML key string delimited with double quotes. - */ - YAMLWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + + XMLWriterBase.prototype.dtdAttList = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** - * Produces a YAML value string delimited with double quotes. - */ - YAMLWriter.prototype._val = function (val) { - return JSON.stringify(val); + + XMLWriterBase.prototype.dtdElement = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - return YAMLWriter; -}(BaseWriter_1.BaseWriter)); -exports.YAMLWriter = YAMLWriter; -//# sourceMappingURL=YAMLWriter.js.map + + XMLWriterBase.prototype.dtdEntity = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; + + XMLWriterBase.prototype.dtdNotation = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; + + XMLWriterBase.prototype.openNode = function(node, options, level) {}; + + XMLWriterBase.prototype.closeNode = function(node, options, level) {}; + + XMLWriterBase.prototype.openAttribute = function(att, options, level) {}; + + XMLWriterBase.prototype.closeAttribute = function(att, options, level) {}; + + return XMLWriterBase; + + })(); + +}).call(this); + /***/ }), -/***/ 7476: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 2958: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref; + + ref = __nccwpck_require__(8229), assign = ref.assign, isFunction = ref.isFunction; + + XMLDOMImplementation = __nccwpck_require__(8310); + + XMLDocument = __nccwpck_require__(3730); + + XMLDocumentCB = __nccwpck_require__(7356); + + XMLStringWriter = __nccwpck_require__(5913); + + XMLStreamWriter = __nccwpck_require__(8601); + + NodeType = __nccwpck_require__(9267); + + WriterState = __nccwpck_require__(9766); + + module.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; + }; + + module.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); + } + }; + + module.exports.stringWriter = function(options) { + return new XMLStringWriter(options); + }; + + module.exports.streamWriter = function(stream, options) { + return new XMLStreamWriter(stream, options); + }; + + module.exports.implementation = new XMLDOMImplementation(); + + module.exports.nodeType = NodeType; + + module.exports.writerState = WriterState; + +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var MapWriter_1 = __nccwpck_require__(1397); -exports.MapWriter = MapWriter_1.MapWriter; -var XMLWriter_1 = __nccwpck_require__(9606); -exports.XMLWriter = XMLWriter_1.XMLWriter; -var ObjectWriter_1 = __nccwpck_require__(243); -exports.ObjectWriter = ObjectWriter_1.ObjectWriter; -var JSONWriter_1 = __nccwpck_require__(7510); -exports.JSONWriter = JSONWriter_1.JSONWriter; -var YAMLWriter_1 = __nccwpck_require__(6517); -exports.YAMLWriter = YAMLWriter_1.YAMLWriter; -//# sourceMappingURL=index.js.map /***/ }), @@ -102973,16 +102973,8 @@ class OracleDistribution extends base_installer_1.JavaBase { } const platform = this.getPlatform(); const extension = util_1.getDownloadArchiveExtension(); - let major; - let fileUrl; - if (range.includes('.')) { - major = range.split('.')[0]; - fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`; - } - else { - major = range; - fileUrl = `${ORACLE_DL_BASE}/${range}/latest/jdk-${range}_${platform}-${arch}_bin.${extension}`; - } + const major = range.includes('.') ? range.split('.')[0] : range; + const fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`; if (parseInt(major) < 17) { throw new Error('Oracle JDK is only supported for JDK 17 and later'); } From ebe05e0f88dce569e7e4ca0c17f1caa4fc7cdb87 Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Fri, 9 Jun 2023 10:30:15 +0200 Subject: [PATCH 3/4] Update build --- dist/setup/index.js | 19076 +++++++++++++++++++++--------------------- 1 file changed, 9538 insertions(+), 9538 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index abf3c354d..f5d2e0171 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -90720,10349 +90720,10349 @@ module.exports = v4; /***/ }), -/***/ 5696: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 2839: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + module.exports = { + Disconnected: 1, + Preceding: 2, + Following: 4, + Contains: 8, + ContainedBy: 16, + ImplementationSpecific: 32 + }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(6417); -var util_1 = __nccwpck_require__(6195); -var util_2 = __nccwpck_require__(5282); -var _1 = __nccwpck_require__(4260); -var dom_1 = __nccwpck_require__(770); -/** @inheritdoc */ -function builder(p1, p2) { - var options = formatBuilderOptions(isXMLBuilderCreateOptions(p1) ? p1 : interfaces_1.DefaultBuilderOptions); - var nodes = util_2.Guard.isNode(p1) || util_1.isArray(p1) ? p1 : p2; - if (nodes === undefined) { - throw new Error("Invalid arguments."); - } - if (util_1.isArray(nodes)) { - var builders = []; - for (var i = 0; i < nodes.length; i++) { - var builder_1 = new _1.XMLBuilderImpl(nodes[i]); - builder_1.set(options); - builders.push(builder_1); +}).call(this); + + +/***/ }), + +/***/ 9267: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + module.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(this); + + +/***/ }), + +/***/ 8229: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(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 builders; - } - else { - var builder_2 = new _1.XMLBuilderImpl(nodes); - builder_2.set(options); - return builder_2; - } -} -exports.builder = builder; -/** @inheritdoc */ -function create(p1, p2) { - var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? - p1 : interfaces_1.DefaultBuilderOptions); - var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; - var doc = dom_1.createDocument(); - setOptions(doc, options); - var builder = new _1.XMLBuilderImpl(doc); - if (contents !== undefined) { - // parse contents - builder.ele(contents); - } - return builder; -} -exports.create = create; -/** @inheritdoc */ -function fragment(p1, p2) { - var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? - p1 : interfaces_1.DefaultBuilderOptions); - var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; - var doc = dom_1.createDocument(); - setOptions(doc, options, true); - var builder = new _1.XMLBuilderImpl(doc.createDocumentFragment()); - if (contents !== undefined) { - // parse contents - builder.ele(contents); - } - return builder; -} -exports.fragment = fragment; -/** @inheritdoc */ -function convert(p1, p2, p3) { - var builderOptions; - var contents; - var convertOptions; - if (isXMLBuilderCreateOptions(p1) && p2 !== undefined) { - builderOptions = p1; - contents = p2; - convertOptions = p3; + } } - else { - builderOptions = interfaces_1.DefaultBuilderOptions; - contents = p1; - convertOptions = p2 || undefined; + 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]'; } - return create(builderOptions, contents).end(convertOptions); -} -exports.convert = convert; -function isXMLBuilderCreateOptions(obj) { - if (!util_1.isPlainObject(obj)) + }; + + isEmpty = function(val) { + var key; + if (isArray(val)) { + return !val.length; + } else { + for (key in val) { + if (!hasProp.call(val, key)) continue; return false; - for (var key in obj) { - /* istanbul ignore else */ - if (obj.hasOwnProperty(key)) { - if (!interfaces_1.XMLBuilderOptionKeys.has(key)) - return false; - } + } + return true; } - return true; -} -function formatBuilderOptions(createOptions) { - if (createOptions === void 0) { createOptions = {}; } - var options = util_1.applyDefaults(createOptions, interfaces_1.DefaultBuilderOptions); - if (options.convert.att.length === 0 || - options.convert.ins.length === 0 || - options.convert.text.length === 0 || - options.convert.cdata.length === 0 || - options.convert.comment.length === 0) { - throw new Error("JS object converter strings cannot be zero length."); + }; + + 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; } - return options; -} -function setOptions(doc, options, isFragment) { - var docWithSettings = doc; - docWithSettings._xmlBuilderOptions = options; - docWithSettings._isFragment = isFragment; -} -//# sourceMappingURL=BuilderFunctions.js.map + }; -/***/ }), + module.exports.assign = assign; -/***/ 268: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + module.exports.isFunction = isFunction; -"use strict"; + module.exports.isObject = isObject; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var _1 = __nccwpck_require__(4260); -/** - * Creates an XML builder which serializes the document in chunks. - * - * @param options - callback builder options - * - * @returns callback builder - */ -function createCB(options) { - return new _1.XMLBuilderCBImpl(options); -} -exports.createCB = createCB; -/** - * Creates an XML builder which serializes the fragment in chunks. - * - * @param options - callback builder options - * - * @returns callback builder - */ -function fragmentCB(options) { - return new _1.XMLBuilderCBImpl(options, true); -} -exports.fragmentCB = fragmentCB; -//# sourceMappingURL=BuilderFunctionsCB.js.map + module.exports.isArray = isArray; -/***/ }), + module.exports.isEmpty = isEmpty; -/***/ 1438: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + module.exports.isPlainObject = isPlainObject; -"use strict"; + module.exports.getValue = getValue; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); +}).call(this); + + +/***/ }), + +/***/ 9766: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + module.exports = { + None: 0, + OpenTag: 1, + InsideTag: 2, + CloseTag: 3 + }; + +}).call(this); + + +/***/ }), + +/***/ 8376: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLAttribute, XMLNode; + + NodeType = __nccwpck_require__(9267); + + XMLNode = __nccwpck_require__(7608); + + module.exports = XMLAttribute = (function() { + function XMLAttribute(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(XMLAttribute.prototype, 'nodeType', { + get: function() { + return this.type; + } + }); + + Object.defineProperty(XMLAttribute.prototype, 'ownerElement', { + get: function() { + return this.parent; + } + }); + + Object.defineProperty(XMLAttribute.prototype, 'textContent', { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ''; + } + }); + + Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', { + get: function() { + return ''; + } + }); + + Object.defineProperty(XMLAttribute.prototype, 'prefix', { + get: function() { + return ''; + } + }); + + Object.defineProperty(XMLAttribute.prototype, 'localName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLAttribute.prototype, 'specified', { + get: function() { + return true; + } + }); + + XMLAttribute.prototype.clone = function() { + return Object.create(this); }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLAttribute.prototype.toString = function(options) { + return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } + + XMLAttribute.prototype.debugInfo = function(name) { + name = name || this.name; + if (name == null) { + return "parent: <" + this.parent.name + ">"; + } else { + return "attribute: {" + name + "}, parent: <" + this.parent.name + ">"; + } }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + + XMLAttribute.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 XMLAttribute; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 333: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLCData = (function(superClass) { + extend(XMLCData, superClass); + + function XMLCData(parent, text) { + XMLCData.__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); } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } + + XMLCData.prototype.clone = function() { + return Object.create(this); + }; + + XMLCData.prototype.toString = function(options) { + return this.options.writer.cdata(this, this.options.writer.filterOptions(options)); + }; + + return XMLCData; + + })(XMLCharacterData); + +}).call(this); + + +/***/ }), + +/***/ 7709: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(7608); + + module.exports = XMLCharacterData = (function(superClass) { + extend(XMLCharacterData, superClass); + + function XMLCharacterData(parent) { + XMLCharacterData.__super__.constructor.call(this, parent); + this.value = ''; } - return ar; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(6417); -var util_1 = __nccwpck_require__(6195); -var BuilderFunctions_1 = __nccwpck_require__(5696); -var algorithm_1 = __nccwpck_require__(61); -var infra_1 = __nccwpck_require__(4251); -var NamespacePrefixMap_1 = __nccwpck_require__(283); -var LocalNameSet_1 = __nccwpck_require__(9049); -var util_2 = __nccwpck_require__(5282); -var XMLCBWriter_1 = __nccwpck_require__(7572); -var JSONCBWriter_1 = __nccwpck_require__(7525); -var YAMLCBWriter_1 = __nccwpck_require__(2444); -var events_1 = __nccwpck_require__(2361); -/** - * Represents a readable XML document stream. - */ -var XMLBuilderCBImpl = /** @class */ (function (_super) { - __extends(XMLBuilderCBImpl, _super); - /** - * Initializes a new instance of `XMLStream`. - * - * @param options - stream writer options - * @param fragment - whether to create fragment stream or a document stream - * - * @returns XML stream - */ - function XMLBuilderCBImpl(options, fragment) { - if (fragment === void 0) { fragment = false; } - var _this = _super.call(this) || this; - _this._hasDeclaration = false; - _this._docTypeName = ""; - _this._hasDocumentElement = false; - _this._currentElementSerialized = false; - _this._openTags = []; - _this._ended = false; - _this._fragment = fragment; - // provide default options - _this._options = util_1.applyDefaults(options || {}, interfaces_1.DefaultXMLBuilderCBOptions); - _this._builderOptions = { - defaultNamespace: _this._options.defaultNamespace, - namespaceAlias: _this._options.namespaceAlias - }; - if (_this._options.format === "json") { - _this._writer = new JSONCBWriter_1.JSONCBWriter(_this._options); - } - else if (_this._options.format === "yaml") { - _this._writer = new YAMLCBWriter_1.YAMLCBWriter(_this._options); - } - else { - _this._writer = new XMLCBWriter_1.XMLCBWriter(_this._options); - } - // automatically create listeners for callbacks passed via options - if (_this._options.data !== undefined) { - _this.on("data", _this._options.data); - } - if (_this._options.end !== undefined) { - _this.on("end", _this._options.end); - } - if (_this._options.error !== undefined) { - _this.on("error", _this._options.error); - } - _this._prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); - _this._prefixMap.set("xml", infra_1.namespace.XML); - _this._prefixIndex = { value: 1 }; - _this._push(_this._writer.frontMatter()); - return _this; - } - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.ele = function (p1, p2, p3) { - var e_1, _a; - // parse if JS object or XML or JSON string - if (util_1.isObject(p1) || (util_1.isString(p1) && (/^\s*/g, '>'); - } - else { - for (var i = 0; i < node.data.length; i++) { - var c = node.data[i]; - if (c === "&") - markup += "&"; - else if (c === "<") - markup += "<"; - else if (c === ">") - markup += ">"; - else - markup += c; - } - } - this._push(this._writer.text(markup)); - return this; + + XMLCharacterData.prototype.insertData = function(offset, arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.ins = function (target, content) { - if (content === void 0) { content = ''; } - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).ins(target, content).first().node; - } - catch (err) { - /* istanbul ignore next */ - this.emit("error", err); - /* istanbul ignore next */ - return this; - } - if (this._options.wellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { - this.emit("error", new Error("Processing instruction target contains invalid characters (well-formed required).")); - return this; - } - if (this._options.wellFormed && !algorithm_1.xml_isLegalChar(node.data)) { - this.emit("error", Error("Processing instruction data contains invalid characters (well-formed required).")); - return this; - } - this._push(this._writer.instruction(node.target, node.data)); - return this; + + XMLCharacterData.prototype.deleteData = function(offset, count) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dat = function (content) { - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).dat(content).first().node; - } - catch (err) { - this.emit("error", err); - return this; - } - this._push(this._writer.cdata(node.data)); - return this; + + XMLCharacterData.prototype.replaceData = function(offset, count, arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dec = function (options) { - if (options === void 0) { options = { version: "1.0" }; } - if (this._fragment) { - this.emit("error", Error("Cannot insert an XML declaration into a document fragment.")); - return this; - } - if (this._hasDeclaration) { - this.emit("error", Error("XML declaration is already inserted.")); - return this; - } - this._push(this._writer.declaration(options.version || "1.0", options.encoding, options.standalone)); - this._hasDeclaration = true; - return this; + + XMLCharacterData.prototype.isEqualNode = function(node) { + if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.data !== this.data) { + return false; + } + return true; }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dtd = function (options) { - if (this._fragment) { - this.emit("error", Error("Cannot insert a DocType declaration into a document fragment.")); - return this; - } - if (this._docTypeName !== "") { - this.emit("error", new Error("DocType declaration is already inserted.")); - return this; - } - if (this._hasDocumentElement) { - this.emit("error", new Error("Cannot insert DocType declaration after document element.")); - return this; - } - var node; - try { - node = BuilderFunctions_1.create().dtd(options).first().node; - } - catch (err) { - this.emit("error", err); - return this; - } - if (this._options.wellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { - this.emit("error", new Error("DocType public identifier does not match PubidChar construct (well-formed required).")); - return this; - } - if (this._options.wellFormed && - (!algorithm_1.xml_isLegalChar(node.systemId) || - (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { - this.emit("error", new Error("DocType system identifier contains invalid characters (well-formed required).")); - return this; - } - this._docTypeName = options.name; - this._push(this._writer.docType(options.name, node.publicId, node.systemId)); - return this; + + return XMLCharacterData; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 4407: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLComment = (function(superClass) { + extend(XMLComment, superClass); + + function XMLComment(parent, text) { + XMLComment.__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); + } + + XMLComment.prototype.clone = function() { + return Object.create(this); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.up = function () { - this._serializeOpenTag(false); - this._serializeCloseTag(); - return this; + + XMLComment.prototype.toString = function(options) { + return this.options.writer.comment(this, this.options.writer.filterOptions(options)); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.end = function () { - this._serializeOpenTag(false); - while (this._openTags.length > 0) { - this._serializeCloseTag(); - } - this._push(null); - return this; + + return XMLComment; + + })(XMLCharacterData); + +}).call(this); + + +/***/ }), + +/***/ 7465: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList; + + XMLDOMErrorHandler = __nccwpck_require__(6744); + + XMLDOMStringList = __nccwpck_require__(7028); + + module.exports = XMLDOMConfiguration = (function() { + function XMLDOMConfiguration() { + 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(XMLDOMConfiguration.prototype, 'parameterNames', { + get: function() { + return new XMLDOMStringList(Object.keys(this.defaultParams)); + } + }); + + XMLDOMConfiguration.prototype.getParameter = function(name) { + if (this.params.hasOwnProperty(name)) { + return this.params[name]; + } else { + return null; + } }; - /** - * Serializes the opening tag of an element node. - * - * @param hasChildren - whether the element node has child nodes - */ - XMLBuilderCBImpl.prototype._serializeOpenTag = function (hasChildren) { - if (this._currentElementSerialized) - return; - if (this._currentElement === undefined) - return; - var node = this._currentElement.node; - if (this._options.wellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - this.emit("error", new Error("Node local name contains invalid characters (well-formed required).")); - return; - } - var qualifiedName = ""; - var ignoreNamespaceDefinitionAttribute = false; - var map = this._prefixMap.copy(); - var localPrefixesMap = {}; - var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); - var inheritedNS = this._openTags.length === 0 ? null : this._openTags[this._openTags.length - 1][1]; - var ns = node.namespaceURI; - if (ns === null) - ns = inheritedNS; - if (inheritedNS === ns) { - if (localDefaultNamespace !== null) { - ignoreNamespaceDefinitionAttribute = true; - } - if (ns === infra_1.namespace.XML) { - qualifiedName = "xml:" + node.localName; - } - else { - qualifiedName = node.localName; - } - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - else { - var prefix = node.prefix; - var candidatePrefix = null; - if (prefix !== null || ns !== localDefaultNamespace) { - candidatePrefix = map.get(prefix, ns); - } - if (prefix === "xmlns") { - if (this._options.wellFormed) { - this.emit("error", new Error("An element cannot have the 'xmlns' prefix (well-formed required).")); - return; - } - candidatePrefix = prefix; - } - if (candidatePrefix !== null) { - qualifiedName = candidatePrefix + ':' + node.localName; - if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { - inheritedNS = localDefaultNamespace || null; - } - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - else if (prefix !== null) { - if (prefix in localPrefixesMap) { - prefix = this._generatePrefix(ns, map, this._prefixIndex); - } - map.set(prefix, ns); - qualifiedName += prefix + ':' + node.localName; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - this._push(this._writer.attribute("xmlns:" + prefix, this._serializeAttributeValue(ns, this._options.wellFormed))); - if (localDefaultNamespace !== null) { - inheritedNS = localDefaultNamespace || null; - } - } - else if (localDefaultNamespace === null || - (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { - ignoreNamespaceDefinitionAttribute = true; - qualifiedName += node.localName; - inheritedNS = ns; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - this._push(this._writer.attribute("xmlns", this._serializeAttributeValue(ns, this._options.wellFormed))); - } - else { - qualifiedName += node.localName; - inheritedNS = ns; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - } - this._serializeAttributes(node, map, this._prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, this._options.wellFormed); - var isHTML = (ns === infra_1.namespace.HTML); - if (isHTML && !hasChildren && - XMLBuilderCBImpl._VoidElementNames.has(node.localName)) { - this._push(this._writer.openTagEnd(qualifiedName, true, true)); - this._writer.endElement(qualifiedName); - } - else if (!isHTML && !hasChildren) { - this._push(this._writer.openTagEnd(qualifiedName, true, false)); - this._writer.endElement(qualifiedName); - } - else { - this._push(this._writer.openTagEnd(qualifiedName, false, false)); - } - this._currentElementSerialized = true; - /** - * Save qualified name, original inherited ns, original prefix map, and - * hasChildren flag. - */ - this._openTags.push([qualifiedName, inheritedNS, this._prefixMap, hasChildren]); - /** - * New values of inherited namespace and prefix map will be used while - * serializing child nodes. They will be returned to their original values - * when this node is closed using the _openTags array item we saved above. - */ - if (this._isPrefixMapModified(this._prefixMap, map)) { - this._prefixMap = map; - } - /** - * Calls following this will either serialize child nodes or close this tag. - */ - this._writer.level++; + + XMLDOMConfiguration.prototype.canSetParameter = function(name, value) { + return true; }; - /** - * Serializes the closing tag of an element node. - */ - XMLBuilderCBImpl.prototype._serializeCloseTag = function () { - this._writer.level--; - var lastEle = this._openTags.pop(); - /* istanbul ignore next */ - if (lastEle === undefined) { - this.emit("error", new Error("Last element is undefined.")); - return; - } - var _a = __read(lastEle, 4), qualifiedName = _a[0], ns = _a[1], map = _a[2], hasChildren = _a[3]; - /** - * Restore original values of inherited namespace and prefix map. - */ - this._prefixMap = map; - if (!hasChildren) - return; - this._push(this._writer.closeTag(qualifiedName)); - this._writer.endElement(qualifiedName); + + XMLDOMConfiguration.prototype.setParameter = function(name, value) { + if (value != null) { + return this.params[name] = value; + } else { + return delete this.params[name]; + } }; - /** - * Pushes data to internal buffer. - * - * @param data - data - */ - XMLBuilderCBImpl.prototype._push = function (data) { - if (data === null) { - this._ended = true; - this.emit("end"); - } - else if (this._ended) { - this.emit("error", new Error("Cannot push to ended stream.")); - } - else if (data.length !== 0) { - this._writer.hasData = true; - this.emit("data", data, this._writer.level); - } + + return XMLDOMConfiguration; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 6744: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMErrorHandler; + + module.exports = XMLDOMErrorHandler = (function() { + function XMLDOMErrorHandler() {} + + XMLDOMErrorHandler.prototype.handleError = function(error) { + throw new Error(error); }; - /** - * Reads and serializes an XML tree. - * - * @param node - root node - */ - XMLBuilderCBImpl.prototype._fromNode = function (node) { - var e_2, _a, e_3, _b; - if (util_2.Guard.isElementNode(node)) { - var name = node.prefix ? node.prefix + ":" + node.localName : node.localName; - if (node.namespaceURI !== null) { - this.ele(node.namespaceURI, name); - } - else { - this.ele(name); - } - try { - for (var _c = __values(node.attributes), _d = _c.next(); !_d.done; _d = _c.next()) { - var attr = _d.value; - var name_1 = attr.prefix ? attr.prefix + ":" + attr.localName : attr.localName; - if (attr.namespaceURI !== null) { - this.att(attr.namespaceURI, name_1, attr.value); - } - else { - this.att(name_1, attr.value); - } - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); - } - finally { if (e_2) throw e_2.error; } - } - try { - for (var _e = __values(node.childNodes), _f = _e.next(); !_f.done; _f = _e.next()) { - var child = _f.value; - this._fromNode(child); - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_f && !_f.done && (_b = _e.return)) _b.call(_e); - } - finally { if (e_3) throw e_3.error; } - } - this.up(); - } - else if (util_2.Guard.isExclusiveTextNode(node) && node.data) { - this.txt(node.data); - } - else if (util_2.Guard.isCommentNode(node)) { - this.com(node.data); - } - else if (util_2.Guard.isCDATASectionNode(node)) { - this.dat(node.data); - } - else if (util_2.Guard.isProcessingInstructionNode(node)) { - this.ins(node.target, node.data); - } + + return XMLDOMErrorHandler; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 8310: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMImplementation; + + module.exports = XMLDOMImplementation = (function() { + function XMLDOMImplementation() {} + + XMLDOMImplementation.prototype.hasFeature = function(feature, version) { + return true; }; - /** - * Produces an XML serialization of the attributes of an element node. - * - * @param node - node to serialize - * @param map - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param localPrefixesMap - local prefixes map - * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace - * attributes - * @param requireWellFormed - whether to check conformance - */ - XMLBuilderCBImpl.prototype._serializeAttributes = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed) { - var e_4, _a; - var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; - try { - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - // Optimize common case - if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { - this._push(this._writer.attribute(attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); - continue; - } - if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { - this.emit("error", new Error("Element contains duplicate attributes (well-formed required).")); - return; - } - if (requireWellFormed && localNameSet) - localNameSet.set(attr.namespaceURI, attr.localName); - var attributeNamespace = attr.namespaceURI; - var candidatePrefix = null; - if (attributeNamespace !== null) { - candidatePrefix = map.get(attr.prefix, attributeNamespace); - if (attributeNamespace === infra_1.namespace.XMLNS) { - if (attr.value === infra_1.namespace.XML || - (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || - (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || - localPrefixesMap[attr.localName] !== attr.value) && - map.has(attr.localName, attr.value))) - continue; - if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { - this.emit("error", new Error("XMLNS namespace is reserved (well-formed required).")); - return; - } - if (requireWellFormed && attr.value === '') { - this.emit("error", new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).")); - return; - } - if (attr.prefix === 'xmlns') - candidatePrefix = 'xmlns'; - /** - * _Note:_ The (candidatePrefix === null) check is not in the spec. - * We deviate from the spec here. Otherwise a prefix is generated for - * all attributes with namespaces. - */ - } - else if (candidatePrefix === null) { - if (attr.prefix !== null && - (!map.hasPrefix(attr.prefix) || - map.has(attr.prefix, attributeNamespace))) { - /** - * Check if we can use the attribute's own prefix. - * We deviate from the spec here. - * TODO: This is not an efficient way of searching for prefixes. - * Follow developments to the spec. - */ - candidatePrefix = attr.prefix; - } - else { - candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); - } - this._push(this._writer.attribute("xmlns:" + candidatePrefix, this._serializeAttributeValue(attributeNamespace, this._options.wellFormed))); - } - } - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName) || - (attr.localName === "xmlns" && attributeNamespace === null))) { - this.emit("error", new Error("Attribute local name contains invalid characters (well-formed required).")); - return; - } - this._push(this._writer.attribute((candidatePrefix !== null ? candidatePrefix + ":" : "") + attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); - } - } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_4) throw e_4.error; } - } - }; - /** - * Produces an XML serialization of an attribute value. - * - * @param value - attribute value - * @param requireWellFormed - whether to check conformance - */ - XMLBuilderCBImpl.prototype._serializeAttributeValue = function (value, requireWellFormed) { - if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { - this.emit("error", new Error("Invalid characters in attribute value.")); - return ""; - } - if (value === null) - return ""; - if (this._options.noDoubleEncoding) { - return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - } - else { - var result = ""; - for (var i = 0; i < value.length; i++) { - var c = value[i]; - if (c === "\"") - result += """; - else if (c === "&") - result += "&"; - else if (c === "<") - result += "<"; - else if (c === ">") - result += ">"; - else - result += c; - } - return result; - } + + XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) { + throw new Error("This DOM method is not implemented."); }; - /** - * Records namespace information for the given element and returns the - * default namespace attribute value. - * - * @param node - element node to process - * @param map - namespace prefix map - * @param localPrefixesMap - local prefixes map - */ - XMLBuilderCBImpl.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { - var e_5, _a; - var defaultNamespaceAttrValue = null; - try { - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - var attributeNamespace = attr.namespaceURI; - var attributePrefix = attr.prefix; - if (attributeNamespace === infra_1.namespace.XMLNS) { - if (attributePrefix === null) { - defaultNamespaceAttrValue = attr.value; - continue; - } - else { - var prefixDefinition = attr.localName; - var namespaceDefinition = attr.value; - if (namespaceDefinition === infra_1.namespace.XML) { - continue; - } - if (namespaceDefinition === '') { - namespaceDefinition = null; - } - if (map.has(prefixDefinition, namespaceDefinition)) { - continue; - } - map.set(prefixDefinition, namespaceDefinition); - localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; - } - } - } - } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_5) throw e_5.error; } - } - return defaultNamespaceAttrValue; + + XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) { + throw new Error("This DOM method is not implemented."); }; - /** - * Generates a new prefix for the given namespace. - * - * @param newNamespace - a namespace to generate prefix for - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - */ - XMLBuilderCBImpl.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { - var generatedPrefix = "ns" + prefixIndex.value; - prefixIndex.value++; - prefixMap.set(generatedPrefix, newNamespace); - return generatedPrefix; + + XMLDOMImplementation.prototype.createHTMLDocument = function(title) { + throw new Error("This DOM method is not implemented."); }; - /** - * Determines if the namespace prefix map was modified from its original. - * - * @param originalMap - original namespace prefix map - * @param newMap - new namespace prefix map - */ - XMLBuilderCBImpl.prototype._isPrefixMapModified = function (originalMap, newMap) { - var items1 = originalMap._items; - var items2 = newMap._items; - var nullItems1 = originalMap._nullItems; - var nullItems2 = newMap._nullItems; - for (var key in items2) { - var arr1 = items1[key]; - if (arr1 === undefined) - return true; - var arr2 = items2[key]; - if (arr1.length !== arr2.length) - return true; - for (var i = 0; i < arr1.length; i++) { - if (arr1[i] !== arr2[i]) - return true; - } - } - if (nullItems1.length !== nullItems2.length) - return true; - for (var i = 0; i < nullItems1.length; i++) { - if (nullItems1[i] !== nullItems2[i]) - return true; - } - return false; + + XMLDOMImplementation.prototype.getFeature = function(feature, version) { + throw new Error("This DOM method is not implemented."); }; - XMLBuilderCBImpl._VoidElementNames = new Set(['area', 'base', 'basefont', - 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', - 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); - return XMLBuilderCBImpl; -}(events_1.EventEmitter)); -exports.XMLBuilderCBImpl = XMLBuilderCBImpl; -//# sourceMappingURL=XMLBuilderCBImpl.js.map + + return XMLDOMImplementation; + + })(); + +}).call(this); + /***/ }), -/***/ 8248: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 7028: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMStringList; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(6417); -var util_1 = __nccwpck_require__(6195); -var writers_1 = __nccwpck_require__(7476); -var interfaces_2 = __nccwpck_require__(7305); -var util_2 = __nccwpck_require__(5282); -var algorithm_1 = __nccwpck_require__(61); -var dom_1 = __nccwpck_require__(770); -var infra_1 = __nccwpck_require__(4251); -var readers_1 = __nccwpck_require__(560); -/** - * Represents a wrapper that extends XML nodes to implement easy to use and - * chainable document builder methods. - */ -var XMLBuilderImpl = /** @class */ (function () { - /** - * Initializes a new instance of `XMLBuilderNodeImpl`. - * - * @param domNode - the DOM node to wrap - */ - function XMLBuilderImpl(domNode) { - this._domNode = domNode; + module.exports = XMLDOMStringList = (function() { + function XMLDOMStringList(arr) { + this.arr = arr || []; } - Object.defineProperty(XMLBuilderImpl.prototype, "node", { - /** @inheritdoc */ - get: function () { return this._domNode; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(XMLBuilderImpl.prototype, "options", { - /** @inheritdoc */ - get: function () { return this._options; }, - enumerable: true, - configurable: true + + Object.defineProperty(XMLDOMStringList.prototype, 'length', { + get: function() { + return this.arr.length; + } }); - /** @inheritdoc */ - XMLBuilderImpl.prototype.set = function (options) { - this._options = util_1.applyDefaults(util_1.applyDefaults(this._options, options, true), // apply user settings - interfaces_1.DefaultBuilderOptions); // provide defaults - return this; + + XMLDOMStringList.prototype.item = function(index) { + return this.arr[index] || null; }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.ele = function (p1, p2, p3) { - var _a, _b, _c; - var namespace; - var name; - var attributes; - if (util_1.isObject(p1)) { - // ele(obj: ExpandObject) - return new readers_1.ObjectReader(this._options).parse(this, p1); - } - else if (p1 !== null && /^\s* 0) { - if (namespace === undefined) - namespace = name.slice(atIndex + 1); - name = name.slice(0, atIndex); - } - if (namespace === undefined) { - // look-up default namespace - namespace = (ele ? this._options.defaultNamespace.ele : this._options.defaultNamespace.att); - } - else if (namespace !== null && namespace[0] === "@") { - // look-up namespace aliases - var alias = namespace.slice(1); - namespace = this._options.namespaceAlias[alias]; - if (namespace === undefined) { - throw new Error("Namespace alias `" + alias + "` is not defined. " + this._debugInfo()); - } - } - return [namespace, name]; + + XMLDocument.prototype.createTextNode = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Updates the element's namespace. - * - * @param ns - new namespace - */ - XMLBuilderImpl.prototype._updateNamespace = function (ns) { - var e_2, _a, e_3, _b; - var ele = this._domNode; - if (util_2.Guard.isElementNode(ele) && ns !== null && ele.namespaceURI !== ns) { - var _c = __read(algorithm_1.namespace_extractQName(ele.prefix ? ele.prefix + ':' + ele.localName : ele.localName), 2), elePrefix = _c[0], eleLocalName = _c[1]; - // re-create the element node if its namespace changed - // we can't simply change the namespaceURI since its read-only - var newEle = algorithm_1.create_element(this._doc, eleLocalName, ns, elePrefix); - try { - for (var _d = __values(ele.attributes), _e = _d.next(); !_e.done; _e = _d.next()) { - var attr = _e.value; - var attrQName = attr.prefix ? attr.prefix + ':' + attr.localName : attr.localName; - var _f = __read(algorithm_1.namespace_extractQName(attrQName), 1), attrPrefix = _f[0]; - var newAttrNS = attr.namespaceURI; - if (newAttrNS === null && attrPrefix !== null) { - newAttrNS = ele.lookupNamespaceURI(attrPrefix); - } - if (newAttrNS === null) { - newEle.setAttribute(attrQName, attr.value); - } - else { - newEle.setAttributeNS(newAttrNS, attrQName, attr.value); - } - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_e && !_e.done && (_a = _d.return)) _a.call(_d); - } - finally { if (e_2) throw e_2.error; } - } - // replace the new node in parent node - var parent = ele.parentNode; - /* istanbul ignore next */ - if (parent === null) { - throw new Error("Parent node is null." + this._debugInfo()); - } - parent.replaceChild(newEle, ele); - this._domNode = newEle; - try { - // check child nodes - for (var _g = __values(ele.childNodes), _h = _g.next(); !_h.done; _h = _g.next()) { - var childNode = _h.value; - var newChildNode = childNode.cloneNode(true); - newEle.appendChild(newChildNode); - if (util_2.Guard.isElementNode(newChildNode)) { - var _j = __read(algorithm_1.namespace_extractQName(newChildNode.prefix ? newChildNode.prefix + ':' + newChildNode.localName : newChildNode.localName), 1), newChildNodePrefix = _j[0]; - var newChildNodeNS = newEle.lookupNamespaceURI(newChildNodePrefix); - new XMLBuilderImpl(newChildNode)._updateNamespace(newChildNodeNS); - } - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_h && !_h.done && (_b = _g.return)) _b.call(_g); - } - finally { if (e_3) throw e_3.error; } - } - } + + XMLDocument.prototype.createComment = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - Object.defineProperty(XMLBuilderImpl.prototype, "_doc", { - /** - * Returns the document owning this node. - */ - get: function () { - var node = this.node; - if (util_2.Guard.isDocumentNode(node)) { - return node; - } - else { - var docNode = node.ownerDocument; - /* istanbul ignore next */ - if (!docNode) - throw new Error("Owner document is null. " + this._debugInfo()); - return docNode; - } - }, - enumerable: true, - configurable: true - }); - /** - * Returns debug information for this node. - * - * @param name - node name - */ - XMLBuilderImpl.prototype._debugInfo = function (name) { - var node = this.node; - var parentNode = node.parentNode; - name = name || node.nodeName; - var parentName = parentNode ? parentNode.nodeName : ''; - if (!parentName) { - return "node: <" + name + ">"; - } - else { - return "node: <" + name + ">, parent: <" + parentName + ">"; - } + + XMLDocument.prototype.createCDATASection = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - Object.defineProperty(XMLBuilderImpl.prototype, "_options", { - /** - * Gets or sets builder options. - */ - get: function () { - var doc = this._doc; - /* istanbul ignore next */ - if (doc._xmlBuilderOptions === undefined) { - throw new Error("Builder options is not set."); - } - return doc._xmlBuilderOptions; - }, - set: function (value) { - var doc = this._doc; - doc._xmlBuilderOptions = value; - }, - enumerable: true, - configurable: true - }); - return XMLBuilderImpl; -}()); -exports.XMLBuilderImpl = XMLBuilderImpl; -//# sourceMappingURL=XMLBuilderImpl.js.map -/***/ }), + XMLDocument.prototype.createProcessingInstruction = function(target, data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -/***/ 770: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + XMLDocument.prototype.createAttribute = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -"use strict"; + XMLDocument.prototype.createEntityReference = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var dom_1 = __nccwpck_require__(4646); -var dom_2 = __nccwpck_require__(633); -var util_1 = __nccwpck_require__(6195); -dom_2.dom.setFeatures(false); -/** - * Creates an XML document without any child nodes. - */ -function createDocument() { - var impl = new dom_1.DOMImplementation(); - var doc = impl.createDocument(null, 'root', null); - /* istanbul ignore else */ - if (doc.documentElement) { - doc.removeChild(doc.documentElement); - } - return doc; -} -exports.createDocument = createDocument; -/** - * Sanitizes input strings with user supplied replacement characters. - * - * @param str - input string - * @param replacement - replacement character or function - */ -function sanitizeInput(str, replacement) { - if (str == null) { - return str; - } - else if (replacement === undefined) { - return str + ""; - } - else { - var result = ""; - str = str + ""; - for (var i = 0; i < str.length; i++) { - var n = str.charCodeAt(i); - // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] - if (n === 0x9 || n === 0xA || n === 0xD || - (n >= 0x20 && n <= 0xD7FF) || - (n >= 0xE000 && n <= 0xFFFD)) { - // valid character - not surrogate pair - result += str.charAt(i); - } - else if (n >= 0xD800 && n <= 0xDBFF && i < str.length - 1) { - var n2 = str.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - // valid surrogate pair - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - result += String.fromCodePoint(n); - i++; - } - else { - // invalid lone surrogate - result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); - } - } - else { - // invalid character - result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); - } - } - return result; - } -} -exports.sanitizeInput = sanitizeInput; -//# sourceMappingURL=dom.js.map + XMLDocument.prototype.getElementsByTagName = function(tagname) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -/***/ }), + XMLDocument.prototype.importNode = function(importedNode, deep) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -/***/ 4260: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -"use strict"; + XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var XMLBuilderImpl_1 = __nccwpck_require__(8248); -exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; -var XMLBuilderCBImpl_1 = __nccwpck_require__(1438); -exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; -var BuilderFunctions_1 = __nccwpck_require__(5696); -exports.builder = BuilderFunctions_1.builder; -exports.create = BuilderFunctions_1.create; -exports.fragment = BuilderFunctions_1.fragment; -exports.convert = BuilderFunctions_1.convert; -var BuilderFunctionsCB_1 = __nccwpck_require__(268); -exports.createCB = BuilderFunctionsCB_1.createCB; -exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; -//# sourceMappingURL=index.js.map + XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -/***/ }), + XMLDocument.prototype.getElementById = function(elementId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -/***/ 151: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + XMLDocument.prototype.adoptNode = function(source) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -"use strict"; + XMLDocument.prototype.normalizeDocument = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementsByClassName = function(classNames) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createEvent = function(eventInterface) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createRange = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + return XMLDocument; + + })(XMLNode); + +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var builder_1 = __nccwpck_require__(4260); -exports.builder = builder_1.builder; -exports.create = builder_1.create; -exports.fragment = builder_1.fragment; -exports.convert = builder_1.convert; -exports.createCB = builder_1.createCB; -exports.fragmentCB = builder_1.fragmentCB; -//# sourceMappingURL=index.js.map /***/ }), -/***/ 6417: -/***/ ((__unused_webpack_module, exports) => { +/***/ 7356: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(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; -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Defines default values for builder options. - */ -exports.DefaultBuilderOptions = { - version: "1.0", - encoding: undefined, - standalone: undefined, - keepNullNodes: false, - keepNullAttributes: false, - ignoreConverters: false, - convert: { - att: "@", - ins: "?", - text: "#", - cdata: "$", - comment: "!" - }, - defaultNamespace: { - ele: undefined, - att: undefined - }, - namespaceAlias: { - html: "http://www.w3.org/1999/xhtml", - xml: "http://www.w3.org/XML/1998/namespace", - xmlns: "http://www.w3.org/2000/xmlns/", - mathml: "http://www.w3.org/1998/Math/MathML", - svg: "http://www.w3.org/2000/svg", - xlink: "http://www.w3.org/1999/xlink" - }, - invalidCharReplacement: undefined, - parser: undefined -}; -/** - * Contains keys of `XMLBuilderOptions`. - */ -exports.XMLBuilderOptionKeys = new Set(Object.keys(exports.DefaultBuilderOptions)); -/** - * Defines default values for builder options. - */ -exports.DefaultXMLBuilderCBOptions = { - format: "xml", - wellFormed: false, - prettyPrint: false, - indent: " ", - newline: "\n", - offset: 0, - width: 0, - allowEmptyTags: false, - spaceBeforeSlash: false, - keepNullNodes: false, - keepNullAttributes: false, - ignoreConverters: false, - convert: { - att: "@", - ins: "?", - text: "#", - cdata: "$", - comment: "!" - }, - defaultNamespace: { - ele: undefined, - att: undefined - }, - namespaceAlias: { - html: "http://www.w3.org/1999/xhtml", - xml: "http://www.w3.org/XML/1998/namespace", - xmlns: "http://www.w3.org/2000/xmlns/", - mathml: "http://www.w3.org/1998/Math/MathML", - svg: "http://www.w3.org/2000/svg", - xlink: "http://www.w3.org/1999/xlink" - } -}; -//# sourceMappingURL=interfaces.js.map + ref = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue; -/***/ }), + NodeType = __nccwpck_require__(9267); -/***/ 3396: -/***/ ((__unused_webpack_module, exports) => { + XMLDocument = __nccwpck_require__(3730); -"use strict"; + XMLElement = __nccwpck_require__(9437); -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Pre-serializes XML nodes. - */ -var BaseReader = /** @class */ (function () { - /** - * Initializes a new instance of `BaseReader`. - * - * @param builderOptions - XML builder options - */ - function BaseReader(builderOptions) { - this._builderOptions = builderOptions; - if (builderOptions.parser) { - Object.assign(this, builderOptions.parser); - } - } - BaseReader.prototype._docType = function (parent, name, publicId, systemId) { - return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); - }; - BaseReader.prototype._comment = function (parent, data) { - return parent.com(data); - }; - BaseReader.prototype._text = function (parent, data) { - return parent.txt(data); - }; - BaseReader.prototype._instruction = function (parent, target, data) { - return parent.ins(target, data); - }; - BaseReader.prototype._cdata = function (parent, data) { - return parent.dat(data); - }; - BaseReader.prototype._element = function (parent, namespace, name) { - return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); - }; - BaseReader.prototype._attribute = function (parent, namespace, name, value) { - return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); - }; - /** - * Main parser function which parses the given object and returns an XMLBuilder. - * - * @param node - node to recieve parsed content - * @param obj - object to parse - */ - BaseReader.prototype.parse = function (node, obj) { - return this._parse(node, obj); - }; - /** - * Creates a DocType node. - * The node will be skipped if the function returns `undefined`. - * - * @param name - node name - * @param publicId - public identifier - * @param systemId - system identifier - */ - BaseReader.prototype.docType = function (parent, name, publicId, systemId) { - return this._docType(parent, name, publicId, systemId); - }; - /** - * Creates a comment node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.comment = function (parent, data) { - return this._comment(parent, data); - }; - /** - * Creates a text node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.text = function (parent, data) { - return this._text(parent, data); - }; - /** - * Creates a processing instruction node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param target - instruction target - * @param data - node data - */ - BaseReader.prototype.instruction = function (parent, target, data) { - return this._instruction(parent, target, data); - }; - /** - * Creates a CData section node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.cdata = function (parent, data) { - return this._cdata(parent, data); - }; - /** - * Creates an element node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param namespace - node namespace - * @param name - node name - */ - BaseReader.prototype.element = function (parent, namespace, name) { - return this._element(parent, namespace, name); - }; - /** - * Creates an attribute or namespace declaration. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param namespace - node namespace - * @param name - node name - * @param value - node value - */ - BaseReader.prototype.attribute = function (parent, namespace, name, value) { - return this._attribute(parent, namespace, name, value); - }; - return BaseReader; -}()); -exports.BaseReader = BaseReader; -//# sourceMappingURL=BaseReader.js.map + XMLCData = __nccwpck_require__(333); -/***/ }), + XMLComment = __nccwpck_require__(4407); -/***/ 3518: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLRaw = __nccwpck_require__(6329); -"use strict"; + XMLText = __nccwpck_require__(1318); -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectReader_1 = __nccwpck_require__(768); -var BaseReader_1 = __nccwpck_require__(3396); -/** - * Parses XML nodes from a JSON string. - */ -var JSONReader = /** @class */ (function (_super) { - __extends(JSONReader, _super); - function JSONReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - JSON string to parse - */ - JSONReader.prototype._parse = function (node, str) { - return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, JSON.parse(str)); - }; - return JSONReader; -}(BaseReader_1.BaseReader)); -exports.JSONReader = JSONReader; -//# sourceMappingURL=JSONReader.js.map + XMLProcessingInstruction = __nccwpck_require__(6939); -/***/ }), + XMLDeclaration = __nccwpck_require__(6364); -/***/ 768: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLDocType = __nccwpck_require__(1801); -"use strict"; + XMLDTDAttList = __nccwpck_require__(1015); -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var BaseReader_1 = __nccwpck_require__(3396); -var dom_1 = __nccwpck_require__(770); -/** - * Parses XML nodes from objects and arrays. - * ES6 maps and sets are also supoorted. - */ -var ObjectReader = /** @class */ (function (_super) { - __extends(ObjectReader, _super); - function ObjectReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param obj - object to parse - */ - ObjectReader.prototype._parse = function (node, obj) { - var _this = this; - var options = this._builderOptions; - // sanitizes input characters - var invalidCharReplacement = options.invalidCharReplacement; - var s = function (str) { - return dom_1.sanitizeInput(str, invalidCharReplacement); - }; - var lastChild = null; - if (util_1.isFunction(obj)) { - // evaluate if function - lastChild = this.parse(node, obj.apply(this)); - } - else if (util_1.isArray(obj) || util_1.isSet(obj)) { - util_1.forEachArray(obj, function (item) { return lastChild = _this.parse(node, item); }, this); - } - else /* if (isMap(obj) || isObject(obj)) */ { - // expand if object - util_1.forEachObject(obj, function (key, val) { - if (util_1.isFunction(val)) { - // evaluate if function - val = val.apply(_this); - } - if (!options.ignoreConverters && key.indexOf(options.convert.att) === 0) { - // assign attributes - if (key === options.convert.att) { - if (util_1.isArray(val) || util_1.isSet(val)) { - throw new Error("Invalid attribute: " + val.toString() + ". " + node._debugInfo()); - } - else /* if (isMap(val) || isObject(val)) */ { - util_1.forEachObject(val, function (attrKey, attrVal) { - lastChild = _this.attribute(node, undefined, s(attrKey), s(attrVal)) || lastChild; - }); - } - } - else { - lastChild = _this.attribute(node, undefined, s(key.substr(options.convert.att.length)), s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.text) === 0) { - // text node - if (util_1.isMap(val) || util_1.isObject(val)) { - // if the key is #text expand child nodes under this node to support mixed content - lastChild = _this.parse(node, val); - } - else { - lastChild = _this.text(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.cdata) === 0) { - // cdata node - if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { return lastChild = _this.cdata(node, s(item)) || lastChild; }, _this); - } - else { - lastChild = _this.cdata(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.comment) === 0) { - // comment node - if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { return lastChild = _this.comment(node, s(item)) || lastChild; }, _this); - } - else { - lastChild = _this.comment(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.ins) === 0) { - // processing instruction - if (util_1.isString(val)) { - var insIndex = val.indexOf(' '); - var insTarget = (insIndex === -1 ? val : val.substr(0, insIndex)); - var insValue = (insIndex === -1 ? '' : val.substr(insIndex + 1)); - lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; - } - else if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { - var insIndex = item.indexOf(' '); - var insTarget = (insIndex === -1 ? item : item.substr(0, insIndex)); - var insValue = (insIndex === -1 ? '' : item.substr(insIndex + 1)); - lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; - }, _this); - } - else /* if (isMap(target) || isObject(target)) */ { - util_1.forEachObject(val, function (insTarget, insValue) { return lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; }, _this); - } - } - else if ((util_1.isArray(val) || util_1.isSet(val)) && util_1.isEmpty(val)) { - // skip empty arrays - } - else if ((util_1.isMap(val) || util_1.isObject(val)) && util_1.isEmpty(val)) { - // empty objects produce one node - lastChild = _this.element(node, undefined, s(key)) || lastChild; - } - else if (!options.keepNullNodes && (val == null)) { - // skip null and undefined nodes - } - else if (util_1.isArray(val) || util_1.isSet(val)) { - // expand list by creating child nodes - util_1.forEachArray(val, function (item) { - var childNode = {}; - childNode[key] = item; - lastChild = _this.parse(node, childNode); - }, _this); - } - else if (util_1.isMap(val) || util_1.isObject(val)) { - // create a parent node - var parent = _this.element(node, undefined, key); - if (parent) { - lastChild = parent; - // expand child nodes under parent - _this.parse(parent, val); - } - } - else if (val != null && val !== '') { - // leaf element node with a single text node - var parent = _this.element(node, undefined, key); - if (parent) { - lastChild = parent; - _this.text(parent, s(val)); - } - } - else { - // leaf element node - lastChild = _this.element(node, undefined, s(key)) || lastChild; - } - }, this); - } - return lastChild || node; - }; - return ObjectReader; -}(BaseReader_1.BaseReader)); -exports.ObjectReader = ObjectReader; -//# sourceMappingURL=ObjectReader.js.map + XMLDTDEntity = __nccwpck_require__(53); -/***/ }), + XMLDTDElement = __nccwpck_require__(2421); -/***/ 5044: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLDTDNotation = __nccwpck_require__(2837); -"use strict"; + XMLAttribute = __nccwpck_require__(8376); -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + XMLStringifier = __nccwpck_require__(8594); + + XMLStringWriter = __nccwpck_require__(5913); + + WriterState = __nccwpck_require__(9766); + + module.exports = XMLDocumentCB = (function() { + function XMLDocumentCB(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; } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; + + XMLDocumentCB.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; }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var XMLStringLexer_1 = __nccwpck_require__(7061); -var interfaces_1 = __nccwpck_require__(7707); -var infra_1 = __nccwpck_require__(4251); -var algorithm_1 = __nccwpck_require__(61); -var dom_1 = __nccwpck_require__(770); -var BaseReader_1 = __nccwpck_require__(3396); -/** - * Parses XML nodes from an XML document string. - */ -var XMLReader = /** @class */ (function (_super) { - __extends(XMLReader, _super); - function XMLReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - XML document string to parse - */ - XMLReader.prototype._parse = function (node, str) { - var e_1, _a, e_2, _b; - var lexer = new XMLStringLexer_1.XMLStringLexer(str, { skipWhitespaceOnlyText: true }); - // sanitizes input characters - var invalidCharReplacement = this._builderOptions.invalidCharReplacement; - var s = function (str) { - return dom_1.sanitizeInput(str, invalidCharReplacement); - }; - var context = node; - var token = lexer.nextToken(); - while (token.type !== interfaces_1.TokenType.EOF) { - switch (token.type) { - case interfaces_1.TokenType.Declaration: - var declaration = token; - var version = s(declaration.version); - if (version !== "1.0") { - throw new Error("Invalid xml version: " + version); - } - var builderOptions = { - version: version - }; - if (declaration.encoding) { - builderOptions.encoding = s(declaration.encoding); - } - if (declaration.standalone) { - builderOptions.standalone = (s(declaration.standalone) === "yes"); - } - context.set(builderOptions); - break; - case interfaces_1.TokenType.DocType: - var doctype = token; - context = this.docType(context, s(doctype.name), s(doctype.pubId), s(doctype.sysId)) || context; - break; - case interfaces_1.TokenType.CDATA: - var cdata = token; - context = this.cdata(context, s(cdata.data)) || context; - break; - case interfaces_1.TokenType.Comment: - var comment = token; - context = this.comment(context, s(comment.data)) || context; - break; - case interfaces_1.TokenType.PI: - var pi = token; - context = this.instruction(context, s(pi.target), s(pi.data)) || context; - break; - case interfaces_1.TokenType.Text: - var text = token; - context = this.text(context, s(text.data)) || context; - break; - case interfaces_1.TokenType.Element: - var element = token; - var elementName = s(element.name); - // inherit namespace from parent - var _c = __read(algorithm_1.namespace_extractQName(elementName), 1), prefix = _c[0]; - var namespace = context.node.lookupNamespaceURI(prefix); - // override namespace if there is a namespace declaration - // attribute - // also lookup namespace declaration attributes - var nsDeclarations = {}; - try { - for (var _d = (e_1 = void 0, __values(element.attributes)), _e = _d.next(); !_e.done; _e = _d.next()) { - var _f = __read(_e.value, 2), attName = _f[0], attValue = _f[1]; - attName = s(attName); - attValue = s(attValue); - if (attName === "xmlns") { - namespace = attValue; - } - else { - var _g = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _g[0], attLocalName = _g[1]; - if (attPrefix === "xmlns") { - if (attLocalName === prefix) { - namespace = attValue; - } - nsDeclarations[attLocalName] = attValue; - } - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_e && !_e.done && (_a = _d.return)) _a.call(_d); - } - finally { if (e_1) throw e_1.error; } - } - // create the DOM element node - var elementNode = (namespace !== null ? - this.element(context, namespace, elementName) : - this.element(context, undefined, elementName)); - if (elementNode === undefined) - break; - try { - // assign attributes - for (var _h = (e_2 = void 0, __values(element.attributes)), _j = _h.next(); !_j.done; _j = _h.next()) { - var _k = __read(_j.value, 2), attName = _k[0], attValue = _k[1]; - attName = s(attName); - attValue = s(attValue); - var _l = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _l[0], attLocalName = _l[1]; - var attNamespace = null; - if (attPrefix === "xmlns" || (attPrefix === null && attLocalName === "xmlns")) { - // namespace declaration attribute - attNamespace = infra_1.namespace.XMLNS; - } - else { - attNamespace = elementNode.node.lookupNamespaceURI(attPrefix); - if (attNamespace !== null && elementNode.node.isDefaultNamespace(attNamespace)) { - attNamespace = null; - } - else if (attNamespace === null && attPrefix !== null) { - attNamespace = nsDeclarations[attPrefix] || null; - } - } - if (attNamespace !== null) - this.attribute(elementNode, attNamespace, attName, attValue); - else - this.attribute(elementNode, undefined, attName, attValue); - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_j && !_j.done && (_b = _h.return)) _b.call(_h); - } - finally { if (e_2) throw e_2.error; } - } - if (!element.selfClosing) { - context = elementNode; - } - break; - case interfaces_1.TokenType.ClosingTag: - /* istanbul ignore else */ - if (context.node.parentNode) { - context = context.up(); - } - break; - } - token = lexer.nextToken(); - } - return context; + + XMLDocumentCB.prototype.dummy = function() { + return this; }; - return XMLReader; -}(BaseReader_1.BaseReader)); -exports.XMLReader = XMLReader; -//# sourceMappingURL=XMLReader.js.map -/***/ }), + XMLDocumentCB.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; + }; -/***/ 2475: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLDocumentCB.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; + }; -"use strict"; + XMLDocumentCB.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; + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLDocumentCB.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; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLDocumentCB.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; }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectReader_1 = __nccwpck_require__(768); -var BaseReader_1 = __nccwpck_require__(3396); -var js_yaml_1 = __nccwpck_require__(1917); -/** - * Parses XML nodes from a YAML string. - */ -var YAMLReader = /** @class */ (function (_super) { - __extends(YAMLReader, _super); - function YAMLReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - YAML string to parse - */ - YAMLReader.prototype._parse = function (node, str) { - var result = js_yaml_1.safeLoad(str); - /* istanbul ignore next */ - if (result === undefined) { - throw new Error("Unable to parse YAML document."); - } - return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, result); + + XMLDocumentCB.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; }; - return YAMLReader; -}(BaseReader_1.BaseReader)); -exports.YAMLReader = YAMLReader; -//# sourceMappingURL=YAMLReader.js.map -/***/ }), + XMLDocumentCB.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; + }; -/***/ 560: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + XMLDocumentCB.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; + }; -"use strict"; + XMLDocumentCB.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; + }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var XMLReader_1 = __nccwpck_require__(5044); -exports.XMLReader = XMLReader_1.XMLReader; -var ObjectReader_1 = __nccwpck_require__(768); -exports.ObjectReader = ObjectReader_1.ObjectReader; -var JSONReader_1 = __nccwpck_require__(3518); -exports.JSONReader = JSONReader_1.JSONReader; -var YAMLReader_1 = __nccwpck_require__(2475); -exports.YAMLReader = YAMLReader_1.YAMLReader; -//# sourceMappingURL=index.js.map + XMLDocumentCB.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; + }; -/***/ }), + XMLDocumentCB.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; + }; -/***/ 708: -/***/ ((__unused_webpack_module, exports) => { + XMLDocumentCB.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; + }; -"use strict"; + XMLDocumentCB.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; + }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Pre-serializes XML nodes. - */ -var BaseCBWriter = /** @class */ (function () { - /** - * Initializes a new instance of `BaseCBWriter`. - * - * @param builderOptions - XML builder options - */ - function BaseCBWriter(builderOptions) { - /** - * Gets the current depth of the XML tree. - */ - this.level = 0; - this._builderOptions = builderOptions; - this._writerOptions = builderOptions; - } - return BaseCBWriter; -}()); -exports.BaseCBWriter = BaseCBWriter; -//# sourceMappingURL=BaseCBWriter.js.map + XMLDocumentCB.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; + }; -/***/ }), + XMLDocumentCB.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; + }; -/***/ 7644: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLDocumentCB.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; + }; -"use strict"; + XMLDocumentCB.prototype.end = function() { + while (this.currentLevel >= 0) { + this.up(); + } + return this.onEnd(); + }; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } + XMLDocumentCB.prototype.openCurrent = function() { + if (this.currentNode) { + this.currentNode.children = true; + return this.openNode(this.currentNode); + } }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); + + XMLDocumentCB.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; } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (this && this.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(7305); -var LocalNameSet_1 = __nccwpck_require__(9049); -var NamespacePrefixMap_1 = __nccwpck_require__(283); -var infra_1 = __nccwpck_require__(4251); -var algorithm_1 = __nccwpck_require__(61); -/** - * Pre-serializes XML nodes. - */ -var BaseWriter = /** @class */ (function () { - /** - * Initializes a new instance of `BaseWriter`. - * - * @param builderOptions - XML builder options - */ - function BaseWriter(builderOptions) { - /** - * Gets the current depth of the XML tree. - */ - this.level = 0; - this._builderOptions = builderOptions; - } - /** - * Used by derived classes to serialize the XML declaration. - * - * @param version - a version number string - * @param encoding - encoding declaration - * @param standalone - standalone document declaration - */ - BaseWriter.prototype.declaration = function (version, encoding, standalone) { }; - /** - * Used by derived classes to serialize a DocType node. - * - * @param name - node name - * @param publicId - public identifier - * @param systemId - system identifier - */ - BaseWriter.prototype.docType = function (name, publicId, systemId) { }; - /** - * Used by derived classes to serialize a comment node. - * - * @param data - node data - */ - BaseWriter.prototype.comment = function (data) { }; - /** - * Used by derived classes to serialize a text node. - * - * @param data - node data - */ - BaseWriter.prototype.text = function (data) { }; - /** - * Used by derived classes to serialize a processing instruction node. - * - * @param target - instruction target - * @param data - node data - */ - BaseWriter.prototype.instruction = function (target, data) { }; - /** - * Used by derived classes to serialize a CData section node. - * - * @param data - node data - */ - BaseWriter.prototype.cdata = function (data) { }; - /** - * Used by derived classes to serialize the beginning of the opening tag of an - * element node. - * - * @param name - node name - */ - BaseWriter.prototype.openTagBegin = function (name) { }; - /** - * Used by derived classes to serialize the ending of the opening tag of an - * element node. - * - * @param name - node name - * @param selfClosing - whether the element node is self closing - * @param voidElement - whether the element node is a HTML void element - */ - BaseWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { }; - /** - * Used by derived classes to serialize the closing tag of an element node. - * - * @param name - node name - */ - BaseWriter.prototype.closeTag = function (name) { }; - /** - * Used by derived classes to serialize attributes or namespace declarations. - * - * @param attributes - attribute array - */ - BaseWriter.prototype.attributes = function (attributes) { - var e_1, _a; - try { - for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) { - var attr = attributes_1_1.value; - this.attribute(attr[1] === null ? attr[2] : attr[1] + ':' + attr[2], attr[3]); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1); - } - finally { if (e_1) throw e_1.error; } + 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) + ''; + } + chunk += this.writer.endline(node, this.writerOptions, this.currentLevel); } + this.onData(chunk, this.currentLevel); + return node.isOpen = true; + } }; - /** - * Used by derived classes to serialize an attribute or namespace declaration. - * - * @param name - node name - * @param value - node value - */ - BaseWriter.prototype.attribute = function (name, value) { }; - /** - * Used by derived classes to perform any pre-processing steps before starting - * serializing an element node. - * - * @param name - node name - */ - BaseWriter.prototype.beginElement = function (name) { }; - /** - * Used by derived classes to perform any post-processing steps after - * completing serializing an element node. - * - * @param name - node name - */ - BaseWriter.prototype.endElement = function (name) { }; - /** - * Produces an XML serialization of the given node. The pre-serializer inserts - * namespace declarations where necessary and produces qualified names for - * nodes and attributes. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype.serializeNode = function (node, requireWellFormed, noDoubleEncoding) { - var hasNamespaces = (node._nodeDocument !== undefined && node._nodeDocument._hasNamespaces); - this.level = 0; - this.currentNode = node; - if (hasNamespaces) { - /** From: https://w3c.github.io/DOM-Parsing/#xml-serialization - * - * 1. Let namespace be a context namespace with value null. - * The context namespace tracks the XML serialization algorithm's current - * default namespace. The context namespace is changed when either an Element - * Node has a default namespace declaration, or the algorithm generates a - * default namespace declaration for the Element Node to match its own - * namespace. The algorithm assumes no namespace (null) to start. - * 2. Let prefix map be a new namespace prefix map. - * 3. Add the XML namespace with prefix value "xml" to prefix map. - * 4. Let prefix index be a generated namespace prefix index with value 1. - * The generated namespace prefix index is used to generate a new unique - * prefix value when no suitable existing namespace prefix is available to - * serialize a node's namespaceURI (or the namespaceURI of one of node's - * attributes). See the generate a prefix algorithm. - */ - var namespace = null; - var prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); - prefixMap.set("xml", infra_1.namespace.XML); - var prefixIndex = { value: 1 }; - /** - * 5. Return the result of running the XML serialization algorithm on node - * passing the context namespace namespace, namespace prefix map prefix map, - * generated namespace prefix index reference to prefix index, and the - * flag require well-formed. If an exception occurs during the execution - * of the algorithm, then catch that exception and throw an - * "InvalidStateError" DOMException. - */ - this._serializeNodeNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - } - else { - this._serializeNode(node, requireWellFormed, noDoubleEncoding); + + XMLDocumentCB.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) + '' + 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; + } }; - /** - * Produces an XML serialization of a node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeNodeNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - this.currentNode = node; - switch (node.nodeType) { - case interfaces_1.NodeType.Element: - this._serializeElementNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Document: - this._serializeDocumentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Comment: - this._serializeComment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Text: - this._serializeText(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentFragment: - this._serializeDocumentFragmentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentType: - this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.ProcessingInstruction: - this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.CData: - this._serializeCData(node, requireWellFormed, noDoubleEncoding); - break; - default: - throw new Error("Unknown node type: " + node.nodeType); - } + + XMLDocumentCB.prototype.onData = function(chunk, level) { + this.documentStarted = true; + return this.onDataCallback(chunk, level + 1); }; - /** - * Produces an XML serialization of a node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeNode = function (node, requireWellFormed, noDoubleEncoding) { - this.currentNode = node; - switch (node.nodeType) { - case interfaces_1.NodeType.Element: - this._serializeElement(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Document: - this._serializeDocument(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Comment: - this._serializeComment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Text: - this._serializeText(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentFragment: - this._serializeDocumentFragment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentType: - this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.ProcessingInstruction: - this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.CData: - this._serializeCData(node, requireWellFormed, noDoubleEncoding); - break; - default: - throw new Error("Unknown node type: " + node.nodeType); - } + + XMLDocumentCB.prototype.onEnd = function() { + this.documentCompleted = true; + return this.onEndCallback(); }; - /** - * Produces an XML serialization of an element node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeElementNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_2, _a; - var attributes = []; - /** - * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node - * - * 1. If the require well-formed flag is set (its value is true), and this - * node's localName attribute contains the character ":" (U+003A COLON) or - * does not match the XML Name production, then throw an exception; the - * serialization of this node would not be a well-formed element. - */ - if (requireWellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - throw new Error("Node local name contains invalid characters (well-formed required)."); - } - /** - * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). - * 3. Let qualified name be an empty string. - * 4. Let skip end tag be a boolean flag with value false. - * 5. Let ignore namespace definition attribute be a boolean flag with value - * false. - * 6. Given prefix map, copy a namespace prefix map and let map be the - * result. - * 7. Let local prefixes map be an empty map. The map has unique Node prefix - * strings as its keys, with corresponding namespaceURI Node values as the - * map's key values (in this map, the null namespace is represented by the - * empty string). - * - * _Note:_ This map is local to each element. It is used to ensure there - * are no conflicting prefixes should a new namespace prefix attribute need - * to be generated. It is also used to enable skipping of duplicate prefix - * definitions when writing an element's attributes: the map allows the - * algorithm to distinguish between a prefix in the namespace prefix map - * that might be locally-defined (to the current Element) and one that is - * not. - * 8. Let local default namespace be the result of recording the namespace - * information for node given map and local prefixes map. - * - * _Note:_ The above step will update map with any found namespace prefix - * definitions, add the found prefix definitions to the local prefixes map - * and return a local default namespace value defined by a default namespace - * attribute if one exists. Otherwise it returns null. - * 9. Let inherited ns be a copy of namespace. - * 10. Let ns be the value of node's namespaceURI attribute. - */ - var qualifiedName = ''; - var skipEndTag = false; - var ignoreNamespaceDefinitionAttribute = false; - var map = prefixMap.copy(); - var localPrefixesMap = {}; - var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); - var inheritedNS = namespace; - var ns = node.namespaceURI; - /** 11. If inherited ns is equal to ns, then: */ - if (inheritedNS === ns) { - /** - * 11.1. If local default namespace is not null, then set ignore - * namespace definition attribute to true. - */ - if (localDefaultNamespace !== null) { - ignoreNamespaceDefinitionAttribute = true; - } - /** - * 11.2. If ns is the XML namespace, then append to qualified name the - * concatenation of the string "xml:" and the value of node's localName. - * 11.3. Otherwise, append to qualified name the value of node's - * localName. The node's prefix if it exists, is dropped. - */ - if (ns === infra_1.namespace.XML) { - qualifiedName = 'xml:' + node.localName; - } - else { - qualifiedName = node.localName; - } - /** 11.4. Append the value of qualified name to markup. */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - } - else { - /** - * 12. Otherwise, inherited ns is not equal to ns (the node's own - * namespace is different from the context namespace of its parent). - * Run these sub-steps: - * - * 12.1. Let prefix be the value of node's prefix attribute. - * 12.2. Let candidate prefix be the result of retrieving a preferred - * prefix string prefix from map given namespace ns. The above may return - * null if no namespace key ns exists in map. - */ - var prefix = node.prefix; - /** - * We don't need to run "retrieving a preferred prefix string" algorithm if - * the element has no prefix and its namespace matches to the default - * namespace. - * See: https://github.com/web-platform-tests/wpt/pull/16703 - */ - var candidatePrefix = null; - if (prefix !== null || ns !== localDefaultNamespace) { - candidatePrefix = map.get(prefix, ns); - } - /** - * 12.3. If the value of prefix matches "xmlns", then run the following - * steps: - */ - if (prefix === "xmlns") { - /** - * 12.3.1. If the require well-formed flag is set, then throw an error. - * An Element with prefix "xmlns" will not legally round-trip in a - * conforming XML parser. - */ - if (requireWellFormed) { - throw new Error("An element cannot have the 'xmlns' prefix (well-formed required)."); - } - /** - * 12.3.2. Let candidate prefix be the value of prefix. - */ - candidatePrefix = prefix; - } - /** - * 12.4.Found a suitable namespace prefix: if candidate prefix is not - * null (a namespace prefix is defined which maps to ns), then: - */ - if (candidatePrefix !== null) { - /** - * The following may serialize a different prefix than the Element's - * existing prefix if it already had one. However, the retrieving a - * preferred prefix string algorithm already tried to match the - * existing prefix if possible. - * - * 12.4.1. Append to qualified name the concatenation of candidate - * prefix, ":" (U+003A COLON), and node's localName. There exists on - * this node or the node's ancestry a namespace prefix definition that - * defines the node's namespace. - * 12.4.2. If the local default namespace is not null (there exists a - * locally-defined default namespace declaration attribute) and its - * value is not the XML namespace, then let inherited ns get the value - * of local default namespace unless the local default namespace is the - * empty string in which case let it get null (the context namespace - * is changed to the declared default, rather than this node's own - * namespace). - * - * _Note:_ Any default namespace definitions or namespace prefixes that - * define the XML namespace are omitted when serializing this node's - * attributes. - */ - qualifiedName = candidatePrefix + ':' + node.localName; - if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { - inheritedNS = localDefaultNamespace || null; - } - /** - * 12.4.3. Append the value of qualified name to markup. - */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** 12.5. Otherwise, if prefix is not null, then: */ - } - else if (prefix !== null) { - /** - * _Note:_ By this step, there is no namespace or prefix mapping - * declaration in this node (or any parent node visited by this - * algorithm) that defines prefix otherwise the step labelled Found - * a suitable namespace prefix would have been followed. The sub-steps - * that follow will create a new namespace prefix declaration for prefix - * and ensure that prefix does not conflict with an existing namespace - * prefix declaration of the same localName in node's attribute list. - * - * 12.5.1. If the local prefixes map contains a key matching prefix, - * then let prefix be the result of generating a prefix providing as - * input map, ns, and prefix index. - */ - if (prefix in localPrefixesMap) { - prefix = this._generatePrefix(ns, map, prefixIndex); - } - /** - * 12.5.2. Add prefix to map given namespace ns. - * 12.5.3. Append to qualified name the concatenation of prefix, ":" - * (U+003A COLON), and node's localName. - * 12.5.4. Append the value of qualified name to markup. - */ - map.set(prefix, ns); - qualifiedName += prefix + ':' + node.localName; - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 12.5.5. Append the following to markup, in the order listed: - * - * _Note:_ The following serializes a namespace prefix declaration for - * prefix which was just added to the map. - * - * 12.5.5.1. " " (U+0020 SPACE); - * 12.5.5.2. The string "xmlns:"; - * 12.5.5.3. The value of prefix; - * 12.5.5.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 12.5.5.5. The result of serializing an attribute value given ns and - * the require well-formed flag as input; - * 12.5.5.6. """ (U+0022 QUOTATION MARK). - */ - attributes.push([null, 'xmlns', prefix, - this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); - /** - * 12.5.5.7. If local default namespace is not null (there exists a - * locally-defined default namespace declaration attribute), then - * let inherited ns get the value of local default namespace unless the - * local default namespace is the empty string in which case let it get - * null. - */ - if (localDefaultNamespace !== null) { - inheritedNS = localDefaultNamespace || null; - } - /** - * 12.6. Otherwise, if local default namespace is null, or local - * default namespace is not null and its value is not equal to ns, then: - */ - } - else if (localDefaultNamespace === null || - (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { - /** - * _Note:_ At this point, the namespace for this node still needs to be - * serialized, but there's no prefix (or candidate prefix) available; the - * following uses the default namespace declaration to define the - * namespace--optionally replacing an existing default declaration - * if present. - * - * 12.6.1. Set the ignore namespace definition attribute flag to true. - * 12.6.2. Append to qualified name the value of node's localName. - * 12.6.3. Let the value of inherited ns be ns. - * - * _Note:_ The new default namespace will be used in the serialization - * to define this node's namespace and act as the context namespace for - * its children. - */ - ignoreNamespaceDefinitionAttribute = true; - qualifiedName += node.localName; - inheritedNS = ns; - /** - * 12.6.4. Append the value of qualified name to markup. - */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 12.6.5. Append the following to markup, in the order listed: - * - * _Note:_ The following serializes the new (or replacement) default - * namespace definition. - * - * 12.6.5.1. " " (U+0020 SPACE); - * 12.6.5.2. The string "xmlns"; - * 12.6.5.3. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 12.6.5.4. The result of serializing an attribute value given ns - * and the require well-formed flag as input; - * 12.6.5.5. """ (U+0022 QUOTATION MARK). - */ - attributes.push([null, null, 'xmlns', - this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); - /** - * 12.7. Otherwise, the node has a local default namespace that matches - * ns. Append to qualified name the value of node's localName, let the - * value of inherited ns be ns, and append the value of qualified name - * to markup. - */ - } - else { - qualifiedName += node.localName; - inheritedNS = ns; - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - } - } - /** - * 13. Append to markup the result of the XML serialization of node's - * attributes given map, prefix index, local prefixes map, ignore namespace - * definition attribute flag, and require well-formed flag. - */ - attributes.push.apply(attributes, __spread(this._serializeAttributesNS(node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding))); - this.attributes(attributes); - /** - * 14. If ns is the HTML namespace, and the node's list of children is - * empty, and the node's localName matches any one of the following void - * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", - * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", - * "param", "source", "track", "wbr"; then append the following to markup, - * in the order listed: - * 14.1. " " (U+0020 SPACE); - * 14.2. "/" (U+002F SOLIDUS). - * and set the skip end tag flag to true. - * 15. If ns is not the HTML namespace, and the node's list of children is - * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end - * tag flag to true. - * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. - */ - var isHTML = (ns === infra_1.namespace.HTML); - if (isHTML && node.childNodes.length === 0 && - BaseWriter._VoidElementNames.has(node.localName)) { - this.openTagEnd(qualifiedName, true, true); - this.endElement(qualifiedName); - skipEndTag = true; - } - else if (!isHTML && node.childNodes.length === 0) { - this.openTagEnd(qualifiedName, true, false); - this.endElement(qualifiedName); - skipEndTag = true; - } - else { - this.openTagEnd(qualifiedName, false, false); - } - /** - * 17. If the value of skip end tag is true, then return the value of markup - * and skip the remaining steps. The node is a leaf-node. - */ - if (skipEndTag) - return; - /** - * 18. If ns is the HTML namespace, and the node's localName matches the - * string "template", then this is a template element. Append to markup the - * result of XML serializing a DocumentFragment node given the template - * element's template contents (a DocumentFragment), providing inherited - * ns, map, prefix index, and the require well-formed flag. - * - * _Note:_ This allows template content to round-trip, given the rules for - * parsing XHTML documents. - * - * 19. Otherwise, append to markup the result of running the XML - * serialization algorithm on each of node's children, in tree order, - * providing inherited ns, map, prefix index, and the require well-formed - * flag. - */ - if (isHTML && node.localName === "template") { - // TODO: serialize template contents - } - else { - try { - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this.level++; - this._serializeNodeNS(childNode, inheritedNS, map, prefixIndex, requireWellFormed, noDoubleEncoding); - this.level--; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_2) throw e_2.error; } - } - } - /** - * 20. Append the following to markup, in the order listed: - * 20.1. "" (U+003E GREATER-THAN SIGN). - * 21. Return the value of markup. - */ - this.closeTag(qualifiedName); - this.endElement(qualifiedName); + + XMLDocumentCB.prototype.debugInfo = function(name) { + if (name == null) { + return ""; + } else { + return "node: <" + name + ">"; + } }; - /** - * Produces an XML serialization of an element node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeElement = function (node, requireWellFormed, noDoubleEncoding) { - var e_3, _a; - /** - * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node - * - * 1. If the require well-formed flag is set (its value is true), and this - * node's localName attribute contains the character ":" (U+003A COLON) or - * does not match the XML Name production, then throw an exception; the - * serialization of this node would not be a well-formed element. - */ - if (requireWellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - throw new Error("Node local name contains invalid characters (well-formed required)."); - } - /** - * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). - * 3. Let qualified name be an empty string. - * 4. Let skip end tag be a boolean flag with value false. - * 5. Let ignore namespace definition attribute be a boolean flag with value - * false. - * 6. Given prefix map, copy a namespace prefix map and let map be the - * result. - * 7. Let local prefixes map be an empty map. The map has unique Node prefix - * strings as its keys, with corresponding namespaceURI Node values as the - * map's key values (in this map, the null namespace is represented by the - * empty string). - * - * _Note:_ This map is local to each element. It is used to ensure there - * are no conflicting prefixes should a new namespace prefix attribute need - * to be generated. It is also used to enable skipping of duplicate prefix - * definitions when writing an element's attributes: the map allows the - * algorithm to distinguish between a prefix in the namespace prefix map - * that might be locally-defined (to the current Element) and one that is - * not. - * 8. Let local default namespace be the result of recording the namespace - * information for node given map and local prefixes map. - * - * _Note:_ The above step will update map with any found namespace prefix - * definitions, add the found prefix definitions to the local prefixes map - * and return a local default namespace value defined by a default namespace - * attribute if one exists. Otherwise it returns null. - * 9. Let inherited ns be a copy of namespace. - * 10. Let ns be the value of node's namespaceURI attribute. - */ - var skipEndTag = false; - /** 11. If inherited ns is equal to ns, then: */ - /** - * 11.1. If local default namespace is not null, then set ignore - * namespace definition attribute to true. - */ - /** - * 11.2. If ns is the XML namespace, then append to qualified name the - * concatenation of the string "xml:" and the value of node's localName. - * 11.3. Otherwise, append to qualified name the value of node's - * localName. The node's prefix if it exists, is dropped. - */ - var qualifiedName = node.localName; - /** 11.4. Append the value of qualified name to markup. */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 13. Append to markup the result of the XML serialization of node's - * attributes given map, prefix index, local prefixes map, ignore namespace - * definition attribute flag, and require well-formed flag. - */ - var attributes = this._serializeAttributes(node, requireWellFormed, noDoubleEncoding); - this.attributes(attributes); - /** - * 14. If ns is the HTML namespace, and the node's list of children is - * empty, and the node's localName matches any one of the following void - * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", - * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", - * "param", "source", "track", "wbr"; then append the following to markup, - * in the order listed: - * 14.1. " " (U+0020 SPACE); - * 14.2. "/" (U+002F SOLIDUS). - * and set the skip end tag flag to true. - * 15. If ns is not the HTML namespace, and the node's list of children is - * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end - * tag flag to true. - * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. - */ - if (!node.hasChildNodes()) { - this.openTagEnd(qualifiedName, true, false); - this.endElement(qualifiedName); - skipEndTag = true; - } - else { - this.openTagEnd(qualifiedName, false, false); - } - /** - * 17. If the value of skip end tag is true, then return the value of markup - * and skip the remaining steps. The node is a leaf-node. - */ - if (skipEndTag) - return; - try { - /** - * 18. If ns is the HTML namespace, and the node's localName matches the - * string "template", then this is a template element. Append to markup the - * result of XML serializing a DocumentFragment node given the template - * element's template contents (a DocumentFragment), providing inherited - * ns, map, prefix index, and the require well-formed flag. - * - * _Note:_ This allows template content to round-trip, given the rules for - * parsing XHTML documents. - * - * 19. Otherwise, append to markup the result of running the XML - * serialization algorithm on each of node's children, in tree order, - * providing inherited ns, map, prefix index, and the require well-formed - * flag. - */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this.level++; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); - this.level--; - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_3) throw e_3.error; } - } - /** - * 20. Append the following to markup, in the order listed: - * 20.1. "" (U+003E GREATER-THAN SIGN). - * 21. Return the value of markup. - */ - this.closeTag(qualifiedName); - this.endElement(qualifiedName); + + XMLDocumentCB.prototype.ele = function() { + return this.element.apply(this, arguments); }; - /** - * Produces an XML serialization of a document node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_4, _a; - /** - * If the require well-formed flag is set (its value is true), and this node - * has no documentElement (the documentElement attribute's value is null), - * then throw an exception; the serialization of this node would not be a - * well-formed document. - */ - if (requireWellFormed && node.documentElement === null) { - throw new Error("Missing document element (well-formed required)."); - } - try { - /** - * Otherwise, run the following steps: - * 1. Let serialized document be an empty string. - * 2. For each child child of node, in tree order, run the XML - * serialization algorithm on the child passing along the provided - * arguments, and append the result to serialized document. - * - * _Note:_ This will serialize any number of ProcessingInstruction and - * Comment nodes both before and after the Document's documentElement node, - * including at most one DocumentType node. (Text nodes are not allowed as - * children of the Document.) - * - * 3. Return the value of serialized document. - */ - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - } - } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_4) throw e_4.error; } - } + + XMLDocumentCB.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); }; - /** - * Produces an XML serialization of a document node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocument = function (node, requireWellFormed, noDoubleEncoding) { - var e_5, _a; - /** - * If the require well-formed flag is set (its value is true), and this node - * has no documentElement (the documentElement attribute's value is null), - * then throw an exception; the serialization of this node would not be a - * well-formed document. - */ - if (requireWellFormed && node.documentElement === null) { - throw new Error("Missing document element (well-formed required)."); - } - try { - /** - * Otherwise, run the following steps: - * 1. Let serialized document be an empty string. - * 2. For each child child of node, in tree order, run the XML - * serialization algorithm on the child passing along the provided - * arguments, and append the result to serialized document. - * - * _Note:_ This will serialize any number of ProcessingInstruction and - * Comment nodes both before and after the Document's documentElement node, - * including at most one DocumentType node. (Text nodes are not allowed as - * children of the Document.) - * - * 3. Return the value of serialized document. - */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); - } - } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_5) throw e_5.error; } - } + + XMLDocumentCB.prototype.txt = function(value) { + return this.text(value); }; - /** - * Produces an XML serialization of a comment node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeComment = function (node, requireWellFormed, noDoubleEncoding) { - /** - * If the require well-formed flag is set (its value is true), and node's - * data contains characters that are not matched by the XML Char production - * or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that - * ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception; - * the serialization of this node's data would not be well-formed. - */ - if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || - node.data.indexOf("--") !== -1 || node.data.endsWith("-"))) { - throw new Error("Comment data contains invalid characters (well-formed required)."); - } - /** - * Otherwise, return the concatenation of "". - */ - this.comment(node.data); + + XMLDocumentCB.prototype.dat = function(value) { + return this.cdata(value); }; - /** - * Produces an XML serialization of a text node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - * @param level - current depth of the XML tree - */ - BaseWriter.prototype._serializeText = function (node, requireWellFormed, noDoubleEncoding) { - /** - * 1. If the require well-formed flag is set (its value is true), and - * node's data contains characters that are not matched by the XML Char - * production, then throw an exception; the serialization of this node's - * data would not be well-formed. - */ - if (requireWellFormed && !algorithm_1.xml_isLegalChar(node.data)) { - throw new Error("Text data contains invalid characters (well-formed required)."); - } - /** - * 2. Let markup be the value of node's data. - * 3. Replace any occurrences of "&" in markup by "&". - * 4. Replace any occurrences of "<" in markup by "<". - * 5. Replace any occurrences of ">" in markup by ">". - * 6. Return the value of markup. - */ - var markup = ""; - if (noDoubleEncoding) { - markup = node.data.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>'); - } - else { - for (var i = 0; i < node.data.length; i++) { - var c = node.data[i]; - if (c === "&") - markup += "&"; - else if (c === "<") - markup += "<"; - else if (c === ">") - markup += ">"; - else - markup += c; - } - } - this.text(markup); + + XMLDocumentCB.prototype.com = function(value) { + return this.comment(value); }; - /** - * Produces an XML serialization of a document fragment node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentFragmentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_6, _a; - try { - /** - * 1. Let markup the empty string. - * 2. For each child child of node, in tree order, run the XML serialization - * algorithm on the child given namespace, prefix map, a reference to prefix - * index, and flag require well-formed. Concatenate the result to markup. - * 3. Return the value of markup. - */ - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - } - } - catch (e_6_1) { e_6 = { error: e_6_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_6) throw e_6.error; } - } + + XMLDocumentCB.prototype.ins = function(target, value) { + return this.instruction(target, value); }; - /** - * Produces an XML serialization of a document fragment node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentFragment = function (node, requireWellFormed, noDoubleEncoding) { - var e_7, _a; - try { - /** - * 1. Let markup the empty string. - * 2. For each child child of node, in tree order, run the XML serialization - * algorithm on the child given namespace, prefix map, a reference to prefix - * index, and flag require well-formed. Concatenate the result to markup. - * 3. Return the value of markup. - */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); - } - } - catch (e_7_1) { e_7 = { error: e_7_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_7) throw e_7.error; } - } + + XMLDocumentCB.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); }; - /** - * Produces an XML serialization of a document type node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentType = function (node, requireWellFormed, noDoubleEncoding) { - /** - * 1. If the require well-formed flag is true and the node's publicId - * attribute contains characters that are not matched by the XML PubidChar - * production, then throw an exception; the serialization of this node - * would not be a well-formed document type declaration. - */ - if (requireWellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { - throw new Error("DocType public identifier does not match PubidChar construct (well-formed required)."); - } - /** - * 2. If the require well-formed flag is true and the node's systemId - * attribute contains characters that are not matched by the XML Char - * production or that contains both a """ (U+0022 QUOTATION MARK) and a - * "'" (U+0027 APOSTROPHE), then throw an exception; the serialization - * of this node would not be a well-formed document type declaration. - */ - if (requireWellFormed && - (!algorithm_1.xml_isLegalChar(node.systemId) || - (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { - throw new Error("DocType system identifier contains invalid characters (well-formed required)."); - } - /** - * 3. Let markup be an empty string. - * 4. Append the string "" (U+003E GREATER-THAN SIGN) to markup. - * 11. Return the value of markup. - */ - this.docType(node.name, node.publicId, node.systemId); + + XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) { + return this.doctype(root, pubID, sysID); }; - /** - * Produces an XML serialization of a processing instruction node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeProcessingInstruction = function (node, requireWellFormed, noDoubleEncoding) { - /** - * 1. If the require well-formed flag is set (its value is true), and node's - * target contains a ":" (U+003A COLON) character or is an ASCII - * case-insensitive match for the string "xml", then throw an exception; - * the serialization of this node's target would not be well-formed. - */ - if (requireWellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { - throw new Error("Processing instruction target contains invalid characters (well-formed required)."); - } - /** - * 2. If the require well-formed flag is set (its value is true), and node's - * data contains characters that are not matched by the XML Char production - * or contains the string "?>" (U+003F QUESTION MARK, - * U+003E GREATER-THAN SIGN), then throw an exception; the serialization of - * this node's data would not be well-formed. - */ - if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || - node.data.indexOf("?>") !== -1)) { - throw new Error("Processing instruction data contains invalid characters (well-formed required)."); - } - /** - * 3. Let markup be the concatenation of the following, in the order listed: - * 3.1. "" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN). - * 4. Return the value of markup. - */ - this.instruction(node.target, node.data); + + XMLDocumentCB.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); }; - /** - * Produces an XML serialization of a CDATA node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeCData = function (node, requireWellFormed, noDoubleEncoding) { - if (requireWellFormed && (node.data.indexOf("]]>") !== -1)) { - throw new Error("CDATA contains invalid characters (well-formed required)."); - } - this.cdata(node.data); + + XMLDocumentCB.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); }; - /** - * Produces an XML serialization of the attributes of an element node. - * - * @param node - node to serialize - * @param map - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param localPrefixesMap - local prefixes map - * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace - * attributes - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributesNS = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding) { - var e_8, _a; - /** - * 1. Let result be the empty string. - * 2. Let localname set be a new empty namespace localname set. This - * localname set will contain tuples of unique attribute namespaceURI and - * localName pairs, and is populated as each attr is processed. This set is - * used to [optionally] enforce the well-formed constraint that an element - * cannot have two attributes with the same namespaceURI and localName. - * This can occur when two otherwise identical attributes on the same - * element differ only by their prefix values. - */ - var result = []; - var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; - try { - /** - * 3. Loop: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: - */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - // Optimize common case - if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - continue; - } - /** - * 3.1. If the require well-formed flag is set (its value is true), and the - * localname set contains a tuple whose values match those of a new tuple - * consisting of attr's namespaceURI attribute and localName attribute, - * then throw an exception; the serialization of this attr would fail to - * produce a well-formed element serialization. - */ - if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { - throw new Error("Element contains duplicate attributes (well-formed required)."); - } - /** - * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and - * localName attribute, and add it to the localname set. - * 3.3. Let attribute namespace be the value of attr's namespaceURI value. - * 3.4. Let candidate prefix be null. - */ - if (requireWellFormed && localNameSet) - localNameSet.set(attr.namespaceURI, attr.localName); - var attributeNamespace = attr.namespaceURI; - var candidatePrefix = null; - /** 3.5. If attribute namespace is not null, then run these sub-steps: */ - if (attributeNamespace !== null) { - /** - * 3.5.1. Let candidate prefix be the result of retrieving a preferred - * prefix string from map given namespace attribute namespace with - * preferred prefix being attr's prefix value. - */ - candidatePrefix = map.get(attr.prefix, attributeNamespace); - /** - * 3.5.2. If the value of attribute namespace is the XMLNS namespace, - * then run these steps: - */ - if (attributeNamespace === infra_1.namespace.XMLNS) { - /** - * 3.5.2.1. If any of the following are true, then stop running these - * steps and goto Loop to visit the next attribute: - * - the attr's value is the XML namespace; - * _Note:_ The XML namespace cannot be redeclared and survive - * round-tripping (unless it defines the prefix "xml"). To avoid this - * problem, this algorithm always prefixes elements in the XML - * namespace with "xml" and drops any related definitions as seen - * in the above condition. - * - the attr's prefix is null and the ignore namespace definition - * attribute flag is true (the Element's default namespace attribute - * should be skipped); - * - the attr's prefix is not null and either - * * the attr's localName is not a key contained in the local - * prefixes map, or - * * the attr's localName is present in the local prefixes map but - * the value of the key does not match attr's value - * and furthermore that the attr's localName (as the prefix to find) - * is found in the namespace prefix map given the namespace consisting - * of the attr's value (the current namespace prefix definition was - * exactly defined previously--on an ancestor element not the current - * element whose attributes are being processed). - */ - if (attr.value === infra_1.namespace.XML || - (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || - (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || - localPrefixesMap[attr.localName] !== attr.value) && - map.has(attr.localName, attr.value))) - continue; - /** - * 3.5.2.2. If the require well-formed flag is set (its value is true), - * and the value of attr's value attribute matches the XMLNS - * namespace, then throw an exception; the serialization of this - * attribute would produce invalid XML because the XMLNS namespace - * is reserved and cannot be applied as an element's namespace via - * XML parsing. - * - * _Note:_ DOM APIs do allow creation of elements in the XMLNS - * namespace but with strict qualifications. - */ - if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { - throw new Error("XMLNS namespace is reserved (well-formed required)."); - } - /** - * 3.5.2.3. If the require well-formed flag is set (its value is true), - * and the value of attr's value attribute is the empty string, then - * throw an exception; namespace prefix declarations cannot be used - * to undeclare a namespace (use a default namespace declaration - * instead). - */ - if (requireWellFormed && attr.value === '') { - throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required)."); - } - /** - * 3.5.2.4. the attr's prefix matches the string "xmlns", then let - * candidate prefix be the string "xmlns". - */ - if (attr.prefix === 'xmlns') - candidatePrefix = 'xmlns'; - /** - * 3.5.3. Otherwise, the attribute namespace is not the XMLNS namespace. - * Run these steps: - * - * _Note:_ The (candidatePrefix === null) check is not in the spec. - * We deviate from the spec here. Otherwise a prefix is generated for - * all attributes with namespaces. - */ - } - else if (candidatePrefix === null) { - if (attr.prefix !== null && - (!map.hasPrefix(attr.prefix) || - map.has(attr.prefix, attributeNamespace))) { - /** - * Check if we can use the attribute's own prefix. - * We deviate from the spec here. - * TODO: This is not an efficient way of searching for prefixes. - * Follow developments to the spec. - */ - candidatePrefix = attr.prefix; - } - else { - /** - * 3.5.3.1. Let candidate prefix be the result of generating a prefix - * providing map, attribute namespace, and prefix index as input. - */ - candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); - } - /** - * 3.5.3.2. Append the following to result, in the order listed: - * 3.5.3.2.1. " " (U+0020 SPACE); - * 3.5.3.2.2. The string "xmlns:"; - * 3.5.3.2.3. The value of candidate prefix; - * 3.5.3.2.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.5.3.2.5. The result of serializing an attribute value given - * attribute namespace and the require well-formed flag as input; - * 3.5.3.2.6. """ (U+0022 QUOTATION MARK). - */ - result.push([null, "xmlns", candidatePrefix, - this._serializeAttributeValue(attributeNamespace, requireWellFormed, noDoubleEncoding)]); - } - } - /** - * 3.6. Append a " " (U+0020 SPACE) to result. - * 3.7. If candidate prefix is not null, then append to result the - * concatenation of candidate prefix with ":" (U+003A COLON). - */ - var attrName = ''; - if (candidatePrefix !== null) { - attrName = candidatePrefix; - } - /** - * 3.8. If the require well-formed flag is set (its value is true), and - * this attr's localName attribute contains the character - * ":" (U+003A COLON) or does not match the XML Name production or - * equals "xmlns" and attribute namespace is null, then throw an - * exception; the serialization of this attr would not be a - * well-formed attribute. - */ - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName) || - (attr.localName === "xmlns" && attributeNamespace === null))) { - throw new Error("Attribute local name contains invalid characters (well-formed required)."); - } - /** - * 3.9. Append the following strings to result, in the order listed: - * 3.9.1. The value of attr's localName; - * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.9.3. The result of serializing an attribute value given attr's value - * attribute and the require well-formed flag as input; - * 3.9.4. """ (U+0022 QUOTATION MARK). - */ - result.push([attributeNamespace, candidatePrefix, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - } - } - catch (e_8_1) { e_8 = { error: e_8_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_8) throw e_8.error; } - } - /** - * 4. Return the value of result. - */ - return result; + + XMLDocumentCB.prototype.t = function(value) { + return this.text(value); }; - /** - * Produces an XML serialization of the attributes of an element node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributes = function (node, requireWellFormed, noDoubleEncoding) { - var e_9, _a; - /** - * 1. Let result be the empty string. - * 2. Let localname set be a new empty namespace localname set. This - * localname set will contain tuples of unique attribute namespaceURI and - * localName pairs, and is populated as each attr is processed. This set is - * used to [optionally] enforce the well-formed constraint that an element - * cannot have two attributes with the same namespaceURI and localName. - * This can occur when two otherwise identical attributes on the same - * element differ only by their prefix values. - */ - var result = []; - var localNameSet = requireWellFormed ? {} : undefined; - try { - /** - * 3. Loop: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: - */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - // Optimize common case - if (!requireWellFormed) { - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - continue; - } - /** - * 3.1. If the require well-formed flag is set (its value is true), and the - * localname set contains a tuple whose values match those of a new tuple - * consisting of attr's namespaceURI attribute and localName attribute, - * then throw an exception; the serialization of this attr would fail to - * produce a well-formed element serialization. - */ - if (requireWellFormed && localNameSet && (attr.localName in localNameSet)) { - throw new Error("Element contains duplicate attributes (well-formed required)."); - } - /** - * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and - * localName attribute, and add it to the localname set. - * 3.3. Let attribute namespace be the value of attr's namespaceURI value. - * 3.4. Let candidate prefix be null. - */ - /* istanbul ignore else */ - if (requireWellFormed && localNameSet) - localNameSet[attr.localName] = true; - /** 3.5. If attribute namespace is not null, then run these sub-steps: */ - /** - * 3.6. Append a " " (U+0020 SPACE) to result. - * 3.7. If candidate prefix is not null, then append to result the - * concatenation of candidate prefix with ":" (U+003A COLON). - */ - /** - * 3.8. If the require well-formed flag is set (its value is true), and - * this attr's localName attribute contains the character - * ":" (U+003A COLON) or does not match the XML Name production or - * equals "xmlns" and attribute namespace is null, then throw an - * exception; the serialization of this attr would not be a - * well-formed attribute. - */ - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName))) { - throw new Error("Attribute local name contains invalid characters (well-formed required)."); - } - /** - * 3.9. Append the following strings to result, in the order listed: - * 3.9.1. The value of attr's localName; - * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.9.3. The result of serializing an attribute value given attr's value - * attribute and the require well-formed flag as input; - * 3.9.4. """ (U+0022 QUOTATION MARK). - */ - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - } - } - catch (e_9_1) { e_9 = { error: e_9_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_9) throw e_9.error; } - } - /** - * 4. Return the value of result. - */ - return result; + + XMLDocumentCB.prototype.d = function(value) { + return this.cdata(value); }; - /** - * Records namespace information for the given element and returns the - * default namespace attribute value. - * - * @param node - element node to process - * @param map - namespace prefix map - * @param localPrefixesMap - local prefixes map - */ - BaseWriter.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { - var e_10, _a; - /** - * 1. Let default namespace attr value be null. - */ - var defaultNamespaceAttrValue = null; - try { - /** - * 2. Main: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: - */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - /** - * _Note:_ The following conditional steps find namespace prefixes. Only - * attributes in the XMLNS namespace are considered (e.g., attributes made - * to look like namespace declarations via - * setAttribute("xmlns:pretend-prefix", "pretend-namespace") are not - * included). - */ - /** 2.1. Let attribute namespace be the value of attr's namespaceURI value. */ - var attributeNamespace = attr.namespaceURI; - /** 2.2. Let attribute prefix be the value of attr's prefix. */ - var attributePrefix = attr.prefix; - /** 2.3. If the attribute namespace is the XMLNS namespace, then: */ - if (attributeNamespace === infra_1.namespace.XMLNS) { - /** - * 2.3.1. If attribute prefix is null, then attr is a default namespace - * declaration. Set the default namespace attr value to attr's value and - * stop running these steps, returning to Main to visit the next - * attribute. - */ - if (attributePrefix === null) { - defaultNamespaceAttrValue = attr.value; - continue; - /** - * 2.3.2. Otherwise, the attribute prefix is not null and attr is a - * namespace prefix definition. Run the following steps: - */ - } - else { - /** 2.3.2.1. Let prefix definition be the value of attr's localName. */ - var prefixDefinition = attr.localName; - /** 2.3.2.2. Let namespace definition be the value of attr's value. */ - var namespaceDefinition = attr.value; - /** - * 2.3.2.3. If namespace definition is the XML namespace, then stop - * running these steps, and return to Main to visit the next - * attribute. - * - * _Note:_ XML namespace definitions in prefixes are completely - * ignored (in order to avoid unnecessary work when there might be - * prefix conflicts). XML namespaced elements are always handled - * uniformly by prefixing (and overriding if necessary) the element's - * localname with the reserved "xml" prefix. - */ - if (namespaceDefinition === infra_1.namespace.XML) { - continue; - } - /** - * 2.3.2.4. If namespace definition is the empty string (the - * declarative form of having no namespace), then let namespace - * definition be null instead. - */ - if (namespaceDefinition === '') { - namespaceDefinition = null; - } - /** - * 2.3.2.5. If prefix definition is found in map given the namespace - * namespace definition, then stop running these steps, and return to - * Main to visit the next attribute. - * - * _Note:_ This step avoids adding duplicate prefix definitions for - * the same namespace in the map. This has the side-effect of avoiding - * later serialization of duplicate namespace prefix declarations in - * any descendant nodes. - */ - if (map.has(prefixDefinition, namespaceDefinition)) { - continue; - } - /** - * 2.3.2.6. Add the prefix prefix definition to map given namespace - * namespace definition. - */ - map.set(prefixDefinition, namespaceDefinition); - /** - * 2.3.2.7. Add the value of prefix definition as a new key to the - * local prefixes map, with the namespace definition as the key's - * value replacing the value of null with the empty string if - * applicable. - */ - localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; - } - } - } - } - catch (e_10_1) { e_10 = { error: e_10_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_10) throw e_10.error; } - } - /** - * 3. Return the value of default namespace attr value. - * - * _Note:_ The empty string is a legitimate return value and is not - * converted to null. - */ - return defaultNamespaceAttrValue; + + XMLDocumentCB.prototype.c = function(value) { + return this.comment(value); }; - /** - * Generates a new prefix for the given namespace. - * - * @param newNamespace - a namespace to generate prefix for - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - */ - BaseWriter.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { - /** - * 1. Let generated prefix be the concatenation of the string "ns" and the - * current numerical value of prefix index. - * 2. Let the value of prefix index be incremented by one. - * 3. Add to map the generated prefix given the new namespace namespace. - * 4. Return the value of generated prefix. - */ - var generatedPrefix = "ns" + prefixIndex.value.toString(); - prefixIndex.value++; - prefixMap.set(generatedPrefix, newNamespace); - return generatedPrefix; + + XMLDocumentCB.prototype.r = function(value) { + return this.raw(value); }; - /** - * Produces an XML serialization of an attribute value. - * - * @param value - attribute value - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributeValue = function (value, requireWellFormed, noDoubleEncoding) { - /** - * From: https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value - * - * 1. If the require well-formed flag is set (its value is true), and - * attribute value contains characters that are not matched by the XML Char - * production, then throw an exception; the serialization of this attribute - * value would fail to produce a well-formed element serialization. - */ - if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { - throw new Error("Invalid characters in attribute value."); - } - /** - * 2. If attribute value is null, then return the empty string. - */ - if (value === null) - return ""; - /** - * 3. Otherwise, attribute value is a string. Return the value of attribute - * value, first replacing any occurrences of the following: - * - "&" with "&" - * - """ with """ - * - "<" with "<" - * - ">" with ">" - * NOTE - * This matches behavior present in browsers, and goes above and beyond the - * grammar requirement in the XML specification's AttValue production by - * also replacing ">" characters. - */ - if (noDoubleEncoding) { - return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - } - else { - var result = ""; - for (var i = 0; i < value.length; i++) { - var c = value[i]; - if (c === "\"") - result += """; - else if (c === "&") - result += "&"; - else if (c === "<") - result += "<"; - else if (c === ">") - result += ">"; - else - result += c; - } - return result; - } + + XMLDocumentCB.prototype.i = function(target, value) { + return this.instruction(target, value); }; - BaseWriter._VoidElementNames = new Set(['area', 'base', 'basefont', - 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', - 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); - return BaseWriter; -}()); -exports.BaseWriter = BaseWriter; -//# sourceMappingURL=BaseWriter.js.map -/***/ }), + XMLDocumentCB.prototype.att = function() { + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + return this.attList.apply(this, arguments); + } else { + return this.attribute.apply(this, arguments); + } + }; -/***/ 7525: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLDocumentCB.prototype.a = function() { + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + return this.attList.apply(this, arguments); + } else { + return this.attribute.apply(this, arguments); + } + }; -"use strict"; + XMLDocumentCB.prototype.ent = function(name, value) { + return this.entity(name, value); + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLDocumentCB.prototype.pent = function(name, value) { + return this.pEntity(name, value); }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLDocumentCB.prototype.not = function(name, value) { + return this.notation(name, value); }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var BaseCBWriter_1 = __nccwpck_require__(708); -/** - * Serializes XML nodes. - */ -var JSONCBWriter = /** @class */ (function (_super) { - __extends(JSONCBWriter, _super); - /** - * Initializes a new instance of `JSONCBWriter`. - * - * @param builderOptions - XML builder options - */ - function JSONCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._hasChildren = []; - _this._additionalLevel = 0; - return _this; + + return XMLDocumentCB; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 3590: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDummy = (function(superClass) { + extend(XMLDummy, superClass); + + function XMLDummy(parent) { + XMLDummy.__super__.constructor.call(this, parent); + this.type = NodeType.Dummy; } - /** @inheritdoc */ - JSONCBWriter.prototype.frontMatter = function () { - return ""; + + XMLDummy.prototype.clone = function() { + return Object.create(this); }; - /** @inheritdoc */ - JSONCBWriter.prototype.declaration = function (version, encoding, standalone) { - return ""; + + XMLDummy.prototype.toString = function(options) { + return ''; }; - /** @inheritdoc */ - JSONCBWriter.prototype.docType = function (name, publicId, systemId) { - return ""; - }; - /** @inheritdoc */ - JSONCBWriter.prototype.comment = function (data) { - // { "!": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.comment) + this._sep() + - this._val(data) + this._sep() + "}"; + + return XMLDummy; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 9437: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(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 = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue; + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + XMLAttribute = __nccwpck_require__(8376); + + XMLNamedNodeMap = __nccwpck_require__(4361); + + module.exports = XMLElement = (function(superClass) { + extend(XMLElement, superClass); + + function XMLElement(parent, name, attributes) { + var child, j, len, ref1; + XMLElement.__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(XMLElement.prototype, 'tagName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLElement.prototype, 'namespaceURI', { + get: function() { + return ''; + } + }); + + Object.defineProperty(XMLElement.prototype, 'prefix', { + get: function() { + return ''; + } + }); + + Object.defineProperty(XMLElement.prototype, 'localName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLElement.prototype, 'id', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'className', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'classList', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'attributes', { + get: function() { + if (!this.attributeMap || !this.attributeMap.nodes) { + this.attributeMap = new XMLNamedNodeMap(this.attribs); + } + return this.attributeMap; + } + }); + + XMLElement.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; }; - /** @inheritdoc */ - JSONCBWriter.prototype.text = function (data) { - // { "#": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.text) + this._sep() + - this._val(data) + this._sep() + "}"; + + XMLElement.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; }; - /** @inheritdoc */ - JSONCBWriter.prototype.instruction = function (target, data) { - // { "?": "target hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.ins) + this._sep() + - this._val(data ? target + " " + data : target) + this._sep() + "}"; + + XMLElement.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; }; - /** @inheritdoc */ - JSONCBWriter.prototype.cdata = function (data) { - // { "$": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.cdata) + this._sep() + - this._val(data) + this._sep() + "}"; + + XMLElement.prototype.toString = function(options) { + return this.options.writer.element(this, this.options.writer.filterOptions(options)); }; - /** @inheritdoc */ - JSONCBWriter.prototype.attribute = function (name, value) { - // { "@name": "val" } - return this._comma() + this._beginLine(1) + "{" + this._sep() + - this._key(this._builderOptions.convert.att + name) + this._sep() + - this._val(value) + this._sep() + "}"; + + XMLElement.prototype.att = function(name, value) { + return this.attribute(name, value); }; - /** @inheritdoc */ - JSONCBWriter.prototype.openTagBegin = function (name) { - // { "node": { "#": [ - var str = this._comma() + this._beginLine() + "{" + this._sep() + this._key(name) + this._sep() + "{"; - this._additionalLevel++; - this.hasData = true; - str += this._beginLine() + this._key(this._builderOptions.convert.text) + this._sep() + "["; - this._hasChildren.push(false); - return str; + + XMLElement.prototype.a = function(name, value) { + return this.attribute(name, value); }; - /** @inheritdoc */ - JSONCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (selfClosing) { - var str = this._sep() + "]"; - this._additionalLevel--; - str += this._beginLine() + "}" + this._sep() + "}"; - return str; - } - else { - return ""; - } + + XMLElement.prototype.getAttribute = function(name) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name].value; + } else { + return null; + } }; - /** @inheritdoc */ - JSONCBWriter.prototype.closeTag = function (name) { - // ] } } - var str = this._beginLine() + "]"; - this._additionalLevel--; - str += this._beginLine() + "}" + this._sep() + "}"; - return str; + + XMLElement.prototype.setAttribute = function(name, value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - JSONCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - JSONCBWriter.prototype.endElement = function (name) { this._hasChildren.pop(); }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - JSONCBWriter.prototype._beginLine = function (additionalOffset) { - if (additionalOffset === void 0) { additionalOffset = 0; } - if (this._writerOptions.prettyPrint) { - return (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level + additionalOffset); - } - else { - return ""; - } + + XMLElement.prototype.getAttributeNode = function(name) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name]; + } else { + return null; + } }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - */ - JSONCBWriter.prototype._indent = function (level) { - if (level + this._additionalLevel <= 0) { - return ""; - } - else { - return this._writerOptions.indent.repeat(level + this._additionalLevel); - } + + XMLElement.prototype.setAttributeNode = function(newAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces a comma before a child node if it has previous siblings. - */ - JSONCBWriter.prototype._comma = function () { - var str = (this._hasChildren[this._hasChildren.length - 1] ? "," : ""); - if (this._hasChildren.length > 0) { - this._hasChildren[this._hasChildren.length - 1] = true; - } - return str; + + XMLElement.prototype.removeAttributeNode = function(oldAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces a separator string. - */ - JSONCBWriter.prototype._sep = function () { - return (this._writerOptions.prettyPrint ? " " : ""); + + XMLElement.prototype.getElementsByTagName = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces a JSON key string delimited with double quotes. - */ - JSONCBWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + + XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces a JSON value string delimited with double quotes. - */ - JSONCBWriter.prototype._val = function (val) { - return JSON.stringify(val); + + XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - return JSONCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.JSONCBWriter = JSONCBWriter; -//# sourceMappingURL=JSONCBWriter.js.map -/***/ }), + XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -/***/ 7510: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -"use strict"; + XMLElement.prototype.setAttributeNodeNS = function(newAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLElement.prototype.hasAttribute = function(name) { + return this.attribs.hasOwnProperty(name); }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; + + XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.setIdAttribute = function(name, isId) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name].isId; + } else { + return isId; + } + }; + + XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getElementsByTagName = function(tagname) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.getElementsByClassName = function(classNames) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.isEqualNode = function(node) { + var i, j, ref1; + if (!XMLElement.__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; }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectWriter_1 = __nccwpck_require__(243); -var util_1 = __nccwpck_require__(6195); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into a JSON string. - */ -var JSONWriter = /** @class */ (function (_super) { - __extends(JSONWriter, _super); - /** - * Initializes a new instance of `JSONWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function JSONWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - prettyPrint: false, - indent: ' ', - newline: '\n', - offset: 0, - group: false, - verbose: false - }); - return _this; + + return XMLElement; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 4361: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLNamedNodeMap; + + module.exports = XMLNamedNodeMap = (function() { + function XMLNamedNodeMap(nodes) { + this.nodes = nodes; } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - * @param writerOptions - serialization options - */ - JSONWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - // recursively convert object into JSON string - return this._beginLine(this._writerOptions, 0) + this._convertObject(val, this._writerOptions); + + Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { + get: function() { + return Object.keys(this.nodes).length || 0; + } + }); + + XMLNamedNodeMap.prototype.clone = function() { + return this.nodes = null; }; - /** - * Produces an XML serialization of the given object. - * - * @param obj - object to serialize - * @param options - serialization options - * @param level - depth of the XML tree - */ - JSONWriter.prototype._convertObject = function (obj, options, level) { - var e_1, _a; - var _this = this; - if (level === void 0) { level = 0; } - var markup = ''; - var isLeaf = this._isLeafNode(obj); - if (util_1.isArray(obj)) { - markup += '['; - var len = obj.length; - var i = 0; - try { - for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { - var val = obj_1_1.value; - markup += this._endLine(options, level + 1) + - this._beginLine(options, level + 1) + - this._convertObject(val, options, level + 1); - if (i < len - 1) { - markup += ','; - } - i++; - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); - } - finally { if (e_1) throw e_1.error; } - } - markup += this._endLine(options, level) + this._beginLine(options, level); - markup += ']'; - } - else if (util_1.isObject(obj)) { - markup += '{'; - var len_1 = util_1.objectLength(obj); - var i_1 = 0; - util_1.forEachObject(obj, function (key, val) { - if (isLeaf && options.prettyPrint) { - markup += ' '; - } - else { - markup += _this._endLine(options, level + 1) + _this._beginLine(options, level + 1); - } - markup += _this._key(key); - if (options.prettyPrint) { - markup += ' '; - } - markup += _this._convertObject(val, options, level + 1); - if (i_1 < len_1 - 1) { - markup += ','; - } - i_1++; - }, this); - if (isLeaf && options.prettyPrint) { - markup += ' '; - } - else { - markup += this._endLine(options, level) + this._beginLine(options, level); - } - markup += '}'; - } - else { - markup += this._val(obj); - } - return markup; + + XMLNamedNodeMap.prototype.getNamedItem = function(name) { + return this.nodes[name]; }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - */ - JSONWriter.prototype._beginLine = function (options, level) { - if (!options.prettyPrint) { - return ''; - } - else { - var indentLevel = options.offset + level + 1; - if (indentLevel > 0) { - return new Array(indentLevel).join(options.indent); - } - } - return ''; + + XMLNamedNodeMap.prototype.setNamedItem = function(node) { + var oldNode; + oldNode = this.nodes[node.nodeName]; + this.nodes[node.nodeName] = node; + return oldNode || null; }; - /** - * Produces characters to be appended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - */ - JSONWriter.prototype._endLine = function (options, level) { - if (!options.prettyPrint) { - return ''; - } - else { - return options.newline; - } + + XMLNamedNodeMap.prototype.removeNamedItem = function(name) { + var oldNode; + oldNode = this.nodes[name]; + delete this.nodes[name]; + return oldNode || null; }; - /** - * Produces a JSON key string delimited with double quotes. - */ - JSONWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + + XMLNamedNodeMap.prototype.item = function(index) { + return this.nodes[Object.keys(this.nodes)[index]] || null; }; - /** - * Produces a JSON value string delimited with double quotes. - */ - JSONWriter.prototype._val = function (val) { - return JSON.stringify(val); + + XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented."); }; - /** - * Determines if an object is a leaf node. - * - * @param obj - */ - JSONWriter.prototype._isLeafNode = function (obj) { - return this._descendantCount(obj) <= 1; + + XMLNamedNodeMap.prototype.setNamedItemNS = function(node) { + throw new Error("This DOM method is not implemented."); }; - /** - * Counts the number of descendants of the given object. - * - * @param obj - * @param count - */ - JSONWriter.prototype._descendantCount = function (obj, count) { - var _this = this; - if (count === void 0) { count = 0; } - if (util_1.isArray(obj)) { - util_1.forEachArray(obj, function (val) { return count += _this._descendantCount(val, count); }, this); - } - else if (util_1.isObject(obj)) { - util_1.forEachObject(obj, function (key, val) { return count += _this._descendantCount(val, count); }, this); - } - else { - count++; - } - return count; + + XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented."); }; - return JSONWriter; -}(BaseWriter_1.BaseWriter)); -exports.JSONWriter = JSONWriter; -//# sourceMappingURL=JSONWriter.js.map -/***/ }), + return XMLNamedNodeMap; -/***/ 1397: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + })(); -"use strict"; +}).call(this); -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var ObjectWriter_1 = __nccwpck_require__(243); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into ES6 maps and arrays. - */ -var MapWriter = /** @class */ (function (_super) { - __extends(MapWriter, _super); - /** - * Initializes a new instance of `MapWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function MapWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - format: "map", - wellFormed: false, - noDoubleEncoding: false, - group: false, - verbose: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - MapWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - verbose: false - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - // recursively convert object into Map - return this._convertObject(val); - }; - /** - * Recursively converts a JS object into an ES5 map. - * - * @param obj - a JS object - */ - MapWriter.prototype._convertObject = function (obj) { - if (util_1.isArray(obj)) { - for (var i = 0; i < obj.length; i++) { - obj[i] = this._convertObject(obj[i]); - } - return obj; - } - else if (util_1.isObject(obj)) { - var map = new Map(); - for (var key in obj) { - map.set(key, this._convertObject(obj[key])); - } - return map; - } - else { - return obj; - } - }; - return MapWriter; -}(BaseWriter_1.BaseWriter)); -exports.MapWriter = MapWriter; -//# sourceMappingURL=MapWriter.js.map /***/ }), -/***/ 243: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; +/***/ 7608: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var interfaces_1 = __nccwpck_require__(7305); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into objects and arrays. - */ -var ObjectWriter = /** @class */ (function (_super) { - __extends(ObjectWriter, _super); - /** - * Initializes a new instance of `ObjectWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function ObjectWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._writerOptions = util_1.applyDefaults(writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - group: false, - verbose: false - }); - return _this; +// Generated by CoffeeScript 1.12.7 +(function() { + var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1, + hasProp = {}.hasOwnProperty; + + ref1 = __nccwpck_require__(8229), 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; + + module.exports = XMLNode = (function() { + function XMLNode(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 = __nccwpck_require__(9437); + XMLCData = __nccwpck_require__(333); + XMLComment = __nccwpck_require__(4407); + XMLDeclaration = __nccwpck_require__(6364); + XMLDocType = __nccwpck_require__(1801); + XMLRaw = __nccwpck_require__(6329); + XMLText = __nccwpck_require__(1318); + XMLProcessingInstruction = __nccwpck_require__(6939); + XMLDummy = __nccwpck_require__(3590); + NodeType = __nccwpck_require__(9267); + XMLNodeList = __nccwpck_require__(6768); + XMLNamedNodeMap = __nccwpck_require__(4361); + DocumentPosition = __nccwpck_require__(2839); + } } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - ObjectWriter.prototype.serialize = function (node) { - this._currentList = []; - this._currentIndex = 0; - this._listRegister = [this._currentList]; - /** - * First pass, serialize nodes - * This creates a list of nodes grouped under node types while preserving - * insertion order. For example: - * [ - * root: [ - * node: [ - * { "@" : { "att1": "val1", "att2": "val2" } - * { "#": "node text" } - * { childNode: [] } - * { "#": "more text" } - * ], - * node: [ - * { "@" : { "att": "val" } - * { "#": [ "text line1", "text line2" ] } - * ] - * ] - * ] - */ - this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); - /** - * Second pass, process node lists. Above example becomes: - * { - * root: { - * node: [ - * { - * "@att1": "val1", - * "@att2": "val2", - * "#1": "node text", - * childNode: {}, - * "#2": "more text" - * }, - * { - * "@att": "val", - * "#": [ "text line1", "text line2" ] - * } - * ] - * } - * } - */ - return this._process(this._currentList, this._writerOptions); - }; - ObjectWriter.prototype._process = function (items, options) { - var _a, _b, _c, _d, _e, _f, _g; - if (items.length === 0) - return {}; - // determine if there are non-unique element names - var namesSeen = {}; - var hasNonUniqueNames = false; - var textCount = 0; - var commentCount = 0; - var instructionCount = 0; - var cdataCount = 0; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - continue; - case "#": - textCount++; - break; - case "!": - commentCount++; - break; - case "?": - instructionCount++; - break; - case "$": - cdataCount++; - break; - default: - if (namesSeen[key]) { - hasNonUniqueNames = true; - } - else { - namesSeen[key] = true; - } - break; - } - } - var defAttrKey = this._getAttrKey(); - var defTextKey = this._getNodeKey(interfaces_1.NodeType.Text); - var defCommentKey = this._getNodeKey(interfaces_1.NodeType.Comment); - var defInstructionKey = this._getNodeKey(interfaces_1.NodeType.ProcessingInstruction); - var defCdataKey = this._getNodeKey(interfaces_1.NodeType.CData); - if (textCount === 1 && items.length === 1 && util_1.isString(items[0]["#"])) { - // special case of an element node with a single text node - return items[0]["#"]; + + Object.defineProperty(XMLNode.prototype, 'nodeName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLNode.prototype, 'nodeType', { + get: function() { + return this.type; + } + }); + + Object.defineProperty(XMLNode.prototype, 'nodeValue', { + get: function() { + return this.value; + } + }); + + Object.defineProperty(XMLNode.prototype, 'parentNode', { + get: function() { + return this.parent; + } + }); + + Object.defineProperty(XMLNode.prototype, 'childNodes', { + get: function() { + if (!this.childNodeList || !this.childNodeList.nodes) { + this.childNodeList = new XMLNodeList(this.children); } - else if (hasNonUniqueNames) { - var obj = {}; - // process attributes first - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - if (key === "@") { - var attrs = item["@"]; - var attrKeys = Object.keys(attrs); - if (attrKeys.length === 1) { - obj[defAttrKey + attrKeys[0]] = attrs[attrKeys[0]]; - } - else { - obj[defAttrKey] = item["@"]; - } - } - } - // list contains element nodes with non-unique names - // return an array with mixed content notation - var result = []; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - // attributes were processed above - break; - case "#": - result.push((_a = {}, _a[defTextKey] = item["#"], _a)); - break; - case "!": - result.push((_b = {}, _b[defCommentKey] = item["!"], _b)); - break; - case "?": - result.push((_c = {}, _c[defInstructionKey] = item["?"], _c)); - break; - case "$": - result.push((_d = {}, _d[defCdataKey] = item["$"], _d)); - break; - default: - // element node - var ele = item; - if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { - // group of element nodes - var eleGroup = []; - var listOfLists = ele[key]; - for (var i_1 = 0; i_1 < listOfLists.length; i_1++) { - eleGroup.push(this._process(listOfLists[i_1], options)); - } - result.push((_e = {}, _e[key] = eleGroup, _e)); - } - else { - // single element node - if (options.verbose) { - result.push((_f = {}, _f[key] = [this._process(ele[key], options)], _f)); - } - else { - result.push((_g = {}, _g[key] = this._process(ele[key], options), _g)); - } - } - break; - } - } - obj[defTextKey] = result; - return obj; - } - else { - // all element nodes have unique names - // return an object while prefixing data node keys - var textId = 1; - var commentId = 1; - var instructionId = 1; - var cdataId = 1; - var obj = {}; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - var attrs = item["@"]; - var attrKeys = Object.keys(attrs); - if (!options.group || attrKeys.length === 1) { - for (var attrName in attrs) { - obj[defAttrKey + attrName] = attrs[attrName]; - } - } - else { - obj[defAttrKey] = attrs; - } - break; - case "#": - textId = this._processSpecItem(item["#"], obj, options.group, defTextKey, textCount, textId); - break; - case "!": - commentId = this._processSpecItem(item["!"], obj, options.group, defCommentKey, commentCount, commentId); - break; - case "?": - instructionId = this._processSpecItem(item["?"], obj, options.group, defInstructionKey, instructionCount, instructionId); - break; - case "$": - cdataId = this._processSpecItem(item["$"], obj, options.group, defCdataKey, cdataCount, cdataId); - break; - default: - // element node - var ele = item; - if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { - // group of element nodes - var eleGroup = []; - var listOfLists = ele[key]; - for (var i_2 = 0; i_2 < listOfLists.length; i_2++) { - eleGroup.push(this._process(listOfLists[i_2], options)); - } - obj[key] = eleGroup; - } - else { - // single element node - if (options.verbose) { - obj[key] = [this._process(ele[key], options)]; - } - else { - obj[key] = this._process(ele[key], options); - } - } - break; - } + return this.childNodeList; + } + }); + + Object.defineProperty(XMLNode.prototype, 'firstChild', { + get: function() { + return this.children[0] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'lastChild', { + get: function() { + return this.children[this.children.length - 1] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'previousSibling', { + get: function() { + var i; + i = this.parent.children.indexOf(this); + return this.parent.children[i - 1] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'nextSibling', { + get: function() { + var i; + i = this.parent.children.indexOf(this); + return this.parent.children[i + 1] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'ownerDocument', { + get: function() { + return this.document() || null; + } + }); + + Object.defineProperty(XMLNode.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 obj; + } + return str; + } else { + return null; } + }, + set: function(value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + XMLNode.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; }; - ObjectWriter.prototype._processSpecItem = function (item, obj, group, defKey, count, id) { - var e_1, _a; - if (!group && util_1.isArray(item) && count + item.length > 2) { - try { - for (var item_1 = __values(item), item_1_1 = item_1.next(); !item_1_1.done; item_1_1 = item_1.next()) { - var subItem = item_1_1.value; - var key = defKey + (id++).toString(); - obj[key] = subItem; - } + + XMLNode.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); } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); - } - finally { if (e_1) throw e_1.error; } + } 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 { - var key = count > 1 ? defKey + (id++).toString() : defKey; - obj[key] = item; - } - return id; - }; - /** @inheritdoc */ - ObjectWriter.prototype.beginElement = function (name) { - var _a, _b; - var childItems = []; - if (this._currentList.length === 0) { - this._currentList.push((_a = {}, _a[name] = childItems, _a)); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isElementNode(lastItem, name)) { - if (lastItem[name].length !== 0 && util_1.isArray(lastItem[name][0])) { - var listOfLists = lastItem[name]; - listOfLists.push(childItems); - } - else { - lastItem[name] = [lastItem[name], childItems]; - } - } - else { - this._currentList.push((_b = {}, _b[name] = childItems, _b)); - } - } - this._currentIndex++; - if (this._listRegister.length > this._currentIndex) { - this._listRegister[this._currentIndex] = childItems; - } - else { - this._listRegister.push(childItems); - } - this._currentList = childItems; - }; - /** @inheritdoc */ - ObjectWriter.prototype.endElement = function () { - this._currentList = this._listRegister[--this._currentIndex]; - }; - /** @inheritdoc */ - ObjectWriter.prototype.attribute = function (name, value) { - var _a, _b; - if (this._currentList.length === 0) { - this._currentList.push({ "@": (_a = {}, _a[name] = value, _a) }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - /* istanbul ignore else */ - if (this._isAttrNode(lastItem)) { - lastItem["@"][name] = value; - } - else { - this._currentList.push({ "@": (_b = {}, _b[name] = value, _b) }); - } + } 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; }; - /** @inheritdoc */ - ObjectWriter.prototype.comment = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "!": data }); + + XMLNode.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); } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isCommentNode(lastItem)) { - if (util_1.isArray(lastItem["!"])) { - lastItem["!"].push(data); - } - else { - lastItem["!"] = [lastItem["!"], data]; - } - } - else { - this._currentList.push({ "!": data }); - } + 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; + } }; - /** @inheritdoc */ - ObjectWriter.prototype.text = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "#": data }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isTextNode(lastItem)) { - if (util_1.isArray(lastItem["#"])) { - lastItem["#"].push(data); - } - else { - lastItem["#"] = [lastItem["#"], data]; - } - } - else { - this._currentList.push({ "#": data }); - } - } + + XMLNode.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; }; - /** @inheritdoc */ - ObjectWriter.prototype.instruction = function (target, data) { - var value = (data === "" ? target : target + " " + data); - if (this._currentList.length === 0) { - this._currentList.push({ "?": value }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isInstructionNode(lastItem)) { - if (util_1.isArray(lastItem["?"])) { - lastItem["?"].push(value); - } - else { - lastItem["?"] = [lastItem["?"], value]; - } - } - else { - this._currentList.push({ "?": value }); - } - } + + XMLNode.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; }; - /** @inheritdoc */ - ObjectWriter.prototype.cdata = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "$": data }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isCDATANode(lastItem)) { - if (util_1.isArray(lastItem["$"])) { - lastItem["$"].push(data); - } - else { - lastItem["$"] = [lastItem["$"], data]; - } - } - else { - this._currentList.push({ "$": data }); - } - } + + XMLNode.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; }; - ObjectWriter.prototype._isAttrNode = function (x) { - return "@" in x; + + XMLNode.prototype.text = function(value) { + var child; + if (isObject(value)) { + this.element(value); + } + child = new XMLText(this, value); + this.children.push(child); + return this; }; - ObjectWriter.prototype._isTextNode = function (x) { - return "#" in x; + + XMLNode.prototype.cdata = function(value) { + var child; + child = new XMLCData(this, value); + this.children.push(child); + return this; }; - ObjectWriter.prototype._isCommentNode = function (x) { - return "!" in x; + + XMLNode.prototype.comment = function(value) { + var child; + child = new XMLComment(this, value); + this.children.push(child); + return this; }; - ObjectWriter.prototype._isInstructionNode = function (x) { - return "?" in x; + + XMLNode.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; }; - ObjectWriter.prototype._isCDATANode = function (x) { - return "$" in x; + + XMLNode.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; }; - ObjectWriter.prototype._isElementNode = function (x, name) { - return name in x; + + XMLNode.prototype.raw = function(value) { + var child; + child = new XMLRaw(this, value); + this.children.push(child); + return this; }; - /** - * Returns an object key for an attribute or namespace declaration. - */ - ObjectWriter.prototype._getAttrKey = function () { - return this._builderOptions.convert.att; + + XMLNode.prototype.dummy = function() { + var child; + child = new XMLDummy(this); + return child; }; - /** - * Returns an object key for the given node type. - * - * @param nodeType - node type to get a key for - */ - ObjectWriter.prototype._getNodeKey = function (nodeType) { - switch (nodeType) { - case interfaces_1.NodeType.Comment: - return this._builderOptions.convert.comment; - case interfaces_1.NodeType.Text: - return this._builderOptions.convert.text; - case interfaces_1.NodeType.ProcessingInstruction: - return this._builderOptions.convert.ins; - case interfaces_1.NodeType.CData: - return this._builderOptions.convert.cdata; - /* istanbul ignore next */ - default: - throw new Error("Invalid node type."); + + XMLNode.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; }; - return ObjectWriter; -}(BaseWriter_1.BaseWriter)); -exports.ObjectWriter = ObjectWriter; -//# sourceMappingURL=ObjectWriter.js.map - -/***/ }), - -/***/ 7572: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { -"use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLNode.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; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLNode.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; }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var BaseCBWriter_1 = __nccwpck_require__(708); -/** - * Serializes XML nodes. - */ -var XMLCBWriter = /** @class */ (function (_super) { - __extends(XMLCBWriter, _super); - /** - * Initializes a new instance of `XMLCBWriter`. - * - * @param builderOptions - XML builder options - */ - function XMLCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._lineLength = 0; - return _this; - } - /** @inheritdoc */ - XMLCBWriter.prototype.frontMatter = function () { - return ""; + + XMLNode.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; }; - /** @inheritdoc */ - XMLCBWriter.prototype.declaration = function (version, encoding, standalone) { - var markup = this._beginLine() + ""; - return markup; + } + doc.children.push(doctype); + return doctype; }; - /** @inheritdoc */ - XMLCBWriter.prototype.docType = function (name, publicId, systemId) { - var markup = this._beginLine(); - if (publicId && systemId) { - markup += ""; - } - else if (publicId) { - markup += ""; - } - else if (systemId) { - markup += ""; - } - else { - markup += ""; + + XMLNode.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; + }; + + XMLNode.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; } - return markup; + } }; - /** @inheritdoc */ - XMLCBWriter.prototype.comment = function (data) { - return this._beginLine() + ""; + + XMLNode.prototype.document = function() { + var node; + node = this; + while (node) { + if (node.type === NodeType.Document) { + return node; + } else { + node = node.parent; + } + } }; - /** @inheritdoc */ - XMLCBWriter.prototype.text = function (data) { - return this._beginLine() + data; + + XMLNode.prototype.end = function(options) { + return this.document().end(options); }; - /** @inheritdoc */ - XMLCBWriter.prototype.instruction = function (target, data) { - if (data) { - return this._beginLine() + ""; - } - else { - return this._beginLine() + ""; - } + + XMLNode.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]; }; - /** @inheritdoc */ - XMLCBWriter.prototype.cdata = function (data) { - return this._beginLine() + ""; + + XMLNode.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]; }; - /** @inheritdoc */ - XMLCBWriter.prototype.openTagBegin = function (name) { - this._lineLength += 1 + name.length; - return this._beginLine() + "<" + name; + + XMLNode.prototype.importDocument = function(doc) { + var clonedRoot; + clonedRoot = doc.root().clone(); + clonedRoot.parent = this; + clonedRoot.isRoot = false; + this.children.push(clonedRoot); + return this; }; - /** @inheritdoc */ - XMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (voidElement) { - return " />"; - } - else if (selfClosing) { - if (this._writerOptions.allowEmptyTags) { - return ">"; - } - else if (this._writerOptions.spaceBeforeSlash) { - return " />"; - } - else { - return "/>"; - } - } - else { - return ">"; - } - }; - /** @inheritdoc */ - XMLCBWriter.prototype.closeTag = function (name) { - return this._beginLine() + ""; + + XMLNode.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 + ">"; + } }; - /** @inheritdoc */ - XMLCBWriter.prototype.attribute = function (name, value) { - var str = name + "=\"" + value + "\""; - if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && - this._lineLength + 1 + str.length > this._writerOptions.width) { - str = this._beginLine() + this._indent(1) + str; - this._lineLength = str.length; - return str; - } - else { - this._lineLength += 1 + str.length; - return " " + str; - } + + XMLNode.prototype.ele = function(name, attributes, text) { + return this.element(name, attributes, text); }; - /** @inheritdoc */ - XMLCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - XMLCBWriter.prototype.endElement = function (name) { }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - XMLCBWriter.prototype._beginLine = function () { - if (this._writerOptions.prettyPrint) { - var str = (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level); - this._lineLength = str.length; - return str; - } - else { - return ""; - } + + XMLNode.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - */ - XMLCBWriter.prototype._indent = function (level) { - if (level <= 0) { - return ""; - } - else { - return this._writerOptions.indent.repeat(level); - } + + XMLNode.prototype.txt = function(value) { + return this.text(value); }; - return XMLCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.XMLCBWriter = XMLCBWriter; -//# sourceMappingURL=XMLCBWriter.js.map -/***/ }), + XMLNode.prototype.dat = function(value) { + return this.cdata(value); + }; -/***/ 9606: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLNode.prototype.com = function(value) { + return this.comment(value); + }; -"use strict"; + XMLNode.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLNode.prototype.doc = function() { + return this.document(); }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLNode.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var interfaces_1 = __nccwpck_require__(7305); -var BaseWriter_1 = __nccwpck_require__(7644); -var util_2 = __nccwpck_require__(5282); -/** - * Serializes XML nodes into strings. - */ -var XMLWriter = /** @class */ (function (_super) { - __extends(XMLWriter, _super); - /** - * Initializes a new instance of `XMLWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function XMLWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._indentation = {}; - _this._lengthToLastNewline = 0; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - headless: false, - prettyPrint: false, - indent: " ", - newline: "\n", - offset: 0, - width: 0, - allowEmptyTags: false, - indentTextOnlyNodes: false, - spaceBeforeSlash: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - XMLWriter.prototype.serialize = function (node) { - this._refs = { suppressPretty: false, emptyNode: false, markup: "" }; - // Serialize XML declaration - if (node.nodeType === interfaces_1.NodeType.Document && !this._writerOptions.headless) { - this.declaration(this._builderOptions.version, this._builderOptions.encoding, this._builderOptions.standalone); - } - // recursively serialize node - this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); - // remove trailing newline - if (this._writerOptions.prettyPrint && - this._refs.markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { - this._refs.markup = this._refs.markup.slice(0, -this._writerOptions.newline.length); - } - return this._refs.markup; + + XMLNode.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); }; - /** @inheritdoc */ - XMLWriter.prototype.declaration = function (version, encoding, standalone) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLNode.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); }; - /** @inheritdoc */ - XMLWriter.prototype.docType = function (name, publicId, systemId) { - this._beginLine(); - if (publicId && systemId) { - this._refs.markup += ""; - } - else if (publicId) { - this._refs.markup += ""; - } - else if (systemId) { - this._refs.markup += ""; - } - else { - this._refs.markup += ""; - } - this._endLine(); + + XMLNode.prototype.t = function(value) { + return this.text(value); }; - /** @inheritdoc */ - XMLWriter.prototype.openTagBegin = function (name) { - this._beginLine(); - this._refs.markup += "<" + name; + + XMLNode.prototype.d = function(value) { + return this.cdata(value); }; - /** @inheritdoc */ - XMLWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - // do not indent text only elements or elements with empty text nodes - this._refs.suppressPretty = false; - this._refs.emptyNode = false; - if (this._writerOptions.prettyPrint && !selfClosing && !voidElement) { - var textOnlyNode = true; - var emptyNode = true; - var childNode = this.currentNode.firstChild; - var cdataCount = 0; - var textCount = 0; - while (childNode) { - if (util_2.Guard.isExclusiveTextNode(childNode)) { - textCount++; - } - else if (util_2.Guard.isCDATASectionNode(childNode)) { - cdataCount++; - } - else { - textOnlyNode = false; - emptyNode = false; - break; - } - if (childNode.data !== '') { - emptyNode = false; - } - childNode = childNode.nextSibling; - } - this._refs.suppressPretty = !this._writerOptions.indentTextOnlyNodes && textOnlyNode && ((cdataCount <= 1 && textCount === 0) || cdataCount === 0); - this._refs.emptyNode = emptyNode; - } - if ((voidElement || selfClosing || this._refs.emptyNode) && this._writerOptions.allowEmptyTags) { - this._refs.markup += ">"; - } - else { - this._refs.markup += voidElement ? " />" : - (selfClosing || this._refs.emptyNode) ? (this._writerOptions.spaceBeforeSlash ? " />" : "/>") : ">"; - } - this._endLine(); + + XMLNode.prototype.c = function(value) { + return this.comment(value); }; - /** @inheritdoc */ - XMLWriter.prototype.closeTag = function (name) { - if (!this._refs.emptyNode) { - this._beginLine(); - this._refs.markup += ""; - } - this._refs.suppressPretty = false; - this._refs.emptyNode = false; - this._endLine(); - }; - /** @inheritdoc */ - XMLWriter.prototype.attribute = function (name, value) { - var str = name + "=\"" + value + "\""; - if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && - this._refs.markup.length - this._lengthToLastNewline + 1 + str.length > this._writerOptions.width) { - this._endLine(); - this._beginLine(); - this._refs.markup += this._indent(1) + str; - } - else { - this._refs.markup += " " + str; - } - }; - /** @inheritdoc */ - XMLWriter.prototype.text = function (data) { - if (data !== '') { - this._beginLine(); - this._refs.markup += data; - this._endLine(); - } + + XMLNode.prototype.r = function(value) { + return this.raw(value); }; - /** @inheritdoc */ - XMLWriter.prototype.cdata = function (data) { - if (data !== '') { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); - } + + XMLNode.prototype.i = function(target, value) { + return this.instruction(target, value); }; - /** @inheritdoc */ - XMLWriter.prototype.comment = function (data) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLNode.prototype.u = function() { + return this.up(); }; - /** @inheritdoc */ - XMLWriter.prototype.instruction = function (target, data) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLNode.prototype.importXMLBuilder = function(doc) { + return this.importDocument(doc); }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - XMLWriter.prototype._beginLine = function () { - if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) { - this._refs.markup += this._indent(this._writerOptions.offset + this.level); - } + + XMLNode.prototype.replaceChild = function(newChild, oldChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces characters to be appended to a line of string in pretty-print - * mode. - */ - XMLWriter.prototype._endLine = function () { - if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) { - this._refs.markup += this._writerOptions.newline; - this._lengthToLastNewline = this._refs.markup.length; - } + + XMLNode.prototype.removeChild = function(oldChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - */ - XMLWriter.prototype._indent = function (level) { - if (level <= 0) { - return ""; - } - else if (this._indentation[level] !== undefined) { - return this._indentation[level]; - } - else { - var str = this._writerOptions.indent.repeat(level); - this._indentation[level] = str; - return str; - } + + XMLNode.prototype.appendChild = function(newChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - return XMLWriter; -}(BaseWriter_1.BaseWriter)); -exports.XMLWriter = XMLWriter; -//# sourceMappingURL=XMLWriter.js.map -/***/ }), + XMLNode.prototype.hasChildNodes = function() { + return this.children.length !== 0; + }; -/***/ 2444: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLNode.prototype.cloneNode = function(deep) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -"use strict"; + XMLNode.prototype.normalize = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + XMLNode.prototype.isSupported = function(feature, version) { + return true; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLNode.prototype.hasAttributes = function() { + return this.attribs.length !== 0; }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var BaseCBWriter_1 = __nccwpck_require__(708); -/** - * Serializes XML nodes. - */ -var YAMLCBWriter = /** @class */ (function (_super) { - __extends(YAMLCBWriter, _super); - /** - * Initializes a new instance of `BaseCBWriter`. - * - * @param builderOptions - XML builder options - */ - function YAMLCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._rootWritten = false; - _this._additionalLevel = 0; - if (builderOptions.indent.length < 2) { - throw new Error("YAML indententation string must be at least two characters long."); - } - if (builderOptions.offset < 0) { - throw new Error("YAML offset should be zero or a positive number."); + + XMLNode.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 _this; - } - /** @inheritdoc */ - YAMLCBWriter.prototype.frontMatter = function () { - return this._beginLine() + "---"; + 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; + } }; - /** @inheritdoc */ - YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { - return ""; + + XMLNode.prototype.isSameNode = function(other) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { - return ""; + + XMLNode.prototype.lookupPrefix = function(namespaceURI) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - YAMLCBWriter.prototype.comment = function (data) { - // "!": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.comment) + " " + - this._val(data); + + XMLNode.prototype.isDefaultNamespace = function(namespaceURI) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - YAMLCBWriter.prototype.text = function (data) { - // "#": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.text) + " " + - this._val(data); + + XMLNode.prototype.lookupNamespaceURI = function(prefix) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - YAMLCBWriter.prototype.instruction = function (target, data) { - // "?": "target hello" - return this._beginLine() + - this._key(this._builderOptions.convert.ins) + " " + - this._val(data ? target + " " + data : target); + + XMLNode.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; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.cdata = function (data) { - // "$": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.cdata) + " " + - this._val(data); + + XMLNode.prototype.getFeature = function(feature, version) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - YAMLCBWriter.prototype.attribute = function (name, value) { - // "@name": "val" - this._additionalLevel++; - var str = this._beginLine() + - this._key(this._builderOptions.convert.att + name) + " " + - this._val(value); - this._additionalLevel--; - return str; + + XMLNode.prototype.setUserData = function(key, data, handler) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagBegin = function (name) { - // "node": - // "#": - // - - var str = this._beginLine() + this._key(name); - if (!this._rootWritten) { - this._rootWritten = true; - } - this.hasData = true; - this._additionalLevel++; - str += this._beginLine(true) + this._key(this._builderOptions.convert.text); - return str; + + XMLNode.prototype.getUserData = function(key) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (selfClosing) { - return " " + this._val(""); + + XMLNode.prototype.contains = function(other) { + if (!other) { + return false; + } + return other === this || this.isDescendant(other); + }; + + XMLNode.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; } - return ""; + isDescendantChild = child.isDescendant(node); + if (isDescendantChild) { + return true; + } + } + return false; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.closeTag = function (name) { - this._additionalLevel--; - return ""; + + XMLNode.prototype.isAncestor = function(node) { + return node.isDescendant(this); }; - /** @inheritdoc */ - YAMLCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - YAMLCBWriter.prototype.endElement = function (name) { }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - YAMLCBWriter.prototype._beginLine = function (suppressArray) { - if (suppressArray === void 0) { suppressArray = false; } - return (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level, suppressArray); + + XMLNode.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; + } }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - * @param suppressArray - whether the suppress array marker - */ - YAMLCBWriter.prototype._indent = function (level, suppressArray) { - if (level + this._additionalLevel <= 0) { - return ""; + + XMLNode.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; + } + }; + + XMLNode.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; } - else { - var chars = this._writerOptions.indent.repeat(level + this._additionalLevel); - if (!suppressArray && this._rootWritten) { - return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); - } - return chars; + }); + if (found) { + return pos; + } else { + return -1; + } + }; + + XMLNode.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; + } } + } }; - /** - * Produces a YAML key string delimited with double quotes. - */ - YAMLCBWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + + return XMLNode; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 6768: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLNodeList; + + module.exports = XMLNodeList = (function() { + function XMLNodeList(nodes) { + this.nodes = nodes; + } + + Object.defineProperty(XMLNodeList.prototype, 'length', { + get: function() { + return this.nodes.length || 0; + } + }); + + XMLNodeList.prototype.clone = function() { + return this.nodes = null; }; - /** - * Produces a YAML value string delimited with double quotes. - */ - YAMLCBWriter.prototype._val = function (val) { - return JSON.stringify(val); + + XMLNodeList.prototype.item = function(index) { + return this.nodes[index] || null; }; - return YAMLCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.YAMLCBWriter = YAMLCBWriter; -//# sourceMappingURL=YAMLCBWriter.js.map + + return XMLNodeList; + + })(); + +}).call(this); + /***/ }), -/***/ 6517: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 6939: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(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; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); + NodeType = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLProcessingInstruction = (function(superClass) { + extend(XMLProcessingInstruction, superClass); + + function XMLProcessingInstruction(parent, target, value) { + XMLProcessingInstruction.__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); + } + } + + XMLProcessingInstruction.prototype.clone = function() { + return Object.create(this); }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLProcessingInstruction.prototype.toString = function(options) { + return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options)); }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } + + XMLProcessingInstruction.prototype.isEqualNode = function(node) { + if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.target !== this.target) { + return false; + } + return true; }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectWriter_1 = __nccwpck_require__(243); -var util_1 = __nccwpck_require__(6195); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into a YAML string. - */ -var YAMLWriter = /** @class */ (function (_super) { - __extends(YAMLWriter, _super); - /** - * Initializes a new instance of `YAMLWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function YAMLWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - indent: ' ', - newline: '\n', - offset: 0, - group: false, - verbose: false - }); - if (_this._writerOptions.indent.length < 2) { - throw new Error("YAML indententation string must be at least two characters long."); - } - if (_this._writerOptions.offset < 0) { - throw new Error("YAML offset should be zero or a positive number."); - } - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - * @param writerOptions - serialization options - */ - YAMLWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - var markup = this._beginLine(this._writerOptions, 0) + '---' + this._endLine(this._writerOptions) + - this._convertObject(val, this._writerOptions, 0); - // remove trailing newline - /* istanbul ignore else */ - if (markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { - markup = markup.slice(0, -this._writerOptions.newline.length); - } - return markup; - }; - /** - * Produces an XML serialization of the given object. - * - * @param obj - object to serialize - * @param options - serialization options - * @param level - depth of the XML tree - * @param indentLeaf - indents leaf nodes - */ - YAMLWriter.prototype._convertObject = function (obj, options, level, suppressIndent) { - var e_1, _a; - var _this = this; - if (suppressIndent === void 0) { suppressIndent = false; } - var markup = ''; - if (util_1.isArray(obj)) { - try { - for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { - var val = obj_1_1.value; - markup += this._beginLine(options, level, true); - if (!util_1.isObject(val)) { - markup += this._val(val) + this._endLine(options); - } - else if (util_1.isEmpty(val)) { - markup += '""' + this._endLine(options); - } - else { - markup += this._convertObject(val, options, level, true); - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); - } - finally { if (e_1) throw e_1.error; } - } - } - else /* if (isObject(obj)) */ { - util_1.forEachObject(obj, function (key, val) { - if (suppressIndent) { - markup += _this._key(key); - suppressIndent = false; - } - else { - markup += _this._beginLine(options, level) + _this._key(key); - } - if (!util_1.isObject(val)) { - markup += ' ' + _this._val(val) + _this._endLine(options); - } - else if (util_1.isEmpty(val)) { - markup += ' ""' + _this._endLine(options); - } - else { - markup += _this._endLine(options) + - _this._convertObject(val, options, level + 1); - } - }, this); - } - return markup; - }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - * @param isArray - whether this line is an array item - */ - YAMLWriter.prototype._beginLine = function (options, level, isArray) { - if (isArray === void 0) { isArray = false; } - var indentLevel = options.offset + level + 1; - var chars = new Array(indentLevel).join(options.indent); - if (isArray) { - return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); - } - else { - return chars; - } - }; - /** - * Produces characters to be appended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - */ - YAMLWriter.prototype._endLine = function (options) { - return options.newline; - }; - /** - * Produces a YAML key string delimited with double quotes. - */ - YAMLWriter.prototype._key = function (key) { - return "\"" + key + "\":"; - }; - /** - * Produces a YAML value string delimited with double quotes. - */ - YAMLWriter.prototype._val = function (val) { - return JSON.stringify(val); - }; - return YAMLWriter; -}(BaseWriter_1.BaseWriter)); -exports.YAMLWriter = YAMLWriter; -//# sourceMappingURL=YAMLWriter.js.map -/***/ }), + return XMLProcessingInstruction; -/***/ 7476: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + })(XMLCharacterData); -"use strict"; +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var MapWriter_1 = __nccwpck_require__(1397); -exports.MapWriter = MapWriter_1.MapWriter; -var XMLWriter_1 = __nccwpck_require__(9606); -exports.XMLWriter = XMLWriter_1.XMLWriter; -var ObjectWriter_1 = __nccwpck_require__(243); -exports.ObjectWriter = ObjectWriter_1.ObjectWriter; -var JSONWriter_1 = __nccwpck_require__(7510); -exports.JSONWriter = JSONWriter_1.JSONWriter; -var YAMLWriter_1 = __nccwpck_require__(6517); -exports.YAMLWriter = YAMLWriter_1.YAMLWriter; -//# sourceMappingURL=index.js.map /***/ }), -/***/ 2839: -/***/ (function(module) { +/***/ 6329: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { // Generated by CoffeeScript 1.12.7 (function() { - module.exports = { - Disconnected: 1, - Preceding: 2, - Following: 4, - Contains: 8, - ContainedBy: 16, - ImplementationSpecific: 32 - }; + 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; -}).call(this); + NodeType = __nccwpck_require__(9267); + XMLNode = __nccwpck_require__(7608); -/***/ }), + module.exports = XMLRaw = (function(superClass) { + extend(XMLRaw, superClass); -/***/ 9267: -/***/ (function(module) { + function XMLRaw(parent, text) { + XMLRaw.__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); + } -// Generated by CoffeeScript 1.12.7 -(function() { - module.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 - }; + XMLRaw.prototype.clone = function() { + return Object.create(this); + }; + + XMLRaw.prototype.toString = function(options) { + return this.options.writer.raw(this, this.options.writer.filterOptions(options)); + }; + + return XMLRaw; + + })(XMLNode); }).call(this); /***/ }), -/***/ 8229: -/***/ (function(module) { +/***/ 8601: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { // Generated by CoffeeScript 1.12.7 (function() { - var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject, - slice = [].slice, + 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; - 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; - }; + NodeType = __nccwpck_require__(9267); - isFunction = function(val) { - return !!val && Object.prototype.toString.call(val) === '[object Function]'; - }; + XMLWriterBase = __nccwpck_require__(6752); - isObject = function(val) { - var ref; - return !!val && ((ref = typeof val) === 'function' || ref === 'object'); - }; + WriterState = __nccwpck_require__(9766); - isArray = function(val) { - if (isFunction(Array.isArray)) { - return Array.isArray(val); - } else { - return Object.prototype.toString.call(val) === '[object Array]'; + module.exports = XMLStreamWriter = (function(superClass) { + extend(XMLStreamWriter, superClass); + + function XMLStreamWriter(stream, options) { + this.stream = stream; + XMLStreamWriter.__super__.constructor.call(this, options); } - }; - isEmpty = function(val) { - var key; - if (isArray(val)) { - return !val.length; - } else { - for (key in val) { - if (!hasProp.call(val, key)) continue; - return false; + XMLStreamWriter.prototype.endline = function(node, options, level) { + if (node.isLastRootNode && options.state === WriterState.CloseTag) { + return ''; + } else { + return XMLStreamWriter.__super__.endline.call(this, node, options, level); } - 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)); - }; + XMLStreamWriter.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; + }; - getValue = function(obj) { - if (isFunction(obj.valueOf)) { - return obj.valueOf(); - } else { - return obj; - } - }; + XMLStreamWriter.prototype.attribute = function(att, options, level) { + return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level)); + }; - module.exports.assign = assign; + XMLStreamWriter.prototype.cdata = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level)); + }; - module.exports.isFunction = isFunction; + XMLStreamWriter.prototype.comment = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level)); + }; - module.exports.isObject = isObject; + XMLStreamWriter.prototype.declaration = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level)); + }; - module.exports.isArray = isArray; + XMLStreamWriter.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(' 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); + }; - module.exports.isEmpty = isEmpty; + XMLStreamWriter.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(''); + } 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(''); + } 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) + ''); + } + this.stream.write(this.endline(node, options, level)); + options.state = WriterState.None; + return this.closeNode(node, options, level); + }; - module.exports.isPlainObject = isPlainObject; + XMLStreamWriter.prototype.processingInstruction = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level)); + }; - module.exports.getValue = getValue; + XMLStreamWriter.prototype.raw = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level)); + }; -}).call(this); + XMLStreamWriter.prototype.text = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level)); + }; + XMLStreamWriter.prototype.dtdAttList = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level)); + }; -/***/ }), + XMLStreamWriter.prototype.dtdElement = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level)); + }; -/***/ 9766: -/***/ (function(module) { + XMLStreamWriter.prototype.dtdEntity = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level)); + }; -// Generated by CoffeeScript 1.12.7 -(function() { - module.exports = { - None: 0, - OpenTag: 1, - InsideTag: 2, - CloseTag: 3 - }; + XMLStreamWriter.prototype.dtdNotation = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level)); + }; + + return XMLStreamWriter; + + })(XMLWriterBase); }).call(this); /***/ }), -/***/ 8376: +/***/ 5913: /***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { // Generated by CoffeeScript 1.12.7 (function() { - var NodeType, XMLAttribute, XMLNode; + 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; - NodeType = __nccwpck_require__(9267); + XMLWriterBase = __nccwpck_require__(6752); - XMLNode = __nccwpck_require__(7608); + module.exports = XMLStringWriter = (function(superClass) { + extend(XMLStringWriter, superClass); - module.exports = XMLAttribute = (function() { - function XMLAttribute(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; + function XMLStringWriter(options) { + XMLStringWriter.__super__.constructor.call(this, options); } - Object.defineProperty(XMLAttribute.prototype, 'nodeType', { - get: function() { - return this.type; + XMLStringWriter.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); } - }); - - Object.defineProperty(XMLAttribute.prototype, 'ownerElement', { - get: function() { - return this.parent; + if (options.pretty && r.slice(-options.newline.length) === options.newline) { + r = r.slice(0, -options.newline.length); } - }); + return r; + }; - Object.defineProperty(XMLAttribute.prototype, 'textContent', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'prefix', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'localName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'specified', { - get: function() { - return true; - } - }); - - XMLAttribute.prototype.clone = function() { - return Object.create(this); - }; - - XMLAttribute.prototype.toString = function(options) { - return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); - }; - - XMLAttribute.prototype.debugInfo = function(name) { - name = name || this.name; - if (name == null) { - return "parent: <" + this.parent.name + ">"; - } else { - return "attribute: {" + name + "}, parent: <" + this.parent.name + ">"; - } - }; - - XMLAttribute.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 XMLAttribute; + return XMLStringWriter; - })(); + })(XMLWriterBase); }).call(this); /***/ }), -/***/ 333: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +/***/ 8594: +/***/ (function(module) { // Generated by CoffeeScript 1.12.7 (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; }, + var XMLStringifier, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, hasProp = {}.hasOwnProperty; - NodeType = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLCData = (function(superClass) { - extend(XMLCData, superClass); - - function XMLCData(parent, text) { - XMLCData.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing CDATA text. " + this.debugInfo()); + module.exports = XMLStringifier = (function() { + function XMLStringifier(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; } - this.name = "#cdata-section"; - this.type = NodeType.CData; - this.value = this.stringify.cdata(text); } - XMLCData.prototype.clone = function() { - return Object.create(this); + XMLStringifier.prototype.name = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalName('' + val || ''); }; - XMLCData.prototype.toString = function(options) { - return this.options.writer.cdata(this, this.options.writer.filterOptions(options)); + XMLStringifier.prototype.text = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar(this.textEscape('' + val || '')); }; - return XMLCData; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 7709: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); - - module.exports = XMLCharacterData = (function(superClass) { - extend(XMLCharacterData, superClass); - - function XMLCharacterData(parent) { - XMLCharacterData.__super__.constructor.call(this, parent); - this.value = ''; - } - - Object.defineProperty(XMLCharacterData.prototype, 'data', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; + XMLStringifier.prototype.cdata = function(val) { + if (this.options.noValidation) { + return val; } - }); + val = '' + val || ''; + val = val.replace(']]>', ']]]]>'); + return this.assertLegalChar(val); + }; - Object.defineProperty(XMLCharacterData.prototype, 'length', { - get: function() { - return this.value.length; + XMLStringifier.prototype.comment = function(val) { + if (this.options.noValidation) { + return val; } - }); - - Object.defineProperty(XMLCharacterData.prototype, 'textContent', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; + val = '' + val || ''; + if (val.match(/--/)) { + throw new Error("Comment text cannot contain double-hypen: " + val); } - }); + return this.assertLegalChar(val); + }; - XMLCharacterData.prototype.clone = function() { - return Object.create(this); + XMLStringifier.prototype.raw = function(val) { + if (this.options.noValidation) { + return val; + } + return '' + val || ''; }; - XMLCharacterData.prototype.substringData = function(offset, count) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + XMLStringifier.prototype.attValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar(this.attEscape(val = '' + val || '')); }; - XMLCharacterData.prototype.appendData = function(arg) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + XMLStringifier.prototype.insTarget = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - XMLCharacterData.prototype.insertData = function(offset, arg) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + XMLStringifier.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); }; - XMLCharacterData.prototype.deleteData = function(offset, count) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + XMLStringifier.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; }; - XMLCharacterData.prototype.replaceData = function(offset, count, arg) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + XMLStringifier.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); }; - XMLCharacterData.prototype.isEqualNode = function(node) { - if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { - return false; + XMLStringifier.prototype.xmlStandalone = function(val) { + if (this.options.noValidation) { + return val; } - if (node.data !== this.data) { - return false; + if (val) { + return "yes"; + } else { + return "no"; } - return true; }; - return XMLCharacterData; + XMLStringifier.prototype.dtdPubID = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); + }; - })(XMLNode); + XMLStringifier.prototype.dtdSysID = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); + }; -}).call(this); + XMLStringifier.prototype.dtdElementValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); + }; + XMLStringifier.prototype.dtdAttType = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); + }; -/***/ }), + XMLStringifier.prototype.dtdAttDefault = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); + }; -/***/ 4407: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + XMLStringifier.prototype.dtdEntityValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); + }; -// Generated by CoffeeScript 1.12.7 -(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; + XMLStringifier.prototype.dtdNData = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); + }; - NodeType = __nccwpck_require__(9267); + XMLStringifier.prototype.convertAttKey = '@'; - XMLCharacterData = __nccwpck_require__(7709); + XMLStringifier.prototype.convertPIKey = '?'; - module.exports = XMLComment = (function(superClass) { - extend(XMLComment, superClass); + XMLStringifier.prototype.convertTextKey = '#text'; - function XMLComment(parent, text) { - XMLComment.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing comment text. " + this.debugInfo()); + XMLStringifier.prototype.convertCDataKey = '#cdata'; + + XMLStringifier.prototype.convertCommentKey = '#comment'; + + XMLStringifier.prototype.convertRawKey = '#raw'; + + XMLStringifier.prototype.assertLegalChar = function(str) { + var regex, res; + if (this.options.noValidation) { + return str; } - this.name = "#comment"; - this.type = NodeType.Comment; - this.value = this.stringify.comment(text); - } + 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; + }; - XMLComment.prototype.clone = function() { - return Object.create(this); + XMLStringifier.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; }; - XMLComment.prototype.toString = function(options) { - return this.options.writer.comment(this, this.options.writer.filterOptions(options)); + XMLStringifier.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(/\r/g, ' '); }; - return XMLComment; + XMLStringifier.prototype.attEscape = function(str) { + var ampregex; + if (this.options.noValidation) { + return str; + } + ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; + return str.replace(ampregex, '&').replace(/ 0) { + return new Array(indentLevel).join(options.indent); + } + } + return ''; }; - return XMLDOMStringList; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 1015: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDAttList = (function(superClass) { - extend(XMLDTDAttList, superClass); - - function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { - XMLDTDAttList.__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); + XMLWriterBase.prototype.endline = function(node, options, level) { + if (!options.pretty || options.suppressPrettyCount) { + return ''; + } else { + return options.newline; } - this.defaultValueType = defaultValueType; - } - - XMLDTDAttList.prototype.toString = function(options) { - return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options)); }; - return XMLDTDAttList; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 2421: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); + XMLWriterBase.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; + }; - NodeType = __nccwpck_require__(9267); + XMLWriterBase.prototype.cdata = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; - module.exports = XMLDTDElement = (function(superClass) { - extend(XMLDTDElement, superClass); + XMLWriterBase.prototype.comment = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; - function XMLDTDElement(parent, name, value) { - XMLDTDElement.__super__.constructor.call(this, parent); - if (name == null) { - throw new Error("Missing DTD element name. " + this.debugInfo()); - } - if (!value) { - value = '(#PCDATA)'; + XMLWriterBase.prototype.declaration = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + ''; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - return XMLDTDElement; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 53: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = (__nccwpck_require__(8229).isObject); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDEntity = (function(superClass) { - extend(XMLDTDEntity, superClass); - - function XMLDTDEntity(parent, pe, name, value) { - XMLDTDEntity.__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)); + XMLWriterBase.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 += ' 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); } - this.internal = false; - if (value.pubID != null) { - this.pubID = this.stringify.dtdPubID(value.pubID); + 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; + }; + + XMLWriterBase.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 += '' + this.endline(node, options, level); + } else { + options.state = WriterState.CloseTag; + r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level); } - if (value.sysID != null) { - this.sysID = this.stringify.dtdSysID(value.sysID); + } 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 += '' + 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; + } + } } - if (value.nData != null) { - this.nData = this.stringify.dtdNData(value.nData); + 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); } - if (this.pe && this.nData) { - throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name)); + options.state = WriterState.CloseTag; + r += this.indent(node, options, level) + ''; + if (prettySuppressed) { + options.suppressPrettyCount--; } + r += this.endline(node, options, level); + options.state = WriterState.None; } - } + this.closeNode(node, options, level); + return r; + }; - Object.defineProperty(XMLDTDEntity.prototype, 'publicId', { - get: function() { - return this.pubID; + XMLWriterBase.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); } - }); + }; - Object.defineProperty(XMLDTDEntity.prototype, 'systemId', { - get: function() { - return this.sysID; + XMLWriterBase.prototype.processingInstruction = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + ''; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; - Object.defineProperty(XMLDTDEntity.prototype, 'notationName', { - get: function() { - return this.nData || null; - } - }); + XMLWriterBase.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; + }; - Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', { - get: function() { - return null; - } - }); + XMLWriterBase.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; + }; - Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', { - get: function() { - return null; + XMLWriterBase.prototype.dtdAttList = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; - XMLDTDEntity.prototype.toString = function(options) { - return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options)); + XMLWriterBase.prototype.dtdElement = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - return XMLDTDEntity; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 2837: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDNotation = (function(superClass) { - extend(XMLDTDNotation, superClass); - - function XMLDTDNotation(parent, name, value) { - XMLDTDNotation.__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); + XMLWriterBase.prototype.dtdEntity = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; - Object.defineProperty(XMLDTDNotation.prototype, 'publicId', { - get: function() { - return this.pubID; + XMLWriterBase.prototype.dtdNotation = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; - Object.defineProperty(XMLDTDNotation.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); + XMLWriterBase.prototype.openNode = function(node, options, level) {}; - XMLDTDNotation.prototype.toString = function(options) { - return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options)); - }; + XMLWriterBase.prototype.closeNode = function(node, options, level) {}; - return XMLDTDNotation; + XMLWriterBase.prototype.openAttribute = function(att, options, level) {}; - })(XMLNode); + XMLWriterBase.prototype.closeAttribute = function(att, options, level) {}; + + return XMLWriterBase; + + })(); }).call(this); /***/ }), -/***/ 6364: +/***/ 2958: /***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { // Generated by CoffeeScript 1.12.7 (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 = (__nccwpck_require__(8229).isObject); - - XMLNode = __nccwpck_require__(7608); + var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref; - NodeType = __nccwpck_require__(9267); + ref = __nccwpck_require__(8229), assign = ref.assign, isFunction = ref.isFunction; - module.exports = XMLDeclaration = (function(superClass) { - extend(XMLDeclaration, superClass); + XMLDOMImplementation = __nccwpck_require__(8310); - function XMLDeclaration(parent, version, encoding, standalone) { - var ref; - XMLDeclaration.__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); - } - } + XMLDocument = __nccwpck_require__(3730); - XMLDeclaration.prototype.toString = function(options) { - return this.options.writer.declaration(this, this.options.writer.filterOptions(options)); - }; + XMLDocumentCB = __nccwpck_require__(7356); - return XMLDeclaration; + XMLStringWriter = __nccwpck_require__(5913); - })(XMLNode); + XMLStreamWriter = __nccwpck_require__(8601); -}).call(this); + NodeType = __nccwpck_require__(9267); + WriterState = __nccwpck_require__(9766); -/***/ }), + module.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; + }; -/***/ 1801: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + module.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); + } + }; -// Generated by CoffeeScript 1.12.7 -(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; + module.exports.stringWriter = function(options) { + return new XMLStringWriter(options); + }; - isObject = (__nccwpck_require__(8229).isObject); + module.exports.streamWriter = function(stream, options) { + return new XMLStreamWriter(stream, options); + }; - XMLNode = __nccwpck_require__(7608); + module.exports.implementation = new XMLDOMImplementation(); - NodeType = __nccwpck_require__(9267); + module.exports.nodeType = NodeType; - XMLDTDAttList = __nccwpck_require__(1015); + module.exports.writerState = WriterState; - XMLDTDEntity = __nccwpck_require__(53); +}).call(this); - XMLDTDElement = __nccwpck_require__(2421); - XMLDTDNotation = __nccwpck_require__(2837); +/***/ }), - XMLNamedNodeMap = __nccwpck_require__(4361); +/***/ 5696: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - module.exports = XMLDocType = (function(superClass) { - extend(XMLDocType, superClass); +"use strict"; - function XMLDocType(parent, pubID, sysID) { - var child, i, len, ref, ref1, ref2; - XMLDocType.__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(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var util_2 = __nccwpck_require__(5282); +var _1 = __nccwpck_require__(4260); +var dom_1 = __nccwpck_require__(770); +/** @inheritdoc */ +function builder(p1, p2) { + var options = formatBuilderOptions(isXMLBuilderCreateOptions(p1) ? p1 : interfaces_1.DefaultBuilderOptions); + var nodes = util_2.Guard.isNode(p1) || util_1.isArray(p1) ? p1 : p2; + if (nodes === undefined) { + throw new Error("Invalid arguments."); } - - Object.defineProperty(XMLDocType.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; - } + if (util_1.isArray(nodes)) { + var builders = []; + for (var i = 0; i < nodes.length; i++) { + var builder_1 = new _1.XMLBuilderImpl(nodes[i]); + builder_1.set(options); + builders.push(builder_1); } - return new XMLNamedNodeMap(nodes); - } - }); - - Object.defineProperty(XMLDocType.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 builders; + } + else { + var builder_2 = new _1.XMLBuilderImpl(nodes); + builder_2.set(options); + return builder_2; + } +} +exports.builder = builder; +/** @inheritdoc */ +function create(p1, p2) { + var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? + p1 : interfaces_1.DefaultBuilderOptions); + var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; + var doc = dom_1.createDocument(); + setOptions(doc, options); + var builder = new _1.XMLBuilderImpl(doc); + if (contents !== undefined) { + // parse contents + builder.ele(contents); + } + return builder; +} +exports.create = create; +/** @inheritdoc */ +function fragment(p1, p2) { + var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? + p1 : interfaces_1.DefaultBuilderOptions); + var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; + var doc = dom_1.createDocument(); + setOptions(doc, options, true); + var builder = new _1.XMLBuilderImpl(doc.createDocumentFragment()); + if (contents !== undefined) { + // parse contents + builder.ele(contents); + } + return builder; +} +exports.fragment = fragment; +/** @inheritdoc */ +function convert(p1, p2, p3) { + var builderOptions; + var contents; + var convertOptions; + if (isXMLBuilderCreateOptions(p1) && p2 !== undefined) { + builderOptions = p1; + contents = p2; + convertOptions = p3; + } + else { + builderOptions = interfaces_1.DefaultBuilderOptions; + contents = p1; + convertOptions = p2 || undefined; + } + return create(builderOptions, contents).end(convertOptions); +} +exports.convert = convert; +function isXMLBuilderCreateOptions(obj) { + if (!util_1.isPlainObject(obj)) + return false; + for (var key in obj) { + /* istanbul ignore else */ + if (obj.hasOwnProperty(key)) { + if (!interfaces_1.XMLBuilderOptionKeys.has(key)) + return false; } - return new XMLNamedNodeMap(nodes); - } - }); - - Object.defineProperty(XMLDocType.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); - - Object.defineProperty(XMLDocType.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); - - Object.defineProperty(XMLDocType.prototype, 'internalSubset', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - XMLDocType.prototype.element = function(name, value) { - var child; - child = new XMLDTDElement(this, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.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; - }; - - XMLDocType.prototype.entity = function(name, value) { - var child; - child = new XMLDTDEntity(this, false, name, value); - this.children.push(child); - return this; - }; + } + return true; +} +function formatBuilderOptions(createOptions) { + if (createOptions === void 0) { createOptions = {}; } + var options = util_1.applyDefaults(createOptions, interfaces_1.DefaultBuilderOptions); + if (options.convert.att.length === 0 || + options.convert.ins.length === 0 || + options.convert.text.length === 0 || + options.convert.cdata.length === 0 || + options.convert.comment.length === 0) { + throw new Error("JS object converter strings cannot be zero length."); + } + return options; +} +function setOptions(doc, options, isFragment) { + var docWithSettings = doc; + docWithSettings._xmlBuilderOptions = options; + docWithSettings._isFragment = isFragment; +} +//# sourceMappingURL=BuilderFunctions.js.map - XMLDocType.prototype.pEntity = function(name, value) { - var child; - child = new XMLDTDEntity(this, true, name, value); - this.children.push(child); - return this; - }; +/***/ }), - XMLDocType.prototype.notation = function(name, value) { - var child; - child = new XMLDTDNotation(this, name, value); - this.children.push(child); - return this; - }; +/***/ 268: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - XMLDocType.prototype.toString = function(options) { - return this.options.writer.docType(this, this.options.writer.filterOptions(options)); - }; +"use strict"; - XMLDocType.prototype.ele = function(name, value) { - return this.element(name, value); - }; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var _1 = __nccwpck_require__(4260); +/** + * Creates an XML builder which serializes the document in chunks. + * + * @param options - callback builder options + * + * @returns callback builder + */ +function createCB(options) { + return new _1.XMLBuilderCBImpl(options); +} +exports.createCB = createCB; +/** + * Creates an XML builder which serializes the fragment in chunks. + * + * @param options - callback builder options + * + * @returns callback builder + */ +function fragmentCB(options) { + return new _1.XMLBuilderCBImpl(options, true); +} +exports.fragmentCB = fragmentCB; +//# sourceMappingURL=BuilderFunctionsCB.js.map - XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); - }; +/***/ }), - XMLDocType.prototype.ent = function(name, value) { - return this.entity(name, value); - }; +/***/ 1438: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLDocType.prototype.pent = function(name, value) { - return this.pEntity(name, value); - }; +"use strict"; - XMLDocType.prototype.not = function(name, value) { - return this.notation(name, value); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLDocType.prototype.up = function() { - return this.root() || this.documentObject; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLDocType.prototype.isEqualNode = function(node) { - if (!XMLDocType.__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; +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } }; - - return XMLDocType; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 3730: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = (__nccwpck_require__(8229).isPlainObject); - - XMLDOMImplementation = __nccwpck_require__(8310); - - XMLDOMConfiguration = __nccwpck_require__(7465); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - XMLStringifier = __nccwpck_require__(8594); - - XMLStringWriter = __nccwpck_require__(5913); - - module.exports = XMLDocument = (function(superClass) { - extend(XMLDocument, superClass); - - function XMLDocument(options) { - XMLDocument.__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); + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } - - Object.defineProperty(XMLDocument.prototype, 'implementation', { - value: new XMLDOMImplementation() - }); - - Object.defineProperty(XMLDocument.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; - } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); } - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'documentElement', { - get: function() { - return this.rootObject || null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'inputEncoding', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', { - get: function() { - return false; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].encoding; - } else { - return null; + finally { if (e) throw e.error; } + } + return ar; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var BuilderFunctions_1 = __nccwpck_require__(5696); +var algorithm_1 = __nccwpck_require__(61); +var infra_1 = __nccwpck_require__(4251); +var NamespacePrefixMap_1 = __nccwpck_require__(283); +var LocalNameSet_1 = __nccwpck_require__(9049); +var util_2 = __nccwpck_require__(5282); +var XMLCBWriter_1 = __nccwpck_require__(7572); +var JSONCBWriter_1 = __nccwpck_require__(7525); +var YAMLCBWriter_1 = __nccwpck_require__(2444); +var events_1 = __nccwpck_require__(2361); +/** + * Represents a readable XML document stream. + */ +var XMLBuilderCBImpl = /** @class */ (function (_super) { + __extends(XMLBuilderCBImpl, _super); + /** + * Initializes a new instance of `XMLStream`. + * + * @param options - stream writer options + * @param fragment - whether to create fragment stream or a document stream + * + * @returns XML stream + */ + function XMLBuilderCBImpl(options, fragment) { + if (fragment === void 0) { fragment = false; } + var _this = _super.call(this) || this; + _this._hasDeclaration = false; + _this._docTypeName = ""; + _this._hasDocumentElement = false; + _this._currentElementSerialized = false; + _this._openTags = []; + _this._ended = false; + _this._fragment = fragment; + // provide default options + _this._options = util_1.applyDefaults(options || {}, interfaces_1.DefaultXMLBuilderCBOptions); + _this._builderOptions = { + defaultNamespace: _this._options.defaultNamespace, + namespaceAlias: _this._options.namespaceAlias + }; + if (_this._options.format === "json") { + _this._writer = new JSONCBWriter_1.JSONCBWriter(_this._options); } - } - }); - - Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].standalone === 'yes'; - } else { - return false; + else if (_this._options.format === "yaml") { + _this._writer = new YAMLCBWriter_1.YAMLCBWriter(_this._options); } - } - }); - - Object.defineProperty(XMLDocument.prototype, 'xmlVersion', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].version; - } else { - return "1.0"; + else { + _this._writer = new XMLCBWriter_1.XMLCBWriter(_this._options); } - } - }); - - Object.defineProperty(XMLDocument.prototype, 'URL', { - get: function() { - return this.documentURI; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'origin', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'compatMode', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'characterSet', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'contentType', { - get: function() { - return null; - } - }); - - XMLDocument.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)); - }; - - XMLDocument.prototype.toString = function(options) { - return this.options.writer.document(this, this.options.writer.filterOptions(options)); - }; - - XMLDocument.prototype.createElement = function(tagName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createDocumentFragment = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createTextNode = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createComment = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createCDATASection = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createProcessingInstruction = function(target, data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createAttribute = function(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createEntityReference = function(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.getElementsByTagName = function(tagname) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.importNode = function(importedNode, deep) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + // automatically create listeners for callbacks passed via options + if (_this._options.data !== undefined) { + _this.on("data", _this._options.data); + } + if (_this._options.end !== undefined) { + _this.on("end", _this._options.end); + } + if (_this._options.error !== undefined) { + _this.on("error", _this._options.error); + } + _this._prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); + _this._prefixMap.set("xml", infra_1.namespace.XML); + _this._prefixIndex = { value: 1 }; + _this._push(_this._writer.frontMatter()); + return _this; + } + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.ele = function (p1, p2, p3) { + var e_1, _a; + // parse if JS object or XML or JSON string + if (util_1.isObject(p1) || (util_1.isString(p1) && (/^\s*/g, '>'); + } + else { + for (var i = 0; i < node.data.length; i++) { + var c = node.data[i]; + if (c === "&") + markup += "&"; + else if (c === "<") + markup += "<"; + else if (c === ">") + markup += ">"; + else + markup += c; + } + } + this._push(this._writer.text(markup)); + return this; }; - - XMLDocument.prototype.adoptNode = function(source) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.ins = function (target, content) { + if (content === void 0) { content = ''; } + this._serializeOpenTag(true); + var node; + try { + node = BuilderFunctions_1.fragment(this._builderOptions).ins(target, content).first().node; + } + catch (err) { + /* istanbul ignore next */ + this.emit("error", err); + /* istanbul ignore next */ + return this; + } + if (this._options.wellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { + this.emit("error", new Error("Processing instruction target contains invalid characters (well-formed required).")); + return this; + } + if (this._options.wellFormed && !algorithm_1.xml_isLegalChar(node.data)) { + this.emit("error", Error("Processing instruction data contains invalid characters (well-formed required).")); + return this; + } + this._push(this._writer.instruction(node.target, node.data)); + return this; }; - - XMLDocument.prototype.normalizeDocument = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dat = function (content) { + this._serializeOpenTag(true); + var node; + try { + node = BuilderFunctions_1.fragment(this._builderOptions).dat(content).first().node; + } + catch (err) { + this.emit("error", err); + return this; + } + this._push(this._writer.cdata(node.data)); + return this; }; - - XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dec = function (options) { + if (options === void 0) { options = { version: "1.0" }; } + if (this._fragment) { + this.emit("error", Error("Cannot insert an XML declaration into a document fragment.")); + return this; + } + if (this._hasDeclaration) { + this.emit("error", Error("XML declaration is already inserted.")); + return this; + } + this._push(this._writer.declaration(options.version || "1.0", options.encoding, options.standalone)); + this._hasDeclaration = true; + return this; }; - - XMLDocument.prototype.getElementsByClassName = function(classNames) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dtd = function (options) { + if (this._fragment) { + this.emit("error", Error("Cannot insert a DocType declaration into a document fragment.")); + return this; + } + if (this._docTypeName !== "") { + this.emit("error", new Error("DocType declaration is already inserted.")); + return this; + } + if (this._hasDocumentElement) { + this.emit("error", new Error("Cannot insert DocType declaration after document element.")); + return this; + } + var node; + try { + node = BuilderFunctions_1.create().dtd(options).first().node; + } + catch (err) { + this.emit("error", err); + return this; + } + if (this._options.wellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { + this.emit("error", new Error("DocType public identifier does not match PubidChar construct (well-formed required).")); + return this; + } + if (this._options.wellFormed && + (!algorithm_1.xml_isLegalChar(node.systemId) || + (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { + this.emit("error", new Error("DocType system identifier contains invalid characters (well-formed required).")); + return this; + } + this._docTypeName = options.name; + this._push(this._writer.docType(options.name, node.publicId, node.systemId)); + return this; }; - - XMLDocument.prototype.createEvent = function(eventInterface) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createRange = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.up = function () { + this._serializeOpenTag(false); + this._serializeCloseTag(); + return this; }; - - return XMLDocument; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 7356: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue; - - NodeType = __nccwpck_require__(9267); - - XMLDocument = __nccwpck_require__(3730); - - XMLElement = __nccwpck_require__(9437); - - XMLCData = __nccwpck_require__(333); - - XMLComment = __nccwpck_require__(4407); - - XMLRaw = __nccwpck_require__(6329); - - XMLText = __nccwpck_require__(1318); - - XMLProcessingInstruction = __nccwpck_require__(6939); - - XMLDeclaration = __nccwpck_require__(6364); - - XMLDocType = __nccwpck_require__(1801); - - XMLDTDAttList = __nccwpck_require__(1015); - - XMLDTDEntity = __nccwpck_require__(53); - - XMLDTDElement = __nccwpck_require__(2421); - - XMLDTDNotation = __nccwpck_require__(2837); - - XMLAttribute = __nccwpck_require__(8376); - - XMLStringifier = __nccwpck_require__(8594); - - XMLStringWriter = __nccwpck_require__(5913); - - WriterState = __nccwpck_require__(9766); - - module.exports = XMLDocumentCB = (function() { - function XMLDocumentCB(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; - } - - XMLDocumentCB.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(); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.end = function () { + this._serializeOpenTag(false); + while (this._openTags.length > 0) { + this._serializeCloseTag(); } - } - return this; - }; - - XMLDocumentCB.prototype.dummy = function() { - return this; - }; - - XMLDocumentCB.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; + this._push(null); + return this; }; - - XMLDocumentCB.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); + /** + * Serializes the opening tag of an element node. + * + * @param hasChildren - whether the element node has child nodes + */ + XMLBuilderCBImpl.prototype._serializeOpenTag = function (hasChildren) { + if (this._currentElementSerialized) + return; + if (this._currentElement === undefined) + return; + var node = this._currentElement.node; + if (this._options.wellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + this.emit("error", new Error("Node local name contains invalid characters (well-formed required).")); + return; } - } - return this; - }; - - XMLDocumentCB.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); + var qualifiedName = ""; + var ignoreNamespaceDefinitionAttribute = false; + var map = this._prefixMap.copy(); + var localPrefixesMap = {}; + var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); + var inheritedNS = this._openTags.length === 0 ? null : this._openTags[this._openTags.length - 1][1]; + var ns = node.namespaceURI; + if (ns === null) + ns = inheritedNS; + if (inheritedNS === ns) { + if (localDefaultNamespace !== null) { + ignoreNamespaceDefinitionAttribute = true; + } + if (ns === infra_1.namespace.XML) { + qualifiedName = "xml:" + node.localName; + } + else { + qualifiedName = node.localName; + } + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); } - } else { - if (isFunction(value)) { - value = value.apply(); + else { + var prefix = node.prefix; + var candidatePrefix = null; + if (prefix !== null || ns !== localDefaultNamespace) { + candidatePrefix = map.get(prefix, ns); + } + if (prefix === "xmlns") { + if (this._options.wellFormed) { + this.emit("error", new Error("An element cannot have the 'xmlns' prefix (well-formed required).")); + return; + } + candidatePrefix = prefix; + } + if (candidatePrefix !== null) { + qualifiedName = candidatePrefix + ':' + node.localName; + if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { + inheritedNS = localDefaultNamespace || null; + } + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + } + else if (prefix !== null) { + if (prefix in localPrefixesMap) { + prefix = this._generatePrefix(ns, map, this._prefixIndex); + } + map.set(prefix, ns); + qualifiedName += prefix + ':' + node.localName; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + this._push(this._writer.attribute("xmlns:" + prefix, this._serializeAttributeValue(ns, this._options.wellFormed))); + if (localDefaultNamespace !== null) { + inheritedNS = localDefaultNamespace || null; + } + } + else if (localDefaultNamespace === null || + (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { + ignoreNamespaceDefinitionAttribute = true; + qualifiedName += node.localName; + inheritedNS = ns; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + this._push(this._writer.attribute("xmlns", this._serializeAttributeValue(ns, this._options.wellFormed))); + } + else { + qualifiedName += node.localName; + inheritedNS = ns; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + } } - 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); + this._serializeAttributes(node, map, this._prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, this._options.wellFormed); + var isHTML = (ns === infra_1.namespace.HTML); + if (isHTML && !hasChildren && + XMLBuilderCBImpl._VoidElementNames.has(node.localName)) { + this._push(this._writer.openTagEnd(qualifiedName, true, true)); + this._writer.endElement(qualifiedName); } - } - return this; - }; - - XMLDocumentCB.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; - }; - - XMLDocumentCB.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; - }; - - XMLDocumentCB.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; + else if (!isHTML && !hasChildren) { + this._push(this._writer.openTagEnd(qualifiedName, true, false)); + this._writer.endElement(qualifiedName); + } + else { + this._push(this._writer.openTagEnd(qualifiedName, false, false)); + } + this._currentElementSerialized = true; + /** + * Save qualified name, original inherited ns, original prefix map, and + * hasChildren flag. + */ + this._openTags.push([qualifiedName, inheritedNS, this._prefixMap, hasChildren]); + /** + * New values of inherited namespace and prefix map will be used while + * serializing child nodes. They will be returned to their original values + * when this node is closed using the _openTags array item we saved above. + */ + if (this._isPrefixMapModified(this._prefixMap, map)) { + this._prefixMap = map; + } + /** + * Calls following this will either serialize child nodes or close this tag. + */ + this._writer.level++; }; - - XMLDocumentCB.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; + /** + * Serializes the closing tag of an element node. + */ + XMLBuilderCBImpl.prototype._serializeCloseTag = function () { + this._writer.level--; + var lastEle = this._openTags.pop(); + /* istanbul ignore next */ + if (lastEle === undefined) { + this.emit("error", new Error("Last element is undefined.")); + return; + } + var _a = __read(lastEle, 4), qualifiedName = _a[0], ns = _a[1], map = _a[2], hasChildren = _a[3]; + /** + * Restore original values of inherited namespace and prefix map. + */ + this._prefixMap = map; + if (!hasChildren) + return; + this._push(this._writer.closeTag(qualifiedName)); + this._writer.endElement(qualifiedName); }; - - XMLDocumentCB.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); + /** + * Pushes data to internal buffer. + * + * @param data - data + */ + XMLBuilderCBImpl.prototype._push = function (data) { + if (data === null) { + this._ended = true; + this.emit("end"); } - } else if (isObject(target)) { - for (insTarget in target) { - if (!hasProp.call(target, insTarget)) continue; - insValue = target[insTarget]; - this.instruction(insTarget, insValue); + else if (this._ended) { + this.emit("error", new Error("Cannot push to ended stream.")); } - } else { - if (isFunction(value)) { - value = value.apply(); + else if (data.length !== 0) { + this._writer.hasData = true; + this.emit("data", data, this._writer.level); } - node = new XMLProcessingInstruction(this, target, value); - this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); - } - return this; }; - - XMLDocumentCB.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; + /** + * Reads and serializes an XML tree. + * + * @param node - root node + */ + XMLBuilderCBImpl.prototype._fromNode = function (node) { + var e_2, _a, e_3, _b; + if (util_2.Guard.isElementNode(node)) { + var name = node.prefix ? node.prefix + ":" + node.localName : node.localName; + if (node.namespaceURI !== null) { + this.ele(node.namespaceURI, name); + } + else { + this.ele(name); + } + try { + for (var _c = __values(node.attributes), _d = _c.next(); !_d.done; _d = _c.next()) { + var attr = _d.value; + var name_1 = attr.prefix ? attr.prefix + ":" + attr.localName : attr.localName; + if (attr.namespaceURI !== null) { + this.att(attr.namespaceURI, name_1, attr.value); + } + else { + this.att(name_1, attr.value); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_2) throw e_2.error; } + } + try { + for (var _e = __values(node.childNodes), _f = _e.next(); !_f.done; _f = _e.next()) { + var child = _f.value; + this._fromNode(child); + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + } + finally { if (e_3) throw e_3.error; } + } + this.up(); + } + else if (util_2.Guard.isExclusiveTextNode(node) && node.data) { + this.txt(node.data); + } + else if (util_2.Guard.isCommentNode(node)) { + this.com(node.data); + } + else if (util_2.Guard.isCDATASectionNode(node)) { + this.dat(node.data); + } + else if (util_2.Guard.isProcessingInstructionNode(node)) { + this.ins(node.target, node.data); + } }; - - XMLDocumentCB.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; - }; - - XMLDocumentCB.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; - }; - - XMLDocumentCB.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; - }; - - XMLDocumentCB.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; - }; - - XMLDocumentCB.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; - }; - - XMLDocumentCB.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; - }; - - XMLDocumentCB.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); + /** + * Produces an XML serialization of the attributes of an element node. + * + * @param node - node to serialize + * @param map - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param localPrefixesMap - local prefixes map + * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace + * attributes + * @param requireWellFormed - whether to check conformance + */ + XMLBuilderCBImpl.prototype._serializeAttributes = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed) { + var e_4, _a; + var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; + try { + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + // Optimize common case + if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { + this._push(this._writer.attribute(attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); + continue; + } + if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { + this.emit("error", new Error("Element contains duplicate attributes (well-formed required).")); + return; + } + if (requireWellFormed && localNameSet) + localNameSet.set(attr.namespaceURI, attr.localName); + var attributeNamespace = attr.namespaceURI; + var candidatePrefix = null; + if (attributeNamespace !== null) { + candidatePrefix = map.get(attr.prefix, attributeNamespace); + if (attributeNamespace === infra_1.namespace.XMLNS) { + if (attr.value === infra_1.namespace.XML || + (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || + (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || + localPrefixesMap[attr.localName] !== attr.value) && + map.has(attr.localName, attr.value))) + continue; + if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { + this.emit("error", new Error("XMLNS namespace is reserved (well-formed required).")); + return; + } + if (requireWellFormed && attr.value === '') { + this.emit("error", new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).")); + return; + } + if (attr.prefix === 'xmlns') + candidatePrefix = 'xmlns'; + /** + * _Note:_ The (candidatePrefix === null) check is not in the spec. + * We deviate from the spec here. Otherwise a prefix is generated for + * all attributes with namespaces. + */ + } + else if (candidatePrefix === null) { + if (attr.prefix !== null && + (!map.hasPrefix(attr.prefix) || + map.has(attr.prefix, attributeNamespace))) { + /** + * Check if we can use the attribute's own prefix. + * We deviate from the spec here. + * TODO: This is not an efficient way of searching for prefixes. + * Follow developments to the spec. + */ + candidatePrefix = attr.prefix; + } + else { + candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); + } + this._push(this._writer.attribute("xmlns:" + candidatePrefix, this._serializeAttributeValue(attributeNamespace, this._options.wellFormed))); + } + } + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName) || + (attr.localName === "xmlns" && attributeNamespace === null))) { + this.emit("error", new Error("Attribute local name contains invalid characters (well-formed required).")); + return; + } + this._push(this._writer.attribute((candidatePrefix !== null ? candidatePrefix + ":" : "") + attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_4) throw e_4.error; } } - this.currentNode = null; - } else { - this.closeNode(this.openTags[this.currentLevel]); - } - delete this.openTags[this.currentLevel]; - this.currentLevel--; - return this; - }; - - XMLDocumentCB.prototype.end = function() { - while (this.currentLevel >= 0) { - this.up(); - } - return this.onEnd(); - }; - - XMLDocumentCB.prototype.openCurrent = function() { - if (this.currentNode) { - this.currentNode.children = true; - return this.openNode(this.currentNode); - } }; - - XMLDocumentCB.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; + /** + * Produces an XML serialization of an attribute value. + * + * @param value - attribute value + * @param requireWellFormed - whether to check conformance + */ + XMLBuilderCBImpl.prototype._serializeAttributeValue = function (value, requireWellFormed) { + if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { + this.emit("error", new Error("Invalid characters in attribute value.")); + return ""; } - 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) + ''; - } - chunk += this.writer.endline(node, this.writerOptions, this.currentLevel); + if (value === null) + return ""; + if (this._options.noDoubleEncoding) { + return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); } - this.onData(chunk, this.currentLevel); - return node.isOpen = true; - } - }; - - XMLDocumentCB.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) + '' + 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); + else { + var result = ""; + for (var i = 0; i < value.length; i++) { + var c = value[i]; + if (c === "\"") + result += """; + else if (c === "&") + result += "&"; + else if (c === "<") + result += "<"; + else if (c === ">") + result += ">"; + else + result += c; + } + return result; } - this.writerOptions.state = WriterState.None; - this.onData(chunk, this.currentLevel); - return node.isClosed = true; - } }; - - XMLDocumentCB.prototype.onData = function(chunk, level) { - this.documentStarted = true; - return this.onDataCallback(chunk, level + 1); - }; - - XMLDocumentCB.prototype.onEnd = function() { - this.documentCompleted = true; - return this.onEndCallback(); - }; - - XMLDocumentCB.prototype.debugInfo = function(name) { - if (name == null) { - return ""; - } else { - return "node: <" + name + ">"; - } - }; - - XMLDocumentCB.prototype.ele = function() { - return this.element.apply(this, arguments); - }; - - XMLDocumentCB.prototype.nod = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLDocumentCB.prototype.txt = function(value) { - return this.text(value); - }; - - XMLDocumentCB.prototype.dat = function(value) { - return this.cdata(value); - }; - - XMLDocumentCB.prototype.com = function(value) { - return this.comment(value); - }; - - XMLDocumentCB.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; - - XMLDocumentCB.prototype.dec = function(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - }; - - XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) { - return this.doctype(root, pubID, sysID); - }; - - XMLDocumentCB.prototype.e = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLDocumentCB.prototype.n = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLDocumentCB.prototype.t = function(value) { - return this.text(value); - }; - - XMLDocumentCB.prototype.d = function(value) { - return this.cdata(value); - }; - - XMLDocumentCB.prototype.c = function(value) { - return this.comment(value); - }; - - XMLDocumentCB.prototype.r = function(value) { - return this.raw(value); - }; - - XMLDocumentCB.prototype.i = function(target, value) { - return this.instruction(target, value); - }; - - XMLDocumentCB.prototype.att = function() { - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - return this.attList.apply(this, arguments); - } else { - return this.attribute.apply(this, arguments); - } - }; - - XMLDocumentCB.prototype.a = function() { - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - return this.attList.apply(this, arguments); - } else { - return this.attribute.apply(this, arguments); - } - }; - - XMLDocumentCB.prototype.ent = function(name, value) { - return this.entity(name, value); + /** + * Records namespace information for the given element and returns the + * default namespace attribute value. + * + * @param node - element node to process + * @param map - namespace prefix map + * @param localPrefixesMap - local prefixes map + */ + XMLBuilderCBImpl.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { + var e_5, _a; + var defaultNamespaceAttrValue = null; + try { + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + var attributeNamespace = attr.namespaceURI; + var attributePrefix = attr.prefix; + if (attributeNamespace === infra_1.namespace.XMLNS) { + if (attributePrefix === null) { + defaultNamespaceAttrValue = attr.value; + continue; + } + else { + var prefixDefinition = attr.localName; + var namespaceDefinition = attr.value; + if (namespaceDefinition === infra_1.namespace.XML) { + continue; + } + if (namespaceDefinition === '') { + namespaceDefinition = null; + } + if (map.has(prefixDefinition, namespaceDefinition)) { + continue; + } + map.set(prefixDefinition, namespaceDefinition); + localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; + } + } + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_5) throw e_5.error; } + } + return defaultNamespaceAttrValue; }; - - XMLDocumentCB.prototype.pent = function(name, value) { - return this.pEntity(name, value); + /** + * Generates a new prefix for the given namespace. + * + * @param newNamespace - a namespace to generate prefix for + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + */ + XMLBuilderCBImpl.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { + var generatedPrefix = "ns" + prefixIndex.value; + prefixIndex.value++; + prefixMap.set(generatedPrefix, newNamespace); + return generatedPrefix; }; - - XMLDocumentCB.prototype.not = function(name, value) { - return this.notation(name, value); + /** + * Determines if the namespace prefix map was modified from its original. + * + * @param originalMap - original namespace prefix map + * @param newMap - new namespace prefix map + */ + XMLBuilderCBImpl.prototype._isPrefixMapModified = function (originalMap, newMap) { + var items1 = originalMap._items; + var items2 = newMap._items; + var nullItems1 = originalMap._nullItems; + var nullItems2 = newMap._nullItems; + for (var key in items2) { + var arr1 = items1[key]; + if (arr1 === undefined) + return true; + var arr2 = items2[key]; + if (arr1.length !== arr2.length) + return true; + for (var i = 0; i < arr1.length; i++) { + if (arr1[i] !== arr2[i]) + return true; + } + } + if (nullItems1.length !== nullItems2.length) + return true; + for (var i = 0; i < nullItems1.length; i++) { + if (nullItems1[i] !== nullItems2[i]) + return true; + } + return false; }; - - return XMLDocumentCB; - - })(); - -}).call(this); - + XMLBuilderCBImpl._VoidElementNames = new Set(['area', 'base', 'basefont', + 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', + 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); + return XMLBuilderCBImpl; +}(events_1.EventEmitter)); +exports.XMLBuilderCBImpl = XMLBuilderCBImpl; +//# sourceMappingURL=XMLBuilderCBImpl.js.map /***/ }), -/***/ 3590: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); +/***/ 8248: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports = XMLDummy = (function(superClass) { - extend(XMLDummy, superClass); +"use strict"; - function XMLDummy(parent) { - XMLDummy.__super__.constructor.call(this, parent); - this.type = NodeType.Dummy; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } - - XMLDummy.prototype.clone = function() { - return Object.create(this); - }; - - XMLDummy.prototype.toString = function(options) { - return ''; + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } }; - - return XMLDummy; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 9437: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue; - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - XMLAttribute = __nccwpck_require__(8376); - - XMLNamedNodeMap = __nccwpck_require__(4361); - - module.exports = XMLElement = (function(superClass) { - extend(XMLElement, superClass); - - function XMLElement(parent, name, attributes) { - var child, j, len, ref1; - XMLElement.__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; - } - } - } - } + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var writers_1 = __nccwpck_require__(7476); +var interfaces_2 = __nccwpck_require__(7305); +var util_2 = __nccwpck_require__(5282); +var algorithm_1 = __nccwpck_require__(61); +var dom_1 = __nccwpck_require__(770); +var infra_1 = __nccwpck_require__(4251); +var readers_1 = __nccwpck_require__(560); +/** + * Represents a wrapper that extends XML nodes to implement easy to use and + * chainable document builder methods. + */ +var XMLBuilderImpl = /** @class */ (function () { + /** + * Initializes a new instance of `XMLBuilderNodeImpl`. + * + * @param domNode - the DOM node to wrap + */ + function XMLBuilderImpl(domNode) { + this._domNode = domNode; } - - Object.defineProperty(XMLElement.prototype, 'tagName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLElement.prototype, 'namespaceURI', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLElement.prototype, 'prefix', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLElement.prototype, 'localName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLElement.prototype, 'id', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - Object.defineProperty(XMLElement.prototype, 'className', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - Object.defineProperty(XMLElement.prototype, 'classList', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } + Object.defineProperty(XMLBuilderImpl.prototype, "node", { + /** @inheritdoc */ + get: function () { return this._domNode; }, + enumerable: true, + configurable: true }); - - Object.defineProperty(XMLElement.prototype, 'attributes', { - get: function() { - if (!this.attributeMap || !this.attributeMap.nodes) { - this.attributeMap = new XMLNamedNodeMap(this.attribs); - } - return this.attributeMap; - } + Object.defineProperty(XMLBuilderImpl.prototype, "options", { + /** @inheritdoc */ + get: function () { return this._options; }, + enumerable: true, + configurable: true }); - - XMLElement.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; + /** @inheritdoc */ + XMLBuilderImpl.prototype.set = function (options) { + this._options = util_1.applyDefaults(util_1.applyDefaults(this._options, options, true), // apply user settings + interfaces_1.DefaultBuilderOptions); // provide defaults + return this; }; - - XMLElement.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); + /** @inheritdoc */ + XMLBuilderImpl.prototype.ele = function (p1, p2, p3) { + var _a, _b, _c; + var namespace; + var name; + var attributes; + if (util_1.isObject(p1)) { + // ele(obj: ExpandObject) + return new readers_1.ObjectReader(this._options).parse(this, p1); } - } else { - if (isFunction(value)) { - value = value.apply(); + else if (p1 !== null && /^\s*= ref1; i = 0 <= ref1 ? ++j : --j) { - if (!this.attribs[i].isEqualNode(node.attribs[i])) { - return false; + }; + /** @inheritdoc */ + XMLBuilderImpl.prototype.toArray = function (self, recursive) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = []; + this.each(function (node) { return result.push(node); }, self, recursive); + return result; + }; + /** @inheritdoc */ + XMLBuilderImpl.prototype.toString = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "xml"; + } + return this._serialize(writerOptions); + }; + /** @inheritdoc */ + XMLBuilderImpl.prototype.toObject = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "object"; + } + return this._serialize(writerOptions); + }; + /** @inheritdoc */ + XMLBuilderImpl.prototype.end = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "xml"; + } + return this.doc()._serialize(writerOptions); + }; + /** + * Gets the next descendant of the given node of the tree rooted at `root` + * in depth-first pre-order. Returns a three-tuple with + * [descendant, descendant_index, descendant_level]. + * + * @param root - root node of the tree + * @param self - whether to visit the current node along with child nodes + * @param recursive - whether to visit all descendant nodes in tree-order or + * only the immediate child nodes + */ + XMLBuilderImpl.prototype._getFirstDescendantNode = function (root, self, recursive) { + if (self) + return [this._domNode, 0, 0]; + else if (recursive) + return this._getNextDescendantNode(root, root, recursive, 0, 0); + else + return [this._domNode.firstChild, 0, 1]; + }; + /** + * Gets the next descendant of the given node of the tree rooted at `root` + * in depth-first pre-order. Returns a three-tuple with + * [descendant, descendant_index, descendant_level]. + * + * @param root - root node of the tree + * @param node - current node + * @param recursive - whether to visit all descendant nodes in tree-order or + * only the immediate child nodes + * @param index - child node index + * @param level - current depth of the XML tree + */ + XMLBuilderImpl.prototype._getNextDescendantNode = function (root, node, recursive, index, level) { + if (recursive) { + // traverse child nodes + if (node.firstChild) + return [node.firstChild, 0, level + 1]; + if (node === root) + return [null, -1, -1]; + // traverse siblings + if (node.nextSibling) + return [node.nextSibling, index + 1, level]; + // traverse parent's next sibling + var parent = node.parentNode; + while (parent && parent !== root) { + if (parent.nextSibling) + return [parent.nextSibling, algorithm_1.tree_index(parent.nextSibling), level - 1]; + parent = parent.parentNode; + level--; + } + } + else { + if (root === node) + return [node.firstChild, 0, level + 1]; + else + return [node.nextSibling, index + 1, level]; + } + return [null, -1, -1]; + }; + /** + * Converts the node into its string or object representation. + * + * @param options - serialization options + */ + XMLBuilderImpl.prototype._serialize = function (writerOptions) { + if (writerOptions.format === "xml") { + var writer = new writers_1.XMLWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "map") { + var writer = new writers_1.MapWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "object") { + var writer = new writers_1.ObjectWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "json") { + var writer = new writers_1.JSONWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "yaml") { + var writer = new writers_1.YAMLWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else { + throw new Error("Invalid writer format: " + writerOptions.format + ". " + this._debugInfo()); + } + }; + /** + * Extracts a namespace and name from the given string. + * + * @param namespace - namespace + * @param name - a string containing both a name and namespace separated by an + * `'@'` character + * @param ele - `true` if this is an element namespace; otherwise `false` + */ + XMLBuilderImpl.prototype._extractNamespace = function (namespace, name, ele) { + // extract from name + var atIndex = name.indexOf("@"); + if (atIndex > 0) { + if (namespace === undefined) + namespace = name.slice(atIndex + 1); + name = name.slice(0, atIndex); + } + if (namespace === undefined) { + // look-up default namespace + namespace = (ele ? this._options.defaultNamespace.ele : this._options.defaultNamespace.att); + } + else if (namespace !== null && namespace[0] === "@") { + // look-up namespace aliases + var alias = namespace.slice(1); + namespace = this._options.namespaceAlias[alias]; + if (namespace === undefined) { + throw new Error("Namespace alias `" + alias + "` is not defined. " + this._debugInfo()); + } + } + return [namespace, name]; + }; + /** + * Updates the element's namespace. + * + * @param ns - new namespace + */ + XMLBuilderImpl.prototype._updateNamespace = function (ns) { + var e_2, _a, e_3, _b; + var ele = this._domNode; + if (util_2.Guard.isElementNode(ele) && ns !== null && ele.namespaceURI !== ns) { + var _c = __read(algorithm_1.namespace_extractQName(ele.prefix ? ele.prefix + ':' + ele.localName : ele.localName), 2), elePrefix = _c[0], eleLocalName = _c[1]; + // re-create the element node if its namespace changed + // we can't simply change the namespaceURI since its read-only + var newEle = algorithm_1.create_element(this._doc, eleLocalName, ns, elePrefix); + try { + for (var _d = __values(ele.attributes), _e = _d.next(); !_e.done; _e = _d.next()) { + var attr = _e.value; + var attrQName = attr.prefix ? attr.prefix + ':' + attr.localName : attr.localName; + var _f = __read(algorithm_1.namespace_extractQName(attrQName), 1), attrPrefix = _f[0]; + var newAttrNS = attr.namespaceURI; + if (newAttrNS === null && attrPrefix !== null) { + newAttrNS = ele.lookupNamespaceURI(attrPrefix); + } + if (newAttrNS === null) { + newEle.setAttribute(attrQName, attr.value); + } + else { + newEle.setAttributeNS(newAttrNS, attrQName, attr.value); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_e && !_e.done && (_a = _d.return)) _a.call(_d); + } + finally { if (e_2) throw e_2.error; } + } + // replace the new node in parent node + var parent = ele.parentNode; + /* istanbul ignore next */ + if (parent === null) { + throw new Error("Parent node is null." + this._debugInfo()); + } + parent.replaceChild(newEle, ele); + this._domNode = newEle; + try { + // check child nodes + for (var _g = __values(ele.childNodes), _h = _g.next(); !_h.done; _h = _g.next()) { + var childNode = _h.value; + var newChildNode = childNode.cloneNode(true); + newEle.appendChild(newChildNode); + if (util_2.Guard.isElementNode(newChildNode)) { + var _j = __read(algorithm_1.namespace_extractQName(newChildNode.prefix ? newChildNode.prefix + ':' + newChildNode.localName : newChildNode.localName), 1), newChildNodePrefix = _j[0]; + var newChildNodeNS = newEle.lookupNamespaceURI(newChildNodePrefix); + new XMLBuilderImpl(newChildNode)._updateNamespace(newChildNodeNS); + } + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_h && !_h.done && (_b = _g.return)) _b.call(_g); + } + finally { if (e_3) throw e_3.error; } + } + } + }; + Object.defineProperty(XMLBuilderImpl.prototype, "_doc", { + /** + * Returns the document owning this node. + */ + get: function () { + var node = this.node; + if (util_2.Guard.isDocumentNode(node)) { + return node; + } + else { + var docNode = node.ownerDocument; + /* istanbul ignore next */ + if (!docNode) + throw new Error("Owner document is null. " + this._debugInfo()); + return docNode; + } + }, + enumerable: true, + configurable: true + }); + /** + * Returns debug information for this node. + * + * @param name - node name + */ + XMLBuilderImpl.prototype._debugInfo = function (name) { + var node = this.node; + var parentNode = node.parentNode; + name = name || node.nodeName; + var parentName = parentNode ? parentNode.nodeName : ''; + if (!parentName) { + return "node: <" + name + ">"; + } + else { + return "node: <" + name + ">, parent: <" + parentName + ">"; + } + }; + Object.defineProperty(XMLBuilderImpl.prototype, "_options", { + /** + * Gets or sets builder options. + */ + get: function () { + var doc = this._doc; + /* istanbul ignore next */ + if (doc._xmlBuilderOptions === undefined) { + throw new Error("Builder options is not set."); + } + return doc._xmlBuilderOptions; + }, + set: function (value) { + var doc = this._doc; + doc._xmlBuilderOptions = value; + }, + enumerable: true, + configurable: true + }); + return XMLBuilderImpl; +}()); +exports.XMLBuilderImpl = XMLBuilderImpl; +//# sourceMappingURL=XMLBuilderImpl.js.map + +/***/ }), + +/***/ 770: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +var dom_1 = __nccwpck_require__(4646); +var dom_2 = __nccwpck_require__(633); +var util_1 = __nccwpck_require__(6195); +dom_2.dom.setFeatures(false); +/** + * Creates an XML document without any child nodes. + */ +function createDocument() { + var impl = new dom_1.DOMImplementation(); + var doc = impl.createDocument(null, 'root', null); + /* istanbul ignore else */ + if (doc.documentElement) { + doc.removeChild(doc.documentElement); + } + return doc; +} +exports.createDocument = createDocument; +/** + * Sanitizes input strings with user supplied replacement characters. + * + * @param str - input string + * @param replacement - replacement character or function + */ +function sanitizeInput(str, replacement) { + if (str == null) { + return str; + } + else if (replacement === undefined) { + return str + ""; + } + else { + var result = ""; + str = str + ""; + for (var i = 0; i < str.length; i++) { + var n = str.charCodeAt(i); + // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] + if (n === 0x9 || n === 0xA || n === 0xD || + (n >= 0x20 && n <= 0xD7FF) || + (n >= 0xE000 && n <= 0xFFFD)) { + // valid character - not surrogate pair + result += str.charAt(i); + } + else if (n >= 0xD800 && n <= 0xDBFF && i < str.length - 1) { + var n2 = str.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + // valid surrogate pair + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + result += String.fromCodePoint(n); + i++; + } + else { + // invalid lone surrogate + result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); + } + } + else { + // invalid character + result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); + } + } + return result; + } +} +exports.sanitizeInput = sanitizeInput; +//# sourceMappingURL=dom.js.map + +/***/ }), + +/***/ 4260: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +var XMLBuilderImpl_1 = __nccwpck_require__(8248); +exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; +var XMLBuilderCBImpl_1 = __nccwpck_require__(1438); +exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; +var BuilderFunctions_1 = __nccwpck_require__(5696); +exports.builder = BuilderFunctions_1.builder; +exports.create = BuilderFunctions_1.create; +exports.fragment = BuilderFunctions_1.fragment; +exports.convert = BuilderFunctions_1.convert; +var BuilderFunctionsCB_1 = __nccwpck_require__(268); +exports.createCB = BuilderFunctionsCB_1.createCB; +exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 151: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +var builder_1 = __nccwpck_require__(4260); +exports.builder = builder_1.builder; +exports.create = builder_1.create; +exports.fragment = builder_1.fragment; +exports.convert = builder_1.convert; +exports.createCB = builder_1.createCB; +exports.fragmentCB = builder_1.fragmentCB; +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 6417: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * Defines default values for builder options. + */ +exports.DefaultBuilderOptions = { + version: "1.0", + encoding: undefined, + standalone: undefined, + keepNullNodes: false, + keepNullAttributes: false, + ignoreConverters: false, + convert: { + att: "@", + ins: "?", + text: "#", + cdata: "$", + comment: "!" + }, + defaultNamespace: { + ele: undefined, + att: undefined + }, + namespaceAlias: { + html: "http://www.w3.org/1999/xhtml", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/", + mathml: "http://www.w3.org/1998/Math/MathML", + svg: "http://www.w3.org/2000/svg", + xlink: "http://www.w3.org/1999/xlink" + }, + invalidCharReplacement: undefined, + parser: undefined +}; +/** + * Contains keys of `XMLBuilderOptions`. + */ +exports.XMLBuilderOptionKeys = new Set(Object.keys(exports.DefaultBuilderOptions)); +/** + * Defines default values for builder options. + */ +exports.DefaultXMLBuilderCBOptions = { + format: "xml", + wellFormed: false, + prettyPrint: false, + indent: " ", + newline: "\n", + offset: 0, + width: 0, + allowEmptyTags: false, + spaceBeforeSlash: false, + keepNullNodes: false, + keepNullAttributes: false, + ignoreConverters: false, + convert: { + att: "@", + ins: "?", + text: "#", + cdata: "$", + comment: "!" + }, + defaultNamespace: { + ele: undefined, + att: undefined + }, + namespaceAlias: { + html: "http://www.w3.org/1999/xhtml", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/", + mathml: "http://www.w3.org/1998/Math/MathML", + svg: "http://www.w3.org/2000/svg", + xlink: "http://www.w3.org/1999/xlink" + } +}; +//# sourceMappingURL=interfaces.js.map + +/***/ }), + +/***/ 3396: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * Pre-serializes XML nodes. + */ +var BaseReader = /** @class */ (function () { + /** + * Initializes a new instance of `BaseReader`. + * + * @param builderOptions - XML builder options + */ + function BaseReader(builderOptions) { + this._builderOptions = builderOptions; + if (builderOptions.parser) { + Object.assign(this, builderOptions.parser); + } + } + BaseReader.prototype._docType = function (parent, name, publicId, systemId) { + return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); + }; + BaseReader.prototype._comment = function (parent, data) { + return parent.com(data); + }; + BaseReader.prototype._text = function (parent, data) { + return parent.txt(data); + }; + BaseReader.prototype._instruction = function (parent, target, data) { + return parent.ins(target, data); + }; + BaseReader.prototype._cdata = function (parent, data) { + return parent.dat(data); + }; + BaseReader.prototype._element = function (parent, namespace, name) { + return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); + }; + BaseReader.prototype._attribute = function (parent, namespace, name, value) { + return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); + }; + /** + * Main parser function which parses the given object and returns an XMLBuilder. + * + * @param node - node to recieve parsed content + * @param obj - object to parse + */ + BaseReader.prototype.parse = function (node, obj) { + return this._parse(node, obj); + }; + /** + * Creates a DocType node. + * The node will be skipped if the function returns `undefined`. + * + * @param name - node name + * @param publicId - public identifier + * @param systemId - system identifier + */ + BaseReader.prototype.docType = function (parent, name, publicId, systemId) { + return this._docType(parent, name, publicId, systemId); + }; + /** + * Creates a comment node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.comment = function (parent, data) { + return this._comment(parent, data); + }; + /** + * Creates a text node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.text = function (parent, data) { + return this._text(parent, data); + }; + /** + * Creates a processing instruction node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param target - instruction target + * @param data - node data + */ + BaseReader.prototype.instruction = function (parent, target, data) { + return this._instruction(parent, target, data); + }; + /** + * Creates a CData section node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.cdata = function (parent, data) { + return this._cdata(parent, data); + }; + /** + * Creates an element node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param namespace - node namespace + * @param name - node name + */ + BaseReader.prototype.element = function (parent, namespace, name) { + return this._element(parent, namespace, name); + }; + /** + * Creates an attribute or namespace declaration. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param namespace - node namespace + * @param name - node name + * @param value - node value + */ + BaseReader.prototype.attribute = function (parent, namespace, name, value) { + return this._attribute(parent, namespace, name, value); + }; + return BaseReader; +}()); +exports.BaseReader = BaseReader; +//# sourceMappingURL=BaseReader.js.map + +/***/ }), + +/***/ 3518: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectReader_1 = __nccwpck_require__(768); +var BaseReader_1 = __nccwpck_require__(3396); +/** + * Parses XML nodes from a JSON string. + */ +var JSONReader = /** @class */ (function (_super) { + __extends(JSONReader, _super); + function JSONReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - JSON string to parse + */ + JSONReader.prototype._parse = function (node, str) { + return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, JSON.parse(str)); + }; + return JSONReader; +}(BaseReader_1.BaseReader)); +exports.JSONReader = JSONReader; +//# sourceMappingURL=JSONReader.js.map + +/***/ }), + +/***/ 768: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var BaseReader_1 = __nccwpck_require__(3396); +var dom_1 = __nccwpck_require__(770); +/** + * Parses XML nodes from objects and arrays. + * ES6 maps and sets are also supoorted. + */ +var ObjectReader = /** @class */ (function (_super) { + __extends(ObjectReader, _super); + function ObjectReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param obj - object to parse + */ + ObjectReader.prototype._parse = function (node, obj) { + var _this = this; + var options = this._builderOptions; + // sanitizes input characters + var invalidCharReplacement = options.invalidCharReplacement; + var s = function (str) { + return dom_1.sanitizeInput(str, invalidCharReplacement); + }; + var lastChild = null; + if (util_1.isFunction(obj)) { + // evaluate if function + lastChild = this.parse(node, obj.apply(this)); + } + else if (util_1.isArray(obj) || util_1.isSet(obj)) { + util_1.forEachArray(obj, function (item) { return lastChild = _this.parse(node, item); }, this); + } + else /* if (isMap(obj) || isObject(obj)) */ { + // expand if object + util_1.forEachObject(obj, function (key, val) { + if (util_1.isFunction(val)) { + // evaluate if function + val = val.apply(_this); + } + if (!options.ignoreConverters && key.indexOf(options.convert.att) === 0) { + // assign attributes + if (key === options.convert.att) { + if (util_1.isArray(val) || util_1.isSet(val)) { + throw new Error("Invalid attribute: " + val.toString() + ". " + node._debugInfo()); + } + else /* if (isMap(val) || isObject(val)) */ { + util_1.forEachObject(val, function (attrKey, attrVal) { + lastChild = _this.attribute(node, undefined, s(attrKey), s(attrVal)) || lastChild; + }); + } + } + else { + lastChild = _this.attribute(node, undefined, s(key.substr(options.convert.att.length)), s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.text) === 0) { + // text node + if (util_1.isMap(val) || util_1.isObject(val)) { + // if the key is #text expand child nodes under this node to support mixed content + lastChild = _this.parse(node, val); + } + else { + lastChild = _this.text(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.cdata) === 0) { + // cdata node + if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { return lastChild = _this.cdata(node, s(item)) || lastChild; }, _this); + } + else { + lastChild = _this.cdata(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.comment) === 0) { + // comment node + if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { return lastChild = _this.comment(node, s(item)) || lastChild; }, _this); + } + else { + lastChild = _this.comment(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.ins) === 0) { + // processing instruction + if (util_1.isString(val)) { + var insIndex = val.indexOf(' '); + var insTarget = (insIndex === -1 ? val : val.substr(0, insIndex)); + var insValue = (insIndex === -1 ? '' : val.substr(insIndex + 1)); + lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; + } + else if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { + var insIndex = item.indexOf(' '); + var insTarget = (insIndex === -1 ? item : item.substr(0, insIndex)); + var insValue = (insIndex === -1 ? '' : item.substr(insIndex + 1)); + lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; + }, _this); + } + else /* if (isMap(target) || isObject(target)) */ { + util_1.forEachObject(val, function (insTarget, insValue) { return lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; }, _this); + } + } + else if ((util_1.isArray(val) || util_1.isSet(val)) && util_1.isEmpty(val)) { + // skip empty arrays + } + else if ((util_1.isMap(val) || util_1.isObject(val)) && util_1.isEmpty(val)) { + // empty objects produce one node + lastChild = _this.element(node, undefined, s(key)) || lastChild; + } + else if (!options.keepNullNodes && (val == null)) { + // skip null and undefined nodes + } + else if (util_1.isArray(val) || util_1.isSet(val)) { + // expand list by creating child nodes + util_1.forEachArray(val, function (item) { + var childNode = {}; + childNode[key] = item; + lastChild = _this.parse(node, childNode); + }, _this); + } + else if (util_1.isMap(val) || util_1.isObject(val)) { + // create a parent node + var parent = _this.element(node, undefined, key); + if (parent) { + lastChild = parent; + // expand child nodes under parent + _this.parse(parent, val); + } + } + else if (val != null && val !== '') { + // leaf element node with a single text node + var parent = _this.element(node, undefined, key); + if (parent) { + lastChild = parent; + _this.text(parent, s(val)); + } + } + else { + // leaf element node + lastChild = _this.element(node, undefined, s(key)) || lastChild; + } + }, this); + } + return lastChild || node; + }; + return ObjectReader; +}(BaseReader_1.BaseReader)); +exports.ObjectReader = ObjectReader; +//# sourceMappingURL=ObjectReader.js.map + +/***/ }), + +/***/ 5044: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var XMLStringLexer_1 = __nccwpck_require__(7061); +var interfaces_1 = __nccwpck_require__(7707); +var infra_1 = __nccwpck_require__(4251); +var algorithm_1 = __nccwpck_require__(61); +var dom_1 = __nccwpck_require__(770); +var BaseReader_1 = __nccwpck_require__(3396); +/** + * Parses XML nodes from an XML document string. + */ +var XMLReader = /** @class */ (function (_super) { + __extends(XMLReader, _super); + function XMLReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - XML document string to parse + */ + XMLReader.prototype._parse = function (node, str) { + var e_1, _a, e_2, _b; + var lexer = new XMLStringLexer_1.XMLStringLexer(str, { skipWhitespaceOnlyText: true }); + // sanitizes input characters + var invalidCharReplacement = this._builderOptions.invalidCharReplacement; + var s = function (str) { + return dom_1.sanitizeInput(str, invalidCharReplacement); + }; + var context = node; + var token = lexer.nextToken(); + while (token.type !== interfaces_1.TokenType.EOF) { + switch (token.type) { + case interfaces_1.TokenType.Declaration: + var declaration = token; + var version = s(declaration.version); + if (version !== "1.0") { + throw new Error("Invalid xml version: " + version); + } + var builderOptions = { + version: version + }; + if (declaration.encoding) { + builderOptions.encoding = s(declaration.encoding); + } + if (declaration.standalone) { + builderOptions.standalone = (s(declaration.standalone) === "yes"); + } + context.set(builderOptions); + break; + case interfaces_1.TokenType.DocType: + var doctype = token; + context = this.docType(context, s(doctype.name), s(doctype.pubId), s(doctype.sysId)) || context; + break; + case interfaces_1.TokenType.CDATA: + var cdata = token; + context = this.cdata(context, s(cdata.data)) || context; + break; + case interfaces_1.TokenType.Comment: + var comment = token; + context = this.comment(context, s(comment.data)) || context; + break; + case interfaces_1.TokenType.PI: + var pi = token; + context = this.instruction(context, s(pi.target), s(pi.data)) || context; + break; + case interfaces_1.TokenType.Text: + var text = token; + context = this.text(context, s(text.data)) || context; + break; + case interfaces_1.TokenType.Element: + var element = token; + var elementName = s(element.name); + // inherit namespace from parent + var _c = __read(algorithm_1.namespace_extractQName(elementName), 1), prefix = _c[0]; + var namespace = context.node.lookupNamespaceURI(prefix); + // override namespace if there is a namespace declaration + // attribute + // also lookup namespace declaration attributes + var nsDeclarations = {}; + try { + for (var _d = (e_1 = void 0, __values(element.attributes)), _e = _d.next(); !_e.done; _e = _d.next()) { + var _f = __read(_e.value, 2), attName = _f[0], attValue = _f[1]; + attName = s(attName); + attValue = s(attValue); + if (attName === "xmlns") { + namespace = attValue; + } + else { + var _g = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _g[0], attLocalName = _g[1]; + if (attPrefix === "xmlns") { + if (attLocalName === prefix) { + namespace = attValue; + } + nsDeclarations[attLocalName] = attValue; + } + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_e && !_e.done && (_a = _d.return)) _a.call(_d); + } + finally { if (e_1) throw e_1.error; } + } + // create the DOM element node + var elementNode = (namespace !== null ? + this.element(context, namespace, elementName) : + this.element(context, undefined, elementName)); + if (elementNode === undefined) + break; + try { + // assign attributes + for (var _h = (e_2 = void 0, __values(element.attributes)), _j = _h.next(); !_j.done; _j = _h.next()) { + var _k = __read(_j.value, 2), attName = _k[0], attValue = _k[1]; + attName = s(attName); + attValue = s(attValue); + var _l = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _l[0], attLocalName = _l[1]; + var attNamespace = null; + if (attPrefix === "xmlns" || (attPrefix === null && attLocalName === "xmlns")) { + // namespace declaration attribute + attNamespace = infra_1.namespace.XMLNS; + } + else { + attNamespace = elementNode.node.lookupNamespaceURI(attPrefix); + if (attNamespace !== null && elementNode.node.isDefaultNamespace(attNamespace)) { + attNamespace = null; + } + else if (attNamespace === null && attPrefix !== null) { + attNamespace = nsDeclarations[attPrefix] || null; + } + } + if (attNamespace !== null) + this.attribute(elementNode, attNamespace, attName, attValue); + else + this.attribute(elementNode, undefined, attName, attValue); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_j && !_j.done && (_b = _h.return)) _b.call(_h); + } + finally { if (e_2) throw e_2.error; } + } + if (!element.selfClosing) { + context = elementNode; + } + break; + case interfaces_1.TokenType.ClosingTag: + /* istanbul ignore else */ + if (context.node.parentNode) { + context = context.up(); + } + break; + } + token = lexer.nextToken(); + } + return context; + }; + return XMLReader; +}(BaseReader_1.BaseReader)); +exports.XMLReader = XMLReader; +//# sourceMappingURL=XMLReader.js.map + +/***/ }), + +/***/ 2475: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectReader_1 = __nccwpck_require__(768); +var BaseReader_1 = __nccwpck_require__(3396); +var js_yaml_1 = __nccwpck_require__(1917); +/** + * Parses XML nodes from a YAML string. + */ +var YAMLReader = /** @class */ (function (_super) { + __extends(YAMLReader, _super); + function YAMLReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - YAML string to parse + */ + YAMLReader.prototype._parse = function (node, str) { + var result = js_yaml_1.safeLoad(str); + /* istanbul ignore next */ + if (result === undefined) { + throw new Error("Unable to parse YAML document."); + } + return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, result); + }; + return YAMLReader; +}(BaseReader_1.BaseReader)); +exports.YAMLReader = YAMLReader; +//# sourceMappingURL=YAMLReader.js.map + +/***/ }), + +/***/ 560: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +var XMLReader_1 = __nccwpck_require__(5044); +exports.XMLReader = XMLReader_1.XMLReader; +var ObjectReader_1 = __nccwpck_require__(768); +exports.ObjectReader = ObjectReader_1.ObjectReader; +var JSONReader_1 = __nccwpck_require__(3518); +exports.JSONReader = JSONReader_1.JSONReader; +var YAMLReader_1 = __nccwpck_require__(2475); +exports.YAMLReader = YAMLReader_1.YAMLReader; +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 708: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * Pre-serializes XML nodes. + */ +var BaseCBWriter = /** @class */ (function () { + /** + * Initializes a new instance of `BaseCBWriter`. + * + * @param builderOptions - XML builder options + */ + function BaseCBWriter(builderOptions) { + /** + * Gets the current depth of the XML tree. + */ + this.level = 0; + this._builderOptions = builderOptions; + this._writerOptions = builderOptions; + } + return BaseCBWriter; +}()); +exports.BaseCBWriter = BaseCBWriter; +//# sourceMappingURL=BaseCBWriter.js.map + +/***/ }), + +/***/ 7644: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(7305); +var LocalNameSet_1 = __nccwpck_require__(9049); +var NamespacePrefixMap_1 = __nccwpck_require__(283); +var infra_1 = __nccwpck_require__(4251); +var algorithm_1 = __nccwpck_require__(61); +/** + * Pre-serializes XML nodes. + */ +var BaseWriter = /** @class */ (function () { + /** + * Initializes a new instance of `BaseWriter`. + * + * @param builderOptions - XML builder options + */ + function BaseWriter(builderOptions) { + /** + * Gets the current depth of the XML tree. + */ + this.level = 0; + this._builderOptions = builderOptions; + } + /** + * Used by derived classes to serialize the XML declaration. + * + * @param version - a version number string + * @param encoding - encoding declaration + * @param standalone - standalone document declaration + */ + BaseWriter.prototype.declaration = function (version, encoding, standalone) { }; + /** + * Used by derived classes to serialize a DocType node. + * + * @param name - node name + * @param publicId - public identifier + * @param systemId - system identifier + */ + BaseWriter.prototype.docType = function (name, publicId, systemId) { }; + /** + * Used by derived classes to serialize a comment node. + * + * @param data - node data + */ + BaseWriter.prototype.comment = function (data) { }; + /** + * Used by derived classes to serialize a text node. + * + * @param data - node data + */ + BaseWriter.prototype.text = function (data) { }; + /** + * Used by derived classes to serialize a processing instruction node. + * + * @param target - instruction target + * @param data - node data + */ + BaseWriter.prototype.instruction = function (target, data) { }; + /** + * Used by derived classes to serialize a CData section node. + * + * @param data - node data + */ + BaseWriter.prototype.cdata = function (data) { }; + /** + * Used by derived classes to serialize the beginning of the opening tag of an + * element node. + * + * @param name - node name + */ + BaseWriter.prototype.openTagBegin = function (name) { }; + /** + * Used by derived classes to serialize the ending of the opening tag of an + * element node. + * + * @param name - node name + * @param selfClosing - whether the element node is self closing + * @param voidElement - whether the element node is a HTML void element + */ + BaseWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { }; + /** + * Used by derived classes to serialize the closing tag of an element node. + * + * @param name - node name + */ + BaseWriter.prototype.closeTag = function (name) { }; + /** + * Used by derived classes to serialize attributes or namespace declarations. + * + * @param attributes - attribute array + */ + BaseWriter.prototype.attributes = function (attributes) { + var e_1, _a; + try { + for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) { + var attr = attributes_1_1.value; + this.attribute(attr[1] === null ? attr[2] : attr[1] + ':' + attr[2], attr[3]); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1); + } + finally { if (e_1) throw e_1.error; } + } + }; + /** + * Used by derived classes to serialize an attribute or namespace declaration. + * + * @param name - node name + * @param value - node value + */ + BaseWriter.prototype.attribute = function (name, value) { }; + /** + * Used by derived classes to perform any pre-processing steps before starting + * serializing an element node. + * + * @param name - node name + */ + BaseWriter.prototype.beginElement = function (name) { }; + /** + * Used by derived classes to perform any post-processing steps after + * completing serializing an element node. + * + * @param name - node name + */ + BaseWriter.prototype.endElement = function (name) { }; + /** + * Produces an XML serialization of the given node. The pre-serializer inserts + * namespace declarations where necessary and produces qualified names for + * nodes and attributes. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype.serializeNode = function (node, requireWellFormed, noDoubleEncoding) { + var hasNamespaces = (node._nodeDocument !== undefined && node._nodeDocument._hasNamespaces); + this.level = 0; + this.currentNode = node; + if (hasNamespaces) { + /** From: https://w3c.github.io/DOM-Parsing/#xml-serialization + * + * 1. Let namespace be a context namespace with value null. + * The context namespace tracks the XML serialization algorithm's current + * default namespace. The context namespace is changed when either an Element + * Node has a default namespace declaration, or the algorithm generates a + * default namespace declaration for the Element Node to match its own + * namespace. The algorithm assumes no namespace (null) to start. + * 2. Let prefix map be a new namespace prefix map. + * 3. Add the XML namespace with prefix value "xml" to prefix map. + * 4. Let prefix index be a generated namespace prefix index with value 1. + * The generated namespace prefix index is used to generate a new unique + * prefix value when no suitable existing namespace prefix is available to + * serialize a node's namespaceURI (or the namespaceURI of one of node's + * attributes). See the generate a prefix algorithm. + */ + var namespace = null; + var prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); + prefixMap.set("xml", infra_1.namespace.XML); + var prefixIndex = { value: 1 }; + /** + * 5. Return the result of running the XML serialization algorithm on node + * passing the context namespace namespace, namespace prefix map prefix map, + * generated namespace prefix index reference to prefix index, and the + * flag require well-formed. If an exception occurs during the execution + * of the algorithm, then catch that exception and throw an + * "InvalidStateError" DOMException. + */ + this._serializeNodeNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + } + else { + this._serializeNode(node, requireWellFormed, noDoubleEncoding); + } + }; + /** + * Produces an XML serialization of a node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeNodeNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + this.currentNode = node; + switch (node.nodeType) { + case interfaces_1.NodeType.Element: + this._serializeElementNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Document: + this._serializeDocumentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Comment: + this._serializeComment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Text: + this._serializeText(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentFragment: + this._serializeDocumentFragmentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentType: + this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.ProcessingInstruction: + this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.CData: + this._serializeCData(node, requireWellFormed, noDoubleEncoding); + break; + default: + throw new Error("Unknown node type: " + node.nodeType); + } + }; + /** + * Produces an XML serialization of a node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeNode = function (node, requireWellFormed, noDoubleEncoding) { + this.currentNode = node; + switch (node.nodeType) { + case interfaces_1.NodeType.Element: + this._serializeElement(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Document: + this._serializeDocument(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Comment: + this._serializeComment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Text: + this._serializeText(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentFragment: + this._serializeDocumentFragment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentType: + this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.ProcessingInstruction: + this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.CData: + this._serializeCData(node, requireWellFormed, noDoubleEncoding); + break; + default: + throw new Error("Unknown node type: " + node.nodeType); + } + }; + /** + * Produces an XML serialization of an element node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeElementNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_2, _a; + var attributes = []; + /** + * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node + * + * 1. If the require well-formed flag is set (its value is true), and this + * node's localName attribute contains the character ":" (U+003A COLON) or + * does not match the XML Name production, then throw an exception; the + * serialization of this node would not be a well-formed element. + */ + if (requireWellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + throw new Error("Node local name contains invalid characters (well-formed required)."); + } + /** + * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). + * 3. Let qualified name be an empty string. + * 4. Let skip end tag be a boolean flag with value false. + * 5. Let ignore namespace definition attribute be a boolean flag with value + * false. + * 6. Given prefix map, copy a namespace prefix map and let map be the + * result. + * 7. Let local prefixes map be an empty map. The map has unique Node prefix + * strings as its keys, with corresponding namespaceURI Node values as the + * map's key values (in this map, the null namespace is represented by the + * empty string). + * + * _Note:_ This map is local to each element. It is used to ensure there + * are no conflicting prefixes should a new namespace prefix attribute need + * to be generated. It is also used to enable skipping of duplicate prefix + * definitions when writing an element's attributes: the map allows the + * algorithm to distinguish between a prefix in the namespace prefix map + * that might be locally-defined (to the current Element) and one that is + * not. + * 8. Let local default namespace be the result of recording the namespace + * information for node given map and local prefixes map. + * + * _Note:_ The above step will update map with any found namespace prefix + * definitions, add the found prefix definitions to the local prefixes map + * and return a local default namespace value defined by a default namespace + * attribute if one exists. Otherwise it returns null. + * 9. Let inherited ns be a copy of namespace. + * 10. Let ns be the value of node's namespaceURI attribute. + */ + var qualifiedName = ''; + var skipEndTag = false; + var ignoreNamespaceDefinitionAttribute = false; + var map = prefixMap.copy(); + var localPrefixesMap = {}; + var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); + var inheritedNS = namespace; + var ns = node.namespaceURI; + /** 11. If inherited ns is equal to ns, then: */ + if (inheritedNS === ns) { + /** + * 11.1. If local default namespace is not null, then set ignore + * namespace definition attribute to true. + */ + if (localDefaultNamespace !== null) { + ignoreNamespaceDefinitionAttribute = true; + } + /** + * 11.2. If ns is the XML namespace, then append to qualified name the + * concatenation of the string "xml:" and the value of node's localName. + * 11.3. Otherwise, append to qualified name the value of node's + * localName. The node's prefix if it exists, is dropped. + */ + if (ns === infra_1.namespace.XML) { + qualifiedName = 'xml:' + node.localName; + } + else { + qualifiedName = node.localName; + } + /** 11.4. Append the value of qualified name to markup. */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + } + else { + /** + * 12. Otherwise, inherited ns is not equal to ns (the node's own + * namespace is different from the context namespace of its parent). + * Run these sub-steps: + * + * 12.1. Let prefix be the value of node's prefix attribute. + * 12.2. Let candidate prefix be the result of retrieving a preferred + * prefix string prefix from map given namespace ns. The above may return + * null if no namespace key ns exists in map. + */ + var prefix = node.prefix; + /** + * We don't need to run "retrieving a preferred prefix string" algorithm if + * the element has no prefix and its namespace matches to the default + * namespace. + * See: https://github.com/web-platform-tests/wpt/pull/16703 + */ + var candidatePrefix = null; + if (prefix !== null || ns !== localDefaultNamespace) { + candidatePrefix = map.get(prefix, ns); + } + /** + * 12.3. If the value of prefix matches "xmlns", then run the following + * steps: + */ + if (prefix === "xmlns") { + /** + * 12.3.1. If the require well-formed flag is set, then throw an error. + * An Element with prefix "xmlns" will not legally round-trip in a + * conforming XML parser. + */ + if (requireWellFormed) { + throw new Error("An element cannot have the 'xmlns' prefix (well-formed required)."); + } + /** + * 12.3.2. Let candidate prefix be the value of prefix. + */ + candidatePrefix = prefix; + } + /** + * 12.4.Found a suitable namespace prefix: if candidate prefix is not + * null (a namespace prefix is defined which maps to ns), then: + */ + if (candidatePrefix !== null) { + /** + * The following may serialize a different prefix than the Element's + * existing prefix if it already had one. However, the retrieving a + * preferred prefix string algorithm already tried to match the + * existing prefix if possible. + * + * 12.4.1. Append to qualified name the concatenation of candidate + * prefix, ":" (U+003A COLON), and node's localName. There exists on + * this node or the node's ancestry a namespace prefix definition that + * defines the node's namespace. + * 12.4.2. If the local default namespace is not null (there exists a + * locally-defined default namespace declaration attribute) and its + * value is not the XML namespace, then let inherited ns get the value + * of local default namespace unless the local default namespace is the + * empty string in which case let it get null (the context namespace + * is changed to the declared default, rather than this node's own + * namespace). + * + * _Note:_ Any default namespace definitions or namespace prefixes that + * define the XML namespace are omitted when serializing this node's + * attributes. + */ + qualifiedName = candidatePrefix + ':' + node.localName; + if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { + inheritedNS = localDefaultNamespace || null; + } + /** + * 12.4.3. Append the value of qualified name to markup. + */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** 12.5. Otherwise, if prefix is not null, then: */ + } + else if (prefix !== null) { + /** + * _Note:_ By this step, there is no namespace or prefix mapping + * declaration in this node (or any parent node visited by this + * algorithm) that defines prefix otherwise the step labelled Found + * a suitable namespace prefix would have been followed. The sub-steps + * that follow will create a new namespace prefix declaration for prefix + * and ensure that prefix does not conflict with an existing namespace + * prefix declaration of the same localName in node's attribute list. + * + * 12.5.1. If the local prefixes map contains a key matching prefix, + * then let prefix be the result of generating a prefix providing as + * input map, ns, and prefix index. + */ + if (prefix in localPrefixesMap) { + prefix = this._generatePrefix(ns, map, prefixIndex); + } + /** + * 12.5.2. Add prefix to map given namespace ns. + * 12.5.3. Append to qualified name the concatenation of prefix, ":" + * (U+003A COLON), and node's localName. + * 12.5.4. Append the value of qualified name to markup. + */ + map.set(prefix, ns); + qualifiedName += prefix + ':' + node.localName; + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 12.5.5. Append the following to markup, in the order listed: + * + * _Note:_ The following serializes a namespace prefix declaration for + * prefix which was just added to the map. + * + * 12.5.5.1. " " (U+0020 SPACE); + * 12.5.5.2. The string "xmlns:"; + * 12.5.5.3. The value of prefix; + * 12.5.5.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 12.5.5.5. The result of serializing an attribute value given ns and + * the require well-formed flag as input; + * 12.5.5.6. """ (U+0022 QUOTATION MARK). + */ + attributes.push([null, 'xmlns', prefix, + this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); + /** + * 12.5.5.7. If local default namespace is not null (there exists a + * locally-defined default namespace declaration attribute), then + * let inherited ns get the value of local default namespace unless the + * local default namespace is the empty string in which case let it get + * null. + */ + if (localDefaultNamespace !== null) { + inheritedNS = localDefaultNamespace || null; + } + /** + * 12.6. Otherwise, if local default namespace is null, or local + * default namespace is not null and its value is not equal to ns, then: + */ + } + else if (localDefaultNamespace === null || + (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { + /** + * _Note:_ At this point, the namespace for this node still needs to be + * serialized, but there's no prefix (or candidate prefix) available; the + * following uses the default namespace declaration to define the + * namespace--optionally replacing an existing default declaration + * if present. + * + * 12.6.1. Set the ignore namespace definition attribute flag to true. + * 12.6.2. Append to qualified name the value of node's localName. + * 12.6.3. Let the value of inherited ns be ns. + * + * _Note:_ The new default namespace will be used in the serialization + * to define this node's namespace and act as the context namespace for + * its children. + */ + ignoreNamespaceDefinitionAttribute = true; + qualifiedName += node.localName; + inheritedNS = ns; + /** + * 12.6.4. Append the value of qualified name to markup. + */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 12.6.5. Append the following to markup, in the order listed: + * + * _Note:_ The following serializes the new (or replacement) default + * namespace definition. + * + * 12.6.5.1. " " (U+0020 SPACE); + * 12.6.5.2. The string "xmlns"; + * 12.6.5.3. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 12.6.5.4. The result of serializing an attribute value given ns + * and the require well-formed flag as input; + * 12.6.5.5. """ (U+0022 QUOTATION MARK). + */ + attributes.push([null, null, 'xmlns', + this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); + /** + * 12.7. Otherwise, the node has a local default namespace that matches + * ns. Append to qualified name the value of node's localName, let the + * value of inherited ns be ns, and append the value of qualified name + * to markup. + */ + } + else { + qualifiedName += node.localName; + inheritedNS = ns; + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + } } - } - return true; - }; - - return XMLElement; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 4361: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLNamedNodeMap; - - module.exports = XMLNamedNodeMap = (function() { - function XMLNamedNodeMap(nodes) { - this.nodes = nodes; - } - - Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { - get: function() { - return Object.keys(this.nodes).length || 0; - } - }); - - XMLNamedNodeMap.prototype.clone = function() { - return this.nodes = null; - }; - - XMLNamedNodeMap.prototype.getNamedItem = function(name) { - return this.nodes[name]; - }; - - XMLNamedNodeMap.prototype.setNamedItem = function(node) { - var oldNode; - oldNode = this.nodes[node.nodeName]; - this.nodes[node.nodeName] = node; - return oldNode || null; - }; - - XMLNamedNodeMap.prototype.removeNamedItem = function(name) { - var oldNode; - oldNode = this.nodes[name]; - delete this.nodes[name]; - return oldNode || null; - }; - - XMLNamedNodeMap.prototype.item = function(index) { - return this.nodes[Object.keys(this.nodes)[index]] || null; + /** + * 13. Append to markup the result of the XML serialization of node's + * attributes given map, prefix index, local prefixes map, ignore namespace + * definition attribute flag, and require well-formed flag. + */ + attributes.push.apply(attributes, __spread(this._serializeAttributesNS(node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding))); + this.attributes(attributes); + /** + * 14. If ns is the HTML namespace, and the node's list of children is + * empty, and the node's localName matches any one of the following void + * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", + * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", + * "param", "source", "track", "wbr"; then append the following to markup, + * in the order listed: + * 14.1. " " (U+0020 SPACE); + * 14.2. "/" (U+002F SOLIDUS). + * and set the skip end tag flag to true. + * 15. If ns is not the HTML namespace, and the node's list of children is + * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end + * tag flag to true. + * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. + */ + var isHTML = (ns === infra_1.namespace.HTML); + if (isHTML && node.childNodes.length === 0 && + BaseWriter._VoidElementNames.has(node.localName)) { + this.openTagEnd(qualifiedName, true, true); + this.endElement(qualifiedName); + skipEndTag = true; + } + else if (!isHTML && node.childNodes.length === 0) { + this.openTagEnd(qualifiedName, true, false); + this.endElement(qualifiedName); + skipEndTag = true; + } + else { + this.openTagEnd(qualifiedName, false, false); + } + /** + * 17. If the value of skip end tag is true, then return the value of markup + * and skip the remaining steps. The node is a leaf-node. + */ + if (skipEndTag) + return; + /** + * 18. If ns is the HTML namespace, and the node's localName matches the + * string "template", then this is a template element. Append to markup the + * result of XML serializing a DocumentFragment node given the template + * element's template contents (a DocumentFragment), providing inherited + * ns, map, prefix index, and the require well-formed flag. + * + * _Note:_ This allows template content to round-trip, given the rules for + * parsing XHTML documents. + * + * 19. Otherwise, append to markup the result of running the XML + * serialization algorithm on each of node's children, in tree order, + * providing inherited ns, map, prefix index, and the require well-formed + * flag. + */ + if (isHTML && node.localName === "template") { + // TODO: serialize template contents + } + else { + try { + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this.level++; + this._serializeNodeNS(childNode, inheritedNS, map, prefixIndex, requireWellFormed, noDoubleEncoding); + this.level--; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + } + /** + * 20. Append the following to markup, in the order listed: + * 20.1. "" (U+003E GREATER-THAN SIGN). + * 21. Return the value of markup. + */ + this.closeTag(qualifiedName); + this.endElement(qualifiedName); }; - - XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented."); + /** + * Produces an XML serialization of an element node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeElement = function (node, requireWellFormed, noDoubleEncoding) { + var e_3, _a; + /** + * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node + * + * 1. If the require well-formed flag is set (its value is true), and this + * node's localName attribute contains the character ":" (U+003A COLON) or + * does not match the XML Name production, then throw an exception; the + * serialization of this node would not be a well-formed element. + */ + if (requireWellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + throw new Error("Node local name contains invalid characters (well-formed required)."); + } + /** + * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). + * 3. Let qualified name be an empty string. + * 4. Let skip end tag be a boolean flag with value false. + * 5. Let ignore namespace definition attribute be a boolean flag with value + * false. + * 6. Given prefix map, copy a namespace prefix map and let map be the + * result. + * 7. Let local prefixes map be an empty map. The map has unique Node prefix + * strings as its keys, with corresponding namespaceURI Node values as the + * map's key values (in this map, the null namespace is represented by the + * empty string). + * + * _Note:_ This map is local to each element. It is used to ensure there + * are no conflicting prefixes should a new namespace prefix attribute need + * to be generated. It is also used to enable skipping of duplicate prefix + * definitions when writing an element's attributes: the map allows the + * algorithm to distinguish between a prefix in the namespace prefix map + * that might be locally-defined (to the current Element) and one that is + * not. + * 8. Let local default namespace be the result of recording the namespace + * information for node given map and local prefixes map. + * + * _Note:_ The above step will update map with any found namespace prefix + * definitions, add the found prefix definitions to the local prefixes map + * and return a local default namespace value defined by a default namespace + * attribute if one exists. Otherwise it returns null. + * 9. Let inherited ns be a copy of namespace. + * 10. Let ns be the value of node's namespaceURI attribute. + */ + var skipEndTag = false; + /** 11. If inherited ns is equal to ns, then: */ + /** + * 11.1. If local default namespace is not null, then set ignore + * namespace definition attribute to true. + */ + /** + * 11.2. If ns is the XML namespace, then append to qualified name the + * concatenation of the string "xml:" and the value of node's localName. + * 11.3. Otherwise, append to qualified name the value of node's + * localName. The node's prefix if it exists, is dropped. + */ + var qualifiedName = node.localName; + /** 11.4. Append the value of qualified name to markup. */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 13. Append to markup the result of the XML serialization of node's + * attributes given map, prefix index, local prefixes map, ignore namespace + * definition attribute flag, and require well-formed flag. + */ + var attributes = this._serializeAttributes(node, requireWellFormed, noDoubleEncoding); + this.attributes(attributes); + /** + * 14. If ns is the HTML namespace, and the node's list of children is + * empty, and the node's localName matches any one of the following void + * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", + * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", + * "param", "source", "track", "wbr"; then append the following to markup, + * in the order listed: + * 14.1. " " (U+0020 SPACE); + * 14.2. "/" (U+002F SOLIDUS). + * and set the skip end tag flag to true. + * 15. If ns is not the HTML namespace, and the node's list of children is + * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end + * tag flag to true. + * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. + */ + if (!node.hasChildNodes()) { + this.openTagEnd(qualifiedName, true, false); + this.endElement(qualifiedName); + skipEndTag = true; + } + else { + this.openTagEnd(qualifiedName, false, false); + } + /** + * 17. If the value of skip end tag is true, then return the value of markup + * and skip the remaining steps. The node is a leaf-node. + */ + if (skipEndTag) + return; + try { + /** + * 18. If ns is the HTML namespace, and the node's localName matches the + * string "template", then this is a template element. Append to markup the + * result of XML serializing a DocumentFragment node given the template + * element's template contents (a DocumentFragment), providing inherited + * ns, map, prefix index, and the require well-formed flag. + * + * _Note:_ This allows template content to round-trip, given the rules for + * parsing XHTML documents. + * + * 19. Otherwise, append to markup the result of running the XML + * serialization algorithm on each of node's children, in tree order, + * providing inherited ns, map, prefix index, and the require well-formed + * flag. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this.level++; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + this.level--; + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_3) throw e_3.error; } + } + /** + * 20. Append the following to markup, in the order listed: + * 20.1. "" (U+003E GREATER-THAN SIGN). + * 21. Return the value of markup. + */ + this.closeTag(qualifiedName); + this.endElement(qualifiedName); }; - - XMLNamedNodeMap.prototype.setNamedItemNS = function(node) { - throw new Error("This DOM method is not implemented."); + /** + * Produces an XML serialization of a document node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_4, _a; + /** + * If the require well-formed flag is set (its value is true), and this node + * has no documentElement (the documentElement attribute's value is null), + * then throw an exception; the serialization of this node would not be a + * well-formed document. + */ + if (requireWellFormed && node.documentElement === null) { + throw new Error("Missing document element (well-formed required)."); + } + try { + /** + * Otherwise, run the following steps: + * 1. Let serialized document be an empty string. + * 2. For each child child of node, in tree order, run the XML + * serialization algorithm on the child passing along the provided + * arguments, and append the result to serialized document. + * + * _Note:_ This will serialize any number of ProcessingInstruction and + * Comment nodes both before and after the Document's documentElement node, + * including at most one DocumentType node. (Text nodes are not allowed as + * children of the Document.) + * + * 3. Return the value of serialized document. + */ + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_4) throw e_4.error; } + } }; - - XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented."); + /** + * Produces an XML serialization of a document node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocument = function (node, requireWellFormed, noDoubleEncoding) { + var e_5, _a; + /** + * If the require well-formed flag is set (its value is true), and this node + * has no documentElement (the documentElement attribute's value is null), + * then throw an exception; the serialization of this node would not be a + * well-formed document. + */ + if (requireWellFormed && node.documentElement === null) { + throw new Error("Missing document element (well-formed required)."); + } + try { + /** + * Otherwise, run the following steps: + * 1. Let serialized document be an empty string. + * 2. For each child child of node, in tree order, run the XML + * serialization algorithm on the child passing along the provided + * arguments, and append the result to serialized document. + * + * _Note:_ This will serialize any number of ProcessingInstruction and + * Comment nodes both before and after the Document's documentElement node, + * including at most one DocumentType node. (Text nodes are not allowed as + * children of the Document.) + * + * 3. Return the value of serialized document. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_5) throw e_5.error; } + } }; - - return XMLNamedNodeMap; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 7608: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1, - hasProp = {}.hasOwnProperty; - - ref1 = __nccwpck_require__(8229), 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; - - module.exports = XMLNode = (function() { - function XMLNode(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 = __nccwpck_require__(9437); - XMLCData = __nccwpck_require__(333); - XMLComment = __nccwpck_require__(4407); - XMLDeclaration = __nccwpck_require__(6364); - XMLDocType = __nccwpck_require__(1801); - XMLRaw = __nccwpck_require__(6329); - XMLText = __nccwpck_require__(1318); - XMLProcessingInstruction = __nccwpck_require__(6939); - XMLDummy = __nccwpck_require__(3590); - NodeType = __nccwpck_require__(9267); - XMLNodeList = __nccwpck_require__(6768); - XMLNamedNodeMap = __nccwpck_require__(4361); - DocumentPosition = __nccwpck_require__(2839); - } - } - - Object.defineProperty(XMLNode.prototype, 'nodeName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLNode.prototype, 'nodeType', { - get: function() { - return this.type; - } - }); - - Object.defineProperty(XMLNode.prototype, 'nodeValue', { - get: function() { - return this.value; - } - }); - - Object.defineProperty(XMLNode.prototype, 'parentNode', { - get: function() { - return this.parent; - } - }); - - Object.defineProperty(XMLNode.prototype, 'childNodes', { - get: function() { - if (!this.childNodeList || !this.childNodeList.nodes) { - this.childNodeList = new XMLNodeList(this.children); + /** + * Produces an XML serialization of a comment node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeComment = function (node, requireWellFormed, noDoubleEncoding) { + /** + * If the require well-formed flag is set (its value is true), and node's + * data contains characters that are not matched by the XML Char production + * or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that + * ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception; + * the serialization of this node's data would not be well-formed. + */ + if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || + node.data.indexOf("--") !== -1 || node.data.endsWith("-"))) { + throw new Error("Comment data contains invalid characters (well-formed required)."); } - return this.childNodeList; - } - }); - - Object.defineProperty(XMLNode.prototype, 'firstChild', { - get: function() { - return this.children[0] || null; - } - }); - - Object.defineProperty(XMLNode.prototype, 'lastChild', { - get: function() { - return this.children[this.children.length - 1] || null; - } - }); - - Object.defineProperty(XMLNode.prototype, 'previousSibling', { - get: function() { - var i; - i = this.parent.children.indexOf(this); - return this.parent.children[i - 1] || null; - } - }); - - Object.defineProperty(XMLNode.prototype, 'nextSibling', { - get: function() { - var i; - i = this.parent.children.indexOf(this); - return this.parent.children[i + 1] || null; - } - }); - - Object.defineProperty(XMLNode.prototype, 'ownerDocument', { - get: function() { - return this.document() || null; - } - }); - - Object.defineProperty(XMLNode.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; + /** + * Otherwise, return the concatenation of "". + */ + this.comment(node.data); + }; + /** + * Produces an XML serialization of a text node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + * @param level - current depth of the XML tree + */ + BaseWriter.prototype._serializeText = function (node, requireWellFormed, noDoubleEncoding) { + /** + * 1. If the require well-formed flag is set (its value is true), and + * node's data contains characters that are not matched by the XML Char + * production, then throw an exception; the serialization of this node's + * data would not be well-formed. + */ + if (requireWellFormed && !algorithm_1.xml_isLegalChar(node.data)) { + throw new Error("Text data contains invalid characters (well-formed required)."); + } + /** + * 2. Let markup be the value of node's data. + * 3. Replace any occurrences of "&" in markup by "&". + * 4. Replace any occurrences of "<" in markup by "<". + * 5. Replace any occurrences of ">" in markup by ">". + * 6. Return the value of markup. + */ + var markup = ""; + if (noDoubleEncoding) { + markup = node.data.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') + .replace(//g, '>'); + } + else { + for (var i = 0; i < node.data.length; i++) { + var c = node.data[i]; + if (c === "&") + markup += "&"; + else if (c === "<") + markup += "<"; + else if (c === ">") + markup += ">"; + else + markup += c; } - } - return str; - } else { - return null; } - }, - set: function(value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - XMLNode.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; + this.text(markup); + }; + /** + * Produces an XML serialization of a document fragment node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentFragmentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_6, _a; + try { + /** + * 1. Let markup the empty string. + * 2. For each child child of node, in tree order, run the XML serialization + * algorithm on the child given namespace, prefix map, a reference to prefix + * index, and flag require well-formed. Concatenate the result to markup. + * 3. Return the value of markup. + */ + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + } + } + catch (e_6_1) { e_6 = { error: e_6_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_6) throw e_6.error; } + } + }; + /** + * Produces an XML serialization of a document fragment node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentFragment = function (node, requireWellFormed, noDoubleEncoding) { + var e_7, _a; + try { + /** + * 1. Let markup the empty string. + * 2. For each child child of node, in tree order, run the XML serialization + * algorithm on the child given namespace, prefix map, a reference to prefix + * index, and flag require well-formed. Concatenate the result to markup. + * 3. Return the value of markup. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + } + } + catch (e_7_1) { e_7 = { error: e_7_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_7) throw e_7.error; } + } + }; + /** + * Produces an XML serialization of a document type node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentType = function (node, requireWellFormed, noDoubleEncoding) { + /** + * 1. If the require well-formed flag is true and the node's publicId + * attribute contains characters that are not matched by the XML PubidChar + * production, then throw an exception; the serialization of this node + * would not be a well-formed document type declaration. + */ + if (requireWellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { + throw new Error("DocType public identifier does not match PubidChar construct (well-formed required)."); + } + /** + * 2. If the require well-formed flag is true and the node's systemId + * attribute contains characters that are not matched by the XML Char + * production or that contains both a """ (U+0022 QUOTATION MARK) and a + * "'" (U+0027 APOSTROPHE), then throw an exception; the serialization + * of this node would not be a well-formed document type declaration. + */ + if (requireWellFormed && + (!algorithm_1.xml_isLegalChar(node.systemId) || + (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { + throw new Error("DocType system identifier contains invalid characters (well-formed required)."); + } + /** + * 3. Let markup be an empty string. + * 4. Append the string "" (U+003E GREATER-THAN SIGN) to markup. + * 11. Return the value of markup. + */ + this.docType(node.name, node.publicId, node.systemId); + }; + /** + * Produces an XML serialization of a processing instruction node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeProcessingInstruction = function (node, requireWellFormed, noDoubleEncoding) { + /** + * 1. If the require well-formed flag is set (its value is true), and node's + * target contains a ":" (U+003A COLON) character or is an ASCII + * case-insensitive match for the string "xml", then throw an exception; + * the serialization of this node's target would not be well-formed. + */ + if (requireWellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { + throw new Error("Processing instruction target contains invalid characters (well-formed required)."); + } + /** + * 2. If the require well-formed flag is set (its value is true), and node's + * data contains characters that are not matched by the XML Char production + * or contains the string "?>" (U+003F QUESTION MARK, + * U+003E GREATER-THAN SIGN), then throw an exception; the serialization of + * this node's data would not be well-formed. + */ + if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || + node.data.indexOf("?>") !== -1)) { + throw new Error("Processing instruction data contains invalid characters (well-formed required)."); + } + /** + * 3. Let markup be the concatenation of the following, in the order listed: + * 3.1. "" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN). + * 4. Return the value of markup. + */ + this.instruction(node.target, node.data); }; - - XMLNode.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); + /** + * Produces an XML serialization of a CDATA node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeCData = function (node, requireWellFormed, noDoubleEncoding) { + if (requireWellFormed && (node.data.indexOf("]]>") !== -1)) { + throw new Error("CDATA contains invalid characters (well-formed required)."); } - } 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); + this.cdata(node.data); + }; + /** + * Produces an XML serialization of the attributes of an element node. + * + * @param node - node to serialize + * @param map - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param localPrefixesMap - local prefixes map + * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace + * attributes + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeAttributesNS = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding) { + var e_8, _a; + /** + * 1. Let result be the empty string. + * 2. Let localname set be a new empty namespace localname set. This + * localname set will contain tuples of unique attribute namespaceURI and + * localName pairs, and is populated as each attr is processed. This set is + * used to [optionally] enforce the well-formed constraint that an element + * cannot have two attributes with the same namespaceURI and localName. + * This can occur when two otherwise identical attributes on the same + * element differ only by their prefix values. + */ + var result = []; + var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; + try { + /** + * 3. Loop: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + // Optimize common case + if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + continue; + } + /** + * 3.1. If the require well-formed flag is set (its value is true), and the + * localname set contains a tuple whose values match those of a new tuple + * consisting of attr's namespaceURI attribute and localName attribute, + * then throw an exception; the serialization of this attr would fail to + * produce a well-formed element serialization. + */ + if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { + throw new Error("Element contains duplicate attributes (well-formed required)."); + } + /** + * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and + * localName attribute, and add it to the localname set. + * 3.3. Let attribute namespace be the value of attr's namespaceURI value. + * 3.4. Let candidate prefix be null. + */ + if (requireWellFormed && localNameSet) + localNameSet.set(attr.namespaceURI, attr.localName); + var attributeNamespace = attr.namespaceURI; + var candidatePrefix = null; + /** 3.5. If attribute namespace is not null, then run these sub-steps: */ + if (attributeNamespace !== null) { + /** + * 3.5.1. Let candidate prefix be the result of retrieving a preferred + * prefix string from map given namespace attribute namespace with + * preferred prefix being attr's prefix value. + */ + candidatePrefix = map.get(attr.prefix, attributeNamespace); + /** + * 3.5.2. If the value of attribute namespace is the XMLNS namespace, + * then run these steps: + */ + if (attributeNamespace === infra_1.namespace.XMLNS) { + /** + * 3.5.2.1. If any of the following are true, then stop running these + * steps and goto Loop to visit the next attribute: + * - the attr's value is the XML namespace; + * _Note:_ The XML namespace cannot be redeclared and survive + * round-tripping (unless it defines the prefix "xml"). To avoid this + * problem, this algorithm always prefixes elements in the XML + * namespace with "xml" and drops any related definitions as seen + * in the above condition. + * - the attr's prefix is null and the ignore namespace definition + * attribute flag is true (the Element's default namespace attribute + * should be skipped); + * - the attr's prefix is not null and either + * * the attr's localName is not a key contained in the local + * prefixes map, or + * * the attr's localName is present in the local prefixes map but + * the value of the key does not match attr's value + * and furthermore that the attr's localName (as the prefix to find) + * is found in the namespace prefix map given the namespace consisting + * of the attr's value (the current namespace prefix definition was + * exactly defined previously--on an ancestor element not the current + * element whose attributes are being processed). + */ + if (attr.value === infra_1.namespace.XML || + (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || + (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || + localPrefixesMap[attr.localName] !== attr.value) && + map.has(attr.localName, attr.value))) + continue; + /** + * 3.5.2.2. If the require well-formed flag is set (its value is true), + * and the value of attr's value attribute matches the XMLNS + * namespace, then throw an exception; the serialization of this + * attribute would produce invalid XML because the XMLNS namespace + * is reserved and cannot be applied as an element's namespace via + * XML parsing. + * + * _Note:_ DOM APIs do allow creation of elements in the XMLNS + * namespace but with strict qualifications. + */ + if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { + throw new Error("XMLNS namespace is reserved (well-formed required)."); + } + /** + * 3.5.2.3. If the require well-formed flag is set (its value is true), + * and the value of attr's value attribute is the empty string, then + * throw an exception; namespace prefix declarations cannot be used + * to undeclare a namespace (use a default namespace declaration + * instead). + */ + if (requireWellFormed && attr.value === '') { + throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required)."); + } + /** + * 3.5.2.4. the attr's prefix matches the string "xmlns", then let + * candidate prefix be the string "xmlns". + */ + if (attr.prefix === 'xmlns') + candidatePrefix = 'xmlns'; + /** + * 3.5.3. Otherwise, the attribute namespace is not the XMLNS namespace. + * Run these steps: + * + * _Note:_ The (candidatePrefix === null) check is not in the spec. + * We deviate from the spec here. Otherwise a prefix is generated for + * all attributes with namespaces. + */ + } + else if (candidatePrefix === null) { + if (attr.prefix !== null && + (!map.hasPrefix(attr.prefix) || + map.has(attr.prefix, attributeNamespace))) { + /** + * Check if we can use the attribute's own prefix. + * We deviate from the spec here. + * TODO: This is not an efficient way of searching for prefixes. + * Follow developments to the spec. + */ + candidatePrefix = attr.prefix; + } + else { + /** + * 3.5.3.1. Let candidate prefix be the result of generating a prefix + * providing map, attribute namespace, and prefix index as input. + */ + candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); + } + /** + * 3.5.3.2. Append the following to result, in the order listed: + * 3.5.3.2.1. " " (U+0020 SPACE); + * 3.5.3.2.2. The string "xmlns:"; + * 3.5.3.2.3. The value of candidate prefix; + * 3.5.3.2.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.5.3.2.5. The result of serializing an attribute value given + * attribute namespace and the require well-formed flag as input; + * 3.5.3.2.6. """ (U+0022 QUOTATION MARK). + */ + result.push([null, "xmlns", candidatePrefix, + this._serializeAttributeValue(attributeNamespace, requireWellFormed, noDoubleEncoding)]); + } + } + /** + * 3.6. Append a " " (U+0020 SPACE) to result. + * 3.7. If candidate prefix is not null, then append to result the + * concatenation of candidate prefix with ":" (U+003A COLON). + */ + var attrName = ''; + if (candidatePrefix !== null) { + attrName = candidatePrefix; + } + /** + * 3.8. If the require well-formed flag is set (its value is true), and + * this attr's localName attribute contains the character + * ":" (U+003A COLON) or does not match the XML Name production or + * equals "xmlns" and attribute namespace is null, then throw an + * exception; the serialization of this attr would not be a + * well-formed attribute. + */ + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName) || + (attr.localName === "xmlns" && attributeNamespace === null))) { + throw new Error("Attribute local name contains invalid characters (well-formed required)."); + } + /** + * 3.9. Append the following strings to result, in the order listed: + * 3.9.1. The value of attr's localName; + * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.9.3. The result of serializing an attribute value given attr's value + * attribute and the require well-formed flag as input; + * 3.9.4. """ (U+0022 QUOTATION MARK). + */ + result.push([attributeNamespace, candidatePrefix, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); } - } 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; - }; - - XMLNode.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)); + catch (e_8_1) { e_8 = { error: e_8_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_8) throw e_8.error; } } - 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; - } - }; - - XMLNode.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; - }; - - XMLNode.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; - }; - - XMLNode.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; - }; - - XMLNode.prototype.text = function(value) { - var child; - if (isObject(value)) { - this.element(value); - } - child = new XMLText(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.cdata = function(value) { - var child; - child = new XMLCData(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.comment = function(value) { - var child; - child = new XMLComment(this, value); - this.children.push(child); - return this; - }; - - XMLNode.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; - }; - - XMLNode.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; - }; - - XMLNode.prototype.raw = function(value) { - var child; - child = new XMLRaw(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.dummy = function() { - var child; - child = new XMLDummy(this); - return child; + /** + * 4. Return the value of result. + */ + return result; }; - - XMLNode.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); + /** + * Produces an XML serialization of the attributes of an element node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeAttributes = function (node, requireWellFormed, noDoubleEncoding) { + var e_9, _a; + /** + * 1. Let result be the empty string. + * 2. Let localname set be a new empty namespace localname set. This + * localname set will contain tuples of unique attribute namespaceURI and + * localName pairs, and is populated as each attr is processed. This set is + * used to [optionally] enforce the well-formed constraint that an element + * cannot have two attributes with the same namespaceURI and localName. + * This can occur when two otherwise identical attributes on the same + * element differ only by their prefix values. + */ + var result = []; + var localNameSet = requireWellFormed ? {} : undefined; + try { + /** + * 3. Loop: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + // Optimize common case + if (!requireWellFormed) { + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + continue; + } + /** + * 3.1. If the require well-formed flag is set (its value is true), and the + * localname set contains a tuple whose values match those of a new tuple + * consisting of attr's namespaceURI attribute and localName attribute, + * then throw an exception; the serialization of this attr would fail to + * produce a well-formed element serialization. + */ + if (requireWellFormed && localNameSet && (attr.localName in localNameSet)) { + throw new Error("Element contains duplicate attributes (well-formed required)."); + } + /** + * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and + * localName attribute, and add it to the localname set. + * 3.3. Let attribute namespace be the value of attr's namespaceURI value. + * 3.4. Let candidate prefix be null. + */ + /* istanbul ignore else */ + if (requireWellFormed && localNameSet) + localNameSet[attr.localName] = true; + /** 3.5. If attribute namespace is not null, then run these sub-steps: */ + /** + * 3.6. Append a " " (U+0020 SPACE) to result. + * 3.7. If candidate prefix is not null, then append to result the + * concatenation of candidate prefix with ":" (U+003A COLON). + */ + /** + * 3.8. If the require well-formed flag is set (its value is true), and + * this attr's localName attribute contains the character + * ":" (U+003A COLON) or does not match the XML Name production or + * equals "xmlns" and attribute namespace is null, then throw an + * exception; the serialization of this attr would not be a + * well-formed attribute. + */ + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName))) { + throw new Error("Attribute local name contains invalid characters (well-formed required)."); + } + /** + * 3.9. Append the following strings to result, in the order listed: + * 3.9.1. The value of attr's localName; + * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.9.3. The result of serializing an attribute value given attr's value + * attribute and the require well-formed flag as input; + * 3.9.4. """ (U+0022 QUOTATION MARK). + */ + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + } } - } else { - if (isFunction(value)) { - value = value.apply(); + catch (e_9_1) { e_9 = { error: e_9_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_9) throw e_9.error; } } - instruction = new XMLProcessingInstruction(this, target, value); - this.children.push(instruction); - } - return this; - }; - - XMLNode.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; + /** + * 4. Return the value of result. + */ + return result; }; - - XMLNode.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; + /** + * Records namespace information for the given element and returns the + * default namespace attribute value. + * + * @param node - element node to process + * @param map - namespace prefix map + * @param localPrefixesMap - local prefixes map + */ + BaseWriter.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { + var e_10, _a; + /** + * 1. Let default namespace attr value be null. + */ + var defaultNamespaceAttrValue = null; + try { + /** + * 2. Main: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + /** + * _Note:_ The following conditional steps find namespace prefixes. Only + * attributes in the XMLNS namespace are considered (e.g., attributes made + * to look like namespace declarations via + * setAttribute("xmlns:pretend-prefix", "pretend-namespace") are not + * included). + */ + /** 2.1. Let attribute namespace be the value of attr's namespaceURI value. */ + var attributeNamespace = attr.namespaceURI; + /** 2.2. Let attribute prefix be the value of attr's prefix. */ + var attributePrefix = attr.prefix; + /** 2.3. If the attribute namespace is the XMLNS namespace, then: */ + if (attributeNamespace === infra_1.namespace.XMLNS) { + /** + * 2.3.1. If attribute prefix is null, then attr is a default namespace + * declaration. Set the default namespace attr value to attr's value and + * stop running these steps, returning to Main to visit the next + * attribute. + */ + if (attributePrefix === null) { + defaultNamespaceAttrValue = attr.value; + continue; + /** + * 2.3.2. Otherwise, the attribute prefix is not null and attr is a + * namespace prefix definition. Run the following steps: + */ + } + else { + /** 2.3.2.1. Let prefix definition be the value of attr's localName. */ + var prefixDefinition = attr.localName; + /** 2.3.2.2. Let namespace definition be the value of attr's value. */ + var namespaceDefinition = attr.value; + /** + * 2.3.2.3. If namespace definition is the XML namespace, then stop + * running these steps, and return to Main to visit the next + * attribute. + * + * _Note:_ XML namespace definitions in prefixes are completely + * ignored (in order to avoid unnecessary work when there might be + * prefix conflicts). XML namespaced elements are always handled + * uniformly by prefixing (and overriding if necessary) the element's + * localname with the reserved "xml" prefix. + */ + if (namespaceDefinition === infra_1.namespace.XML) { + continue; + } + /** + * 2.3.2.4. If namespace definition is the empty string (the + * declarative form of having no namespace), then let namespace + * definition be null instead. + */ + if (namespaceDefinition === '') { + namespaceDefinition = null; + } + /** + * 2.3.2.5. If prefix definition is found in map given the namespace + * namespace definition, then stop running these steps, and return to + * Main to visit the next attribute. + * + * _Note:_ This step avoids adding duplicate prefix definitions for + * the same namespace in the map. This has the side-effect of avoiding + * later serialization of duplicate namespace prefix declarations in + * any descendant nodes. + */ + if (map.has(prefixDefinition, namespaceDefinition)) { + continue; + } + /** + * 2.3.2.6. Add the prefix prefix definition to map given namespace + * namespace definition. + */ + map.set(prefixDefinition, namespaceDefinition); + /** + * 2.3.2.7. Add the value of prefix definition as a new key to the + * local prefixes map, with the namespace definition as the key's + * value replacing the value of null with the empty string if + * applicable. + */ + localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; + } + } + } + } + catch (e_10_1) { e_10 = { error: e_10_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_10) throw e_10.error; } + } + /** + * 3. Return the value of default namespace attr value. + * + * _Note:_ The empty string is a legitimate return value and is not + * converted to null. + */ + return defaultNamespaceAttrValue; }; - - XMLNode.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; + /** + * Generates a new prefix for the given namespace. + * + * @param newNamespace - a namespace to generate prefix for + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + */ + BaseWriter.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { + /** + * 1. Let generated prefix be the concatenation of the string "ns" and the + * current numerical value of prefix index. + * 2. Let the value of prefix index be incremented by one. + * 3. Add to map the generated prefix given the new namespace namespace. + * 4. Return the value of generated prefix. + */ + var generatedPrefix = "ns" + prefixIndex.value.toString(); + prefixIndex.value++; + prefixMap.set(generatedPrefix, newNamespace); + return generatedPrefix; }; - - XMLNode.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; + /** + * Produces an XML serialization of an attribute value. + * + * @param value - attribute value + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeAttributeValue = function (value, requireWellFormed, noDoubleEncoding) { + /** + * From: https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value + * + * 1. If the require well-formed flag is set (its value is true), and + * attribute value contains characters that are not matched by the XML Char + * production, then throw an exception; the serialization of this attribute + * value would fail to produce a well-formed element serialization. + */ + if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { + throw new Error("Invalid characters in attribute value."); } - } - 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; + /** + * 2. If attribute value is null, then return the empty string. + */ + if (value === null) + return ""; + /** + * 3. Otherwise, attribute value is a string. Return the value of attribute + * value, first replacing any occurrences of the following: + * - "&" with "&" + * - """ with """ + * - "<" with "<" + * - ">" with ">" + * NOTE + * This matches behavior present in browsers, and goes above and beyond the + * grammar requirement in the XML specification's AttValue production by + * also replacing ">" characters. + */ + if (noDoubleEncoding) { + return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); } - } - doc.children.push(doctype); - return doctype; - }; - - XMLNode.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; - }; - - XMLNode.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; + else { + var result = ""; + for (var i = 0; i < value.length; i++) { + var c = value[i]; + if (c === "\"") + result += """; + else if (c === "&") + result += "&"; + else if (c === "<") + result += "<"; + else if (c === ">") + result += ">"; + else + result += c; + } + return result; } - } }; + BaseWriter._VoidElementNames = new Set(['area', 'base', 'basefont', + 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', + 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); + return BaseWriter; +}()); +exports.BaseWriter = BaseWriter; +//# sourceMappingURL=BaseWriter.js.map - XMLNode.prototype.document = function() { - var node; - node = this; - while (node) { - if (node.type === NodeType.Document) { - return node; - } else { - node = node.parent; - } - } - }; +/***/ }), - XMLNode.prototype.end = function(options) { - return this.document().end(options); - }; +/***/ 7525: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLNode.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]; - }; +"use strict"; - XMLNode.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]; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLNode.prototype.importDocument = function(doc) { - var clonedRoot; - clonedRoot = doc.root().clone(); - clonedRoot.parent = this; - clonedRoot.isRoot = false; - this.children.push(clonedRoot); - return this; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLNode.prototype.debugInfo = function(name) { - var ref2, ref3; - name = name || this.name; - if ((name == null) && !((ref2 = this.parent) != null ? ref2.name : void 0)) { +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var BaseCBWriter_1 = __nccwpck_require__(708); +/** + * Serializes XML nodes. + */ +var JSONCBWriter = /** @class */ (function (_super) { + __extends(JSONCBWriter, _super); + /** + * Initializes a new instance of `JSONCBWriter`. + * + * @param builderOptions - XML builder options + */ + function JSONCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._hasChildren = []; + _this._additionalLevel = 0; + return _this; + } + /** @inheritdoc */ + JSONCBWriter.prototype.frontMatter = function () { 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 + ">"; - } - }; - - XMLNode.prototype.ele = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLNode.prototype.nod = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLNode.prototype.txt = function(value) { - return this.text(value); - }; - - XMLNode.prototype.dat = function(value) { - return this.cdata(value); - }; - - XMLNode.prototype.com = function(value) { - return this.comment(value); - }; - - XMLNode.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; - - XMLNode.prototype.doc = function() { - return this.document(); }; - - XMLNode.prototype.dec = function(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); + /** @inheritdoc */ + JSONCBWriter.prototype.declaration = function (version, encoding, standalone) { + return ""; }; - - XMLNode.prototype.e = function(name, attributes, text) { - return this.element(name, attributes, text); + /** @inheritdoc */ + JSONCBWriter.prototype.docType = function (name, publicId, systemId) { + return ""; }; - - XMLNode.prototype.n = function(name, attributes, text) { - return this.node(name, attributes, text); + /** @inheritdoc */ + JSONCBWriter.prototype.comment = function (data) { + // { "!": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.comment) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - XMLNode.prototype.t = function(value) { - return this.text(value); + /** @inheritdoc */ + JSONCBWriter.prototype.text = function (data) { + // { "#": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.text) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - XMLNode.prototype.d = function(value) { - return this.cdata(value); + /** @inheritdoc */ + JSONCBWriter.prototype.instruction = function (target, data) { + // { "?": "target hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.ins) + this._sep() + + this._val(data ? target + " " + data : target) + this._sep() + "}"; }; - - XMLNode.prototype.c = function(value) { - return this.comment(value); + /** @inheritdoc */ + JSONCBWriter.prototype.cdata = function (data) { + // { "$": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.cdata) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - XMLNode.prototype.r = function(value) { - return this.raw(value); + /** @inheritdoc */ + JSONCBWriter.prototype.attribute = function (name, value) { + // { "@name": "val" } + return this._comma() + this._beginLine(1) + "{" + this._sep() + + this._key(this._builderOptions.convert.att + name) + this._sep() + + this._val(value) + this._sep() + "}"; }; - - XMLNode.prototype.i = function(target, value) { - return this.instruction(target, value); + /** @inheritdoc */ + JSONCBWriter.prototype.openTagBegin = function (name) { + // { "node": { "#": [ + var str = this._comma() + this._beginLine() + "{" + this._sep() + this._key(name) + this._sep() + "{"; + this._additionalLevel++; + this.hasData = true; + str += this._beginLine() + this._key(this._builderOptions.convert.text) + this._sep() + "["; + this._hasChildren.push(false); + return str; }; - - XMLNode.prototype.u = function() { - return this.up(); + /** @inheritdoc */ + JSONCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (selfClosing) { + var str = this._sep() + "]"; + this._additionalLevel--; + str += this._beginLine() + "}" + this._sep() + "}"; + return str; + } + else { + return ""; + } }; - - XMLNode.prototype.importXMLBuilder = function(doc) { - return this.importDocument(doc); + /** @inheritdoc */ + JSONCBWriter.prototype.closeTag = function (name) { + // ] } } + var str = this._beginLine() + "]"; + this._additionalLevel--; + str += this._beginLine() + "}" + this._sep() + "}"; + return str; }; - - XMLNode.prototype.replaceChild = function(newChild, oldChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + JSONCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + JSONCBWriter.prototype.endElement = function (name) { this._hasChildren.pop(); }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + JSONCBWriter.prototype._beginLine = function (additionalOffset) { + if (additionalOffset === void 0) { additionalOffset = 0; } + if (this._writerOptions.prettyPrint) { + return (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level + additionalOffset); + } + else { + return ""; + } }; - - XMLNode.prototype.removeChild = function(oldChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + JSONCBWriter.prototype._indent = function (level) { + if (level + this._additionalLevel <= 0) { + return ""; + } + else { + return this._writerOptions.indent.repeat(level + this._additionalLevel); + } }; - - XMLNode.prototype.appendChild = function(newChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Produces a comma before a child node if it has previous siblings. + */ + JSONCBWriter.prototype._comma = function () { + var str = (this._hasChildren[this._hasChildren.length - 1] ? "," : ""); + if (this._hasChildren.length > 0) { + this._hasChildren[this._hasChildren.length - 1] = true; + } + return str; }; - - XMLNode.prototype.hasChildNodes = function() { - return this.children.length !== 0; + /** + * Produces a separator string. + */ + JSONCBWriter.prototype._sep = function () { + return (this._writerOptions.prettyPrint ? " " : ""); }; - - XMLNode.prototype.cloneNode = function(deep) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Produces a JSON key string delimited with double quotes. + */ + JSONCBWriter.prototype._key = function (key) { + return "\"" + key + "\":"; }; - - XMLNode.prototype.normalize = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * Produces a JSON value string delimited with double quotes. + */ + JSONCBWriter.prototype._val = function (val) { + return JSON.stringify(val); }; + return JSONCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.JSONCBWriter = JSONCBWriter; +//# sourceMappingURL=JSONCBWriter.js.map - XMLNode.prototype.isSupported = function(feature, version) { - return true; - }; +/***/ }), - XMLNode.prototype.hasAttributes = function() { - return this.attribs.length !== 0; - }; +/***/ 7510: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLNode.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; - } - }; +"use strict"; - XMLNode.prototype.isSameNode = function(other) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLNode.prototype.lookupPrefix = function(namespaceURI) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLNode.prototype.isDefaultNamespace = function(namespaceURI) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } }; - - XMLNode.prototype.lookupNamespaceURI = function(prefix) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectWriter_1 = __nccwpck_require__(243); +var util_1 = __nccwpck_require__(6195); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into a JSON string. + */ +var JSONWriter = /** @class */ (function (_super) { + __extends(JSONWriter, _super); + /** + * Initializes a new instance of `JSONWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function JSONWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + prettyPrint: false, + indent: ' ', + newline: '\n', + offset: 0, + group: false, + verbose: false + }); + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + * @param writerOptions - serialization options + */ + JSONWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + // recursively convert object into JSON string + return this._beginLine(this._writerOptions, 0) + this._convertObject(val, this._writerOptions); }; - - XMLNode.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; + /** + * Produces an XML serialization of the given object. + * + * @param obj - object to serialize + * @param options - serialization options + * @param level - depth of the XML tree + */ + JSONWriter.prototype._convertObject = function (obj, options, level) { + var e_1, _a; + var _this = this; + if (level === void 0) { level = 0; } + var markup = ''; + var isLeaf = this._isLeafNode(obj); + if (util_1.isArray(obj)) { + markup += '['; + var len = obj.length; + var i = 0; + try { + for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { + var val = obj_1_1.value; + markup += this._endLine(options, level + 1) + + this._beginLine(options, level + 1) + + this._convertObject(val, options, level + 1); + if (i < len - 1) { + markup += ','; + } + i++; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); + } + finally { if (e_1) throw e_1.error; } + } + markup += this._endLine(options, level) + this._beginLine(options, level); + markup += ']'; + } + else if (util_1.isObject(obj)) { + markup += '{'; + var len_1 = util_1.objectLength(obj); + var i_1 = 0; + util_1.forEachObject(obj, function (key, val) { + if (isLeaf && options.prettyPrint) { + markup += ' '; + } + else { + markup += _this._endLine(options, level + 1) + _this._beginLine(options, level + 1); + } + markup += _this._key(key); + if (options.prettyPrint) { + markup += ' '; + } + markup += _this._convertObject(val, options, level + 1); + if (i_1 < len_1 - 1) { + markup += ','; + } + i_1++; + }, this); + if (isLeaf && options.prettyPrint) { + markup += ' '; + } + else { + markup += this._endLine(options, level) + this._beginLine(options, level); + } + markup += '}'; } - } - return true; - }; - - XMLNode.prototype.getFeature = function(feature, version) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.setUserData = function(key, data, handler) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.getUserData = function(key) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.contains = function(other) { - if (!other) { - return false; - } - return other === this || this.isDescendant(other); + else { + markup += this._val(obj); + } + return markup; }; - - XMLNode.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; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + * @param level - current depth of the XML tree + */ + JSONWriter.prototype._beginLine = function (options, level) { + if (!options.prettyPrint) { + return ''; } - isDescendantChild = child.isDescendant(node); - if (isDescendantChild) { - return true; + else { + var indentLevel = options.offset + level + 1; + if (indentLevel > 0) { + return new Array(indentLevel).join(options.indent); + } } - } - return false; - }; - - XMLNode.prototype.isAncestor = function(node) { - return node.isDescendant(this); - }; - - XMLNode.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; - } - }; - - XMLNode.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; - } + return ''; }; - - XMLNode.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; + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + * @param level - current depth of the XML tree + */ + JSONWriter.prototype._endLine = function (options, level) { + if (!options.prettyPrint) { + return ''; } - }); - if (found) { - return pos; - } else { - return -1; - } - }; - - XMLNode.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; - } + else { + return options.newline; } - } - }; - - return XMLNode; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 6768: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLNodeList; - - module.exports = XMLNodeList = (function() { - function XMLNodeList(nodes) { - this.nodes = nodes; - } - - Object.defineProperty(XMLNodeList.prototype, 'length', { - get: function() { - return this.nodes.length || 0; - } - }); - - XMLNodeList.prototype.clone = function() { - return this.nodes = null; }; - - XMLNodeList.prototype.item = function(index) { - return this.nodes[index] || null; + /** + * Produces a JSON key string delimited with double quotes. + */ + JSONWriter.prototype._key = function (key) { + return "\"" + key + "\":"; }; - - return XMLNodeList; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 6939: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLProcessingInstruction = (function(superClass) { - extend(XMLProcessingInstruction, superClass); - - function XMLProcessingInstruction(parent, target, value) { - XMLProcessingInstruction.__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); - } - } - - XMLProcessingInstruction.prototype.clone = function() { - return Object.create(this); + /** + * Produces a JSON value string delimited with double quotes. + */ + JSONWriter.prototype._val = function (val) { + return JSON.stringify(val); }; - - XMLProcessingInstruction.prototype.toString = function(options) { - return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options)); + /** + * Determines if an object is a leaf node. + * + * @param obj + */ + JSONWriter.prototype._isLeafNode = function (obj) { + return this._descendantCount(obj) <= 1; }; - - XMLProcessingInstruction.prototype.isEqualNode = function(node) { - if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { - return false; - } - if (node.target !== this.target) { - return false; - } - return true; + /** + * Counts the number of descendants of the given object. + * + * @param obj + * @param count + */ + JSONWriter.prototype._descendantCount = function (obj, count) { + var _this = this; + if (count === void 0) { count = 0; } + if (util_1.isArray(obj)) { + util_1.forEachArray(obj, function (val) { return count += _this._descendantCount(val, count); }, this); + } + else if (util_1.isObject(obj)) { + util_1.forEachObject(obj, function (key, val) { return count += _this._descendantCount(val, count); }, this); + } + else { + count++; + } + return count; }; - - return XMLProcessingInstruction; - - })(XMLCharacterData); - -}).call(this); - + return JSONWriter; +}(BaseWriter_1.BaseWriter)); +exports.JSONWriter = JSONWriter; +//# sourceMappingURL=JSONWriter.js.map /***/ }), -/***/ 6329: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLNode = __nccwpck_require__(7608); +/***/ 1397: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports = XMLRaw = (function(superClass) { - extend(XMLRaw, superClass); +"use strict"; - function XMLRaw(parent, text) { - XMLRaw.__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); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var ObjectWriter_1 = __nccwpck_require__(243); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into ES6 maps and arrays. + */ +var MapWriter = /** @class */ (function (_super) { + __extends(MapWriter, _super); + /** + * Initializes a new instance of `MapWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function MapWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + format: "map", + wellFormed: false, + noDoubleEncoding: false, + group: false, + verbose: false + }); + return _this; } - - XMLRaw.prototype.clone = function() { - return Object.create(this); + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + */ + MapWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + verbose: false + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + // recursively convert object into Map + return this._convertObject(val); }; - - XMLRaw.prototype.toString = function(options) { - return this.options.writer.raw(this, this.options.writer.filterOptions(options)); + /** + * Recursively converts a JS object into an ES5 map. + * + * @param obj - a JS object + */ + MapWriter.prototype._convertObject = function (obj) { + if (util_1.isArray(obj)) { + for (var i = 0; i < obj.length; i++) { + obj[i] = this._convertObject(obj[i]); + } + return obj; + } + else if (util_1.isObject(obj)) { + var map = new Map(); + for (var key in obj) { + map.set(key, this._convertObject(obj[key])); + } + return map; + } + else { + return obj; + } }; - - return XMLRaw; - - })(XMLNode); - -}).call(this); - + return MapWriter; +}(BaseWriter_1.BaseWriter)); +exports.MapWriter = MapWriter; +//# sourceMappingURL=MapWriter.js.map /***/ }), -/***/ 8601: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLWriterBase = __nccwpck_require__(6752); - - WriterState = __nccwpck_require__(9766); +/***/ 243: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports = XMLStreamWriter = (function(superClass) { - extend(XMLStreamWriter, superClass); +"use strict"; - function XMLStreamWriter(stream, options) { - this.stream = stream; - XMLStreamWriter.__super__.constructor.call(this, options); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var interfaces_1 = __nccwpck_require__(7305); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into objects and arrays. + */ +var ObjectWriter = /** @class */ (function (_super) { + __extends(ObjectWriter, _super); + /** + * Initializes a new instance of `ObjectWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function ObjectWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._writerOptions = util_1.applyDefaults(writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + group: false, + verbose: false + }); + return _this; } - - XMLStreamWriter.prototype.endline = function(node, options, level) { - if (node.isLastRootNode && options.state === WriterState.CloseTag) { - return ''; - } else { - return XMLStreamWriter.__super__.endline.call(this, node, options, level); - } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + */ + ObjectWriter.prototype.serialize = function (node) { + this._currentList = []; + this._currentIndex = 0; + this._listRegister = [this._currentList]; + /** + * First pass, serialize nodes + * This creates a list of nodes grouped under node types while preserving + * insertion order. For example: + * [ + * root: [ + * node: [ + * { "@" : { "att1": "val1", "att2": "val2" } + * { "#": "node text" } + * { childNode: [] } + * { "#": "more text" } + * ], + * node: [ + * { "@" : { "att": "val" } + * { "#": [ "text line1", "text line2" ] } + * ] + * ] + * ] + */ + this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); + /** + * Second pass, process node lists. Above example becomes: + * { + * root: { + * node: [ + * { + * "@att1": "val1", + * "@att2": "val2", + * "#1": "node text", + * childNode: {}, + * "#2": "more text" + * }, + * { + * "@att": "val", + * "#": [ "text line1", "text line2" ] + * } + * ] + * } + * } + */ + return this._process(this._currentList, this._writerOptions); }; - - XMLStreamWriter.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; + ObjectWriter.prototype._process = function (items, options) { + var _a, _b, _c, _d, _e, _f, _g; + if (items.length === 0) + return {}; + // determine if there are non-unique element names + var namesSeen = {}; + var hasNonUniqueNames = false; + var textCount = 0; + var commentCount = 0; + var instructionCount = 0; + var cdataCount = 0; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + continue; + case "#": + textCount++; + break; + case "!": + commentCount++; + break; + case "?": + instructionCount++; + break; + case "$": + cdataCount++; + break; + default: + if (namesSeen[key]) { + hasNonUniqueNames = true; + } + else { + namesSeen[key] = true; + } + break; + } + } + var defAttrKey = this._getAttrKey(); + var defTextKey = this._getNodeKey(interfaces_1.NodeType.Text); + var defCommentKey = this._getNodeKey(interfaces_1.NodeType.Comment); + var defInstructionKey = this._getNodeKey(interfaces_1.NodeType.ProcessingInstruction); + var defCdataKey = this._getNodeKey(interfaces_1.NodeType.CData); + if (textCount === 1 && items.length === 1 && util_1.isString(items[0]["#"])) { + // special case of an element node with a single text node + return items[0]["#"]; + } + else if (hasNonUniqueNames) { + var obj = {}; + // process attributes first + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + if (key === "@") { + var attrs = item["@"]; + var attrKeys = Object.keys(attrs); + if (attrKeys.length === 1) { + obj[defAttrKey + attrKeys[0]] = attrs[attrKeys[0]]; + } + else { + obj[defAttrKey] = item["@"]; + } + } + } + // list contains element nodes with non-unique names + // return an array with mixed content notation + var result = []; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + // attributes were processed above + break; + case "#": + result.push((_a = {}, _a[defTextKey] = item["#"], _a)); + break; + case "!": + result.push((_b = {}, _b[defCommentKey] = item["!"], _b)); + break; + case "?": + result.push((_c = {}, _c[defInstructionKey] = item["?"], _c)); + break; + case "$": + result.push((_d = {}, _d[defCdataKey] = item["$"], _d)); + break; + default: + // element node + var ele = item; + if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { + // group of element nodes + var eleGroup = []; + var listOfLists = ele[key]; + for (var i_1 = 0; i_1 < listOfLists.length; i_1++) { + eleGroup.push(this._process(listOfLists[i_1], options)); + } + result.push((_e = {}, _e[key] = eleGroup, _e)); + } + else { + // single element node + if (options.verbose) { + result.push((_f = {}, _f[key] = [this._process(ele[key], options)], _f)); + } + else { + result.push((_g = {}, _g[key] = this._process(ele[key], options), _g)); + } + } + break; + } + } + obj[defTextKey] = result; + return obj; + } + else { + // all element nodes have unique names + // return an object while prefixing data node keys + var textId = 1; + var commentId = 1; + var instructionId = 1; + var cdataId = 1; + var obj = {}; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + var attrs = item["@"]; + var attrKeys = Object.keys(attrs); + if (!options.group || attrKeys.length === 1) { + for (var attrName in attrs) { + obj[defAttrKey + attrName] = attrs[attrName]; + } + } + else { + obj[defAttrKey] = attrs; + } + break; + case "#": + textId = this._processSpecItem(item["#"], obj, options.group, defTextKey, textCount, textId); + break; + case "!": + commentId = this._processSpecItem(item["!"], obj, options.group, defCommentKey, commentCount, commentId); + break; + case "?": + instructionId = this._processSpecItem(item["?"], obj, options.group, defInstructionKey, instructionCount, instructionId); + break; + case "$": + cdataId = this._processSpecItem(item["$"], obj, options.group, defCdataKey, cdataCount, cdataId); + break; + default: + // element node + var ele = item; + if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { + // group of element nodes + var eleGroup = []; + var listOfLists = ele[key]; + for (var i_2 = 0; i_2 < listOfLists.length; i_2++) { + eleGroup.push(this._process(listOfLists[i_2], options)); + } + obj[key] = eleGroup; + } + else { + // single element node + if (options.verbose) { + obj[key] = [this._process(ele[key], options)]; + } + else { + obj[key] = this._process(ele[key], options); + } + } + break; + } + } + return obj; + } }; - - XMLStreamWriter.prototype.attribute = function(att, options, level) { - return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level)); + ObjectWriter.prototype._processSpecItem = function (item, obj, group, defKey, count, id) { + var e_1, _a; + if (!group && util_1.isArray(item) && count + item.length > 2) { + try { + for (var item_1 = __values(item), item_1_1 = item_1.next(); !item_1_1.done; item_1_1 = item_1.next()) { + var subItem = item_1_1.value; + var key = defKey + (id++).toString(); + obj[key] = subItem; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); + } + finally { if (e_1) throw e_1.error; } + } + } + else { + var key = count > 1 ? defKey + (id++).toString() : defKey; + obj[key] = item; + } + return id; }; - - XMLStreamWriter.prototype.cdata = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level)); + /** @inheritdoc */ + ObjectWriter.prototype.beginElement = function (name) { + var _a, _b; + var childItems = []; + if (this._currentList.length === 0) { + this._currentList.push((_a = {}, _a[name] = childItems, _a)); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isElementNode(lastItem, name)) { + if (lastItem[name].length !== 0 && util_1.isArray(lastItem[name][0])) { + var listOfLists = lastItem[name]; + listOfLists.push(childItems); + } + else { + lastItem[name] = [lastItem[name], childItems]; + } + } + else { + this._currentList.push((_b = {}, _b[name] = childItems, _b)); + } + } + this._currentIndex++; + if (this._listRegister.length > this._currentIndex) { + this._listRegister[this._currentIndex] = childItems; + } + else { + this._listRegister.push(childItems); + } + this._currentList = childItems; }; - - XMLStreamWriter.prototype.comment = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level)); + /** @inheritdoc */ + ObjectWriter.prototype.endElement = function () { + this._currentList = this._listRegister[--this._currentIndex]; }; - - XMLStreamWriter.prototype.declaration = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level)); + /** @inheritdoc */ + ObjectWriter.prototype.attribute = function (name, value) { + var _a, _b; + if (this._currentList.length === 0) { + this._currentList.push({ "@": (_a = {}, _a[name] = value, _a) }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + /* istanbul ignore else */ + if (this._isAttrNode(lastItem)) { + lastItem["@"][name] = value; + } + else { + this._currentList.push({ "@": (_b = {}, _b[name] = value, _b) }); + } + } }; - - XMLStreamWriter.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(' 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); + /** @inheritdoc */ + ObjectWriter.prototype.comment = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "!": data }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isCommentNode(lastItem)) { + if (util_1.isArray(lastItem["!"])) { + lastItem["!"].push(data); + } + else { + lastItem["!"] = [lastItem["!"], data]; + } + } + else { + this._currentList.push({ "!": data }); + } } - 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); }; - - XMLStreamWriter.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(''); - } else { - options.state = WriterState.CloseTag; - this.stream.write(options.spaceBeforeSlash + '/>'); + /** @inheritdoc */ + ObjectWriter.prototype.text = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "#": data }); } - } 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(''); - } 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); + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isTextNode(lastItem)) { + if (util_1.isArray(lastItem["#"])) { + lastItem["#"].push(data); + } + else { + lastItem["#"] = [lastItem["#"], data]; + } + } + else { + this._currentList.push({ "#": data }); + } } - options.state = WriterState.CloseTag; - this.stream.write(this.indent(node, options, level) + ''); - } - this.stream.write(this.endline(node, options, level)); - options.state = WriterState.None; - return this.closeNode(node, options, level); }; - - XMLStreamWriter.prototype.processingInstruction = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level)); + /** @inheritdoc */ + ObjectWriter.prototype.instruction = function (target, data) { + var value = (data === "" ? target : target + " " + data); + if (this._currentList.length === 0) { + this._currentList.push({ "?": value }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isInstructionNode(lastItem)) { + if (util_1.isArray(lastItem["?"])) { + lastItem["?"].push(value); + } + else { + lastItem["?"] = [lastItem["?"], value]; + } + } + else { + this._currentList.push({ "?": value }); + } + } }; - - XMLStreamWriter.prototype.raw = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level)); + /** @inheritdoc */ + ObjectWriter.prototype.cdata = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "$": data }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isCDATANode(lastItem)) { + if (util_1.isArray(lastItem["$"])) { + lastItem["$"].push(data); + } + else { + lastItem["$"] = [lastItem["$"], data]; + } + } + else { + this._currentList.push({ "$": data }); + } + } }; - - XMLStreamWriter.prototype.text = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level)); + ObjectWriter.prototype._isAttrNode = function (x) { + return "@" in x; }; - - XMLStreamWriter.prototype.dtdAttList = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level)); + ObjectWriter.prototype._isTextNode = function (x) { + return "#" in x; }; - - XMLStreamWriter.prototype.dtdElement = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level)); + ObjectWriter.prototype._isCommentNode = function (x) { + return "!" in x; }; - - XMLStreamWriter.prototype.dtdEntity = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level)); + ObjectWriter.prototype._isInstructionNode = function (x) { + return "?" in x; }; - - XMLStreamWriter.prototype.dtdNotation = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level)); + ObjectWriter.prototype._isCDATANode = function (x) { + return "$" in x; }; - - return XMLStreamWriter; - - })(XMLWriterBase); - -}).call(this); - - -/***/ }), - -/***/ 5913: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(6752); - - module.exports = XMLStringWriter = (function(superClass) { - extend(XMLStringWriter, superClass); - - function XMLStringWriter(options) { - XMLStringWriter.__super__.constructor.call(this, options); - } - - XMLStringWriter.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; + ObjectWriter.prototype._isElementNode = function (x, name) { + return name in x; }; - - return XMLStringWriter; - - })(XMLWriterBase); - -}).call(this); - + /** + * Returns an object key for an attribute or namespace declaration. + */ + ObjectWriter.prototype._getAttrKey = function () { + return this._builderOptions.convert.att; + }; + /** + * Returns an object key for the given node type. + * + * @param nodeType - node type to get a key for + */ + ObjectWriter.prototype._getNodeKey = function (nodeType) { + switch (nodeType) { + case interfaces_1.NodeType.Comment: + return this._builderOptions.convert.comment; + case interfaces_1.NodeType.Text: + return this._builderOptions.convert.text; + case interfaces_1.NodeType.ProcessingInstruction: + return this._builderOptions.convert.ins; + case interfaces_1.NodeType.CData: + return this._builderOptions.convert.cdata; + /* istanbul ignore next */ + default: + throw new Error("Invalid node type."); + } + }; + return ObjectWriter; +}(BaseWriter_1.BaseWriter)); +exports.ObjectWriter = ObjectWriter; +//# sourceMappingURL=ObjectWriter.js.map /***/ }), -/***/ 8594: -/***/ (function(module) { +/***/ 7572: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLStringifier, - bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - hasProp = {}.hasOwnProperty; +"use strict"; - module.exports = XMLStringifier = (function() { - function XMLStringifier(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; - } +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var BaseCBWriter_1 = __nccwpck_require__(708); +/** + * Serializes XML nodes. + */ +var XMLCBWriter = /** @class */ (function (_super) { + __extends(XMLCBWriter, _super); + /** + * Initializes a new instance of `XMLCBWriter`. + * + * @param builderOptions - XML builder options + */ + function XMLCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._lineLength = 0; + return _this; } - - XMLStringifier.prototype.name = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalName('' + val || ''); + /** @inheritdoc */ + XMLCBWriter.prototype.frontMatter = function () { + return ""; }; - - XMLStringifier.prototype.text = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar(this.textEscape('' + val || '')); + /** @inheritdoc */ + XMLCBWriter.prototype.declaration = function (version, encoding, standalone) { + var markup = this._beginLine() + ""; + return markup; }; - - XMLStringifier.prototype.cdata = function(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - val = val.replace(']]>', ']]]]>'); - return this.assertLegalChar(val); + /** @inheritdoc */ + XMLCBWriter.prototype.docType = function (name, publicId, systemId) { + var markup = this._beginLine(); + if (publicId && systemId) { + markup += ""; + } + else if (publicId) { + markup += ""; + } + else if (systemId) { + markup += ""; + } + else { + markup += ""; + } + return markup; }; - - XMLStringifier.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); + /** @inheritdoc */ + XMLCBWriter.prototype.comment = function (data) { + return this._beginLine() + ""; }; - - XMLStringifier.prototype.raw = function(val) { - if (this.options.noValidation) { - return val; - } - return '' + val || ''; + /** @inheritdoc */ + XMLCBWriter.prototype.text = function (data) { + return this._beginLine() + data; }; - - XMLStringifier.prototype.attValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar(this.attEscape(val = '' + val || '')); + /** @inheritdoc */ + XMLCBWriter.prototype.instruction = function (target, data) { + if (data) { + return this._beginLine() + ""; + } + else { + return this._beginLine() + ""; + } }; - - XMLStringifier.prototype.insTarget = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); + /** @inheritdoc */ + XMLCBWriter.prototype.cdata = function (data) { + return this._beginLine() + ""; }; - - XMLStringifier.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); + /** @inheritdoc */ + XMLCBWriter.prototype.openTagBegin = function (name) { + this._lineLength += 1 + name.length; + return this._beginLine() + "<" + name; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (voidElement) { + return " />"; + } + else if (selfClosing) { + if (this._writerOptions.allowEmptyTags) { + return ">"; + } + else if (this._writerOptions.spaceBeforeSlash) { + return " />"; + } + else { + return "/>"; + } + } + else { + return ">"; + } + }; + /** @inheritdoc */ + XMLCBWriter.prototype.closeTag = function (name) { + return this._beginLine() + ""; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.attribute = function (name, value) { + var str = name + "=\"" + value + "\""; + if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && + this._lineLength + 1 + str.length > this._writerOptions.width) { + str = this._beginLine() + this._indent(1) + str; + this._lineLength = str.length; + return str; + } + else { + this._lineLength += 1 + str.length; + return " " + str; + } + }; + /** @inheritdoc */ + XMLCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + XMLCBWriter.prototype.endElement = function (name) { }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + XMLCBWriter.prototype._beginLine = function () { + if (this._writerOptions.prettyPrint) { + var str = (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level); + this._lineLength = str.length; + return str; + } + else { + return ""; + } }; - - XMLStringifier.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; + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + XMLCBWriter.prototype._indent = function (level) { + if (level <= 0) { + return ""; + } + else { + return this._writerOptions.indent.repeat(level); + } }; + return XMLCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.XMLCBWriter = XMLCBWriter; +//# sourceMappingURL=XMLCBWriter.js.map - XMLStringifier.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); - }; +/***/ }), - XMLStringifier.prototype.xmlStandalone = function(val) { - if (this.options.noValidation) { - return val; - } - if (val) { - return "yes"; - } else { - return "no"; - } - }; +/***/ 9606: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLStringifier.prototype.dtdPubID = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; +"use strict"; - XMLStringifier.prototype.dtdSysID = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLStringifier.prototype.dtdElementValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLStringifier.prototype.dtdAttType = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var interfaces_1 = __nccwpck_require__(7305); +var BaseWriter_1 = __nccwpck_require__(7644); +var util_2 = __nccwpck_require__(5282); +/** + * Serializes XML nodes into strings. + */ +var XMLWriter = /** @class */ (function (_super) { + __extends(XMLWriter, _super); + /** + * Initializes a new instance of `XMLWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function XMLWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._indentation = {}; + _this._lengthToLastNewline = 0; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + headless: false, + prettyPrint: false, + indent: " ", + newline: "\n", + offset: 0, + width: 0, + allowEmptyTags: false, + indentTextOnlyNodes: false, + spaceBeforeSlash: false + }); + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + */ + XMLWriter.prototype.serialize = function (node) { + this._refs = { suppressPretty: false, emptyNode: false, markup: "" }; + // Serialize XML declaration + if (node.nodeType === interfaces_1.NodeType.Document && !this._writerOptions.headless) { + this.declaration(this._builderOptions.version, this._builderOptions.encoding, this._builderOptions.standalone); + } + // recursively serialize node + this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); + // remove trailing newline + if (this._writerOptions.prettyPrint && + this._refs.markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { + this._refs.markup = this._refs.markup.slice(0, -this._writerOptions.newline.length); + } + return this._refs.markup; }; - - XMLStringifier.prototype.dtdAttDefault = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); + /** @inheritdoc */ + XMLWriter.prototype.declaration = function (version, encoding, standalone) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); }; - - XMLStringifier.prototype.dtdEntityValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); + /** @inheritdoc */ + XMLWriter.prototype.docType = function (name, publicId, systemId) { + this._beginLine(); + if (publicId && systemId) { + this._refs.markup += ""; + } + else if (publicId) { + this._refs.markup += ""; + } + else if (systemId) { + this._refs.markup += ""; + } + else { + this._refs.markup += ""; + } + this._endLine(); }; - - XMLStringifier.prototype.dtdNData = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); + /** @inheritdoc */ + XMLWriter.prototype.openTagBegin = function (name) { + this._beginLine(); + this._refs.markup += "<" + name; }; - - XMLStringifier.prototype.convertAttKey = '@'; - - XMLStringifier.prototype.convertPIKey = '?'; - - XMLStringifier.prototype.convertTextKey = '#text'; - - XMLStringifier.prototype.convertCDataKey = '#cdata'; - - XMLStringifier.prototype.convertCommentKey = '#comment'; - - XMLStringifier.prototype.convertRawKey = '#raw'; - - XMLStringifier.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); + /** @inheritdoc */ + XMLWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + // do not indent text only elements or elements with empty text nodes + this._refs.suppressPretty = false; + this._refs.emptyNode = false; + if (this._writerOptions.prettyPrint && !selfClosing && !voidElement) { + var textOnlyNode = true; + var emptyNode = true; + var childNode = this.currentNode.firstChild; + var cdataCount = 0; + var textCount = 0; + while (childNode) { + if (util_2.Guard.isExclusiveTextNode(childNode)) { + textCount++; + } + else if (util_2.Guard.isCDATASectionNode(childNode)) { + cdataCount++; + } + else { + textOnlyNode = false; + emptyNode = false; + break; + } + if (childNode.data !== '') { + emptyNode = false; + } + childNode = childNode.nextSibling; + } + this._refs.suppressPretty = !this._writerOptions.indentTextOnlyNodes && textOnlyNode && ((cdataCount <= 1 && textCount === 0) || cdataCount === 0); + this._refs.emptyNode = emptyNode; } - } 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); + if ((voidElement || selfClosing || this._refs.emptyNode) && this._writerOptions.allowEmptyTags) { + this._refs.markup += ">"; + } + else { + this._refs.markup += voidElement ? " />" : + (selfClosing || this._refs.emptyNode) ? (this._writerOptions.spaceBeforeSlash ? " />" : "/>") : ">"; } - } - return str; - }; - - XMLStringifier.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; - }; - - XMLStringifier.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(/\r/g, ' '); + this._endLine(); }; - - XMLStringifier.prototype.attEscape = function(str) { - var ampregex; - if (this.options.noValidation) { - return str; - } - ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; - return str.replace(ampregex, '&').replace(/"; + } + this._refs.suppressPretty = false; + this._refs.emptyNode = false; + this._endLine(); }; - - return XMLStringifier; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 1318: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(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 = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLText = (function(superClass) { - extend(XMLText, superClass); - - function XMLText(parent, text) { - XMLText.__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(XMLText.prototype, 'isElementContentWhitespace', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - Object.defineProperty(XMLText.prototype, 'wholeText', { - get: function() { - var next, prev, str; - str = ''; - prev = this.previousSibling; - while (prev) { - str = prev.data + str; - prev = prev.previousSibling; + /** @inheritdoc */ + XMLWriter.prototype.attribute = function (name, value) { + var str = name + "=\"" + value + "\""; + if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && + this._refs.markup.length - this._lengthToLastNewline + 1 + str.length > this._writerOptions.width) { + this._endLine(); + this._beginLine(); + this._refs.markup += this._indent(1) + str; } - str += this.data; - next = this.nextSibling; - while (next) { - str = str + next.data; - next = next.nextSibling; + else { + this._refs.markup += " " + str; } - return str; - } - }); - - XMLText.prototype.clone = function() { - return Object.create(this); }; - - XMLText.prototype.toString = function(options) { - return this.options.writer.text(this, this.options.writer.filterOptions(options)); + /** @inheritdoc */ + XMLWriter.prototype.text = function (data) { + if (data !== '') { + this._beginLine(); + this._refs.markup += data; + this._endLine(); + } }; - - XMLText.prototype.splitText = function(offset) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLWriter.prototype.cdata = function (data) { + if (data !== '') { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); + } }; - - XMLText.prototype.replaceWholeText = function(content) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLWriter.prototype.comment = function (data) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); }; - - return XMLText; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 6752: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign, - hasProp = {}.hasOwnProperty; - - assign = (__nccwpck_require__(8229).assign); - - NodeType = __nccwpck_require__(9267); - - XMLDeclaration = __nccwpck_require__(6364); - - XMLDocType = __nccwpck_require__(1801); - - XMLCData = __nccwpck_require__(333); - - XMLComment = __nccwpck_require__(4407); - - XMLElement = __nccwpck_require__(9437); - - XMLRaw = __nccwpck_require__(6329); - - XMLText = __nccwpck_require__(1318); - - XMLProcessingInstruction = __nccwpck_require__(6939); - - XMLDummy = __nccwpck_require__(3590); - - XMLDTDAttList = __nccwpck_require__(1015); - - XMLDTDElement = __nccwpck_require__(2421); - - XMLDTDEntity = __nccwpck_require__(53); - - XMLDTDNotation = __nccwpck_require__(2837); - - WriterState = __nccwpck_require__(9766); - - module.exports = XMLWriterBase = (function() { - function XMLWriterBase(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; - } - } - - XMLWriterBase.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; + /** @inheritdoc */ + XMLWriter.prototype.instruction = function (target, data) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); }; - - XMLWriterBase.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); + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + XMLWriter.prototype._beginLine = function () { + if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) { + this._refs.markup += this._indent(this._writerOptions.offset + this.level); + } + }; + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + */ + XMLWriter.prototype._endLine = function () { + if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) { + this._refs.markup += this._writerOptions.newline; + this._lengthToLastNewline = this._refs.markup.length; } - } - return ''; }; - - XMLWriterBase.prototype.endline = function(node, options, level) { - if (!options.pretty || options.suppressPrettyCount) { - return ''; - } else { - return options.newline; - } + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + XMLWriter.prototype._indent = function (level) { + if (level <= 0) { + return ""; + } + else if (this._indentation[level] !== undefined) { + return this._indentation[level]; + } + else { + var str = this._writerOptions.indent.repeat(level); + this._indentation[level] = str; + return str; + } }; + return XMLWriter; +}(BaseWriter_1.BaseWriter)); +exports.XMLWriter = XMLWriter; +//# sourceMappingURL=XMLWriter.js.map - XMLWriterBase.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; - }; +/***/ }), - XMLWriterBase.prototype.cdata = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; +/***/ 2444: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLWriterBase.prototype.comment = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; +"use strict"; - XMLWriterBase.prototype.declaration = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + ''; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); }; - - XMLWriterBase.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 += ' 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; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLWriterBase.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 += '' + this.endline(node, options, level); - } else { - options.state = WriterState.CloseTag; - r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level); +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var BaseCBWriter_1 = __nccwpck_require__(708); +/** + * Serializes XML nodes. + */ +var YAMLCBWriter = /** @class */ (function (_super) { + __extends(YAMLCBWriter, _super); + /** + * Initializes a new instance of `BaseCBWriter`. + * + * @param builderOptions - XML builder options + */ + function YAMLCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._rootWritten = false; + _this._additionalLevel = 0; + if (builderOptions.indent.length < 2) { + throw new Error("YAML indententation string must be at least two characters long."); } - } 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 += '' + 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; - } - } + if (builderOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); + } + return _this; + } + /** @inheritdoc */ + YAMLCBWriter.prototype.frontMatter = function () { + return this._beginLine() + "---"; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.comment = function (data) { + // "!": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.comment) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.text = function (data) { + // "#": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.text) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.instruction = function (target, data) { + // "?": "target hello" + return this._beginLine() + + this._key(this._builderOptions.convert.ins) + " " + + this._val(data ? target + " " + data : target); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.cdata = function (data) { + // "$": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.cdata) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.attribute = function (name, value) { + // "@name": "val" + this._additionalLevel++; + var str = this._beginLine() + + this._key(this._builderOptions.convert.att + name) + " " + + this._val(value); + this._additionalLevel--; + return str; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.openTagBegin = function (name) { + // "node": + // "#": + // - + var str = this._beginLine() + this._key(name); + if (!this._rootWritten) { + this._rootWritten = true; } - 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); + this.hasData = true; + this._additionalLevel++; + str += this._beginLine(true) + this._key(this._builderOptions.convert.text); + return str; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (selfClosing) { + return " " + this._val(""); } - options.state = WriterState.CloseTag; - r += this.indent(node, options, level) + ''; - if (prettySuppressed) { - options.suppressPrettyCount--; + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.closeTag = function (name) { + this._additionalLevel--; + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + YAMLCBWriter.prototype.endElement = function (name) { }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + YAMLCBWriter.prototype._beginLine = function (suppressArray) { + if (suppressArray === void 0) { suppressArray = false; } + return (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level, suppressArray); + }; + /** + * Produces an indentation string. + * + * @param level - depth of the tree + * @param suppressArray - whether the suppress array marker + */ + YAMLCBWriter.prototype._indent = function (level, suppressArray) { + if (level + this._additionalLevel <= 0) { + return ""; + } + else { + var chars = this._writerOptions.indent.repeat(level + this._additionalLevel); + if (!suppressArray && this._rootWritten) { + return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); + } + return chars; } - r += this.endline(node, options, level); - options.state = WriterState.None; - } - this.closeNode(node, options, level); - return r; }; - - XMLWriterBase.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); - } + /** + * Produces a YAML key string delimited with double quotes. + */ + YAMLCBWriter.prototype._key = function (key) { + return "\"" + key + "\":"; }; - - XMLWriterBase.prototype.processingInstruction = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + ''; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** + * Produces a YAML value string delimited with double quotes. + */ + YAMLCBWriter.prototype._val = function (val) { + return JSON.stringify(val); }; + return YAMLCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.YAMLCBWriter = YAMLCBWriter; +//# sourceMappingURL=YAMLCBWriter.js.map - XMLWriterBase.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; - }; +/***/ }), - XMLWriterBase.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; - }; +/***/ 6517: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLWriterBase.prototype.dtdAttList = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectWriter_1 = __nccwpck_require__(243); +var util_1 = __nccwpck_require__(6195); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into a YAML string. + */ +var YAMLWriter = /** @class */ (function (_super) { + __extends(YAMLWriter, _super); + /** + * Initializes a new instance of `YAMLWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function YAMLWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + indent: ' ', + newline: '\n', + offset: 0, + group: false, + verbose: false + }); + if (_this._writerOptions.indent.length < 2) { + throw new Error("YAML indententation string must be at least two characters long."); + } + if (_this._writerOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); + } + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + * @param writerOptions - serialization options + */ + YAMLWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + var markup = this._beginLine(this._writerOptions, 0) + '---' + this._endLine(this._writerOptions) + + this._convertObject(val, this._writerOptions, 0); + // remove trailing newline + /* istanbul ignore else */ + if (markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { + markup = markup.slice(0, -this._writerOptions.newline.length); + } + return markup; }; - - XMLWriterBase.prototype.dtdElement = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** + * Produces an XML serialization of the given object. + * + * @param obj - object to serialize + * @param options - serialization options + * @param level - depth of the XML tree + * @param indentLeaf - indents leaf nodes + */ + YAMLWriter.prototype._convertObject = function (obj, options, level, suppressIndent) { + var e_1, _a; + var _this = this; + if (suppressIndent === void 0) { suppressIndent = false; } + var markup = ''; + if (util_1.isArray(obj)) { + try { + for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { + var val = obj_1_1.value; + markup += this._beginLine(options, level, true); + if (!util_1.isObject(val)) { + markup += this._val(val) + this._endLine(options); + } + else if (util_1.isEmpty(val)) { + markup += '""' + this._endLine(options); + } + else { + markup += this._convertObject(val, options, level, true); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); + } + finally { if (e_1) throw e_1.error; } + } + } + else /* if (isObject(obj)) */ { + util_1.forEachObject(obj, function (key, val) { + if (suppressIndent) { + markup += _this._key(key); + suppressIndent = false; + } + else { + markup += _this._beginLine(options, level) + _this._key(key); + } + if (!util_1.isObject(val)) { + markup += ' ' + _this._val(val) + _this._endLine(options); + } + else if (util_1.isEmpty(val)) { + markup += ' ""' + _this._endLine(options); + } + else { + markup += _this._endLine(options) + + _this._convertObject(val, options, level + 1); + } + }, this); + } + return markup; }; - - XMLWriterBase.prototype.dtdEntity = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; }; - - XMLWriterBase.prototype.dtdNotation = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + */ + YAMLWriter.prototype._endLine = function (options) { + return options.newline; }; - - XMLWriterBase.prototype.openNode = function(node, options, level) {}; - - XMLWriterBase.prototype.closeNode = function(node, options, level) {}; - - XMLWriterBase.prototype.openAttribute = function(att, options, level) {}; - - XMLWriterBase.prototype.closeAttribute = function(att, options, level) {}; - - return XMLWriterBase; - - })(); - -}).call(this); - + /** + * Produces a YAML key string delimited with double quotes. + */ + YAMLWriter.prototype._key = function (key) { + return "\"" + key + "\":"; + }; + /** + * Produces a YAML value string delimited with double quotes. + */ + YAMLWriter.prototype._val = function (val) { + return JSON.stringify(val); + }; + return YAMLWriter; +}(BaseWriter_1.BaseWriter)); +exports.YAMLWriter = YAMLWriter; +//# sourceMappingURL=YAMLWriter.js.map /***/ }), -/***/ 2958: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref; - - ref = __nccwpck_require__(8229), assign = ref.assign, isFunction = ref.isFunction; - - XMLDOMImplementation = __nccwpck_require__(8310); - - XMLDocument = __nccwpck_require__(3730); - - XMLDocumentCB = __nccwpck_require__(7356); - - XMLStringWriter = __nccwpck_require__(5913); - - XMLStreamWriter = __nccwpck_require__(8601); - - NodeType = __nccwpck_require__(9267); - - WriterState = __nccwpck_require__(9766); - - module.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; - }; - - module.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); - } - }; - - module.exports.stringWriter = function(options) { - return new XMLStringWriter(options); - }; - - module.exports.streamWriter = function(stream, options) { - return new XMLStreamWriter(stream, options); - }; - - module.exports.implementation = new XMLDOMImplementation(); - - module.exports.nodeType = NodeType; - - module.exports.writerState = WriterState; +/***/ 7476: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -}).call(this); +"use strict"; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var MapWriter_1 = __nccwpck_require__(1397); +exports.MapWriter = MapWriter_1.MapWriter; +var XMLWriter_1 = __nccwpck_require__(9606); +exports.XMLWriter = XMLWriter_1.XMLWriter; +var ObjectWriter_1 = __nccwpck_require__(243); +exports.ObjectWriter = ObjectWriter_1.ObjectWriter; +var JSONWriter_1 = __nccwpck_require__(7510); +exports.JSONWriter = JSONWriter_1.JSONWriter; +var YAMLWriter_1 = __nccwpck_require__(6517); +exports.YAMLWriter = YAMLWriter_1.YAMLWriter; +//# sourceMappingURL=index.js.map /***/ }), From 33b10b64eb638c2717d7f7c3e01e6a71f9735954 Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Tue, 18 Jul 2023 09:28:12 +0200 Subject: [PATCH 4/4] Use archive as fallback only when dealing with major version --- .../distributors/oracle-installer.test.ts | 26 +++++++++-- dist/setup/index.js | 32 ++++++++++---- src/distributions/oracle/installer.ts | 44 ++++++++++++++----- 3 files changed, 78 insertions(+), 24 deletions(-) diff --git a/__tests__/distributors/oracle-installer.test.ts b/__tests__/distributors/oracle-installer.test.ts index baf1d8e41..ad16ecaca 100644 --- a/__tests__/distributors/oracle-installer.test.ts +++ b/__tests__/distributors/oracle-installer.test.ts @@ -25,7 +25,12 @@ describe('findPackageForDownload', () => { [ '20', '20', - 'https://download.oracle.com/java/20/archive/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' + 'https://download.oracle.com/java/20/latest/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' + ], + [ + '18', + '18', + 'https://download.oracle.com/java/18/archive/jdk-18_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' ], [ '20.0.1', @@ -35,7 +40,7 @@ describe('findPackageForDownload', () => { [ '17', '17', - 'https://download.oracle.com/java/17/archive/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' + 'https://download.oracle.com/java/17/latest/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' ], [ '17.0.1', @@ -53,6 +58,19 @@ describe('findPackageForDownload', () => { }) ); + /** + * NOTE - Should fail to retrieve 18 from latest and check archive instead + */ + if (input === '18') { + spyHttpClient.mockReturnValueOnce( + Promise.resolve({ + message: { + statusCode: 404 + } + }) + ); + } + const result = await distribution['findPackageForDownload'](input); jest.restoreAllMocks(); @@ -75,7 +93,7 @@ describe('findPackageForDownload', () => { jest.spyOn(os, 'arch').mockReturnValue(osArch); jest.spyOn(os, 'platform').mockReturnValue('linux'); - const version = '17'; + const version = '18'; const distro = new OracleDistribution({ version, architecture: '', // to get default value @@ -89,7 +107,7 @@ describe('findPackageForDownload', () => { } const archiveType = getDownloadArchiveExtension(); const result = await distro['findPackageForDownload'](version); - const expectedUrl = `https://download.oracle.com/java/17/archive/jdk-17_${osType}-${distroArch}_bin.${archiveType}`; + const expectedUrl = `https://download.oracle.com/java/18/archive/jdk-18_${osType}-${distroArch}_bin.${archiveType}`; expect(result.url).toBe(expectedUrl); } diff --git a/dist/setup/index.js b/dist/setup/index.js index f5d2e0171..fe8ba78fd 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -102973,19 +102973,33 @@ class OracleDistribution extends base_installer_1.JavaBase { } const platform = this.getPlatform(); const extension = util_1.getDownloadArchiveExtension(); - const major = range.includes('.') ? range.split('.')[0] : range; - const fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`; + const isOnlyMajorProvided = !range.includes('.'); + const major = isOnlyMajorProvided ? range : range.split('.')[0]; + const possibleUrls = []; + /** + * NOTE + * If only major version was provided we will check it under /latest first + * in order to retrieve the latest possible version if possible, + * otherwise we will fall back to /archive where we are guaranteed to + * find any version if it exists + */ + if (isOnlyMajorProvided) { + possibleUrls.push(`${ORACLE_DL_BASE}/${major}/latest/jdk-${major}_${platform}-${arch}_bin.${extension}`); + } + possibleUrls.push(`${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`); if (parseInt(major) < 17) { throw new Error('Oracle JDK is only supported for JDK 17 and later'); } - const response = yield this.http.head(fileUrl); - if (response.message.statusCode === http_client_1.HttpCodes.NotFound) { - throw new Error(`Could not find Oracle JDK for SemVer ${range}`); - } - if (response.message.statusCode !== http_client_1.HttpCodes.OK) { - throw new Error(`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`); + for (const url of possibleUrls) { + const response = yield this.http.head(url); + if (response.message.statusCode === http_client_1.HttpCodes.OK) { + return { url, version: range }; + } + if (response.message.statusCode !== http_client_1.HttpCodes.NotFound) { + throw new Error(`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`); + } } - return { url: fileUrl, version: range }; + throw new Error(`Could not find Oracle JDK for SemVer ${range}`); }); } getPlatform(platform = process.platform) { diff --git a/src/distributions/oracle/installer.ts b/src/distributions/oracle/installer.ts index 8f68d9ddc..ec0ab2157 100644 --- a/src/distributions/oracle/installer.ts +++ b/src/distributions/oracle/installer.ts @@ -65,26 +65,48 @@ export class OracleDistribution extends JavaBase { const platform = this.getPlatform(); const extension = getDownloadArchiveExtension(); - const major = range.includes('.') ? range.split('.')[0] : range; - const fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`; + + const isOnlyMajorProvided = !range.includes('.'); + const major = isOnlyMajorProvided ? range : range.split('.')[0]; + + const possibleUrls: string[] = []; + + /** + * NOTE + * If only major version was provided we will check it under /latest first + * in order to retrieve the latest possible version if possible, + * otherwise we will fall back to /archive where we are guaranteed to + * find any version if it exists + */ + if (isOnlyMajorProvided) { + possibleUrls.push( + `${ORACLE_DL_BASE}/${major}/latest/jdk-${major}_${platform}-${arch}_bin.${extension}` + ); + } + + possibleUrls.push( + `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}` + ); if (parseInt(major) < 17) { throw new Error('Oracle JDK is only supported for JDK 17 and later'); } - const response = await this.http.head(fileUrl); + for (const url of possibleUrls) { + const response = await this.http.head(url); - if (response.message.statusCode === HttpCodes.NotFound) { - throw new Error(`Could not find Oracle JDK for SemVer ${range}`); - } + if (response.message.statusCode === HttpCodes.OK) { + return {url, version: range}; + } - if (response.message.statusCode !== HttpCodes.OK) { - throw new Error( - `Http request for Oracle JDK failed with status code: ${response.message.statusCode}` - ); + if (response.message.statusCode !== HttpCodes.NotFound) { + throw new Error( + `Http request for Oracle JDK failed with status code: ${response.message.statusCode}` + ); + } } - return {url: fileUrl, version: range}; + throw new Error(`Could not find Oracle JDK for SemVer ${range}`); } public getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {