diff options
Diffstat (limited to 'node_modules/domutils')
27 files changed, 1391 insertions, 0 deletions
diff --git a/node_modules/domutils/LICENSE b/node_modules/domutils/LICENSE new file mode 100644 index 0000000..c464f86 --- /dev/null +++ b/node_modules/domutils/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) Felix Böhm +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/domutils/lib/feeds.d.ts b/node_modules/domutils/lib/feeds.d.ts new file mode 100644 index 0000000..bc71c10 --- /dev/null +++ b/node_modules/domutils/lib/feeds.d.ts @@ -0,0 +1,45 @@ +import type { Node } from "domhandler"; +export declare type FeedItemMediaMedium = "image" | "audio" | "video" | "document" | "executable"; +export declare type FeedItemMediaExpression = "sample" | "full" | "nonstop"; +export interface FeedItemMedia { + medium: FeedItemMediaMedium | undefined; + isDefault: boolean; + url?: string; + fileSize?: number; + type?: string; + expression?: FeedItemMediaExpression; + bitrate?: number; + framerate?: number; + samplingrate?: number; + channels?: number; + duration?: number; + height?: number; + width?: number; + lang?: string; +} +export interface FeedItem { + id?: string; + title?: string; + link?: string; + description?: string; + pubDate?: Date; + media: FeedItemMedia[]; +} +export interface Feed { + type: string; + id?: string; + title?: string; + link?: string; + description?: string; + updated?: Date; + author?: string; + items: FeedItem[]; +} +/** + * Get the feed object from the root of a DOM tree. + * + * @param doc - The DOM to to extract the feed from. + * @returns The feed. + */ +export declare function getFeed(doc: Node[]): Feed | null; +//# sourceMappingURL=feeds.d.ts.map
\ No newline at end of file diff --git a/node_modules/domutils/lib/feeds.d.ts.map b/node_modules/domutils/lib/feeds.d.ts.map new file mode 100644 index 0000000..a3e1d1f --- /dev/null +++ b/node_modules/domutils/lib/feeds.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"feeds.d.ts","sourceRoot":"","sources":["../src/feeds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,YAAY,CAAC;AAIhD,oBAAY,mBAAmB,GACzB,OAAO,GACP,OAAO,GACP,OAAO,GACP,UAAU,GACV,YAAY,CAAC;AAEnB,oBAAY,uBAAuB,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpE,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACxC,SAAS,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,KAAK,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,IAAI;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,CAQhD"}
\ No newline at end of file diff --git a/node_modules/domutils/lib/feeds.js b/node_modules/domutils/lib/feeds.js new file mode 100644 index 0000000..7e5775a --- /dev/null +++ b/node_modules/domutils/lib/feeds.js @@ -0,0 +1,190 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getFeed = void 0; +var stringify_1 = require("./stringify"); +var legacy_1 = require("./legacy"); +/** + * Get the feed object from the root of a DOM tree. + * + * @param doc - The DOM to to extract the feed from. + * @returns The feed. + */ +function getFeed(doc) { + var feedRoot = getOneElement(isValidFeed, doc); + return !feedRoot + ? null + : feedRoot.name === "feed" + ? getAtomFeed(feedRoot) + : getRssFeed(feedRoot); +} +exports.getFeed = getFeed; +/** + * Parse an Atom feed. + * + * @param feedRoot The root of the feed. + * @returns The parsed feed. + */ +function getAtomFeed(feedRoot) { + var _a; + var childs = feedRoot.children; + var feed = { + type: "atom", + items: (0, legacy_1.getElementsByTagName)("entry", childs).map(function (item) { + var _a; + var children = item.children; + var entry = { media: getMediaElements(children) }; + addConditionally(entry, "id", "id", children); + addConditionally(entry, "title", "title", children); + var href = (_a = getOneElement("link", children)) === null || _a === void 0 ? void 0 : _a.attribs.href; + if (href) { + entry.link = href; + } + var description = fetch("summary", children) || fetch("content", children); + if (description) { + entry.description = description; + } + var pubDate = fetch("updated", children); + if (pubDate) { + entry.pubDate = new Date(pubDate); + } + return entry; + }), + }; + addConditionally(feed, "id", "id", childs); + addConditionally(feed, "title", "title", childs); + var href = (_a = getOneElement("link", childs)) === null || _a === void 0 ? void 0 : _a.attribs.href; + if (href) { + feed.link = href; + } + addConditionally(feed, "description", "subtitle", childs); + var updated = fetch("updated", childs); + if (updated) { + feed.updated = new Date(updated); + } + addConditionally(feed, "author", "email", childs, true); + return feed; +} +/** + * Parse a RSS feed. + * + * @param feedRoot The root of the feed. + * @returns The parsed feed. + */ +function getRssFeed(feedRoot) { + var _a, _b; + var childs = (_b = (_a = getOneElement("channel", feedRoot.children)) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []; + var feed = { + type: feedRoot.name.substr(0, 3), + id: "", + items: (0, legacy_1.getElementsByTagName)("item", feedRoot.children).map(function (item) { + var children = item.children; + var entry = { media: getMediaElements(children) }; + addConditionally(entry, "id", "guid", children); + addConditionally(entry, "title", "title", children); + addConditionally(entry, "link", "link", children); + addConditionally(entry, "description", "description", children); + var pubDate = fetch("pubDate", children); + if (pubDate) + entry.pubDate = new Date(pubDate); + return entry; + }), + }; + addConditionally(feed, "title", "title", childs); + addConditionally(feed, "link", "link", childs); + addConditionally(feed, "description", "description", childs); + var updated = fetch("lastBuildDate", childs); + if (updated) { + feed.updated = new Date(updated); + } + addConditionally(feed, "author", "managingEditor", childs, true); + return feed; +} +var MEDIA_KEYS_STRING = ["url", "type", "lang"]; +var MEDIA_KEYS_INT = [ + "fileSize", + "bitrate", + "framerate", + "samplingrate", + "channels", + "duration", + "height", + "width", +]; +/** + * Get all media elements of a feed item. + * + * @param where Nodes to search in. + * @returns Media elements. + */ +function getMediaElements(where) { + return (0, legacy_1.getElementsByTagName)("media:content", where).map(function (elem) { + var attribs = elem.attribs; + var media = { + medium: attribs.medium, + isDefault: !!attribs.isDefault, + }; + for (var _i = 0, MEDIA_KEYS_STRING_1 = MEDIA_KEYS_STRING; _i < MEDIA_KEYS_STRING_1.length; _i++) { + var attrib = MEDIA_KEYS_STRING_1[_i]; + if (attribs[attrib]) { + media[attrib] = attribs[attrib]; + } + } + for (var _a = 0, MEDIA_KEYS_INT_1 = MEDIA_KEYS_INT; _a < MEDIA_KEYS_INT_1.length; _a++) { + var attrib = MEDIA_KEYS_INT_1[_a]; + if (attribs[attrib]) { + media[attrib] = parseInt(attribs[attrib], 10); + } + } + if (attribs.expression) { + media.expression = + attribs.expression; + } + return media; + }); +} +/** + * Get one element by tag name. + * + * @param tagName Tag name to look for + * @param node Node to search in + * @returns The element or null + */ +function getOneElement(tagName, node) { + return (0, legacy_1.getElementsByTagName)(tagName, node, true, 1)[0]; +} +/** + * Get the text content of an element with a certain tag name. + * + * @param tagName Tag name to look for. + * @param where Node to search in. + * @param recurse Whether to recurse into child nodes. + * @returns The text content of the element. + */ +function fetch(tagName, where, recurse) { + if (recurse === void 0) { recurse = false; } + return (0, stringify_1.textContent)((0, legacy_1.getElementsByTagName)(tagName, where, recurse, 1)).trim(); +} +/** + * Adds a property to an object if it has a value. + * + * @param obj Object to be extended + * @param prop Property name + * @param tagName Tag name that contains the conditionally added property + * @param where Element to search for the property + * @param recurse Whether to recurse into child nodes. + */ +function addConditionally(obj, prop, tagName, where, recurse) { + if (recurse === void 0) { recurse = false; } + var val = fetch(tagName, where, recurse); + if (val) + obj[prop] = val; +} +/** + * Checks if an element is a feed root node. + * + * @param value The name of the element to check. + * @returns Whether an element is a feed root node. + */ +function isValidFeed(value) { + return value === "rss" || value === "feed" || value === "rdf:RDF"; +} diff --git a/node_modules/domutils/lib/helpers.d.ts b/node_modules/domutils/lib/helpers.d.ts new file mode 100644 index 0000000..61b282f --- /dev/null +++ b/node_modules/domutils/lib/helpers.d.ts @@ -0,0 +1,51 @@ +import { Node } from "domhandler"; +/** + * Given an array of nodes, remove any member that is contained by another. + * + * @param nodes Nodes to filter. + * @returns Remaining nodes that aren't subtrees of each other. + */ +export declare function removeSubsets(nodes: Node[]): Node[]; +export declare const enum DocumentPosition { + DISCONNECTED = 1, + PRECEDING = 2, + FOLLOWING = 4, + CONTAINS = 8, + CONTAINED_BY = 16 +} +/** + * Compare the position of one node against another node in any other document. + * The return value is a bitmask with the following values: + * + * Document order: + * > There is an ordering, document order, defined on all the nodes in the + * > document corresponding to the order in which the first character of the + * > XML representation of each node occurs in the XML representation of the + * > document after expansion of general entities. Thus, the document element + * > node will be the first node. Element nodes occur before their children. + * > Thus, document order orders element nodes in order of the occurrence of + * > their start-tag in the XML (after expansion of entities). The attribute + * > nodes of an element occur after the element and before its children. The + * > relative order of attribute nodes is implementation-dependent./ + * + * Source: + * http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order + * + * @param nodeA The first node to use in the comparison + * @param nodeB The second node to use in the comparison + * @returns A bitmask describing the input nodes' relative position. + * + * See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for + * a description of these values. + */ +export declare function compareDocumentPosition(nodeA: Node, nodeB: Node): number; +/** + * Sort an array of nodes based on their relative position in the document and + * remove any duplicate nodes. If the array contains nodes that do not belong + * to the same document, sort order is unspecified. + * + * @param nodes Array of DOM nodes. + * @returns Collection of unique nodes, sorted in document order. + */ +export declare function uniqueSort<T extends Node>(nodes: T[]): T[]; +//# sourceMappingURL=helpers.d.ts.map
\ No newline at end of file diff --git a/node_modules/domutils/lib/helpers.d.ts.map b/node_modules/domutils/lib/helpers.d.ts.map new file mode 100644 index 0000000..3c0b410 --- /dev/null +++ b/node_modules/domutils/lib/helpers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CA6BnD;AAGD,0BAAkB,gBAAgB;IAC9B,YAAY,IAAI;IAChB,SAAS,IAAI;IACb,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,YAAY,KAAK;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,CA4CxE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAc1D"}
\ No newline at end of file diff --git a/node_modules/domutils/lib/helpers.js b/node_modules/domutils/lib/helpers.js new file mode 100644 index 0000000..e823a92 --- /dev/null +++ b/node_modules/domutils/lib/helpers.js @@ -0,0 +1,125 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.uniqueSort = exports.compareDocumentPosition = exports.removeSubsets = void 0; +var domhandler_1 = require("domhandler"); +/** + * Given an array of nodes, remove any member that is contained by another. + * + * @param nodes Nodes to filter. + * @returns Remaining nodes that aren't subtrees of each other. + */ +function removeSubsets(nodes) { + var idx = nodes.length; + /* + * Check if each node (or one of its ancestors) is already contained in the + * array. + */ + while (--idx >= 0) { + var node = nodes[idx]; + /* + * Remove the node if it is not unique. + * We are going through the array from the end, so we only + * have to check nodes that preceed the node under consideration in the array. + */ + if (idx > 0 && nodes.lastIndexOf(node, idx - 1) >= 0) { + nodes.splice(idx, 1); + continue; + } + for (var ancestor = node.parent; ancestor; ancestor = ancestor.parent) { + if (nodes.includes(ancestor)) { + nodes.splice(idx, 1); + break; + } + } + } + return nodes; +} +exports.removeSubsets = removeSubsets; +/** + * Compare the position of one node against another node in any other document. + * The return value is a bitmask with the following values: + * + * Document order: + * > There is an ordering, document order, defined on all the nodes in the + * > document corresponding to the order in which the first character of the + * > XML representation of each node occurs in the XML representation of the + * > document after expansion of general entities. Thus, the document element + * > node will be the first node. Element nodes occur before their children. + * > Thus, document order orders element nodes in order of the occurrence of + * > their start-tag in the XML (after expansion of entities). The attribute + * > nodes of an element occur after the element and before its children. The + * > relative order of attribute nodes is implementation-dependent./ + * + * Source: + * http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order + * + * @param nodeA The first node to use in the comparison + * @param nodeB The second node to use in the comparison + * @returns A bitmask describing the input nodes' relative position. + * + * See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for + * a description of these values. + */ +function compareDocumentPosition(nodeA, nodeB) { + var aParents = []; + var bParents = []; + if (nodeA === nodeB) { + return 0; + } + var current = (0, domhandler_1.hasChildren)(nodeA) ? nodeA : nodeA.parent; + while (current) { + aParents.unshift(current); + current = current.parent; + } + current = (0, domhandler_1.hasChildren)(nodeB) ? nodeB : nodeB.parent; + while (current) { + bParents.unshift(current); + current = current.parent; + } + var maxIdx = Math.min(aParents.length, bParents.length); + var idx = 0; + while (idx < maxIdx && aParents[idx] === bParents[idx]) { + idx++; + } + if (idx === 0) { + return 1 /* DISCONNECTED */; + } + var sharedParent = aParents[idx - 1]; + var siblings = sharedParent.children; + var aSibling = aParents[idx]; + var bSibling = bParents[idx]; + if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) { + if (sharedParent === nodeB) { + return 4 /* FOLLOWING */ | 16 /* CONTAINED_BY */; + } + return 4 /* FOLLOWING */; + } + if (sharedParent === nodeA) { + return 2 /* PRECEDING */ | 8 /* CONTAINS */; + } + return 2 /* PRECEDING */; +} +exports.compareDocumentPosition = compareDocumentPosition; +/** + * Sort an array of nodes based on their relative position in the document and + * remove any duplicate nodes. If the array contains nodes that do not belong + * to the same document, sort order is unspecified. + * + * @param nodes Array of DOM nodes. + * @returns Collection of unique nodes, sorted in document order. + */ +function uniqueSort(nodes) { + nodes = nodes.filter(function (node, i, arr) { return !arr.includes(node, i + 1); }); + nodes.sort(function (a, b) { + var relative = compareDocumentPosition(a, b); + if (relative & 2 /* PRECEDING */) { + return -1; + } + else if (relative & 4 /* FOLLOWING */) { + return 1; + } + return 0; + }); + return nodes; +} +exports.uniqueSort = uniqueSort; diff --git a/node_modules/domutils/lib/index.d.ts b/node_modules/domutils/lib/index.d.ts new file mode 100644 index 0000000..33b282d --- /dev/null +++ b/node_modules/domutils/lib/index.d.ts @@ -0,0 +1,10 @@ +export * from "./stringify"; +export * from "./traversal"; +export * from "./manipulation"; +export * from "./querying"; +export * from "./legacy"; +export * from "./helpers"; +export * from "./feeds"; +/** @deprecated Use these methods from `domhandler` directly. */ +export { isTag, isCDATA, isText, isComment, isDocument, hasChildren, } from "domhandler"; +//# sourceMappingURL=index.d.ts.map
\ No newline at end of file diff --git a/node_modules/domutils/lib/index.d.ts.map b/node_modules/domutils/lib/index.d.ts.map new file mode 100644 index 0000000..4c113d1 --- /dev/null +++ b/node_modules/domutils/lib/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,gEAAgE;AAChE,OAAO,EACH,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAS,EACT,UAAU,EACV,WAAW,GACd,MAAM,YAAY,CAAC"}
\ No newline at end of file diff --git a/node_modules/domutils/lib/index.js b/node_modules/domutils/lib/index.js new file mode 100644 index 0000000..029aa09 --- /dev/null +++ b/node_modules/domutils/lib/index.js @@ -0,0 +1,28 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hasChildren = exports.isDocument = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = void 0; +__exportStar(require("./stringify"), exports); +__exportStar(require("./traversal"), exports); +__exportStar(require("./manipulation"), exports); +__exportStar(require("./querying"), exports); +__exportStar(require("./legacy"), exports); +__exportStar(require("./helpers"), exports); +__exportStar(require("./feeds"), exports); +/** @deprecated Use these methods from `domhandler` directly. */ +var domhandler_1 = require("domhandler"); +Object.defineProperty(exports, "isTag", { enumerable: true, get: function () { return domhandler_1.isTag; } }); +Object.defineProperty(exports, "isCDATA", { enumerable: true, get: function () { return domhandler_1.isCDATA; } }); +Object.defineProperty(exports, "isText", { enumerable: true, get: function () { return domhandler_1.isText; } }); +Object.defineProperty(exports, "isComment", { enumerable: true, get: function () { return domhandler_1.isComment; } }); +Object.defineProperty(exports, "isDocument", { enumerable: true, get: function () { return domhandler_1.isDocument; } }); +Object.defineProperty(exports, "hasChildren", { enumerable: true, get: function () { return domhandler_1.hasChildren; } }); diff --git a/node_modules/domutils/lib/legacy.d.ts b/node_modules/domutils/lib/legacy.d.ts new file mode 100644 index 0000000..7190d7c --- /dev/null +++ b/node_modules/domutils/lib/legacy.d.ts @@ -0,0 +1,47 @@ +import { Node, Element } from "domhandler"; +import { ElementType } from "domelementtype"; +interface TestElementOpts { + tag_name?: string | ((name: string) => boolean); + tag_type?: string | ((name: string) => boolean); + tag_contains?: string | ((data?: string) => boolean); + [attributeName: string]: undefined | string | ((attributeValue: string) => boolean); +} +/** + * @param options An object describing nodes to look for. + * @param node The element to test. + * @returns Whether the element matches the description in `options`. + */ +export declare function testElement(options: TestElementOpts, node: Node): boolean; +/** + * @param options An object describing nodes to look for. + * @param nodes Nodes to search through. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes that match `options`. + */ +export declare function getElements(options: TestElementOpts, nodes: Node | Node[], recurse: boolean, limit?: number): Node[]; +/** + * @param id The unique ID attribute value to look for. + * @param nodes Nodes to search through. + * @param recurse Also consider child nodes. + * @returns The node with the supplied ID. + */ +export declare function getElementById(id: string | ((id: string) => boolean), nodes: Node | Node[], recurse?: boolean): Element | null; +/** + * @param tagName Tag name to search for. + * @param nodes Nodes to search through. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes with the supplied `tagName`. + */ +export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Element[]; +/** + * @param type Element type to look for. + * @param nodes Nodes to search through. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes with the supplied `type`. + */ +export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Node[]; +export {}; +//# sourceMappingURL=legacy.d.ts.map
\ No newline at end of file diff --git a/node_modules/domutils/lib/legacy.d.ts.map b/node_modules/domutils/lib/legacy.d.ts.map new file mode 100644 index 0000000..f6f7217 --- /dev/null +++ b/node_modules/domutils/lib/legacy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK7C,UAAU,eAAe;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IACrD,CAAC,aAAa,EAAE,MAAM,GAChB,SAAS,GACT,MAAM,GACN,CAAC,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;CAC/C;AAqED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAGzE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACvB,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,EAAE,OAAO,EAChB,KAAK,SAAW,GACjB,IAAI,EAAE,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,EACtC,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,UAAO,GACf,OAAO,GAAG,IAAI,CAGhB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,EAC7C,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,UAAO,EACd,KAAK,SAAW,GACjB,OAAO,EAAE,CAEX;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,WAAW,GAAG,CAAC,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,EACpD,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,UAAO,EACd,KAAK,SAAW,GACjB,IAAI,EAAE,CAER"}
\ No newline at end of file diff --git a/node_modules/domutils/lib/legacy.js b/node_modules/domutils/lib/legacy.js new file mode 100644 index 0000000..478564c --- /dev/null +++ b/node_modules/domutils/lib/legacy.js @@ -0,0 +1,124 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getElementsByTagType = exports.getElementsByTagName = exports.getElementById = exports.getElements = exports.testElement = void 0; +var domhandler_1 = require("domhandler"); +var querying_1 = require("./querying"); +var Checks = { + tag_name: function (name) { + if (typeof name === "function") { + return function (elem) { return (0, domhandler_1.isTag)(elem) && name(elem.name); }; + } + else if (name === "*") { + return domhandler_1.isTag; + } + return function (elem) { return (0, domhandler_1.isTag)(elem) && elem.name === name; }; + }, + tag_type: function (type) { + if (typeof type === "function") { + return function (elem) { return type(elem.type); }; + } + return function (elem) { return elem.type === type; }; + }, + tag_contains: function (data) { + if (typeof data === "function") { + return function (elem) { return (0, domhandler_1.isText)(elem) && data(elem.data); }; + } + return function (elem) { return (0, domhandler_1.isText)(elem) && elem.data === data; }; + }, +}; +/** + * @param attrib Attribute to check. + * @param value Attribute value to look for. + * @returns A function to check whether the a node has an attribute with a particular value. + */ +function getAttribCheck(attrib, value) { + if (typeof value === "function") { + return function (elem) { return (0, domhandler_1.isTag)(elem) && value(elem.attribs[attrib]); }; + } + return function (elem) { return (0, domhandler_1.isTag)(elem) && elem.attribs[attrib] === value; }; +} +/** + * @param a First function to combine. + * @param b Second function to combine. + * @returns A function taking a node and returning `true` if either + * of the input functions returns `true` for the node. + */ +function combineFuncs(a, b) { + return function (elem) { return a(elem) || b(elem); }; +} +/** + * @param options An object describing nodes to look for. + * @returns A function executing all checks in `options` and returning `true` + * if any of them match a node. + */ +function compileTest(options) { + var funcs = Object.keys(options).map(function (key) { + var value = options[key]; + return Object.prototype.hasOwnProperty.call(Checks, key) + ? Checks[key](value) + : getAttribCheck(key, value); + }); + return funcs.length === 0 ? null : funcs.reduce(combineFuncs); +} +/** + * @param options An object describing nodes to look for. + * @param node The element to test. + * @returns Whether the element matches the description in `options`. + */ +function testElement(options, node) { + var test = compileTest(options); + return test ? test(node) : true; +} +exports.testElement = testElement; +/** + * @param options An object describing nodes to look for. + * @param nodes Nodes to search through. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes that match `options`. + */ +function getElements(options, nodes, recurse, limit) { + if (limit === void 0) { limit = Infinity; } + var test = compileTest(options); + return test ? (0, querying_1.filter)(test, nodes, recurse, limit) : []; +} +exports.getElements = getElements; +/** + * @param id The unique ID attribute value to look for. + * @param nodes Nodes to search through. + * @param recurse Also consider child nodes. + * @returns The node with the supplied ID. + */ +function getElementById(id, nodes, recurse) { + if (recurse === void 0) { recurse = true; } + if (!Array.isArray(nodes)) + nodes = [nodes]; + return (0, querying_1.findOne)(getAttribCheck("id", id), nodes, recurse); +} +exports.getElementById = getElementById; +/** + * @param tagName Tag name to search for. + * @param nodes Nodes to search through. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes with the supplied `tagName`. + */ +function getElementsByTagName(tagName, nodes, recurse, limit) { + if (recurse === void 0) { recurse = true; } + if (limit === void 0) { limit = Infinity; } + return (0, querying_1.filter)(Checks.tag_name(tagName), nodes, recurse, limit); +} +exports.getElementsByTagName = getElementsByTagName; +/** + * @param type Element type to look for. + * @param nodes Nodes to search through. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes with the supplied `type`. + */ +function getElementsByTagType(type, nodes, recurse, limit) { + if (recurse === void 0) { recurse = true; } + if (limit === void 0) { limit = Infinity; } + return (0, querying_1.filter)(Checks.tag_type(type), nodes, recurse, limit); +} +exports.getElementsByTagType = getElementsByTagType; diff --git a/node_modules/domutils/lib/manipulation.d.ts b/node_modules/domutils/lib/manipulation.d.ts new file mode 100644 index 0000000..0950619 --- /dev/null +++ b/node_modules/domutils/lib/manipulation.d.ts @@ -0,0 +1,43 @@ +import type { Node, Element } from "domhandler"; +/** + * Remove an element from the dom + * + * @param elem The element to be removed + */ +export declare function removeElement(elem: Node): void; +/** + * Replace an element in the dom + * + * @param elem The element to be replaced + * @param replacement The element to be added + */ +export declare function replaceElement(elem: Node, replacement: Node): void; +/** + * Append a child to an element. + * + * @param elem The element to append to. + * @param child The element to be added as a child. + */ +export declare function appendChild(elem: Element, child: Node): void; +/** + * Append an element after another. + * + * @param elem The element to append after. + * @param next The element be added. + */ +export declare function append(elem: Node, next: Node): void; +/** + * Prepend a child to an element. + * + * @param elem The element to prepend before. + * @param child The element to be added as a child. + */ +export declare function prependChild(elem: Element, child: Node): void; +/** + * Prepend an element before another. + * + * @param elem The element to prepend before. + * @param prev The element be added. + */ +export declare function prepend(elem: Node, prev: Node): void; +//# sourceMappingURL=manipulation.d.ts.map
\ No newline at end of file diff --git a/node_modules/domutils/lib/manipulation.d.ts.map b/node_modules/domutils/lib/manipulation.d.ts.map new file mode 100644 index 0000000..a302120 --- /dev/null +++ b/node_modules/domutils/lib/manipulation.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"manipulation.d.ts","sourceRoot":"","sources":["../src/manipulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAQ9C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,GAAG,IAAI,CAgBlE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAa5D;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAoBnD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAa7D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAiBpD"}
\ No newline at end of file diff --git a/node_modules/domutils/lib/manipulation.js b/node_modules/domutils/lib/manipulation.js new file mode 100644 index 0000000..f7c77ef --- /dev/null +++ b/node_modules/domutils/lib/manipulation.js @@ -0,0 +1,129 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.prepend = exports.prependChild = exports.append = exports.appendChild = exports.replaceElement = exports.removeElement = void 0; +/** + * Remove an element from the dom + * + * @param elem The element to be removed + */ +function removeElement(elem) { + if (elem.prev) + elem.prev.next = elem.next; + if (elem.next) + elem.next.prev = elem.prev; + if (elem.parent) { + var childs = elem.parent.children; + childs.splice(childs.lastIndexOf(elem), 1); + } +} +exports.removeElement = removeElement; +/** + * Replace an element in the dom + * + * @param elem The element to be replaced + * @param replacement The element to be added + */ +function replaceElement(elem, replacement) { + var prev = (replacement.prev = elem.prev); + if (prev) { + prev.next = replacement; + } + var next = (replacement.next = elem.next); + if (next) { + next.prev = replacement; + } + var parent = (replacement.parent = elem.parent); + if (parent) { + var childs = parent.children; + childs[childs.lastIndexOf(elem)] = replacement; + } +} +exports.replaceElement = replaceElement; +/** + * Append a child to an element. + * + * @param elem The element to append to. + * @param child The element to be added as a child. + */ +function appendChild(elem, child) { + removeElement(child); + child.next = null; + child.parent = elem; + if (elem.children.push(child) > 1) { + var sibling = elem.children[elem.children.length - 2]; + sibling.next = child; + child.prev = sibling; + } + else { + child.prev = null; + } +} +exports.appendChild = appendChild; +/** + * Append an element after another. + * + * @param elem The element to append after. + * @param next The element be added. + */ +function append(elem, next) { + removeElement(next); + var parent = elem.parent; + var currNext = elem.next; + next.next = currNext; + next.prev = elem; + elem.next = next; + next.parent = parent; + if (currNext) { + currNext.prev = next; + if (parent) { + var childs = parent.children; + childs.splice(childs.lastIndexOf(currNext), 0, next); + } + } + else if (parent) { + parent.children.push(next); + } +} +exports.append = append; +/** + * Prepend a child to an element. + * + * @param elem The element to prepend before. + * @param child The element to be added as a child. + */ +function prependChild(elem, child) { + removeElement(child); + child.parent = elem; + child.prev = null; + if (elem.children.unshift(child) !== 1) { + var sibling = elem.children[1]; + sibling.prev = child; + child.next = sibling; + } + else { + child.next = null; + } +} +exports.prependChild = prependChild; +/** + * Prepend an element before another. + * + * @param elem The element to prepend before. + * @param prev The element be added. + */ +function prepend(elem, prev) { + removeElement(prev); + var parent = elem.parent; + if (parent) { + var childs = parent.children; + childs.splice(childs.indexOf(elem), 0, prev); + } + if (elem.prev) { + elem.prev.next = prev; + } + prev.parent = parent; + prev.prev = elem.prev; + prev.next = elem; + elem.prev = prev; +} +exports.prepend = prepend; diff --git a/node_modules/domutils/lib/querying.d.ts b/node_modules/domutils/lib/querying.d.ts new file mode 100644 index 0000000..e3dc7aa --- /dev/null +++ b/node_modules/domutils/lib/querying.d.ts @@ -0,0 +1,55 @@ +import { Node, Element } from "domhandler"; +/** + * Search a node and its children for nodes passing a test function. + * + * @param test Function to test nodes on. + * @param node Node to search. Will be included in the result set if it matches. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes passing `test`. + */ +export declare function filter(test: (elem: Node) => boolean, node: Node | Node[], recurse?: boolean, limit?: number): Node[]; +/** + * Search an array of node and its children for nodes passing a test function. + * + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes passing `test`. + */ +export declare function find(test: (elem: Node) => boolean, nodes: Node[], recurse: boolean, limit: number): Node[]; +/** + * Finds the first element inside of an array that matches a test function. + * + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @returns The first node in the array that passes `test`. + */ +export declare function findOneChild(test: (elem: Node) => boolean, nodes: Node[]): Node | undefined; +/** + * Finds one element in a tree that passes a test. + * + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @param recurse Also consider child nodes. + * @returns The first child node that passes `test`. + */ +export declare function findOne(test: (elem: Element) => boolean, nodes: Node[], recurse?: boolean): Element | null; +/** + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @returns Whether a tree of nodes contains at least one node passing a test. + */ +export declare function existsOne(test: (elem: Element) => boolean, nodes: Node[]): boolean; +/** + * Search and array of nodes and its children for nodes passing a test function. + * + * Same as `find`, only with less options, leading to reduced complexity. + * + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @returns All nodes passing `test`. + */ +export declare function findAll(test: (elem: Element) => boolean, nodes: Node[]): Element[]; +//# sourceMappingURL=querying.d.ts.map
\ No newline at end of file diff --git a/node_modules/domutils/lib/querying.d.ts.map b/node_modules/domutils/lib/querying.d.ts.map new file mode 100644 index 0000000..983fd51 --- /dev/null +++ b/node_modules/domutils/lib/querying.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"querying.d.ts","sourceRoot":"","sources":["../src/querying.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAClB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,EAC7B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,EACnB,OAAO,UAAO,EACd,KAAK,SAAW,GACjB,IAAI,EAAE,CAGR;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAChB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,EAC7B,KAAK,EAAE,IAAI,EAAE,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,GACd,IAAI,EAAE,CAkBR;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,EAC7B,KAAK,EAAE,IAAI,EAAE,GACd,IAAI,GAAG,SAAS,CAElB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACnB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,IAAI,EAAE,EACb,OAAO,UAAO,GACf,OAAO,GAAG,IAAI,CAehB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACrB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,IAAI,EAAE,GACd,OAAO,CAQT;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CACnB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,IAAI,EAAE,GACd,OAAO,EAAE,CAYX"}
\ No newline at end of file diff --git a/node_modules/domutils/lib/querying.js b/node_modules/domutils/lib/querying.js new file mode 100644 index 0000000..1eb20e9 --- /dev/null +++ b/node_modules/domutils/lib/querying.js @@ -0,0 +1,126 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.findAll = exports.existsOne = exports.findOne = exports.findOneChild = exports.find = exports.filter = void 0; +var domhandler_1 = require("domhandler"); +/** + * Search a node and its children for nodes passing a test function. + * + * @param test Function to test nodes on. + * @param node Node to search. Will be included in the result set if it matches. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes passing `test`. + */ +function filter(test, node, recurse, limit) { + if (recurse === void 0) { recurse = true; } + if (limit === void 0) { limit = Infinity; } + if (!Array.isArray(node)) + node = [node]; + return find(test, node, recurse, limit); +} +exports.filter = filter; +/** + * Search an array of node and its children for nodes passing a test function. + * + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @param recurse Also consider child nodes. + * @param limit Maximum number of nodes to return. + * @returns All nodes passing `test`. + */ +function find(test, nodes, recurse, limit) { + var result = []; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var elem = nodes_1[_i]; + if (test(elem)) { + result.push(elem); + if (--limit <= 0) + break; + } + if (recurse && (0, domhandler_1.hasChildren)(elem) && elem.children.length > 0) { + var children = find(test, elem.children, recurse, limit); + result.push.apply(result, children); + limit -= children.length; + if (limit <= 0) + break; + } + } + return result; +} +exports.find = find; +/** + * Finds the first element inside of an array that matches a test function. + * + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @returns The first node in the array that passes `test`. + */ +function findOneChild(test, nodes) { + return nodes.find(test); +} +exports.findOneChild = findOneChild; +/** + * Finds one element in a tree that passes a test. + * + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @param recurse Also consider child nodes. + * @returns The first child node that passes `test`. + */ +function findOne(test, nodes, recurse) { + if (recurse === void 0) { recurse = true; } + var elem = null; + for (var i = 0; i < nodes.length && !elem; i++) { + var checked = nodes[i]; + if (!(0, domhandler_1.isTag)(checked)) { + continue; + } + else if (test(checked)) { + elem = checked; + } + else if (recurse && checked.children.length > 0) { + elem = findOne(test, checked.children); + } + } + return elem; +} +exports.findOne = findOne; +/** + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @returns Whether a tree of nodes contains at least one node passing a test. + */ +function existsOne(test, nodes) { + return nodes.some(function (checked) { + return (0, domhandler_1.isTag)(checked) && + (test(checked) || + (checked.children.length > 0 && + existsOne(test, checked.children))); + }); +} +exports.existsOne = existsOne; +/** + * Search and array of nodes and its children for nodes passing a test function. + * + * Same as `find`, only with less options, leading to reduced complexity. + * + * @param test Function to test nodes on. + * @param nodes Array of nodes to search. + * @returns All nodes passing `test`. + */ +function findAll(test, nodes) { + var _a; + var result = []; + var stack = nodes.filter(domhandler_1.isTag); + var elem; + while ((elem = stack.shift())) { + var children = (_a = elem.children) === null || _a === void 0 ? void 0 : _a.filter(domhandler_1.isTag); + if (children && children.length > 0) { + stack.unshift.apply(stack, children); + } + if (test(elem)) + result.push(elem); + } + return result; +} +exports.findAll = findAll; diff --git a/node_modules/domutils/lib/stringify.d.ts b/node_modules/domutils/lib/stringify.d.ts new file mode 100644 index 0000000..b5019d0 --- /dev/null +++ b/node_modules/domutils/lib/stringify.d.ts @@ -0,0 +1,41 @@ +import { Node } from "domhandler"; +import { DomSerializerOptions } from "dom-serializer"; +/** + * @param node Node to get the outer HTML of. + * @param options Options for serialization. + * @deprecated Use the `dom-serializer` module directly. + * @returns `node`'s outer HTML. + */ +export declare function getOuterHTML(node: Node | Node[], options?: DomSerializerOptions): string; +/** + * @param node Node to get the inner HTML of. + * @param options Options for serialization. + * @deprecated Use the `dom-serializer` module directly. + * @returns `node`'s inner HTML. + */ +export declare function getInnerHTML(node: Node, options?: DomSerializerOptions): string; +/** + * Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags. + * + * @deprecated Use `textContent` instead. + * @param node Node to get the inner text of. + * @returns `node`'s inner text. + */ +export declare function getText(node: Node | Node[]): string; +/** + * Get a node's text content. + * + * @param node Node to get the text content of. + * @returns `node`'s text content. + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent} + */ +export declare function textContent(node: Node | Node[]): string; +/** + * Get a node's inner text. + * + * @param node Node to get the inner text of. + * @returns `node`'s inner text. + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText} + */ +export declare function innerText(node: Node | Node[]): string; +//# sourceMappingURL=stringify.d.ts.map
\ No newline at end of file diff --git a/node_modules/domutils/lib/stringify.d.ts.map b/node_modules/domutils/lib/stringify.d.ts.map new file mode 100644 index 0000000..777fec6 --- /dev/null +++ b/node_modules/domutils/lib/stringify.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../src/stringify.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,IAAI,EAEP,MAAM,YAAY,CAAC;AACpB,OAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGlE;;;;;GAKG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,EACnB,OAAO,CAAC,EAAE,oBAAoB,GAC/B,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,oBAAoB,GAC/B,MAAM,CAIR;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,CAMnD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,CAOvD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,CAOrD"}
\ No newline at end of file diff --git a/node_modules/domutils/lib/stringify.js b/node_modules/domutils/lib/stringify.js new file mode 100644 index 0000000..db74747 --- /dev/null +++ b/node_modules/domutils/lib/stringify.js @@ -0,0 +1,86 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.innerText = exports.textContent = exports.getText = exports.getInnerHTML = exports.getOuterHTML = void 0; +var domhandler_1 = require("domhandler"); +var dom_serializer_1 = __importDefault(require("dom-serializer")); +var domelementtype_1 = require("domelementtype"); +/** + * @param node Node to get the outer HTML of. + * @param options Options for serialization. + * @deprecated Use the `dom-serializer` module directly. + * @returns `node`'s outer HTML. + */ +function getOuterHTML(node, options) { + return (0, dom_serializer_1.default)(node, options); +} +exports.getOuterHTML = getOuterHTML; +/** + * @param node Node to get the inner HTML of. + * @param options Options for serialization. + * @deprecated Use the `dom-serializer` module directly. + * @returns `node`'s inner HTML. + */ +function getInnerHTML(node, options) { + return (0, domhandler_1.hasChildren)(node) + ? node.children.map(function (node) { return getOuterHTML(node, options); }).join("") + : ""; +} +exports.getInnerHTML = getInnerHTML; +/** + * Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags. + * + * @deprecated Use `textContent` instead. + * @param node Node to get the inner text of. + * @returns `node`'s inner text. + */ +function getText(node) { + if (Array.isArray(node)) + return node.map(getText).join(""); + if ((0, domhandler_1.isTag)(node)) + return node.name === "br" ? "\n" : getText(node.children); + if ((0, domhandler_1.isCDATA)(node)) + return getText(node.children); + if ((0, domhandler_1.isText)(node)) + return node.data; + return ""; +} +exports.getText = getText; +/** + * Get a node's text content. + * + * @param node Node to get the text content of. + * @returns `node`'s text content. + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent} + */ +function textContent(node) { + if (Array.isArray(node)) + return node.map(textContent).join(""); + if ((0, domhandler_1.hasChildren)(node) && !(0, domhandler_1.isComment)(node)) { + return textContent(node.children); + } + if ((0, domhandler_1.isText)(node)) + return node.data; + return ""; +} +exports.textContent = textContent; +/** + * Get a node's inner text. + * + * @param node Node to get the inner text of. + * @returns `node`'s inner text. + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText} + */ +function innerText(node) { + if (Array.isArray(node)) + return node.map(innerText).join(""); + if ((0, domhandler_1.hasChildren)(node) && (node.type === domelementtype_1.ElementType.Tag || (0, domhandler_1.isCDATA)(node))) { + return innerText(node.children); + } + if ((0, domhandler_1.isText)(node)) + return node.data; + return ""; +} +exports.innerText = innerText; diff --git a/node_modules/domutils/lib/traversal.d.ts b/node_modules/domutils/lib/traversal.d.ts new file mode 100644 index 0000000..0e2f44a --- /dev/null +++ b/node_modules/domutils/lib/traversal.d.ts @@ -0,0 +1,59 @@ +import { Node, Element, NodeWithChildren } from "domhandler"; +/** + * Get a node's children. + * + * @param elem Node to get the children of. + * @returns `elem`'s children, or an empty array. + */ +export declare function getChildren(elem: Node): Node[]; +export declare function getParent(elem: Element): Element | null; +export declare function getParent(elem: Node): NodeWithChildren | null; +/** + * Gets an elements siblings, including the element itself. + * + * Attempts to get the children through the element's parent first. + * If we don't have a parent (the element is a root node), + * we walk the element's `prev` & `next` to get all remaining nodes. + * + * @param elem Element to get the siblings of. + * @returns `elem`'s siblings. + */ +export declare function getSiblings(elem: Node): Node[]; +/** + * Gets an attribute from an element. + * + * @param elem Element to check. + * @param name Attribute name to retrieve. + * @returns The element's attribute value, or `undefined`. + */ +export declare function getAttributeValue(elem: Element, name: string): string | undefined; +/** + * Checks whether an element has an attribute. + * + * @param elem Element to check. + * @param name Attribute name to look for. + * @returns Returns whether `elem` has the attribute `name`. + */ +export declare function hasAttrib(elem: Element, name: string): boolean; +/** + * Get the tag name of an element. + * + * @param elem The element to get the name for. + * @returns The tag name of `elem`. + */ +export declare function getName(elem: Element): string; +/** + * Returns the next element sibling of a node. + * + * @param elem The element to get the next sibling of. + * @returns `elem`'s next sibling that is a tag. + */ +export declare function nextElementSibling(elem: Node): Element | null; +/** + * Returns the previous element sibling of a node. + * + * @param elem The element to get the previous sibling of. + * @returns `elem`'s previous sibling that is a tag. + */ +export declare function prevElementSibling(elem: Node): Element | null; +//# sourceMappingURL=traversal.d.ts.map
\ No newline at end of file diff --git a/node_modules/domutils/lib/traversal.d.ts.map b/node_modules/domutils/lib/traversal.d.ts.map new file mode 100644 index 0000000..0309d33 --- /dev/null +++ b/node_modules/domutils/lib/traversal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../src/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGpE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAE9C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;AACzD,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAAC;AAW/D;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAe9C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,GACb,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM9D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,GAAG,IAAI,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,GAAG,IAAI,CAI7D"}
\ No newline at end of file diff --git a/node_modules/domutils/lib/traversal.js b/node_modules/domutils/lib/traversal.js new file mode 100644 index 0000000..3a7ff72 --- /dev/null +++ b/node_modules/domutils/lib/traversal.js @@ -0,0 +1,117 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.prevElementSibling = exports.nextElementSibling = exports.getName = exports.hasAttrib = exports.getAttributeValue = exports.getSiblings = exports.getParent = exports.getChildren = void 0; +var domhandler_1 = require("domhandler"); +var emptyArray = []; +/** + * Get a node's children. + * + * @param elem Node to get the children of. + * @returns `elem`'s children, or an empty array. + */ +function getChildren(elem) { + var _a; + return (_a = elem.children) !== null && _a !== void 0 ? _a : emptyArray; +} +exports.getChildren = getChildren; +/** + * Get a node's parent. + * + * @param elem Node to get the parent of. + * @returns `elem`'s parent node. + */ +function getParent(elem) { + return elem.parent || null; +} +exports.getParent = getParent; +/** + * Gets an elements siblings, including the element itself. + * + * Attempts to get the children through the element's parent first. + * If we don't have a parent (the element is a root node), + * we walk the element's `prev` & `next` to get all remaining nodes. + * + * @param elem Element to get the siblings of. + * @returns `elem`'s siblings. + */ +function getSiblings(elem) { + var _a, _b; + var parent = getParent(elem); + if (parent != null) + return getChildren(parent); + var siblings = [elem]; + var prev = elem.prev, next = elem.next; + while (prev != null) { + siblings.unshift(prev); + (_a = prev, prev = _a.prev); + } + while (next != null) { + siblings.push(next); + (_b = next, next = _b.next); + } + return siblings; +} +exports.getSiblings = getSiblings; +/** + * Gets an attribute from an element. + * + * @param elem Element to check. + * @param name Attribute name to retrieve. + * @returns The element's attribute value, or `undefined`. + */ +function getAttributeValue(elem, name) { + var _a; + return (_a = elem.attribs) === null || _a === void 0 ? void 0 : _a[name]; +} +exports.getAttributeValue = getAttributeValue; +/** + * Checks whether an element has an attribute. + * + * @param elem Element to check. + * @param name Attribute name to look for. + * @returns Returns whether `elem` has the attribute `name`. + */ +function hasAttrib(elem, name) { + return (elem.attribs != null && + Object.prototype.hasOwnProperty.call(elem.attribs, name) && + elem.attribs[name] != null); +} +exports.hasAttrib = hasAttrib; +/** + * Get the tag name of an element. + * + * @param elem The element to get the name for. + * @returns The tag name of `elem`. + */ +function getName(elem) { + return elem.name; +} +exports.getName = getName; +/** + * Returns the next element sibling of a node. + * + * @param elem The element to get the next sibling of. + * @returns `elem`'s next sibling that is a tag. + */ +function nextElementSibling(elem) { + var _a; + var next = elem.next; + while (next !== null && !(0, domhandler_1.isTag)(next)) + (_a = next, next = _a.next); + return next; +} +exports.nextElementSibling = nextElementSibling; +/** + * Returns the previous element sibling of a node. + * + * @param elem The element to get the previous sibling of. + * @returns `elem`'s previous sibling that is a tag. + */ +function prevElementSibling(elem) { + var _a; + var prev = elem.prev; + while (prev !== null && !(0, domhandler_1.isTag)(prev)) + (_a = prev, prev = _a.prev); + return prev; +} +exports.prevElementSibling = prevElementSibling; diff --git a/node_modules/domutils/package.json b/node_modules/domutils/package.json new file mode 100644 index 0000000..89e583f --- /dev/null +++ b/node_modules/domutils/package.json @@ -0,0 +1,65 @@ +{ + "name": "domutils", + "version": "2.8.0", + "description": "Utilities for working with htmlparser2's dom", + "author": "Felix Boehm <me@feedic.com>", + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + }, + "license": "BSD-2-Clause", + "sideEffects": false, + "main": "lib/index.js", + "types": "lib/index.d.ts", + "files": [ + "lib/**/*" + ], + "scripts": { + "test": "npm run test:jest && npm run lint", + "test:jest": "jest", + "lint": "npm run lint:es && npm run lint:prettier", + "lint:es": "eslint --ignore-path .gitignore .", + "lint:prettier": "npm run prettier -- --check", + "format": "npm run format:es && npm run format:prettier", + "format:es": "npm run lint:es -- --fix", + "format:prettier": "npm run prettier -- --write", + "prettier": "prettier \"**/*.{ts,md,json,yml}\" --ignore-path .gitignore", + "build": "tsc", + "build:docs": "typedoc --hideGenerator --exclude \"**/*+(index|.spec).ts\" src", + "prepare": "npm run build" + }, + "repository": { + "type": "git", + "url": "git://github.com/fb55/domutils.git" + }, + "keywords": [ + "dom", + "htmlparser2" + ], + "dependencies": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + }, + "devDependencies": { + "@types/jest": "^27.0.1", + "@types/node": "^16.7.2", + "@typescript-eslint/eslint-plugin": "^4.29.3", + "@typescript-eslint/parser": "^4.29.3", + "eslint": "^7.32.0", + "eslint-config-prettier": "^8.1.0", + "eslint-plugin-jsdoc": "^36.0.8", + "htmlparser2": "~7.0.0", + "jest": "^27.1.0", + "prettier": "^2.0.5", + "ts-jest": "^27.0.5", + "typedoc": "^0.21.6", + "typescript": "^4.4.2" + }, + "jest": { + "preset": "ts-jest", + "testEnvironment": "node" + }, + "prettier": { + "tabWidth": 4 + } +} diff --git a/node_modules/domutils/readme.md b/node_modules/domutils/readme.md new file mode 100644 index 0000000..95883b5 --- /dev/null +++ b/node_modules/domutils/readme.md @@ -0,0 +1,31 @@ +# domutils [![Build Status](https://travis-ci.com/fb55/domutils.svg?branch=master)](https://travis-ci.com/fb55/domutils) + +Utilities for working with [htmlparser2](https://github.com/fb55/htmlparser2)'s DOM. + +All functions are exported as a single module. Look [through the docs](https://domutils.js.org/modules.html) to see what is available. + +## Ecosystem + +| Name | Description | +| ------------------------------------------------------------- | ------------------------------------------------------- | +| [htmlparser2](https://github.com/fb55/htmlparser2) | Fast & forgiving HTML/XML parser | +| [domhandler](https://github.com/fb55/domhandler) | Handler for htmlparser2 that turns documents into a DOM | +| [domutils](https://github.com/fb55/domutils) | Utilities for working with domhandler's DOM | +| [css-select](https://github.com/fb55/css-select) | CSS selector engine, compatible with domhandler's DOM | +| [cheerio](https://github.com/cheeriojs/cheerio) | The jQuery API for domhandler's DOM | +| [dom-serializer](https://github.com/cheeriojs/dom-serializer) | Serializer for domhandler's DOM | + +--- + +License: BSD-2-Clause + +## Security contact information + +To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). +Tidelift will coordinate the fix and disclosure. + +## `domutils` for enterprise + +Available as part of the Tidelift Subscription + +The maintainers of `domutils` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-domutils?utm_source=npm-domutils&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) |