UNPKG

opennms

Version:

Client API for the OpenNMS network monitoring platform

1,481 lines (1,419 loc) 3.22 MB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(global, () => { return /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./node_modules/@xmldom/xmldom/lib/conventions.js": /***/ ((__unused_webpack_module, exports) => { "use strict"; /** * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes. * * Works with anything that has a `length` property and index access properties, * including NodeList. * * @param {T[] | { length: number; [number]: T }} list * @param {function (item: T, index: number, list:T[]):boolean} predicate * @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac * Allows injecting a custom implementation in tests (`Array.prototype` by default). * @returns {T | undefined} * @template {unknown} T * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find */ function find(list, predicate, ac) { if (ac === undefined) { ac = Array.prototype; } if (list && typeof ac.find === 'function') { return ac.find.call(list, predicate); } for (var i = 0; i < list.length; i++) { if (hasOwn(list, i)) { var item = list[i]; if (predicate.call(undefined, item, i, list)) { return item; } } } } /** * "Shallow freezes" an object to render it immutable. * Uses `Object.freeze` if available, * otherwise the immutability is only in the type. * * Is used to create "enum like" objects. * * If `Object.getOwnPropertyDescriptors` is available, * a new object with all properties of object but without any prototype is created and returned * after freezing it. * * @param {T} object * The object to freeze. * @param {Pick<ObjectConstructor, 'create' | 'freeze' | 'getOwnPropertyDescriptors'>} [oc=Object] * `Object` by default, * allows to inject custom object constructor for tests. * @returns {Readonly<T>} * @template {Object} T * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze * @prettierignore */ function freeze(object, oc) { if (oc === undefined) { oc = Object; } if (oc && typeof oc.getOwnPropertyDescriptors === 'function') { object = oc.create(null, oc.getOwnPropertyDescriptors(object)); } return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object; } /** * Implementation for `Object.hasOwn` but ES5 compatible. * * @param {any} object * @param {string | number} key * @returns {boolean} */ function hasOwn(object, key) { return Object.prototype.hasOwnProperty.call(object, key); } /** * Since xmldom can not rely on `Object.assign`, * it uses/provides a simplified version that is sufficient for its needs. * * @param {Object} target * @param {Object | null | undefined} source * @returns {Object} * The target with the merged/overridden properties. * @throws {TypeError} * If target is not an object. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign */ function assign(target, source) { if (target === null || typeof target !== 'object') { throw new TypeError('target is not an object'); } for (var key in source) { if (hasOwn(source, key)) { target[key] = source[key]; } } return target; } /** * A number of attributes are boolean attributes. * The presence of a boolean attribute on an element represents the `true` value, * and the absence of the attribute represents the `false` value. * * If the attribute is present, its value must either be the empty string, or a value that is * an ASCII case-insensitive match for the attribute's canonical name, * with no leading or trailing whitespace. * * Note: The values `"true"` and `"false"` are not allowed on boolean attributes. * To represent a `false` value, the attribute has to be omitted altogether. * * @see https://html.spec.whatwg.org/#boolean-attributes * @see https://html.spec.whatwg.org/#attributes-3 */ var HTML_BOOLEAN_ATTRIBUTES = freeze({ allowfullscreen: true, async: true, autofocus: true, autoplay: true, checked: true, controls: true, default: true, defer: true, disabled: true, formnovalidate: true, hidden: true, ismap: true, itemscope: true, loop: true, multiple: true, muted: true, nomodule: true, novalidate: true, open: true, playsinline: true, readonly: true, required: true, reversed: true, selected: true }); /** * Check if `name` is matching one of the HTML boolean attribute names. * This method doesn't check if such attributes are allowed in the context of the current * document/parsing. * * @param {string} name * @returns {boolean} * @see {@link HTML_BOOLEAN_ATTRIBUTES} * @see https://html.spec.whatwg.org/#boolean-attributes * @see https://html.spec.whatwg.org/#attributes-3 */ function isHTMLBooleanAttribute(name) { return hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase()); } /** * Void elements only have a start tag; end tags must not be specified for void elements. * These elements should be written as self-closing like this: `<area />`. * This should not be confused with optional tags that HTML allows to omit the end tag for * (like `li`, `tr` and others), which can have content after them, * so they can not be written as self-closing. * xmldom does not have any logic for optional end tags cases, * and will report them as a warning. * Content that would go into the unopened element, * will instead be added as a sibling text node. * * @type {Readonly<{ * area: boolean; * col: boolean; * img: boolean; * wbr: boolean; * link: boolean; * hr: boolean; * source: boolean; * br: boolean; * input: boolean; * param: boolean; * meta: boolean; * embed: boolean; * track: boolean; * base: boolean; * }>} * @see https://html.spec.whatwg.org/#void-elements * @see https://html.spec.whatwg.org/#optional-tags */ var HTML_VOID_ELEMENTS = freeze({ area: true, base: true, br: true, col: true, embed: true, hr: true, img: true, input: true, link: true, meta: true, param: true, source: true, track: true, wbr: true }); /** * Check if `tagName` is matching one of the HTML void element names. * This method doesn't check if such tags are allowed in the context of the current * document/parsing. * * @param {string} tagName * @returns {boolean} * @see {@link HTML_VOID_ELEMENTS} * @see https://html.spec.whatwg.org/#void-elements */ function isHTMLVoidElement(tagName) { return hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase()); } /** * Tag names that are raw text elements according to HTML spec. * The value denotes whether they are escapable or not. * * @see {@link isHTMLEscapableRawTextElement} * @see {@link isHTMLRawTextElement} * @see https://html.spec.whatwg.org/#raw-text-elements * @see https://html.spec.whatwg.org/#escapable-raw-text-elements */ var HTML_RAW_TEXT_ELEMENTS = freeze({ script: false, style: false, textarea: true, title: true }); /** * Check if `tagName` is matching one of the HTML raw text element names. * This method doesn't check if such tags are allowed in the context of the current * document/parsing. * * @param {string} tagName * @returns {boolean} * @see {@link isHTMLEscapableRawTextElement} * @see {@link HTML_RAW_TEXT_ELEMENTS} * @see https://html.spec.whatwg.org/#raw-text-elements * @see https://html.spec.whatwg.org/#escapable-raw-text-elements */ function isHTMLRawTextElement(tagName) { var key = tagName.toLowerCase(); return hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && !HTML_RAW_TEXT_ELEMENTS[key]; } /** * Check if `tagName` is matching one of the HTML escapable raw text element names. * This method doesn't check if such tags are allowed in the context of the current * document/parsing. * * @param {string} tagName * @returns {boolean} * @see {@link isHTMLRawTextElement} * @see {@link HTML_RAW_TEXT_ELEMENTS} * @see https://html.spec.whatwg.org/#raw-text-elements * @see https://html.spec.whatwg.org/#escapable-raw-text-elements */ function isHTMLEscapableRawTextElement(tagName) { var key = tagName.toLowerCase(); return hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && HTML_RAW_TEXT_ELEMENTS[key]; } /** * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document. * * @param {string} mimeType * @returns {mimeType is 'text/html'} * @see https://www.iana.org/assignments/media-types/text/html * @see https://en.wikipedia.org/wiki/HTML * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */ function isHTMLMimeType(mimeType) { return mimeType === MIME_TYPE.HTML; } /** * For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that the * HTML namespace is provided as the default. * * @param {string} mimeType * @returns {boolean} * @see https://dom.spec.whatwg.org/#dom-document-createelement * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument */ function hasDefaultHTMLNamespace(mimeType) { return isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION; } /** * All mime types that are allowed as input to `DOMParser.parseFromString` * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 * MDN * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype * WHATWG HTML Spec * @see {@link DOMParser.prototype.parseFromString} */ var MIME_TYPE = freeze({ /** * `text/html`, the only mime type that triggers treating an XML document as HTML. * * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration * @see https://en.wikipedia.org/wiki/HTML Wikipedia * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring * WHATWG HTML Spec */ HTML: 'text/html', /** * `application/xml`, the standard mime type for XML documents. * * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType * registration * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303 * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia */ XML_APPLICATION: 'application/xml', /** * `text/html`, an alias for `application/xml`. * * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303 * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia */ XML_TEXT: 'text/xml', /** * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace, * but is parsed as an XML document. * * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType * registration * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec * @see https://en.wikipedia.org/wiki/XHTML Wikipedia */ XML_XHTML_APPLICATION: 'application/xhtml+xml', /** * `image/svg+xml`, * * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1 * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia */ XML_SVG_IMAGE: 'image/svg+xml' }); /** * @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'} * MimeType */ /** * @type {MimeType[]} * @private * Basically `Object.values`, which is not available in ES5. */ var _MIME_TYPES = Object.keys(MIME_TYPE).map(function (key) { return MIME_TYPE[key]; }); /** * Only returns true if `mimeType` is one of the allowed values for * `DOMParser.parseFromString`. * * @param {string} mimeType * @returns {mimeType is 'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'} * */ function isValidMimeType(mimeType) { return _MIME_TYPES.indexOf(mimeType) > -1; } /** * Namespaces that are used in this code base. * * @see http://www.w3.org/TR/REC-xml-names */ var NAMESPACE = freeze({ /** * The XHTML namespace. * * @see http://www.w3.org/1999/xhtml */ HTML: 'http://www.w3.org/1999/xhtml', /** * The SVG namespace. * * @see http://www.w3.org/2000/svg */ SVG: 'http://www.w3.org/2000/svg', /** * The `xml:` namespace. * * @see http://www.w3.org/XML/1998/namespace */ XML: 'http://www.w3.org/XML/1998/namespace', /** * The `xmlns:` namespace. * * @see https://www.w3.org/2000/xmlns/ */ XMLNS: 'http://www.w3.org/2000/xmlns/' }); exports.assign = assign; exports.find = find; exports.freeze = freeze; exports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES; exports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS; exports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS; exports.hasDefaultHTMLNamespace = hasDefaultHTMLNamespace; exports.hasOwn = hasOwn; exports.isHTMLBooleanAttribute = isHTMLBooleanAttribute; exports.isHTMLRawTextElement = isHTMLRawTextElement; exports.isHTMLEscapableRawTextElement = isHTMLEscapableRawTextElement; exports.isHTMLMimeType = isHTMLMimeType; exports.isHTMLVoidElement = isHTMLVoidElement; exports.isValidMimeType = isValidMimeType; exports.MIME_TYPE = MIME_TYPE; exports.NAMESPACE = NAMESPACE; /***/ }), /***/ "./node_modules/@xmldom/xmldom/lib/dom-parser.js": /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; var conventions = __webpack_require__("./node_modules/@xmldom/xmldom/lib/conventions.js"); var dom = __webpack_require__("./node_modules/@xmldom/xmldom/lib/dom.js"); var errors = __webpack_require__("./node_modules/@xmldom/xmldom/lib/errors.js"); var entities = __webpack_require__("./node_modules/@xmldom/xmldom/lib/entities.js"); var sax = __webpack_require__("./node_modules/@xmldom/xmldom/lib/sax.js"); var DOMImplementation = dom.DOMImplementation; var hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace; var isHTMLMimeType = conventions.isHTMLMimeType; var isValidMimeType = conventions.isValidMimeType; var MIME_TYPE = conventions.MIME_TYPE; var NAMESPACE = conventions.NAMESPACE; var ParseError = errors.ParseError; var XMLReader = sax.XMLReader; /** * Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends>: * * > XML parsed entities are often stored in computer files which, * > for editing convenience, are organized into lines. * > These lines are typically separated by some combination * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA). * > * > To simplify the tasks of applications, the XML processor must behave * > as if it normalized all line breaks in external parsed entities (including the document entity) * > on input, before parsing, by translating all of the following to a single #xA character: * > * > 1. the two-character sequence #xD #xA, * > 2. the two-character sequence #xD #x85, * > 3. the single character #x85, * > 4. the single character #x2028, * > 5. any #xD character that is not immediately followed by #xA or #x85. * * @param {string} input * @returns {string} * @prettierignore */ function normalizeLineEndings(input) { return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028]/g, '\n'); } /** * @typedef Locator * @property {number} [columnNumber] * @property {number} [lineNumber] */ /** * @typedef DOMParserOptions * @property {typeof assign} [assign] * The method to use instead of `conventions.assign`, which is used to copy values from * `options` before they are used for parsing. * @property {typeof DOMHandler} [domHandler] * For internal testing: The class for creating an instance for handling events from the SAX * parser. * *****Warning: By configuring a faulty implementation, the specified behavior can completely * be broken.*****. * @property {Function} [errorHandler] * DEPRECATED! use `onError` instead. * @property {function(level:ErrorLevel, message:string, context: DOMHandler):void} * [onError] * A function that is invoked for every error that occurs during parsing. * * If it is not provided, all errors are reported to `console.error` * and only `fatalError`s are thrown as a `ParseError`, * which prevents any further processing. * If the provided method throws, a `ParserError` is thrown, * which prevents any further processing. * * Be aware that many `warning`s are considered an error that prevents further processing in * most implementations. * @property {boolean} [locator=true] * Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber` * attribute describing their location in the XML string. * Default is true. * @property {(string) => string} [normalizeLineEndings] * used to replace line endings before parsing, defaults to `normalizeLineEndings` * @property {Object} [xmlns] * The XML namespaces that should be assumed when parsing. * The default namespace can be provided by the key that is the empty string. * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`, * the default namespace that will be used, * will be overridden according to the specification. * @see {@link normalizeLineEndings} */ /** * The DOMParser interface provides the ability to parse XML or HTML source code from a string * into a DOM `Document`. * * ***xmldom is different from the spec in that it allows an `options` parameter, * to control the behavior***. * * @class * @param {DOMParserOptions} [options] * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization */ function DOMParser(options) { options = options || { locator: true }; /** * The method to use instead of `conventions.assign`, which is used to copy values from * `options` * before they are used for parsing. * * @type {conventions.assign} * @private * @see {@link conventions.assign} * @readonly */ this.assign = options.assign || conventions.assign; /** * For internal testing: The class for creating an instance for handling events from the SAX * parser. * *****Warning: By configuring a faulty implementation, the specified behavior can completely * be broken*****. * * @type {typeof DOMHandler} * @private * @readonly */ this.domHandler = options.domHandler || DOMHandler; /** * A function that is invoked for every error that occurs during parsing. * * If it is not provided, all errors are reported to `console.error` * and only `fatalError`s are thrown as a `ParseError`, * which prevents any further processing. * If the provided method throws, a `ParserError` is thrown, * which prevents any further processing. * * Be aware that many `warning`s are considered an error that prevents further processing in * most implementations. * * @type {function(level:ErrorLevel, message:string, context: DOMHandler):void} * @see {@link onErrorStopParsing} * @see {@link onWarningStopParsing} */ this.onError = options.onError || options.errorHandler; if (options.errorHandler && typeof options.errorHandler !== 'function') { throw new TypeError('errorHandler object is no longer supported, switch to onError!'); } else if (options.errorHandler) { options.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this); } /** * used to replace line endings before parsing, defaults to `normalizeLineEndings` * * @type {(string) => string} * @readonly */ this.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings; /** * Configures if the nodes created during parsing will have a `lineNumber` and a * `columnNumber` * attribute describing their location in the XML string. * Default is true. * * @type {boolean} * @readonly */ this.locator = !!options.locator; /** * The default namespace can be provided by the key that is the empty string. * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`, * the default namespace that will be used, * will be overridden according to the specification. * * @type {Readonly<Object>} * @readonly */ this.xmlns = this.assign(Object.create(null), options.xmlns); } /** * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this` * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created, * otherwise an XML `Document` is created. * * __It behaves different from the description in the living standard__: * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior. * - Any unexpected input is reported to `onError` with either a `warning`, * `error` or `fatalError` level. * - Any `fatalError` throws a `ParseError` which prevents further processing. * - Any error thrown by `onError` is converted to a `ParseError` which prevents further * processing - If no `Document` was created during parsing it is reported as a `fatalError`. * *****Warning: By configuring a faulty DOMHandler implementation, * the specified behavior can completely be broken*****. * * @param {string} source * The XML mime type only allows string input! * @param {string} [mimeType='application/xml'] * the mimeType or contentType of the document to be created determines the `type` of document * created (XML or HTML) * @returns {Document} * The `Document` node. * @throws {ParseError} * for any `fatalError` or anything that is thrown by `onError` * @throws {TypeError} * for any invalid `mimeType` * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev */ DOMParser.prototype.parseFromString = function (source, mimeType) { if (!isValidMimeType(mimeType)) { throw new TypeError('DOMParser.parseFromString: the provided mimeType "' + mimeType + '" is not valid.'); } var defaultNSMap = this.assign(Object.create(null), this.xmlns); var entityMap = entities.XML_ENTITIES; var defaultNamespace = defaultNSMap[''] || null; if (hasDefaultHTMLNamespace(mimeType)) { entityMap = entities.HTML_ENTITIES; defaultNamespace = NAMESPACE.HTML; } else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) { defaultNamespace = NAMESPACE.SVG; } defaultNSMap[''] = defaultNamespace; defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML; var domBuilder = new this.domHandler({ mimeType: mimeType, defaultNamespace: defaultNamespace, onError: this.onError }); var locator = this.locator ? {} : undefined; if (this.locator) { domBuilder.setDocumentLocator(locator); } var sax = new XMLReader(); sax.errorHandler = domBuilder; sax.domBuilder = domBuilder; var isXml = !conventions.isHTMLMimeType(mimeType); if (isXml && typeof source !== 'string') { sax.errorHandler.fatalError('source is not a string'); } sax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap); if (!domBuilder.doc.documentElement) { sax.errorHandler.fatalError('missing root element'); } return domBuilder.doc; }; /** * @typedef DOMHandlerOptions * @property {string} [mimeType=MIME_TYPE.XML_APPLICATION] * @property {string | null} [defaultNamespace=null] */ /** * The class that is used to handle events from the SAX parser to create the related DOM * elements. * * Some methods are only implemented as an empty function, * since they are (at least currently) not relevant for xmldom. * * @class * @param {DOMHandlerOptions} [options] * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html */ function DOMHandler(options) { var opt = options || {}; /** * The mime type is used to determine if the DOM handler will create an XML or HTML document. * Only if it is set to `text/html` it will create an HTML document. * It defaults to MIME_TYPE.XML_APPLICATION. * * @type {string} * @see {@link MIME_TYPE} * @readonly */ this.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION; /** * The namespace to use to create an XML document. * For the following reasons this is required: * - The SAX API for `startDocument` doesn't offer any way to pass a namespace, * since at that point there is no way for the parser to know what the default namespace from * the document will be. * - When creating using `DOMImplementation.createDocument` it is required to pass a * namespace, * to determine the correct `Document.contentType`, which should match `this.mimeType`. * - When parsing an XML document with the `application/xhtml+xml` mimeType, * the HTML namespace needs to be the default namespace. * * @type {string | null} * @private * @readonly */ this.defaultNamespace = opt.defaultNamespace || null; /** * @type {boolean} * @private */ this.cdata = false; /** * The last `Element` that was created by `startElement`. * `endElement` sets it to the `currentElement.parentNode`. * * Note: The sax parser currently sets it to white space text nodes between tags. * * @type {Element | Node | undefined} * @private */ this.currentElement = undefined; /** * The Document that is created as part of `startDocument`, * and returned by `DOMParser.parseFromString`. * * @type {Document | undefined} * @readonly */ this.doc = undefined; /** * The locator is stored as part of setDocumentLocator. * It is controlled and mutated by the SAX parser to store the current parsing position. * It is used by DOMHandler to set `columnNumber` and `lineNumber` * on the DOM nodes. * * @type {Readonly<Locator> | undefined} * @private * @readonly (the * sax parser currently sometimes set's it) */ this.locator = undefined; /** * @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void} * @readonly */ this.onError = opt.onError; } function position(locator, node) { node.lineNumber = locator.lineNumber; node.columnNumber = locator.columnNumber; } DOMHandler.prototype = { /** * Either creates an XML or an HTML document and stores it under `this.doc`. * If it is an XML document, `this.defaultNamespace` is used to create it, * and it will not contain any `childNodes`. * If it is an HTML document, it will be created without any `childNodes`. * * @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html */ startDocument: function () { var impl = new DOMImplementation(); this.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, ''); }, startElement: function (namespaceURI, localName, qName, attrs) { var doc = this.doc; var el = doc.createElementNS(namespaceURI, qName || localName); var len = attrs.length; appendElement(this, el); this.currentElement = el; this.locator && position(this.locator, el); for (var i = 0; i < len; i++) { var namespaceURI = attrs.getURI(i); var value = attrs.getValue(i); var qName = attrs.getQName(i); var attr = doc.createAttributeNS(namespaceURI, qName); this.locator && position(attrs.getLocator(i), attr); attr.value = attr.nodeValue = value; el.setAttributeNode(attr); } }, endElement: function (namespaceURI, localName, qName) { this.currentElement = this.currentElement.parentNode; }, startPrefixMapping: function (prefix, uri) {}, endPrefixMapping: function (prefix) {}, processingInstruction: function (target, data) { var ins = this.doc.createProcessingInstruction(target, data); this.locator && position(this.locator, ins); appendElement(this, ins); }, ignorableWhitespace: function (ch, start, length) {}, characters: function (chars, start, length) { chars = _toString.apply(this, arguments); //console.log(chars) if (chars) { if (this.cdata) { var charNode = this.doc.createCDATASection(chars); } else { var charNode = this.doc.createTextNode(chars); } if (this.currentElement) { this.currentElement.appendChild(charNode); } else if (/^\s*$/.test(chars)) { this.doc.appendChild(charNode); //process xml } this.locator && position(this.locator, charNode); } }, skippedEntity: function (name) {}, endDocument: function () { this.doc.normalize(); }, /** * Stores the locator to be able to set the `columnNumber` and `lineNumber` * on the created DOM nodes. * * @param {Locator} locator */ setDocumentLocator: function (locator) { if (locator) { locator.lineNumber = 0; } this.locator = locator; }, //LexicalHandler comment: function (chars, start, length) { chars = _toString.apply(this, arguments); var comm = this.doc.createComment(chars); this.locator && position(this.locator, comm); appendElement(this, comm); }, startCDATA: function () { //used in characters() methods this.cdata = true; }, endCDATA: function () { this.cdata = false; }, startDTD: function (name, publicId, systemId, internalSubset) { var impl = this.doc.implementation; if (impl && impl.createDocumentType) { var dt = impl.createDocumentType(name, publicId, systemId, internalSubset); this.locator && position(this.locator, dt); appendElement(this, dt); this.doc.doctype = dt; } }, reportError: function (level, message) { if (typeof this.onError === 'function') { try { this.onError(level, message, this); } catch (e) { throw new ParseError('Reporting ' + level + ' "' + message + '" caused ' + e, this.locator); } } else { console.error('[xmldom ' + level + ']\t' + message, _locator(this.locator)); } }, /** * @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html */ warning: function (message) { this.reportError('warning', message); }, error: function (message) { this.reportError('error', message); }, /** * This function reports a fatal error and throws a ParseError. * * @param {string} message * - The message to be used for reporting and throwing the error. * @returns {never} * This function always throws an error and never returns a value. * @throws {ParseError} * Always throws a ParseError with the provided message. */ fatalError: function (message) { this.reportError('fatalError', message); throw new ParseError(message, this.locator); } }; function _locator(l) { if (l) { return '\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']'; } } function _toString(chars, start, length) { if (typeof chars == 'string') { return chars.substr(start, length); } else { //java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)") if (chars.length >= start + length || start) { return new java.lang.String(chars, start, length) + ''; } return chars; } } /* * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html * used method of org.xml.sax.ext.LexicalHandler: * #comment(chars, start, length) * #startCDATA() * #endCDATA() * #startDTD(name, publicId, systemId) * * * IGNORED method of org.xml.sax.ext.LexicalHandler: * #endDTD() * #startEntity(name) * #endEntity(name) * * * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html * IGNORED method of org.xml.sax.ext.DeclHandler * #attributeDecl(eName, aName, type, mode, value) * #elementDecl(name, model) * #externalEntityDecl(name, publicId, systemId) * #internalEntityDecl(name, value) * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html * IGNORED method of org.xml.sax.EntityResolver2 * #resolveEntity(String name,String publicId,String baseURI,String systemId) * #resolveEntity(publicId, systemId) * #getExternalSubset(name, baseURI) * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html * IGNORED method of org.xml.sax.DTDHandler * #notationDecl(name, publicId, systemId) {}; * #unparsedEntityDecl(name, publicId, systemId, notationName) {}; */ 'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(/\w+/g, function (key) { DOMHandler.prototype[key] = function () { return null; }; }); /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ function appendElement(handler, node) { if (!handler.currentElement) { handler.doc.appendChild(node); } else { handler.currentElement.appendChild(node); } } /** * A method that prevents any further parsing when an `error` * with level `error` is reported during parsing. * * @see {@link DOMParserOptions.onError} * @see {@link onWarningStopParsing} */ function onErrorStopParsing(level) { if (level === 'error') throw 'onErrorStopParsing'; } /** * A method that prevents any further parsing when any `error` is reported during parsing. * * @see {@link DOMParserOptions.onError} * @see {@link onErrorStopParsing} */ function onWarningStopParsing() { throw 'onWarningStopParsing'; } exports.__DOMHandler = DOMHandler; exports.DOMParser = DOMParser; exports.normalizeLineEndings = normalizeLineEndings; exports.onErrorStopParsing = onErrorStopParsing; exports.onWarningStopParsing = onWarningStopParsing; /***/ }), /***/ "./node_modules/@xmldom/xmldom/lib/dom.js": /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; var conventions = __webpack_require__("./node_modules/@xmldom/xmldom/lib/conventions.js"); var find = conventions.find; var hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace; var hasOwn = conventions.hasOwn; var isHTMLMimeType = conventions.isHTMLMimeType; var isHTMLRawTextElement = conventions.isHTMLRawTextElement; var isHTMLVoidElement = conventions.isHTMLVoidElement; var MIME_TYPE = conventions.MIME_TYPE; var NAMESPACE = conventions.NAMESPACE; /** * Private DOM Constructor symbol * * Internal symbol used for construction of all classes whose constructors should be private. * Currently used for checks in `Node`, `Document`, `Element`, `Attr`, `CharacterData`, `Text`, `Comment`, * `CDATASection`, `DocumentType`, `Notation`, `Entity`, `EntityReference`, `DocumentFragment`, `ProcessingInstruction` * so the constructor can't be used from outside the module. */ var PDC = Symbol(); var errors = __webpack_require__("./node_modules/@xmldom/xmldom/lib/errors.js"); var DOMException = errors.DOMException; var DOMExceptionName = errors.DOMExceptionName; var g = __webpack_require__("./node_modules/@xmldom/xmldom/lib/grammar.js"); /** * Checks if the given symbol equals the Private DOM Constructor symbol (PDC) * and throws an Illegal constructor exception when the symbols don't match. * This ensures that the constructor remains private and can't be used outside this module. */ function checkSymbol(symbol) { if (symbol !== PDC) { throw new TypeError('Illegal constructor'); } } /** * A prerequisite for `[].filter`, to drop elements that are empty. * * @param {string} input * The string to be checked. * @returns {boolean} * Returns `true` if the input string is not empty, `false` otherwise. */ function notEmptyString(input) { return input !== ''; } /** * Splits a string on ASCII whitespace characters (U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, * U+0020 SPACE). * It follows the definition from the infra specification from WHATWG. * * @param {string} input * The string to be split. * @returns {string[]} * An array of the split strings. The array can be empty if the input string is empty or only * contains whitespace characters. * @see {@link https://infra.spec.whatwg.org/#split-on-ascii-whitespace} * @see {@link https://infra.spec.whatwg.org/#ascii-whitespace} */ function splitOnASCIIWhitespace(input) { // U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []; } /** * Adds element as a key to current if it is not already present. * * @param {Record<string, boolean | undefined>} current * The current record object to which the element will be added as a key. * The object's keys are string types and values are either boolean or undefined. * @param {string} element * The string to be added as a key to the current record. * @returns {Record<string, boolean | undefined>} * The updated record object after the addition of the new element. */ function orderedSetReducer(current, element) { if (!hasOwn(current, element)) { current[element] = true; } return current; } /** * Converts a string into an ordered set by splitting the input on ASCII whitespace and * ensuring uniqueness of elements. * This follows the definition of an ordered set from the infra specification by WHATWG. * * @param {string} input * The input string to be transformed into an ordered set. * @returns {string[]} * An array of unique strings obtained from the input, preserving the original order. * The array can be empty if the input string is empty or only contains whitespace characters. * @see {@link https://infra.spec.whatwg.org/#ordered-set} */ function toOrderedSet(input) { if (!input) return []; var list = splitOnASCIIWhitespace(input); return Object.keys(list.reduce(orderedSetReducer, {})); } /** * Uses `list.indexOf` to implement a function that behaves like `Array.prototype.includes`. * This function is used in environments where `Array.prototype.includes` may not be available. * * @param {any[]} list * The array in which to search for the element. * @returns {function(any): boolean} * A function that accepts an element and returns a boolean indicating whether the element is * included in the provided list. */ function arrayIncludes(list) { return function (element) { return list && list.indexOf(element) !== -1; }; } /** * Validates a qualified name based on the criteria provided in the DOM specification by * WHATWG. * * @param {string} qualifiedName * The qualified name to be validated. * @throws {DOMException} * With code {@link DOMException.INVALID_CHARACTER_ERR} if the qualified name contains an * invalid character. * @see {@link https://dom.spec.whatwg.org/#validate} */ function validateQualifiedName(qualifiedName) { if (!g.QName_exact.test(qualifiedName)) { throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in qualified name "' + qualifiedName + '"'); } } /** * Validates a qualified name and the namespace associated with it, * based on the criteria provided in the DOM specification by WHATWG. * * @param {string | null} namespace * The namespace to be validated. It can be a string or null. * @param {string} qualifiedName * The qualified name to be validated. * @returns {[namespace: string | null, prefix: string | null, localName: string]} * Returns a tuple with the namespace, * prefix and local name of the qualified name. * @throws {DOMException} * Throws a DOMException if the qualified name or the namespace is not valid. * @see {@link https://dom.spec.whatwg.org/#validate-and-extract} */ function validateAndExtract(namespace, qualifiedName) { validateQualifiedName(qualifiedName); namespace = namespace || null; /** * @type {string | null} */ var prefix = null; var localName = qualifiedName; if (qualifiedName.indexOf(':') >= 0) { var splitResult = qualifiedName.split(':'); prefix = splitResult[0]; localName = splitResult[1]; } if (prefix !== null && namespace === null) { throw new DOMException(DOMException.NAMESPACE_ERR, 'prefix is non-null and namespace is null'); } if (prefix === 'xml' && namespace !== conventions.NAMESPACE.XML) { throw new DOMException(DOMException.NAMESPACE_ERR, 'prefix is "xml" and namespace is not the XML namespace'); } if ((prefix === 'xmlns' || qualifiedName === 'xmlns') && namespace !== conventions.NAMESPACE.XMLNS) { throw new DOMException(DOMException.NAMESPACE_ERR, 'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace'); } if (namespace === conventions.NAMESPACE.XMLNS && prefix !== 'xmlns' && qualifiedName !== 'xmlns') { throw new DOMException(DOMException.NAMESPACE_ERR, 'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"'); } return [namespace, prefix, localName]; } /** * Copies properties from one object to another. * It only copies the object's own (not inherited) properties. * * @param {Object} src * The source object from which properties are copied. * @param {Object} dest * The destination object to which properties are copied. */ function copy(src, dest) { for (var p in src) { if (hasOwn(src, p)) { dest[p] = src[p]; } } } /** * Extends a class with the properties and methods of a super class. * It uses a form of prototypal inheritance, and establishes the `constructor` property * correctly(?). * * It is not clear to the current maintainers if this implementation is making sense, * since it creates an intermediate prototype function, * which all properties of `Super` are copied onto using `_copy`. * * @param {Object} Class * The class that is to be extended. * @param {Object} Super * The super class from which properties and methods are inherited. * @private */ function _extends(Class, Super) { var pt = Class.prototype; if (!(pt instanceof Super)) { function t() {} t.prototype = Super.prototype; t = new t(); copy(pt, t); Class.prototype = pt = t; } if (pt.constructor != Class) { if (typeof Class != 'function') { console.error('unknown Class:' + Class); } pt.constructor = Class; } } var NodeType = {}; var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1; var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2; var TEXT_NODE = NodeType.TEXT_NODE = 3; var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4; var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5; var ENTITY_NODE = NodeType.ENTITY_NODE = 6; var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7; var COMMENT_NODE = NodeType.COMMENT_NODE = 8; var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9; var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10; var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11; var NOTATION_NODE = NodeType.NOTATION_NODE = 12; var DocumentPosition = conventions.freeze({ DOCUMENT_POSITION_DISCONNECTED: 1, DOCUMENT_POSITION_PRECEDING: 2, DOCUMENT_POSITION_FOLLOWING: 4, DOCUMENT_POSITION_CONTAINS: 8, DOCUMENT_POSITION_CONTAINED_BY: 16, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32 }); //helper functions for compareDocumentPosition /** * Constructs a parent chain for a node. * * @param {Node} node * The start node from which the parent chain will be constructed. * @returns {Node[]} * The array of nodes representing the parent chain from the root to the specified node. */ function parentChain(node) { var chain = []; while (node.parentNode || node.ownerElement) { node = node.parentNode || node.ownerElement; chain.unshift(node); } return chain; } /** * Finds the common ancestor in two parent chains. * * @param {Node[]} a * The first parent chain. * @param {Node[]} b * The second parent chain. * @returns {Node} * The common ancestor node if it exists. If there is no common ancestor, the function will * return `null`. */ function commonAncestor(a, b) { if (b.length < a.length) return commonAncestor(b, a); var c = null; for (var n in a) { if (a[n] !== b[n]) return c; c = a[n]; } return c; } /** * Assigns a unique identifier to a document to ensure consistency while comparing unrelated * nodes. * * @param {Document} doc * The document to which a unique identifier is to be assigned. * @returns {string} * The unique identifier of the document. If the document already had a unique identifier, the * function will return the existing one. */ function docGUID(doc) { if (!doc.guid) doc.guid = Math.random(); return doc.guid; } //-- end of helper functions /** * The NodeList interface provides the abstraction of an ordered collection of nodes, * without defining or constraining how this collection is implemented. * NodeList objects in the DOM are live. * The items in the NodeList are accessible via an integral index, starting from 0. * You can also access the items of the NodeList with a `for...of` loop. * * @class NodeList * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177 * @constructs NodeList */ function NodeList() {} NodeList.prototype = { /** * The number of nodes in the list. The range of valid child node indices is 0 to length-1 * inclusive. * * @type {number} */ length: 0, /** * Returns the item at `index`. If index is greater than or equal to the number of nodes in * the list, this returns null. * * @param index * Unsigned long Index into the collection. * @returns {Node | null} * The node at position `index` in the NodeList, * or null if that is not a valid index. */ item: function (index) { return index >= 0 && index < this.length ? this[index] : null; }, /** * Returns a string representation of the NodeList. * * @param {unknown} nodeFilter * __A filter function? Not implemented according to the spec?__. * @returns {string} * A string representation of the NodeList. */ toString: function (nodeFilter) { for (var buf = [], i = 0; i < this.length; i++) { serializeToString(this[i], buf, nodeFilter); } return buf.join(''); }, /** * Filters the NodeList based on a predicate. * * @param {function(Node): boolean} predicate * - A predicate function to filter the NodeList. * @returns {Node[]} * An array of nodes that satisfy the predicate. * @private */ filter: function (predicate) { return Array.prototype.filter.call(this, predicate); }, /** * Returns the first index at which a given node can be found in the NodeList, or -1 if it is * not present. * * @param {Node} item * - The Node item to locate in the NodeList. * @returns {number} * The first index of the node in the NodeList; -1 if not found. * @private */ indexOf: function (item) { return Array.prototype.indexOf.call(this, item); } }; NodeList.prototype[Symbol.iterator] = function () { var me = this; var index = 0; return { next: function () { if (index < me.length) { return { value: me[index++], done: false }; } else { return { done: true }; } }, return: function () { return { done: true }; } }; }; /** * Represents a live collection of nodes that is automatically updated when its associated * document changes. * * @class LiveNodeList * @param {Node} node * The associated node. * @param {function} refresh * The function to refresh the live node list. * @augments NodeList * @constructs LiveNodeList */ function LiveNodeList(node, refresh) { this._node = node; this._refresh = refresh; _updateLiveList(this); } /** * Updates the live node list. * * @param {LiveNodeList} list * The live node list to update. * @private */ function _updateLiveList(list) { var inc = list._node._inc || list._node.ownerDocument._inc; if (list._inc !== inc) { var ls = list._refresh(list._node); __set__(list, 'length', ls.length); if (!list.$$length || ls.length < list.$$length) { for (var i = ls.length; i in list; i++) { if (hasOwn(list, i)) { delete list[i]; } } } copy(ls, list); list._inc = inc; } } /** * Returns the node at position `index` in the LiveNodeList, or null if that is not a valid * index. * * @param {number} i * Index into the collection. * @returns {Node | null} * The node at position `index` in the LiveNodeList, or null if that is not a valid index. */ LiveNodeList.prototype.item = function (i) { _updateLiveList(this); return this[i] || null; }; _extends(LiveNodeList, NodeList); /** * Objects implementing the NamedNodeMap interface are used to represent collections of nodes * that can be accessed by name. * Note that NamedNodeMap does not inherit from NodeList; * NamedNodeMaps are not maintained in any particular order. * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal * index, * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, * and does not imply that the DOM specifies an orde