diff --git a/.github/workflows/e2e-publishing.yml b/.github/workflows/e2e-publishing.yml
index dd7bd4351..c927adb4f 100644
--- a/.github/workflows/e2e-publishing.yml
+++ b/.github/workflows/e2e-publishing.yml
@@ -151,3 +151,45 @@ jobs:
if (-not (Test-Path $path)) {
throw "settings.xml file is not found in expected location"
}
+ test-publishing-multiple-repositories-with-gpg-passphrase:
+ name: Validate settings.xml
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [macos-latest, windows-latest, ubuntu-latest]
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: setup-java
+ uses: ./
+ id: setup-java
+ with:
+ distribution: 'adopt'
+ java-version: '11'
+ mvn-repositories-len: 2
+ server-id-0: maven-0
+ server-username-0: MAVEN_USERNAME-0
+ server-password-0: MAVEN_CENTRAL_TOKEN-0
+ server-id-1: maven-1
+ server-username-1: MAVEN_USERNAME-1
+ server-password-1: MAVEN_CENTRAL_TOKEN-1
+ gpg-passphrase: MAVEN_GPG_PASSPHRASE
+ - name: Validate settings.xml
+ run: |
+ $xmlPath = Join-Path $HOME ".m2" "settings.xml"
+ Get-Content $xmlPath | ForEach-Object { Write-Host $_ }
+
+ [xml]$xml = Get-Content $xmlPath
+ $servers = $xml.settings.servers.server
+ if (($servers[0].id -ne 'maven-0') -or ($servers[0].username -ne '${env.MAVEN_USERNAME-0}') -or ($servers[0].password -ne '${env.MAVEN_CENTRAL_TOKEN-0}')) {
+ throw "Generated XML file is incorrect"
+ }
+
+ if (($servers[1].id -ne 'maven-1') -or ($servers[0].username -ne '${env.MAVEN_PASSWORD-1}') -or ($servers[1].password -ne '${env.MAVEN_CENTRAL_TOKEN-1}')) {
+ throw "Generated XML file is incorrect"
+ }
+
+ if (($servers[1].id -ne 'gpg.passphrase') -or ($servers[1].passphrase -ne '${env.MAVEN_GPG_PASSPHRASE}')) {
+ throw "Generated XML file is incorrect"
+ }
diff --git a/__tests__/auth.test.ts b/__tests__/auth.test.ts
index 06591da7a..2c67ee709 100644
--- a/__tests__/auth.test.ts
+++ b/__tests__/auth.test.ts
@@ -43,9 +43,7 @@ describe('auth tests', () => {
await io.rmRF(altHome); // ensure it doesn't already exist
await auth.createAuthenticationSettings(
- id,
- username,
- password,
+ [{id, username, password}],
altHome,
true
);
@@ -56,7 +54,7 @@ describe('auth tests', () => {
expect(fs.existsSync(altHome)).toBe(true);
expect(fs.existsSync(altSettingsFile)).toBe(true);
expect(fs.readFileSync(altSettingsFile, 'utf-8')).toEqual(
- auth.generate(id, username, password)
+ auth.generate([{id, username, password}])
);
await io.rmRF(altHome);
@@ -68,9 +66,7 @@ describe('auth tests', () => {
const password = 'TOKEN';
await auth.createAuthenticationSettings(
- id,
- username,
- password,
+ [{id, username, password}],
m2Dir,
true
);
@@ -78,7 +74,7 @@ describe('auth tests', () => {
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
- auth.generate(id, username, password)
+ auth.generate([{id, username, password}])
);
}, 100000);
@@ -89,18 +85,15 @@ describe('auth tests', () => {
const gpgPassphrase = 'GPG';
await auth.createAuthenticationSettings(
- id,
- username,
- password,
+ [{id, username, password, gpgPassphrase}],
m2Dir,
- true,
- gpgPassphrase
+ true
);
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
- auth.generate(id, username, password, gpgPassphrase)
+ auth.generate([{id, username, password, gpgPassphrase}])
);
}, 100000);
@@ -115,9 +108,7 @@ describe('auth tests', () => {
expect(fs.existsSync(settingsFile)).toBe(true);
await auth.createAuthenticationSettings(
- id,
- username,
- password,
+ [{id, username, password}],
m2Dir,
true
);
@@ -125,7 +116,7 @@ describe('auth tests', () => {
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
- auth.generate(id, username, password)
+ auth.generate([{id, username, password}])
);
}, 100000);
@@ -140,9 +131,7 @@ describe('auth tests', () => {
expect(fs.existsSync(settingsFile)).toBe(true);
await auth.createAuthenticationSettings(
- id,
- username,
- password,
+ [{id, username, password}],
m2Dir,
false
);
@@ -169,7 +158,7 @@ describe('auth tests', () => {
`;
- expect(auth.generate(id, username, password)).toEqual(expectedSettings);
+ expect(auth.generate([{id, username, password}])).toEqual(expectedSettings);
});
it('generates valid settings.xml with additional configuration', () => {
@@ -194,8 +183,50 @@ describe('auth tests', () => {
`;
- expect(auth.generate(id, username, password, gpgPassphrase)).toEqual(
- expectedSettings
- );
+ expect(
+ auth.generate([
+ {id, username, password},
+ {id: 'gpg.passphrase', gpgPassphrase: gpgPassphrase}
+ ])
+ ).toEqual(expectedSettings);
+ });
+
+ it('generates valid settings.xml for multiple repositories', () => {
+ const id0 = 'packages0';
+ const username0 = 'USER0';
+ const password0 = '&<>"\'\'"><&0';
+ const id1 = 'packages1';
+ const username1 = 'USER1';
+ const password1 = '&<>"\'\'"><&1';
+ const gpgPassphrase = 'PASSPHRASE';
+
+ const expectedSettings = `
+
+
+ ${id0}
+ \${env.${username0}}
+ \${env.&<>"''"><&0}
+
+
+ ${id1}
+ \${env.${username1}}
+ \${env.&<>"''"><&1}
+
+
+ gpg.passphrase
+ \${env.${gpgPassphrase}}
+
+
+`;
+
+ expect(
+ auth.generate([
+ {id: id0, username: username0, password: password0},
+ {id: id1, username: username1, password: password1},
+ {id: 'gpg.passphrase', gpgPassphrase: gpgPassphrase}
+ ])
+ ).toEqual(expectedSettings);
});
});
diff --git a/action.yml b/action.yml
index 0969d5d42..e51f243ab 100644
--- a/action.yml
+++ b/action.yml
@@ -39,6 +39,33 @@ inputs:
authentication to the Apache Maven repository. Default is $GITHUB_TOKEN'
required: false
default: 'GITHUB_TOKEN'
+ mvn-repositories-len:
+ description: 'Number of Maven repositories being configured - Only applicable if more than one Maven repository is being configured'
+ required: false
+ server-id-0:
+ description: 'ID of the first distributionManagement repository in the pom.xml
+ file - Only applicable if more than one Maven repository is being configured'
+ required: false
+ server-username-0:
+ description: 'Environment variable name for the username for authentication
+ to the first Maven repository - Only applicable if more than one Maven repository is being configured'
+ required: false
+ server-password-0:
+ description: 'Environment variable name for password or token for
+ authentication to the first Maven repository - Only applicable if more than one Maven repository is being configured'
+ required: false
+ server-id-1:
+ description: 'ID of the second distributionManagement repository in the pom.xml
+ file - Only applicable if more than one Maven repository is being configured'
+ required: false
+ server-username-1:
+ description: 'Environment variable name for the username for authentication
+ to the second Maven repository - Only applicable if more than one Maven repository is being configured'
+ required: false
+ server-password-1:
+ description: 'Environment variable name for password or token for
+ authentication to the second Maven repository - Only applicable if more than one Maven repository is being configured'
+ required: false
settings-path:
description: 'Path to where the settings.xml file will be written. Default is ~/.m2.'
required: false
diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js
index b8d03ca1f..25841cc3c 100644
--- a/dist/cleanup/index.js
+++ b/dist/cleanup/index.js
@@ -93365,7 +93365,7 @@ else {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
-exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
+exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_NUM_MVN_REPOS = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
exports.INPUT_JAVA_VERSION = 'java-version';
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
@@ -93374,6 +93374,7 @@ exports.INPUT_JAVA_PACKAGE = 'java-package';
exports.INPUT_DISTRIBUTION = 'distribution';
exports.INPUT_JDK_FILE = 'jdkFile';
exports.INPUT_CHECK_LATEST = 'check-latest';
+exports.INPUT_NUM_MVN_REPOS = 'mvn-repositories-len';
exports.INPUT_SERVER_ID = 'server-id';
exports.INPUT_SERVER_USERNAME = 'server-username';
exports.INPUT_SERVER_PASSWORD = 'server-password';
diff --git a/dist/setup/index.js b/dist/setup/index.js
index 08107f095..1c16496f0 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -113605,4454 +113605,4486 @@ module.exports = v4;
/***/ }),
-/***/ 52839:
-/***/ (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);
-
-
-/***/ }),
-
-/***/ 29267:
-/***/ (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);
-
-
-/***/ }),
-
-/***/ 58229:
-/***/ (function(module) {
+/***/ 95696:
+/***/ ((__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__(56417);
+var util_1 = __nccwpck_require__(76195);
+var util_2 = __nccwpck_require__(65282);
+var _1 = __nccwpck_require__(44260);
+var dom_1 = __nccwpck_require__(40770);
+/** @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;
+/***/ 10268:
+/***/ ((__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__(44260);
+/**
+ * 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;
+/***/ 71438:
+/***/ (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);
-
-
-/***/ }),
-
-/***/ 58376:
-/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-
-// Generated by CoffeeScript 1.12.7
-(function() {
- var NodeType, XMLAttribute, XMLNode;
-
- NodeType = __nccwpck_require__(29267);
-
- XMLNode = __nccwpck_require__(67608);
-
- 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);
-
-
-/***/ }),
-
-/***/ 90333:
-/***/ (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__(29267);
-
- XMLCharacterData = __nccwpck_require__(87709);
-
- 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);
-
-
-/***/ }),
-
-/***/ 87709:
-/***/ (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__(67608);
-
- 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__(56417);
+var util_1 = __nccwpck_require__(76195);
+var BuilderFunctions_1 = __nccwpck_require__(95696);
+var algorithm_1 = __nccwpck_require__(61);
+var infra_1 = __nccwpck_require__(84251);
+var NamespacePrefixMap_1 = __nccwpck_require__(90283);
+var LocalNameSet_1 = __nccwpck_require__(19049);
+var util_2 = __nccwpck_require__(65282);
+var XMLCBWriter_1 = __nccwpck_require__(77572);
+var JSONCBWriter_1 = __nccwpck_require__(37525);
+var YAMLCBWriter_1 = __nccwpck_require__(42444);
+var events_1 = __nccwpck_require__(82361);
+/**
+ * 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);
-
-
-/***/ }),
-
-/***/ 74407:
-/***/ (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__(29267);
-
- XMLCharacterData = __nccwpck_require__(87709);
-
- 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);
-
-
-/***/ }),
-
-/***/ 67465:
-/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-
-// Generated by CoffeeScript 1.12.7
-(function() {
- var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
-
- XMLDOMErrorHandler = __nccwpck_require__(46744);
-
- XMLDOMStringList = __nccwpck_require__(97028);
-
- 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);
-
-
-/***/ }),
-
-/***/ 46744:
-/***/ (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);
-
-
-/***/ }),
-
-/***/ 78310:
-/***/ (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);
-
-
-/***/ }),
-
-/***/ 97028:
-/***/ (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);
-
-
-/***/ }),
-
-/***/ 81015:
-/***/ (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__(67608);
-
- NodeType = __nccwpck_require__(29267);
-
- 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);
-
-
-/***/ }),
-
-/***/ 52421:
-/***/ (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__(67608);
-
- NodeType = __nccwpck_require__(29267);
-
- 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);
-
-
-/***/ }),
-
-/***/ 40053:
-/***/ (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__(58229).isObject);
-
- XMLNode = __nccwpck_require__(67608);
-
- NodeType = __nccwpck_require__(29267);
-
- 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);
-
-
-/***/ }),
-
-/***/ 82837:
-/***/ (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__(67608);
-
- NodeType = __nccwpck_require__(29267);
-
- 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);
-
-
-/***/ }),
-
-/***/ 46364:
-/***/ (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__(58229).isObject);
-
- XMLNode = __nccwpck_require__(67608);
-
- NodeType = __nccwpck_require__(29267);
-
- 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);
-
-
-/***/ }),
-
-/***/ 81801:
-/***/ (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__(58229).isObject);
-
- XMLNode = __nccwpck_require__(67608);
-
- NodeType = __nccwpck_require__(29267);
-
- XMLDTDAttList = __nccwpck_require__(81015);
-
- XMLDTDEntity = __nccwpck_require__(40053);
-
- XMLDTDElement = __nccwpck_require__(52421);
-
- XMLDTDNotation = __nccwpck_require__(82837);
-
- 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
/***/ }),
-/***/ 53730:
-/***/ (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__(58229).isPlainObject);
-
- XMLDOMImplementation = __nccwpck_require__(78310);
-
- XMLDOMConfiguration = __nccwpck_require__(67465);
-
- XMLNode = __nccwpck_require__(67608);
-
- NodeType = __nccwpck_require__(29267);
-
- XMLStringifier = __nccwpck_require__(8594);
-
- XMLStringWriter = __nccwpck_require__(85913);
+/***/ 48248:
+/***/ (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__(56417);
+var util_1 = __nccwpck_require__(76195);
+var writers_1 = __nccwpck_require__(17476);
+var interfaces_2 = __nccwpck_require__(27305);
+var util_2 = __nccwpck_require__(65282);
+var algorithm_1 = __nccwpck_require__(61);
+var dom_1 = __nccwpck_require__(40770);
+var infra_1 = __nccwpck_require__(84251);
+var readers_1 = __nccwpck_require__(90560);
+/**
+ * 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);
- }
+ // 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);
+ }
+ else {
+ // insert before document element node or append to end
+ this._doc.insertBefore(docType, this._doc.documentElement);
+ }
+ return this;
};
-
- 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;
+ /** @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);
}
- 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 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; }
+ }
}
- this.onData(chunk, this.currentLevel);
- return node.isOpen = true;
- }
+ 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);
+ }
+ }
+ 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) + '' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
- } else {
- chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
+ /** @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);
- };
-
- 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);
+ /** @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.dtd = function(root, pubID, sysID) {
- return this.doctype(root, pubID, sysID);
+ /** @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.e = function(name, attributes, text) {
- return this.element(name, attributes, text);
+ /** @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.n = function(name, attributes, text) {
- return this.node(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.t = function(value) {
- return this.text(value);
+ /** @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.d = function(value) {
- return this.cdata(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.c = function(value) {
- return this.comment(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.r = function(value) {
- return this.raw(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.i = function(target, value) {
- return this.instruction(target, value);
+ /** @inheritdoc */
+ XMLBuilderImpl.prototype.toString = function (writerOptions) {
+ writerOptions = writerOptions || {};
+ if (writerOptions.format === undefined) {
+ writerOptions.format = "xml";
+ }
+ 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.toObject = function (writerOptions) {
+ writerOptions = writerOptions || {};
+ if (writerOptions.format === undefined) {
+ writerOptions.format = "object";
+ }
+ return this._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);
- }
+ /** @inheritdoc */
+ XMLBuilderImpl.prototype.end = function (writerOptions) {
+ writerOptions = writerOptions || {};
+ if (writerOptions.format === undefined) {
+ writerOptions.format = "xml";
+ }
+ return this.doc()._serialize(writerOptions);
};
-
- 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 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.pent = function(name, value) {
- return this.pEntity(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.not = function(name, value) {
- return this.notation(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());
+ }
};
-
- return XMLDocumentCB;
-
- })();
-
-}).call(this);
-
+ /**
+ * 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
/***/ }),
-/***/ 43590:
-/***/ (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__(67608);
-
- NodeType = __nccwpck_require__(29267);
+/***/ 40770:
+/***/ ((__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__(54646);
+var dom_2 = __nccwpck_require__(50633);
+var util_1 = __nccwpck_require__(76195);
+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 '';
- };
+/***/ 44260:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
- return XMLDummy;
-
- })(XMLNode);
-
-}).call(this);
+"use strict";
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+var XMLBuilderImpl_1 = __nccwpck_require__(48248);
+exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl;
+var XMLBuilderCBImpl_1 = __nccwpck_require__(71438);
+exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl;
+var BuilderFunctions_1 = __nccwpck_require__(95696);
+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__(10268);
+exports.createCB = BuilderFunctionsCB_1.createCB;
+exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB;
+//# sourceMappingURL=index.js.map
/***/ }),
-/***/ 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__(58229), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
+/***/ 70151:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
- XMLNode = __nccwpck_require__(67608);
+"use strict";
- NodeType = __nccwpck_require__(29267);
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+var builder_1 = __nccwpck_require__(44260);
+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
- XMLAttribute = __nccwpck_require__(58376);
+/***/ }),
- XMLNamedNodeMap = __nccwpck_require__(4361);
+/***/ 56417:
+/***/ ((__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());
- }
- });
+/***/ 33396:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
- 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 }));
+var dom_1 = __nccwpck_require__(40770);
+/**
+ * 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);
+ BaseReader.prototype._element = function (parent, namespace, name) {
+ return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name));
};
-
- XMLElement.prototype.getAttribute = function(name) {
- if (this.attribs.hasOwnProperty(name)) {
- return this.attribs[name].value;
- } else {
- return null;
- }
+ BaseReader.prototype._attribute = function (parent, namespace, name, value) {
+ return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value));
};
-
- XMLElement.prototype.setAttribute = function(name, value) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
+ BaseReader.prototype._sanitize = function (str) {
+ return dom_1.sanitizeInput(str, this._builderOptions.invalidCharReplacement);
};
-
- 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);
};
-
- XMLElement.prototype.setAttributeNodeNS = function(newAttr) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
+ /**
+ * Sanitizes input strings.
+ *
+ * @param str - input string
+ */
+ BaseReader.prototype.sanitize = function (str) {
+ return this._sanitize(str);
};
+ return BaseReader;
+}());
+exports.BaseReader = BaseReader;
+//# sourceMappingURL=BaseReader.js.map
- 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);
- };
+/***/ 43518:
+/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
- XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- };
+"use strict";
- XMLElement.prototype.setIdAttribute = function(name, isId) {
- if (this.attribs.hasOwnProperty(name)) {
- return this.attribs[name].isId;
- } else {
- return isId;
- }
+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.setIdAttributeNS = function(namespaceURI, localName, isId) {
- 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.setIdAttributeNode = function(idAttr, isId) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
+})();
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+var ObjectReader_1 = __nccwpck_require__(40768);
+var BaseReader_1 = __nccwpck_require__(33396);
+/**
+ * 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.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());
- };
+/***/ 40768:
+/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
- XMLElement.prototype.getElementsByClassName = function(classNames) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- };
+"use strict";
- 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;
+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__(76195);
+var BaseReader_1 = __nccwpck_require__(33396);
+/**
+ * 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;
+ var lastChild = null;
+ if (util_1.isFunction(obj)) {
+ // evaluate if function
+ lastChild = this.parse(node, obj.apply(this));
}
- }
- return true;
+ 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, _this.sanitize(attrKey), _this.sanitize(attrVal)) || lastChild;
+ });
+ }
+ }
+ else {
+ lastChild = _this.attribute(node, undefined, _this.sanitize(key.substr(options.convert.att.length)), _this.sanitize(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, _this.sanitize(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, _this.sanitize(item)) || lastChild; }, _this);
+ }
+ else {
+ lastChild = _this.cdata(node, _this.sanitize(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, _this.sanitize(item)) || lastChild; }, _this);
+ }
+ else {
+ lastChild = _this.comment(node, _this.sanitize(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, _this.sanitize(insTarget), _this.sanitize(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, _this.sanitize(insTarget), _this.sanitize(insValue)) || lastChild;
+ }, _this);
+ }
+ else /* if (isMap(target) || isObject(target)) */ {
+ util_1.forEachObject(val, function (insTarget, insValue) { return lastChild = _this.instruction(node, _this.sanitize(insTarget), _this.sanitize(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, _this.sanitize(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, _this.sanitize(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, _this.sanitize(key));
+ if (parent) {
+ lastChild = parent;
+ _this.text(parent, _this.sanitize(val));
+ }
+ }
+ else {
+ // leaf element node
+ lastChild = _this.element(node, undefined, _this.sanitize(key)) || lastChild;
+ }
+ }, this);
+ }
+ return lastChild || node;
};
-
- return XMLElement;
-
- })(XMLNode);
-
-}).call(this);
-
+ return ObjectReader;
+}(BaseReader_1.BaseReader));
+exports.ObjectReader = ObjectReader;
+//# sourceMappingURL=ObjectReader.js.map
/***/ }),
-/***/ 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;
- };
+/***/ 65044:
+/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
- XMLNamedNodeMap.prototype.getNamedItem = function(name) {
- return this.nodes[name];
- };
+"use strict";
- XMLNamedNodeMap.prototype.setNamedItem = function(node) {
- var oldNode;
- oldNode = this.nodes[node.nodeName];
- this.nodes[node.nodeName] = node;
- return oldNode || 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);
};
-
- XMLNamedNodeMap.prototype.removeNamedItem = function(name) {
- var oldNode;
- oldNode = this.nodes[name];
- delete this.nodes[name];
- return oldNode || null;
+ return function (d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
-
- XMLNamedNodeMap.prototype.item = function(index) {
- return this.nodes[Object.keys(this.nodes)[index]] || null;
+})();
+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 };
+ }
};
-
- XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented.");
- };
-
- XMLNamedNodeMap.prototype.setNamedItemNS = function(node) {
- throw new Error("This DOM method is not implemented.");
- };
-
- XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented.");
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
+};
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+var XMLStringLexer_1 = __nccwpck_require__(47061);
+var interfaces_1 = __nccwpck_require__(97707);
+var infra_1 = __nccwpck_require__(84251);
+var algorithm_1 = __nccwpck_require__(61);
+var BaseReader_1 = __nccwpck_require__(33396);
+/**
+ * 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 });
+ 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 = this.sanitize(declaration.version);
+ if (version !== "1.0") {
+ throw new Error("Invalid xml version: " + version);
+ }
+ var builderOptions = {
+ version: version
+ };
+ if (declaration.encoding) {
+ builderOptions.encoding = this.sanitize(declaration.encoding);
+ }
+ if (declaration.standalone) {
+ builderOptions.standalone = (this.sanitize(declaration.standalone) === "yes");
+ }
+ context.set(builderOptions);
+ break;
+ case interfaces_1.TokenType.DocType:
+ var doctype = token;
+ context = this.docType(context, this.sanitize(doctype.name), this.sanitize(doctype.pubId), this.sanitize(doctype.sysId)) || context;
+ break;
+ case interfaces_1.TokenType.CDATA:
+ var cdata = token;
+ context = this.cdata(context, this.sanitize(cdata.data)) || context;
+ break;
+ case interfaces_1.TokenType.Comment:
+ var comment = token;
+ context = this.comment(context, this.sanitize(comment.data)) || context;
+ break;
+ case interfaces_1.TokenType.PI:
+ var pi = token;
+ context = this.instruction(context, this.sanitize(pi.target), this.sanitize(pi.data)) || context;
+ break;
+ case interfaces_1.TokenType.Text:
+ var text = token;
+ context = this.text(context, this.sanitize(text.data)) || context;
+ break;
+ case interfaces_1.TokenType.Element:
+ var element = token;
+ var elementName = this.sanitize(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 = this.sanitize(attName);
+ attValue = this.sanitize(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 = this.sanitize(attName);
+ attValue = this.sanitize(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 XMLNamedNodeMap;
-
- })();
-
-}).call(this);
-
+ return XMLReader;
+}(BaseReader_1.BaseReader));
+exports.XMLReader = XMLReader;
+//# sourceMappingURL=XMLReader.js.map
/***/ }),
-/***/ 67608:
-/***/ (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;
+/***/ 12475:
+/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
- ref1 = __nccwpck_require__(58229), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
+"use strict";
- XMLElement = 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__(40768);
+var BaseReader_1 = __nccwpck_require__(33396);
+var js_yaml_1 = __nccwpck_require__(10829);
+/**
+ * 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
- XMLCData = null;
+/***/ }),
- XMLComment = null;
+/***/ 90560:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
- XMLDeclaration = null;
+"use strict";
- XMLDocType = null;
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+var XMLReader_1 = __nccwpck_require__(65044);
+exports.XMLReader = XMLReader_1.XMLReader;
+var ObjectReader_1 = __nccwpck_require__(40768);
+exports.ObjectReader = ObjectReader_1.ObjectReader;
+var JSONReader_1 = __nccwpck_require__(43518);
+exports.JSONReader = JSONReader_1.JSONReader;
+var YAMLReader_1 = __nccwpck_require__(12475);
+exports.YAMLReader = YAMLReader_1.YAMLReader;
+//# sourceMappingURL=index.js.map
- XMLRaw = null;
+/***/ }),
- XMLText = null;
+/***/ 50708:
+/***/ ((__unused_webpack_module, exports) => {
- XMLProcessingInstruction = null;
+"use strict";
- 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__(90333);
- XMLComment = __nccwpck_require__(74407);
- XMLDeclaration = __nccwpck_require__(46364);
- XMLDocType = __nccwpck_require__(81801);
- XMLRaw = __nccwpck_require__(16329);
- XMLText = __nccwpck_require__(21318);
- XMLProcessingInstruction = __nccwpck_require__(56939);
- XMLDummy = __nccwpck_require__(43590);
- NodeType = __nccwpck_require__(29267);
- XMLNodeList = __nccwpck_require__(36768);
- XMLNamedNodeMap = __nccwpck_require__(4361);
- DocumentPosition = __nccwpck_require__(52839);
- }
+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, '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(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;
- }
- });
+/***/ 37644:
+/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
- Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
- get: function() {
- return this.document() || null;
- }
- });
+"use strict";
- 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;
+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 };
}
- },
- 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;
};
-
- 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);
+ 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__(27305);
+var LocalNameSet_1 = __nccwpck_require__(19049);
+var NamespacePrefixMap_1 = __nccwpck_require__(90283);
+var infra_1 = __nccwpck_require__(84251);
+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; }
}
- }
- 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);
+ /**
+ * 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);
}
- return newChild;
- } else {
- if (this.isRoot) {
- throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
+ else {
+ this._serializeNode(node, requireWellFormed, noDoubleEncoding);
}
- 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;
+ /**
+ * 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.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);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- 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;
- }
- }
- ref3 = doc.children;
- for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
- child = ref3[i];
- if (child.isRoot) {
- doc.children.splice(i, 0, doctype);
- return doctype;
- }
- }
- doc.children.push(doctype);
- return doctype;
- };
-
- 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 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.document = function() {
- var node;
- node = this;
- while (node) {
- if (node.type === NodeType.Document) {
- return node;
- } else {
- node = node.parent;
+ /**
+ * 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).");
}
- }
- };
-
- 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;
+ /**
+ * 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 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;
+ 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);
+ }
}
- isDescendantChild = child.isDescendant(node);
- if (isDescendantChild) {
- return true;
+ /**
+ * 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;
}
- }
- 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;
+ else if (!isHTML && node.childNodes.length === 0) {
+ this.openTagEnd(qualifiedName, true, false);
+ this.endElement(qualifiedName);
+ skipEndTag = true;
}
- });
- if (found) {
- return pos;
- } else {
- return -1;
- }
+ 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+003C LESS-THAN SIGN, U+002F SOLIDUS);
+ * 20.2. The value of qualified name;
+ * 20.3. ">" (U+003E GREATER-THAN SIGN).
+ * 21. Return the value of markup.
+ */
+ this.closeTag(qualifiedName);
+ this.endElement(qualifiedName);
};
-
- 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 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+003C LESS-THAN SIGN, U+002F SOLIDUS);
+ * 20.2. The value of qualified name;
+ * 20.3. ">" (U+003E GREATER-THAN SIGN).
+ * 21. Return the value of markup.
+ */
+ this.closeTag(qualifiedName);
+ this.endElement(qualifiedName);
};
-
- return XMLNode;
-
- })();
-
-}).call(this);
-
-
-/***/ }),
-
-/***/ 36768:
-/***/ (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 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; }
+ }
};
-
- return XMLNodeList;
-
- })();
-
-}).call(this);
-
-
-/***/ }),
-
-/***/ 56939:
-/***/ (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__(29267);
-
- XMLCharacterData = __nccwpck_require__(87709);
-
- 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 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; }
+ }
};
-
- XMLProcessingInstruction.prototype.toString = function(options) {
- return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
+ /**
+ * 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);
};
-
- 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 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 XMLProcessingInstruction;
-
- })(XMLCharacterData);
-
-}).call(this);
-
-
-/***/ }),
-
-/***/ 16329:
-/***/ (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__(29267);
-
- XMLNode = __nccwpck_require__(67608);
-
- 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);
-
-
-/***/ }),
-
-/***/ 78601:
-/***/ (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__(29267);
-
- XMLWriterBase = __nccwpck_require__(66752);
-
- 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));
- };
-
- 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 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; }
}
- 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('' + node.name + '>');
- } else {
- options.state = WriterState.CloseTag;
- this.stream.write(options.spaceBeforeSlash + '/>');
+ /**
+ * 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);
+ }
}
- } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
- this.stream.write('>');
- options.state = WriterState.InsideTag;
- options.suppressPrettyCount++;
- prettySuppressed = true;
- this.writeChildNode(firstChildNode, options, level + 1);
- options.suppressPrettyCount--;
- prettySuppressed = false;
- options.state = WriterState.CloseTag;
- this.stream.write('' + node.name + '>');
- } else {
- this.stream.write('>' + this.endline(node, options, level));
- options.state = WriterState.InsideTag;
- ref1 = node.children;
- for (j = 0, len = ref1.length; j < len; j++) {
- child = ref1[j];
- this.writeChildNode(child, options, level + 1);
+ 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(this.indent(node, options, level) + '' + node.name + '>');
- }
- this.stream.write(this.endline(node, options, level));
- options.state = WriterState.None;
- return this.closeNode(node, options, level);
- };
-
- 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);
-
-
-/***/ }),
-
-/***/ 85913:
-/***/ (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__(66752);
-
- 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 || ''));
+ /**
+ * 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);
};
-
- XMLStringifier.prototype.insTarget = function(val) {
- if (this.options.noValidation) {
- return 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+003C LESS-THAN SIGN, U+003F QUESTION MARK);
+ * 3.2. The value of node's target;
+ * 3.3. " " (U+0020 SPACE);
+ * 3.4. The value of node's data;
+ * 3.5. "?>" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN).
+ * 4. Return the value of markup.
+ */
+ this.instruction(node.target, node.data);
};
-
- 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);
+ /**
+ * 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.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);
- };
-
- XMLStringifier.prototype.xmlStandalone = function(val) {
- if (this.options.noValidation) {
- return val;
- }
- if (val) {
- return "yes";
- } else {
- return "no";
- }
- };
-
- 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 || '');
+ /**
+ * 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.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 || '');
- };
-
- 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);
- }
- } 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;
- };
-
- 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, '
');
- };
-
- 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;
+ }
+ };
+ 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
/***/ }),
-/***/ 66752:
-/***/ (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__(58229).assign);
-
- NodeType = __nccwpck_require__(29267);
-
- XMLDeclaration = __nccwpck_require__(46364);
-
- XMLDocType = __nccwpck_require__(81801);
-
- XMLCData = __nccwpck_require__(90333);
-
- XMLComment = __nccwpck_require__(74407);
-
- XMLElement = __nccwpck_require__(9437);
-
- XMLRaw = __nccwpck_require__(16329);
-
- XMLText = __nccwpck_require__(21318);
-
- XMLProcessingInstruction = __nccwpck_require__(56939);
-
- XMLDummy = __nccwpck_require__(43590);
-
- XMLDTDAttList = __nccwpck_require__(81015);
-
- XMLDTDElement = __nccwpck_require__(52421);
-
- XMLDTDEntity = __nccwpck_require__(40053);
-
- XMLDTDNotation = __nccwpck_require__(82837);
+/***/ 37525:
+/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
- WriterState = __nccwpck_require__(9766);
+"use strict";
- 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;
- }
+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__(50708);
+/**
+ * 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;
}
-
- 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.frontMatter = function () {
+ return "";
};
-
- 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.declaration = function (version, encoding, standalone) {
+ return "";
};
-
- XMLWriterBase.prototype.endline = function(node, options, level) {
- if (!options.pretty || options.suppressPrettyCount) {
- return '';
- } else {
- return options.newline;
- }
+ /** @inheritdoc */
+ JSONCBWriter.prototype.docType = function (name, publicId, systemId) {
+ return "";
};
-
- 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.comment = function (data) {
+ // { "!": "hello" }
+ return this._comma() + this._beginLine() + "{" + this._sep() +
+ this._key(this._builderOptions.convert.comment) + this._sep() +
+ this._val(data) + 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.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.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.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.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.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.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;
+ /** @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.element = function(node, options, level) {
- var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
- level || (level = 0);
- prettySuppressed = false;
- r = '';
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r += this.indent(node, options, level) + '<' + node.name;
- ref = node.attribs;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- r += this.attribute(att, options, level);
- }
- childNodeCount = node.children.length;
- firstChildNode = childNodeCount === 0 ? null : node.children[0];
- if (childNodeCount === 0 || node.children.every(function(e) {
- return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
- })) {
- if (options.allowEmpty) {
- r += '>';
- options.state = WriterState.CloseTag;
- r += '' + node.name + '>' + this.endline(node, options, level);
- } else {
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
+ /** @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;
+ };
+ /** @inheritdoc */
+ JSONCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) {
+ if (selfClosing) {
+ var str = this._sep() + "]";
+ this._additionalLevel--;
+ str += this._beginLine() + "}" + this._sep() + "}";
+ return str;
}
- } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
- r += '>';
- options.state = WriterState.InsideTag;
- options.suppressPrettyCount++;
- prettySuppressed = true;
- r += this.writeChildNode(firstChildNode, options, level + 1);
- options.suppressPrettyCount--;
- prettySuppressed = false;
- options.state = WriterState.CloseTag;
- r += '' + node.name + '>' + this.endline(node, options, level);
- } else {
- if (options.dontPrettyTextNodes) {
- ref1 = node.children;
- for (i = 0, len = ref1.length; i < len; i++) {
- child = ref1[i];
- if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) {
- options.suppressPrettyCount++;
- prettySuppressed = true;
- break;
- }
- }
+ else {
+ return "";
}
- 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);
+ };
+ /** @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);
}
- options.state = WriterState.CloseTag;
- r += this.indent(node, options, level) + '' + node.name + '>';
- if (prettySuppressed) {
- options.suppressPrettyCount--;
+ else {
+ return "";
}
- 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);
- }
};
-
- XMLWriterBase.prototype.processingInstruction = function(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '';
- options.state = WriterState.InsideTag;
- r += node.target;
- if (node.value) {
- r += ' ' + node.value;
- }
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '?>';
- r += this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
+ /**
+ * 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);
+ }
};
-
- 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 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;
};
-
- 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 separator string.
+ */
+ JSONCBWriter.prototype._sep = function () {
+ return (this._writerOptions.prettyPrint ? " " : "");
};
-
- 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 JSON key string delimited with double quotes.
+ */
+ JSONCBWriter.prototype._key = function (key) {
+ return "\"" + key + "\":";
};
-
- 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 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.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;
- };
+/***/ 37510:
+/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
- 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);
-
-
-/***/ }),
-
-/***/ 52958:
-/***/ (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__(58229), assign = ref.assign, isFunction = ref.isFunction;
-
- XMLDOMImplementation = __nccwpck_require__(78310);
-
- XMLDocument = __nccwpck_require__(53730);
-
- XMLDocumentCB = __nccwpck_require__(77356);
-
- XMLStringWriter = __nccwpck_require__(85913);
-
- XMLStreamWriter = __nccwpck_require__(78601);
-
- NodeType = __nccwpck_require__(29267);
-
- 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);
-
-
-/***/ }),
-
-/***/ 95696:
-/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-var interfaces_1 = __nccwpck_require__(56417);
-var util_1 = __nccwpck_require__(76195);
-var util_2 = __nccwpck_require__(65282);
-var _1 = __nccwpck_require__(44260);
-var dom_1 = __nccwpck_require__(40770);
-/** @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
-
-/***/ }),
-
-/***/ 10268:
-/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-var _1 = __nccwpck_require__(44260);
-/**
- * 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
-
-/***/ }),
-
-/***/ 71438:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
-
-"use strict";
+"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
@@ -118078,10082 +118110,10050 @@ 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__(56417);
+var ObjectWriter_1 = __nccwpck_require__(50243);
var util_1 = __nccwpck_require__(76195);
-var BuilderFunctions_1 = __nccwpck_require__(95696);
-var algorithm_1 = __nccwpck_require__(61);
-var infra_1 = __nccwpck_require__(84251);
-var NamespacePrefixMap_1 = __nccwpck_require__(90283);
-var LocalNameSet_1 = __nccwpck_require__(19049);
-var util_2 = __nccwpck_require__(65282);
-var XMLCBWriter_1 = __nccwpck_require__(77572);
-var JSONCBWriter_1 = __nccwpck_require__(37525);
-var YAMLCBWriter_1 = __nccwpck_require__(42444);
-var events_1 = __nccwpck_require__(82361);
+var BaseWriter_1 = __nccwpck_require__(37644);
/**
- * Represents a readable XML document stream.
+ * Serializes XML nodes into a JSON string.
*/
-var XMLBuilderCBImpl = /** @class */ (function (_super) {
- __extends(XMLBuilderCBImpl, _super);
+var JSONWriter = /** @class */ (function (_super) {
+ __extends(JSONWriter, _super);
/**
- * Initializes a new instance of `XMLStream`.
- *
- * @param options - stream writer options
- * @param fragment - whether to create fragment stream or a document stream
+ * 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);
+ }
}
- return this;
+ return '';
};
- /** @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;
+ /**
+ * 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 (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;
+ else {
+ return options.newline;
}
- this._push(this._writer.comment(node.data));
- return this;
};
- /** @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;
- };
- /** @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;
+ /**
+ * Produces a JSON key string delimited with double quotes.
+ */
+ JSONWriter.prototype._key = function (key) {
+ return "\"" + key + "\":";
};
- /** @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;
+ /**
+ * Produces a JSON value string delimited with double quotes.
+ */
+ JSONWriter.prototype._val = function (val) {
+ return JSON.stringify(val);
};
- /** @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;
+ /**
+ * Determines if an object is a leaf node.
+ *
+ * @param obj
+ */
+ JSONWriter.prototype._isLeafNode = function (obj) {
+ return this._descendantCount(obj) <= 1;
};
- /** @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;
+ /**
+ * 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);
}
- 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;
+ else if (util_1.isObject(obj)) {
+ util_1.forEachObject(obj, function (key, val) { return count += _this._descendantCount(val, count); }, 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;
+ else {
+ count++;
}
- this._docTypeName = options.name;
- this._push(this._writer.docType(options.name, node.publicId, node.systemId));
- return this;
+ return count;
};
- /** @inheritdoc */
- XMLBuilderCBImpl.prototype.up = function () {
- this._serializeOpenTag(false);
- this._serializeCloseTag();
- return this;
+ return JSONWriter;
+}(BaseWriter_1.BaseWriter));
+exports.JSONWriter = JSONWriter;
+//# sourceMappingURL=JSONWriter.js.map
+
+/***/ }),
+
+/***/ 41397:
+/***/ (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.end = function () {
- this._serializeOpenTag(false);
- while (this._openTags.length > 0) {
- this._serializeCloseTag();
- }
- this._push(null);
- return this;
+ 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__(76195);
+var ObjectWriter_1 = __nccwpck_require__(50243);
+var BaseWriter_1 = __nccwpck_require__(37644);
+/**
+ * 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);
};
/**
- * Serializes the opening tag of an element node.
+ * Recursively converts a JS object into an ES5 map.
*
- * @param hasChildren - whether the element node has child nodes
+ * @param obj - a JS object
*/
- 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;
+ 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;
}
- 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));
+ else if (util_1.isObject(obj)) {
+ var map = new Map();
+ for (var key in obj) {
+ map.set(key, this._convertObject(obj[key]));
}
- }
- 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);
+ return map;
}
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;
+ return obj;
}
- /**
- * Calls following this will either serialize child nodes or close this tag.
- */
- this._writer.level++;
};
- /**
- * 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 MapWriter;
+}(BaseWriter_1.BaseWriter));
+exports.MapWriter = MapWriter;
+//# sourceMappingURL=MapWriter.js.map
+
+/***/ }),
+
+/***/ 50243:
+/***/ (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);
};
- /**
- * 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 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__(76195);
+var interfaces_1 = __nccwpck_require__(27305);
+var BaseWriter_1 = __nccwpck_require__(37644);
+/**
+ * Serializes XML nodes into objects and arrays.
+ */
+var ObjectWriter = /** @class */ (function (_super) {
+ __extends(ObjectWriter, _super);
/**
- * Reads and serializes an XML tree.
+ * Initializes a new instance of `ObjectWriter`.
*
- * @param node - root node
+ * @param builderOptions - XML builder options
+ * @param writerOptions - serialization options
*/
- 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);
- }
- };
+ 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 attributes of an element node.
+ * Produces an XML serialization of the given 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)));
+ 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;
- }
- 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.
- */
+ case "#":
+ textCount++;
+ break;
+ case "!":
+ commentCount++;
+ break;
+ case "?":
+ instructionCount++;
+ break;
+ case "$":
+ cdataCount++;
+ break;
+ default:
+ if (namesSeen[key]) {
+ hasNonUniqueNames = true;
}
- 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)));
+ else {
+ namesSeen[key] = true;
}
- }
- 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);
+ break;
}
- 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;
+ 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]["#"];
}
- };
- /**
- * 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 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 {
- 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 || '';
+ 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;
}
- 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;
};
- /**
- * 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;
+ 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;
};
- /**
- * 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;
+ /** @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));
}
}
- if (nullItems1.length !== nullItems2.length)
- return true;
- for (var i = 0; i < nullItems1.length; i++) {
- if (nullItems1[i] !== nullItems2[i])
- return true;
+ this._currentIndex++;
+ if (this._listRegister.length > this._currentIndex) {
+ this._listRegister[this._currentIndex] = childItems;
}
- return false;
+ else {
+ this._listRegister.push(childItems);
+ }
+ this._currentList = childItems;
};
- 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
-
-/***/ }),
-
-/***/ 48248:
-/***/ (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);
+ /** @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) });
}
- 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 };
+ 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) });
+ }
}
};
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
-};
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-var interfaces_1 = __nccwpck_require__(56417);
-var util_1 = __nccwpck_require__(76195);
-var writers_1 = __nccwpck_require__(17476);
-var interfaces_2 = __nccwpck_require__(27305);
-var util_2 = __nccwpck_require__(65282);
-var algorithm_1 = __nccwpck_require__(61);
-var dom_1 = __nccwpck_require__(40770);
-var infra_1 = __nccwpck_require__(84251);
-var readers_1 = __nccwpck_require__(90560);
-/**
- * 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(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;
- };
/** @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 */
- XMLBuilderImpl.prototype.txt = function (content) {
- if (content === null || content === undefined) {
- if (this._options.keepNullNodes) {
- // keep null nodes
- content = "";
- }
- else {
- // skip null|undefined nodes
- return this;
- }
+ XMLCBWriter.prototype.docType = function (name, publicId, systemId) {
+ var markup = this._beginLine();
+ if (publicId && systemId) {
+ markup += "";
}
- var child = this._doc.createTextNode(dom_1.sanitizeInput(content, this._options.invalidCharReplacement));
- this.node.appendChild(child);
- return this;
+ else if (publicId) {
+ markup += "";
+ }
+ else if (systemId) {
+ markup += "";
+ }
+ else {
+ markup += "";
+ }
+ return markup;
};
/** @inheritdoc */
- XMLBuilderImpl.prototype.com = function (content) {
- if (content === null || content === undefined) {
- if (this._options.keepNullNodes) {
- // keep null nodes
- content = "";
- }
- else {
- // skip null|undefined nodes
- return this;
- }
- }
- var child = this._doc.createComment(dom_1.sanitizeInput(content, this._options.invalidCharReplacement));
- this.node.appendChild(child);
- return this;
+ XMLCBWriter.prototype.comment = function (data) {
+ return this._beginLine() + "";
};
/** @inheritdoc */
- XMLBuilderImpl.prototype.dat = function (content) {
- if (content === null || content === undefined) {
- if (this._options.keepNullNodes) {
- // keep null nodes
- content = "";
- }
- else {
- // skip null|undefined nodes
- return this;
- }
+ XMLCBWriter.prototype.text = function (data) {
+ return this._beginLine() + data;
+ };
+ /** @inheritdoc */
+ XMLCBWriter.prototype.instruction = function (target, data) {
+ if (data) {
+ return this._beginLine() + "" + target + " " + data + "?>";
+ }
+ else {
+ return this._beginLine() + "" + target + "?>";
}
- var child = this._doc.createCDATASection(dom_1.sanitizeInput(content, this._options.invalidCharReplacement));
- this.node.appendChild(child);
- return this;
};
/** @inheritdoc */
- XMLBuilderImpl.prototype.ins = function (target, content) {
- var _this = this;
- if (content === void 0) { content = ''; }
- if (content === null || content === undefined) {
- if (this._options.keepNullNodes) {
- // keep null nodes
- content = "";
+ 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 " />";
+ }
+ else if (selfClosing) {
+ if (this._writerOptions.allowEmptyTags) {
+ return ">" + name + ">";
+ }
+ else if (this._writerOptions.spaceBeforeSlash) {
+ return " />";
}
else {
- // skip null|undefined nodes
- return this;
+ return "/>";
}
}
- 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 ">";
}
- 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;
+ XMLCBWriter.prototype.closeTag = function (name) {
+ return this._beginLine() + "" + name + ">";
};
/** @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.");
- }
- // 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);
+ 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 {
- // insert before document element node or append to end
- this._doc.insertBefore(docType, this._doc.documentElement);
+ this._lineLength += 1 + str.length;
+ return " " + str;
}
- return this;
};
/** @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; }
- }
+ 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 {
- // 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);
- }
+ return "";
}
- return this;
};
- /** @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);
+ /**
+ * Produces an indentation string.
+ *
+ * @param level - depth of the tree
+ */
+ XMLCBWriter.prototype._indent = function (level) {
+ if (level <= 0) {
+ return "";
}
else {
- return new XMLBuilderImpl(this._doc);
+ return this._writerOptions.indent.repeat(level);
}
};
- /** @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);
+ return XMLCBWriter;
+}(BaseCBWriter_1.BaseCBWriter));
+exports.XMLCBWriter = XMLCBWriter;
+//# sourceMappingURL=XMLCBWriter.js.map
+
+/***/ }),
+
+/***/ 59606:
+/***/ (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 */
- XMLBuilderImpl.prototype.up = function () {
- var parent = this._domNode.parentNode;
- if (!parent) {
- throw new Error("Parent node is null. " + this._debugInfo());
- }
- return new XMLBuilderImpl(parent);
+ return function (d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
- /** @inheritdoc */
- XMLBuilderImpl.prototype.prev = function () {
- var node = this._domNode.previousSibling;
- if (!node) {
- throw new Error("Previous sibling node is null. " + this._debugInfo());
+})();
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+var util_1 = __nccwpck_require__(76195);
+var interfaces_1 = __nccwpck_require__(27305);
+var BaseWriter_1 = __nccwpck_require__(37644);
+var util_2 = __nccwpck_require__(65282);
+/**
+ * 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);
}
- return new XMLBuilderImpl(node);
- };
- /** @inheritdoc */
- XMLBuilderImpl.prototype.next = function () {
- var node = this._domNode.nextSibling;
- if (!node) {
- throw new Error("Next sibling node is null. " + this._debugInfo());
+ // 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 new XMLBuilderImpl(node);
+ return this._refs.markup;
};
/** @inheritdoc */
- XMLBuilderImpl.prototype.first = function () {
- var node = this._domNode.firstChild;
- if (!node) {
- throw new Error("First child node is null. " + this._debugInfo());
+ XMLWriter.prototype.declaration = function (version, encoding, standalone) {
+ this._beginLine();
+ this._refs.markup += "";
+ this._endLine();
};
/** @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;
+ XMLWriter.prototype.docType = function (name, publicId, systemId) {
+ this._beginLine();
+ if (publicId && systemId) {
+ this._refs.markup += "";
}
- 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;
+ else if (publicId) {
+ this._refs.markup += "";
+ }
+ else if (systemId) {
+ this._refs.markup += "";
+ }
+ else {
+ this._refs.markup += "";
+ }
+ this._endLine();
};
/** @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;
+ XMLWriter.prototype.openTagBegin = function (name) {
+ this._beginLine();
+ this._refs.markup += "<" + name;
};
/** @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;
+ 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;
}
- result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]);
+ this._refs.suppressPretty = !this._writerOptions.indentTextOnlyNodes && textOnlyNode && ((cdataCount <= 1 && textCount === 0) || cdataCount === 0);
+ this._refs.emptyNode = emptyNode;
}
- return undefined;
- };
- /** @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;
+ if ((voidElement || selfClosing || this._refs.emptyNode) && this._writerOptions.allowEmptyTags) {
+ this._refs.markup += ">" + name + ">";
+ }
+ else {
+ this._refs.markup += voidElement ? " />" :
+ (selfClosing || this._refs.emptyNode) ? (this._writerOptions.spaceBeforeSlash ? " />" : "/>") : ">";
+ }
+ this._endLine();
};
/** @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]);
+ XMLWriter.prototype.closeTag = function (name) {
+ if (!this._refs.emptyNode) {
+ this._beginLine();
+ this._refs.markup += "" + name + ">";
}
- return true;
+ this._refs.suppressPretty = false;
+ this._refs.emptyNode = false;
+ this._endLine();
};
/** @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]);
+ 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;
}
- 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;
+ XMLWriter.prototype.text = function (data) {
+ if (data !== '') {
+ this._beginLine();
+ this._refs.markup += data;
+ this._endLine();
+ }
};
/** @inheritdoc */
- XMLBuilderImpl.prototype.toString = function (writerOptions) {
- writerOptions = writerOptions || {};
- if (writerOptions.format === undefined) {
- writerOptions.format = "xml";
+ XMLWriter.prototype.cdata = function (data) {
+ if (data !== '') {
+ this._beginLine();
+ this._refs.markup += "";
+ this._endLine();
}
- return this._serialize(writerOptions);
};
/** @inheritdoc */
- XMLBuilderImpl.prototype.toObject = function (writerOptions) {
- writerOptions = writerOptions || {};
- if (writerOptions.format === undefined) {
- writerOptions.format = "object";
- }
- return this._serialize(writerOptions);
+ XMLWriter.prototype.comment = function (data) {
+ this._beginLine();
+ this._refs.markup += "";
+ this._endLine();
};
/** @inheritdoc */
- XMLBuilderImpl.prototype.end = function (writerOptions) {
- writerOptions = writerOptions || {};
- if (writerOptions.format === undefined) {
- writerOptions.format = "xml";
+ XMLWriter.prototype.instruction = function (target, data) {
+ this._beginLine();
+ this._refs.markup += "" + (data === "" ? target : target + " " + data) + "?>";
+ this._endLine();
+ };
+ /**
+ * 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 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
+ * Produces characters to be appended 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];
+ XMLWriter.prototype._endLine = function () {
+ if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) {
+ this._refs.markup += this._writerOptions.newline;
+ this._lengthToLastNewline = this._refs.markup.length;
+ }
};
/**
- * 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
*/
- 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--;
- }
+ XMLWriter.prototype._indent = function (level) {
+ if (level <= 0) {
+ return "";
+ }
+ else if (this._indentation[level] !== undefined) {
+ return this._indentation[level];
}
else {
- if (root === node)
- return [node.firstChild, 0, level + 1];
- else
- return [node.nextSibling, index + 1, level];
+ var str = this._writerOptions.indent.repeat(level);
+ this._indentation[level] = str;
+ return str;
}
- return [null, -1, -1];
};
+ return XMLWriter;
+}(BaseWriter_1.BaseWriter));
+exports.XMLWriter = XMLWriter;
+//# sourceMappingURL=XMLWriter.js.map
+
+/***/ }),
+
+/***/ 42444:
+/***/ (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__(50708);
+/**
+ * Serializes XML nodes.
+ */
+var YAMLCBWriter = /** @class */ (function (_super) {
+ __extends(YAMLCBWriter, _super);
/**
- * Converts the node into its string or object representation.
+ * Initializes a new instance of `BaseCBWriter`.
*
- * @param options - serialization options
+ * @param builderOptions - XML builder options
*/
- XMLBuilderImpl.prototype._serialize = function (writerOptions) {
- if (writerOptions.format === "xml") {
- var writer = new writers_1.XMLWriter(this._options, writerOptions);
- return writer.serialize(this.node);
+ 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 (writerOptions.format === "map") {
- var writer = new writers_1.MapWriter(this._options, writerOptions);
- return writer.serialize(this.node);
+ if (builderOptions.offset < 0) {
+ throw new Error("YAML offset should be zero or a positive number.");
}
- else if (writerOptions.format === "object") {
- var writer = new writers_1.ObjectWriter(this._options, writerOptions);
- return writer.serialize(this.node);
+ 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;
}
- else if (writerOptions.format === "json") {
- var writer = new writers_1.JSONWriter(this._options, writerOptions);
- return writer.serialize(this.node);
+ 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("");
}
- else if (writerOptions.format === "yaml") {
- var writer = new writers_1.YAMLWriter(this._options, writerOptions);
- return writer.serialize(this.node);
+ 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 {
- throw new Error("Invalid writer format: " + writerOptions.format + ". " + this._debugInfo());
+ 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;
}
};
/**
- * Extracts a namespace and name from the given string.
+ * 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
+
+/***/ }),
+
+/***/ 96517:
+/***/ (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__(50243);
+var util_1 = __nccwpck_require__(76195);
+var BaseWriter_1 = __nccwpck_require__(37644);
+/**
+ * Serializes XML nodes into a YAML string.
+ */
+var YAMLWriter = /** @class */ (function (_super) {
+ __extends(YAMLWriter, _super);
+ /**
+ * 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
/***/ }),
-/***/ 40770:
+/***/ 17476:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
-var dom_1 = __nccwpck_require__(54646);
-var dom_2 = __nccwpck_require__(50633);
-var util_1 = __nccwpck_require__(76195);
-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__(41397);
+exports.MapWriter = MapWriter_1.MapWriter;
+var XMLWriter_1 = __nccwpck_require__(59606);
+exports.XMLWriter = XMLWriter_1.XMLWriter;
+var ObjectWriter_1 = __nccwpck_require__(50243);
+exports.ObjectWriter = ObjectWriter_1.ObjectWriter;
+var JSONWriter_1 = __nccwpck_require__(37510);
+exports.JSONWriter = JSONWriter_1.JSONWriter;
+var YAMLWriter_1 = __nccwpck_require__(96517);
+exports.YAMLWriter = YAMLWriter_1.YAMLWriter;
+//# sourceMappingURL=index.js.map
/***/ }),
-/***/ 44260:
-/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+/***/ 10829:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-var XMLBuilderImpl_1 = __nccwpck_require__(48248);
-exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl;
-var XMLBuilderCBImpl_1 = __nccwpck_require__(71438);
-exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl;
-var BuilderFunctions_1 = __nccwpck_require__(95696);
-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__(10268);
-exports.createCB = BuilderFunctionsCB_1.createCB;
-exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB;
-//# sourceMappingURL=index.js.map
+
+
+var yaml = __nccwpck_require__(59625);
+
+
+module.exports = yaml;
+
/***/ }),
-/***/ 70151:
-/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+/***/ 59625:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-var builder_1 = __nccwpck_require__(44260);
-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
+
+
+var loader = __nccwpck_require__(40342);
+var dumper = __nccwpck_require__(98069);
+
+
+function deprecated(name) {
+ return function () {
+ throw new Error('Function ' + name + ' is deprecated and cannot be used.');
+ };
+}
+
+
+module.exports.Type = __nccwpck_require__(90256);
+module.exports.Schema = __nccwpck_require__(66280);
+module.exports.FAILSAFE_SCHEMA = __nccwpck_require__(70026);
+module.exports.JSON_SCHEMA = __nccwpck_require__(2168);
+module.exports.CORE_SCHEMA = __nccwpck_require__(11950);
+module.exports.DEFAULT_SAFE_SCHEMA = __nccwpck_require__(42881);
+module.exports.DEFAULT_FULL_SCHEMA = __nccwpck_require__(145);
+module.exports.load = loader.load;
+module.exports.loadAll = loader.loadAll;
+module.exports.safeLoad = loader.safeLoad;
+module.exports.safeLoadAll = loader.safeLoadAll;
+module.exports.dump = dumper.dump;
+module.exports.safeDump = dumper.safeDump;
+module.exports.YAMLException = __nccwpck_require__(29291);
+
+// Deprecated schema names from JS-YAML 2.0.x
+module.exports.MINIMAL_SCHEMA = __nccwpck_require__(70026);
+module.exports.SAFE_SCHEMA = __nccwpck_require__(42881);
+module.exports.DEFAULT_SCHEMA = __nccwpck_require__(145);
+
+// Deprecated functions from JS-YAML 1.x.x
+module.exports.scan = deprecated('scan');
+module.exports.parse = deprecated('parse');
+module.exports.compose = deprecated('compose');
+module.exports.addConstructor = deprecated('addConstructor');
+
/***/ }),
-/***/ 56417:
-/***/ ((__unused_webpack_module, exports) => {
+/***/ 59941:
+/***/ ((module) => {
"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"
+
+
+function isNothing(subject) {
+ return (typeof subject === 'undefined') || (subject === null);
+}
+
+
+function isObject(subject) {
+ return (typeof subject === 'object') && (subject !== null);
+}
+
+
+function toArray(sequence) {
+ if (Array.isArray(sequence)) return sequence;
+ else if (isNothing(sequence)) return [];
+
+ return [ sequence ];
+}
+
+
+function extend(target, source) {
+ var index, length, key, sourceKeys;
+
+ if (source) {
+ sourceKeys = Object.keys(source);
+
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
+ key = sourceKeys[index];
+ target[key] = source[key];
}
-};
-//# sourceMappingURL=interfaces.js.map
+ }
+
+ return target;
+}
+
+
+function repeat(string, count) {
+ var result = '', cycle;
+
+ for (cycle = 0; cycle < count; cycle += 1) {
+ result += string;
+ }
+
+ return result;
+}
+
+
+function isNegativeZero(number) {
+ return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
+}
+
+
+module.exports.isNothing = isNothing;
+module.exports.isObject = isObject;
+module.exports.toArray = toArray;
+module.exports.repeat = repeat;
+module.exports.isNegativeZero = isNegativeZero;
+module.exports.extend = extend;
+
/***/ }),
-/***/ 33396:
-/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+/***/ 98069:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-var dom_1 = __nccwpck_require__(40770);
-/**
- * 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));
- };
- BaseReader.prototype._sanitize = function (str) {
- return dom_1.sanitizeInput(str, this._builderOptions.invalidCharReplacement);
- };
- /**
- * 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);
- };
- /**
- * Sanitizes input strings.
- *
- * @param str - input string
- */
- BaseReader.prototype.sanitize = function (str) {
- return this._sanitize(str);
- };
- return BaseReader;
-}());
-exports.BaseReader = BaseReader;
-//# sourceMappingURL=BaseReader.js.map
-/***/ }),
+/*eslint-disable no-use-before-define*/
-/***/ 43518:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+var common = __nccwpck_require__(59941);
+var YAMLException = __nccwpck_require__(29291);
+var DEFAULT_FULL_SCHEMA = __nccwpck_require__(145);
+var DEFAULT_SAFE_SCHEMA = __nccwpck_require__(42881);
-"use strict";
+var _toString = Object.prototype.toString;
+var _hasOwnProperty = Object.prototype.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 ObjectReader_1 = __nccwpck_require__(40768);
-var BaseReader_1 = __nccwpck_require__(33396);
-/**
- * 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
+var CHAR_TAB = 0x09; /* Tab */
+var CHAR_LINE_FEED = 0x0A; /* LF */
+var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
+var CHAR_SPACE = 0x20; /* Space */
+var CHAR_EXCLAMATION = 0x21; /* ! */
+var CHAR_DOUBLE_QUOTE = 0x22; /* " */
+var CHAR_SHARP = 0x23; /* # */
+var CHAR_PERCENT = 0x25; /* % */
+var CHAR_AMPERSAND = 0x26; /* & */
+var CHAR_SINGLE_QUOTE = 0x27; /* ' */
+var CHAR_ASTERISK = 0x2A; /* * */
+var CHAR_COMMA = 0x2C; /* , */
+var CHAR_MINUS = 0x2D; /* - */
+var CHAR_COLON = 0x3A; /* : */
+var CHAR_EQUALS = 0x3D; /* = */
+var CHAR_GREATER_THAN = 0x3E; /* > */
+var CHAR_QUESTION = 0x3F; /* ? */
+var CHAR_COMMERCIAL_AT = 0x40; /* @ */
+var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
+var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
+var CHAR_GRAVE_ACCENT = 0x60; /* ` */
+var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
+var CHAR_VERTICAL_LINE = 0x7C; /* | */
+var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
-/***/ }),
+var ESCAPE_SEQUENCES = {};
-/***/ 40768:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+ESCAPE_SEQUENCES[0x00] = '\\0';
+ESCAPE_SEQUENCES[0x07] = '\\a';
+ESCAPE_SEQUENCES[0x08] = '\\b';
+ESCAPE_SEQUENCES[0x09] = '\\t';
+ESCAPE_SEQUENCES[0x0A] = '\\n';
+ESCAPE_SEQUENCES[0x0B] = '\\v';
+ESCAPE_SEQUENCES[0x0C] = '\\f';
+ESCAPE_SEQUENCES[0x0D] = '\\r';
+ESCAPE_SEQUENCES[0x1B] = '\\e';
+ESCAPE_SEQUENCES[0x22] = '\\"';
+ESCAPE_SEQUENCES[0x5C] = '\\\\';
+ESCAPE_SEQUENCES[0x85] = '\\N';
+ESCAPE_SEQUENCES[0xA0] = '\\_';
+ESCAPE_SEQUENCES[0x2028] = '\\L';
+ESCAPE_SEQUENCES[0x2029] = '\\P';
-"use strict";
+var DEPRECATED_BOOLEANS_SYNTAX = [
+ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
+ 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
+];
-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__(76195);
-var BaseReader_1 = __nccwpck_require__(33396);
-/**
- * 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;
+function compileStyleMap(schema, map) {
+ var result, keys, index, length, tag, style, type;
+
+ if (map === null) return {};
+
+ result = {};
+ keys = Object.keys(map);
+
+ for (index = 0, length = keys.length; index < length; index += 1) {
+ tag = keys[index];
+ style = String(map[tag]);
+
+ if (tag.slice(0, 2) === '!!') {
+ tag = 'tag:yaml.org,2002:' + tag.slice(2);
}
- /**
- * 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;
- 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, _this.sanitize(attrKey), _this.sanitize(attrVal)) || lastChild;
- });
- }
- }
- else {
- lastChild = _this.attribute(node, undefined, _this.sanitize(key.substr(options.convert.att.length)), _this.sanitize(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, _this.sanitize(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, _this.sanitize(item)) || lastChild; }, _this);
- }
- else {
- lastChild = _this.cdata(node, _this.sanitize(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, _this.sanitize(item)) || lastChild; }, _this);
- }
- else {
- lastChild = _this.comment(node, _this.sanitize(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, _this.sanitize(insTarget), _this.sanitize(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, _this.sanitize(insTarget), _this.sanitize(insValue)) || lastChild;
- }, _this);
- }
- else /* if (isMap(target) || isObject(target)) */ {
- util_1.forEachObject(val, function (insTarget, insValue) { return lastChild = _this.instruction(node, _this.sanitize(insTarget), _this.sanitize(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, _this.sanitize(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, _this.sanitize(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, _this.sanitize(key));
- if (parent) {
- lastChild = parent;
- _this.text(parent, _this.sanitize(val));
- }
- }
- else {
- // leaf element node
- lastChild = _this.element(node, undefined, _this.sanitize(key)) || lastChild;
- }
- }, this);
- }
- return lastChild || node;
- };
- return ObjectReader;
-}(BaseReader_1.BaseReader));
-exports.ObjectReader = ObjectReader;
-//# sourceMappingURL=ObjectReader.js.map
+ type = schema.compiledTypeMap['fallback'][tag];
-/***/ }),
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) {
+ style = type.styleAliases[style];
+ }
-/***/ 65044:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+ result[tag] = style;
+ }
-"use strict";
+ return result;
+}
-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; }
+function encodeHex(character) {
+ var string, handle, length;
+
+ string = character.toString(16).toUpperCase();
+
+ if (character <= 0xFF) {
+ handle = 'x';
+ length = 2;
+ } else if (character <= 0xFFFF) {
+ handle = 'u';
+ length = 4;
+ } else if (character <= 0xFFFFFFFF) {
+ handle = 'U';
+ length = 8;
+ } else {
+ throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
+ }
+
+ return '\\' + handle + common.repeat('0', length - string.length) + string;
+}
+
+function State(options) {
+ this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
+ this.indent = Math.max(1, (options['indent'] || 2));
+ this.noArrayIndent = options['noArrayIndent'] || false;
+ this.skipInvalid = options['skipInvalid'] || false;
+ this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
+ this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
+ this.sortKeys = options['sortKeys'] || false;
+ this.lineWidth = options['lineWidth'] || 80;
+ this.noRefs = options['noRefs'] || false;
+ this.noCompatMode = options['noCompatMode'] || false;
+ this.condenseFlow = options['condenseFlow'] || false;
+
+ this.implicitTypes = this.schema.compiledImplicit;
+ this.explicitTypes = this.schema.compiledExplicit;
+
+ this.tag = null;
+ this.result = '';
+
+ this.duplicates = [];
+ this.usedDuplicates = null;
+}
+
+// Indents every line in a string. Empty lines (\n only) are not indented.
+function indentString(string, spaces) {
+ var ind = common.repeat(' ', spaces),
+ position = 0,
+ next = -1,
+ result = '',
+ line,
+ length = string.length;
+
+ while (position < length) {
+ next = string.indexOf('\n', position);
+ if (next === -1) {
+ line = string.slice(position);
+ position = length;
+ } else {
+ line = string.slice(position, next + 1);
+ position = next + 1;
}
- 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__(47061);
-var interfaces_1 = __nccwpck_require__(97707);
-var infra_1 = __nccwpck_require__(84251);
-var algorithm_1 = __nccwpck_require__(61);
-var BaseReader_1 = __nccwpck_require__(33396);
-/**
- * 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;
+
+ if (line.length && line !== '\n') result += ind;
+
+ result += line;
+ }
+
+ return result;
+}
+
+function generateNextLine(state, level) {
+ return '\n' + common.repeat(' ', state.indent * level);
+}
+
+function testImplicitResolving(state, str) {
+ var index, length, type;
+
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
+ type = state.implicitTypes[index];
+
+ if (type.resolve(str)) {
+ return true;
}
- /**
- * 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 });
- 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 = this.sanitize(declaration.version);
- if (version !== "1.0") {
- throw new Error("Invalid xml version: " + version);
- }
- var builderOptions = {
- version: version
- };
- if (declaration.encoding) {
- builderOptions.encoding = this.sanitize(declaration.encoding);
- }
- if (declaration.standalone) {
- builderOptions.standalone = (this.sanitize(declaration.standalone) === "yes");
- }
- context.set(builderOptions);
- break;
- case interfaces_1.TokenType.DocType:
- var doctype = token;
- context = this.docType(context, this.sanitize(doctype.name), this.sanitize(doctype.pubId), this.sanitize(doctype.sysId)) || context;
- break;
- case interfaces_1.TokenType.CDATA:
- var cdata = token;
- context = this.cdata(context, this.sanitize(cdata.data)) || context;
- break;
- case interfaces_1.TokenType.Comment:
- var comment = token;
- context = this.comment(context, this.sanitize(comment.data)) || context;
- break;
- case interfaces_1.TokenType.PI:
- var pi = token;
- context = this.instruction(context, this.sanitize(pi.target), this.sanitize(pi.data)) || context;
- break;
- case interfaces_1.TokenType.Text:
- var text = token;
- context = this.text(context, this.sanitize(text.data)) || context;
- break;
- case interfaces_1.TokenType.Element:
- var element = token;
- var elementName = this.sanitize(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 = this.sanitize(attName);
- attValue = this.sanitize(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 = this.sanitize(attName);
- attValue = this.sanitize(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 false;
+}
-/***/ 12475:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+// [33] s-white ::= s-space | s-tab
+function isWhitespace(c) {
+ return c === CHAR_SPACE || c === CHAR_TAB;
+}
-"use strict";
+// Returns true if the character can be printed without escaping.
+// From YAML 1.2: "any allowed characters known to be non-printable
+// should also be escaped. [However,] This isn’t mandatory"
+// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
+function isPrintable(c) {
+ return (0x00020 <= c && c <= 0x00007E)
+ || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
+ || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
+ || (0x10000 <= c && c <= 0x10FFFF);
+}
-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__(40768);
-var BaseReader_1 = __nccwpck_require__(33396);
-var js_yaml_1 = __nccwpck_require__(10829);
-/**
- * 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
+// [34] ns-char ::= nb-char - s-white
+// [27] nb-char ::= c-printable - b-char - c-byte-order-mark
+// [26] b-char ::= b-line-feed | b-carriage-return
+// [24] b-line-feed ::= #xA /* LF */
+// [25] b-carriage-return ::= #xD /* CR */
+// [3] c-byte-order-mark ::= #xFEFF
+function isNsChar(c) {
+ return isPrintable(c) && !isWhitespace(c)
+ // byte-order-mark
+ && c !== 0xFEFF
+ // b-char
+ && c !== CHAR_CARRIAGE_RETURN
+ && c !== CHAR_LINE_FEED;
+}
-/***/ }),
+// Simplified test for values allowed after the first character in plain style.
+function isPlainSafe(c, prev) {
+ // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
+ // where nb-char ::= c-printable - b-char - c-byte-order-mark.
+ return isPrintable(c) && c !== 0xFEFF
+ // - c-flow-indicator
+ && c !== CHAR_COMMA
+ && c !== CHAR_LEFT_SQUARE_BRACKET
+ && c !== CHAR_RIGHT_SQUARE_BRACKET
+ && c !== CHAR_LEFT_CURLY_BRACKET
+ && c !== CHAR_RIGHT_CURLY_BRACKET
+ // - ":" - "#"
+ // /* An ns-char preceding */ "#"
+ && c !== CHAR_COLON
+ && ((c !== CHAR_SHARP) || (prev && isNsChar(prev)));
+}
-/***/ 90560:
-/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+// Simplified test for values allowed as the first character in plain style.
+function isPlainSafeFirst(c) {
+ // Uses a subset of ns-char - c-indicator
+ // where ns-char = nb-char - s-white.
+ return isPrintable(c) && c !== 0xFEFF
+ && !isWhitespace(c) // - s-white
+ // - (c-indicator ::=
+ // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
+ && c !== CHAR_MINUS
+ && c !== CHAR_QUESTION
+ && c !== CHAR_COLON
+ && c !== CHAR_COMMA
+ && c !== CHAR_LEFT_SQUARE_BRACKET
+ && c !== CHAR_RIGHT_SQUARE_BRACKET
+ && c !== CHAR_LEFT_CURLY_BRACKET
+ && c !== CHAR_RIGHT_CURLY_BRACKET
+ // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
+ && c !== CHAR_SHARP
+ && c !== CHAR_AMPERSAND
+ && c !== CHAR_ASTERISK
+ && c !== CHAR_EXCLAMATION
+ && c !== CHAR_VERTICAL_LINE
+ && c !== CHAR_EQUALS
+ && c !== CHAR_GREATER_THAN
+ && c !== CHAR_SINGLE_QUOTE
+ && c !== CHAR_DOUBLE_QUOTE
+ // | “%” | “@” | “`”)
+ && c !== CHAR_PERCENT
+ && c !== CHAR_COMMERCIAL_AT
+ && c !== CHAR_GRAVE_ACCENT;
+}
-"use strict";
+// Determines whether block indentation indicator is required.
+function needIndentIndicator(string) {
+ var leadingSpaceRe = /^\n* /;
+ return leadingSpaceRe.test(string);
+}
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-var XMLReader_1 = __nccwpck_require__(65044);
-exports.XMLReader = XMLReader_1.XMLReader;
-var ObjectReader_1 = __nccwpck_require__(40768);
-exports.ObjectReader = ObjectReader_1.ObjectReader;
-var JSONReader_1 = __nccwpck_require__(43518);
-exports.JSONReader = JSONReader_1.JSONReader;
-var YAMLReader_1 = __nccwpck_require__(12475);
-exports.YAMLReader = YAMLReader_1.YAMLReader;
-//# sourceMappingURL=index.js.map
+var STYLE_PLAIN = 1,
+ STYLE_SINGLE = 2,
+ STYLE_LITERAL = 3,
+ STYLE_FOLDED = 4,
+ STYLE_DOUBLE = 5;
-/***/ }),
+// Determines which scalar styles are possible and returns the preferred style.
+// lineWidth = -1 => no limit.
+// Pre-conditions: str.length > 0.
+// Post-conditions:
+// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
+// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
+// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
+function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
+ var i;
+ var char, prev_char;
+ var hasLineBreak = false;
+ var hasFoldableLine = false; // only checked if shouldTrackWidth
+ var shouldTrackWidth = lineWidth !== -1;
+ var previousLineBreak = -1; // count the first line correctly
+ var plain = isPlainSafeFirst(string.charCodeAt(0))
+ && !isWhitespace(string.charCodeAt(string.length - 1));
-/***/ 50708:
-/***/ ((__unused_webpack_module, exports) => {
+ if (singleLineOnly) {
+ // Case: no block styles.
+ // Check for disallowed characters to rule out plain and single.
+ for (i = 0; i < string.length; i++) {
+ char = string.charCodeAt(i);
+ if (!isPrintable(char)) {
+ return STYLE_DOUBLE;
+ }
+ prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
+ plain = plain && isPlainSafe(char, prev_char);
+ }
+ } else {
+ // Case: block styles permitted.
+ for (i = 0; i < string.length; i++) {
+ char = string.charCodeAt(i);
+ if (char === CHAR_LINE_FEED) {
+ hasLineBreak = true;
+ // Check if any line can be folded.
+ if (shouldTrackWidth) {
+ hasFoldableLine = hasFoldableLine ||
+ // Foldable line = too long, and not more-indented.
+ (i - previousLineBreak - 1 > lineWidth &&
+ string[previousLineBreak + 1] !== ' ');
+ previousLineBreak = i;
+ }
+ } else if (!isPrintable(char)) {
+ return STYLE_DOUBLE;
+ }
+ prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
+ plain = plain && isPlainSafe(char, prev_char);
+ }
+ // in case the end is missing a \n
+ hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
+ (i - previousLineBreak - 1 > lineWidth &&
+ string[previousLineBreak + 1] !== ' '));
+ }
+ // Although every style can represent \n without escaping, prefer block styles
+ // for multiline, since they're more readable and they don't add empty lines.
+ // Also prefer folding a super-long line.
+ if (!hasLineBreak && !hasFoldableLine) {
+ // Strings interpretable as another type have to be quoted;
+ // e.g. the string 'true' vs. the boolean true.
+ return plain && !testAmbiguousType(string)
+ ? STYLE_PLAIN : STYLE_SINGLE;
+ }
+ // Edge case: block indentation indicator can only have one digit.
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
+ return STYLE_DOUBLE;
+ }
+ // At this point we know block styles are valid.
+ // Prefer literal style unless we want to fold.
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
+}
-"use strict";
+// Note: line breaking/folding is implemented for only the folded style.
+// NB. We drop the last trailing newline (if any) of a returned block scalar
+// since the dumper adds its own newline. This always works:
+// • No ending newline => unaffected; already using strip "-" chomping.
+// • Ending newline => removed then restored.
+// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
+function writeScalar(state, string, level, iskey) {
+ state.dump = (function () {
+ if (string.length === 0) {
+ return "''";
+ }
+ if (!state.noCompatMode &&
+ DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
+ return "'" + string + "'";
+ }
-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;
+ var indent = state.indent * Math.max(1, level); // no 0-indent scalars
+ // As indentation gets deeper, let the width decrease monotonically
+ // to the lower bound min(state.lineWidth, 40).
+ // Note that this implies
+ // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
+ // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
+ // This behaves better than a constant minimum width which disallows narrower options,
+ // or an indent threshold which causes the width to suddenly increase.
+ var lineWidth = state.lineWidth === -1
+ ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
+
+ // Without knowing if keys are implicit/explicit, assume implicit for safety.
+ var singleLineOnly = iskey
+ // No block styles in flow mode.
+ || (state.flowLevel > -1 && level >= state.flowLevel);
+ function testAmbiguity(string) {
+ return testImplicitResolving(state, string);
}
- return BaseCBWriter;
-}());
-exports.BaseCBWriter = BaseCBWriter;
-//# sourceMappingURL=BaseCBWriter.js.map
-/***/ }),
+ switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
+ case STYLE_PLAIN:
+ return string;
+ case STYLE_SINGLE:
+ return "'" + string.replace(/'/g, "''") + "'";
+ case STYLE_LITERAL:
+ return '|' + blockHeader(string, state.indent)
+ + dropEndingNewline(indentString(string, indent));
+ case STYLE_FOLDED:
+ return '>' + blockHeader(string, state.indent)
+ + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
+ case STYLE_DOUBLE:
+ return '"' + escapeString(string, lineWidth) + '"';
+ default:
+ throw new YAMLException('impossible error: invalid scalar style');
+ }
+ }());
+}
-/***/ 37644:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
+function blockHeader(string, indentPerLevel) {
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
-"use strict";
+ // note the special case: the string '\n' counts as a "trailing" empty line.
+ var clip = string[string.length - 1] === '\n';
+ var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
+ var chomp = keep ? '+' : (clip ? '' : '-');
-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__(27305);
-var LocalNameSet_1 = __nccwpck_require__(19049);
-var NamespacePrefixMap_1 = __nccwpck_require__(90283);
-var infra_1 = __nccwpck_require__(84251);
-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);
- }
- }
- /**
- * 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+003C LESS-THAN SIGN, U+002F SOLIDUS);
- * 20.2. The value of qualified name;
- * 20.3. ">" (U+003E GREATER-THAN SIGN).
- * 21. Return the value of markup.
- */
- this.closeTag(qualifiedName);
- this.endElement(qualifiedName);
- };
- /**
- * 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+003C LESS-THAN SIGN, U+002F SOLIDUS);
- * 20.2. The value of qualified name;
- * 20.3. ">" (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).");
- }
- 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; }
- }
- };
- /**
- * 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; }
- }
- };
- /**
- * 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);
- };
- /**
- * 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);
- };
- /**
- * 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+003C LESS-THAN SIGN, U+003F QUESTION MARK);
- * 3.2. The value of node's target;
- * 3.3. " " (U+0020 SPACE);
- * 3.4. The value of node's data;
- * 3.5. "?>" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN).
- * 4. Return the value of markup.
- */
- this.instruction(node.target, node.data);
- };
- /**
- * 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);
- };
- /**
- * 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;
- };
- /**
- * 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;
- };
- /**
- * 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;
- };
- /**
- * 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;
- };
- /**
- * 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;
- }
- };
- 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 indentIndicator + chomp + '\n';
+}
+
+// (See the note for writeScalar.)
+function dropEndingNewline(string) {
+ return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
+}
+
+// Note: a long line without a suitable break point will exceed the width limit.
+// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
+function foldString(string, width) {
+ // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
+ // unless they're before or after a more-indented line, or at the very
+ // beginning or end, in which case $k$ maps to $k$.
+ // Therefore, parse each chunk as newline(s) followed by a content line.
+ var lineRe = /(\n+)([^\n]*)/g;
+
+ // first line (possibly an empty line)
+ var result = (function () {
+ var nextLF = string.indexOf('\n');
+ nextLF = nextLF !== -1 ? nextLF : string.length;
+ lineRe.lastIndex = nextLF;
+ return foldLine(string.slice(0, nextLF), width);
+ }());
+ // If we haven't reached the first content line yet, don't add an extra \n.
+ var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
+ var moreIndented;
+
+ // rest of the lines
+ var match;
+ while ((match = lineRe.exec(string))) {
+ var prefix = match[1], line = match[2];
+ moreIndented = (line[0] === ' ');
+ result += prefix
+ + (!prevMoreIndented && !moreIndented && line !== ''
+ ? '\n' : '')
+ + foldLine(line, width);
+ prevMoreIndented = moreIndented;
+ }
+
+ return result;
+}
+
+// Greedy line breaking.
+// Picks the longest line under the limit each time,
+// otherwise settles for the shortest line over the limit.
+// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
+function foldLine(line, width) {
+ if (line === '' || line[0] === ' ') return line;
+
+ // Since a more-indented line adds a \n, breaks can't be followed by a space.
+ var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
+ var match;
+ // start is an inclusive index. end, curr, and next are exclusive.
+ var start = 0, end, curr = 0, next = 0;
+ var result = '';
+
+ // Invariants: 0 <= start <= length-1.
+ // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
+ // Inside the loop:
+ // A match implies length >= 2, so curr and next are <= length-2.
+ while ((match = breakRe.exec(line))) {
+ next = match.index;
+ // maintain invariant: curr - start <= width
+ if (next - start > width) {
+ end = (curr > start) ? curr : next; // derive end <= length-2
+ result += '\n' + line.slice(start, end);
+ // skip the space that was output as \n
+ start = end + 1; // derive start <= length-1
+ }
+ curr = next;
+ }
+
+ // By the invariants, start <= length-1, so there is something left over.
+ // It is either the whole string or a part starting from non-whitespace.
+ result += '\n';
+ // Insert a break if the remainder is too long and there is a break available.
+ if (line.length - start > width && curr > start) {
+ result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
+ } else {
+ result += line.slice(start);
+ }
+
+ return result.slice(1); // drop extra \n joiner
+}
+
+// Escapes a double-quoted string.
+function escapeString(string) {
+ var result = '';
+ var char, nextChar;
+ var escapeSeq;
+
+ for (var i = 0; i < string.length; i++) {
+ char = string.charCodeAt(i);
+ // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
+ if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) {
+ nextChar = string.charCodeAt(i + 1);
+ if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) {
+ // Combine the surrogate pair and store it escaped.
+ result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
+ // Advance index one extra since we already used that char here.
+ i++; continue;
+ }
+ }
+ escapeSeq = ESCAPE_SEQUENCES[char];
+ result += !escapeSeq && isPrintable(char)
+ ? string[i]
+ : escapeSeq || encodeHex(char);
+ }
+
+ return result;
+}
+
+function writeFlowSequence(state, level, object) {
+ var _result = '',
+ _tag = state.tag,
+ index,
+ length;
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ // Write only valid elements.
+ if (writeNode(state, level, object[index], false, false)) {
+ if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
+ _result += state.dump;
+ }
+ }
+
+ state.tag = _tag;
+ state.dump = '[' + _result + ']';
+}
+
+function writeBlockSequence(state, level, object, compact) {
+ var _result = '',
+ _tag = state.tag,
+ index,
+ length;
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ // Write only valid elements.
+ if (writeNode(state, level + 1, object[index], true, true)) {
+ if (!compact || index !== 0) {
+ _result += generateNextLine(state, level);
+ }
+
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ _result += '-';
+ } else {
+ _result += '- ';
+ }
+
+ _result += state.dump;
+ }
+ }
+
+ state.tag = _tag;
+ state.dump = _result || '[]'; // Empty sequence if no valid values.
+}
-/***/ }),
+function writeFlowMapping(state, level, object) {
+ var _result = '',
+ _tag = state.tag,
+ objectKeyList = Object.keys(object),
+ index,
+ length,
+ objectKey,
+ objectValue,
+ pairBuffer;
-/***/ 37525:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
-"use strict";
+ pairBuffer = '';
+ if (index !== 0) pairBuffer += ', ';
-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__(50708);
-/**
- * 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 "";
- };
- /** @inheritdoc */
- JSONCBWriter.prototype.declaration = function (version, encoding, standalone) {
- 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() + "}";
- };
- /** @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() + "}";
- };
- /** @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() + "}";
- };
- /** @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() + "}";
- };
- /** @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() + "}";
- };
- /** @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;
- };
- /** @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 "";
- }
- };
- /** @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 "";
- }
- };
- /**
- * 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);
- }
- };
- /**
- * 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;
- };
- /**
- * 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 + "\":";
- };
- /**
- * 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
+ if (state.condenseFlow) pairBuffer += '"';
-/***/ }),
+ objectKey = objectKeyList[index];
+ objectValue = object[objectKey];
-/***/ 37510:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+ if (!writeNode(state, level, objectKey, false, false)) {
+ continue; // Skip this pair because of invalid key;
+ }
-"use strict";
+ if (state.dump.length > 1024) pairBuffer += '? ';
-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__(50243);
-var util_1 = __nccwpck_require__(76195);
-var BaseWriter_1 = __nccwpck_require__(37644);
-/**
- * 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;
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
+
+ if (!writeNode(state, level, objectValue, false, false)) {
+ continue; // Skip this pair because of invalid value.
}
- /**
- * 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;
- 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;
- };
- /**
- * 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 '';
- };
- /**
- * 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;
- }
- };
- /**
- * 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);
- }
- 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 JSONWriter;
-}(BaseWriter_1.BaseWriter));
-exports.JSONWriter = JSONWriter;
-//# sourceMappingURL=JSONWriter.js.map
-/***/ }),
+ pairBuffer += state.dump;
-/***/ 41397:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+ // Both key and value are valid.
+ _result += pairBuffer;
+ }
-"use strict";
+ state.tag = _tag;
+ state.dump = '{' + _result + '}';
+}
-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__(76195);
-var ObjectWriter_1 = __nccwpck_require__(50243);
-var BaseWriter_1 = __nccwpck_require__(37644);
-/**
- * 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;
+function writeBlockMapping(state, level, object, compact) {
+ var _result = '',
+ _tag = state.tag,
+ objectKeyList = Object.keys(object),
+ index,
+ length,
+ objectKey,
+ objectValue,
+ explicitPair,
+ pairBuffer;
+
+ // Allow sorting keys so that the output file is deterministic
+ if (state.sortKeys === true) {
+ // Default sorting
+ objectKeyList.sort();
+ } else if (typeof state.sortKeys === 'function') {
+ // Custom sort function
+ objectKeyList.sort(state.sortKeys);
+ } else if (state.sortKeys) {
+ // Something is wrong
+ throw new YAMLException('sortKeys must be a boolean or a function');
+ }
+
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+ pairBuffer = '';
+
+ if (!compact || index !== 0) {
+ pairBuffer += generateNextLine(state, level);
+ }
+
+ objectKey = objectKeyList[index];
+ objectValue = object[objectKey];
+
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
+ continue; // Skip this pair because of invalid key.
+ }
+
+ explicitPair = (state.tag !== null && state.tag !== '?') ||
+ (state.dump && state.dump.length > 1024);
+
+ if (explicitPair) {
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ pairBuffer += '?';
+ } else {
+ pairBuffer += '? ';
+ }
}
- /**
- * 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
-/***/ }),
+ pairBuffer += state.dump;
-/***/ 50243:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+ if (explicitPair) {
+ pairBuffer += generateNextLine(state, level);
+ }
-"use strict";
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
+ continue; // Skip this pair because of invalid 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 __());
- };
-})();
-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__(76195);
-var interfaces_1 = __nccwpck_require__(27305);
-var BaseWriter_1 = __nccwpck_require__(37644);
-/**
- * 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;
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ pairBuffer += ':';
+ } else {
+ pairBuffer += ': ';
}
- /**
- * 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;
- }
+
+ pairBuffer += state.dump;
+
+ // Both key and value are valid.
+ _result += pairBuffer;
+ }
+
+ state.tag = _tag;
+ state.dump = _result || '{}'; // Empty mapping if no valid pairs.
+}
+
+function detectType(state, object, explicit) {
+ var _result, typeList, index, length, type, style;
+
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
+
+ for (index = 0, length = typeList.length; index < length; index += 1) {
+ type = typeList[index];
+
+ if ((type.instanceOf || type.predicate) &&
+ (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
+ (!type.predicate || type.predicate(object))) {
+
+ state.tag = explicit ? type.tag : '?';
+
+ if (type.represent) {
+ style = state.styleMap[type.tag] || type.defaultStyle;
+
+ if (_toString.call(type.represent) === '[object Function]') {
+ _result = type.represent(object, style);
+ } else if (_hasOwnProperty.call(type.represent, style)) {
+ _result = type.represent[style](object, style);
+ } else {
+ throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
}
- 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]["#"];
+
+ state.dump = _result;
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// Serializes `object` and writes it to global `result`.
+// Returns true on success, or false on invalid object.
+//
+function writeNode(state, level, object, block, compact, iskey) {
+ state.tag = null;
+ state.dump = object;
+
+ if (!detectType(state, object, false)) {
+ detectType(state, object, true);
+ }
+
+ var type = _toString.call(state.dump);
+
+ if (block) {
+ block = (state.flowLevel < 0 || state.flowLevel > level);
+ }
+
+ var objectOrArray = type === '[object Object]' || type === '[object Array]',
+ duplicateIndex,
+ duplicate;
+
+ if (objectOrArray) {
+ duplicateIndex = state.duplicates.indexOf(object);
+ duplicate = duplicateIndex !== -1;
+ }
+
+ if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
+ compact = false;
+ }
+
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
+ state.dump = '*ref_' + duplicateIndex;
+ } else {
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
+ state.usedDuplicates[duplicateIndex] = true;
+ }
+ if (type === '[object Object]') {
+ if (block && (Object.keys(state.dump).length !== 0)) {
+ writeBlockMapping(state, level, state.dump, compact);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + state.dump;
}
- 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 {
+ writeFlowMapping(state, level, state.dump);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
}
- 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;
+ }
+ } else if (type === '[object Array]') {
+ var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level;
+ if (block && (state.dump.length !== 0)) {
+ writeBlockSequence(state, arrayLevel, state.dump, compact);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + state.dump;
}
- };
- 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 {
+ writeFlowSequence(state, arrayLevel, state.dump);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
}
- else {
- var key = count > 1 ? defKey + (id++).toString() : defKey;
- obj[key] = item;
+ }
+ } else if (type === '[object String]') {
+ if (state.tag !== '?') {
+ writeScalar(state, state.dump, level, iskey);
+ }
+ } else {
+ if (state.skipInvalid) return false;
+ throw new YAMLException('unacceptable kind of an object to dump ' + type);
+ }
+
+ if (state.tag !== null && state.tag !== '?') {
+ state.dump = '!<' + state.tag + '> ' + state.dump;
+ }
+ }
+
+ return true;
+}
+
+function getDuplicateReferences(object, state) {
+ var objects = [],
+ duplicatesIndexes = [],
+ index,
+ length;
+
+ inspectNode(object, objects, duplicatesIndexes);
+
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
+ }
+ state.usedDuplicates = new Array(length);
+}
+
+function inspectNode(object, objects, duplicatesIndexes) {
+ var objectKeyList,
+ index,
+ length;
+
+ if (object !== null && typeof object === 'object') {
+ index = objects.indexOf(object);
+ if (index !== -1) {
+ if (duplicatesIndexes.indexOf(index) === -1) {
+ duplicatesIndexes.push(index);
+ }
+ } else {
+ objects.push(object);
+
+ if (Array.isArray(object)) {
+ for (index = 0, length = object.length; index < length; index += 1) {
+ inspectNode(object[index], objects, duplicatesIndexes);
}
- 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 {
+ objectKeyList = Object.keys(object);
+
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
}
- 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));
- }
+ }
+ }
+ }
+}
+
+function dump(input, options) {
+ options = options || {};
+
+ var state = new State(options);
+
+ if (!state.noRefs) getDuplicateReferences(input, state);
+
+ if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
+
+ return '';
+}
+
+function safeDump(input, options) {
+ return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
+}
+
+module.exports.dump = dump;
+module.exports.safeDump = safeDump;
+
+
+/***/ }),
+
+/***/ 29291:
+/***/ ((module) => {
+
+"use strict";
+// YAML error class. http://stackoverflow.com/questions/8458984
+//
+
+
+function YAMLException(reason, mark) {
+ // Super constructor
+ Error.call(this);
+
+ this.name = 'YAMLException';
+ this.reason = reason;
+ this.mark = mark;
+ this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
+
+ // Include stack trace in error object
+ if (Error.captureStackTrace) {
+ // Chrome and NodeJS
+ Error.captureStackTrace(this, this.constructor);
+ } else {
+ // FF, IE 10+ and Safari 6+. Fallback for others
+ this.stack = (new Error()).stack || '';
+ }
+}
+
+
+// Inherit from Error
+YAMLException.prototype = Object.create(Error.prototype);
+YAMLException.prototype.constructor = YAMLException;
+
+
+YAMLException.prototype.toString = function toString(compact) {
+ var result = this.name + ': ';
+
+ result += this.reason || '(unknown reason)';
+
+ if (!compact && this.mark) {
+ result += ' ' + this.mark.toString();
+ }
+
+ return result;
+};
+
+
+module.exports = YAMLException;
+
+
+/***/ }),
+
+/***/ 40342:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+/*eslint-disable max-len,no-use-before-define*/
+
+var common = __nccwpck_require__(59941);
+var YAMLException = __nccwpck_require__(29291);
+var Mark = __nccwpck_require__(77262);
+var DEFAULT_SAFE_SCHEMA = __nccwpck_require__(42881);
+var DEFAULT_FULL_SCHEMA = __nccwpck_require__(145);
+
+
+var _hasOwnProperty = Object.prototype.hasOwnProperty;
+
+
+var CONTEXT_FLOW_IN = 1;
+var CONTEXT_FLOW_OUT = 2;
+var CONTEXT_BLOCK_IN = 3;
+var CONTEXT_BLOCK_OUT = 4;
+
+
+var CHOMPING_CLIP = 1;
+var CHOMPING_STRIP = 2;
+var CHOMPING_KEEP = 3;
+
+
+var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
+var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
+var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
+var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
+var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
+
+
+function _class(obj) { return Object.prototype.toString.call(obj); }
+
+function is_EOL(c) {
+ return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
+}
+
+function is_WHITE_SPACE(c) {
+ return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
+}
+
+function is_WS_OR_EOL(c) {
+ return (c === 0x09/* Tab */) ||
+ (c === 0x20/* Space */) ||
+ (c === 0x0A/* LF */) ||
+ (c === 0x0D/* CR */);
+}
+
+function is_FLOW_INDICATOR(c) {
+ return c === 0x2C/* , */ ||
+ c === 0x5B/* [ */ ||
+ c === 0x5D/* ] */ ||
+ c === 0x7B/* { */ ||
+ c === 0x7D/* } */;
+}
+
+function fromHexCode(c) {
+ var lc;
+
+ if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
+ return c - 0x30;
+ }
+
+ /*eslint-disable no-bitwise*/
+ lc = c | 0x20;
+
+ if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
+ return lc - 0x61 + 10;
+ }
+
+ return -1;
+}
+
+function escapedHexLen(c) {
+ if (c === 0x78/* x */) { return 2; }
+ if (c === 0x75/* u */) { return 4; }
+ if (c === 0x55/* U */) { return 8; }
+ return 0;
+}
+
+function fromDecimalCode(c) {
+ if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
+ return c - 0x30;
+ }
+
+ return -1;
+}
+
+function simpleEscapeSequence(c) {
+ /* eslint-disable indent */
+ return (c === 0x30/* 0 */) ? '\x00' :
+ (c === 0x61/* a */) ? '\x07' :
+ (c === 0x62/* b */) ? '\x08' :
+ (c === 0x74/* t */) ? '\x09' :
+ (c === 0x09/* Tab */) ? '\x09' :
+ (c === 0x6E/* n */) ? '\x0A' :
+ (c === 0x76/* v */) ? '\x0B' :
+ (c === 0x66/* f */) ? '\x0C' :
+ (c === 0x72/* r */) ? '\x0D' :
+ (c === 0x65/* e */) ? '\x1B' :
+ (c === 0x20/* Space */) ? ' ' :
+ (c === 0x22/* " */) ? '\x22' :
+ (c === 0x2F/* / */) ? '/' :
+ (c === 0x5C/* \ */) ? '\x5C' :
+ (c === 0x4E/* N */) ? '\x85' :
+ (c === 0x5F/* _ */) ? '\xA0' :
+ (c === 0x4C/* L */) ? '\u2028' :
+ (c === 0x50/* P */) ? '\u2029' : '';
+}
+
+function charFromCodepoint(c) {
+ if (c <= 0xFFFF) {
+ return String.fromCharCode(c);
+ }
+ // Encode UTF-16 surrogate pair
+ // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
+ return String.fromCharCode(
+ ((c - 0x010000) >> 10) + 0xD800,
+ ((c - 0x010000) & 0x03FF) + 0xDC00
+ );
+}
+
+var simpleEscapeCheck = new Array(256); // integer, for fast access
+var simpleEscapeMap = new Array(256);
+for (var i = 0; i < 256; i++) {
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
+}
+
+
+function State(input, options) {
+ this.input = input;
+
+ this.filename = options['filename'] || null;
+ this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
+ this.onWarning = options['onWarning'] || null;
+ this.legacy = options['legacy'] || false;
+ this.json = options['json'] || false;
+ this.listener = options['listener'] || null;
+
+ this.implicitTypes = this.schema.compiledImplicit;
+ this.typeMap = this.schema.compiledTypeMap;
+
+ this.length = input.length;
+ this.position = 0;
+ this.line = 0;
+ this.lineStart = 0;
+ this.lineIndent = 0;
+
+ this.documents = [];
+
+ /*
+ this.version;
+ this.checkLineBreaks;
+ this.tagMap;
+ this.anchorMap;
+ this.tag;
+ this.anchor;
+ this.kind;
+ this.result;*/
+
+}
+
+
+function generateError(state, message) {
+ return new YAMLException(
+ message,
+ new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
+}
+
+function throwError(state, message) {
+ throw generateError(state, message);
+}
+
+function throwWarning(state, message) {
+ if (state.onWarning) {
+ state.onWarning.call(null, generateError(state, message));
+ }
+}
+
+
+var directiveHandlers = {
+
+ YAML: function handleYamlDirective(state, name, args) {
+
+ var match, major, minor;
+
+ if (state.version !== null) {
+ throwError(state, 'duplication of %YAML directive');
+ }
+
+ if (args.length !== 1) {
+ throwError(state, 'YAML directive accepts exactly one argument');
+ }
+
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
+
+ if (match === null) {
+ throwError(state, 'ill-formed argument of the YAML directive');
+ }
+
+ major = parseInt(match[1], 10);
+ minor = parseInt(match[2], 10);
+
+ if (major !== 1) {
+ throwError(state, 'unacceptable YAML version of the document');
+ }
+
+ state.version = args[0];
+ state.checkLineBreaks = (minor < 2);
+
+ if (minor !== 1 && minor !== 2) {
+ throwWarning(state, 'unsupported YAML version of the document');
+ }
+ },
+
+ TAG: function handleTagDirective(state, name, args) {
+
+ var handle, prefix;
+
+ if (args.length !== 2) {
+ throwError(state, 'TAG directive accepts exactly two arguments');
+ }
+
+ handle = args[0];
+ prefix = args[1];
+
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
+ throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
+ }
+
+ if (_hasOwnProperty.call(state.tagMap, handle)) {
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
+ }
+
+ if (!PATTERN_TAG_URI.test(prefix)) {
+ throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
+ }
+
+ state.tagMap[handle] = prefix;
+ }
+};
+
+
+function captureSegment(state, start, end, checkJson) {
+ var _position, _length, _character, _result;
+
+ if (start < end) {
+ _result = state.input.slice(start, end);
+
+ if (checkJson) {
+ for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
+ _character = _result.charCodeAt(_position);
+ if (!(_character === 0x09 ||
+ (0x20 <= _character && _character <= 0x10FFFF))) {
+ throwError(state, 'expected valid JSON character');
}
- this._currentIndex++;
- if (this._listRegister.length > this._currentIndex) {
- this._listRegister[this._currentIndex] = childItems;
+ }
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
+ throwError(state, 'the stream contains non-printable characters');
+ }
+
+ state.result += _result;
+ }
+}
+
+function mergeMappings(state, destination, source, overridableKeys) {
+ var sourceKeys, key, index, quantity;
+
+ if (!common.isObject(source)) {
+ throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
+ }
+
+ sourceKeys = Object.keys(source);
+
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
+ key = sourceKeys[index];
+
+ if (!_hasOwnProperty.call(destination, key)) {
+ destination[key] = source[key];
+ overridableKeys[key] = true;
+ }
+ }
+}
+
+function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
+ var index, quantity;
+
+ // The output is a plain object here, so keys can only be strings.
+ // We need to convert keyNode to a string, but doing so can hang the process
+ // (deeply nested arrays that explode exponentially using aliases).
+ if (Array.isArray(keyNode)) {
+ keyNode = Array.prototype.slice.call(keyNode);
+
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
+ if (Array.isArray(keyNode[index])) {
+ throwError(state, 'nested arrays are not supported inside keys');
+ }
+
+ if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
+ keyNode[index] = '[object Object]';
+ }
+ }
+ }
+
+ // Avoid code execution in load() via toString property
+ // (still use its own toString for arrays, timestamps,
+ // and whatever user schema extensions happen to have @@toStringTag)
+ if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
+ keyNode = '[object Object]';
+ }
+
+
+ keyNode = String(keyNode);
+
+ if (_result === null) {
+ _result = {};
+ }
+
+ if (keyTag === 'tag:yaml.org,2002:merge') {
+ if (Array.isArray(valueNode)) {
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
+ }
+ } else {
+ mergeMappings(state, _result, valueNode, overridableKeys);
+ }
+ } else {
+ if (!state.json &&
+ !_hasOwnProperty.call(overridableKeys, keyNode) &&
+ _hasOwnProperty.call(_result, keyNode)) {
+ state.line = startLine || state.line;
+ state.position = startPos || state.position;
+ throwError(state, 'duplicated mapping key');
+ }
+ _result[keyNode] = valueNode;
+ delete overridableKeys[keyNode];
+ }
+
+ return _result;
+}
+
+function readLineBreak(state) {
+ var ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x0A/* LF */) {
+ state.position++;
+ } else if (ch === 0x0D/* CR */) {
+ state.position++;
+ if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
+ state.position++;
+ }
+ } else {
+ throwError(state, 'a line break is expected');
+ }
+
+ state.line += 1;
+ state.lineStart = state.position;
+}
+
+function skipSeparationSpace(state, allowComments, checkIndent) {
+ var lineBreaks = 0,
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+ while (is_WHITE_SPACE(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (allowComments && ch === 0x23/* # */) {
+ do {
+ ch = state.input.charCodeAt(++state.position);
+ } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
+ }
+
+ if (is_EOL(ch)) {
+ readLineBreak(state);
+
+ ch = state.input.charCodeAt(state.position);
+ lineBreaks++;
+ state.lineIndent = 0;
+
+ while (ch === 0x20/* Space */) {
+ state.lineIndent++;
+ ch = state.input.charCodeAt(++state.position);
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
+ throwWarning(state, 'deficient indentation');
+ }
+
+ return lineBreaks;
+}
+
+function testDocumentSeparator(state) {
+ var _position = state.position,
+ ch;
+
+ ch = state.input.charCodeAt(_position);
+
+ // Condition state.position === state.lineStart is tested
+ // in parent on each call, for efficiency. No needs to test here again.
+ if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
+ ch === state.input.charCodeAt(_position + 1) &&
+ ch === state.input.charCodeAt(_position + 2)) {
+
+ _position += 3;
+
+ ch = state.input.charCodeAt(_position);
+
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function writeFoldedLines(state, count) {
+ if (count === 1) {
+ state.result += ' ';
+ } else if (count > 1) {
+ state.result += common.repeat('\n', count - 1);
+ }
+}
+
+
+function readPlainScalar(state, nodeIndent, withinFlowCollection) {
+ var preceding,
+ following,
+ captureStart,
+ captureEnd,
+ hasPendingContent,
+ _line,
+ _lineStart,
+ _lineIndent,
+ _kind = state.kind,
+ _result = state.result,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (is_WS_OR_EOL(ch) ||
+ is_FLOW_INDICATOR(ch) ||
+ ch === 0x23/* # */ ||
+ ch === 0x26/* & */ ||
+ ch === 0x2A/* * */ ||
+ ch === 0x21/* ! */ ||
+ ch === 0x7C/* | */ ||
+ ch === 0x3E/* > */ ||
+ ch === 0x27/* ' */ ||
+ ch === 0x22/* " */ ||
+ ch === 0x25/* % */ ||
+ ch === 0x40/* @ */ ||
+ ch === 0x60/* ` */) {
+ return false;
+ }
+
+ if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following) ||
+ withinFlowCollection && is_FLOW_INDICATOR(following)) {
+ return false;
+ }
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ captureStart = captureEnd = state.position;
+ hasPendingContent = false;
+
+ while (ch !== 0) {
+ if (ch === 0x3A/* : */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following) ||
+ withinFlowCollection && is_FLOW_INDICATOR(following)) {
+ break;
+ }
+
+ } else if (ch === 0x23/* # */) {
+ preceding = state.input.charCodeAt(state.position - 1);
+
+ if (is_WS_OR_EOL(preceding)) {
+ break;
+ }
+
+ } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
+ withinFlowCollection && is_FLOW_INDICATOR(ch)) {
+ break;
+
+ } else if (is_EOL(ch)) {
+ _line = state.line;
+ _lineStart = state.lineStart;
+ _lineIndent = state.lineIndent;
+ skipSeparationSpace(state, false, -1);
+
+ if (state.lineIndent >= nodeIndent) {
+ hasPendingContent = true;
+ ch = state.input.charCodeAt(state.position);
+ continue;
+ } else {
+ state.position = captureEnd;
+ state.line = _line;
+ state.lineStart = _lineStart;
+ state.lineIndent = _lineIndent;
+ break;
+ }
+ }
+
+ if (hasPendingContent) {
+ captureSegment(state, captureStart, captureEnd, false);
+ writeFoldedLines(state, state.line - _line);
+ captureStart = captureEnd = state.position;
+ hasPendingContent = false;
+ }
+
+ if (!is_WHITE_SPACE(ch)) {
+ captureEnd = state.position + 1;
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ captureSegment(state, captureStart, captureEnd, false);
+
+ if (state.result) {
+ return true;
+ }
+
+ state.kind = _kind;
+ state.result = _result;
+ return false;
+}
+
+function readSingleQuotedScalar(state, nodeIndent) {
+ var ch,
+ captureStart, captureEnd;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x27/* ' */) {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ state.position++;
+ captureStart = captureEnd = state.position;
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ if (ch === 0x27/* ' */) {
+ captureSegment(state, captureStart, state.position, true);
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x27/* ' */) {
+ captureStart = state.position;
+ state.position++;
+ captureEnd = state.position;
+ } else {
+ return true;
+ }
+
+ } else if (is_EOL(ch)) {
+ captureSegment(state, captureStart, captureEnd, true);
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
+ captureStart = captureEnd = state.position;
+
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
+ throwError(state, 'unexpected end of the document within a single quoted scalar');
+
+ } else {
+ state.position++;
+ captureEnd = state.position;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a single quoted scalar');
+}
+
+function readDoubleQuotedScalar(state, nodeIndent) {
+ var captureStart,
+ captureEnd,
+ hexLength,
+ hexResult,
+ tmp,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x22/* " */) {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ state.position++;
+ captureStart = captureEnd = state.position;
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ if (ch === 0x22/* " */) {
+ captureSegment(state, captureStart, state.position, true);
+ state.position++;
+ return true;
+
+ } else if (ch === 0x5C/* \ */) {
+ captureSegment(state, captureStart, state.position, true);
+ ch = state.input.charCodeAt(++state.position);
+
+ if (is_EOL(ch)) {
+ skipSeparationSpace(state, false, nodeIndent);
+
+ // TODO: rework to inline fn with no type cast?
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
+ state.result += simpleEscapeMap[ch];
+ state.position++;
+
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
+ hexLength = tmp;
+ hexResult = 0;
+
+ for (; hexLength > 0; hexLength--) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if ((tmp = fromHexCode(ch)) >= 0) {
+ hexResult = (hexResult << 4) + tmp;
+
+ } else {
+ throwError(state, 'expected hexadecimal character');
+ }
}
- else {
- this._listRegister.push(childItems);
+
+ state.result += charFromCodepoint(hexResult);
+
+ state.position++;
+
+ } else {
+ throwError(state, 'unknown escape sequence');
+ }
+
+ captureStart = captureEnd = state.position;
+
+ } else if (is_EOL(ch)) {
+ captureSegment(state, captureStart, captureEnd, true);
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
+ captureStart = captureEnd = state.position;
+
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
+ throwError(state, 'unexpected end of the document within a double quoted scalar');
+
+ } else {
+ state.position++;
+ captureEnd = state.position;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a double quoted scalar');
+}
+
+function readFlowCollection(state, nodeIndent) {
+ var readNext = true,
+ _line,
+ _tag = state.tag,
+ _result,
+ _anchor = state.anchor,
+ following,
+ terminator,
+ isPair,
+ isExplicitPair,
+ isMapping,
+ overridableKeys = {},
+ keyNode,
+ keyTag,
+ valueNode,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x5B/* [ */) {
+ terminator = 0x5D;/* ] */
+ isMapping = false;
+ _result = [];
+ } else if (ch === 0x7B/* { */) {
+ terminator = 0x7D;/* } */
+ isMapping = true;
+ _result = {};
+ } else {
+ return false;
+ }
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+
+ while (ch !== 0) {
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === terminator) {
+ state.position++;
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = isMapping ? 'mapping' : 'sequence';
+ state.result = _result;
+ return true;
+ } else if (!readNext) {
+ throwError(state, 'missed comma between flow collection entries');
+ }
+
+ keyTag = keyNode = valueNode = null;
+ isPair = isExplicitPair = false;
+
+ if (ch === 0x3F/* ? */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following)) {
+ isPair = isExplicitPair = true;
+ state.position++;
+ skipSeparationSpace(state, true, nodeIndent);
+ }
+ }
+
+ _line = state.line;
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
+ keyTag = state.tag;
+ keyNode = state.result;
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
+ isPair = true;
+ ch = state.input.charCodeAt(++state.position);
+ skipSeparationSpace(state, true, nodeIndent);
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
+ valueNode = state.result;
+ }
+
+ if (isMapping) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
+ } else if (isPair) {
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
+ } else {
+ _result.push(keyNode);
+ }
+
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x2C/* , */) {
+ readNext = true;
+ ch = state.input.charCodeAt(++state.position);
+ } else {
+ readNext = false;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a flow collection');
+}
+
+function readBlockScalar(state, nodeIndent) {
+ var captureStart,
+ folding,
+ chomping = CHOMPING_CLIP,
+ didReadContent = false,
+ detectedIndent = false,
+ textIndent = nodeIndent,
+ emptyLines = 0,
+ atMoreIndented = false,
+ tmp,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x7C/* | */) {
+ folding = false;
+ } else if (ch === 0x3E/* > */) {
+ folding = true;
+ } else {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+
+ while (ch !== 0) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
+ if (CHOMPING_CLIP === chomping) {
+ chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
+ } else {
+ throwError(state, 'repeat of a chomping mode identifier');
+ }
+
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
+ if (tmp === 0) {
+ throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
+ } else if (!detectedIndent) {
+ textIndent = nodeIndent + tmp - 1;
+ detectedIndent = true;
+ } else {
+ throwError(state, 'repeat of an indentation width identifier');
+ }
+
+ } else {
+ break;
+ }
+ }
+
+ if (is_WHITE_SPACE(ch)) {
+ do { ch = state.input.charCodeAt(++state.position); }
+ while (is_WHITE_SPACE(ch));
+
+ if (ch === 0x23/* # */) {
+ do { ch = state.input.charCodeAt(++state.position); }
+ while (!is_EOL(ch) && (ch !== 0));
+ }
+ }
+
+ while (ch !== 0) {
+ readLineBreak(state);
+ state.lineIndent = 0;
+
+ ch = state.input.charCodeAt(state.position);
+
+ while ((!detectedIndent || state.lineIndent < textIndent) &&
+ (ch === 0x20/* Space */)) {
+ state.lineIndent++;
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (!detectedIndent && state.lineIndent > textIndent) {
+ textIndent = state.lineIndent;
+ }
+
+ if (is_EOL(ch)) {
+ emptyLines++;
+ continue;
+ }
+
+ // End of the scalar.
+ if (state.lineIndent < textIndent) {
+
+ // Perform the chomping.
+ if (chomping === CHOMPING_KEEP) {
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+ } else if (chomping === CHOMPING_CLIP) {
+ if (didReadContent) { // i.e. only if the scalar is not empty.
+ state.result += '\n';
}
- 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) });
+ }
+
+ // Break this `while` cycle and go to the funciton's epilogue.
+ break;
+ }
+
+ // Folded style: use fancy rules to handle line breaks.
+ if (folding) {
+
+ // Lines starting with white space characters (more-indented lines) are not folded.
+ if (is_WHITE_SPACE(ch)) {
+ atMoreIndented = true;
+ // except for the first content line (cf. Example 8.1)
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+
+ // End of more-indented block.
+ } else if (atMoreIndented) {
+ atMoreIndented = false;
+ state.result += common.repeat('\n', emptyLines + 1);
+
+ // Just one line break - perceive as the same line.
+ } else if (emptyLines === 0) {
+ if (didReadContent) { // i.e. only if we have already read some scalar content.
+ state.result += ' ';
}
- 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) });
- }
+
+ // Several line breaks - perceive as different lines.
+ } else {
+ state.result += common.repeat('\n', emptyLines);
+ }
+
+ // Literal style: just add exact number of line breaks between content lines.
+ } else {
+ // Keep all line breaks except the header line break.
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+ }
+
+ didReadContent = true;
+ detectedIndent = true;
+ emptyLines = 0;
+ captureStart = state.position;
+
+ while (!is_EOL(ch) && (ch !== 0)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ captureSegment(state, captureStart, state.position, false);
+ }
+
+ return true;
+}
+
+function readBlockSequence(state, nodeIndent) {
+ var _line,
+ _tag = state.tag,
+ _anchor = state.anchor,
+ _result = [],
+ following,
+ detected = false,
+ ch;
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+
+ if (ch !== 0x2D/* - */) {
+ break;
+ }
+
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (!is_WS_OR_EOL(following)) {
+ break;
+ }
+
+ detected = true;
+ state.position++;
+
+ if (skipSeparationSpace(state, true, -1)) {
+ if (state.lineIndent <= nodeIndent) {
+ _result.push(null);
+ ch = state.input.charCodeAt(state.position);
+ continue;
+ }
+ }
+
+ _line = state.line;
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
+ _result.push(state.result);
+ skipSeparationSpace(state, true, -1);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
+ throwError(state, 'bad indentation of a sequence entry');
+ } else if (state.lineIndent < nodeIndent) {
+ break;
+ }
+ }
+
+ if (detected) {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = 'sequence';
+ state.result = _result;
+ return true;
+ }
+ return false;
+}
+
+function readBlockMapping(state, nodeIndent, flowIndent) {
+ var following,
+ allowCompact,
+ _line,
+ _pos,
+ _tag = state.tag,
+ _anchor = state.anchor,
+ _result = {},
+ overridableKeys = {},
+ keyTag = null,
+ keyNode = null,
+ valueNode = null,
+ atExplicitKey = false,
+ detected = false,
+ ch;
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+ following = state.input.charCodeAt(state.position + 1);
+ _line = state.line; // Save the current line.
+ _pos = state.position;
+
+ //
+ // Explicit notation case. There are two separate blocks:
+ // first for the key (denoted by "?") and second for the value (denoted by ":")
+ //
+ if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
+
+ if (ch === 0x3F/* ? */) {
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
+ keyTag = keyNode = valueNode = null;
}
- };
- /** @inheritdoc */
- ObjectWriter.prototype.comment = function (data) {
- if (this._currentList.length === 0) {
- this._currentList.push({ "!": data });
+
+ detected = true;
+ atExplicitKey = true;
+ allowCompact = true;
+
+ } else if (atExplicitKey) {
+ // i.e. 0x3A/* : */ === character after the explicit key.
+ atExplicitKey = false;
+ allowCompact = true;
+
+ } else {
+ throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
+ }
+
+ state.position += 1;
+ ch = following;
+
+ //
+ // Implicit notation case. Flow-style node as the key first, then ":", and the value.
+ //
+ } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
+
+ if (state.line === _line) {
+ ch = state.input.charCodeAt(state.position);
+
+ while (is_WHITE_SPACE(ch)) {
+ ch = state.input.charCodeAt(++state.position);
}
- 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 });
- }
+
+ if (ch === 0x3A/* : */) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if (!is_WS_OR_EOL(ch)) {
+ throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
+ }
+
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
+ keyTag = keyNode = valueNode = null;
+ }
+
+ detected = true;
+ atExplicitKey = false;
+ allowCompact = false;
+ keyTag = state.tag;
+ keyNode = state.result;
+
+ } else if (detected) {
+ throwError(state, 'can not read an implicit mapping pair; a colon is missed');
+
+ } else {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ return true; // Keep the result of `composeNode`.
}
- };
- /** @inheritdoc */
- ObjectWriter.prototype.text = function (data) {
- if (this._currentList.length === 0) {
- this._currentList.push({ "#": data });
+
+ } else if (detected) {
+ throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
+
+ } else {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ return true; // Keep the result of `composeNode`.
+ }
+
+ } else {
+ break; // Reading is done. Go to the epilogue.
+ }
+
+ //
+ // Common reading code for both explicit and implicit notations.
+ //
+ if (state.line === _line || state.lineIndent > nodeIndent) {
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
+ if (atExplicitKey) {
+ keyNode = state.result;
+ } else {
+ valueNode = state.result;
}
- 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 });
- }
+ }
+
+ if (!atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
+ keyTag = keyNode = valueNode = null;
+ }
+
+ skipSeparationSpace(state, true, -1);
+ ch = state.input.charCodeAt(state.position);
+ }
+
+ if (state.lineIndent > nodeIndent && (ch !== 0)) {
+ throwError(state, 'bad indentation of a mapping entry');
+ } else if (state.lineIndent < nodeIndent) {
+ break;
+ }
+ }
+
+ //
+ // Epilogue.
+ //
+
+ // Special case: last mapping's node contains only the key in explicit notation.
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
+ }
+
+ // Expose the resulting mapping.
+ if (detected) {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = 'mapping';
+ state.result = _result;
+ }
+
+ return detected;
+}
+
+function readTagProperty(state) {
+ var _position,
+ isVerbatim = false,
+ isNamed = false,
+ tagHandle,
+ tagName,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x21/* ! */) return false;
+
+ if (state.tag !== null) {
+ throwError(state, 'duplication of a tag property');
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x3C/* < */) {
+ isVerbatim = true;
+ ch = state.input.charCodeAt(++state.position);
+
+ } else if (ch === 0x21/* ! */) {
+ isNamed = true;
+ tagHandle = '!!';
+ ch = state.input.charCodeAt(++state.position);
+
+ } else {
+ tagHandle = '!';
+ }
+
+ _position = state.position;
+
+ if (isVerbatim) {
+ do { ch = state.input.charCodeAt(++state.position); }
+ while (ch !== 0 && ch !== 0x3E/* > */);
+
+ if (state.position < state.length) {
+ tagName = state.input.slice(_position, state.position);
+ ch = state.input.charCodeAt(++state.position);
+ } else {
+ throwError(state, 'unexpected end of the stream within a verbatim tag');
+ }
+ } else {
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+
+ if (ch === 0x21/* ! */) {
+ if (!isNamed) {
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
+
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
+ throwError(state, 'named tag handle cannot contain such characters');
+ }
+
+ isNamed = true;
+ _position = state.position + 1;
+ } else {
+ throwError(state, 'tag suffix cannot contain exclamation marks');
}
- };
- /** @inheritdoc */
- ObjectWriter.prototype.instruction = function (target, data) {
- var value = (data === "" ? target : target + " " + data);
- if (this._currentList.length === 0) {
- this._currentList.push({ "?": value });
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ tagName = state.input.slice(_position, state.position);
+
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
+ throwError(state, 'tag suffix cannot contain flow indicator characters');
+ }
+ }
+
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
+ throwError(state, 'tag name cannot contain such characters: ' + tagName);
+ }
+
+ if (isVerbatim) {
+ state.tag = tagName;
+
+ } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
+ state.tag = state.tagMap[tagHandle] + tagName;
+
+ } else if (tagHandle === '!') {
+ state.tag = '!' + tagName;
+
+ } else if (tagHandle === '!!') {
+ state.tag = 'tag:yaml.org,2002:' + tagName;
+
+ } else {
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
+ }
+
+ return true;
+}
+
+function readAnchorProperty(state) {
+ var _position,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x26/* & */) return false;
+
+ if (state.anchor !== null) {
+ throwError(state, 'duplication of an anchor property');
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (state.position === _position) {
+ throwError(state, 'name of an anchor node must contain at least one character');
+ }
+
+ state.anchor = state.input.slice(_position, state.position);
+ return true;
+}
+
+function readAlias(state) {
+ var _position, alias,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x2A/* * */) return false;
+
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (state.position === _position) {
+ throwError(state, 'name of an alias node must contain at least one character');
+ }
+
+ alias = state.input.slice(_position, state.position);
+
+ if (!state.anchorMap.hasOwnProperty(alias)) {
+ throwError(state, 'unidentified alias "' + alias + '"');
+ }
+
+ state.result = state.anchorMap[alias];
+ skipSeparationSpace(state, true, -1);
+ return true;
+}
+
+function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
+ var allowBlockStyles,
+ allowBlockScalars,
+ allowBlockCollections,
+ indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) {
+ indentStatus = 1;
+ } else if (state.lineIndent === parentIndent) {
+ indentStatus = 0;
+ } else if (state.lineIndent < parentIndent) {
+ indentStatus = -1;
+ }
+ }
+ }
+
+ if (indentStatus === 1) {
+ while (readTagProperty(state) || readAnchorProperty(state)) {
+ if (skipSeparationSpace(state, true, -1)) {
+ atNewLine = true;
+ allowBlockCollections = allowBlockStyles;
+
+ if (state.lineIndent > parentIndent) {
+ indentStatus = 1;
+ } else if (state.lineIndent === parentIndent) {
+ indentStatus = 0;
+ } else if (state.lineIndent < parentIndent) {
+ indentStatus = -1;
}
- 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 });
- }
+ } else {
+ allowBlockCollections = false;
+ }
+ }
+ }
+
+ if (allowBlockCollections) {
+ allowBlockCollections = atNewLine || allowCompact;
+ }
+
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
+ flowIndent = parentIndent;
+ } else {
+ flowIndent = parentIndent + 1;
+ }
+
+ blockIndent = state.position - state.lineStart;
+
+ if (indentStatus === 1) {
+ if (allowBlockCollections &&
+ (readBlockSequence(state, blockIndent) ||
+ readBlockMapping(state, blockIndent, flowIndent)) ||
+ readFlowCollection(state, flowIndent)) {
+ hasContent = true;
+ } else {
+ if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
+ readSingleQuotedScalar(state, flowIndent) ||
+ readDoubleQuotedScalar(state, flowIndent)) {
+ hasContent = true;
+
+ } else if (readAlias(state)) {
+ hasContent = true;
+
+ if (state.tag !== null || state.anchor !== null) {
+ throwError(state, 'alias node should not have any properties');
+ }
+
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
+ hasContent = true;
+
+ if (state.tag === null) {
+ state.tag = '?';
+ }
}
- };
- /** @inheritdoc */
- ObjectWriter.prototype.cdata = function (data) {
- if (this._currentList.length === 0) {
- this._currentList.push({ "$": data });
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
}
- 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 (indentStatus === 0) {
+ // Special case: block sequences are allowed to have same indentation level as the parent.
+ // http://www.yaml.org/spec/1.2/spec.html#id2799784
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
+ }
+ }
+
+ if (state.tag !== null && state.tag !== '!') {
+ if (state.tag === '?') {
+ // Implicit resolving is not allowed for non-scalar types, and '?'
+ // non-specific tag is only automatically assigned to plain scalars.
+ //
+ // We only need to check kind conformity in case user explicitly assigns '?'
+ // tag, for example like this: "!> [0]"
+ //
+ if (state.result !== null && state.kind !== 'scalar') {
+ throwError(state, 'unacceptable node kind for !> tag; it should be "scalar", not "' + state.kind + '"');
+ }
+
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
+ type = state.implicitTypes[typeIndex];
+
+ if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
+ state.result = type.construct(state.result);
+ state.tag = type.tag;
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
+ }
+ break;
}
- };
- 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;
- };
- /**
- * 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.");
+ }
+ } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
+ type = state.typeMap[state.kind || 'fallback'][state.tag];
+
+ if (state.result !== null && type.kind !== state.kind) {
+ throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
+ }
+
+ if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
+ throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
+ } else {
+ state.result = type.construct(state.result);
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
}
- };
- return ObjectWriter;
-}(BaseWriter_1.BaseWriter));
-exports.ObjectWriter = ObjectWriter;
-//# sourceMappingURL=ObjectWriter.js.map
+ }
+ } else {
+ throwError(state, 'unknown tag !<' + state.tag + '>');
+ }
+ }
+
+ if (state.listener !== null) {
+ state.listener('close', state);
+ }
+ return state.tag !== null || state.anchor !== null || hasContent;
+}
+
+function readDocument(state) {
+ var documentStart = state.position,
+ _position,
+ directiveName,
+ directiveArgs,
+ hasDirectives = false,
+ ch;
+
+ state.version = null;
+ state.checkLineBreaks = state.legacy;
+ state.tagMap = {};
+ state.anchorMap = {};
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ skipSeparationSpace(state, true, -1);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (state.lineIndent > 0 || ch !== 0x25/* % */) {
+ break;
+ }
+
+ hasDirectives = true;
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ directiveName = state.input.slice(_position, state.position);
+ directiveArgs = [];
+
+ if (directiveName.length < 1) {
+ throwError(state, 'directive name must not be less than one character in length');
+ }
+
+ while (ch !== 0) {
+ while (is_WHITE_SPACE(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (ch === 0x23/* # */) {
+ do { ch = state.input.charCodeAt(++state.position); }
+ while (ch !== 0 && !is_EOL(ch));
+ break;
+ }
+
+ if (is_EOL(ch)) break;
+
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ directiveArgs.push(state.input.slice(_position, state.position));
+ }
+
+ if (ch !== 0) readLineBreak(state);
+
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
+ } else {
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
+ }
+ }
+
+ skipSeparationSpace(state, true, -1);
+
+ if (state.lineIndent === 0 &&
+ state.input.charCodeAt(state.position) === 0x2D/* - */ &&
+ state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
+ state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
+ state.position += 3;
+ skipSeparationSpace(state, true, -1);
+
+ } else if (hasDirectives) {
+ throwError(state, 'directives end mark is expected');
+ }
+
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
+ skipSeparationSpace(state, true, -1);
+
+ if (state.checkLineBreaks &&
+ PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
+ throwWarning(state, 'non-ASCII line breaks are interpreted as content');
+ }
+
+ state.documents.push(state.result);
+
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
+
+ if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
+ state.position += 3;
+ skipSeparationSpace(state, true, -1);
+ }
+ return;
+ }
+
+ if (state.position < (state.length - 1)) {
+ throwError(state, 'end of the stream or a document separator is expected');
+ } else {
+ return;
+ }
+}
+
+
+function loadDocuments(input, options) {
+ input = String(input);
+ options = options || {};
+
+ if (input.length !== 0) {
+
+ // Add tailing `\n` if not exists
+ if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
+ input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
+ input += '\n';
+ }
+
+ // Strip BOM
+ if (input.charCodeAt(0) === 0xFEFF) {
+ input = input.slice(1);
+ }
+ }
+
+ var state = new State(input, options);
+
+ var nullpos = input.indexOf('\0');
+
+ if (nullpos !== -1) {
+ state.position = nullpos;
+ throwError(state, 'null byte is not allowed in input');
+ }
+
+ // Use 0 as string terminator. That significantly simplifies bounds check.
+ state.input += '\0';
+
+ while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
+ state.lineIndent += 1;
+ state.position += 1;
+ }
+
+ while (state.position < (state.length - 1)) {
+ readDocument(state);
+ }
+
+ return state.documents;
+}
+
+
+function loadAll(input, iterator, options) {
+ if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
+ options = iterator;
+ iterator = null;
+ }
+
+ var documents = loadDocuments(input, options);
+
+ if (typeof iterator !== 'function') {
+ return documents;
+ }
+
+ for (var index = 0, length = documents.length; index < length; index += 1) {
+ iterator(documents[index]);
+ }
+}
+
+
+function load(input, options) {
+ var documents = loadDocuments(input, options);
+
+ if (documents.length === 0) {
+ /*eslint-disable no-undefined*/
+ return undefined;
+ } else if (documents.length === 1) {
+ return documents[0];
+ }
+ throw new YAMLException('expected a single document in the stream, but found more');
+}
+
+
+function safeLoadAll(input, iterator, options) {
+ if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
+ options = iterator;
+ iterator = null;
+ }
+
+ return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
+}
+
+
+function safeLoad(input, options) {
+ return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
+}
+
+
+module.exports.loadAll = loadAll;
+module.exports.load = load;
+module.exports.safeLoadAll = safeLoadAll;
+module.exports.safeLoad = safeLoad;
+
+
+/***/ }),
+
+/***/ 77262:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+
+var common = __nccwpck_require__(59941);
+
+
+function Mark(name, buffer, position, line, column) {
+ this.name = name;
+ this.buffer = buffer;
+ this.position = position;
+ this.line = line;
+ this.column = column;
+}
+
+
+Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
+ var head, start, tail, end, snippet;
+
+ if (!this.buffer) return null;
+
+ indent = indent || 4;
+ maxLength = maxLength || 75;
+
+ head = '';
+ start = this.position;
+
+ while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
+ start -= 1;
+ if (this.position - start > (maxLength / 2 - 1)) {
+ head = ' ... ';
+ start += 5;
+ break;
+ }
+ }
+
+ tail = '';
+ end = this.position;
+
+ while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
+ end += 1;
+ if (end - this.position > (maxLength / 2 - 1)) {
+ tail = ' ... ';
+ end -= 5;
+ break;
+ }
+ }
+
+ snippet = this.buffer.slice(start, end);
+
+ return common.repeat(' ', indent) + head + snippet + tail + '\n' +
+ common.repeat(' ', indent + this.position - start + head.length) + '^';
+};
+
+
+Mark.prototype.toString = function toString(compact) {
+ var snippet, where = '';
+
+ if (this.name) {
+ where += 'in "' + this.name + '" ';
+ }
+
+ where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
+
+ if (!compact) {
+ snippet = this.getSnippet();
+
+ if (snippet) {
+ where += ':\n' + snippet;
+ }
+ }
+
+ return where;
+};
+
+
+module.exports = Mark;
+
+
+/***/ }),
+
+/***/ 66280:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+/*eslint-disable max-len*/
+
+var common = __nccwpck_require__(59941);
+var YAMLException = __nccwpck_require__(29291);
+var Type = __nccwpck_require__(90256);
+
+
+function compileList(schema, name, result) {
+ var exclude = [];
+
+ schema.include.forEach(function (includedSchema) {
+ result = compileList(includedSchema, name, result);
+ });
+
+ schema[name].forEach(function (currentType) {
+ result.forEach(function (previousType, previousIndex) {
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
+ exclude.push(previousIndex);
+ }
+ });
+
+ result.push(currentType);
+ });
+
+ return result.filter(function (type, index) {
+ return exclude.indexOf(index) === -1;
+ });
+}
+
+
+function compileMap(/* lists... */) {
+ var result = {
+ scalar: {},
+ sequence: {},
+ mapping: {},
+ fallback: {}
+ }, index, length;
+
+ function collectType(type) {
+ result[type.kind][type.tag] = result['fallback'][type.tag] = type;
+ }
+
+ for (index = 0, length = arguments.length; index < length; index += 1) {
+ arguments[index].forEach(collectType);
+ }
+ return result;
+}
+
+
+function Schema(definition) {
+ this.include = definition.include || [];
+ this.implicit = definition.implicit || [];
+ this.explicit = definition.explicit || [];
+
+ this.implicit.forEach(function (type) {
+ if (type.loadKind && type.loadKind !== 'scalar') {
+ throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
+ }
+ });
+
+ this.compiledImplicit = compileList(this, 'implicit', []);
+ this.compiledExplicit = compileList(this, 'explicit', []);
+ this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
+}
+
+
+Schema.DEFAULT = null;
+
+
+Schema.create = function createSchema() {
+ var schemas, types;
+
+ switch (arguments.length) {
+ case 1:
+ schemas = Schema.DEFAULT;
+ types = arguments[0];
+ break;
+
+ case 2:
+ schemas = arguments[0];
+ types = arguments[1];
+ break;
+
+ default:
+ throw new YAMLException('Wrong number of arguments for Schema.create function');
+ }
+
+ schemas = common.toArray(schemas);
+ types = common.toArray(types);
+
+ if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
+ throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
+ }
+
+ if (!types.every(function (type) { return type instanceof Type; })) {
+ throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
+ }
+
+ return new Schema({
+ include: schemas,
+ explicit: types
+ });
+};
+
+
+module.exports = Schema;
+
/***/ }),
-/***/ 77572:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+/***/ 11950:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
+// Standard YAML's Core schema.
+// http://www.yaml.org/spec/1.2/spec.html#id2804923
+//
+// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
+// So, Core schema has no distinctions from JSON schema is JS-YAML.
+
+
+
+
+
+var Schema = __nccwpck_require__(66280);
+
+
+module.exports = new Schema({
+ include: [
+ __nccwpck_require__(2168)
+ ]
+});
+
+
+/***/ }),
+
+/***/ 145:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+
+"use strict";
+// JS-YAML's default schema for `load` function.
+// It is not described in the YAML specification.
+//
+// This schema is based on JS-YAML's default safe schema and includes
+// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
+//
+// Also this schema is used as default base schema at `Schema.create` function.
+
+
+
+
+
+var Schema = __nccwpck_require__(66280);
+
+
+module.exports = Schema.DEFAULT = new Schema({
+ include: [
+ __nccwpck_require__(42881)
+ ],
+ explicit: [
+ __nccwpck_require__(34801),
+ __nccwpck_require__(77234),
+ __nccwpck_require__(35361)
+ ]
+});
-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__(50708);
-/**
- * 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 "";
- };
- /** @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() + "" + target + " " + data + "?>";
- }
- else {
- return this._beginLine() + "" + target + "?>";
- }
- };
- /** @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 " />";
- }
- else if (selfClosing) {
- if (this._writerOptions.allowEmptyTags) {
- return ">" + name + ">";
- }
- else if (this._writerOptions.spaceBeforeSlash) {
- return " />";
- }
- else {
- return "/>";
- }
- }
- else {
- return ">";
- }
- };
- /** @inheritdoc */
- XMLCBWriter.prototype.closeTag = function (name) {
- return this._beginLine() + "" + 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;
- }
- };
- /** @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 "";
- }
- };
- /**
- * 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
/***/ }),
-/***/ 59606:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+/***/ 42881:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
+// JS-YAML's default schema for `safeLoad` function.
+// It is not described in the YAML specification.
+//
+// This schema is based on standard YAML's Core schema and includes most of
+// extra types described at YAML tag repository. (http://yaml.org/type/)
+
+
+
+
+
+var Schema = __nccwpck_require__(66280);
+
+
+module.exports = new Schema({
+ include: [
+ __nccwpck_require__(11950)
+ ],
+ implicit: [
+ __nccwpck_require__(82018),
+ __nccwpck_require__(60194)
+ ],
+ explicit: [
+ __nccwpck_require__(21716),
+ __nccwpck_require__(96439),
+ __nccwpck_require__(33730),
+ __nccwpck_require__(9047)
+ ]
+});
-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__(76195);
-var interfaces_1 = __nccwpck_require__(27305);
-var BaseWriter_1 = __nccwpck_require__(37644);
-var util_2 = __nccwpck_require__(65282);
-/**
- * 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;
- };
- /** @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 += "";
- }
- else if (publicId) {
- this._refs.markup += "";
- }
- else if (systemId) {
- this._refs.markup += "";
- }
- else {
- this._refs.markup += "";
- }
- this._endLine();
- };
- /** @inheritdoc */
- XMLWriter.prototype.openTagBegin = function (name) {
- this._beginLine();
- this._refs.markup += "<" + name;
- };
- /** @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 += ">" + name + ">";
- }
- else {
- this._refs.markup += voidElement ? " />" :
- (selfClosing || this._refs.emptyNode) ? (this._writerOptions.spaceBeforeSlash ? " />" : "/>") : ">";
- }
- this._endLine();
- };
- /** @inheritdoc */
- XMLWriter.prototype.closeTag = function (name) {
- if (!this._refs.emptyNode) {
- this._beginLine();
- this._refs.markup += "" + name + ">";
- }
- 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();
- }
- };
- /** @inheritdoc */
- XMLWriter.prototype.cdata = function (data) {
- if (data !== '') {
- this._beginLine();
- this._refs.markup += "";
- this._endLine();
- }
- };
- /** @inheritdoc */
- XMLWriter.prototype.comment = function (data) {
- this._beginLine();
- this._refs.markup += "";
- this._endLine();
- };
- /** @inheritdoc */
- XMLWriter.prototype.instruction = function (target, data) {
- this._beginLine();
- this._refs.markup += "" + (data === "" ? target : target + " " + data) + "?>";
- this._endLine();
- };
- /**
- * 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;
- }
- };
- /**
- * 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
/***/ }),
-/***/ 42444:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+/***/ 70026:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
+// Standard YAML's Failsafe schema.
+// http://www.yaml.org/spec/1.2/spec.html#id2802346
+
+
+
+
+
+var Schema = __nccwpck_require__(66280);
+
+
+module.exports = new Schema({
+ explicit: [
+ __nccwpck_require__(24649),
+ __nccwpck_require__(65629),
+ __nccwpck_require__(15938)
+ ]
+});
+
+
+/***/ }),
+
+/***/ 2168:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+
+"use strict";
+// Standard YAML's JSON schema.
+// http://www.yaml.org/spec/1.2/spec.html#id2803231
+//
+// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
+// So, this schema is not such strict as defined in the YAML specification.
+// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
+
+
+
+
+
+var Schema = __nccwpck_require__(66280);
+
+
+module.exports = new Schema({
+ include: [
+ __nccwpck_require__(70026)
+ ],
+ implicit: [
+ __nccwpck_require__(26058),
+ __nccwpck_require__(93195),
+ __nccwpck_require__(76865),
+ __nccwpck_require__(16480)
+ ]
+});
+
+
+/***/ }),
+
+/***/ 90256:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+var YAMLException = __nccwpck_require__(29291);
+
+var TYPE_CONSTRUCTOR_OPTIONS = [
+ 'kind',
+ 'resolve',
+ 'construct',
+ 'instanceOf',
+ 'predicate',
+ 'represent',
+ 'defaultStyle',
+ 'styleAliases'
+];
+
+var YAML_NODE_KINDS = [
+ 'scalar',
+ 'sequence',
+ 'mapping'
+];
+
+function compileStyleAliases(map) {
+ var result = {};
+
+ if (map !== null) {
+ Object.keys(map).forEach(function (style) {
+ map[style].forEach(function (alias) {
+ result[String(alias)] = style;
+ });
+ });
+ }
+
+ return result;
+}
+
+function Type(tag, options) {
+ options = options || {};
+
+ Object.keys(options).forEach(function (name) {
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
+ throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
+ }
+ });
+
+ // TODO: Add tag format check.
+ this.tag = tag;
+ this.kind = options['kind'] || null;
+ this.resolve = options['resolve'] || function () { return true; };
+ this.construct = options['construct'] || function (data) { return data; };
+ this.instanceOf = options['instanceOf'] || null;
+ this.predicate = options['predicate'] || null;
+ this.represent = options['represent'] || null;
+ this.defaultStyle = options['defaultStyle'] || null;
+ this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
+
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
+ throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
+ }
+}
+
+module.exports = Type;
-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__(50708);
-/**
- * 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.");
- }
- 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;
- }
- 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("");
- }
- 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;
- }
- };
- /**
- * 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
/***/ }),
-/***/ 96517:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+/***/ 21716:
+/***/ ((module, __unused_webpack_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__(50243);
-var util_1 = __nccwpck_require__(76195);
-var BaseWriter_1 = __nccwpck_require__(37644);
-/**
- * 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
-/***/ }),
+/*eslint-disable no-bitwise*/
+
+var NodeBuffer;
+
+try {
+ // A trick for browserified version, to not include `Buffer` shim
+ var _require = require;
+ NodeBuffer = _require('buffer').Buffer;
+} catch (__) {}
+
+var Type = __nccwpck_require__(90256);
+
+
+// [ 64, 65, 66 ] -> [ padding, CR, LF ]
+var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
+
+
+function resolveYamlBinary(data) {
+ if (data === null) return false;
+
+ var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
+
+ // Convert one by one.
+ for (idx = 0; idx < max; idx++) {
+ code = map.indexOf(data.charAt(idx));
+
+ // Skip CR/LF
+ if (code > 64) continue;
-/***/ 17476:
-/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+ // Fail on illegal characters
+ if (code < 0) return false;
-"use strict";
+ bitlen += 6;
+ }
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-var MapWriter_1 = __nccwpck_require__(41397);
-exports.MapWriter = MapWriter_1.MapWriter;
-var XMLWriter_1 = __nccwpck_require__(59606);
-exports.XMLWriter = XMLWriter_1.XMLWriter;
-var ObjectWriter_1 = __nccwpck_require__(50243);
-exports.ObjectWriter = ObjectWriter_1.ObjectWriter;
-var JSONWriter_1 = __nccwpck_require__(37510);
-exports.JSONWriter = JSONWriter_1.JSONWriter;
-var YAMLWriter_1 = __nccwpck_require__(96517);
-exports.YAMLWriter = YAMLWriter_1.YAMLWriter;
-//# sourceMappingURL=index.js.map
+ // If there are any bits left, source was corrupted
+ return (bitlen % 8) === 0;
+}
-/***/ }),
+function constructYamlBinary(data) {
+ var idx, tailbits,
+ input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
+ max = input.length,
+ map = BASE64_MAP,
+ bits = 0,
+ result = [];
-/***/ 10829:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ // Collect by 6*4 bits (3 bytes)
-"use strict";
+ for (idx = 0; idx < max; idx++) {
+ if ((idx % 4 === 0) && idx) {
+ result.push((bits >> 16) & 0xFF);
+ result.push((bits >> 8) & 0xFF);
+ result.push(bits & 0xFF);
+ }
+ bits = (bits << 6) | map.indexOf(input.charAt(idx));
+ }
+ // Dump tail
-var yaml = __nccwpck_require__(59625);
+ tailbits = (max % 4) * 6;
+ if (tailbits === 0) {
+ result.push((bits >> 16) & 0xFF);
+ result.push((bits >> 8) & 0xFF);
+ result.push(bits & 0xFF);
+ } else if (tailbits === 18) {
+ result.push((bits >> 10) & 0xFF);
+ result.push((bits >> 2) & 0xFF);
+ } else if (tailbits === 12) {
+ result.push((bits >> 4) & 0xFF);
+ }
-module.exports = yaml;
+ // Wrap into Buffer for NodeJS and leave Array for browser
+ if (NodeBuffer) {
+ // Support node 6.+ Buffer API when available
+ return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
+ }
+
+ return result;
+}
+
+function representYamlBinary(object /*, style*/) {
+ var result = '', bits = 0, idx, tail,
+ max = object.length,
+ map = BASE64_MAP;
+
+ // Convert every three bytes to 4 ASCII characters.
+
+ for (idx = 0; idx < max; idx++) {
+ if ((idx % 3 === 0) && idx) {
+ result += map[(bits >> 18) & 0x3F];
+ result += map[(bits >> 12) & 0x3F];
+ result += map[(bits >> 6) & 0x3F];
+ result += map[bits & 0x3F];
+ }
+
+ bits = (bits << 8) + object[idx];
+ }
+
+ // Dump tail
+
+ tail = max % 3;
+
+ if (tail === 0) {
+ result += map[(bits >> 18) & 0x3F];
+ result += map[(bits >> 12) & 0x3F];
+ result += map[(bits >> 6) & 0x3F];
+ result += map[bits & 0x3F];
+ } else if (tail === 2) {
+ result += map[(bits >> 10) & 0x3F];
+ result += map[(bits >> 4) & 0x3F];
+ result += map[(bits << 2) & 0x3F];
+ result += map[64];
+ } else if (tail === 1) {
+ result += map[(bits >> 2) & 0x3F];
+ result += map[(bits << 4) & 0x3F];
+ result += map[64];
+ result += map[64];
+ }
+
+ return result;
+}
+
+function isBinary(object) {
+ return NodeBuffer && NodeBuffer.isBuffer(object);
+}
+
+module.exports = new Type('tag:yaml.org,2002:binary', {
+ kind: 'scalar',
+ resolve: resolveYamlBinary,
+ construct: constructYamlBinary,
+ predicate: isBinary,
+ represent: representYamlBinary
+});
/***/ }),
-/***/ 59625:
+/***/ 93195:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
+var Type = __nccwpck_require__(90256);
-var loader = __nccwpck_require__(40342);
-var dumper = __nccwpck_require__(98069);
+function resolveYamlBoolean(data) {
+ if (data === null) return false;
+ var max = data.length;
-function deprecated(name) {
- return function () {
- throw new Error('Function ' + name + ' is deprecated and cannot be used.');
- };
+ return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
+ (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
}
+function constructYamlBoolean(data) {
+ return data === 'true' ||
+ data === 'True' ||
+ data === 'TRUE';
+}
-module.exports.Type = __nccwpck_require__(90256);
-module.exports.Schema = __nccwpck_require__(66280);
-module.exports.FAILSAFE_SCHEMA = __nccwpck_require__(70026);
-module.exports.JSON_SCHEMA = __nccwpck_require__(2168);
-module.exports.CORE_SCHEMA = __nccwpck_require__(11950);
-module.exports.DEFAULT_SAFE_SCHEMA = __nccwpck_require__(42881);
-module.exports.DEFAULT_FULL_SCHEMA = __nccwpck_require__(145);
-module.exports.load = loader.load;
-module.exports.loadAll = loader.loadAll;
-module.exports.safeLoad = loader.safeLoad;
-module.exports.safeLoadAll = loader.safeLoadAll;
-module.exports.dump = dumper.dump;
-module.exports.safeDump = dumper.safeDump;
-module.exports.YAMLException = __nccwpck_require__(29291);
-
-// Deprecated schema names from JS-YAML 2.0.x
-module.exports.MINIMAL_SCHEMA = __nccwpck_require__(70026);
-module.exports.SAFE_SCHEMA = __nccwpck_require__(42881);
-module.exports.DEFAULT_SCHEMA = __nccwpck_require__(145);
+function isBoolean(object) {
+ return Object.prototype.toString.call(object) === '[object Boolean]';
+}
-// Deprecated functions from JS-YAML 1.x.x
-module.exports.scan = deprecated('scan');
-module.exports.parse = deprecated('parse');
-module.exports.compose = deprecated('compose');
-module.exports.addConstructor = deprecated('addConstructor');
+module.exports = new Type('tag:yaml.org,2002:bool', {
+ kind: 'scalar',
+ resolve: resolveYamlBoolean,
+ construct: constructYamlBoolean,
+ predicate: isBoolean,
+ represent: {
+ lowercase: function (object) { return object ? 'true' : 'false'; },
+ uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
+ camelcase: function (object) { return object ? 'True' : 'False'; }
+ },
+ defaultStyle: 'lowercase'
+});
/***/ }),
-/***/ 59941:
-/***/ ((module) => {
+/***/ 16480:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
+var common = __nccwpck_require__(59941);
+var Type = __nccwpck_require__(90256);
-function isNothing(subject) {
- return (typeof subject === 'undefined') || (subject === null);
-}
+var YAML_FLOAT_PATTERN = new RegExp(
+ // 2.5e4, 2.5 and integers
+ '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
+ // .2e4, .2
+ // special case, seems not from spec
+ '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
+ // 20:59
+ '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
+ // .inf
+ '|[-+]?\\.(?:inf|Inf|INF)' +
+ // .nan
+ '|\\.(?:nan|NaN|NAN))$');
+function resolveYamlFloat(data) {
+ if (data === null) return false;
-function isObject(subject) {
- return (typeof subject === 'object') && (subject !== null);
+ if (!YAML_FLOAT_PATTERN.test(data) ||
+ // Quick hack to not allow integers end with `_`
+ // Probably should update regexp & check speed
+ data[data.length - 1] === '_') {
+ return false;
+ }
+
+ return true;
}
+function constructYamlFloat(data) {
+ var value, sign, base, digits;
-function toArray(sequence) {
- if (Array.isArray(sequence)) return sequence;
- else if (isNothing(sequence)) return [];
+ value = data.replace(/_/g, '').toLowerCase();
+ sign = value[0] === '-' ? -1 : 1;
+ digits = [];
- return [ sequence ];
-}
+ if ('+-'.indexOf(value[0]) >= 0) {
+ value = value.slice(1);
+ }
+ if (value === '.inf') {
+ return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
-function extend(target, source) {
- var index, length, key, sourceKeys;
+ } else if (value === '.nan') {
+ return NaN;
- if (source) {
- sourceKeys = Object.keys(source);
+ } else if (value.indexOf(':') >= 0) {
+ value.split(':').forEach(function (v) {
+ digits.unshift(parseFloat(v, 10));
+ });
- for (index = 0, length = sourceKeys.length; index < length; index += 1) {
- key = sourceKeys[index];
- target[key] = source[key];
- }
- }
+ value = 0.0;
+ base = 1;
- return target;
+ digits.forEach(function (d) {
+ value += d * base;
+ base *= 60;
+ });
+
+ return sign * value;
+
+ }
+ return sign * parseFloat(value, 10);
}
-function repeat(string, count) {
- var result = '', cycle;
+var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
+
+function representYamlFloat(object, style) {
+ var res;
- for (cycle = 0; cycle < count; cycle += 1) {
- result += string;
+ if (isNaN(object)) {
+ switch (style) {
+ case 'lowercase': return '.nan';
+ case 'uppercase': return '.NAN';
+ case 'camelcase': return '.NaN';
+ }
+ } else if (Number.POSITIVE_INFINITY === object) {
+ switch (style) {
+ case 'lowercase': return '.inf';
+ case 'uppercase': return '.INF';
+ case 'camelcase': return '.Inf';
+ }
+ } else if (Number.NEGATIVE_INFINITY === object) {
+ switch (style) {
+ case 'lowercase': return '-.inf';
+ case 'uppercase': return '-.INF';
+ case 'camelcase': return '-.Inf';
+ }
+ } else if (common.isNegativeZero(object)) {
+ return '-0.0';
}
- return result;
-}
+ res = object.toString(10);
+ // JS stringifier can build scientific format without dots: 5e-100,
+ // while YAML requres dot: 5.e-100. Fix it with simple hack
-function isNegativeZero(number) {
- return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
}
+function isFloat(object) {
+ return (Object.prototype.toString.call(object) === '[object Number]') &&
+ (object % 1 !== 0 || common.isNegativeZero(object));
+}
-module.exports.isNothing = isNothing;
-module.exports.isObject = isObject;
-module.exports.toArray = toArray;
-module.exports.repeat = repeat;
-module.exports.isNegativeZero = isNegativeZero;
-module.exports.extend = extend;
+module.exports = new Type('tag:yaml.org,2002:float', {
+ kind: 'scalar',
+ resolve: resolveYamlFloat,
+ construct: constructYamlFloat,
+ predicate: isFloat,
+ represent: representYamlFloat,
+ defaultStyle: 'lowercase'
+});
/***/ }),
-/***/ 98069:
+/***/ 76865:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
-/*eslint-disable no-use-before-define*/
+var common = __nccwpck_require__(59941);
+var Type = __nccwpck_require__(90256);
-var common = __nccwpck_require__(59941);
-var YAMLException = __nccwpck_require__(29291);
-var DEFAULT_FULL_SCHEMA = __nccwpck_require__(145);
-var DEFAULT_SAFE_SCHEMA = __nccwpck_require__(42881);
+function isHexCode(c) {
+ return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
+ ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
+ ((0x61/* a */ <= c) && (c <= 0x66/* f */));
+}
-var _toString = Object.prototype.toString;
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
+function isOctCode(c) {
+ return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
+}
-var CHAR_TAB = 0x09; /* Tab */
-var CHAR_LINE_FEED = 0x0A; /* LF */
-var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
-var CHAR_SPACE = 0x20; /* Space */
-var CHAR_EXCLAMATION = 0x21; /* ! */
-var CHAR_DOUBLE_QUOTE = 0x22; /* " */
-var CHAR_SHARP = 0x23; /* # */
-var CHAR_PERCENT = 0x25; /* % */
-var CHAR_AMPERSAND = 0x26; /* & */
-var CHAR_SINGLE_QUOTE = 0x27; /* ' */
-var CHAR_ASTERISK = 0x2A; /* * */
-var CHAR_COMMA = 0x2C; /* , */
-var CHAR_MINUS = 0x2D; /* - */
-var CHAR_COLON = 0x3A; /* : */
-var CHAR_EQUALS = 0x3D; /* = */
-var CHAR_GREATER_THAN = 0x3E; /* > */
-var CHAR_QUESTION = 0x3F; /* ? */
-var CHAR_COMMERCIAL_AT = 0x40; /* @ */
-var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
-var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
-var CHAR_GRAVE_ACCENT = 0x60; /* ` */
-var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
-var CHAR_VERTICAL_LINE = 0x7C; /* | */
-var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
+function isDecCode(c) {
+ return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
+}
-var ESCAPE_SEQUENCES = {};
+function resolveYamlInteger(data) {
+ if (data === null) return false;
-ESCAPE_SEQUENCES[0x00] = '\\0';
-ESCAPE_SEQUENCES[0x07] = '\\a';
-ESCAPE_SEQUENCES[0x08] = '\\b';
-ESCAPE_SEQUENCES[0x09] = '\\t';
-ESCAPE_SEQUENCES[0x0A] = '\\n';
-ESCAPE_SEQUENCES[0x0B] = '\\v';
-ESCAPE_SEQUENCES[0x0C] = '\\f';
-ESCAPE_SEQUENCES[0x0D] = '\\r';
-ESCAPE_SEQUENCES[0x1B] = '\\e';
-ESCAPE_SEQUENCES[0x22] = '\\"';
-ESCAPE_SEQUENCES[0x5C] = '\\\\';
-ESCAPE_SEQUENCES[0x85] = '\\N';
-ESCAPE_SEQUENCES[0xA0] = '\\_';
-ESCAPE_SEQUENCES[0x2028] = '\\L';
-ESCAPE_SEQUENCES[0x2029] = '\\P';
+ var max = data.length,
+ index = 0,
+ hasDigits = false,
+ ch;
-var DEPRECATED_BOOLEANS_SYNTAX = [
- 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
- 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
-];
+ if (!max) return false;
-function compileStyleMap(schema, map) {
- var result, keys, index, length, tag, style, type;
+ ch = data[index];
- if (map === null) return {};
+ // sign
+ if (ch === '-' || ch === '+') {
+ ch = data[++index];
+ }
- result = {};
- keys = Object.keys(map);
+ if (ch === '0') {
+ // 0
+ if (index + 1 === max) return true;
+ ch = data[++index];
- for (index = 0, length = keys.length; index < length; index += 1) {
- tag = keys[index];
- style = String(map[tag]);
+ // base 2, base 8, base 16
- if (tag.slice(0, 2) === '!!') {
- tag = 'tag:yaml.org,2002:' + tag.slice(2);
- }
- type = schema.compiledTypeMap['fallback'][tag];
+ if (ch === 'b') {
+ // base 2
+ index++;
- if (type && _hasOwnProperty.call(type.styleAliases, style)) {
- style = type.styleAliases[style];
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (ch !== '0' && ch !== '1') return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
}
- result[tag] = style;
- }
-
- return result;
-}
-function encodeHex(character) {
- var string, handle, length;
+ if (ch === 'x') {
+ // base 16
+ index++;
- string = character.toString(16).toUpperCase();
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (!isHexCode(data.charCodeAt(index))) return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
+ }
- if (character <= 0xFF) {
- handle = 'x';
- length = 2;
- } else if (character <= 0xFFFF) {
- handle = 'u';
- length = 4;
- } else if (character <= 0xFFFFFFFF) {
- handle = 'U';
- length = 8;
- } else {
- throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
+ // base 8
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (!isOctCode(data.charCodeAt(index))) return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
}
- return '\\' + handle + common.repeat('0', length - string.length) + string;
-}
+ // base 10 (except 0) or base 60
-function State(options) {
- this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
- this.indent = Math.max(1, (options['indent'] || 2));
- this.noArrayIndent = options['noArrayIndent'] || false;
- this.skipInvalid = options['skipInvalid'] || false;
- this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
- this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
- this.sortKeys = options['sortKeys'] || false;
- this.lineWidth = options['lineWidth'] || 80;
- this.noRefs = options['noRefs'] || false;
- this.noCompatMode = options['noCompatMode'] || false;
- this.condenseFlow = options['condenseFlow'] || false;
+ // value should not start with `_`;
+ if (ch === '_') return false;
- this.implicitTypes = this.schema.compiledImplicit;
- this.explicitTypes = this.schema.compiledExplicit;
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (ch === ':') break;
+ if (!isDecCode(data.charCodeAt(index))) {
+ return false;
+ }
+ hasDigits = true;
+ }
- this.tag = null;
- this.result = '';
+ // Should have digits and should not end with `_`
+ if (!hasDigits || ch === '_') return false;
- this.duplicates = [];
- this.usedDuplicates = null;
+ // if !base60 - done;
+ if (ch !== ':') return true;
+
+ // base60 almost not used, no needs to optimize
+ return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
}
-// Indents every line in a string. Empty lines (\n only) are not indented.
-function indentString(string, spaces) {
- var ind = common.repeat(' ', spaces),
- position = 0,
- next = -1,
- result = '',
- line,
- length = string.length;
+function constructYamlInteger(data) {
+ var value = data, sign = 1, ch, base, digits = [];
- while (position < length) {
- next = string.indexOf('\n', position);
- if (next === -1) {
- line = string.slice(position);
- position = length;
- } else {
- line = string.slice(position, next + 1);
- position = next + 1;
- }
+ if (value.indexOf('_') !== -1) {
+ value = value.replace(/_/g, '');
+ }
- if (line.length && line !== '\n') result += ind;
+ ch = value[0];
- result += line;
+ if (ch === '-' || ch === '+') {
+ if (ch === '-') sign = -1;
+ value = value.slice(1);
+ ch = value[0];
}
- return result;
-}
+ if (value === '0') return 0;
-function generateNextLine(state, level) {
- return '\n' + common.repeat(' ', state.indent * level);
-}
+ if (ch === '0') {
+ if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
+ if (value[1] === 'x') return sign * parseInt(value, 16);
+ return sign * parseInt(value, 8);
+ }
-function testImplicitResolving(state, str) {
- var index, length, type;
+ if (value.indexOf(':') !== -1) {
+ value.split(':').forEach(function (v) {
+ digits.unshift(parseInt(v, 10));
+ });
- for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
- type = state.implicitTypes[index];
+ value = 0;
+ base = 1;
+
+ digits.forEach(function (d) {
+ value += (d * base);
+ base *= 60;
+ });
+
+ return sign * value;
- if (type.resolve(str)) {
- return true;
- }
}
- return false;
+ return sign * parseInt(value, 10);
}
-// [33] s-white ::= s-space | s-tab
-function isWhitespace(c) {
- return c === CHAR_SPACE || c === CHAR_TAB;
+function isInteger(object) {
+ return (Object.prototype.toString.call(object)) === '[object Number]' &&
+ (object % 1 === 0 && !common.isNegativeZero(object));
}
-// Returns true if the character can be printed without escaping.
-// From YAML 1.2: "any allowed characters known to be non-printable
-// should also be escaped. [However,] This isn’t mandatory"
-// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
-function isPrintable(c) {
- return (0x00020 <= c && c <= 0x00007E)
- || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
- || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
- || (0x10000 <= c && c <= 0x10FFFF);
-}
+module.exports = new Type('tag:yaml.org,2002:int', {
+ kind: 'scalar',
+ resolve: resolveYamlInteger,
+ construct: constructYamlInteger,
+ predicate: isInteger,
+ represent: {
+ binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
+ octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
+ decimal: function (obj) { return obj.toString(10); },
+ /* eslint-disable max-len */
+ hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
+ },
+ defaultStyle: 'decimal',
+ styleAliases: {
+ binary: [ 2, 'bin' ],
+ octal: [ 8, 'oct' ],
+ decimal: [ 10, 'dec' ],
+ hexadecimal: [ 16, 'hex' ]
+ }
+});
-// [34] ns-char ::= nb-char - s-white
-// [27] nb-char ::= c-printable - b-char - c-byte-order-mark
-// [26] b-char ::= b-line-feed | b-carriage-return
-// [24] b-line-feed ::= #xA /* LF */
-// [25] b-carriage-return ::= #xD /* CR */
-// [3] c-byte-order-mark ::= #xFEFF
-function isNsChar(c) {
- return isPrintable(c) && !isWhitespace(c)
- // byte-order-mark
- && c !== 0xFEFF
- // b-char
- && c !== CHAR_CARRIAGE_RETURN
- && c !== CHAR_LINE_FEED;
-}
-// Simplified test for values allowed after the first character in plain style.
-function isPlainSafe(c, prev) {
- // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
- // where nb-char ::= c-printable - b-char - c-byte-order-mark.
- return isPrintable(c) && c !== 0xFEFF
- // - c-flow-indicator
- && c !== CHAR_COMMA
- && c !== CHAR_LEFT_SQUARE_BRACKET
- && c !== CHAR_RIGHT_SQUARE_BRACKET
- && c !== CHAR_LEFT_CURLY_BRACKET
- && c !== CHAR_RIGHT_CURLY_BRACKET
- // - ":" - "#"
- // /* An ns-char preceding */ "#"
- && c !== CHAR_COLON
- && ((c !== CHAR_SHARP) || (prev && isNsChar(prev)));
-}
+/***/ }),
-// Simplified test for values allowed as the first character in plain style.
-function isPlainSafeFirst(c) {
- // Uses a subset of ns-char - c-indicator
- // where ns-char = nb-char - s-white.
- return isPrintable(c) && c !== 0xFEFF
- && !isWhitespace(c) // - s-white
- // - (c-indicator ::=
- // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
- && c !== CHAR_MINUS
- && c !== CHAR_QUESTION
- && c !== CHAR_COLON
- && c !== CHAR_COMMA
- && c !== CHAR_LEFT_SQUARE_BRACKET
- && c !== CHAR_RIGHT_SQUARE_BRACKET
- && c !== CHAR_LEFT_CURLY_BRACKET
- && c !== CHAR_RIGHT_CURLY_BRACKET
- // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
- && c !== CHAR_SHARP
- && c !== CHAR_AMPERSAND
- && c !== CHAR_ASTERISK
- && c !== CHAR_EXCLAMATION
- && c !== CHAR_VERTICAL_LINE
- && c !== CHAR_EQUALS
- && c !== CHAR_GREATER_THAN
- && c !== CHAR_SINGLE_QUOTE
- && c !== CHAR_DOUBLE_QUOTE
- // | “%” | “@” | “`”)
- && c !== CHAR_PERCENT
- && c !== CHAR_COMMERCIAL_AT
- && c !== CHAR_GRAVE_ACCENT;
-}
+/***/ 35361:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
-// Determines whether block indentation indicator is required.
-function needIndentIndicator(string) {
- var leadingSpaceRe = /^\n* /;
- return leadingSpaceRe.test(string);
-}
+"use strict";
-var STYLE_PLAIN = 1,
- STYLE_SINGLE = 2,
- STYLE_LITERAL = 3,
- STYLE_FOLDED = 4,
- STYLE_DOUBLE = 5;
-// Determines which scalar styles are possible and returns the preferred style.
-// lineWidth = -1 => no limit.
-// Pre-conditions: str.length > 0.
-// Post-conditions:
-// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
-// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
-// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
-function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
- var i;
- var char, prev_char;
- var hasLineBreak = false;
- var hasFoldableLine = false; // only checked if shouldTrackWidth
- var shouldTrackWidth = lineWidth !== -1;
- var previousLineBreak = -1; // count the first line correctly
- var plain = isPlainSafeFirst(string.charCodeAt(0))
- && !isWhitespace(string.charCodeAt(string.length - 1));
+var esprima;
- if (singleLineOnly) {
- // Case: no block styles.
- // Check for disallowed characters to rule out plain and single.
- for (i = 0; i < string.length; i++) {
- char = string.charCodeAt(i);
- if (!isPrintable(char)) {
- return STYLE_DOUBLE;
- }
- prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
- plain = plain && isPlainSafe(char, prev_char);
- }
- } else {
- // Case: block styles permitted.
- for (i = 0; i < string.length; i++) {
- char = string.charCodeAt(i);
- if (char === CHAR_LINE_FEED) {
- hasLineBreak = true;
- // Check if any line can be folded.
- if (shouldTrackWidth) {
- hasFoldableLine = hasFoldableLine ||
- // Foldable line = too long, and not more-indented.
- (i - previousLineBreak - 1 > lineWidth &&
- string[previousLineBreak + 1] !== ' ');
- previousLineBreak = i;
- }
- } else if (!isPrintable(char)) {
- return STYLE_DOUBLE;
- }
- prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
- plain = plain && isPlainSafe(char, prev_char);
- }
- // in case the end is missing a \n
- hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
- (i - previousLineBreak - 1 > lineWidth &&
- string[previousLineBreak + 1] !== ' '));
- }
- // Although every style can represent \n without escaping, prefer block styles
- // for multiline, since they're more readable and they don't add empty lines.
- // Also prefer folding a super-long line.
- if (!hasLineBreak && !hasFoldableLine) {
- // Strings interpretable as another type have to be quoted;
- // e.g. the string 'true' vs. the boolean true.
- return plain && !testAmbiguousType(string)
- ? STYLE_PLAIN : STYLE_SINGLE;
- }
- // Edge case: block indentation indicator can only have one digit.
- if (indentPerLevel > 9 && needIndentIndicator(string)) {
- return STYLE_DOUBLE;
- }
- // At this point we know block styles are valid.
- // Prefer literal style unless we want to fold.
- return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
+// Browserified version does not have esprima
+//
+// 1. For node.js just require module as deps
+// 2. For browser try to require mudule via external AMD system.
+// If not found - try to fallback to window.esprima. If not
+// found too - then fail to parse.
+//
+try {
+ // workaround to exclude package from browserify list.
+ var _require = require;
+ esprima = _require('esprima');
+} catch (_) {
+ /* eslint-disable no-redeclare */
+ /* global window */
+ if (typeof window !== 'undefined') esprima = window.esprima;
}
-// Note: line breaking/folding is implemented for only the folded style.
-// NB. We drop the last trailing newline (if any) of a returned block scalar
-// since the dumper adds its own newline. This always works:
-// • No ending newline => unaffected; already using strip "-" chomping.
-// • Ending newline => removed then restored.
-// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
-function writeScalar(state, string, level, iskey) {
- state.dump = (function () {
- if (string.length === 0) {
- return "''";
- }
- if (!state.noCompatMode &&
- DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
- return "'" + string + "'";
- }
+var Type = __nccwpck_require__(90256);
+
+function resolveJavascriptFunction(data) {
+ if (data === null) return false;
- var indent = state.indent * Math.max(1, level); // no 0-indent scalars
- // As indentation gets deeper, let the width decrease monotonically
- // to the lower bound min(state.lineWidth, 40).
- // Note that this implies
- // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
- // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
- // This behaves better than a constant minimum width which disallows narrower options,
- // or an indent threshold which causes the width to suddenly increase.
- var lineWidth = state.lineWidth === -1
- ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
+ try {
+ var source = '(' + data + ')',
+ ast = esprima.parse(source, { range: true });
- // Without knowing if keys are implicit/explicit, assume implicit for safety.
- var singleLineOnly = iskey
- // No block styles in flow mode.
- || (state.flowLevel > -1 && level >= state.flowLevel);
- function testAmbiguity(string) {
- return testImplicitResolving(state, string);
+ if (ast.type !== 'Program' ||
+ ast.body.length !== 1 ||
+ ast.body[0].type !== 'ExpressionStatement' ||
+ (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
+ ast.body[0].expression.type !== 'FunctionExpression')) {
+ return false;
}
- switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
- case STYLE_PLAIN:
- return string;
- case STYLE_SINGLE:
- return "'" + string.replace(/'/g, "''") + "'";
- case STYLE_LITERAL:
- return '|' + blockHeader(string, state.indent)
- + dropEndingNewline(indentString(string, indent));
- case STYLE_FOLDED:
- return '>' + blockHeader(string, state.indent)
- + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
- case STYLE_DOUBLE:
- return '"' + escapeString(string, lineWidth) + '"';
- default:
- throw new YAMLException('impossible error: invalid scalar style');
- }
- }());
+ return true;
+ } catch (err) {
+ return false;
+ }
}
-// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
-function blockHeader(string, indentPerLevel) {
- var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
+function constructJavascriptFunction(data) {
+ /*jslint evil:true*/
- // note the special case: the string '\n' counts as a "trailing" empty line.
- var clip = string[string.length - 1] === '\n';
- var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
- var chomp = keep ? '+' : (clip ? '' : '-');
+ var source = '(' + data + ')',
+ ast = esprima.parse(source, { range: true }),
+ params = [],
+ body;
- return indentIndicator + chomp + '\n';
+ if (ast.type !== 'Program' ||
+ ast.body.length !== 1 ||
+ ast.body[0].type !== 'ExpressionStatement' ||
+ (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
+ ast.body[0].expression.type !== 'FunctionExpression')) {
+ throw new Error('Failed to resolve function');
+ }
+
+ ast.body[0].expression.params.forEach(function (param) {
+ params.push(param.name);
+ });
+
+ body = ast.body[0].expression.body.range;
+
+ // Esprima's ranges include the first '{' and the last '}' characters on
+ // function expressions. So cut them out.
+ if (ast.body[0].expression.body.type === 'BlockStatement') {
+ /*eslint-disable no-new-func*/
+ return new Function(params, source.slice(body[0] + 1, body[1] - 1));
+ }
+ // ES6 arrow functions can omit the BlockStatement. In that case, just return
+ // the body.
+ /*eslint-disable no-new-func*/
+ return new Function(params, 'return ' + source.slice(body[0], body[1]));
}
-// (See the note for writeScalar.)
-function dropEndingNewline(string) {
- return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
+function representJavascriptFunction(object /*, style*/) {
+ return object.toString();
}
-// Note: a long line without a suitable break point will exceed the width limit.
-// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
-function foldString(string, width) {
- // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
- // unless they're before or after a more-indented line, or at the very
- // beginning or end, in which case $k$ maps to $k$.
- // Therefore, parse each chunk as newline(s) followed by a content line.
- var lineRe = /(\n+)([^\n]*)/g;
+function isFunction(object) {
+ return Object.prototype.toString.call(object) === '[object Function]';
+}
- // first line (possibly an empty line)
- var result = (function () {
- var nextLF = string.indexOf('\n');
- nextLF = nextLF !== -1 ? nextLF : string.length;
- lineRe.lastIndex = nextLF;
- return foldLine(string.slice(0, nextLF), width);
- }());
- // If we haven't reached the first content line yet, don't add an extra \n.
- var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
- var moreIndented;
+module.exports = new Type('tag:yaml.org,2002:js/function', {
+ kind: 'scalar',
+ resolve: resolveJavascriptFunction,
+ construct: constructJavascriptFunction,
+ predicate: isFunction,
+ represent: representJavascriptFunction
+});
- // rest of the lines
- var match;
- while ((match = lineRe.exec(string))) {
- var prefix = match[1], line = match[2];
- moreIndented = (line[0] === ' ');
- result += prefix
- + (!prevMoreIndented && !moreIndented && line !== ''
- ? '\n' : '')
- + foldLine(line, width);
- prevMoreIndented = moreIndented;
- }
- return result;
-}
+/***/ }),
-// Greedy line breaking.
-// Picks the longest line under the limit each time,
-// otherwise settles for the shortest line over the limit.
-// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
-function foldLine(line, width) {
- if (line === '' || line[0] === ' ') return line;
+/***/ 77234:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
- // Since a more-indented line adds a \n, breaks can't be followed by a space.
- var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
- var match;
- // start is an inclusive index. end, curr, and next are exclusive.
- var start = 0, end, curr = 0, next = 0;
- var result = '';
+"use strict";
- // Invariants: 0 <= start <= length-1.
- // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
- // Inside the loop:
- // A match implies length >= 2, so curr and next are <= length-2.
- while ((match = breakRe.exec(line))) {
- next = match.index;
- // maintain invariant: curr - start <= width
- if (next - start > width) {
- end = (curr > start) ? curr : next; // derive end <= length-2
- result += '\n' + line.slice(start, end);
- // skip the space that was output as \n
- start = end + 1; // derive start <= length-1
- }
- curr = next;
- }
- // By the invariants, start <= length-1, so there is something left over.
- // It is either the whole string or a part starting from non-whitespace.
- result += '\n';
- // Insert a break if the remainder is too long and there is a break available.
- if (line.length - start > width && curr > start) {
- result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
- } else {
- result += line.slice(start);
+var Type = __nccwpck_require__(90256);
+
+function resolveJavascriptRegExp(data) {
+ if (data === null) return false;
+ if (data.length === 0) return false;
+
+ var regexp = data,
+ tail = /\/([gim]*)$/.exec(data),
+ modifiers = '';
+
+ // if regexp starts with '/' it can have modifiers and must be properly closed
+ // `/foo/gim` - modifiers tail can be maximum 3 chars
+ if (regexp[0] === '/') {
+ if (tail) modifiers = tail[1];
+
+ if (modifiers.length > 3) return false;
+ // if expression starts with /, is should be properly terminated
+ if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
}
- return result.slice(1); // drop extra \n joiner
+ return true;
}
-// Escapes a double-quoted string.
-function escapeString(string) {
- var result = '';
- var char, nextChar;
- var escapeSeq;
+function constructJavascriptRegExp(data) {
+ var regexp = data,
+ tail = /\/([gim]*)$/.exec(data),
+ modifiers = '';
- for (var i = 0; i < string.length; i++) {
- char = string.charCodeAt(i);
- // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
- if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) {
- nextChar = string.charCodeAt(i + 1);
- if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) {
- // Combine the surrogate pair and store it escaped.
- result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
- // Advance index one extra since we already used that char here.
- i++; continue;
- }
- }
- escapeSeq = ESCAPE_SEQUENCES[char];
- result += !escapeSeq && isPrintable(char)
- ? string[i]
- : escapeSeq || encodeHex(char);
+ // `/foo/gim` - tail can be maximum 4 chars
+ if (regexp[0] === '/') {
+ if (tail) modifiers = tail[1];
+ regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
}
+ return new RegExp(regexp, modifiers);
+}
+
+function representJavascriptRegExp(object /*, style*/) {
+ var result = '/' + object.source + '/';
+
+ if (object.global) result += 'g';
+ if (object.multiline) result += 'm';
+ if (object.ignoreCase) result += 'i';
+
return result;
}
-function writeFlowSequence(state, level, object) {
- var _result = '',
- _tag = state.tag,
- index,
- length;
+function isRegExp(object) {
+ return Object.prototype.toString.call(object) === '[object RegExp]';
+}
+
+module.exports = new Type('tag:yaml.org,2002:js/regexp', {
+ kind: 'scalar',
+ resolve: resolveJavascriptRegExp,
+ construct: constructJavascriptRegExp,
+ predicate: isRegExp,
+ represent: representJavascriptRegExp
+});
+
+
+/***/ }),
+
+/***/ 34801:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+var Type = __nccwpck_require__(90256);
+
+function resolveJavascriptUndefined() {
+ return true;
+}
+
+function constructJavascriptUndefined() {
+ /*eslint-disable no-undefined*/
+ return undefined;
+}
- for (index = 0, length = object.length; index < length; index += 1) {
- // Write only valid elements.
- if (writeNode(state, level, object[index], false, false)) {
- if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
- _result += state.dump;
- }
- }
+function representJavascriptUndefined() {
+ return '';
+}
- state.tag = _tag;
- state.dump = '[' + _result + ']';
+function isUndefined(object) {
+ return typeof object === 'undefined';
}
-function writeBlockSequence(state, level, object, compact) {
- var _result = '',
- _tag = state.tag,
- index,
- length;
+module.exports = new Type('tag:yaml.org,2002:js/undefined', {
+ kind: 'scalar',
+ resolve: resolveJavascriptUndefined,
+ construct: constructJavascriptUndefined,
+ predicate: isUndefined,
+ represent: representJavascriptUndefined
+});
- for (index = 0, length = object.length; index < length; index += 1) {
- // Write only valid elements.
- if (writeNode(state, level + 1, object[index], true, true)) {
- if (!compact || index !== 0) {
- _result += generateNextLine(state, level);
- }
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
- _result += '-';
- } else {
- _result += '- ';
- }
+/***/ }),
- _result += state.dump;
- }
- }
+/***/ 15938:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
- state.tag = _tag;
- state.dump = _result || '[]'; // Empty sequence if no valid values.
-}
+"use strict";
-function writeFlowMapping(state, level, object) {
- var _result = '',
- _tag = state.tag,
- objectKeyList = Object.keys(object),
- index,
- length,
- objectKey,
- objectValue,
- pairBuffer;
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+var Type = __nccwpck_require__(90256);
- pairBuffer = '';
- if (index !== 0) pairBuffer += ', ';
+module.exports = new Type('tag:yaml.org,2002:map', {
+ kind: 'mapping',
+ construct: function (data) { return data !== null ? data : {}; }
+});
- if (state.condenseFlow) pairBuffer += '"';
- objectKey = objectKeyList[index];
- objectValue = object[objectKey];
+/***/ }),
- if (!writeNode(state, level, objectKey, false, false)) {
- continue; // Skip this pair because of invalid key;
- }
+/***/ 60194:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
- if (state.dump.length > 1024) pairBuffer += '? ';
+"use strict";
- pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
- if (!writeNode(state, level, objectValue, false, false)) {
- continue; // Skip this pair because of invalid value.
- }
+var Type = __nccwpck_require__(90256);
- pairBuffer += state.dump;
+function resolveYamlMerge(data) {
+ return data === '<<' || data === null;
+}
- // Both key and value are valid.
- _result += pairBuffer;
- }
+module.exports = new Type('tag:yaml.org,2002:merge', {
+ kind: 'scalar',
+ resolve: resolveYamlMerge
+});
- state.tag = _tag;
- state.dump = '{' + _result + '}';
-}
-function writeBlockMapping(state, level, object, compact) {
- var _result = '',
- _tag = state.tag,
- objectKeyList = Object.keys(object),
- index,
- length,
- objectKey,
- objectValue,
- explicitPair,
- pairBuffer;
+/***/ }),
- // Allow sorting keys so that the output file is deterministic
- if (state.sortKeys === true) {
- // Default sorting
- objectKeyList.sort();
- } else if (typeof state.sortKeys === 'function') {
- // Custom sort function
- objectKeyList.sort(state.sortKeys);
- } else if (state.sortKeys) {
- // Something is wrong
- throw new YAMLException('sortKeys must be a boolean or a function');
- }
+/***/ 26058:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
- pairBuffer = '';
+"use strict";
- if (!compact || index !== 0) {
- pairBuffer += generateNextLine(state, level);
- }
- objectKey = objectKeyList[index];
- objectValue = object[objectKey];
+var Type = __nccwpck_require__(90256);
- if (!writeNode(state, level + 1, objectKey, true, true, true)) {
- continue; // Skip this pair because of invalid key.
- }
+function resolveYamlNull(data) {
+ if (data === null) return true;
- explicitPair = (state.tag !== null && state.tag !== '?') ||
- (state.dump && state.dump.length > 1024);
+ var max = data.length;
- if (explicitPair) {
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
- pairBuffer += '?';
- } else {
- pairBuffer += '? ';
- }
- }
+ return (max === 1 && data === '~') ||
+ (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
+}
- pairBuffer += state.dump;
+function constructYamlNull() {
+ return null;
+}
- if (explicitPair) {
- pairBuffer += generateNextLine(state, level);
- }
+function isNull(object) {
+ return object === null;
+}
- if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
- continue; // Skip this pair because of invalid value.
- }
+module.exports = new Type('tag:yaml.org,2002:null', {
+ kind: 'scalar',
+ resolve: resolveYamlNull,
+ construct: constructYamlNull,
+ predicate: isNull,
+ represent: {
+ canonical: function () { return '~'; },
+ lowercase: function () { return 'null'; },
+ uppercase: function () { return 'NULL'; },
+ camelcase: function () { return 'Null'; }
+ },
+ defaultStyle: 'lowercase'
+});
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
- pairBuffer += ':';
- } else {
- pairBuffer += ': ';
- }
- pairBuffer += state.dump;
+/***/ }),
- // Both key and value are valid.
- _result += pairBuffer;
- }
+/***/ 96439:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
- state.tag = _tag;
- state.dump = _result || '{}'; // Empty mapping if no valid pairs.
-}
+"use strict";
-function detectType(state, object, explicit) {
- var _result, typeList, index, length, type, style;
- typeList = explicit ? state.explicitTypes : state.implicitTypes;
+var Type = __nccwpck_require__(90256);
- for (index = 0, length = typeList.length; index < length; index += 1) {
- type = typeList[index];
+var _hasOwnProperty = Object.prototype.hasOwnProperty;
+var _toString = Object.prototype.toString;
- if ((type.instanceOf || type.predicate) &&
- (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
- (!type.predicate || type.predicate(object))) {
+function resolveYamlOmap(data) {
+ if (data === null) return true;
- state.tag = explicit ? type.tag : '?';
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey,
+ object = data;
- if (type.represent) {
- style = state.styleMap[type.tag] || type.defaultStyle;
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
+ pairHasKey = false;
- if (_toString.call(type.represent) === '[object Function]') {
- _result = type.represent(object, style);
- } else if (_hasOwnProperty.call(type.represent, style)) {
- _result = type.represent[style](object, style);
- } else {
- throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
- }
+ if (_toString.call(pair) !== '[object Object]') return false;
- state.dump = _result;
+ for (pairKey in pair) {
+ if (_hasOwnProperty.call(pair, pairKey)) {
+ if (!pairHasKey) pairHasKey = true;
+ else return false;
}
-
- return true;
}
+
+ if (!pairHasKey) return false;
+
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
+ else return false;
}
- return false;
+ return true;
}
-// Serializes `object` and writes it to global `result`.
-// Returns true on success, or false on invalid object.
-//
-function writeNode(state, level, object, block, compact, iskey) {
- state.tag = null;
- state.dump = object;
+function constructYamlOmap(data) {
+ return data !== null ? data : [];
+}
- if (!detectType(state, object, false)) {
- detectType(state, object, true);
- }
+module.exports = new Type('tag:yaml.org,2002:omap', {
+ kind: 'sequence',
+ resolve: resolveYamlOmap,
+ construct: constructYamlOmap
+});
- var type = _toString.call(state.dump);
- if (block) {
- block = (state.flowLevel < 0 || state.flowLevel > level);
- }
+/***/ }),
- var objectOrArray = type === '[object Object]' || type === '[object Array]',
- duplicateIndex,
- duplicate;
+/***/ 33730:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
- if (objectOrArray) {
- duplicateIndex = state.duplicates.indexOf(object);
- duplicate = duplicateIndex !== -1;
- }
+"use strict";
- if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
- compact = false;
- }
- if (duplicate && state.usedDuplicates[duplicateIndex]) {
- state.dump = '*ref_' + duplicateIndex;
- } else {
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
- state.usedDuplicates[duplicateIndex] = true;
- }
- if (type === '[object Object]') {
- if (block && (Object.keys(state.dump).length !== 0)) {
- writeBlockMapping(state, level, state.dump, compact);
- if (duplicate) {
- state.dump = '&ref_' + duplicateIndex + state.dump;
- }
- } else {
- writeFlowMapping(state, level, state.dump);
- if (duplicate) {
- state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
- }
- }
- } else if (type === '[object Array]') {
- var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level;
- if (block && (state.dump.length !== 0)) {
- writeBlockSequence(state, arrayLevel, state.dump, compact);
- if (duplicate) {
- state.dump = '&ref_' + duplicateIndex + state.dump;
- }
- } else {
- writeFlowSequence(state, arrayLevel, state.dump);
- if (duplicate) {
- state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
- }
- }
- } else if (type === '[object String]') {
- if (state.tag !== '?') {
- writeScalar(state, state.dump, level, iskey);
- }
- } else {
- if (state.skipInvalid) return false;
- throw new YAMLException('unacceptable kind of an object to dump ' + type);
- }
+var Type = __nccwpck_require__(90256);
- if (state.tag !== null && state.tag !== '?') {
- state.dump = '!<' + state.tag + '> ' + state.dump;
- }
- }
+var _toString = Object.prototype.toString;
- return true;
-}
+function resolveYamlPairs(data) {
+ if (data === null) return true;
-function getDuplicateReferences(object, state) {
- var objects = [],
- duplicatesIndexes = [],
- index,
- length;
+ var index, length, pair, keys, result,
+ object = data;
- inspectNode(object, objects, duplicatesIndexes);
+ result = new Array(object.length);
- for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
- state.duplicates.push(objects[duplicatesIndexes[index]]);
- }
- state.usedDuplicates = new Array(length);
-}
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
-function inspectNode(object, objects, duplicatesIndexes) {
- var objectKeyList,
- index,
- length;
+ if (_toString.call(pair) !== '[object Object]') return false;
- if (object !== null && typeof object === 'object') {
- index = objects.indexOf(object);
- if (index !== -1) {
- if (duplicatesIndexes.indexOf(index) === -1) {
- duplicatesIndexes.push(index);
- }
- } else {
- objects.push(object);
+ keys = Object.keys(pair);
- if (Array.isArray(object)) {
- for (index = 0, length = object.length; index < length; index += 1) {
- inspectNode(object[index], objects, duplicatesIndexes);
- }
- } else {
- objectKeyList = Object.keys(object);
+ if (keys.length !== 1) return false;
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
- inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
- }
- }
- }
+ result[index] = [ keys[0], pair[keys[0]] ];
}
+
+ return true;
}
-function dump(input, options) {
- options = options || {};
+function constructYamlPairs(data) {
+ if (data === null) return [];
- var state = new State(options);
+ var index, length, pair, keys, result,
+ object = data;
- if (!state.noRefs) getDuplicateReferences(input, state);
+ result = new Array(object.length);
- if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
- return '';
-}
+ keys = Object.keys(pair);
-function safeDump(input, options) {
- return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
+ result[index] = [ keys[0], pair[keys[0]] ];
+ }
+
+ return result;
}
-module.exports.dump = dump;
-module.exports.safeDump = safeDump;
+module.exports = new Type('tag:yaml.org,2002:pairs', {
+ kind: 'sequence',
+ resolve: resolveYamlPairs,
+ construct: constructYamlPairs
+});
/***/ }),
-/***/ 29291:
-/***/ ((module) => {
+/***/ 65629:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
-// YAML error class. http://stackoverflow.com/questions/8458984
-//
-function YAMLException(reason, mark) {
- // Super constructor
- Error.call(this);
+var Type = __nccwpck_require__(90256);
- this.name = 'YAMLException';
- this.reason = reason;
- this.mark = mark;
- this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
+module.exports = new Type('tag:yaml.org,2002:seq', {
+ kind: 'sequence',
+ construct: function (data) { return data !== null ? data : []; }
+});
- // Include stack trace in error object
- if (Error.captureStackTrace) {
- // Chrome and NodeJS
- Error.captureStackTrace(this, this.constructor);
- } else {
- // FF, IE 10+ and Safari 6+. Fallback for others
- this.stack = (new Error()).stack || '';
- }
-}
+/***/ }),
-// Inherit from Error
-YAMLException.prototype = Object.create(Error.prototype);
-YAMLException.prototype.constructor = YAMLException;
+/***/ 9047:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+"use strict";
-YAMLException.prototype.toString = function toString(compact) {
- var result = this.name + ': ';
- result += this.reason || '(unknown reason)';
+var Type = __nccwpck_require__(90256);
- if (!compact && this.mark) {
- result += ' ' + this.mark.toString();
+var _hasOwnProperty = Object.prototype.hasOwnProperty;
+
+function resolveYamlSet(data) {
+ if (data === null) return true;
+
+ var key, object = data;
+
+ for (key in object) {
+ if (_hasOwnProperty.call(object, key)) {
+ if (object[key] !== null) return false;
+ }
}
- return result;
-};
+ return true;
+}
+function constructYamlSet(data) {
+ return data !== null ? data : {};
+}
-module.exports = YAMLException;
+module.exports = new Type('tag:yaml.org,2002:set', {
+ kind: 'mapping',
+ resolve: resolveYamlSet,
+ construct: constructYamlSet
+});
/***/ }),
-/***/ 40342:
+/***/ 24649:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
-/*eslint-disable max-len,no-use-before-define*/
-
-var common = __nccwpck_require__(59941);
-var YAMLException = __nccwpck_require__(29291);
-var Mark = __nccwpck_require__(77262);
-var DEFAULT_SAFE_SCHEMA = __nccwpck_require__(42881);
-var DEFAULT_FULL_SCHEMA = __nccwpck_require__(145);
-
-
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
+var Type = __nccwpck_require__(90256);
+module.exports = new Type('tag:yaml.org,2002:str', {
+ kind: 'scalar',
+ construct: function (data) { return data !== null ? data : ''; }
+});
-var CONTEXT_FLOW_IN = 1;
-var CONTEXT_FLOW_OUT = 2;
-var CONTEXT_BLOCK_IN = 3;
-var CONTEXT_BLOCK_OUT = 4;
+/***/ }),
-var CHOMPING_CLIP = 1;
-var CHOMPING_STRIP = 2;
-var CHOMPING_KEEP = 3;
+/***/ 82018:
+/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+"use strict";
-var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
-var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
-var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
-var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
-var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
+var Type = __nccwpck_require__(90256);
-function _class(obj) { return Object.prototype.toString.call(obj); }
+var YAML_DATE_REGEXP = new RegExp(
+ '^([0-9][0-9][0-9][0-9])' + // [1] year
+ '-([0-9][0-9])' + // [2] month
+ '-([0-9][0-9])$'); // [3] day
-function is_EOL(c) {
- return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
-}
+var YAML_TIMESTAMP_REGEXP = new RegExp(
+ '^([0-9][0-9][0-9][0-9])' + // [1] year
+ '-([0-9][0-9]?)' + // [2] month
+ '-([0-9][0-9]?)' + // [3] day
+ '(?:[Tt]|[ \\t]+)' + // ...
+ '([0-9][0-9]?)' + // [4] hour
+ ':([0-9][0-9])' + // [5] minute
+ ':([0-9][0-9])' + // [6] second
+ '(?:\\.([0-9]*))?' + // [7] fraction
+ '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
+ '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
-function is_WHITE_SPACE(c) {
- return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
+function resolveYamlTimestamp(data) {
+ if (data === null) return false;
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
+ return false;
}
-function is_WS_OR_EOL(c) {
- return (c === 0x09/* Tab */) ||
- (c === 0x20/* Space */) ||
- (c === 0x0A/* LF */) ||
- (c === 0x0D/* CR */);
-}
+function constructYamlTimestamp(data) {
+ var match, year, month, day, hour, minute, second, fraction = 0,
+ delta = null, tz_hour, tz_minute, date;
-function is_FLOW_INDICATOR(c) {
- return c === 0x2C/* , */ ||
- c === 0x5B/* [ */ ||
- c === 0x5D/* ] */ ||
- c === 0x7B/* { */ ||
- c === 0x7D/* } */;
-}
+ match = YAML_DATE_REGEXP.exec(data);
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
-function fromHexCode(c) {
- var lc;
+ if (match === null) throw new Error('Date resolve error');
- if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
- return c - 0x30;
- }
+ // match: [1] year [2] month [3] day
- /*eslint-disable no-bitwise*/
- lc = c | 0x20;
+ year = +(match[1]);
+ month = +(match[2]) - 1; // JS month starts with 0
+ day = +(match[3]);
- if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
- return lc - 0x61 + 10;
+ if (!match[4]) { // no hour
+ return new Date(Date.UTC(year, month, day));
}
- return -1;
-}
+ // match: [4] hour [5] minute [6] second [7] fraction
-function escapedHexLen(c) {
- if (c === 0x78/* x */) { return 2; }
- if (c === 0x75/* u */) { return 4; }
- if (c === 0x55/* U */) { return 8; }
- return 0;
-}
+ hour = +(match[4]);
+ minute = +(match[5]);
+ second = +(match[6]);
-function fromDecimalCode(c) {
- if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
- return c - 0x30;
+ if (match[7]) {
+ fraction = match[7].slice(0, 3);
+ while (fraction.length < 3) { // milli-seconds
+ fraction += '0';
+ }
+ fraction = +fraction;
}
- return -1;
-}
-
-function simpleEscapeSequence(c) {
- /* eslint-disable indent */
- return (c === 0x30/* 0 */) ? '\x00' :
- (c === 0x61/* a */) ? '\x07' :
- (c === 0x62/* b */) ? '\x08' :
- (c === 0x74/* t */) ? '\x09' :
- (c === 0x09/* Tab */) ? '\x09' :
- (c === 0x6E/* n */) ? '\x0A' :
- (c === 0x76/* v */) ? '\x0B' :
- (c === 0x66/* f */) ? '\x0C' :
- (c === 0x72/* r */) ? '\x0D' :
- (c === 0x65/* e */) ? '\x1B' :
- (c === 0x20/* Space */) ? ' ' :
- (c === 0x22/* " */) ? '\x22' :
- (c === 0x2F/* / */) ? '/' :
- (c === 0x5C/* \ */) ? '\x5C' :
- (c === 0x4E/* N */) ? '\x85' :
- (c === 0x5F/* _ */) ? '\xA0' :
- (c === 0x4C/* L */) ? '\u2028' :
- (c === 0x50/* P */) ? '\u2029' : '';
-}
+ // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
-function charFromCodepoint(c) {
- if (c <= 0xFFFF) {
- return String.fromCharCode(c);
+ if (match[9]) {
+ tz_hour = +(match[10]);
+ tz_minute = +(match[11] || 0);
+ delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
+ if (match[9] === '-') delta = -delta;
}
- // Encode UTF-16 surrogate pair
- // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
- return String.fromCharCode(
- ((c - 0x010000) >> 10) + 0xD800,
- ((c - 0x010000) & 0x03FF) + 0xDC00
- );
-}
-var simpleEscapeCheck = new Array(256); // integer, for fast access
-var simpleEscapeMap = new Array(256);
-for (var i = 0; i < 256; i++) {
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
- simpleEscapeMap[i] = simpleEscapeSequence(i);
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
+
+ if (delta) date.setTime(date.getTime() - delta);
+
+ return date;
}
+function representYamlTimestamp(object /*, style*/) {
+ return object.toISOString();
+}
-function State(input, options) {
- this.input = input;
+module.exports = new Type('tag:yaml.org,2002:timestamp', {
+ kind: 'scalar',
+ resolve: resolveYamlTimestamp,
+ construct: constructYamlTimestamp,
+ instanceOf: Date,
+ represent: representYamlTimestamp
+});
- this.filename = options['filename'] || null;
- this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
- this.onWarning = options['onWarning'] || null;
- this.legacy = options['legacy'] || false;
- this.json = options['json'] || false;
- this.listener = options['listener'] || null;
- this.implicitTypes = this.schema.compiledImplicit;
- this.typeMap = this.schema.compiledTypeMap;
+/***/ }),
- this.length = input.length;
- this.position = 0;
- this.line = 0;
- this.lineStart = 0;
- this.lineIndent = 0;
+/***/ 52839:
+/***/ (function(module) {
- this.documents = [];
+// Generated by CoffeeScript 1.12.7
+(function() {
+ module.exports = {
+ Disconnected: 1,
+ Preceding: 2,
+ Following: 4,
+ Contains: 8,
+ ContainedBy: 16,
+ ImplementationSpecific: 32
+ };
- /*
- this.version;
- this.checkLineBreaks;
- this.tagMap;
- this.anchorMap;
- this.tag;
- this.anchor;
- this.kind;
- this.result;*/
+}).call(this);
-}
+/***/ }),
-function generateError(state, message) {
- return new YAMLException(
- message,
- new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
-}
+/***/ 29267:
+/***/ (function(module) {
-function throwError(state, message) {
- throw generateError(state, message);
-}
+// 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
+ };
-function throwWarning(state, message) {
- if (state.onWarning) {
- state.onWarning.call(null, generateError(state, message));
- }
-}
+}).call(this);
-var directiveHandlers = {
+/***/ }),
- YAML: function handleYamlDirective(state, name, args) {
+/***/ 58229:
+/***/ (function(module) {
- var match, major, minor;
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
+ slice = [].slice,
+ hasProp = {}.hasOwnProperty;
- if (state.version !== null) {
- throwError(state, 'duplication of %YAML directive');
+ 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;
+ };
- if (args.length !== 1) {
- throwError(state, 'YAML directive accepts exactly one argument');
- }
+ isFunction = function(val) {
+ return !!val && Object.prototype.toString.call(val) === '[object Function]';
+ };
- match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
+ isObject = function(val) {
+ var ref;
+ return !!val && ((ref = typeof val) === 'function' || ref === 'object');
+ };
- if (match === null) {
- throwError(state, 'ill-formed argument of the YAML directive');
+ isArray = function(val) {
+ if (isFunction(Array.isArray)) {
+ return Array.isArray(val);
+ } else {
+ return Object.prototype.toString.call(val) === '[object Array]';
}
-
- major = parseInt(match[1], 10);
- minor = parseInt(match[2], 10);
-
- if (major !== 1) {
- throwError(state, 'unacceptable YAML version of the document');
+ };
+
+ 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;
}
+ };
- state.version = args[0];
- state.checkLineBreaks = (minor < 2);
+ 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));
+ };
- if (minor !== 1 && minor !== 2) {
- throwWarning(state, 'unsupported YAML version of the document');
+ getValue = function(obj) {
+ if (isFunction(obj.valueOf)) {
+ return obj.valueOf();
+ } else {
+ return obj;
}
- },
-
- TAG: function handleTagDirective(state, name, args) {
+ };
- var handle, prefix;
+ module.exports.assign = assign;
- if (args.length !== 2) {
- throwError(state, 'TAG directive accepts exactly two arguments');
- }
+ module.exports.isFunction = isFunction;
- handle = args[0];
- prefix = args[1];
+ module.exports.isObject = isObject;
- if (!PATTERN_TAG_HANDLE.test(handle)) {
- throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
- }
+ module.exports.isArray = isArray;
- if (_hasOwnProperty.call(state.tagMap, handle)) {
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
- }
+ module.exports.isEmpty = isEmpty;
- if (!PATTERN_TAG_URI.test(prefix)) {
- throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
- }
+ module.exports.isPlainObject = isPlainObject;
- state.tagMap[handle] = prefix;
- }
-};
+ module.exports.getValue = getValue;
+}).call(this);
-function captureSegment(state, start, end, checkJson) {
- var _position, _length, _character, _result;
- if (start < end) {
- _result = state.input.slice(start, end);
+/***/ }),
- if (checkJson) {
- for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
- _character = _result.charCodeAt(_position);
- if (!(_character === 0x09 ||
- (0x20 <= _character && _character <= 0x10FFFF))) {
- throwError(state, 'expected valid JSON character');
- }
- }
- } else if (PATTERN_NON_PRINTABLE.test(_result)) {
- throwError(state, 'the stream contains non-printable characters');
- }
+/***/ 9766:
+/***/ (function(module) {
- state.result += _result;
- }
-}
+// Generated by CoffeeScript 1.12.7
+(function() {
+ module.exports = {
+ None: 0,
+ OpenTag: 1,
+ InsideTag: 2,
+ CloseTag: 3
+ };
-function mergeMappings(state, destination, source, overridableKeys) {
- var sourceKeys, key, index, quantity;
+}).call(this);
- if (!common.isObject(source)) {
- throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
- }
- sourceKeys = Object.keys(source);
+/***/ }),
- for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
- key = sourceKeys[index];
+/***/ 58376:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- if (!_hasOwnProperty.call(destination, key)) {
- destination[key] = source[key];
- overridableKeys[key] = true;
- }
- }
-}
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var NodeType, XMLAttribute, XMLNode;
-function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
- var index, quantity;
+ NodeType = __nccwpck_require__(29267);
- // The output is a plain object here, so keys can only be strings.
- // We need to convert keyNode to a string, but doing so can hang the process
- // (deeply nested arrays that explode exponentially using aliases).
- if (Array.isArray(keyNode)) {
- keyNode = Array.prototype.slice.call(keyNode);
+ XMLNode = __nccwpck_require__(67608);
- for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
- if (Array.isArray(keyNode[index])) {
- throwError(state, 'nested arrays are not supported inside keys');
+ 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 (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
- keyNode[index] = '[object Object]';
+ 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;
}
- }
-
- // Avoid code execution in load() via toString property
- // (still use its own toString for arrays, timestamps,
- // and whatever user schema extensions happen to have @@toStringTag)
- if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
- keyNode = '[object Object]';
- }
-
- keyNode = String(keyNode);
+ Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
+ get: function() {
+ return this.type;
+ }
+ });
- if (_result === null) {
- _result = {};
- }
+ Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
+ get: function() {
+ return this.parent;
+ }
+ });
- if (keyTag === 'tag:yaml.org,2002:merge') {
- if (Array.isArray(valueNode)) {
- for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
- mergeMappings(state, _result, valueNode[index], overridableKeys);
+ Object.defineProperty(XMLAttribute.prototype, 'textContent', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
}
- } else {
- mergeMappings(state, _result, valueNode, overridableKeys);
- }
- } else {
- if (!state.json &&
- !_hasOwnProperty.call(overridableKeys, keyNode) &&
- _hasOwnProperty.call(_result, keyNode)) {
- state.line = startLine || state.line;
- state.position = startPos || state.position;
- throwError(state, 'duplicated mapping key');
- }
- _result[keyNode] = valueNode;
- delete overridableKeys[keyNode];
- }
+ });
- return _result;
-}
+ Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
+ get: function() {
+ return '';
+ }
+ });
-function readLineBreak(state) {
- var ch;
+ Object.defineProperty(XMLAttribute.prototype, 'prefix', {
+ get: function() {
+ return '';
+ }
+ });
- ch = state.input.charCodeAt(state.position);
+ Object.defineProperty(XMLAttribute.prototype, 'localName', {
+ get: function() {
+ return this.name;
+ }
+ });
- if (ch === 0x0A/* LF */) {
- state.position++;
- } else if (ch === 0x0D/* CR */) {
- state.position++;
- if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
- state.position++;
- }
- } else {
- throwError(state, 'a line break is expected');
- }
+ Object.defineProperty(XMLAttribute.prototype, 'specified', {
+ get: function() {
+ return true;
+ }
+ });
- state.line += 1;
- state.lineStart = state.position;
-}
+ XMLAttribute.prototype.clone = function() {
+ return Object.create(this);
+ };
-function skipSeparationSpace(state, allowComments, checkIndent) {
- var lineBreaks = 0,
- ch = state.input.charCodeAt(state.position);
+ XMLAttribute.prototype.toString = function(options) {
+ return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
+ };
- while (ch !== 0) {
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
+ 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 + ">";
+ }
+ };
- if (allowComments && ch === 0x23/* # */) {
- do {
- ch = state.input.charCodeAt(++state.position);
- } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
- }
+ 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;
+ };
- if (is_EOL(ch)) {
- readLineBreak(state);
+ return XMLAttribute;
- ch = state.input.charCodeAt(state.position);
- lineBreaks++;
- state.lineIndent = 0;
+ })();
- while (ch === 0x20/* Space */) {
- state.lineIndent++;
- ch = state.input.charCodeAt(++state.position);
- }
- } else {
- break;
- }
- }
+}).call(this);
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
- throwWarning(state, 'deficient indentation');
- }
- return lineBreaks;
-}
+/***/ }),
-function testDocumentSeparator(state) {
- var _position = state.position,
- ch;
+/***/ 90333:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- ch = state.input.charCodeAt(_position);
+// 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;
- // Condition state.position === state.lineStart is tested
- // in parent on each call, for efficiency. No needs to test here again.
- if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
- ch === state.input.charCodeAt(_position + 1) &&
- ch === state.input.charCodeAt(_position + 2)) {
+ NodeType = __nccwpck_require__(29267);
- _position += 3;
+ XMLCharacterData = __nccwpck_require__(87709);
- ch = state.input.charCodeAt(_position);
+ module.exports = XMLCData = (function(superClass) {
+ extend(XMLCData, superClass);
- if (ch === 0 || is_WS_OR_EOL(ch)) {
- return true;
+ 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 false;
-}
+ XMLCData.prototype.clone = function() {
+ return Object.create(this);
+ };
-function writeFoldedLines(state, count) {
- if (count === 1) {
- state.result += ' ';
- } else if (count > 1) {
- state.result += common.repeat('\n', count - 1);
- }
-}
+ XMLCData.prototype.toString = function(options) {
+ return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
+ };
+ return XMLCData;
-function readPlainScalar(state, nodeIndent, withinFlowCollection) {
- var preceding,
- following,
- captureStart,
- captureEnd,
- hasPendingContent,
- _line,
- _lineStart,
- _lineIndent,
- _kind = state.kind,
- _result = state.result,
- ch;
+ })(XMLCharacterData);
- ch = state.input.charCodeAt(state.position);
+}).call(this);
- if (is_WS_OR_EOL(ch) ||
- is_FLOW_INDICATOR(ch) ||
- ch === 0x23/* # */ ||
- ch === 0x26/* & */ ||
- ch === 0x2A/* * */ ||
- ch === 0x21/* ! */ ||
- ch === 0x7C/* | */ ||
- ch === 0x3E/* > */ ||
- ch === 0x27/* ' */ ||
- ch === 0x22/* " */ ||
- ch === 0x25/* % */ ||
- ch === 0x40/* @ */ ||
- ch === 0x60/* ` */) {
- return false;
- }
- if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
- following = state.input.charCodeAt(state.position + 1);
+/***/ }),
- if (is_WS_OR_EOL(following) ||
- withinFlowCollection && is_FLOW_INDICATOR(following)) {
- return false;
- }
- }
+/***/ 87709:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- state.kind = 'scalar';
- state.result = '';
- captureStart = captureEnd = state.position;
- hasPendingContent = false;
+// 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;
- while (ch !== 0) {
- if (ch === 0x3A/* : */) {
- following = state.input.charCodeAt(state.position + 1);
+ XMLNode = __nccwpck_require__(67608);
- if (is_WS_OR_EOL(following) ||
- withinFlowCollection && is_FLOW_INDICATOR(following)) {
- break;
- }
+ module.exports = XMLCharacterData = (function(superClass) {
+ extend(XMLCharacterData, superClass);
- } else if (ch === 0x23/* # */) {
- preceding = state.input.charCodeAt(state.position - 1);
+ function XMLCharacterData(parent) {
+ XMLCharacterData.__super__.constructor.call(this, parent);
+ this.value = '';
+ }
- if (is_WS_OR_EOL(preceding)) {
- break;
+ Object.defineProperty(XMLCharacterData.prototype, 'data', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
}
+ });
- } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
- withinFlowCollection && is_FLOW_INDICATOR(ch)) {
- break;
-
- } else if (is_EOL(ch)) {
- _line = state.line;
- _lineStart = state.lineStart;
- _lineIndent = state.lineIndent;
- skipSeparationSpace(state, false, -1);
+ Object.defineProperty(XMLCharacterData.prototype, 'length', {
+ get: function() {
+ return this.value.length;
+ }
+ });
- if (state.lineIndent >= nodeIndent) {
- hasPendingContent = true;
- ch = state.input.charCodeAt(state.position);
- continue;
- } else {
- state.position = captureEnd;
- state.line = _line;
- state.lineStart = _lineStart;
- state.lineIndent = _lineIndent;
- break;
+ Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
}
- }
+ });
- if (hasPendingContent) {
- captureSegment(state, captureStart, captureEnd, false);
- writeFoldedLines(state, state.line - _line);
- captureStart = captureEnd = state.position;
- hasPendingContent = false;
- }
+ XMLCharacterData.prototype.clone = function() {
+ return Object.create(this);
+ };
- if (!is_WHITE_SPACE(ch)) {
- captureEnd = state.position + 1;
- }
+ XMLCharacterData.prototype.substringData = function(offset, count) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- ch = state.input.charCodeAt(++state.position);
- }
+ XMLCharacterData.prototype.appendData = function(arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- captureSegment(state, captureStart, captureEnd, false);
+ XMLCharacterData.prototype.insertData = function(offset, arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (state.result) {
- return true;
- }
+ XMLCharacterData.prototype.deleteData = function(offset, count) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- state.kind = _kind;
- state.result = _result;
- return false;
-}
+ XMLCharacterData.prototype.replaceData = function(offset, count, arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
-function readSingleQuotedScalar(state, nodeIndent) {
- var ch,
- captureStart, captureEnd;
+ 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;
+ };
- ch = state.input.charCodeAt(state.position);
+ return XMLCharacterData;
- if (ch !== 0x27/* ' */) {
- return false;
- }
+ })(XMLNode);
- state.kind = 'scalar';
- state.result = '';
- state.position++;
- captureStart = captureEnd = state.position;
+}).call(this);
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
- if (ch === 0x27/* ' */) {
- captureSegment(state, captureStart, state.position, true);
- ch = state.input.charCodeAt(++state.position);
- if (ch === 0x27/* ' */) {
- captureStart = state.position;
- state.position++;
- captureEnd = state.position;
- } else {
- return true;
- }
+/***/ }),
+
+/***/ 74407:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- } else if (is_EOL(ch)) {
- captureSegment(state, captureStart, captureEnd, true);
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
- captureStart = captureEnd = state.position;
+// 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;
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
- throwError(state, 'unexpected end of the document within a single quoted scalar');
+ NodeType = __nccwpck_require__(29267);
- } else {
- state.position++;
- captureEnd = state.position;
- }
- }
+ XMLCharacterData = __nccwpck_require__(87709);
- throwError(state, 'unexpected end of the stream within a single quoted scalar');
-}
+ module.exports = XMLComment = (function(superClass) {
+ extend(XMLComment, superClass);
-function readDoubleQuotedScalar(state, nodeIndent) {
- var captureStart,
- captureEnd,
- hexLength,
- hexResult,
- tmp,
- ch;
+ 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);
+ }
- ch = state.input.charCodeAt(state.position);
+ XMLComment.prototype.clone = function() {
+ return Object.create(this);
+ };
- if (ch !== 0x22/* " */) {
- return false;
- }
+ XMLComment.prototype.toString = function(options) {
+ return this.options.writer.comment(this, this.options.writer.filterOptions(options));
+ };
- state.kind = 'scalar';
- state.result = '';
- state.position++;
- captureStart = captureEnd = state.position;
+ return XMLComment;
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
- if (ch === 0x22/* " */) {
- captureSegment(state, captureStart, state.position, true);
- state.position++;
- return true;
+ })(XMLCharacterData);
- } else if (ch === 0x5C/* \ */) {
- captureSegment(state, captureStart, state.position, true);
- ch = state.input.charCodeAt(++state.position);
+}).call(this);
- if (is_EOL(ch)) {
- skipSeparationSpace(state, false, nodeIndent);
- // TODO: rework to inline fn with no type cast?
- } else if (ch < 256 && simpleEscapeCheck[ch]) {
- state.result += simpleEscapeMap[ch];
- state.position++;
+/***/ }),
- } else if ((tmp = escapedHexLen(ch)) > 0) {
- hexLength = tmp;
- hexResult = 0;
+/***/ 67465:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- for (; hexLength > 0; hexLength--) {
- ch = state.input.charCodeAt(++state.position);
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
- if ((tmp = fromHexCode(ch)) >= 0) {
- hexResult = (hexResult << 4) + tmp;
+ XMLDOMErrorHandler = __nccwpck_require__(46744);
- } else {
- throwError(state, 'expected hexadecimal character');
- }
- }
+ XMLDOMStringList = __nccwpck_require__(97028);
- state.result += charFromCodepoint(hexResult);
+ 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);
+ }
- state.position++;
+ 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 {
- throwError(state, 'unknown escape sequence');
+ return null;
}
+ };
- captureStart = captureEnd = state.position;
+ XMLDOMConfiguration.prototype.canSetParameter = function(name, value) {
+ return true;
+ };
- } else if (is_EOL(ch)) {
- captureSegment(state, captureStart, captureEnd, true);
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
- captureStart = captureEnd = state.position;
+ XMLDOMConfiguration.prototype.setParameter = function(name, value) {
+ if (value != null) {
+ return this.params[name] = value;
+ } else {
+ return delete this.params[name];
+ }
+ };
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
- throwError(state, 'unexpected end of the document within a double quoted scalar');
+ return XMLDOMConfiguration;
- } else {
- state.position++;
- captureEnd = state.position;
- }
- }
+ })();
- throwError(state, 'unexpected end of the stream within a double quoted scalar');
-}
+}).call(this);
-function readFlowCollection(state, nodeIndent) {
- var readNext = true,
- _line,
- _tag = state.tag,
- _result,
- _anchor = state.anchor,
- following,
- terminator,
- isPair,
- isExplicitPair,
- isMapping,
- overridableKeys = {},
- keyNode,
- keyTag,
- valueNode,
- ch;
- ch = state.input.charCodeAt(state.position);
+/***/ }),
- if (ch === 0x5B/* [ */) {
- terminator = 0x5D;/* ] */
- isMapping = false;
- _result = [];
- } else if (ch === 0x7B/* { */) {
- terminator = 0x7D;/* } */
- isMapping = true;
- _result = {};
- } else {
- return false;
- }
+/***/ 46744:
+/***/ (function(module) {
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = _result;
- }
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDOMErrorHandler;
- ch = state.input.charCodeAt(++state.position);
+ module.exports = XMLDOMErrorHandler = (function() {
+ function XMLDOMErrorHandler() {}
- while (ch !== 0) {
- skipSeparationSpace(state, true, nodeIndent);
+ XMLDOMErrorHandler.prototype.handleError = function(error) {
+ throw new Error(error);
+ };
- ch = state.input.charCodeAt(state.position);
+ return XMLDOMErrorHandler;
- if (ch === terminator) {
- state.position++;
- state.tag = _tag;
- state.anchor = _anchor;
- state.kind = isMapping ? 'mapping' : 'sequence';
- state.result = _result;
- return true;
- } else if (!readNext) {
- throwError(state, 'missed comma between flow collection entries');
- }
+ })();
- keyTag = keyNode = valueNode = null;
- isPair = isExplicitPair = false;
+}).call(this);
- if (ch === 0x3F/* ? */) {
- following = state.input.charCodeAt(state.position + 1);
- if (is_WS_OR_EOL(following)) {
- isPair = isExplicitPair = true;
- state.position++;
- skipSeparationSpace(state, true, nodeIndent);
- }
- }
+/***/ }),
- _line = state.line;
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
- keyTag = state.tag;
- keyNode = state.result;
- skipSeparationSpace(state, true, nodeIndent);
+/***/ 78310:
+/***/ (function(module) {
- ch = state.input.charCodeAt(state.position);
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDOMImplementation;
- if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
- isPair = true;
- ch = state.input.charCodeAt(++state.position);
- skipSeparationSpace(state, true, nodeIndent);
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
- valueNode = state.result;
- }
+ module.exports = XMLDOMImplementation = (function() {
+ function XMLDOMImplementation() {}
- if (isMapping) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
- } else if (isPair) {
- _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
- } else {
- _result.push(keyNode);
- }
+ XMLDOMImplementation.prototype.hasFeature = function(feature, version) {
+ return true;
+ };
- skipSeparationSpace(state, true, nodeIndent);
+ XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) {
+ throw new Error("This DOM method is not implemented.");
+ };
- ch = state.input.charCodeAt(state.position);
+ XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) {
+ throw new Error("This DOM method is not implemented.");
+ };
- if (ch === 0x2C/* , */) {
- readNext = true;
- ch = state.input.charCodeAt(++state.position);
- } else {
- readNext = false;
- }
- }
+ XMLDOMImplementation.prototype.createHTMLDocument = function(title) {
+ throw new Error("This DOM method is not implemented.");
+ };
- throwError(state, 'unexpected end of the stream within a flow collection');
-}
+ XMLDOMImplementation.prototype.getFeature = function(feature, version) {
+ throw new Error("This DOM method is not implemented.");
+ };
-function readBlockScalar(state, nodeIndent) {
- var captureStart,
- folding,
- chomping = CHOMPING_CLIP,
- didReadContent = false,
- detectedIndent = false,
- textIndent = nodeIndent,
- emptyLines = 0,
- atMoreIndented = false,
- tmp,
- ch;
+ return XMLDOMImplementation;
- ch = state.input.charCodeAt(state.position);
+ })();
- if (ch === 0x7C/* | */) {
- folding = false;
- } else if (ch === 0x3E/* > */) {
- folding = true;
- } else {
- return false;
- }
+}).call(this);
- state.kind = 'scalar';
- state.result = '';
- while (ch !== 0) {
- ch = state.input.charCodeAt(++state.position);
+/***/ }),
- if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
- if (CHOMPING_CLIP === chomping) {
- chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
- } else {
- throwError(state, 'repeat of a chomping mode identifier');
- }
+/***/ 97028:
+/***/ (function(module) {
- } else if ((tmp = fromDecimalCode(ch)) >= 0) {
- if (tmp === 0) {
- throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
- } else if (!detectedIndent) {
- textIndent = nodeIndent + tmp - 1;
- detectedIndent = true;
- } else {
- throwError(state, 'repeat of an indentation width identifier');
- }
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDOMStringList;
- } else {
- break;
+ module.exports = XMLDOMStringList = (function() {
+ function XMLDOMStringList(arr) {
+ this.arr = arr || [];
}
- }
- if (is_WHITE_SPACE(ch)) {
- do { ch = state.input.charCodeAt(++state.position); }
- while (is_WHITE_SPACE(ch));
-
- if (ch === 0x23/* # */) {
- do { ch = state.input.charCodeAt(++state.position); }
- while (!is_EOL(ch) && (ch !== 0));
- }
- }
+ Object.defineProperty(XMLDOMStringList.prototype, 'length', {
+ get: function() {
+ return this.arr.length;
+ }
+ });
- while (ch !== 0) {
- readLineBreak(state);
- state.lineIndent = 0;
+ XMLDOMStringList.prototype.item = function(index) {
+ return this.arr[index] || null;
+ };
- ch = state.input.charCodeAt(state.position);
+ XMLDOMStringList.prototype.contains = function(str) {
+ return this.arr.indexOf(str) !== -1;
+ };
- while ((!detectedIndent || state.lineIndent < textIndent) &&
- (ch === 0x20/* Space */)) {
- state.lineIndent++;
- ch = state.input.charCodeAt(++state.position);
- }
+ return XMLDOMStringList;
- if (!detectedIndent && state.lineIndent > textIndent) {
- textIndent = state.lineIndent;
- }
+ })();
- if (is_EOL(ch)) {
- emptyLines++;
- continue;
- }
+}).call(this);
- // End of the scalar.
- if (state.lineIndent < textIndent) {
- // Perform the chomping.
- if (chomping === CHOMPING_KEEP) {
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
- } else if (chomping === CHOMPING_CLIP) {
- if (didReadContent) { // i.e. only if the scalar is not empty.
- state.result += '\n';
- }
- }
+/***/ }),
- // Break this `while` cycle and go to the funciton's epilogue.
- break;
- }
+/***/ 81015:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- // Folded style: use fancy rules to handle line breaks.
- if (folding) {
+// 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;
- // Lines starting with white space characters (more-indented lines) are not folded.
- if (is_WHITE_SPACE(ch)) {
- atMoreIndented = true;
- // except for the first content line (cf. Example 8.1)
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+ XMLNode = __nccwpck_require__(67608);
- // End of more-indented block.
- } else if (atMoreIndented) {
- atMoreIndented = false;
- state.result += common.repeat('\n', emptyLines + 1);
+ NodeType = __nccwpck_require__(29267);
- // Just one line break - perceive as the same line.
- } else if (emptyLines === 0) {
- if (didReadContent) { // i.e. only if we have already read some scalar content.
- state.result += ' ';
- }
+ module.exports = XMLDTDAttList = (function(superClass) {
+ extend(XMLDTDAttList, superClass);
- // Several line breaks - perceive as different lines.
- } else {
- state.result += common.repeat('\n', emptyLines);
+ 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());
}
-
- // Literal style: just add exact number of line breaks between content lines.
- } else {
- // Keep all line breaks except the header line break.
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+ 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;
}
- didReadContent = true;
- detectedIndent = true;
- emptyLines = 0;
- captureStart = state.position;
-
- while (!is_EOL(ch) && (ch !== 0)) {
- ch = state.input.charCodeAt(++state.position);
- }
+ XMLDTDAttList.prototype.toString = function(options) {
+ return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
+ };
- captureSegment(state, captureStart, state.position, false);
- }
+ return XMLDTDAttList;
- return true;
-}
+ })(XMLNode);
-function readBlockSequence(state, nodeIndent) {
- var _line,
- _tag = state.tag,
- _anchor = state.anchor,
- _result = [],
- following,
- detected = false,
- ch;
+}).call(this);
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = _result;
- }
- ch = state.input.charCodeAt(state.position);
+/***/ }),
- while (ch !== 0) {
+/***/ 52421:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- if (ch !== 0x2D/* - */) {
- break;
- }
+// 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;
- following = state.input.charCodeAt(state.position + 1);
+ XMLNode = __nccwpck_require__(67608);
- if (!is_WS_OR_EOL(following)) {
- break;
- }
+ NodeType = __nccwpck_require__(29267);
- detected = true;
- state.position++;
+ module.exports = XMLDTDElement = (function(superClass) {
+ extend(XMLDTDElement, superClass);
- if (skipSeparationSpace(state, true, -1)) {
- if (state.lineIndent <= nodeIndent) {
- _result.push(null);
- ch = state.input.charCodeAt(state.position);
- continue;
+ 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);
}
- _line = state.line;
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
- _result.push(state.result);
- skipSeparationSpace(state, true, -1);
+ XMLDTDElement.prototype.toString = function(options) {
+ return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
+ };
- ch = state.input.charCodeAt(state.position);
+ return XMLDTDElement;
- if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
- throwError(state, 'bad indentation of a sequence entry');
- } else if (state.lineIndent < nodeIndent) {
- break;
- }
- }
+ })(XMLNode);
- if (detected) {
- state.tag = _tag;
- state.anchor = _anchor;
- state.kind = 'sequence';
- state.result = _result;
- return true;
- }
- return false;
-}
+}).call(this);
-function readBlockMapping(state, nodeIndent, flowIndent) {
- var following,
- allowCompact,
- _line,
- _pos,
- _tag = state.tag,
- _anchor = state.anchor,
- _result = {},
- overridableKeys = {},
- keyTag = null,
- keyNode = null,
- valueNode = null,
- atExplicitKey = false,
- detected = false,
- ch;
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = _result;
- }
+/***/ }),
- ch = state.input.charCodeAt(state.position);
+/***/ 40053:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- while (ch !== 0) {
- following = state.input.charCodeAt(state.position + 1);
- _line = state.line; // Save the current line.
- _pos = state.position;
+// 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;
- //
- // Explicit notation case. There are two separate blocks:
- // first for the key (denoted by "?") and second for the value (denoted by ":")
- //
- if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
+ isObject = (__nccwpck_require__(58229).isObject);
- if (ch === 0x3F/* ? */) {
- if (atExplicitKey) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
- keyTag = keyNode = valueNode = null;
- }
+ XMLNode = __nccwpck_require__(67608);
- detected = true;
- atExplicitKey = true;
- allowCompact = true;
+ NodeType = __nccwpck_require__(29267);
- } else if (atExplicitKey) {
- // i.e. 0x3A/* : */ === character after the explicit key.
- atExplicitKey = false;
- allowCompact = true;
+ 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 {
- throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
+ if (!value.pubID && !value.sysID) {
+ throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
+ }
+ if (value.pubID && !value.sysID) {
+ throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
+ }
+ this.internal = false;
+ if (value.pubID != null) {
+ this.pubID = this.stringify.dtdPubID(value.pubID);
+ }
+ if (value.sysID != null) {
+ this.sysID = this.stringify.dtdSysID(value.sysID);
+ }
+ if (value.nData != null) {
+ this.nData = this.stringify.dtdNData(value.nData);
+ }
+ if (this.pe && this.nData) {
+ throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
+ }
}
+ }
- state.position += 1;
- ch = following;
+ Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
- //
- // Implicit notation case. Flow-style node as the key first, then ":", and the value.
- //
- } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
+ Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
- if (state.line === _line) {
- ch = state.input.charCodeAt(state.position);
+ Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
+ get: function() {
+ return this.nData || null;
+ }
+ });
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
+ Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
+ get: function() {
+ return null;
+ }
+ });
- if (ch === 0x3A/* : */) {
- ch = state.input.charCodeAt(++state.position);
+ Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
+ get: function() {
+ return null;
+ }
+ });
- if (!is_WS_OR_EOL(ch)) {
- throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
- }
+ Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
+ get: function() {
+ return null;
+ }
+ });
- if (atExplicitKey) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
- keyTag = keyNode = valueNode = null;
- }
+ XMLDTDEntity.prototype.toString = function(options) {
+ return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
+ };
- detected = true;
- atExplicitKey = false;
- allowCompact = false;
- keyTag = state.tag;
- keyNode = state.result;
+ return XMLDTDEntity;
- } else if (detected) {
- throwError(state, 'can not read an implicit mapping pair; a colon is missed');
+ })(XMLNode);
- } else {
- state.tag = _tag;
- state.anchor = _anchor;
- return true; // Keep the result of `composeNode`.
- }
+}).call(this);
- } else if (detected) {
- throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
- } else {
- state.tag = _tag;
- state.anchor = _anchor;
- return true; // Keep the result of `composeNode`.
- }
+/***/ }),
- } else {
- break; // Reading is done. Go to the epilogue.
- }
+/***/ 82837:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- //
- // Common reading code for both explicit and implicit notations.
- //
- if (state.line === _line || state.lineIndent > nodeIndent) {
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
- if (atExplicitKey) {
- keyNode = state.result;
- } else {
- valueNode = state.result;
- }
- }
+// 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;
- if (!atExplicitKey) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
- keyTag = keyNode = valueNode = null;
- }
+ XMLNode = __nccwpck_require__(67608);
- skipSeparationSpace(state, true, -1);
- ch = state.input.charCodeAt(state.position);
- }
+ NodeType = __nccwpck_require__(29267);
- if (state.lineIndent > nodeIndent && (ch !== 0)) {
- throwError(state, 'bad indentation of a mapping entry');
- } else if (state.lineIndent < nodeIndent) {
- break;
+ 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);
+ }
}
- }
- //
- // Epilogue.
- //
+ Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
- // Special case: last mapping's node contains only the key in explicit notation.
- if (atExplicitKey) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
- }
+ Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
- // Expose the resulting mapping.
- if (detected) {
- state.tag = _tag;
- state.anchor = _anchor;
- state.kind = 'mapping';
- state.result = _result;
- }
+ XMLDTDNotation.prototype.toString = function(options) {
+ return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
+ };
- return detected;
-}
+ return XMLDTDNotation;
-function readTagProperty(state) {
- var _position,
- isVerbatim = false,
- isNamed = false,
- tagHandle,
- tagName,
- ch;
+ })(XMLNode);
- ch = state.input.charCodeAt(state.position);
+}).call(this);
- if (ch !== 0x21/* ! */) return false;
- if (state.tag !== null) {
- throwError(state, 'duplication of a tag property');
- }
+/***/ }),
- ch = state.input.charCodeAt(++state.position);
+/***/ 46364:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- if (ch === 0x3C/* < */) {
- isVerbatim = true;
- ch = state.input.charCodeAt(++state.position);
+// 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;
- } else if (ch === 0x21/* ! */) {
- isNamed = true;
- tagHandle = '!!';
- ch = state.input.charCodeAt(++state.position);
+ isObject = (__nccwpck_require__(58229).isObject);
- } else {
- tagHandle = '!';
- }
+ XMLNode = __nccwpck_require__(67608);
- _position = state.position;
+ NodeType = __nccwpck_require__(29267);
- if (isVerbatim) {
- do { ch = state.input.charCodeAt(++state.position); }
- while (ch !== 0 && ch !== 0x3E/* > */);
+ module.exports = XMLDeclaration = (function(superClass) {
+ extend(XMLDeclaration, superClass);
- if (state.position < state.length) {
- tagName = state.input.slice(_position, state.position);
- ch = state.input.charCodeAt(++state.position);
- } else {
- throwError(state, 'unexpected end of the stream within a verbatim tag');
+ 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);
+ }
}
- } else {
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
- if (ch === 0x21/* ! */) {
- if (!isNamed) {
- tagHandle = state.input.slice(_position - 1, state.position + 1);
+ XMLDeclaration.prototype.toString = function(options) {
+ return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
+ };
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
- throwError(state, 'named tag handle cannot contain such characters');
- }
+ return XMLDeclaration;
- isNamed = true;
- _position = state.position + 1;
- } else {
- throwError(state, 'tag suffix cannot contain exclamation marks');
- }
- }
+ })(XMLNode);
- ch = state.input.charCodeAt(++state.position);
- }
+}).call(this);
- tagName = state.input.slice(_position, state.position);
- if (PATTERN_FLOW_INDICATORS.test(tagName)) {
- throwError(state, 'tag suffix cannot contain flow indicator characters');
- }
- }
+/***/ }),
- if (tagName && !PATTERN_TAG_URI.test(tagName)) {
- throwError(state, 'tag name cannot contain such characters: ' + tagName);
- }
+/***/ 81801:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- if (isVerbatim) {
- state.tag = tagName;
+// 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;
- } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
- state.tag = state.tagMap[tagHandle] + tagName;
+ isObject = (__nccwpck_require__(58229).isObject);
- } else if (tagHandle === '!') {
- state.tag = '!' + tagName;
+ XMLNode = __nccwpck_require__(67608);
- } else if (tagHandle === '!!') {
- state.tag = 'tag:yaml.org,2002:' + tagName;
+ NodeType = __nccwpck_require__(29267);
- } else {
- throwError(state, 'undeclared tag handle "' + tagHandle + '"');
- }
+ XMLDTDAttList = __nccwpck_require__(81015);
- return true;
-}
+ XMLDTDEntity = __nccwpck_require__(40053);
-function readAnchorProperty(state) {
- var _position,
- ch;
+ XMLDTDElement = __nccwpck_require__(52421);
- ch = state.input.charCodeAt(state.position);
+ XMLDTDNotation = __nccwpck_require__(82837);
- if (ch !== 0x26/* & */) return false;
+ XMLNamedNodeMap = __nccwpck_require__(4361);
- if (state.anchor !== null) {
- throwError(state, 'duplication of an anchor property');
- }
+ module.exports = XMLDocType = (function(superClass) {
+ extend(XMLDocType, superClass);
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
+ 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);
+ }
+ }
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
+ 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;
+ }
+ }
+ return new XMLNamedNodeMap(nodes);
+ }
+ });
- if (state.position === _position) {
- throwError(state, 'name of an anchor node must contain at least one character');
- }
+ 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 new XMLNamedNodeMap(nodes);
+ }
+ });
- state.anchor = state.input.slice(_position, state.position);
- return true;
-}
+ Object.defineProperty(XMLDocType.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
-function readAlias(state) {
- var _position, alias,
- ch;
+ Object.defineProperty(XMLDocType.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
- ch = state.input.charCodeAt(state.position);
+ Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
- if (ch !== 0x2A/* * */) return false;
+ XMLDocType.prototype.element = function(name, value) {
+ var child;
+ child = new XMLDTDElement(this, name, value);
+ this.children.push(child);
+ return this;
+ };
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
+ 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;
+ };
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
+ XMLDocType.prototype.entity = function(name, value) {
+ var child;
+ child = new XMLDTDEntity(this, false, name, value);
+ this.children.push(child);
+ return this;
+ };
- if (state.position === _position) {
- throwError(state, 'name of an alias node must contain at least one character');
- }
+ XMLDocType.prototype.pEntity = function(name, value) {
+ var child;
+ child = new XMLDTDEntity(this, true, name, value);
+ this.children.push(child);
+ return this;
+ };
- alias = state.input.slice(_position, state.position);
+ XMLDocType.prototype.notation = function(name, value) {
+ var child;
+ child = new XMLDTDNotation(this, name, value);
+ this.children.push(child);
+ return this;
+ };
- if (!state.anchorMap.hasOwnProperty(alias)) {
- throwError(state, 'unidentified alias "' + alias + '"');
- }
+ XMLDocType.prototype.toString = function(options) {
+ return this.options.writer.docType(this, this.options.writer.filterOptions(options));
+ };
- state.result = state.anchorMap[alias];
- skipSeparationSpace(state, true, -1);
- return true;
-}
+ XMLDocType.prototype.ele = function(name, value) {
+ return this.element(name, value);
+ };
-function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
- var allowBlockStyles,
- allowBlockScalars,
- allowBlockCollections,
- indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) {
- indentStatus = 1;
- } else if (state.lineIndent === parentIndent) {
- indentStatus = 0;
- } else if (state.lineIndent < parentIndent) {
- indentStatus = -1;
+ 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;
+ };
- if (indentStatus === 1) {
- while (readTagProperty(state) || readAnchorProperty(state)) {
- if (skipSeparationSpace(state, true, -1)) {
- atNewLine = true;
- allowBlockCollections = allowBlockStyles;
+ return XMLDocType;
- if (state.lineIndent > parentIndent) {
- indentStatus = 1;
- } else if (state.lineIndent === parentIndent) {
- indentStatus = 0;
- } else if (state.lineIndent < parentIndent) {
- indentStatus = -1;
- }
- } else {
- allowBlockCollections = false;
- }
- }
- }
+ })(XMLNode);
- if (allowBlockCollections) {
- allowBlockCollections = atNewLine || allowCompact;
- }
+}).call(this);
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
- flowIndent = parentIndent;
- } else {
- flowIndent = parentIndent + 1;
- }
- blockIndent = state.position - state.lineStart;
+/***/ }),
- if (indentStatus === 1) {
- if (allowBlockCollections &&
- (readBlockSequence(state, blockIndent) ||
- readBlockMapping(state, blockIndent, flowIndent)) ||
- readFlowCollection(state, flowIndent)) {
- hasContent = true;
- } else {
- if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
- readSingleQuotedScalar(state, flowIndent) ||
- readDoubleQuotedScalar(state, flowIndent)) {
- hasContent = true;
+/***/ 53730:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- } else if (readAlias(state)) {
- hasContent = true;
+// 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;
- if (state.tag !== null || state.anchor !== null) {
- throwError(state, 'alias node should not have any properties');
- }
+ isPlainObject = (__nccwpck_require__(58229).isPlainObject);
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
- hasContent = true;
+ XMLDOMImplementation = __nccwpck_require__(78310);
- if (state.tag === null) {
- state.tag = '?';
- }
- }
+ XMLDOMConfiguration = __nccwpck_require__(67465);
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = state.result;
- }
- }
- } else if (indentStatus === 0) {
- // Special case: block sequences are allowed to have same indentation level as the parent.
- // http://www.yaml.org/spec/1.2/spec.html#id2799784
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
- }
- }
+ XMLNode = __nccwpck_require__(67608);
- if (state.tag !== null && state.tag !== '!') {
- if (state.tag === '?') {
- // Implicit resolving is not allowed for non-scalar types, and '?'
- // non-specific tag is only automatically assigned to plain scalars.
- //
- // We only need to check kind conformity in case user explicitly assigns '?'
- // tag, for example like this: "!> [0]"
- //
- if (state.result !== null && state.kind !== 'scalar') {
- throwError(state, 'unacceptable node kind for !> tag; it should be "scalar", not "' + state.kind + '"');
- }
+ NodeType = __nccwpck_require__(29267);
- for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
- type = state.implicitTypes[typeIndex];
+ XMLStringifier = __nccwpck_require__(8594);
- if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
- state.result = type.construct(state.result);
- state.tag = type.tag;
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = state.result;
- }
- break;
- }
- }
- } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
- type = state.typeMap[state.kind || 'fallback'][state.tag];
+ XMLStringWriter = __nccwpck_require__(85913);
- if (state.result !== null && type.kind !== state.kind) {
- throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
- }
+ module.exports = XMLDocument = (function(superClass) {
+ extend(XMLDocument, superClass);
- if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
- throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
- } else {
- state.result = type.construct(state.result);
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = state.result;
- }
+ 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();
}
- } else {
- throwError(state, 'unknown tag !<' + state.tag + '>');
+ this.options = options;
+ this.stringify = new XMLStringifier(options);
}
- }
-
- if (state.listener !== null) {
- state.listener('close', state);
- }
- return state.tag !== null || state.anchor !== null || hasContent;
-}
-
-function readDocument(state) {
- var documentStart = state.position,
- _position,
- directiveName,
- directiveArgs,
- hasDirectives = false,
- ch;
-
- state.version = null;
- state.checkLineBreaks = state.legacy;
- state.tagMap = {};
- state.anchorMap = {};
-
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
- skipSeparationSpace(state, true, -1);
-
- ch = state.input.charCodeAt(state.position);
- if (state.lineIndent > 0 || ch !== 0x25/* % */) {
- break;
- }
+ Object.defineProperty(XMLDocument.prototype, 'implementation', {
+ value: new XMLDOMImplementation()
+ });
- hasDirectives = true;
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
+ 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;
+ }
+ }
+ return null;
+ }
+ });
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
+ Object.defineProperty(XMLDocument.prototype, 'documentElement', {
+ get: function() {
+ return this.rootObject || null;
+ }
+ });
- directiveName = state.input.slice(_position, state.position);
- directiveArgs = [];
+ Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
+ get: function() {
+ return null;
+ }
+ });
- if (directiveName.length < 1) {
- throwError(state, 'directive name must not be less than one character in length');
- }
+ Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
+ get: function() {
+ return false;
+ }
+ });
- while (ch !== 0) {
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
+ 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;
+ }
}
+ });
- if (ch === 0x23/* # */) {
- do { ch = state.input.charCodeAt(++state.position); }
- while (ch !== 0 && !is_EOL(ch));
- break;
+ 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;
+ }
}
+ });
- if (is_EOL(ch)) break;
+ 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";
+ }
+ }
+ });
- _position = state.position;
+ Object.defineProperty(XMLDocument.prototype, 'URL', {
+ get: function() {
+ return this.documentURI;
+ }
+ });
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
- ch = state.input.charCodeAt(++state.position);
+ Object.defineProperty(XMLDocument.prototype, 'origin', {
+ get: function() {
+ return null;
}
+ });
- directiveArgs.push(state.input.slice(_position, state.position));
- }
+ Object.defineProperty(XMLDocument.prototype, 'compatMode', {
+ get: function() {
+ return null;
+ }
+ });
- if (ch !== 0) readLineBreak(state);
+ Object.defineProperty(XMLDocument.prototype, 'characterSet', {
+ get: function() {
+ return null;
+ }
+ });
- if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
- directiveHandlers[directiveName](state, directiveName, directiveArgs);
- } else {
- throwWarning(state, 'unknown document directive "' + directiveName + '"');
- }
- }
+ Object.defineProperty(XMLDocument.prototype, 'contentType', {
+ get: function() {
+ return null;
+ }
+ });
- skipSeparationSpace(state, true, -1);
+ 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));
+ };
- if (state.lineIndent === 0 &&
- state.input.charCodeAt(state.position) === 0x2D/* - */ &&
- state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
- state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
- state.position += 3;
- skipSeparationSpace(state, true, -1);
+ XMLDocument.prototype.toString = function(options) {
+ return this.options.writer.document(this, this.options.writer.filterOptions(options));
+ };
- } else if (hasDirectives) {
- throwError(state, 'directives end mark is expected');
- }
+ XMLDocument.prototype.createElement = function(tagName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
- skipSeparationSpace(state, true, -1);
+ XMLDocument.prototype.createDocumentFragment = function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (state.checkLineBreaks &&
- PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
- throwWarning(state, 'non-ASCII line breaks are interpreted as content');
- }
+ XMLDocument.prototype.createTextNode = function(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- state.documents.push(state.result);
+ XMLDocument.prototype.createComment = function(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
+ XMLDocument.prototype.createCDATASection = function(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
- state.position += 3;
- skipSeparationSpace(state, true, -1);
- }
- return;
- }
+ XMLDocument.prototype.createProcessingInstruction = function(target, data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (state.position < (state.length - 1)) {
- throwError(state, 'end of the stream or a document separator is expected');
- } else {
- return;
- }
-}
+ 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());
+ };
-function loadDocuments(input, options) {
- input = String(input);
- options = options || {};
+ XMLDocument.prototype.getElementsByTagName = function(tagname) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (input.length !== 0) {
+ XMLDocument.prototype.importNode = function(importedNode, deep) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- // Add tailing `\n` if not exists
- if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
- input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
- input += '\n';
- }
+ XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- // Strip BOM
- if (input.charCodeAt(0) === 0xFEFF) {
- input = input.slice(1);
- }
- }
+ XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- var state = new State(input, options);
+ XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- var nullpos = input.indexOf('\0');
+ XMLDocument.prototype.getElementById = function(elementId) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (nullpos !== -1) {
- state.position = nullpos;
- throwError(state, 'null byte is not allowed in input');
- }
+ XMLDocument.prototype.adoptNode = function(source) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- // Use 0 as string terminator. That significantly simplifies bounds check.
- state.input += '\0';
+ XMLDocument.prototype.normalizeDocument = function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
- state.lineIndent += 1;
- state.position += 1;
- }
+ XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- while (state.position < (state.length - 1)) {
- readDocument(state);
- }
+ XMLDocument.prototype.getElementsByClassName = function(classNames) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- return state.documents;
-}
+ 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());
+ };
-function loadAll(input, iterator, options) {
- if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
- options = iterator;
- iterator = null;
- }
+ XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- var documents = loadDocuments(input, options);
+ XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (typeof iterator !== 'function') {
- return documents;
- }
+ return XMLDocument;
- for (var index = 0, length = documents.length; index < length; index += 1) {
- iterator(documents[index]);
- }
-}
+ })(XMLNode);
+}).call(this);
-function load(input, options) {
- var documents = loadDocuments(input, options);
- if (documents.length === 0) {
- /*eslint-disable no-undefined*/
- return undefined;
- } else if (documents.length === 1) {
- return documents[0];
- }
- throw new YAMLException('expected a single document in the stream, but found more');
-}
+/***/ }),
+/***/ 77356:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-function safeLoadAll(input, iterator, options) {
- if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
- options = iterator;
- iterator = null;
- }
+// 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;
- return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
-}
+ ref = __nccwpck_require__(58229), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
+ NodeType = __nccwpck_require__(29267);
-function safeLoad(input, options) {
- return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
-}
+ XMLDocument = __nccwpck_require__(53730);
+ XMLElement = __nccwpck_require__(9437);
-module.exports.loadAll = loadAll;
-module.exports.load = load;
-module.exports.safeLoadAll = safeLoadAll;
-module.exports.safeLoad = safeLoad;
+ XMLCData = __nccwpck_require__(90333);
+ XMLComment = __nccwpck_require__(74407);
-/***/ }),
+ XMLRaw = __nccwpck_require__(16329);
-/***/ 77262:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLText = __nccwpck_require__(21318);
-"use strict";
+ XMLProcessingInstruction = __nccwpck_require__(56939);
+ XMLDeclaration = __nccwpck_require__(46364);
+ XMLDocType = __nccwpck_require__(81801);
-var common = __nccwpck_require__(59941);
+ XMLDTDAttList = __nccwpck_require__(81015);
+ XMLDTDEntity = __nccwpck_require__(40053);
-function Mark(name, buffer, position, line, column) {
- this.name = name;
- this.buffer = buffer;
- this.position = position;
- this.line = line;
- this.column = column;
-}
+ XMLDTDElement = __nccwpck_require__(52421);
+ XMLDTDNotation = __nccwpck_require__(82837);
-Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
- var head, start, tail, end, snippet;
+ XMLAttribute = __nccwpck_require__(58376);
- if (!this.buffer) return null;
+ XMLStringifier = __nccwpck_require__(8594);
- indent = indent || 4;
- maxLength = maxLength || 75;
+ XMLStringWriter = __nccwpck_require__(85913);
- head = '';
- start = this.position;
+ WriterState = __nccwpck_require__(9766);
- while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
- start -= 1;
- if (this.position - start > (maxLength / 2 - 1)) {
- head = ' ... ';
- start += 5;
- break;
+ 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;
}
- }
- tail = '';
- end = this.position;
+ 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;
+ };
- while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
- end += 1;
- if (end - this.position > (maxLength / 2 - 1)) {
- tail = ' ... ';
- end -= 5;
- break;
- }
- }
+ XMLDocumentCB.prototype.dummy = function() {
+ return this;
+ };
- snippet = this.buffer.slice(start, end);
+ 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;
+ };
- return common.repeat(' ', indent) + head + snippet + tail + '\n' +
- common.repeat(' ', indent + this.position - start + head.length) + '^';
-};
+ 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;
+ };
+
+ 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;
+ };
+ 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;
+ };
-Mark.prototype.toString = function toString(compact) {
- var snippet, where = '';
+ 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;
+ };
- if (this.name) {
- where += 'in "' + this.name + '" ';
- }
+ 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;
+ };
- where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
+ 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;
+ };
- if (!compact) {
- snippet = this.getSnippet();
+ 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;
+ };
- if (snippet) {
- where += ':\n' + snippet;
- }
- }
+ 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;
+ };
- return where;
-};
+ 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;
+ };
-module.exports = Mark;
+ 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;
+ };
-/***/ 66280:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ 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;
+ };
-"use strict";
+ 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;
+ };
+ XMLDocumentCB.prototype.end = function() {
+ while (this.currentLevel >= 0) {
+ this.up();
+ }
+ return this.onEnd();
+ };
-/*eslint-disable max-len*/
+ XMLDocumentCB.prototype.openCurrent = function() {
+ if (this.currentNode) {
+ this.currentNode.children = true;
+ return this.openNode(this.currentNode);
+ }
+ };
-var common = __nccwpck_require__(59941);
-var YAMLException = __nccwpck_require__(29291);
-var Type = __nccwpck_require__(90256);
+ 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;
+ }
+ 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;
+ }
+ };
+ 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) + '' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
+ } else {
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
+ }
+ this.writerOptions.state = WriterState.None;
+ this.onData(chunk, this.currentLevel);
+ return node.isClosed = true;
+ }
+ };
-function compileList(schema, name, result) {
- var exclude = [];
+ XMLDocumentCB.prototype.onData = function(chunk, level) {
+ this.documentStarted = true;
+ return this.onDataCallback(chunk, level + 1);
+ };
- schema.include.forEach(function (includedSchema) {
- result = compileList(includedSchema, name, result);
- });
+ XMLDocumentCB.prototype.onEnd = function() {
+ this.documentCompleted = true;
+ return this.onEndCallback();
+ };
- schema[name].forEach(function (currentType) {
- result.forEach(function (previousType, previousIndex) {
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
- exclude.push(previousIndex);
+ XMLDocumentCB.prototype.debugInfo = function(name) {
+ if (name == null) {
+ return "";
+ } else {
+ return "node: <" + name + ">";
}
- });
+ };
- result.push(currentType);
- });
+ XMLDocumentCB.prototype.ele = function() {
+ return this.element.apply(this, arguments);
+ };
- return result.filter(function (type, index) {
- return exclude.indexOf(index) === -1;
- });
-}
+ XMLDocumentCB.prototype.nod = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
+ XMLDocumentCB.prototype.txt = function(value) {
+ return this.text(value);
+ };
-function compileMap(/* lists... */) {
- var result = {
- scalar: {},
- sequence: {},
- mapping: {},
- fallback: {}
- }, index, length;
+ XMLDocumentCB.prototype.dat = function(value) {
+ return this.cdata(value);
+ };
- function collectType(type) {
- result[type.kind][type.tag] = result['fallback'][type.tag] = type;
- }
+ XMLDocumentCB.prototype.com = function(value) {
+ return this.comment(value);
+ };
- for (index = 0, length = arguments.length; index < length; index += 1) {
- arguments[index].forEach(collectType);
- }
- return result;
-}
+ XMLDocumentCB.prototype.ins = function(target, value) {
+ return this.instruction(target, value);
+ };
+ XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ };
-function Schema(definition) {
- this.include = definition.include || [];
- this.implicit = definition.implicit || [];
- this.explicit = definition.explicit || [];
+ XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
+ return this.doctype(root, pubID, sysID);
+ };
- this.implicit.forEach(function (type) {
- if (type.loadKind && type.loadKind !== 'scalar') {
- throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
- }
- });
+ XMLDocumentCB.prototype.e = function(name, attributes, text) {
+ return this.element(name, attributes, text);
+ };
- this.compiledImplicit = compileList(this, 'implicit', []);
- this.compiledExplicit = compileList(this, 'explicit', []);
- this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
-}
+ XMLDocumentCB.prototype.n = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
+ XMLDocumentCB.prototype.t = function(value) {
+ return this.text(value);
+ };
-Schema.DEFAULT = null;
+ XMLDocumentCB.prototype.d = function(value) {
+ return this.cdata(value);
+ };
+ XMLDocumentCB.prototype.c = function(value) {
+ return this.comment(value);
+ };
-Schema.create = function createSchema() {
- var schemas, types;
+ XMLDocumentCB.prototype.r = function(value) {
+ return this.raw(value);
+ };
- switch (arguments.length) {
- case 1:
- schemas = Schema.DEFAULT;
- types = arguments[0];
- break;
+ XMLDocumentCB.prototype.i = function(target, value) {
+ return this.instruction(target, value);
+ };
- case 2:
- schemas = arguments[0];
- types = arguments[1];
- break;
+ 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);
+ }
+ };
- default:
- throw new YAMLException('Wrong number of arguments for Schema.create function');
- }
+ 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);
+ }
+ };
- schemas = common.toArray(schemas);
- types = common.toArray(types);
+ XMLDocumentCB.prototype.ent = function(name, value) {
+ return this.entity(name, value);
+ };
- if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
- throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
- }
+ XMLDocumentCB.prototype.pent = function(name, value) {
+ return this.pEntity(name, value);
+ };
- if (!types.every(function (type) { return type instanceof Type; })) {
- throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
- }
+ XMLDocumentCB.prototype.not = function(name, value) {
+ return this.notation(name, value);
+ };
- return new Schema({
- include: schemas,
- explicit: types
- });
-};
+ return XMLDocumentCB;
+ })();
-module.exports = Schema;
+}).call(this);
/***/ }),
-/***/ 11950:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+/***/ 43590:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-"use strict";
-// Standard YAML's Core schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2804923
-//
-// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
-// So, Core schema has no distinctions from JSON schema is JS-YAML.
+// 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__(67608);
+ NodeType = __nccwpck_require__(29267);
+ module.exports = XMLDummy = (function(superClass) {
+ extend(XMLDummy, superClass);
+ function XMLDummy(parent) {
+ XMLDummy.__super__.constructor.call(this, parent);
+ this.type = NodeType.Dummy;
+ }
-var Schema = __nccwpck_require__(66280);
+ XMLDummy.prototype.clone = function() {
+ return Object.create(this);
+ };
+ XMLDummy.prototype.toString = function(options) {
+ return '';
+ };
-module.exports = new Schema({
- include: [
- __nccwpck_require__(2168)
- ]
-});
+ return XMLDummy;
+ })(XMLNode);
-/***/ }),
+}).call(this);
-/***/ 145:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
-"use strict";
-// JS-YAML's default schema for `load` function.
-// It is not described in the YAML specification.
-//
-// This schema is based on JS-YAML's default safe schema and includes
-// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
-//
-// Also this schema is used as default base schema at `Schema.create` function.
+/***/ }),
+/***/ 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__(58229), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
+ XMLNode = __nccwpck_require__(67608);
-var Schema = __nccwpck_require__(66280);
+ NodeType = __nccwpck_require__(29267);
+ XMLAttribute = __nccwpck_require__(58376);
-module.exports = Schema.DEFAULT = new Schema({
- include: [
- __nccwpck_require__(42881)
- ],
- explicit: [
- __nccwpck_require__(34801),
- __nccwpck_require__(77234),
- __nccwpck_require__(35361)
- ]
-});
+ 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;
+ }
+ }
+ }
+ }
+ }
-/***/ 42881:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ Object.defineProperty(XMLElement.prototype, 'tagName', {
+ get: function() {
+ return this.name;
+ }
+ });
-"use strict";
-// JS-YAML's default schema for `safeLoad` function.
-// It is not described in the YAML specification.
-//
-// This schema is based on standard YAML's Core schema and includes most of
-// extra types described at YAML tag repository. (http://yaml.org/type/)
+ 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());
+ }
+ });
-var Schema = __nccwpck_require__(66280);
+ 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;
+ }
+ });
-module.exports = new Schema({
- include: [
- __nccwpck_require__(11950)
- ],
- implicit: [
- __nccwpck_require__(82018),
- __nccwpck_require__(60194)
- ],
- explicit: [
- __nccwpck_require__(21716),
- __nccwpck_require__(96439),
- __nccwpck_require__(33730),
- __nccwpck_require__(9047)
- ]
-});
+ 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;
+ };
+ 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;
+ };
-/***/ }),
+ 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;
+ };
-/***/ 70026:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLElement.prototype.toString = function(options) {
+ return this.options.writer.element(this, this.options.writer.filterOptions(options));
+ };
-"use strict";
-// Standard YAML's Failsafe schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2802346
+ 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;
+ }
+ };
-var Schema = __nccwpck_require__(66280);
+ 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());
+ };
-module.exports = new Schema({
- explicit: [
- __nccwpck_require__(24649),
- __nccwpck_require__(65629),
- __nccwpck_require__(15938)
- ]
-});
+ 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());
+ };
-/***/ 2168:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
-"use strict";
-// Standard YAML's JSON schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2803231
-//
-// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
-// So, this schema is not such strict as defined in the YAML specification.
-// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
+ 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());
+ };
-var Schema = __nccwpck_require__(66280);
+ 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());
+ };
-module.exports = new Schema({
- include: [
- __nccwpck_require__(70026)
- ],
- implicit: [
- __nccwpck_require__(26058),
- __nccwpck_require__(93195),
- __nccwpck_require__(76865),
- __nccwpck_require__(16480)
- ]
-});
+ 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());
+ };
-/***/ 90256:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLElement.prototype.getElementsByClassName = function(classNames) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
-"use strict";
+ 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 XMLElement;
-var YAMLException = __nccwpck_require__(29291);
+ })(XMLNode);
-var TYPE_CONSTRUCTOR_OPTIONS = [
- 'kind',
- 'resolve',
- 'construct',
- 'instanceOf',
- 'predicate',
- 'represent',
- 'defaultStyle',
- 'styleAliases'
-];
+}).call(this);
-var YAML_NODE_KINDS = [
- 'scalar',
- 'sequence',
- 'mapping'
-];
-function compileStyleAliases(map) {
- var result = {};
+/***/ }),
- if (map !== null) {
- Object.keys(map).forEach(function (style) {
- map[style].forEach(function (alias) {
- result[String(alias)] = style;
- });
+/***/ 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;
+ }
});
- }
- return result;
-}
+ XMLNamedNodeMap.prototype.clone = function() {
+ return this.nodes = null;
+ };
-function Type(tag, options) {
- options = options || {};
+ XMLNamedNodeMap.prototype.getNamedItem = function(name) {
+ return this.nodes[name];
+ };
- Object.keys(options).forEach(function (name) {
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
- throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
- }
- });
+ XMLNamedNodeMap.prototype.setNamedItem = function(node) {
+ var oldNode;
+ oldNode = this.nodes[node.nodeName];
+ this.nodes[node.nodeName] = node;
+ return oldNode || null;
+ };
- // TODO: Add tag format check.
- this.tag = tag;
- this.kind = options['kind'] || null;
- this.resolve = options['resolve'] || function () { return true; };
- this.construct = options['construct'] || function (data) { return data; };
- this.instanceOf = options['instanceOf'] || null;
- this.predicate = options['predicate'] || null;
- this.represent = options['represent'] || null;
- this.defaultStyle = options['defaultStyle'] || null;
- this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
+ XMLNamedNodeMap.prototype.removeNamedItem = function(name) {
+ var oldNode;
+ oldNode = this.nodes[name];
+ delete this.nodes[name];
+ return oldNode || null;
+ };
- if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
- throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
- }
-}
+ XMLNamedNodeMap.prototype.item = function(index) {
+ return this.nodes[Object.keys(this.nodes)[index]] || null;
+ };
-module.exports = Type;
+ XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented.");
+ };
+ XMLNamedNodeMap.prototype.setNamedItemNS = function(node) {
+ throw new Error("This DOM method is not implemented.");
+ };
-/***/ }),
+ XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented.");
+ };
-/***/ 21716:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ return XMLNamedNodeMap;
-"use strict";
+ })();
+}).call(this);
-/*eslint-disable no-bitwise*/
-var NodeBuffer;
+/***/ }),
-try {
- // A trick for browserified version, to not include `Buffer` shim
- var _require = require;
- NodeBuffer = _require('buffer').Buffer;
-} catch (__) {}
+/***/ 67608:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-var Type = __nccwpck_require__(90256);
+// 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__(58229), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
-// [ 64, 65, 66 ] -> [ padding, CR, LF ]
-var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
+ XMLElement = null;
+ XMLCData = null;
-function resolveYamlBinary(data) {
- if (data === null) return false;
+ XMLComment = null;
- var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
+ XMLDeclaration = null;
- // Convert one by one.
- for (idx = 0; idx < max; idx++) {
- code = map.indexOf(data.charAt(idx));
+ XMLDocType = null;
- // Skip CR/LF
- if (code > 64) continue;
+ XMLRaw = null;
- // Fail on illegal characters
- if (code < 0) return false;
+ XMLText = null;
- bitlen += 6;
- }
+ XMLProcessingInstruction = null;
- // If there are any bits left, source was corrupted
- return (bitlen % 8) === 0;
-}
+ XMLDummy = null;
-function constructYamlBinary(data) {
- var idx, tailbits,
- input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
- max = input.length,
- map = BASE64_MAP,
- bits = 0,
- result = [];
+ NodeType = null;
- // Collect by 6*4 bits (3 bytes)
+ XMLNodeList = null;
- for (idx = 0; idx < max; idx++) {
- if ((idx % 4 === 0) && idx) {
- result.push((bits >> 16) & 0xFF);
- result.push((bits >> 8) & 0xFF);
- result.push(bits & 0xFF);
- }
+ XMLNamedNodeMap = null;
- bits = (bits << 6) | map.indexOf(input.charAt(idx));
- }
+ DocumentPosition = null;
- // Dump tail
+ 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__(90333);
+ XMLComment = __nccwpck_require__(74407);
+ XMLDeclaration = __nccwpck_require__(46364);
+ XMLDocType = __nccwpck_require__(81801);
+ XMLRaw = __nccwpck_require__(16329);
+ XMLText = __nccwpck_require__(21318);
+ XMLProcessingInstruction = __nccwpck_require__(56939);
+ XMLDummy = __nccwpck_require__(43590);
+ NodeType = __nccwpck_require__(29267);
+ XMLNodeList = __nccwpck_require__(36768);
+ XMLNamedNodeMap = __nccwpck_require__(4361);
+ DocumentPosition = __nccwpck_require__(52839);
+ }
+ }
- tailbits = (max % 4) * 6;
+ Object.defineProperty(XMLNode.prototype, 'nodeName', {
+ get: function() {
+ return this.name;
+ }
+ });
- if (tailbits === 0) {
- result.push((bits >> 16) & 0xFF);
- result.push((bits >> 8) & 0xFF);
- result.push(bits & 0xFF);
- } else if (tailbits === 18) {
- result.push((bits >> 10) & 0xFF);
- result.push((bits >> 2) & 0xFF);
- } else if (tailbits === 12) {
- result.push((bits >> 4) & 0xFF);
- }
+ Object.defineProperty(XMLNode.prototype, 'nodeType', {
+ get: function() {
+ return this.type;
+ }
+ });
- // Wrap into Buffer for NodeJS and leave Array for browser
- if (NodeBuffer) {
- // Support node 6.+ Buffer API when available
- return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
- }
+ Object.defineProperty(XMLNode.prototype, 'nodeValue', {
+ get: function() {
+ return this.value;
+ }
+ });
- return result;
-}
+ Object.defineProperty(XMLNode.prototype, 'parentNode', {
+ get: function() {
+ return this.parent;
+ }
+ });
-function representYamlBinary(object /*, style*/) {
- var result = '', bits = 0, idx, tail,
- max = object.length,
- map = BASE64_MAP;
+ Object.defineProperty(XMLNode.prototype, 'childNodes', {
+ get: function() {
+ if (!this.childNodeList || !this.childNodeList.nodes) {
+ this.childNodeList = new XMLNodeList(this.children);
+ }
+ return this.childNodeList;
+ }
+ });
- // Convert every three bytes to 4 ASCII characters.
+ Object.defineProperty(XMLNode.prototype, 'firstChild', {
+ get: function() {
+ return this.children[0] || null;
+ }
+ });
- for (idx = 0; idx < max; idx++) {
- if ((idx % 3 === 0) && idx) {
- result += map[(bits >> 18) & 0x3F];
- result += map[(bits >> 12) & 0x3F];
- result += map[(bits >> 6) & 0x3F];
- result += map[bits & 0x3F];
- }
+ Object.defineProperty(XMLNode.prototype, 'lastChild', {
+ get: function() {
+ return this.children[this.children.length - 1] || null;
+ }
+ });
- bits = (bits << 8) + object[idx];
- }
+ Object.defineProperty(XMLNode.prototype, 'previousSibling', {
+ get: function() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ return this.parent.children[i - 1] || null;
+ }
+ });
- // Dump tail
+ Object.defineProperty(XMLNode.prototype, 'nextSibling', {
+ get: function() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ return this.parent.children[i + 1] || null;
+ }
+ });
- tail = max % 3;
+ Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
+ get: function() {
+ return this.document() || null;
+ }
+ });
- if (tail === 0) {
- result += map[(bits >> 18) & 0x3F];
- result += map[(bits >> 12) & 0x3F];
- result += map[(bits >> 6) & 0x3F];
- result += map[bits & 0x3F];
- } else if (tail === 2) {
- result += map[(bits >> 10) & 0x3F];
- result += map[(bits >> 4) & 0x3F];
- result += map[(bits << 2) & 0x3F];
- result += map[64];
- } else if (tail === 1) {
- result += map[(bits >> 2) & 0x3F];
- result += map[(bits << 4) & 0x3F];
- result += map[64];
- result += map[64];
- }
+ 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());
+ }
+ });
- return result;
-}
+ 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;
+ };
-function isBinary(object) {
- return NodeBuffer && NodeBuffer.isBuffer(object);
-}
+ 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);
+ }
+ }
+ if (lastChild == null) {
+ throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
+ }
+ return lastChild;
+ };
-module.exports = new Type('tag:yaml.org,2002:binary', {
- kind: 'scalar',
- resolve: resolveYamlBinary,
- construct: constructYamlBinary,
- predicate: isBinary,
- represent: representYamlBinary
-});
+ 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));
+ }
+ 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;
+ };
-/***/ 93195:
-/***/ ((module, __unused_webpack_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;
+ };
+ XMLNode.prototype.cdata = function(value) {
+ var child;
+ child = new XMLCData(this, value);
+ this.children.push(child);
+ return this;
+ };
-var Type = __nccwpck_require__(90256);
+ XMLNode.prototype.comment = function(value) {
+ var child;
+ child = new XMLComment(this, value);
+ this.children.push(child);
+ return this;
+ };
-function resolveYamlBoolean(data) {
- if (data === null) return false;
+ 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;
+ };
- var max = data.length;
+ 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;
+ };
- return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
- (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
-}
+ XMLNode.prototype.raw = function(value) {
+ var child;
+ child = new XMLRaw(this, value);
+ this.children.push(child);
+ return this;
+ };
-function constructYamlBoolean(data) {
- return data === 'true' ||
- data === 'True' ||
- data === 'TRUE';
-}
+ XMLNode.prototype.dummy = function() {
+ var child;
+ child = new XMLDummy(this);
+ return child;
+ };
-function isBoolean(object) {
- return Object.prototype.toString.call(object) === '[object Boolean]';
-}
+ 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;
+ };
-module.exports = new Type('tag:yaml.org,2002:bool', {
- kind: 'scalar',
- resolve: resolveYamlBoolean,
- construct: constructYamlBoolean,
- predicate: isBoolean,
- represent: {
- lowercase: function (object) { return object ? 'true' : 'false'; },
- uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
- camelcase: function (object) { return object ? 'True' : 'False'; }
- },
- defaultStyle: 'lowercase'
-});
+ 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;
+ };
-/***/ 16480:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ 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;
+ }
+ }
+ ref3 = doc.children;
+ for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
+ child = ref3[i];
+ if (child.isRoot) {
+ doc.children.splice(i, 0, doctype);
+ return doctype;
+ }
+ }
+ doc.children.push(doctype);
+ return doctype;
+ };
-"use strict";
+ 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;
+ }
+ }
+ };
-var common = __nccwpck_require__(59941);
-var Type = __nccwpck_require__(90256);
+ XMLNode.prototype.document = function() {
+ var node;
+ node = this;
+ while (node) {
+ if (node.type === NodeType.Document) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ };
-var YAML_FLOAT_PATTERN = new RegExp(
- // 2.5e4, 2.5 and integers
- '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
- // .2e4, .2
- // special case, seems not from spec
- '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
- // 20:59
- '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
- // .inf
- '|[-+]?\\.(?:inf|Inf|INF)' +
- // .nan
- '|\\.(?:nan|NaN|NAN))$');
+ XMLNode.prototype.end = function(options) {
+ return this.document().end(options);
+ };
-function resolveYamlFloat(data) {
- if (data === null) return false;
+ 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];
+ };
- if (!YAML_FLOAT_PATTERN.test(data) ||
- // Quick hack to not allow integers end with `_`
- // Probably should update regexp & check speed
- data[data.length - 1] === '_') {
- return false;
- }
+ 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];
+ };
- return true;
-}
+ XMLNode.prototype.importDocument = function(doc) {
+ var clonedRoot;
+ clonedRoot = doc.root().clone();
+ clonedRoot.parent = this;
+ clonedRoot.isRoot = false;
+ this.children.push(clonedRoot);
+ return this;
+ };
-function constructYamlFloat(data) {
- var value, sign, base, digits;
+ 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 + ">";
+ }
+ };
- value = data.replace(/_/g, '').toLowerCase();
- sign = value[0] === '-' ? -1 : 1;
- digits = [];
+ XMLNode.prototype.ele = function(name, attributes, text) {
+ return this.element(name, attributes, text);
+ };
- if ('+-'.indexOf(value[0]) >= 0) {
- value = value.slice(1);
- }
+ XMLNode.prototype.nod = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
- if (value === '.inf') {
- return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
+ XMLNode.prototype.txt = function(value) {
+ return this.text(value);
+ };
- } else if (value === '.nan') {
- return NaN;
+ XMLNode.prototype.dat = function(value) {
+ return this.cdata(value);
+ };
- } else if (value.indexOf(':') >= 0) {
- value.split(':').forEach(function (v) {
- digits.unshift(parseFloat(v, 10));
- });
+ XMLNode.prototype.com = function(value) {
+ return this.comment(value);
+ };
- value = 0.0;
- base = 1;
+ XMLNode.prototype.ins = function(target, value) {
+ return this.instruction(target, value);
+ };
- digits.forEach(function (d) {
- value += d * base;
- base *= 60;
- });
+ XMLNode.prototype.doc = function() {
+ return this.document();
+ };
- return sign * value;
+ XMLNode.prototype.dec = function(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ };
- }
- return sign * parseFloat(value, 10);
-}
+ 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);
+ };
-var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
+ XMLNode.prototype.t = function(value) {
+ return this.text(value);
+ };
-function representYamlFloat(object, style) {
- var res;
+ XMLNode.prototype.d = function(value) {
+ return this.cdata(value);
+ };
- if (isNaN(object)) {
- switch (style) {
- case 'lowercase': return '.nan';
- case 'uppercase': return '.NAN';
- case 'camelcase': return '.NaN';
- }
- } else if (Number.POSITIVE_INFINITY === object) {
- switch (style) {
- case 'lowercase': return '.inf';
- case 'uppercase': return '.INF';
- case 'camelcase': return '.Inf';
- }
- } else if (Number.NEGATIVE_INFINITY === object) {
- switch (style) {
- case 'lowercase': return '-.inf';
- case 'uppercase': return '-.INF';
- case 'camelcase': return '-.Inf';
- }
- } else if (common.isNegativeZero(object)) {
- return '-0.0';
- }
+ XMLNode.prototype.c = function(value) {
+ return this.comment(value);
+ };
- res = object.toString(10);
+ XMLNode.prototype.r = function(value) {
+ return this.raw(value);
+ };
- // JS stringifier can build scientific format without dots: 5e-100,
- // while YAML requres dot: 5.e-100. Fix it with simple hack
+ XMLNode.prototype.i = function(target, value) {
+ return this.instruction(target, value);
+ };
- return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
-}
+ XMLNode.prototype.u = function() {
+ return this.up();
+ };
-function isFloat(object) {
- return (Object.prototype.toString.call(object) === '[object Number]') &&
- (object % 1 !== 0 || common.isNegativeZero(object));
-}
+ XMLNode.prototype.importXMLBuilder = function(doc) {
+ return this.importDocument(doc);
+ };
-module.exports = new Type('tag:yaml.org,2002:float', {
- kind: 'scalar',
- resolve: resolveYamlFloat,
- construct: constructYamlFloat,
- predicate: isFloat,
- represent: representYamlFloat,
- defaultStyle: 'lowercase'
-});
+ 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());
+ };
-/***/ 76865:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLNode.prototype.hasChildNodes = function() {
+ return this.children.length !== 0;
+ };
-"use strict";
+ 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());
+ };
-var common = __nccwpck_require__(59941);
-var Type = __nccwpck_require__(90256);
+ XMLNode.prototype.isSupported = function(feature, version) {
+ return true;
+ };
-function isHexCode(c) {
- return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
- ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
- ((0x61/* a */ <= c) && (c <= 0x66/* f */));
-}
+ XMLNode.prototype.hasAttributes = function() {
+ return this.attribs.length !== 0;
+ };
-function isOctCode(c) {
- return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
-}
+ 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;
+ }
+ };
-function isDecCode(c) {
- return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
-}
+ XMLNode.prototype.isSameNode = function(other) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
-function resolveYamlInteger(data) {
- if (data === null) return false;
+ XMLNode.prototype.lookupPrefix = function(namespaceURI) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- var max = data.length,
- index = 0,
- hasDigits = false,
- ch;
+ XMLNode.prototype.isDefaultNamespace = function(namespaceURI) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (!max) return false;
+ XMLNode.prototype.lookupNamespaceURI = function(prefix) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- ch = data[index];
+ 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;
+ };
- // sign
- if (ch === '-' || ch === '+') {
- ch = data[++index];
- }
+ XMLNode.prototype.getFeature = function(feature, version) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (ch === '0') {
- // 0
- if (index + 1 === max) return true;
- ch = data[++index];
+ XMLNode.prototype.setUserData = function(key, data, handler) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- // base 2, base 8, base 16
+ XMLNode.prototype.getUserData = function(key) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- if (ch === 'b') {
- // base 2
- index++;
+ XMLNode.prototype.contains = function(other) {
+ if (!other) {
+ return false;
+ }
+ return other === this || this.isDescendant(other);
+ };
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') continue;
- if (ch !== '0' && ch !== '1') return false;
- hasDigits = true;
+ 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;
+ }
+ isDescendantChild = child.isDescendant(node);
+ if (isDescendantChild) {
+ return true;
+ }
}
- return hasDigits && ch !== '_';
- }
+ return false;
+ };
+ XMLNode.prototype.isAncestor = function(node) {
+ return node.isDescendant(this);
+ };
- if (ch === 'x') {
- // base 16
- index++;
+ 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;
+ }
+ };
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') continue;
- if (!isHexCode(data.charCodeAt(index))) return false;
- hasDigits = true;
+ 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 hasDigits && ch !== '_';
- }
+ };
- // base 8
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') continue;
- if (!isOctCode(data.charCodeAt(index))) return false;
- hasDigits = true;
- }
- return hasDigits && ch !== '_';
- }
+ 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;
+ }
+ };
- // base 10 (except 0) or base 60
+ 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;
+ }
+ }
+ }
+ };
- // value should not start with `_`;
- if (ch === '_') return false;
+ return XMLNode;
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') continue;
- if (ch === ':') break;
- if (!isDecCode(data.charCodeAt(index))) {
- return false;
- }
- hasDigits = true;
- }
+ })();
- // Should have digits and should not end with `_`
- if (!hasDigits || ch === '_') return false;
+}).call(this);
- // if !base60 - done;
- if (ch !== ':') return true;
- // base60 almost not used, no needs to optimize
- return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
-}
+/***/ }),
-function constructYamlInteger(data) {
- var value = data, sign = 1, ch, base, digits = [];
+/***/ 36768:
+/***/ (function(module) {
- if (value.indexOf('_') !== -1) {
- value = value.replace(/_/g, '');
- }
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNodeList;
- ch = value[0];
+ module.exports = XMLNodeList = (function() {
+ function XMLNodeList(nodes) {
+ this.nodes = nodes;
+ }
- if (ch === '-' || ch === '+') {
- if (ch === '-') sign = -1;
- value = value.slice(1);
- ch = value[0];
- }
+ Object.defineProperty(XMLNodeList.prototype, 'length', {
+ get: function() {
+ return this.nodes.length || 0;
+ }
+ });
- if (value === '0') return 0;
+ XMLNodeList.prototype.clone = function() {
+ return this.nodes = null;
+ };
- if (ch === '0') {
- if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
- if (value[1] === 'x') return sign * parseInt(value, 16);
- return sign * parseInt(value, 8);
- }
+ XMLNodeList.prototype.item = function(index) {
+ return this.nodes[index] || null;
+ };
- if (value.indexOf(':') !== -1) {
- value.split(':').forEach(function (v) {
- digits.unshift(parseInt(v, 10));
- });
+ return XMLNodeList;
- value = 0;
- base = 1;
+ })();
- digits.forEach(function (d) {
- value += (d * base);
- base *= 60;
- });
+}).call(this);
- return sign * value;
- }
+/***/ }),
- return sign * parseInt(value, 10);
-}
+/***/ 56939:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-function isInteger(object) {
- return (Object.prototype.toString.call(object)) === '[object Number]' &&
- (object % 1 === 0 && !common.isNegativeZero(object));
-}
+// 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;
-module.exports = new Type('tag:yaml.org,2002:int', {
- kind: 'scalar',
- resolve: resolveYamlInteger,
- construct: constructYamlInteger,
- predicate: isInteger,
- represent: {
- binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
- octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
- decimal: function (obj) { return obj.toString(10); },
- /* eslint-disable max-len */
- hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
- },
- defaultStyle: 'decimal',
- styleAliases: {
- binary: [ 2, 'bin' ],
- octal: [ 8, 'oct' ],
- decimal: [ 10, 'dec' ],
- hexadecimal: [ 16, 'hex' ]
- }
-});
+ NodeType = __nccwpck_require__(29267);
+ XMLCharacterData = __nccwpck_require__(87709);
-/***/ }),
+ module.exports = XMLProcessingInstruction = (function(superClass) {
+ extend(XMLProcessingInstruction, superClass);
-/***/ 35361:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ 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);
+ }
+ }
-"use strict";
+ XMLProcessingInstruction.prototype.clone = function() {
+ return Object.create(this);
+ };
+ XMLProcessingInstruction.prototype.toString = function(options) {
+ return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
+ };
-var esprima;
+ 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;
+ };
-// Browserified version does not have esprima
-//
-// 1. For node.js just require module as deps
-// 2. For browser try to require mudule via external AMD system.
-// If not found - try to fallback to window.esprima. If not
-// found too - then fail to parse.
-//
-try {
- // workaround to exclude package from browserify list.
- var _require = require;
- esprima = _require('esprima');
-} catch (_) {
- /* eslint-disable no-redeclare */
- /* global window */
- if (typeof window !== 'undefined') esprima = window.esprima;
-}
+ return XMLProcessingInstruction;
-var Type = __nccwpck_require__(90256);
+ })(XMLCharacterData);
-function resolveJavascriptFunction(data) {
- if (data === null) return false;
+}).call(this);
- try {
- var source = '(' + data + ')',
- ast = esprima.parse(source, { range: true });
- if (ast.type !== 'Program' ||
- ast.body.length !== 1 ||
- ast.body[0].type !== 'ExpressionStatement' ||
- (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
- ast.body[0].expression.type !== 'FunctionExpression')) {
- return false;
- }
+/***/ }),
- return true;
- } catch (err) {
- return false;
- }
-}
+/***/ 16329:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-function constructJavascriptFunction(data) {
- /*jslint evil:true*/
+// 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;
- var source = '(' + data + ')',
- ast = esprima.parse(source, { range: true }),
- params = [],
- body;
+ NodeType = __nccwpck_require__(29267);
- if (ast.type !== 'Program' ||
- ast.body.length !== 1 ||
- ast.body[0].type !== 'ExpressionStatement' ||
- (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
- ast.body[0].expression.type !== 'FunctionExpression')) {
- throw new Error('Failed to resolve function');
- }
+ XMLNode = __nccwpck_require__(67608);
- ast.body[0].expression.params.forEach(function (param) {
- params.push(param.name);
- });
+ module.exports = XMLRaw = (function(superClass) {
+ extend(XMLRaw, superClass);
- body = ast.body[0].expression.body.range;
+ 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);
+ }
- // Esprima's ranges include the first '{' and the last '}' characters on
- // function expressions. So cut them out.
- if (ast.body[0].expression.body.type === 'BlockStatement') {
- /*eslint-disable no-new-func*/
- return new Function(params, source.slice(body[0] + 1, body[1] - 1));
- }
- // ES6 arrow functions can omit the BlockStatement. In that case, just return
- // the body.
- /*eslint-disable no-new-func*/
- return new Function(params, 'return ' + source.slice(body[0], body[1]));
-}
+ XMLRaw.prototype.clone = function() {
+ return Object.create(this);
+ };
-function representJavascriptFunction(object /*, style*/) {
- return object.toString();
-}
+ XMLRaw.prototype.toString = function(options) {
+ return this.options.writer.raw(this, this.options.writer.filterOptions(options));
+ };
-function isFunction(object) {
- return Object.prototype.toString.call(object) === '[object Function]';
-}
+ return XMLRaw;
-module.exports = new Type('tag:yaml.org,2002:js/function', {
- kind: 'scalar',
- resolve: resolveJavascriptFunction,
- construct: constructJavascriptFunction,
- predicate: isFunction,
- represent: representJavascriptFunction
-});
+ })(XMLNode);
+
+}).call(this);
/***/ }),
-/***/ 77234:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+/***/ 78601:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-"use strict";
+// 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__(29267);
-var Type = __nccwpck_require__(90256);
+ XMLWriterBase = __nccwpck_require__(66752);
-function resolveJavascriptRegExp(data) {
- if (data === null) return false;
- if (data.length === 0) return false;
+ WriterState = __nccwpck_require__(9766);
- var regexp = data,
- tail = /\/([gim]*)$/.exec(data),
- modifiers = '';
+ module.exports = XMLStreamWriter = (function(superClass) {
+ extend(XMLStreamWriter, superClass);
- // if regexp starts with '/' it can have modifiers and must be properly closed
- // `/foo/gim` - modifiers tail can be maximum 3 chars
- if (regexp[0] === '/') {
- if (tail) modifiers = tail[1];
+ function XMLStreamWriter(stream, options) {
+ this.stream = stream;
+ XMLStreamWriter.__super__.constructor.call(this, options);
+ }
- if (modifiers.length > 3) return false;
- // if expression starts with /, is should be properly terminated
- if (regexp[regexp.length - modifiers.length - 1] !== '/') 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;
-}
+ 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;
+ };
-function constructJavascriptRegExp(data) {
- var regexp = data,
- tail = /\/([gim]*)$/.exec(data),
- modifiers = '';
+ XMLStreamWriter.prototype.attribute = function(att, options, level) {
+ return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level));
+ };
- // `/foo/gim` - tail can be maximum 4 chars
- if (regexp[0] === '/') {
- if (tail) modifiers = tail[1];
- regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
- }
+ XMLStreamWriter.prototype.cdata = function(node, options, level) {
+ return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level));
+ };
- return new RegExp(regexp, modifiers);
-}
+ XMLStreamWriter.prototype.comment = function(node, options, level) {
+ return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level));
+ };
-function representJavascriptRegExp(object /*, style*/) {
- var result = '/' + object.source + '/';
+ XMLStreamWriter.prototype.declaration = function(node, options, level) {
+ return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level));
+ };
- if (object.global) result += 'g';
- if (object.multiline) result += 'm';
- if (object.ignoreCase) result += 'i';
+ 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);
+ };
- return result;
-}
+ 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('' + node.name + '>');
+ } else {
+ options.state = WriterState.CloseTag;
+ this.stream.write(options.spaceBeforeSlash + '/>');
+ }
+ } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
+ this.stream.write('>');
+ options.state = WriterState.InsideTag;
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ this.writeChildNode(firstChildNode, options, level + 1);
+ options.suppressPrettyCount--;
+ prettySuppressed = false;
+ options.state = WriterState.CloseTag;
+ this.stream.write('' + node.name + '>');
+ } else {
+ this.stream.write('>' + this.endline(node, options, level));
+ options.state = WriterState.InsideTag;
+ ref1 = node.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ this.writeChildNode(child, options, level + 1);
+ }
+ options.state = WriterState.CloseTag;
+ this.stream.write(this.indent(node, options, level) + '' + node.name + '>');
+ }
+ this.stream.write(this.endline(node, options, level));
+ options.state = WriterState.None;
+ return this.closeNode(node, options, level);
+ };
-function isRegExp(object) {
- return Object.prototype.toString.call(object) === '[object RegExp]';
-}
+ XMLStreamWriter.prototype.processingInstruction = function(node, options, level) {
+ return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level));
+ };
-module.exports = new Type('tag:yaml.org,2002:js/regexp', {
- kind: 'scalar',
- resolve: resolveJavascriptRegExp,
- construct: constructJavascriptRegExp,
- predicate: isRegExp,
- represent: representJavascriptRegExp
-});
+ 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));
+ };
-/***/ 34801:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLStreamWriter.prototype.dtdElement = function(node, options, level) {
+ return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level));
+ };
-"use strict";
+ 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;
-var Type = __nccwpck_require__(90256);
+ })(XMLWriterBase);
-function resolveJavascriptUndefined() {
- return true;
-}
+}).call(this);
-function constructJavascriptUndefined() {
- /*eslint-disable no-undefined*/
- return undefined;
-}
-function representJavascriptUndefined() {
- return '';
-}
+/***/ }),
-function isUndefined(object) {
- return typeof object === 'undefined';
-}
+/***/ 85913:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-module.exports = new Type('tag:yaml.org,2002:js/undefined', {
- kind: 'scalar',
- resolve: resolveJavascriptUndefined,
- construct: constructJavascriptUndefined,
- predicate: isUndefined,
- represent: representJavascriptUndefined
-});
+// 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__(66752);
-/***/ }),
+ module.exports = XMLStringWriter = (function(superClass) {
+ extend(XMLStringWriter, superClass);
-/***/ 15938:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ function XMLStringWriter(options) {
+ XMLStringWriter.__super__.constructor.call(this, options);
+ }
-"use strict";
+ 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;
-var Type = __nccwpck_require__(90256);
+ })(XMLWriterBase);
-module.exports = new Type('tag:yaml.org,2002:map', {
- kind: 'mapping',
- construct: function (data) { return data !== null ? data : {}; }
-});
+}).call(this);
/***/ }),
-/***/ 60194:
-/***/ ((module, __unused_webpack_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;
+ 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 Type = __nccwpck_require__(90256);
+ XMLStringifier.prototype.name = function(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalName('' + val || '');
+ };
-function resolveYamlMerge(data) {
- return data === '<<' || data === null;
-}
+ XMLStringifier.prototype.text = function(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar(this.textEscape('' + val || ''));
+ };
-module.exports = new Type('tag:yaml.org,2002:merge', {
- kind: 'scalar',
- resolve: resolveYamlMerge
-});
+ 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 || '';
+ };
-/***/ 26058:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLStringifier.prototype.attValue = function(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar(this.attEscape(val = '' + val || ''));
+ };
-"use strict";
+ 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);
+ };
-var Type = __nccwpck_require__(90256);
+ 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;
+ };
-function resolveYamlNull(data) {
- if (data === null) return true;
+ 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 max = data.length;
+ XMLStringifier.prototype.xmlStandalone = function(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ if (val) {
+ return "yes";
+ } else {
+ return "no";
+ }
+ };
- return (max === 1 && data === '~') ||
- (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
-}
+ XMLStringifier.prototype.dtdPubID = function(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ };
-function constructYamlNull() {
- return null;
-}
+ XMLStringifier.prototype.dtdSysID = function(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ };
-function isNull(object) {
- return object === null;
-}
+ XMLStringifier.prototype.dtdElementValue = function(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ };
-module.exports = new Type('tag:yaml.org,2002:null', {
- kind: 'scalar',
- resolve: resolveYamlNull,
- construct: constructYamlNull,
- predicate: isNull,
- represent: {
- canonical: function () { return '~'; },
- lowercase: function () { return 'null'; },
- uppercase: function () { return 'NULL'; },
- camelcase: function () { return 'Null'; }
- },
- defaultStyle: 'lowercase'
-});
+ 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 || '');
+ };
+
+ 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';
-/***/ 96439:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLStringifier.prototype.convertCDataKey = '#cdata';
-"use strict";
+ XMLStringifier.prototype.convertCommentKey = '#comment';
+ XMLStringifier.prototype.convertRawKey = '#raw';
-var Type = __nccwpck_require__(90256);
+ 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);
+ }
+ } 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;
+ };
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
-var _toString = Object.prototype.toString;
+ 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;
+ };
-function resolveYamlOmap(data) {
- if (data === null) return true;
+ 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, '
');
+ };
- var objectKeys = [], index, length, pair, pairKey, pairHasKey,
- object = data;
+ 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(/ {
+ 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);
+ }
-"use strict";
+ 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);
+ };
-var Type = __nccwpck_require__(90256);
+ XMLText.prototype.toString = function(options) {
+ return this.options.writer.text(this, this.options.writer.filterOptions(options));
+ };
-var _toString = Object.prototype.toString;
+ XMLText.prototype.splitText = function(offset) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
-function resolveYamlPairs(data) {
- if (data === null) return true;
+ XMLText.prototype.replaceWholeText = function(content) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ };
- var index, length, pair, keys, result,
- object = data;
+ return XMLText;
- result = new Array(object.length);
+ })(XMLCharacterData);
- for (index = 0, length = object.length; index < length; index += 1) {
- pair = object[index];
+}).call(this);
- if (_toString.call(pair) !== '[object Object]') return false;
- keys = Object.keys(pair);
+/***/ }),
- if (keys.length !== 1) return false;
+/***/ 66752:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
- result[index] = [ keys[0], pair[keys[0]] ];
- }
+// 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;
- return true;
-}
+ assign = (__nccwpck_require__(58229).assign);
-function constructYamlPairs(data) {
- if (data === null) return [];
+ NodeType = __nccwpck_require__(29267);
- var index, length, pair, keys, result,
- object = data;
+ XMLDeclaration = __nccwpck_require__(46364);
- result = new Array(object.length);
+ XMLDocType = __nccwpck_require__(81801);
- for (index = 0, length = object.length; index < length; index += 1) {
- pair = object[index];
+ XMLCData = __nccwpck_require__(90333);
- keys = Object.keys(pair);
+ XMLComment = __nccwpck_require__(74407);
- result[index] = [ keys[0], pair[keys[0]] ];
- }
+ XMLElement = __nccwpck_require__(9437);
- return result;
-}
+ XMLRaw = __nccwpck_require__(16329);
-module.exports = new Type('tag:yaml.org,2002:pairs', {
- kind: 'sequence',
- resolve: resolveYamlPairs,
- construct: constructYamlPairs
-});
+ XMLText = __nccwpck_require__(21318);
+ XMLProcessingInstruction = __nccwpck_require__(56939);
-/***/ }),
+ XMLDummy = __nccwpck_require__(43590);
-/***/ 65629:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ XMLDTDAttList = __nccwpck_require__(81015);
-"use strict";
+ XMLDTDElement = __nccwpck_require__(52421);
+ XMLDTDEntity = __nccwpck_require__(40053);
-var Type = __nccwpck_require__(90256);
+ XMLDTDNotation = __nccwpck_require__(82837);
-module.exports = new Type('tag:yaml.org,2002:seq', {
- kind: 'sequence',
- construct: function (data) { return data !== null ? data : []; }
-});
+ 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;
+ };
-/***/ 9047:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ 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 '';
+ };
-"use strict";
+ XMLWriterBase.prototype.endline = function(node, options, level) {
+ if (!options.pretty || options.suppressPrettyCount) {
+ return '';
+ } else {
+ return options.newline;
+ }
+ };
+ 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;
+ };
-var Type = __nccwpck_require__(90256);
+ 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;
+ };
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
+ 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 resolveYamlSet(data) {
- if (data === null) return true;
+ 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 key, object = data;
+ 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;
+ };
- for (key in object) {
- if (_hasOwnProperty.call(object, key)) {
- if (object[key] !== null) return false;
- }
- }
+ 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 += '' + node.name + '>' + this.endline(node, options, level);
+ } else {
+ options.state = WriterState.CloseTag;
+ r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
+ }
+ } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
+ r += '>';
+ options.state = WriterState.InsideTag;
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ r += this.writeChildNode(firstChildNode, options, level + 1);
+ options.suppressPrettyCount--;
+ prettySuppressed = false;
+ options.state = WriterState.CloseTag;
+ r += '' + node.name + '>' + this.endline(node, options, level);
+ } else {
+ if (options.dontPrettyTextNodes) {
+ ref1 = node.children;
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) {
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ break;
+ }
+ }
+ }
+ r += '>' + this.endline(node, options, level);
+ options.state = WriterState.InsideTag;
+ ref2 = node.children;
+ for (j = 0, len1 = ref2.length; j < len1; j++) {
+ child = ref2[j];
+ r += this.writeChildNode(child, options, level + 1);
+ }
+ options.state = WriterState.CloseTag;
+ r += this.indent(node, options, level) + '' + node.name + '>';
+ if (prettySuppressed) {
+ options.suppressPrettyCount--;
+ }
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ }
+ this.closeNode(node, options, level);
+ return r;
+ };
- return true;
-}
+ 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);
+ }
+ };
-function constructYamlSet(data) {
- return data !== null ? data : {};
-}
+ XMLWriterBase.prototype.processingInstruction = function(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '';
+ options.state = WriterState.InsideTag;
+ r += node.target;
+ if (node.value) {
+ r += ' ' + node.value;
+ }
+ options.state = WriterState.CloseTag;
+ r += options.spaceBeforeSlash + '?>';
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ };
-module.exports = new Type('tag:yaml.org,2002:set', {
- kind: 'mapping',
- resolve: resolveYamlSet,
- construct: constructYamlSet
-});
+ 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;
+ };
-/***/ }),
+ 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;
+ };
-/***/ 24649:
-/***/ ((module, __unused_webpack_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;
+ };
+ 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;
+ };
-var Type = __nccwpck_require__(90256);
+ XMLWriterBase.prototype.openNode = function(node, options, level) {};
-module.exports = new Type('tag:yaml.org,2002:str', {
- kind: 'scalar',
- construct: function (data) { return data !== null ? data : ''; }
-});
+ XMLWriterBase.prototype.closeNode = function(node, options, level) {};
+ XMLWriterBase.prototype.openAttribute = function(att, options, level) {};
-/***/ }),
+ XMLWriterBase.prototype.closeAttribute = function(att, options, level) {};
-/***/ 82018:
-/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
+ return XMLWriterBase;
-"use strict";
+ })();
+}).call(this);
-var Type = __nccwpck_require__(90256);
-var YAML_DATE_REGEXP = new RegExp(
- '^([0-9][0-9][0-9][0-9])' + // [1] year
- '-([0-9][0-9])' + // [2] month
- '-([0-9][0-9])$'); // [3] day
+/***/ }),
-var YAML_TIMESTAMP_REGEXP = new RegExp(
- '^([0-9][0-9][0-9][0-9])' + // [1] year
- '-([0-9][0-9]?)' + // [2] month
- '-([0-9][0-9]?)' + // [3] day
- '(?:[Tt]|[ \\t]+)' + // ...
- '([0-9][0-9]?)' + // [4] hour
- ':([0-9][0-9])' + // [5] minute
- ':([0-9][0-9])' + // [6] second
- '(?:\\.([0-9]*))?' + // [7] fraction
- '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
- '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
+/***/ 52958:
+/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
-function resolveYamlTimestamp(data) {
- if (data === null) return false;
- if (YAML_DATE_REGEXP.exec(data) !== null) return true;
- if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
- return false;
-}
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
-function constructYamlTimestamp(data) {
- var match, year, month, day, hour, minute, second, fraction = 0,
- delta = null, tz_hour, tz_minute, date;
+ ref = __nccwpck_require__(58229), assign = ref.assign, isFunction = ref.isFunction;
- match = YAML_DATE_REGEXP.exec(data);
- if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
+ XMLDOMImplementation = __nccwpck_require__(78310);
- if (match === null) throw new Error('Date resolve error');
+ XMLDocument = __nccwpck_require__(53730);
- // match: [1] year [2] month [3] day
+ XMLDocumentCB = __nccwpck_require__(77356);
- year = +(match[1]);
- month = +(match[2]) - 1; // JS month starts with 0
- day = +(match[3]);
+ XMLStringWriter = __nccwpck_require__(85913);
- if (!match[4]) { // no hour
- return new Date(Date.UTC(year, month, day));
- }
+ XMLStreamWriter = __nccwpck_require__(78601);
- // match: [4] hour [5] minute [6] second [7] fraction
+ NodeType = __nccwpck_require__(29267);
- hour = +(match[4]);
- minute = +(match[5]);
- second = +(match[6]);
+ WriterState = __nccwpck_require__(9766);
- if (match[7]) {
- fraction = match[7].slice(0, 3);
- while (fraction.length < 3) { // milli-seconds
- fraction += '0';
+ module.exports.create = function(name, xmldec, doctype, options) {
+ var doc, root;
+ if (name == null) {
+ throw new Error("Root element needs a name.");
}
- fraction = +fraction;
- }
+ 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;
+ };
- // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
+ 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);
+ }
+ };
- if (match[9]) {
- tz_hour = +(match[10]);
- tz_minute = +(match[11] || 0);
- delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
- if (match[9] === '-') delta = -delta;
- }
+ module.exports.stringWriter = function(options) {
+ return new XMLStringWriter(options);
+ };
- date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
+ module.exports.streamWriter = function(stream, options) {
+ return new XMLStreamWriter(stream, options);
+ };
- if (delta) date.setTime(date.getTime() - delta);
+ module.exports.implementation = new XMLDOMImplementation();
- return date;
-}
+ module.exports.nodeType = NodeType;
-function representYamlTimestamp(object /*, style*/) {
- return object.toISOString();
-}
+ module.exports.writerState = WriterState;
-module.exports = new Type('tag:yaml.org,2002:timestamp', {
- kind: 'scalar',
- resolve: resolveYamlTimestamp,
- construct: constructYamlTimestamp,
- instanceOf: Date,
- represent: representYamlTimestamp
-});
+}).call(this);
/***/ }),
@@ -128208,20 +128208,21 @@ const gpg = __importStar(__nccwpck_require__(23759));
const util_1 = __nccwpck_require__(92629);
function configureAuthentication() {
return __awaiter(this, void 0, void 0, function* () {
- const id = core.getInput(constants.INPUT_SERVER_ID);
- const username = core.getInput(constants.INPUT_SERVER_USERNAME);
- const password = core.getInput(constants.INPUT_SERVER_PASSWORD);
+ const numMvnRepos = core.getInput(constants.INPUT_NUM_MVN_REPOS);
+ const mvnSettings = [];
const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) ||
path.join(os.homedir(), constants.M2_DIR);
const overwriteSettings = (0, util_1.getBooleanInput)(constants.INPUT_OVERWRITE_SETTINGS, true);
- const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) ||
- constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
- const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE) ||
- (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
- if (gpgPrivateKey) {
- core.setSecret(gpgPrivateKey);
+ let gpgPrivateKey;
+ if (numMvnRepos === '' || core.getInput(constants.INPUT_GPG_PRIVATE_KEY)) {
+ gpgPrivateKey = populateMvnSettings(mvnSettings);
}
- yield createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase);
+ else {
+ for (let i = 0; i < parseInt(numMvnRepos); i++) {
+ populateMvnSettings(mvnSettings, i);
+ }
+ }
+ yield createAuthenticationSettings(mvnSettings, settingsDirectory, overwriteSettings);
if (gpgPrivateKey) {
core.info('Importing private gpg key');
const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || '';
@@ -128230,41 +128231,67 @@ function configureAuthentication() {
});
}
exports.configureAuthentication = configureAuthentication;
-function createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase = undefined) {
+function populateMvnSettings(mvnSettings, idx = -1) {
+ const id = core.getInput(getIndexedInputName(constants.INPUT_SERVER_ID, idx));
+ const username = core.getInput(getIndexedInputName(constants.INPUT_SERVER_USERNAME, idx));
+ const password = core.getInput(getIndexedInputName(constants.INPUT_SERVER_PASSWORD, idx));
+ if (username !== '' && password !== '') {
+ mvnSettings.push({ id: id, username: username, password: password });
+ }
+ if (idx === -1) {
+ const gpgPrivateKey = core.getInput(getIndexedInputName(constants.INPUT_GPG_PRIVATE_KEY, idx)) || constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
+ const gpgPassphrase = core.getInput(getIndexedInputName(constants.INPUT_GPG_PASSPHRASE, idx)) ||
+ (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
+ if (gpgPrivateKey) {
+ core.setSecret(gpgPrivateKey);
+ }
+ if (gpgPassphrase) {
+ mvnSettings.push({ id: 'gpg.passphrase', gpgPassphrase: gpgPassphrase });
+ return gpgPrivateKey;
+ }
+ }
+ return undefined;
+}
+function getIndexedInputName(inputName, idx) {
+ return inputName + (idx >= 0 ? '-' + idx : '');
+}
+function createAuthenticationSettings(mvnSettings, settingsDirectory, overwriteSettings) {
return __awaiter(this, void 0, void 0, function* () {
- core.info(`Creating ${constants.MVN_SETTINGS_FILE} with server-id: ${id}`);
+ core.info(`Creating ${constants.MVN_SETTINGS_FILE}`);
// when an alternate m2 location is specified use only that location (no .m2 directory)
// otherwise use the home/.m2/ path
yield io.mkdirP(settingsDirectory);
- yield write(settingsDirectory, generate(id, username, password, gpgPassphrase), overwriteSettings);
+ yield write(settingsDirectory, generate(mvnSettings), overwriteSettings);
});
}
exports.createAuthenticationSettings = createAuthenticationSettings;
// only exported for testing purposes
-function generate(id, username, password, gpgPassphrase) {
+function generate(mvnSettings) {
const xmlObj = {
settings: {
'@xmlns': 'http://maven.apache.org/SETTINGS/1.0.0',
'@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'@xsi:schemaLocation': 'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd',
servers: {
- server: [
- {
- id: id,
- username: `\${env.${username}}`,
- password: `\${env.${password}}`
- }
- ]
+ server: []
}
}
};
- if (gpgPassphrase) {
- const gpgServer = {
- id: 'gpg.passphrase',
- passphrase: `\${env.${gpgPassphrase}}`
- };
- xmlObj.settings.servers.server.push(gpgServer);
- }
+ mvnSettings.forEach(mvnSetting => {
+ if (mvnSetting.username && mvnSetting.password) {
+ xmlObj.settings.servers.server.push({
+ id: mvnSetting.id,
+ username: `\${env.${mvnSetting.username}}`,
+ password: `\${env.${mvnSetting.password}}`
+ });
+ }
+ if (mvnSetting.gpgPassphrase) {
+ xmlObj.settings.servers.server.push({
+ id: mvnSetting.id,
+ passphrase: `\${env.${mvnSetting.gpgPassphrase}}`
+ });
+ }
+ });
return (0, xmlbuilder2_1.create)(xmlObj).end({
headless: true,
prettyPrint: true,
@@ -128509,7 +128536,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
-exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
+exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_NUM_MVN_REPOS = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
exports.INPUT_JAVA_VERSION = 'java-version';
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
@@ -128518,6 +128545,7 @@ exports.INPUT_JAVA_PACKAGE = 'java-package';
exports.INPUT_DISTRIBUTION = 'distribution';
exports.INPUT_JDK_FILE = 'jdkFile';
exports.INPUT_CHECK_LATEST = 'check-latest';
+exports.INPUT_NUM_MVN_REPOS = 'mvn-repositories-len';
exports.INPUT_SERVER_ID = 'server-id';
exports.INPUT_SERVER_USERNAME = 'server-username';
exports.INPUT_SERVER_PASSWORD = 'server-password';
diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md
index 4ba80b033..52dc52aa2 100644
--- a/docs/advanced-usage.md
+++ b/docs/advanced-usage.md
@@ -411,6 +411,85 @@ The two `settings.xml` files created from the above example look like the follow
If you don't want to overwrite the `settings.xml` file, you can set `overwrite-settings: false`
+### Multiple repositories
+
+There might be instances where you will need to change the version to/from release/snapshot. That will require specifying two maven repositories - one for release versions, one for snapshot versions.
+
+#### Yaml example
+```yaml
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up JDK 11
+ uses: actions/setup-java@v4
+ with:
+ distribution: ''
+ java-version: '11'
+
+ - name: Build with Maven
+ run: mvn -B package --file pom.xml
+
+ - name: Publish to GitHub Packages Apache Maven
+ run: mvn deploy
+ env:
+ GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
+
+ - name: Set up Apache Maven Central
+ uses: actions/setup-java@v4
+ with: # running setup-java again overwrites the settings.xml
+ distribution: 'temurin'
+ java-version: '11'
+ mvn-repositories-len: 2
+ server-id-0: artifactory # Value of the distributionManagement/repository/id field of the pom.xml
+ server-username-0: ARTIFACTORY_USERNAME # env variable for username in deploy
+ server-password-0: ARTIFACTORY_TOKEN # env variable for token in deploy
+ server-id-1: snapshot-artifactory # Value of the distributionManagement/repository/id field of the pom.xml
+ server-username-1: SNAPSHOT_ARTIFACTORY_USERNAME # env variable for username in deploy
+ server-password-1: SNAPSHOT_ARTIFACTORY_TOKEN # env variable for token in deploy
+ gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
+ gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
+
+ - name: Publish to Apache Maven Central
+ run: mvn deploy
+ env:
+ ARTIFACTORY_USERNAME: maven_username123
+ ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_USERNAME }}
+ SNAPSHOT_ARTIFACTORY_USERNAME: snapshot_maven_username123
+ SNAPSHOT_ARTIFACTORY_TOKEN: ${{ secrets.SNAPSHOT_ARTIFACTORY_TOKEN }}
+ MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
+```
+
+Here `mvn-repositories-len` specifies how many artifactories we're configuring here. In this example, the value is 2. In this case, the action will look for `server-id-0`, `server-username-0`, `server-password-0`, `server-id-1`, `server-username-1` and `server-password-1`.
+Depending on the value of `mvn-repositories-len`, the number of entries that will be looked for will vary. But it is looking for 0 based indexing with the max value less than the value of `mvn-repositories-len`.
+
+`settings.xml` file created for the deployment to the Maven Artifactory
+```xml
+
+
+
+ artifactory
+ ${env.ARTIFACTORY_USERNAME}
+ ${env.ARTIFACTORY_TOKEN}
+
+
+ snapshot-artifactory
+ ${env.SNAPSHOT_ARTIFACTORY_USERNAME}
+ ${env.SNAPSHOT_ARTIFACTORY_TOKEN}
+
+
+ gpg.passphrase
+ ${env.MAVEN_GPG_PASSPHRASE}
+
+
+
+```
+
+
### Extra setup for pom.xml:
The Maven GPG Plugin configuration in the pom.xml file should contain the following structure to avoid possible issues like `Inappropriate ioctl for device` or `gpg: signing failed: No such file or directory`:
diff --git a/src/auth.ts b/src/auth.ts
index c8ea6291c..053efc002 100644
--- a/src/auth.ts
+++ b/src/auth.ts
@@ -9,11 +9,11 @@ import {create as xmlCreate} from 'xmlbuilder2';
import * as constants from './constants';
import * as gpg from './gpg';
import {getBooleanInput} from './util';
+import {MvnSettingDefinition} from './mvn.setting.definition';
export async function configureAuthentication() {
- const id = core.getInput(constants.INPUT_SERVER_ID);
- const username = core.getInput(constants.INPUT_SERVER_USERNAME);
- const password = core.getInput(constants.INPUT_SERVER_PASSWORD);
+ const numMvnRepos = core.getInput(constants.INPUT_NUM_MVN_REPOS);
+ const mvnSettings: Array = [];
const settingsDirectory =
core.getInput(constants.INPUT_SETTINGS_PATH) ||
path.join(os.homedir(), constants.M2_DIR);
@@ -21,24 +21,19 @@ export async function configureAuthentication() {
constants.INPUT_OVERWRITE_SETTINGS,
true
);
- const gpgPrivateKey =
- core.getInput(constants.INPUT_GPG_PRIVATE_KEY) ||
- constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
- const gpgPassphrase =
- core.getInput(constants.INPUT_GPG_PASSPHRASE) ||
- (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
-
- if (gpgPrivateKey) {
- core.setSecret(gpgPrivateKey);
+ let gpgPrivateKey;
+ if (numMvnRepos === '' || core.getInput(constants.INPUT_GPG_PRIVATE_KEY)) {
+ gpgPrivateKey = populateMvnSettings(mvnSettings);
+ } else {
+ for (let i = 0; i < parseInt(numMvnRepos); i++) {
+ populateMvnSettings(mvnSettings, i);
+ }
}
await createAuthenticationSettings(
- id,
- username,
- password,
+ mvnSettings,
settingsDirectory,
- overwriteSettings,
- gpgPassphrase
+ overwriteSettings
);
if (gpgPrivateKey) {
@@ -48,32 +43,61 @@ export async function configureAuthentication() {
}
}
+function populateMvnSettings(
+ mvnSettings: Array,
+ idx = -1
+): string | undefined {
+ const id = core.getInput(getIndexedInputName(constants.INPUT_SERVER_ID, idx));
+ const username = core.getInput(
+ getIndexedInputName(constants.INPUT_SERVER_USERNAME, idx)
+ );
+ const password = core.getInput(
+ getIndexedInputName(constants.INPUT_SERVER_PASSWORD, idx)
+ );
+ if (username !== '' && password !== '') {
+ mvnSettings.push({id: id, username: username, password: password});
+ }
+
+ if (idx === -1) {
+ const gpgPrivateKey =
+ core.getInput(
+ getIndexedInputName(constants.INPUT_GPG_PRIVATE_KEY, idx)
+ ) || constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
+ const gpgPassphrase =
+ core.getInput(getIndexedInputName(constants.INPUT_GPG_PASSPHRASE, idx)) ||
+ (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
+
+ if (gpgPrivateKey) {
+ core.setSecret(gpgPrivateKey);
+ }
+
+ if (gpgPassphrase) {
+ mvnSettings.push({id: 'gpg.passphrase', gpgPassphrase: gpgPassphrase});
+ return gpgPrivateKey;
+ }
+ }
+
+ return undefined;
+}
+
+function getIndexedInputName(inputName: string, idx: number): string {
+ return inputName + (idx >= 0 ? '-' + idx : '');
+}
+
export async function createAuthenticationSettings(
- id: string,
- username: string,
- password: string,
+ mvnSettings: Array,
settingsDirectory: string,
- overwriteSettings: boolean,
- gpgPassphrase: string | undefined = undefined
+ overwriteSettings: boolean
) {
- core.info(`Creating ${constants.MVN_SETTINGS_FILE} with server-id: ${id}`);
+ core.info(`Creating ${constants.MVN_SETTINGS_FILE}`);
// when an alternate m2 location is specified use only that location (no .m2 directory)
// otherwise use the home/.m2/ path
await io.mkdirP(settingsDirectory);
- await write(
- settingsDirectory,
- generate(id, username, password, gpgPassphrase),
- overwriteSettings
- );
+ await write(settingsDirectory, generate(mvnSettings), overwriteSettings);
}
// only exported for testing purposes
-export function generate(
- id: string,
- username: string,
- password: string,
- gpgPassphrase?: string | undefined
-) {
+export function generate(mvnSettings: Array) {
const xmlObj: {[key: string]: any} = {
settings: {
'@xmlns': 'http://maven.apache.org/SETTINGS/1.0.0',
@@ -81,24 +105,27 @@ export function generate(
'@xsi:schemaLocation':
'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd',
servers: {
- server: [
- {
- id: id,
- username: `\${env.${username}}`,
- password: `\${env.${password}}`
- }
- ]
+ server: []
}
}
};
- if (gpgPassphrase) {
- const gpgServer = {
- id: 'gpg.passphrase',
- passphrase: `\${env.${gpgPassphrase}}`
- };
- xmlObj.settings.servers.server.push(gpgServer);
- }
+ mvnSettings.forEach(mvnSetting => {
+ if (mvnSetting.username && mvnSetting.password) {
+ xmlObj.settings.servers.server.push({
+ id: mvnSetting.id,
+ username: `\${env.${mvnSetting.username}}`,
+ password: `\${env.${mvnSetting.password}}`
+ });
+ }
+
+ if (mvnSetting.gpgPassphrase) {
+ xmlObj.settings.servers.server.push({
+ id: mvnSetting.id,
+ passphrase: `\${env.${mvnSetting.gpgPassphrase}}`
+ });
+ }
+ });
return xmlCreate(xmlObj).end({
headless: true,
diff --git a/src/constants.ts b/src/constants.ts
index 93af286f8..be326f965 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -6,6 +6,7 @@ export const INPUT_JAVA_PACKAGE = 'java-package';
export const INPUT_DISTRIBUTION = 'distribution';
export const INPUT_JDK_FILE = 'jdkFile';
export const INPUT_CHECK_LATEST = 'check-latest';
+export const INPUT_NUM_MVN_REPOS = 'mvn-repositories-len';
export const INPUT_SERVER_ID = 'server-id';
export const INPUT_SERVER_USERNAME = 'server-username';
export const INPUT_SERVER_PASSWORD = 'server-password';
diff --git a/src/mvn.setting.definition.ts b/src/mvn.setting.definition.ts
new file mode 100644
index 000000000..3e2c41de9
--- /dev/null
+++ b/src/mvn.setting.definition.ts
@@ -0,0 +1,6 @@
+export interface MvnSettingDefinition {
+ id: string;
+ username?: string;
+ password?: string;
+ gpgPassphrase?: string;
+}