merge csv data to topo

This commit is contained in:
Library Map Bot 2022-09-03 07:12:22 +00:00 committed by github-actions[bot]
parent a4f6db9c35
commit be044ccbd2
241 changed files with 5568 additions and 14575 deletions

55
node_modules/boolbase/package.json generated vendored
View file

@ -1,52 +1,23 @@
{
"_from": "boolbase@^1.0.0",
"_id": "boolbase@1.0.0",
"_inBundle": false,
"_integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=",
"_location": "/boolbase",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "boolbase@^1.0.0",
"name": "boolbase",
"escapedName": "boolbase",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/css-select",
"/nth-check"
],
"_resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"_shasum": "68dff5fbe60c51eb37725ea9e3ed310dcc1e776e",
"_spec": "boolbase@^1.0.0",
"_where": "/home/runner/work/public_library_map/public_library_map/node_modules/css-select",
"author": {
"name": "Felix Boehm",
"email": "me@feedic.com"
},
"bugs": {
"url": "https://github.com/fb55/boolbase/issues"
},
"bundleDependencies": false,
"deprecated": false,
"version": "1.0.0",
"description": "two functions: One that returns true, one that returns false",
"homepage": "https://github.com/fb55/boolbase",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/fb55/boolbase"
},
"keywords": [
"boolean",
"function"
],
"author": "Felix Boehm <me@feedic.com>",
"license": "ISC",
"main": "index.js",
"name": "boolbase",
"repository": {
"type": "git",
"url": "git+https://github.com/fb55/boolbase.git"
"bugs": {
"url": "https://github.com/fb55/boolbase/issues"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.0"
"homepage": "https://github.com/fb55/boolbase"
}

View file

@ -1,5 +1,5 @@
import type { Node } from "domhandler";
import type { AnyNode } from "domhandler";
import type { Selector } from "css-what";
export declare function getDocumentRoot(node: Node): Node;
export declare function getDocumentRoot(node: AnyNode): AnyNode;
export declare function groupSelectors(selectors: Selector[][]): [plain: Selector[][], filtered: Selector[][]];
//# sourceMappingURL=helpers.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAGhD;AAED,wBAAgB,cAAc,CAC1B,SAAS,EAAE,QAAQ,EAAE,EAAE,GACxB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,CAa/C"}
{"version":3,"file":"helpers.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio-select/ef063a6ca4c3f0d02d2fc3505e750b6fb81c448d/src/","sources":["helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAGtD;AAED,wBAAgB,cAAc,CAC1B,SAAS,EAAE,QAAQ,EAAE,EAAE,GACxB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,CAa/C"}

View file

@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.groupSelectors = exports.getDocumentRoot = void 0;
var positionals_1 = require("./positionals");
var positionals_js_1 = require("./positionals.js");
function getDocumentRoot(node) {
while (node.parent)
node = node.parent;
@ -13,7 +13,7 @@ function groupSelectors(selectors) {
var plainSelectors = [];
for (var _i = 0, selectors_1 = selectors; _i < selectors_1.length; _i++) {
var selector = selectors_1[_i];
if (selector.some(positionals_1.isFilter)) {
if (selector.some(positionals_js_1.isFilter)) {
filteredSelectors.push(selector);
}
else {
@ -23,3 +23,4 @@ function groupSelectors(selectors) {
return [plainSelectors, filteredSelectors];
}
exports.groupSelectors = groupSelectors;
//# sourceMappingURL=helpers.js.map

View file

@ -1,12 +1,12 @@
import { Options as CSSSelectOptions } from "css-select";
import type { Element, Node, Document } from "domhandler";
import { type Options as CSSSelectOptions } from "css-select";
import type { Element, AnyNode, Document } from "domhandler";
export { filters, pseudos, aliases } from "css-select";
export interface Options extends CSSSelectOptions<Node, Element> {
export interface Options extends CSSSelectOptions<AnyNode, Element> {
/** Optional reference to the root of the document. If not set, this will be computed when needed. */
root?: Document;
}
export declare function is(element: Element, selector: string | ((el: Element) => boolean), options?: Options): boolean;
export declare function some(elements: Element[], selector: string | ((el: Element) => boolean), options?: Options): boolean;
export declare function filter(selector: string, elements: Node[], options?: Options): Element[];
export declare function select(selector: string | ((el: Element) => boolean), root: Node | Node[], options?: Options): Element[];
export declare function filter(selector: string, elements: AnyNode[], options?: Options): Element[];
export declare function select(selector: string | ((el: Element) => boolean), root: AnyNode | AnyNode[], options?: Options, limit?: number): Element[];
//# sourceMappingURL=index.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,OAAO,IAAI,gBAAgB,EAE9B,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAYvD,MAAM,WAAW,OAAQ,SAAQ,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC;IAC5D,qGAAqG;IACrG,IAAI,CAAC,EAAE,QAAQ,CAAC;CACnB;AAED,wBAAgB,EAAE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K,OAAO,CAAC,EAC7C,OAAO,GAAE,OAAY,GACtB,OAAO,CAET;AAED,wBAAgB,IAAI,CAChB,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,EAC7C,OAAO,GAAE,OAAY,GACtB,OAAO,CAWT;AAsCD,wBAAgB,MAAM,CAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE,OAAY,GACtB,OAAO,EAAE,CAEX;AAoGD,wBAAgB,MAAM,CAClB,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,EAC7C,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,EACzB,OAAO,GAAE,OAAY,EACrB,KAAK,SAAW,GACjB,OAAO,EAAE,CA2BX"}

View file

@ -12,7 +12,11 @@ var __assign = (this && this.__assign) || function () {
};
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]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
@ -29,32 +33,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.select = exports.filter = exports.some = exports.is = exports.aliases = exports.pseudos = exports.filters = void 0;
var css_what_1 = require("css-what");
var css_select_1 = require("css-select");
var DomUtils = __importStar(require("domutils"));
var helpers_1 = require("./helpers");
var positionals_1 = require("./positionals");
var boolbase = __importStar(require("boolbase"));
var helpers_js_1 = require("./helpers.js");
var positionals_js_1 = require("./positionals.js");
// Re-export pseudo extension points
var css_select_2 = require("css-select");
Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return css_select_2.filters; } });
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return css_select_2.pseudos; } });
Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return css_select_2.aliases; } });
/** Used to indicate a scope should be filtered. Might be ignored when filtering. */
var UNIVERSAL_SELECTOR = {
type: css_what_1.SelectorType.Universal,
namespace: null,
};
var SCOPE_PSEUDO = {
type: "pseudo",
type: css_what_1.SelectorType.Pseudo,
name: "scope",
data: null,
};
/** Used for actually filtering for scope. */
var CUSTOM_SCOPE_PSEUDO = __assign({}, SCOPE_PSEUDO);
var UNIVERSAL_SELECTOR = { type: "universal", namespace: null };
function is(element, selector, options) {
if (options === void 0) { options = {}; }
return some([element], selector, options);
@ -64,8 +73,8 @@ function some(elements, selector, options) {
if (options === void 0) { options = {}; }
if (typeof selector === "function")
return elements.some(selector);
var _a = helpers_1.groupSelectors(css_what_1.parse(selector, options)), plain = _a[0], filtered = _a[1];
return ((plain.length > 0 && elements.some(css_select_1._compileToken(plain, options))) ||
var _a = (0, helpers_js_1.groupSelectors)((0, css_what_1.parse)(selector)), plain = _a[0], filtered = _a[1];
return ((plain.length > 0 && elements.some((0, css_select_1._compileToken)(plain, options))) ||
filtered.some(function (sel) { return filterBySelector(sel, elements, options).length > 0; }));
}
exports.some = some;
@ -97,7 +106,7 @@ function filterByPosition(filter, elems, data, options) {
}
function filter(selector, elements, options) {
if (options === void 0) { options = {}; }
return filterParsed(css_what_1.parse(selector, options), elements, options);
return filterParsed((0, css_what_1.parse)(selector), elements, options);
}
exports.filter = filter;
/**
@ -112,7 +121,7 @@ exports.filter = filter;
function filterParsed(selector, elements, options) {
if (elements.length === 0)
return [];
var _a = helpers_1.groupSelectors(selector), plainSelectors = _a[0], filteredSelectors = _a[1];
var _a = (0, helpers_js_1.groupSelectors)(selector), plainSelectors = _a[0], filteredSelectors = _a[1];
var found;
if (plainSelectors.length) {
var filtered = filterElements(elements, plainSelectors, options);
@ -165,78 +174,70 @@ function filterBySelector(selector, elements, options) {
* Get root node, run selector with the scope
* set to all of our nodes.
*/
var root = (_a = options.root) !== null && _a !== void 0 ? _a : helpers_1.getDocumentRoot(elements[0]);
var sel = __spreadArray(__spreadArray([], selector), [CUSTOM_SCOPE_PSEUDO]);
return findFilterElements(root, sel, options, true, elements);
var root = (_a = options.root) !== null && _a !== void 0 ? _a : (0, helpers_js_1.getDocumentRoot)(elements[0]);
var opts = __assign(__assign({}, options), { context: elements, relativeSelector: false });
selector.push(SCOPE_PSEUDO);
return findFilterElements(root, selector, opts, true, elements.length);
}
// Performance optimization: If we don't have to traverse, just filter set.
return findFilterElements(elements, selector, options, false);
return findFilterElements(elements, selector, options, false, elements.length);
}
function select(selector, root, options) {
function select(selector, root, options, limit) {
if (options === void 0) { options = {}; }
if (limit === void 0) { limit = Infinity; }
if (typeof selector === "function") {
return find(root, selector);
}
var _a = helpers_1.groupSelectors(css_what_1.parse(selector, options)), plain = _a[0], filtered = _a[1];
var _a = (0, helpers_js_1.groupSelectors)((0, css_what_1.parse)(selector)), plain = _a[0], filtered = _a[1];
var results = filtered.map(function (sel) {
return findFilterElements(root, sel, options, true);
return findFilterElements(root, sel, options, true, limit);
});
// Plain selectors can be queried in a single go
if (plain.length) {
results.push(findElements(root, plain, options, Infinity));
results.push(findElements(root, plain, options, limit));
}
if (results.length === 0) {
return [];
}
// If there was only a single selector, just return the result
if (results.length === 1) {
return results[0];
}
// Sort results, filtering for duplicates
return DomUtils.uniqueSort(results.reduce(function (a, b) { return __spreadArray(__spreadArray([], a), b); }));
return DomUtils.uniqueSort(results.reduce(function (a, b) { return __spreadArray(__spreadArray([], a, true), b, true); }));
}
exports.select = select;
// Traversals that are treated differently in css-select.
var specialTraversal = new Set(["descendant", "adjacent"]);
function includesScopePseudo(t) {
return (t !== SCOPE_PSEUDO &&
t.type === "pseudo" &&
(t.name === "scope" ||
(Array.isArray(t.data) &&
t.data.some(function (data) { return data.some(includesScopePseudo); }))));
}
function addContextIfScope(selector, options, scopeContext) {
return scopeContext && selector.some(includesScopePseudo)
? __assign(__assign({}, options), { context: scopeContext }) : options;
}
/**
*
* @param root Element(s) to search from.
* @param selector Selector to look for.
* @param options Options for querying.
* @param queryForSelector Query multiple levels deep for the initial selector, even if it doesn't contain a traversal.
* @param scopeContext Optional context for a :scope.
*/
function findFilterElements(root, selector, options, queryForSelector, scopeContext) {
var filterIndex = selector.findIndex(positionals_1.isFilter);
function findFilterElements(root, selector, options, queryForSelector, totalLimit) {
var filterIndex = selector.findIndex(positionals_js_1.isFilter);
var sub = selector.slice(0, filterIndex);
var filter = selector[filterIndex];
// If we are at the end of the selector, we can limit the number of elements to retrieve.
var partLimit = selector.length - 1 === filterIndex ? totalLimit : Infinity;
/*
* Set the number of elements to retrieve.
* Eg. for :first, we only have to get a single element.
*/
var limit = positionals_1.getLimit(filter.name, filter.data);
var limit = (0, positionals_js_1.getLimit)(filter.name, filter.data, partLimit);
if (limit === 0)
return [];
var subOpts = addContextIfScope(sub, options, scopeContext);
/*
* Skip `findElements` call if our selector starts with a positional
* pseudo.
*/
var elemsNoLimit = sub.length === 0 && !Array.isArray(root)
? DomUtils.getChildren(root).filter(DomUtils.isTag)
: sub.length === 0 || (sub.length === 1 && sub[0] === SCOPE_PSEUDO)
: sub.length === 0
? (Array.isArray(root) ? root : [root]).filter(DomUtils.isTag)
: queryForSelector || sub.some(css_what_1.isTraversal)
? findElements(root, [sub], subOpts, limit)
: filterElements(root, [sub], subOpts);
? findElements(root, [sub], options, limit)
: filterElements(root, [sub], options);
var elems = elemsNoLimit.slice(0, limit);
var result = filterByPosition(filter.name, elems, filter.data, options);
if (result.length === 0 || selector.length === filterIndex + 1) {
@ -244,22 +245,28 @@ function findFilterElements(root, selector, options, queryForSelector, scopeCont
}
var remainingSelector = selector.slice(filterIndex + 1);
var remainingHasTraversal = remainingSelector.some(css_what_1.isTraversal);
var remainingOpts = addContextIfScope(remainingSelector, options, scopeContext);
if (remainingHasTraversal) {
/*
* Some types of traversals have special logic when they start a selector
* in css-select. If this is the case, add a universal selector in front of
* the selector to avoid this behavior.
*/
if (specialTraversal.has(remainingSelector[0].type)) {
if ((0, css_what_1.isTraversal)(remainingSelector[0])) {
var type = remainingSelector[0].type;
if (type === css_what_1.SelectorType.Sibling ||
type === css_what_1.SelectorType.Adjacent) {
// If we have a sibling traversal, we need to also look at the siblings.
result = (0, css_select_1.prepareContext)(result, DomUtils, true);
}
// Avoid a traversal-first selector error.
remainingSelector.unshift(UNIVERSAL_SELECTOR);
}
options = __assign(__assign({}, options), {
// Avoid absolutizing the selector
relativeSelector: false,
/*
* Add a scope token in front of the remaining selector,
* to make sure traversals don't match elements that aren't a
* part of the considered tree.
* Add a custom root func, to make sure traversals don't match elements
* that aren't a part of the considered tree.
*/
remainingSelector.unshift(SCOPE_PSEUDO);
rootFunc: function (el) { return result.includes(el); } });
}
else if (options.rootFunc && options.rootFunc !== boolbase.trueFunc) {
options = __assign(__assign({}, options), { rootFunc: boolbase.trueFunc });
}
/*
* If we have another filter, recursively call `findFilterElements`,
@ -268,29 +275,28 @@ function findFilterElements(root, selector, options, queryForSelector, scopeCont
*
* Otherwise,
*/
return remainingSelector.some(positionals_1.isFilter)
? findFilterElements(result, remainingSelector, options, false, scopeContext)
return remainingSelector.some(positionals_js_1.isFilter)
? findFilterElements(result, remainingSelector, options, false, totalLimit)
: remainingHasTraversal
? // Query existing elements to resolve traversal.
findElements(result, [remainingSelector], remainingOpts, Infinity)
findElements(result, [remainingSelector], options, totalLimit)
: // If we don't have any more traversals, simply filter elements.
filterElements(result, [remainingSelector], remainingOpts);
filterElements(result, [remainingSelector], options);
}
function findElements(root, sel, options, limit) {
if (limit === 0)
return [];
var query = css_select_1._compileToken(sel, options, root);
var query = (0, css_select_1._compileToken)(sel, options, root);
return find(root, query, limit);
}
function find(root, query, limit) {
if (limit === void 0) { limit = Infinity; }
var elems = css_select_1.prepareContext(root, DomUtils, query.shouldTestNextSiblings);
var elems = (0, css_select_1.prepareContext)(root, DomUtils, query.shouldTestNextSiblings);
return DomUtils.find(function (node) { return DomUtils.isTag(node) && query(node); }, elems, true, limit);
}
function filterElements(elements, sel, options) {
var els = (Array.isArray(elements) ? elements : [elements]).filter(DomUtils.isTag);
if (els.length === 0)
return els;
var query = css_select_1._compileToken(sel, options);
return els.filter(query);
var query = (0, css_select_1._compileToken)(sel, options);
return query === boolbase.trueFunc ? els : els.filter(query);
}
//# sourceMappingURL=index.js.map

View file

@ -6,5 +6,5 @@ export interface CheerioSelector extends PseudoSelector {
data: string | null;
}
export declare function isFilter(s: Selector): s is CheerioSelector;
export declare function getLimit(filter: Filter, data: string | null): number;
export declare function getLimit(filter: Filter, data: string | null, partLimit: number): number;
//# sourceMappingURL=positionals.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"positionals.d.ts","sourceRoot":"","sources":["../src/positionals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEzD,oBAAY,MAAM,GACZ,OAAO,GACP,MAAM,GACN,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,MAAM,GACN,KAAK,GACL,KAAK,CAAC;AACZ,eAAO,MAAM,WAAW,EAAE,GAAG,CAAC,MAAM,CASlC,CAAC;AAEH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,IAAI,eAAe,CAS1D;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBpE"}
{"version":3,"file":"positionals.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio-select/ef063a6ca4c3f0d02d2fc3505e750b6fb81c448d/src/","sources":["positionals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEzD,oBAAY,MAAM,GACZ,OAAO,GACP,MAAM,GACN,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,MAAM,GACN,KAAK,GACL,KAAK,CAAC;AACZ,eAAO,MAAM,WAAW,EAAE,GAAG,CAAC,MAAM,CASlC,CAAC;AAEH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,IAAI,eAAe,CAS1D;AAED,wBAAgB,QAAQ,CACpB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,SAAS,EAAE,MAAM,GAClB,MAAM,CAyBR"}

View file

@ -23,7 +23,7 @@ function isFilter(s) {
return false;
}
exports.isFilter = isFilter;
function getLimit(filter, data) {
function getLimit(filter, data, partLimit) {
var num = data != null ? parseInt(data, 10) : NaN;
switch (filter) {
case "first":
@ -32,11 +32,21 @@ function getLimit(filter, data) {
case "eq":
return isFinite(num) ? (num >= 0 ? num + 1 : Infinity) : 0;
case "lt":
return isFinite(num) ? (num >= 0 ? num : Infinity) : 0;
return isFinite(num)
? num >= 0
? Math.min(num, partLimit)
: Infinity
: 0;
case "gt":
return isFinite(num) ? Infinity : 0;
default:
case "odd":
return 2 * partLimit;
case "even":
return 2 * partLimit - 1;
case "last":
case "not":
return Infinity;
}
}
exports.getLimit = getLimit;
//# sourceMappingURL=positionals.js.map

View file

@ -1,95 +1,76 @@
{
"_from": "cheerio-select@^1.5.0",
"_id": "cheerio-select@1.5.0",
"_inBundle": false,
"_integrity": "sha512-qocaHPv5ypefh6YNxvnbABM07KMxExbtbfuJoIie3iZXX1ERwYmJcIiRrr9H05ucQP1k28dav8rpdDgjQd8drg==",
"_location": "/cheerio-select",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "cheerio-select@^1.5.0",
"name": "cheerio-select",
"escapedName": "cheerio-select",
"rawSpec": "^1.5.0",
"saveSpec": null,
"fetchSpec": "^1.5.0"
},
"_requiredBy": [
"/cheerio"
],
"_resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-1.5.0.tgz",
"_shasum": "faf3daeb31b17c5e1a9dabcee288aaf8aafa5823",
"_spec": "cheerio-select@^1.5.0",
"_where": "/home/runner/work/public_library_map/public_library_map/node_modules/cheerio",
"author": {
"name": "Felix Boehm",
"email": "me@feedic.com"
},
"bugs": {
"url": "https://github.com/cheeriojs/cheerio-select/issues"
},
"bundleDependencies": false,
"dependencies": {
"css-select": "^4.1.3",
"css-what": "^5.0.1",
"domelementtype": "^2.2.0",
"domhandler": "^4.2.0",
"domutils": "^2.7.0"
},
"deprecated": false,
"description": "CSS selector engine supporting jQuery selectors",
"devDependencies": {
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"coveralls": "^3.1.0",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"htmlparser2": "^6.1.0",
"jest": "^27.0.4",
"prettier": "^2.3.1",
"ts-jest": "^27.0.3",
"typescript": "^4.3.2"
},
"directories": {
"lib": "lib/"
},
"files": [
"lib/**/*"
],
"version": "2.1.0",
"author": "Felix Boehm <me@feedic.com>",
"funding": {
"url": "https://github.com/sponsors/fb55"
},
"homepage": "https://github.com/cheeriojs/cheerio-select#readme",
"jest": {
"preset": "ts-jest",
"testEnvironment": "node"
},
"license": "BSD-2-Clause",
"main": "lib/index.js",
"name": "cheerio-select",
"prettier": {
"tabWidth": 4
},
"sideEffects": false,
"repository": {
"type": "git",
"url": "git://github.com/cheeriojs/cheerio-select.git"
},
"directories": {
"lib": "lib/"
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"module": "lib/esm/index.js",
"exports": {
"require": "./lib/index.js",
"import": "./lib/esm/index.js"
},
"files": [
"lib/**/*"
],
"scripts": {
"build": "tsc",
"coverage": "cat coverage/lcov.info | coveralls",
"test": "npm run test:jest && npm run lint",
"test:jest": "jest",
"lint": "npm run lint:es && npm run lint:prettier",
"lint:es": "eslint src",
"lint:prettier": "npm run format:prettier:raw -- --check",
"format": "npm run format:es && npm run format:prettier",
"format:es": "npm run lint:es -- --fix",
"format:prettier": "npm run format:prettier:raw -- --write",
"format:prettier:raw": "prettier '**/*.{ts,md,json,yml}'",
"lint": "npm run lint:es && npm run lint:prettier",
"lint:es": "eslint src",
"lint:prettier": "npm run format:prettier:raw -- --check",
"prepare": "npm run build",
"test": "jest --coverage && npm run lint"
"build": "npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --sourceRoot https://raw.githubusercontent.com/cheeriojs/cheerio-select/$(git rev-parse HEAD)/src/",
"build:esm": "npm run build:cjs -- --module esnext --target es2019 --outDir lib/esm && echo '{\"type\":\"module\"}' > lib/esm/package.json",
"prepare": "npm run build"
},
"sideEffects": false,
"types": "lib/index.d.ts",
"version": "1.5.0"
"dependencies": {
"boolbase": "^1.0.0",
"css-select": "^5.1.0",
"css-what": "^6.1.0",
"domelementtype": "^2.3.0",
"domhandler": "^5.0.3",
"domutils": "^3.0.1"
},
"devDependencies": {
"@types/boolbase": "^1.0.1",
"@types/jest": "^27.5.0",
"@types/node": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.5.0",
"htmlparser2": "^8.0.1",
"jest": "^27.5.1",
"prettier": "^2.6.2",
"ts-jest": "^27.1.4",
"typescript": "^4.6.4"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"coverageProvider": "v8",
"moduleNameMapper": {
"^(.*)\\.js$": "$1"
}
},
"prettier": {
"tabWidth": 4
}
}

2
node_modules/cheerio/LICENSE generated vendored
View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2016 Matt Mueller
Copyright (c) 2022 The Cheerio contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

80
node_modules/cheerio/Readme.md generated vendored
View file

@ -53,7 +53,7 @@ Cheerio wraps around [parse5](https://github.com/inikulin/parse5) parser and can
## Cheerio is not a web browser
Cheerio parses markup and provides an API for traversing/manipulating the resulting data structure. It does not interpret the result as a web browser does. Specifically, it does _not_ produce a visual rendering, apply CSS, load external resources, or execute JavaScript. This makes Cheerio **much, much faster than other solutions**. If your use case requires any of this functionality, you should consider projects like [Puppeteer](https://github.com/puppeteer/puppeteer) or [JSDom](https://github.com/jsdom/jsdom).
Cheerio parses markup and provides an API for traversing/manipulating the resulting data structure. It does not interpret the result as a web browser does. Specifically, it does _not_ produce a visual rendering, apply CSS, load external resources, or execute JavaScript which is common for a SPA (single page application). This makes Cheerio **much, much faster than other solutions**. If your use case requires any of this functionality, you should consider browser automation software like [Puppeteer](https://github.com/puppeteer/puppeteer) and [Playwright](https://github.com/microsoft/playwright) or DOM emulation projects like [JSDom](https://github.com/jsdom/jsdom).
## API
@ -134,6 +134,11 @@ The options in the `xml` object are taken directly from [htmlparser2](https://gi
For a full list of options and their effects, see [domhandler](https://github.com/fb55/DomHandler) and
[htmlparser2's options](https://github.com/fb55/htmlparser2/wiki/Parser-options).
#### Using `htmlparser2`
Cheerio ships with two parsers, `parse5` and `htmlparser2`. The
former is the default for HTML, the latter the default for XML.
Some users may wish to parse markup with the `htmlparser2` library, and
traverse/manipulate the resulting structure with Cheerio. This may be the case
for those upgrading from pre-1.0 releases of Cheerio (which relied on
@ -156,6 +161,13 @@ const dom = htmlparser2.parseDocument(document, options);
const $ = cheerio.load(dom);
```
If you want to save some bytes, you can use Cheerio's _slim_ export, which
always uses `htmlparser2`:
```js
const cheerio = require('cheerio/lib/slim');
```
### Selectors
Cheerio's selector implementation is nearly identical to jQuery's, so the API is very similar.
@ -210,21 +222,6 @@ cheerio.html($('.pear'));
//=> <li class="pear">Pear</li>
```
By default, `html` will leave some tags open. Sometimes you may instead want to render a valid XML document. For example, you might parse the following XML snippet:
```js
const $ = cheerio.load(
'<media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123"/>'
);
```
... and later want to render to XML. To do this, you can use the 'xml' utility function:
```js
$.xml();
//=> <media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123"/>
```
You may also render the text content of a Cheerio object using the `text` static method:
```js
@ -246,7 +243,7 @@ $.prototype.logHtml = function () {
$('body').logHtml(); // logs "Hello, <b>world</b>!" to the console
```
If you're using TypeScript, you should also add a type definition for your new method:
If you're using TypeScript, you should add a type definition for your new method:
```ts
declare module 'cheerio' {
@ -285,8 +282,30 @@ Does your company use Cheerio in production? Please consider [sponsoring this pr
<!-- BEGIN SPONSORS: sponsor -->
<a href="https://substack.com/" target="_blank">![Substack](https://avatars.githubusercontent.com/u/53023767?v=4&s=128)</a>
<a href="https://www.airbnb.com/" target="_blank">![Airbnb](https://images.opencollective.com/airbnb/d327d66/logo.png)</a>
<a href="https://github.com/about" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://avatars.githubusercontent.com/u/9919?v=4&s=128" title="GitHub" alt="GitHub"></img>
</a>
<a href="https://cryptocasinos.com/" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/cryptocasinos/99b168e/logo.png" title="CryptoCasinos" alt="CryptoCasinos"></img>
</a>
<a href="https://www.casinoonlineaams.com" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/casinoonlineaamscom/da74236/logo.png" title="Casinoonlineaams.com" alt="Casinoonlineaams.com"></img>
</a>
<a href="https://casinofiables.com/" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/casinofiables-com/b824bab/logo.png" title="Casinofiables.com" alt="Casinofiables.com"></img>
</a>
<a href="https://apify.com/" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://avatars.githubusercontent.com/u/24586296?v=4&s=128" title="Apify" alt="Apify"></img>
</a>
<a href="https://freebets.ltd.uk" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/freebets/e21c41b/logo.png" title="Free Bets" alt="Free Bets"></img>
</a>
<a href="https://casinoutansvensklicens.co/" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/casino-utan-svensk-licens3/f7e9357/logo.png" title="Casino utan svensk licens" alt="Casino utan svensk licens"></img>
</a>
<a href="https://starwarscasinos.com/" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/casino-utan-svensk-licens1/f3487ff/logo.png" title="Casino utan svensk licens" alt="Casino utan svensk licens"></img>
</a>
<!-- END SPONSORS -->
@ -296,8 +315,27 @@ Does your company use Cheerio in production? Please consider [sponsoring this pr
<!-- BEGIN SPONSORS: backer -->
<a href="https://medium.com/norch" target="_blank">![Espen Klem](https://images.opencollective.com/espenklem/6075b19/avatar.png)</a>
<a href="https://nishant-singh.com" target="_blank">![Nishant Singh](https://avatars.githubusercontent.com/u/10304344?u=9cd1389a1a8211b64979ca3693f96d90f5bf0be9&v=4&s=128)</a>
<a href="https://www.airbnb.com/" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/airbnb/d327d66/logo.png" title="Airbnb" alt="Airbnb"></img>
</a>
<a href="https://kafidoff.com" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/kafidoff-vasy/d7ff85c/avatar.png" title="Vasy Kafidoff" alt="Vasy Kafidoff"></img>
</a>
<a href="https://medium.com/norch" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://images.opencollective.com/espenklem/6075b19/avatar.png" title="Espen Klem" alt="Espen Klem"></img>
</a>
<a href="https://jarrodldavis.com" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://avatars.githubusercontent.com/u/235875?v=4&s=128" title="Jarrod Davis" alt="Jarrod Davis"></img>
</a>
<a href="https://nishant-singh.com" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://avatars.githubusercontent.com/u/10304344?u=2f98c0a745b5352c6e758b9a5bc7a9d9d4e3e969&v=4&s=128" title="Nishant Singh" alt="Nishant Singh"></img>
</a>
<a href="https://github.com/gauthamchandra" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://avatars.githubusercontent.com/u/5430280?u=1115bcd3ed7aa8b2a62ff28f62ee4c2b92729903&v=4&s=128" title="Gautham Chandra" alt="Gautham Chandra"></img>
</a>
<a href="http://www.dr-chuck.com/" target="_blank" rel="noopener noreferrer">
<img style="max-height:128px;max-width:128px" src="https://avatars.githubusercontent.com/u/1197222?u=d6dc85c064736ab851c6d9e3318dcdd1be00fb2c&v=4&s=128" title="Charles Severance" alt="Charles Severance"></img>
</a>
<!-- END SPONSORS -->

View file

@ -3,8 +3,8 @@
*
* @module cheerio/attributes
*/
import type { Node, Element } from 'domhandler';
import type { Cheerio } from '../cheerio';
import type { AnyNode, Element } from 'domhandler';
import type { Cheerio } from '../cheerio.js';
/**
* Method for getting attributes. Gets the attribute value for only the first
* element in the matched set.
@ -21,7 +21,7 @@ import type { Cheerio } from '../cheerio';
* @returns The attribute's value.
* @see {@link https://api.jquery.com/attr/}
*/
export declare function attr<T extends Node>(this: Cheerio<T>, name: string): string | undefined;
export declare function attr<T extends AnyNode>(this: Cheerio<T>, name: string): string | undefined;
/**
* Method for getting all attributes and their values of the first element in
* the matched set.
@ -37,7 +37,7 @@ export declare function attr<T extends Node>(this: Cheerio<T>, name: string): st
* @returns The attribute's values.
* @see {@link https://api.jquery.com/attr/}
*/
export declare function attr<T extends Node>(this: Cheerio<T>): Record<string, string>;
export declare function attr<T extends AnyNode>(this: Cheerio<T>): Record<string, string> | undefined;
/**
* Method for setting attributes. Sets the attribute value for only the first
* element in the matched set. If you set an attribute's value to `null`, you
@ -56,7 +56,7 @@ export declare function attr<T extends Node>(this: Cheerio<T>): Record<string, s
* @returns The instance itself.
* @see {@link https://api.jquery.com/attr/}
*/
export declare function attr<T extends Node>(this: Cheerio<T>, name: string, value?: string | null | ((this: Element, i: number, attrib: string) => string | null)): Cheerio<T>;
export declare function attr<T extends AnyNode>(this: Cheerio<T>, name: string, value?: string | null | ((this: Element, i: number, attrib: string) => string | null)): Cheerio<T>;
/**
* Method for setting multiple attributes at once. Sets the attribute value for
* only the first element in the matched set. If you set an attribute's value to
@ -74,7 +74,7 @@ export declare function attr<T extends Node>(this: Cheerio<T>, name: string, val
* @returns The instance itself.
* @see {@link https://api.jquery.com/attr/}
*/
export declare function attr<T extends Node>(this: Cheerio<T>, values: Record<string, string | null>): Cheerio<T>;
export declare function attr<T extends AnyNode>(this: Cheerio<T>, values: Record<string, string | null>): Cheerio<T>;
interface StyleProp {
length: number;
[key: string]: string | number;
@ -100,14 +100,29 @@ interface StyleProp {
* @returns If `value` is specified the instance itself, otherwise the prop's value.
* @see {@link https://api.jquery.com/prop/}
*/
export declare function prop<T extends Node>(this: Cheerio<T>, name: 'tagName' | 'nodeName'): T extends Element ? string : undefined;
export declare function prop<T extends Node>(this: Cheerio<T>, name: 'innerHTML' | 'outerHTML'): string | null;
export declare function prop<T extends Node>(this: Cheerio<T>, name: 'style'): StyleProp;
export declare function prop<T extends Node, K extends keyof Element>(this: Cheerio<T>, name: K): Element[K];
export declare function prop<T extends Node, K extends keyof Element>(this: Cheerio<T>, name: K, value: Element[K] | ((this: Element, i: number, prop: K) => Element[keyof Element])): Cheerio<T>;
export declare function prop<T extends Node>(this: Cheerio<T>, name: Record<string, string | Element[keyof Element] | boolean>): Cheerio<T>;
export declare function prop<T extends Node>(this: Cheerio<T>, name: string, value: string | boolean | null | ((this: Element, i: number, prop: string) => string | boolean)): Cheerio<T>;
export declare function prop<T extends Node>(this: Cheerio<T>, name: string): string;
export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: 'tagName' | 'nodeName'): T extends Element ? string : undefined;
export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: 'innerHTML' | 'outerHTML' | 'innerText' | 'textContent'): string | null;
/** Get a parsed CSS style object. */
export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: 'style'): StyleProp | undefined;
/**
* Resolve `href` or `src` of supported elements. Requires the `baseURI` option
* to be set, and a global `URL` object to be part of the environment.
*
* @example With `baseURI` set to `'https://example.com'`:
*
* ```js
* $('<img src="image.png">').prop('src');
* //=> 'https://example.com/image.png'
* ```
*/
export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: 'href' | 'src'): string | undefined;
/** Get a property of an element. */
export declare function prop<T extends AnyNode, K extends keyof Element>(this: Cheerio<T>, name: K): Element[K];
/** Set a property of an element. */
export declare function prop<T extends AnyNode, K extends keyof Element>(this: Cheerio<T>, name: K, value: Element[K] | ((this: Element, i: number, prop: K) => Element[keyof Element])): Cheerio<T>;
export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: Record<string, string | Element[keyof Element] | boolean>): Cheerio<T>;
export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: string, value: string | boolean | null | ((this: Element, i: number, prop: string) => string | boolean)): Cheerio<T>;
export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: string): string;
/**
* Method for getting data attributes, for only the first element in the matched set.
*
@ -120,10 +135,10 @@ export declare function prop<T extends Node>(this: Cheerio<T>, name: string): st
* ```
*
* @param name - Name of the data attribute.
* @returns The data attribute's value.
* @returns The data attribute's value, or `undefined` if the attribute does not exist.
* @see {@link https://api.jquery.com/data/}
*/
export declare function data<T extends Node>(this: Cheerio<T>, name: string): unknown | undefined;
export declare function data<T extends AnyNode>(this: Cheerio<T>, name: string): unknown | undefined;
/**
* Method for getting all of an element's data attributes, for only the first
* element in the matched set.
@ -136,10 +151,10 @@ export declare function data<T extends Node>(this: Cheerio<T>, name: string): un
* //=> { appleColor: 'red' }
* ```
*
* @returns The data attribute's values.
* @returns A map with all of the data attributes.
* @see {@link https://api.jquery.com/data/}
*/
export declare function data<T extends Node>(this: Cheerio<T>): Record<string, unknown>;
export declare function data<T extends AnyNode>(this: Cheerio<T>): Record<string, unknown>;
/**
* Method for setting data attributes, for only the first element in the matched set.
*
@ -158,7 +173,7 @@ export declare function data<T extends Node>(this: Cheerio<T>): Record<string, u
* @returns The instance itself.
* @see {@link https://api.jquery.com/data/}
*/
export declare function data<T extends Node>(this: Cheerio<T>, name: string, value: unknown): Cheerio<T>;
export declare function data<T extends AnyNode>(this: Cheerio<T>, name: string, value: unknown): Cheerio<T>;
/**
* Method for setting multiple data attributes at once, for only the first
* element in the matched set.
@ -177,7 +192,7 @@ export declare function data<T extends Node>(this: Cheerio<T>, name: string, val
* @returns The instance itself.
* @see {@link https://api.jquery.com/data/}
*/
export declare function data<T extends Node>(this: Cheerio<T>, values: Record<string, unknown>): Cheerio<T>;
export declare function data<T extends AnyNode>(this: Cheerio<T>, values: Record<string, unknown>): Cheerio<T>;
/**
* Method for getting the value of input, select, and textarea. Note: Support
* for `map`, and `function` has not been added yet.
@ -193,7 +208,7 @@ export declare function data<T extends Node>(this: Cheerio<T>, values: Record<st
* @returns The value.
* @see {@link https://api.jquery.com/val/}
*/
export declare function val<T extends Node>(this: Cheerio<T>): string | undefined | string[];
export declare function val<T extends AnyNode>(this: Cheerio<T>): string | undefined | string[];
/**
* Method for setting the value of input, select, and textarea. Note: Support
* for `map`, and `function` has not been added yet.
@ -210,7 +225,7 @@ export declare function val<T extends Node>(this: Cheerio<T>): string | undefine
* @returns The instance itself.
* @see {@link https://api.jquery.com/val/}
*/
export declare function val<T extends Node>(this: Cheerio<T>, value: string | string[]): Cheerio<T>;
export declare function val<T extends AnyNode>(this: Cheerio<T>, value: string | string[]): Cheerio<T>;
/**
* Method for removing attributes by `name`.
*
@ -230,9 +245,9 @@ export declare function val<T extends Node>(this: Cheerio<T>, value: string | st
* @returns The instance itself.
* @see {@link https://api.jquery.com/removeAttr/}
*/
export declare function removeAttr<T extends Node>(this: Cheerio<T>, name: string): Cheerio<T>;
export declare function removeAttr<T extends AnyNode>(this: Cheerio<T>, name: string): Cheerio<T>;
/**
* Check to see if *any* of the matched elements have the given `className`.
* Check to see if _any_ of the matched elements have the given `className`.
*
* @category Attributes
* @example
@ -252,7 +267,7 @@ export declare function removeAttr<T extends Node>(this: Cheerio<T>, name: strin
* @returns Indicates if an element has the given `className`.
* @see {@link https://api.jquery.com/hasClass/}
*/
export declare function hasClass<T extends Node>(this: Cheerio<T>, className: string): boolean;
export declare function hasClass<T extends AnyNode>(this: Cheerio<T>, className: string): boolean;
/**
* Adds class(es) to all of the matched elements. Also accepts a `function`.
*
@ -271,7 +286,7 @@ export declare function hasClass<T extends Node>(this: Cheerio<T>, className: st
* @returns The instance itself.
* @see {@link https://api.jquery.com/addClass/}
*/
export declare function addClass<T extends Node, R extends ArrayLike<T>>(this: R, value?: string | ((this: Element, i: number, className: string) => string | undefined)): R;
export declare function addClass<T extends AnyNode, R extends ArrayLike<T>>(this: R, value?: string | ((this: Element, i: number, className: string) => string | undefined)): R;
/**
* Removes one or more space-separated classes from the selected elements. If no
* `className` is defined, all classes will be removed. Also accepts a `function`.
@ -291,7 +306,7 @@ export declare function addClass<T extends Node, R extends ArrayLike<T>>(this: R
* @returns The instance itself.
* @see {@link https://api.jquery.com/removeClass/}
*/
export declare function removeClass<T extends Node, R extends ArrayLike<T>>(this: R, name?: string | ((this: Element, i: number, className: string) => string | undefined)): R;
export declare function removeClass<T extends AnyNode, R extends ArrayLike<T>>(this: R, name?: string | ((this: Element, i: number, className: string) => string | undefined)): R;
/**
* Add or remove class(es) from the matched elements, depending on either the
* class's presence or the value of the switch argument. Also accepts a `function`.
@ -312,6 +327,6 @@ export declare function removeClass<T extends Node, R extends ArrayLike<T>>(this
* @returns The instance itself.
* @see {@link https://api.jquery.com/toggleClass/}
*/
export declare function toggleClass<T extends Node, R extends ArrayLike<T>>(this: R, value?: string | ((this: Element, i: number, className: string, stateVal?: boolean) => string), stateVal?: boolean): R;
export declare function toggleClass<T extends AnyNode, R extends ArrayLike<T>>(this: R, value?: string | ((this: Element, i: number, className: string, stateVal?: boolean) => string), stateVal?: boolean): R;
export {};
//# sourceMappingURL=attributes.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/api/attributes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA6F1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EACjC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAAC;AACtB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EACjC,IAAI,EAAE,OAAO,CAAC,CA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B,OAAO,CAoBT;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAC7D,IAAI,EAAE,CAAC,EACP,KAAK,CAAC,EACF,MAAM,GACN,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GACxE,CAAC,CAyCH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAChE,IAAI,EAAE,CAAC,EACP,IAAI,CAAC,EACD,MAAM,GACN,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GACxE,CAAC,CA0CH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAChE,IAAI,EAAE,CAAC,EACP,KAAK,CAAC,EACF,MAAM,GACN,CAAC,CACC,IAAI,EAAE,OAAO,EACb,CAAC,EAAE,MAAM,EACT,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,OAAO,KACf,MAAM,CAAC,EAChB,QAAQ,CAAC,EAAE,OAAO,GACjB,CAAC,CA+CH"}
{"version":3,"file":"attributes.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["api/attributes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAA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AAO,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GACxE,CAAC,CA2CH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EACnE,IAAI,EAAE,CAAC,EACP,KAAK,CAAC,EACF,MAAM,GACN,CAAC,CACC,IAAI,EAAE,OAAO,EACb,CAAC,EAAE,MAAM,EACT,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,OAAO,KACf,MAAM,CAAC,EAChB,QAAQ,CAAC,EAAE,OAAO,GACjB,CAAC,CA+CH"}

View file

@ -6,8 +6,9 @@
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.toggleClass = exports.removeClass = exports.addClass = exports.hasClass = exports.removeAttr = exports.val = exports.data = exports.prop = exports.attr = void 0;
var static_1 = require("../static");
var utils_1 = require("../utils");
var static_js_1 = require("../static.js");
var utils_js_1 = require("../utils.js");
var domutils_1 = require("domutils");
var hasOwn = Object.prototype.hasOwnProperty;
var rspace = /\s+/;
var dataAttrPrefix = 'data-';
@ -26,7 +27,7 @@ var rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hid
var rbrace = /^{[^]*}$|^\[[^]*]$/;
function getAttr(elem, name, xmlMode) {
var _a;
if (!elem || !utils_1.isTag(elem))
if (!elem || !(0, utils_js_1.isTag)(elem))
return undefined;
(_a = elem.attribs) !== null && _a !== void 0 ? _a : (elem.attribs = {});
// Return the entire attribs object if no attribute specified
@ -39,11 +40,11 @@ function getAttr(elem, name, xmlMode) {
}
// Mimic the DOM and return text content as value for `option's`
if (elem.name === 'option' && name === 'value') {
return static_1.text(elem.children);
return (0, static_js_1.text)(elem.children);
}
// Mimic DOM with default value for radios/checkboxes
if (elem.name === 'input' &&
(elem.attribs.type === 'radio' || elem.attribs.type === 'checkbox') &&
(elem.attribs['type'] === 'radio' || elem.attribs['type'] === 'checkbox') &&
name === 'value') {
return 'on';
}
@ -62,7 +63,7 @@ function setAttr(el, name, value) {
removeAttribute(el, name);
}
else {
el.attribs[name] = "" + value;
el.attribs[name] = "".concat(value);
}
}
function attr(name, value) {
@ -74,13 +75,13 @@ function attr(name, value) {
throw new Error('Bad combination of arguments.');
}
}
return utils_1.domEach(this, function (el, i) {
if (utils_1.isTag(el))
return (0, utils_js_1.domEach)(this, function (el, i) {
if ((0, utils_js_1.isTag)(el))
setAttr(el, name, value.call(el, i, el.attribs[name]));
});
}
return utils_1.domEach(this, function (el) {
if (!utils_1.isTag(el))
return (0, utils_js_1.domEach)(this, function (el) {
if (!(0, utils_js_1.isTag)(el))
return;
if (typeof name === 'object') {
Object.keys(name).forEach(function (objName) {
@ -103,13 +104,11 @@ exports.attr = attr;
*
* @private
* @category Attributes
* @param el - Elenent to get the prop of.
* @param el - Element to get the prop of.
* @param name - Name of the prop.
* @returns The prop's value.
*/
function getProp(el, name, xmlMode) {
if (!el || !utils_1.isTag(el))
return;
return name in el
? // @ts-expect-error TS doesn't like us accessing the value directly here.
el[name]
@ -131,12 +130,16 @@ function setProp(el, name, value, xmlMode) {
el[name] = value;
}
else {
setAttr(el, name, !xmlMode && rboolean.test(name) ? (value ? '' : null) : "" + value);
setAttr(el, name, !xmlMode && rboolean.test(name) ? (value ? '' : null) : "".concat(value));
}
}
function prop(name, value) {
var _this = this;
var _a;
if (typeof name === 'string' && value === undefined) {
var el = this[0];
if (!el || !(0, utils_js_1.isTag)(el))
return undefined;
switch (name) {
case 'style': {
var property_1 = this.css();
@ -149,15 +152,39 @@ function prop(name, value) {
}
case 'tagName':
case 'nodeName': {
var el = this[0];
return utils_1.isTag(el) ? el.name.toUpperCase() : undefined;
return el.name.toUpperCase();
}
case 'href':
case 'src': {
var prop_1 = (_a = el.attribs) === null || _a === void 0 ? void 0 : _a[name];
/* eslint-disable node/no-unsupported-features/node-builtins */
if (typeof URL !== 'undefined' &&
((name === 'href' && (el.tagName === 'a' || el.name === 'link')) ||
(name === 'src' &&
(el.tagName === 'img' ||
el.tagName === 'iframe' ||
el.tagName === 'audio' ||
el.tagName === 'video' ||
el.tagName === 'source'))) &&
prop_1 !== undefined &&
this.options.baseURI) {
return new URL(prop_1, this.options.baseURI).href;
}
/* eslint-enable node/no-unsupported-features/node-builtins */
return prop_1;
}
case 'innerText': {
return (0, domutils_1.innerText)(el);
}
case 'textContent': {
return (0, domutils_1.textContent)(el);
}
case 'outerHTML':
return this.clone().wrap('<container />').parent().html();
case 'innerHTML':
return this.html();
default:
return getProp(this[0], name, this.options.xmlMode);
return getProp(el, name, this.options.xmlMode);
}
}
if (typeof name === 'object' || value !== undefined) {
@ -165,13 +192,14 @@ function prop(name, value) {
if (typeof name === 'object') {
throw new Error('Bad combination of arguments.');
}
return utils_1.domEach(this, function (el, i) {
if (utils_1.isTag(el))
return (0, utils_js_1.domEach)(this, function (el, i) {
if ((0, utils_js_1.isTag)(el)) {
setProp(el, name, value.call(el, i, getProp(el, name, _this.options.xmlMode)), _this.options.xmlMode);
}
});
}
return utils_1.domEach(this, function (el) {
if (!utils_1.isTag(el))
return (0, utils_js_1.domEach)(this, function (el) {
if (!(0, utils_js_1.isTag)(el))
return;
if (typeof name === 'object') {
Object.keys(name).forEach(function (key) {
@ -208,13 +236,13 @@ function setData(el, name, value) {
/**
* Read the specified attribute from the equivalent HTML5 `data-*` attribute,
* and (if present) cache the value in the node's internal data store. If no
* attribute name is specified, read *all* HTML5 `data-*` attributes in this manner.
* attribute name is specified, read _all_ HTML5 `data-*` attributes in this manner.
*
* @private
* @category Attributes
* @param el - Elenent to get the data attribute of.
* @param el - Element to get the data attribute of.
* @param name - Name of the data attribute.
* @returns The data attribute's value, or a map with all of the data attribute.
* @returns The data attribute's value, or a map with all of the data attributes.
*/
function readData(el, name) {
var domNames;
@ -225,11 +253,11 @@ function readData(el, name) {
return attrName.startsWith(dataAttrPrefix);
});
jsNames = domNames.map(function (domName) {
return utils_1.camelCase(domName.slice(dataAttrPrefix.length));
return (0, utils_js_1.camelCase)(domName.slice(dataAttrPrefix.length));
});
}
else {
domNames = [dataAttrPrefix + utils_1.cssCase(name)];
domNames = [dataAttrPrefix + (0, utils_js_1.cssCase)(name)];
jsNames = [name];
}
for (var idx = 0; idx < domNames.length; ++idx) {
@ -260,7 +288,7 @@ function readData(el, name) {
function data(name, value) {
var _a;
var elem = this[0];
if (!elem || !utils_1.isTag(elem))
if (!elem || !(0, utils_js_1.isTag)(elem))
return;
var dataEl = elem;
(_a = dataEl.data) !== null && _a !== void 0 ? _a : (dataEl.data = {});
@ -270,12 +298,13 @@ function data(name, value) {
}
// Set the value (with attr map support)
if (typeof name === 'object' || value !== undefined) {
utils_1.domEach(this, function (el) {
if (utils_1.isTag(el))
(0, utils_js_1.domEach)(this, function (el) {
if ((0, utils_js_1.isTag)(el)) {
if (typeof name === 'object')
setData(el, name);
else
setData(el, name, value);
}
});
return this;
}
@ -288,7 +317,7 @@ exports.data = data;
function val(value) {
var querying = arguments.length === 0;
var element = this[0];
if (!element || !utils_1.isTag(element))
if (!element || !(0, utils_js_1.isTag)(element))
return querying ? undefined : this;
switch (element.name) {
case 'textarea':
@ -302,12 +331,12 @@ function val(value) {
this.find('option').removeAttr('selected');
var values = typeof value !== 'object' ? [value] : value;
for (var i = 0; i < values.length; i++) {
this.find("option[value=\"" + values[i] + "\"]").attr('selected', '');
this.find("option[value=\"".concat(values[i], "\"]")).attr('selected', '');
}
return this;
}
return this.attr('multiple')
? option.toArray().map(function (el) { return static_1.text(el.children); })
? option.toArray().map(function (el) { return (0, static_js_1.text)(el.children); })
: option.attr('value');
}
case 'input':
@ -363,8 +392,8 @@ function splitNames(names) {
function removeAttr(name) {
var attrNames = splitNames(name);
var _loop_1 = function (i) {
utils_1.domEach(this_1, function (elem) {
if (utils_1.isTag(elem))
(0, utils_js_1.domEach)(this_1, function (elem) {
if ((0, utils_js_1.isTag)(elem))
removeAttribute(elem, attrNames[i]);
});
};
@ -376,7 +405,7 @@ function removeAttr(name) {
}
exports.removeAttr = removeAttr;
/**
* Check to see if *any* of the matched elements have the given `className`.
* Check to see if _any_ of the matched elements have the given `className`.
*
* @category Attributes
* @example
@ -398,7 +427,7 @@ exports.removeAttr = removeAttr;
*/
function hasClass(className) {
return this.toArray().some(function (elem) {
var clazz = utils_1.isTag(elem) && elem.attribs.class;
var clazz = (0, utils_js_1.isTag)(elem) && elem.attribs['class'];
var idx = -1;
if (clazz && className.length) {
while ((idx = clazz.indexOf(className, idx + 1)) > -1) {
@ -434,9 +463,9 @@ exports.hasClass = hasClass;
function addClass(value) {
// Support functions
if (typeof value === 'function') {
return utils_1.domEach(this, function (el, i) {
if (utils_1.isTag(el)) {
var className = el.attribs.class || '';
return (0, utils_js_1.domEach)(this, function (el, i) {
if ((0, utils_js_1.isTag)(el)) {
var className = el.attribs['class'] || '';
addClass.call([el], value.call(el, i, className));
}
});
@ -449,7 +478,7 @@ function addClass(value) {
for (var i = 0; i < numElements; i++) {
var el = this[i];
// If selected element isn't a tag, move on
if (!utils_1.isTag(el))
if (!(0, utils_js_1.isTag)(el))
continue;
// If we don't already have classes — always set xmlMode to false here, as it doesn't matter for classes
var className = getAttr(el, 'class', false);
@ -457,11 +486,11 @@ function addClass(value) {
setAttr(el, 'class', classNames.join(' ').trim());
}
else {
var setClass = " " + className + " ";
var setClass = " ".concat(className, " ");
// Check if class already exists
for (var j = 0; j < classNames.length; j++) {
var appendClass = classNames[j] + " ";
if (!setClass.includes(" " + appendClass))
var appendClass = "".concat(classNames[j], " ");
if (!setClass.includes(" ".concat(appendClass)))
setClass += appendClass;
}
setAttr(el, 'class', setClass.trim());
@ -492,23 +521,24 @@ exports.addClass = addClass;
function removeClass(name) {
// Handle if value is a function
if (typeof name === 'function') {
return utils_1.domEach(this, function (el, i) {
if (utils_1.isTag(el))
removeClass.call([el], name.call(el, i, el.attribs.class || ''));
return (0, utils_js_1.domEach)(this, function (el, i) {
if ((0, utils_js_1.isTag)(el)) {
removeClass.call([el], name.call(el, i, el.attribs['class'] || ''));
}
});
}
var classes = splitNames(name);
var numClasses = classes.length;
var removeAll = arguments.length === 0;
return utils_1.domEach(this, function (el) {
if (!utils_1.isTag(el))
return (0, utils_js_1.domEach)(this, function (el) {
if (!(0, utils_js_1.isTag)(el))
return;
if (removeAll) {
// Short circuit the remove all case as this is the nice one
el.attribs.class = '';
el.attribs['class'] = '';
}
else {
var elClasses = splitNames(el.attribs.class);
var elClasses = splitNames(el.attribs['class']);
var changed = false;
for (var j = 0; j < numClasses; j++) {
var index = elClasses.indexOf(classes[j]);
@ -523,7 +553,7 @@ function removeClass(name) {
}
}
if (changed) {
el.attribs.class = elClasses.join(' ');
el.attribs['class'] = elClasses.join(' ');
}
}
});
@ -552,9 +582,9 @@ exports.removeClass = removeClass;
function toggleClass(value, stateVal) {
// Support functions
if (typeof value === 'function') {
return utils_1.domEach(this, function (el, i) {
if (utils_1.isTag(el)) {
toggleClass.call([el], value.call(el, i, el.attribs.class || '', stateVal), stateVal);
return (0, utils_js_1.domEach)(this, function (el, i) {
if ((0, utils_js_1.isTag)(el)) {
toggleClass.call([el], value.call(el, i, el.attribs['class'] || '', stateVal), stateVal);
}
});
}
@ -568,9 +598,9 @@ function toggleClass(value, stateVal) {
for (var i = 0; i < numElements; i++) {
var el = this[i];
// If selected element isn't a tag, move on
if (!utils_1.isTag(el))
if (!(0, utils_js_1.isTag)(el))
continue;
var elementClasses = splitNames(el.attribs.class);
var elementClasses = splitNames(el.attribs['class']);
// Check if class already exists
for (var j = 0; j < numClasses; j++) {
// Check if the class name is currently defined
@ -584,8 +614,9 @@ function toggleClass(value, stateVal) {
elementClasses.splice(index, 1);
}
}
el.attribs.class = elementClasses.join(' ');
el.attribs['class'] = elementClasses.join(' ');
}
return this;
}
exports.toggleClass = toggleClass;
//# sourceMappingURL=attributes.js.map

View file

@ -1,14 +1,14 @@
import type { Element, Node } from 'domhandler';
import type { Cheerio } from '../cheerio';
import type { Element, AnyNode } from 'domhandler';
import type { Cheerio } from '../cheerio.js';
/**
* Get the value of a style property for the first element in the set of matched elements.
*
* @category CSS
* @param names - Optionally the names of the property of interest.
* @param names - Optionally the names of the properties of interest.
* @returns A map of all of the style properties.
* @see {@link https://api.jquery.com/css/}
*/
export declare function css<T extends Node>(this: Cheerio<T>, names?: string[]): Record<string, string>;
export declare function css<T extends AnyNode>(this: Cheerio<T>, names?: string[]): Record<string, string> | undefined;
/**
* Get the value of a style property for the first element in the set of matched elements.
*
@ -17,7 +17,7 @@ export declare function css<T extends Node>(this: Cheerio<T>, names?: string[]):
* @returns The property value for the given name.
* @see {@link https://api.jquery.com/css/}
*/
export declare function css<T extends Node>(this: Cheerio<T>, name: string): string | undefined;
export declare function css<T extends AnyNode>(this: Cheerio<T>, name: string): string | undefined;
/**
* Set one CSS property for every matched element.
*
@ -27,15 +27,14 @@ export declare function css<T extends Node>(this: Cheerio<T>, name: string): str
* @returns The instance itself.
* @see {@link https://api.jquery.com/css/}
*/
export declare function css<T extends Node>(this: Cheerio<T>, prop: string, val: string | ((this: Element, i: number, style: string) => string | undefined)): Cheerio<T>;
export declare function css<T extends AnyNode>(this: Cheerio<T>, prop: string, val: string | ((this: Element, i: number, style: string) => string | undefined)): Cheerio<T>;
/**
* Set multiple CSS properties for every matched element.
*
* @category CSS
* @param prop - The name of the property.
* @param val - The new value.
* @param map - A map of property names and values.
* @returns The instance itself.
* @see {@link https://api.jquery.com/css/}
*/
export declare function css<T extends Node>(this: Cheerio<T>, prop: Record<string, string>): Cheerio<T>;
export declare function css<T extends AnyNode>(this: Cheerio<T>, map: Record<string, string>): Cheerio<T>;
//# sourceMappingURL=css.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/api/css.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1B;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAAC;AACtB;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EACC,MAAM,GACN,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GACpE,OAAO,CAAC,CAAC,CAAC,CAAC;AACd;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,OAAO,CAAC,CAAC,CAAC,CAAC"}
{"version":3,"file":"css.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["api/css.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,OAAO,EACnC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;AACtC;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,OAAO,EACnC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAAC;AACtB;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,OAAO,EACnC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EACC,MAAM,GACN,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GACpE,OAAO,CAAC,CAAC,CAAC,CAAC;AACd;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,OAAO,EACnC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC"}

51
node_modules/cheerio/lib/api/css.js generated vendored
View file

@ -1,18 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.css = void 0;
var utils_1 = require("../utils");
var utils_js_1 = require("../utils.js");
/**
* Set multiple CSS properties for every matched element.
*
* @category CSS
* @param prop - The names of the properties.
* @param val - The new values.
* @returns The instance itself.
* @see {@link https://api.jquery.com/css/}
*/
function css(prop, val) {
if ((prop != null && val != null) ||
// When `prop` is a "plain" object
(typeof prop === 'object' && !Array.isArray(prop))) {
return utils_1.domEach(this, function (el, i) {
if (utils_1.isTag(el)) {
return (0, utils_js_1.domEach)(this, function (el, i) {
if ((0, utils_js_1.isTag)(el)) {
// `prop` can't be an array here anymore.
setCss(el, prop, val, i);
}
});
}
if (this.length === 0) {
return undefined;
}
return getCss(this[0], prop);
}
exports.css = css;
@ -35,7 +47,7 @@ function setCss(el, prop, value, idx) {
else if (val != null) {
styles[prop] = val;
}
el.attribs.style = stringify(styles);
el.attribs['style'] = stringify(styles);
}
else if (typeof prop === 'object') {
Object.keys(prop).forEach(function (k, i) {
@ -44,9 +56,9 @@ function setCss(el, prop, value, idx) {
}
}
function getCss(el, prop) {
if (!el || !utils_1.isTag(el))
if (!el || !(0, utils_js_1.isTag)(el))
return;
var styles = parse(el.attribs.style);
var styles = parse(el.attribs['style']);
if (typeof prop === 'string') {
return styles[prop];
}
@ -70,7 +82,7 @@ function getCss(el, prop) {
* @returns The serialized styles.
*/
function stringify(obj) {
return Object.keys(obj).reduce(function (str, prop) { return "" + str + (str ? ' ' : '') + prop + ": " + obj[prop] + ";"; }, '');
return Object.keys(obj).reduce(function (str, prop) { return "".concat(str).concat(str ? ' ' : '').concat(prop, ": ").concat(obj[prop], ";"); }, '');
}
/**
* Parse `styles`.
@ -84,12 +96,23 @@ function parse(styles) {
styles = (styles || '').trim();
if (!styles)
return {};
return styles.split(';').reduce(function (obj, str) {
var obj = {};
var key;
for (var _i = 0, _a = styles.split(';'); _i < _a.length; _i++) {
var str = _a[_i];
var n = str.indexOf(':');
// Skip if there is no :, or if it is the first/last character
if (n < 1 || n === str.length - 1)
return obj;
obj[str.slice(0, n).trim()] = str.slice(n + 1).trim();
return obj;
}, {});
// If there is no :, or if it is the first/last character, add to the previous item's value
if (n < 1 || n === str.length - 1) {
var trimmed = str.trimEnd();
if (trimmed.length > 0 && key !== undefined) {
obj[key] += ";".concat(trimmed);
}
}
else {
key = str.slice(0, n).trim();
obj[key] = str.slice(n + 1).trim();
}
}
return obj;
}
//# sourceMappingURL=css.js.map

View file

@ -1,13 +1,20 @@
import type { Node } from 'domhandler';
import type { Cheerio } from '../cheerio';
import type { AnyNode } from 'domhandler';
import type { Cheerio } from '../cheerio.js';
/**
* Encode a set of form elements as a string for submission.
*
* @category Forms
* @example
*
* ```js
* $('<form><input name="foo" value="bar" /></form>').serialize();
* //=> 'foo=bar'
* ```
*
* @returns The serialized form.
* @see {@link https://api.jquery.com/serialize/}
*/
export declare function serialize<T extends Node>(this: Cheerio<T>): string;
export declare function serialize<T extends AnyNode>(this: Cheerio<T>): string;
interface SerializedField {
name: string;
value: string;
@ -26,6 +33,6 @@ interface SerializedField {
* @returns The serialized form.
* @see {@link https://api.jquery.com/serializeArray/}
*/
export declare function serializeArray<T extends Node>(this: Cheerio<T>): SerializedField[];
export declare function serializeArray<T extends AnyNode>(this: Cheerio<T>): SerializedField[];
export {};
//# sourceMappingURL=forms.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../../src/api/forms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAW1C;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAYlE;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,IAAI,EAC3C,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GACf,eAAe,EAAE,CAsCnB"}
{"version":3,"file":"forms.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["api/forms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAW7C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAYrE;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAC9C,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GACf,eAAe,EAAE,CAsCnB"}

View file

@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeArray = exports.serialize = void 0;
var utils_1 = require("../utils");
var utils_js_1 = require("../utils.js");
/*
* https://github.com/jquery/jquery/blob/2.1.3/src/manipulation/var/rcheckableType.js
* https://github.com/jquery/jquery/blob/2.1.3/src/serialize.js
@ -13,6 +13,13 @@ var rCRLF = /\r?\n/g;
* Encode a set of form elements as a string for submission.
*
* @category Forms
* @example
*
* ```js
* $('<form><input name="foo" value="bar" /></form>').serialize();
* //=> 'foo=bar'
* ```
*
* @returns The serialized form.
* @see {@link https://api.jquery.com/serialize/}
*/
@ -21,7 +28,7 @@ function serialize() {
var arr = this.serializeArray();
// Serialize each element into a key/value string
var retArr = arr.map(function (data) {
return encodeURIComponent(data.name) + "=" + encodeURIComponent(data.value);
return "".concat(encodeURIComponent(data.name), "=").concat(encodeURIComponent(data.value));
});
// Return the resulting serialization
return retArr.join('&').replace(r20, '+');
@ -46,7 +53,7 @@ function serializeArray() {
// Resolve all form elements from either forms or collections of form elements
return this.map(function (_, elem) {
var $elem = _this._make(elem);
if (utils_1.isTag(elem) && elem.name === 'form') {
if ((0, utils_js_1.isTag)(elem) && elem.name === 'form') {
return $elem.find(submittableSelector).toArray();
}
return $elem.filter(submittableSelector).toArray();
@ -82,3 +89,4 @@ function serializeArray() {
.toArray();
}
exports.serializeArray = serializeArray;
//# sourceMappingURL=forms.js.map

View file

@ -3,9 +3,9 @@
*
* @module cheerio/manipulation
*/
import { Node } from 'domhandler';
import type { Cheerio } from '../cheerio';
import type { BasicAcceptedElems, AcceptedElems } from '../types';
import { AnyNode } from 'domhandler';
import type { Cheerio } from '../cheerio.js';
import type { BasicAcceptedElems, AcceptedElems } from '../types.js';
/**
* Create an array of nodes, recursing into arrays and parsing strings if necessary.
*
@ -15,7 +15,7 @@ import type { BasicAcceptedElems, AcceptedElems } from '../types';
* @param clone - Optionally clone nodes.
* @returns The array of nodes.
*/
export declare function _makeDomArray<T extends Node>(this: Cheerio<T>, elem?: BasicAcceptedElems<Node>, clone?: boolean): Node[];
export declare function _makeDomArray<T extends AnyNode>(this: Cheerio<T>, elem?: BasicAcceptedElems<AnyNode>, clone?: boolean): AnyNode[];
/**
* Insert every element in the set of matched elements to the end of the target.
*
@ -37,7 +37,7 @@ export declare function _makeDomArray<T extends Node>(this: Cheerio<T>, elem?: B
* @returns The instance itself.
* @see {@link https://api.jquery.com/appendTo/}
*/
export declare function appendTo<T extends Node>(this: Cheerio<T>, target: BasicAcceptedElems<Node>): Cheerio<T>;
export declare function appendTo<T extends AnyNode>(this: Cheerio<T>, target: BasicAcceptedElems<AnyNode>): Cheerio<T>;
/**
* Insert every element in the set of matched elements to the beginning of the target.
*
@ -59,9 +59,9 @@ export declare function appendTo<T extends Node>(this: Cheerio<T>, target: Basic
* @returns The instance itself.
* @see {@link https://api.jquery.com/prependTo/}
*/
export declare function prependTo<T extends Node>(this: Cheerio<T>, target: BasicAcceptedElems<Node>): Cheerio<T>;
export declare function prependTo<T extends AnyNode>(this: Cheerio<T>, target: BasicAcceptedElems<AnyNode>): Cheerio<T>;
/**
* Inserts content as the *last* child of each of the selected elements.
* Inserts content as the _last_ child of each of the selected elements.
*
* @category Manipulation
* @example
@ -79,9 +79,9 @@ export declare function prependTo<T extends Node>(this: Cheerio<T>, target: Basi
*
* @see {@link https://api.jquery.com/append/}
*/
export declare const append: <T extends Node>(this: Cheerio<T>, ...elems: [(this: Node, i: number, html: string) => BasicAcceptedElems<Node>] | BasicAcceptedElems<Node>[]) => Cheerio<T>;
export declare const append: <T extends AnyNode>(this: Cheerio<T>, ...elems: [(this: AnyNode, i: number, html: string) => BasicAcceptedElems<AnyNode>] | BasicAcceptedElems<AnyNode>[]) => Cheerio<T>;
/**
* Inserts content as the *first* child of each of the selected elements.
* Inserts content as the _first_ child of each of the selected elements.
*
* @category Manipulation
* @example
@ -99,7 +99,7 @@ export declare const append: <T extends Node>(this: Cheerio<T>, ...elems: [(this
*
* @see {@link https://api.jquery.com/prepend/}
*/
export declare const prepend: <T extends Node>(this: Cheerio<T>, ...elems: [(this: Node, i: number, html: string) => BasicAcceptedElems<Node>] | BasicAcceptedElems<Node>[]) => Cheerio<T>;
export declare const prepend: <T extends AnyNode>(this: Cheerio<T>, ...elems: [(this: AnyNode, i: number, html: string) => BasicAcceptedElems<AnyNode>] | BasicAcceptedElems<AnyNode>[]) => Cheerio<T>;
/**
* The .wrap() function can take any string or object that could be passed to
* the $() factory function to specify a DOM structure. This structure may be
@ -142,7 +142,7 @@ export declare const prepend: <T extends Node>(this: Cheerio<T>, ...elems: [(thi
* @param wrapper - The DOM structure to wrap around each element in the selection.
* @see {@link https://api.jquery.com/wrap/}
*/
export declare const wrap: <T extends Node>(this: Cheerio<T>, wrapper: AcceptedElems<Node>) => Cheerio<T>;
export declare const wrap: <T extends AnyNode>(this: Cheerio<T>, wrapper: AcceptedElems<AnyNode>) => Cheerio<T>;
/**
* The .wrapInner() function can take any string or object that could be passed
* to the $() factory function to specify a DOM structure. This structure may be
@ -186,7 +186,7 @@ export declare const wrap: <T extends Node>(this: Cheerio<T>, wrapper: AcceptedE
* @returns The instance itself, for chaining.
* @see {@link https://api.jquery.com/wrapInner/}
*/
export declare const wrapInner: <T extends Node>(this: Cheerio<T>, wrapper: AcceptedElems<Node>) => Cheerio<T>;
export declare const wrapInner: <T extends AnyNode>(this: Cheerio<T>, wrapper: AcceptedElems<AnyNode>) => Cheerio<T>;
/**
* The .unwrap() function, removes the parents of the set of matched elements
* from the DOM, leaving the matched elements in their place.
@ -225,7 +225,7 @@ export declare const wrapInner: <T extends Node>(this: Cheerio<T>, wrapper: Acce
* @returns The instance itself, for chaining.
* @see {@link https://api.jquery.com/unwrap/}
*/
export declare function unwrap<T extends Node>(this: Cheerio<T>, selector?: string): Cheerio<T>;
export declare function unwrap<T extends AnyNode>(this: Cheerio<T>, selector?: string): Cheerio<T>;
/**
* The .wrapAll() function can take any string or object that could be passed to
* the $() function to specify a DOM structure. This structure may be nested
@ -277,7 +277,7 @@ export declare function unwrap<T extends Node>(this: Cheerio<T>, selector?: stri
* @returns The instance itself.
* @see {@link https://api.jquery.com/wrapAll/}
*/
export declare function wrapAll<T extends Node>(this: Cheerio<T>, wrapper: AcceptedElems<T>): Cheerio<T>;
export declare function wrapAll<T extends AnyNode>(this: Cheerio<T>, wrapper: AcceptedElems<T>): Cheerio<T>;
/**
* Insert content next to each element in the set of matched elements.
*
@ -300,7 +300,7 @@ export declare function wrapAll<T extends Node>(this: Cheerio<T>, wrapper: Accep
* @returns The instance itself.
* @see {@link https://api.jquery.com/after/}
*/
export declare function after<T extends Node>(this: Cheerio<T>, ...elems: [(this: Node, i: number, html: string) => BasicAcceptedElems<Node>] | BasicAcceptedElems<Node>[]): Cheerio<T>;
export declare function after<T extends AnyNode>(this: Cheerio<T>, ...elems: [(this: AnyNode, i: number, html: string) => BasicAcceptedElems<AnyNode>] | BasicAcceptedElems<AnyNode>[]): Cheerio<T>;
/**
* Insert every element in the set of matched elements after the target.
*
@ -322,7 +322,7 @@ export declare function after<T extends Node>(this: Cheerio<T>, ...elems: [(this
* @returns The set of newly inserted elements.
* @see {@link https://api.jquery.com/insertAfter/}
*/
export declare function insertAfter<T extends Node>(this: Cheerio<T>, target: BasicAcceptedElems<Node>): Cheerio<T>;
export declare function insertAfter<T extends AnyNode>(this: Cheerio<T>, target: BasicAcceptedElems<AnyNode>): Cheerio<T>;
/**
* Insert content previous to each element in the set of matched elements.
*
@ -345,7 +345,7 @@ export declare function insertAfter<T extends Node>(this: Cheerio<T>, target: Ba
* @returns The instance itself.
* @see {@link https://api.jquery.com/before/}
*/
export declare function before<T extends Node>(this: Cheerio<T>, ...elems: [(this: Node, i: number, html: string) => BasicAcceptedElems<Node>] | BasicAcceptedElems<Node>[]): Cheerio<T>;
export declare function before<T extends AnyNode>(this: Cheerio<T>, ...elems: [(this: AnyNode, i: number, html: string) => BasicAcceptedElems<AnyNode>] | BasicAcceptedElems<AnyNode>[]): Cheerio<T>;
/**
* Insert every element in the set of matched elements before the target.
*
@ -367,7 +367,7 @@ export declare function before<T extends Node>(this: Cheerio<T>, ...elems: [(thi
* @returns The set of newly inserted elements.
* @see {@link https://api.jquery.com/insertBefore/}
*/
export declare function insertBefore<T extends Node>(this: Cheerio<T>, target: BasicAcceptedElems<Node>): Cheerio<T>;
export declare function insertBefore<T extends AnyNode>(this: Cheerio<T>, target: BasicAcceptedElems<AnyNode>): Cheerio<T>;
/**
* Removes the set of matched elements from the DOM and all their children.
* `selector` filters the set of matched elements to be removed.
@ -388,7 +388,7 @@ export declare function insertBefore<T extends Node>(this: Cheerio<T>, target: B
* @returns The instance itself.
* @see {@link https://api.jquery.com/remove/}
*/
export declare function remove<T extends Node>(this: Cheerio<T>, selector?: string): Cheerio<T>;
export declare function remove<T extends AnyNode>(this: Cheerio<T>, selector?: string): Cheerio<T>;
/**
* Replaces matched elements with `content`.
*
@ -410,7 +410,7 @@ export declare function remove<T extends Node>(this: Cheerio<T>, selector?: stri
* @returns The instance itself.
* @see {@link https://api.jquery.com/replaceWith/}
*/
export declare function replaceWith<T extends Node>(this: Cheerio<T>, content: AcceptedElems<Node>): Cheerio<T>;
export declare function replaceWith<T extends AnyNode>(this: Cheerio<T>, content: AcceptedElems<AnyNode>): Cheerio<T>;
/**
* Empties an element, removing all its children.
*
@ -426,10 +426,9 @@ export declare function replaceWith<T extends Node>(this: Cheerio<T>, content: A
* @returns The instance itself.
* @see {@link https://api.jquery.com/empty/}
*/
export declare function empty<T extends Node>(this: Cheerio<T>): Cheerio<T>;
export declare function empty<T extends AnyNode>(this: Cheerio<T>): Cheerio<T>;
/**
* Gets an HTML content string from the first selected element. If `htmlString`
* is specified, each selected element's content is replaced by the new content.
* Gets an HTML content string from the first selected element.
*
* @category Manipulation
* @example
@ -442,23 +441,36 @@ export declare function empty<T extends Node>(this: Cheerio<T>): Cheerio<T>;
* //=> <li class="mango">Mango</li>
* ```
*
* @param str - If specified used to replace selection's contents.
* @returns The HTML content string.
* @see {@link https://api.jquery.com/html/}
*/
export declare function html<T extends AnyNode>(this: Cheerio<T>): string | null;
/**
* Replaces each selected element's content with the specified content.
*
* @category Manipulation
* @example
*
* ```js
* $('.orange').html('<li class="mango">Mango</li>').html();
* //=> <li class="mango">Mango</li>
* ```
*
* @param str - The content to replace selection's contents with.
* @returns The instance itself.
* @see {@link https://api.jquery.com/html/}
*/
export declare function html<T extends Node>(this: Cheerio<T>): string | null;
export declare function html<T extends Node>(this: Cheerio<T>, str: string | Cheerio<T>): Cheerio<T>;
export declare function html<T extends AnyNode>(this: Cheerio<T>, str: string | Cheerio<T>): Cheerio<T>;
/**
* Turns the collection to a string. Alias for `.html()`.
*
* @category Manipulation
* @returns The rendered document.
*/
export declare function toString<T extends Node>(this: Cheerio<T>): string;
export declare function toString<T extends AnyNode>(this: Cheerio<T>): string;
/**
* Get the combined text contents of each element in the set of matched
* elements, including their descendants. If `textString` is specified, each
* selected element's content is replaced by the new text content.
* elements, including their descendants.
*
* @category Manipulation
* @example
@ -473,12 +485,26 @@ export declare function toString<T extends Node>(this: Cheerio<T>): string;
* // Pear
* ```
*
* @param str - If specified replacement for the selected element's contents.
* @returns The instance itself when setting text, otherwise the rendered document.
* @returns The text contents of the collection.
* @see {@link https://api.jquery.com/text/}
*/
export declare function text<T extends Node>(this: Cheerio<T>): string;
export declare function text<T extends Node>(this: Cheerio<T>, str: string | ((this: Node, i: number, text: string) => string)): Cheerio<T>;
export declare function text<T extends AnyNode>(this: Cheerio<T>): string;
/**
* Set the content of each element in the set of matched elements to the specified text.
*
* @category Manipulation
* @example
*
* ```js
* $('.orange').text('Orange');
* //=> <div class="orange">Orange</div>
* ```
*
* @param str - The text to set as the content of each matched element.
* @returns The instance itself.
* @see {@link https://api.jquery.com/text/}
*/
export declare function text<T extends AnyNode>(this: Cheerio<T>, str: string | ((this: AnyNode, i: number, text: string) => string)): Cheerio<T>;
/**
* Clone the cheerio object.
*
@ -492,5 +518,5 @@ export declare function text<T extends Node>(this: Cheerio<T>, str: string | ((t
* @returns The cloned object.
* @see {@link https://api.jquery.com/clone/}
*/
export declare function clone<T extends Node>(this: Cheerio<T>): Cheerio<T>;
export declare function clone<T extends AnyNode>(this: Cheerio<T>): Cheerio<T>;
//# sourceMappingURL=manipulation.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"manipulation.d.ts","sourceRoot":"","sources":["../../src/api/manipulation.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAmC,MAAM,YAAY,CAAC;AAKnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAElE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,IAAI,EAC1C,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAC/B,KAAK,CAAC,EAAE,OAAO,GACd,IAAI,EAAE,CAiBR;AAoGD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,IAAI,EACrC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,EACtC,IAAI,EAAE,OAAO,C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"}
{"version":3,"file":"manipulation.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["api/manipulation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAc,OAAO,EAA8B,MAAM,YAAY,CAAC;AAK7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAErE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAC7C,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAClC,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,EAAE,CAiBX;AA8GD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EACxC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAClC,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,OAAO,EACzC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAClC,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,MAAM,0DAnLD,OAAO,KACV,MAAM,QACH,MAAM,KACT,mBAAmB,OAAO,CAAC,gDAkLxC,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,0DA1MF,OAAO,KACV,MAAM,QACH,MAAM,KACT,mBAAmB,OAAO,CAAC,gDAyMxC,CAAC;AAuDH;;;;;;;;;;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;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,OAAO,EACpC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,OAAO,CAAC,CAAC,CAAC,CAAC;AAyBd;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAEpE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAClE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,OAAO,EACpC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,GACjE,OAAO,CAAC,CAAC,CAAC,CAAC;AA6Bd;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAErE"}

View file

@ -1,18 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.clone = exports.text = exports.toString = exports.html = exports.empty = exports.replaceWith = exports.remove = exports.insertBefore = exports.before = exports.insertAfter = exports.after = exports.wrapAll = exports.unwrap = exports.wrapInner = exports.wrap = exports.prepend = exports.append = exports.prependTo = exports.appendTo = exports._makeDomArray = void 0;
var tslib_1 = require("tslib");
var domhandler_1 = require("domhandler");
/**
* Methods for modifying the DOM structure.
*
* @module cheerio/manipulation
*/
var domhandler_2 = require("domhandler");
var parse_1 = tslib_1.__importStar(require("../parse"));
var static_1 = require("../static");
var utils_1 = require("../utils");
var htmlparser2_1 = require("htmlparser2");
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.clone = exports.text = exports.toString = exports.html = exports.empty = exports.replaceWith = exports.remove = exports.insertBefore = exports.before = exports.insertAfter = exports.after = exports.wrapAll = exports.unwrap = exports.wrapInner = exports.wrap = exports.prepend = exports.append = exports.prependTo = exports.appendTo = exports._makeDomArray = void 0;
var domhandler_1 = require("domhandler");
var parse_js_1 = require("../parse.js");
var static_js_1 = require("../static.js");
var utils_js_1 = require("../utils.js");
var domutils_1 = require("domutils");
/**
* Create an array of nodes, recursing into arrays and parsing strings if necessary.
*
@ -27,16 +34,16 @@ function _makeDomArray(elem, clone) {
if (elem == null) {
return [];
}
if (utils_1.isCheerio(elem)) {
return clone ? utils_1.cloneDom(elem.get()) : elem.get();
if ((0, utils_js_1.isCheerio)(elem)) {
return clone ? (0, utils_js_1.cloneDom)(elem.get()) : elem.get();
}
if (Array.isArray(elem)) {
return elem.reduce(function (newElems, el) { return newElems.concat(_this._makeDomArray(el, clone)); }, []);
}
if (typeof elem === 'string') {
return parse_1.default(elem, this.options, false).children;
return this._parse(elem, this.options, false, null).children;
}
return clone ? utils_1.cloneDom([elem]) : [elem];
return clone ? (0, utils_js_1.cloneDom)([elem]) : [elem];
}
exports._makeDomArray = _makeDomArray;
function _insert(concatenator) {
@ -47,11 +54,11 @@ function _insert(concatenator) {
elems[_i] = arguments[_i];
}
var lastIdx = this.length - 1;
return utils_1.domEach(this, function (el, i) {
if (!domhandler_1.hasChildren(el))
return (0, utils_js_1.domEach)(this, function (el, i) {
if (!(0, domhandler_1.hasChildren)(el))
return;
var domSrc = typeof elems[0] === 'function'
? elems[0].call(el, i, static_1.html(el.children))
? elems[0].call(el, i, _this._render(el.children))
: elems;
var dom = _this._makeDomArray(domSrc, i < lastIdx);
concatenator(dom, el.children, el);
@ -73,12 +80,14 @@ function _insert(concatenator) {
*/
function uniqueSplice(array, spliceIdx, spliceCount, newElems, parent) {
var _a, _b;
var spliceArgs = tslib_1.__spreadArray([
var spliceArgs = __spreadArray([
spliceIdx,
spliceCount
], newElems);
var prev = array[spliceIdx - 1] || null;
var next = array[spliceIdx + spliceCount] || null;
], newElems, true);
var prev = spliceIdx === 0 ? null : array[spliceIdx - 1];
var next = spliceIdx + spliceCount >= array.length
? null
: array[spliceIdx + spliceCount];
/*
* Before splicing in new elements, ensure they do not already appear in the
* current array.
@ -87,7 +96,8 @@ function uniqueSplice(array, spliceIdx, spliceCount, newElems, parent) {
var node = newElems[idx];
var oldParent = node.parent;
if (oldParent) {
var prevIdx = oldParent.children.indexOf(newElems[idx]);
var oldSiblings = oldParent.children;
var prevIdx = oldSiblings.indexOf(node);
if (prevIdx > -1) {
oldParent.children.splice(prevIdx, 1);
if (parent === oldParent && spliceIdx > prevIdx) {
@ -102,8 +112,8 @@ function uniqueSplice(array, spliceIdx, spliceCount, newElems, parent) {
if (node.next) {
node.next.prev = (_b = node.prev) !== null && _b !== void 0 ? _b : null;
}
node.prev = newElems[idx - 1] || prev;
node.next = newElems[idx + 1] || next;
node.prev = idx === 0 ? prev : newElems[idx - 1];
node.next = idx === newElems.length - 1 ? next : newElems[idx + 1];
}
if (prev) {
prev.next = newElems[0];
@ -135,7 +145,7 @@ function uniqueSplice(array, spliceIdx, spliceCount, newElems, parent) {
* @see {@link https://api.jquery.com/appendTo/}
*/
function appendTo(target) {
var appendTarget = utils_1.isCheerio(target) ? target : this._make(target);
var appendTarget = (0, utils_js_1.isCheerio)(target) ? target : this._make(target);
appendTarget.append(this);
return this;
}
@ -162,13 +172,13 @@ exports.appendTo = appendTo;
* @see {@link https://api.jquery.com/prependTo/}
*/
function prependTo(target) {
var prependTarget = utils_1.isCheerio(target) ? target : this._make(target);
var prependTarget = (0, utils_js_1.isCheerio)(target) ? target : this._make(target);
prependTarget.prepend(this);
return this;
}
exports.prependTo = prependTo;
/**
* Inserts content as the *last* child of each of the selected elements.
* Inserts content as the _last_ child of each of the selected elements.
*
* @category Manipulation
* @example
@ -190,7 +200,7 @@ exports.append = _insert(function (dom, children, parent) {
uniqueSplice(children, children.length, 0, dom, parent);
});
/**
* Inserts content as the *first* child of each of the selected elements.
* Inserts content as the _first_ child of each of the selected elements.
*
* @category Manipulation
* @example
@ -219,11 +229,11 @@ function _wrap(insert) {
var el = this[i];
var wrap_1 = typeof wrapper === 'function'
? wrapper.call(el, i, el)
: typeof wrapper === 'string' && !utils_1.isHtml(wrapper)
: typeof wrapper === 'string' && !(0, utils_js_1.isHtml)(wrapper)
? lastParent.find(wrapper).clone()
: wrapper;
var wrapperDom = this._makeDomArray(wrap_1, i < lastIdx)[0];
if (!wrapperDom || !htmlparser2_1.DomUtils.hasChildren(wrapperDom))
if (!wrapperDom || !(0, domhandler_1.hasChildren)(wrapperDom))
continue;
var elInsertLocation = wrapperDom;
/*
@ -233,7 +243,7 @@ function _wrap(insert) {
var j = 0;
while (j < elInsertLocation.children.length) {
var child = elInsertLocation.children[j];
if (utils_1.isTag(child)) {
if ((0, utils_js_1.isTag)(child)) {
elInsertLocation = child;
j = 0;
}
@ -294,7 +304,7 @@ exports.wrap = _wrap(function (el, elInsertLocation, wrapperDom) {
return;
var siblings = parent.children;
var index = siblings.indexOf(el);
parse_1.update([el], elInsertLocation);
(0, parse_js_1.update)([el], elInsertLocation);
/*
* The previous operation removed the current element from the `siblings`
* array, so the `dom` array can be inserted without removing any
@ -346,10 +356,10 @@ exports.wrap = _wrap(function (el, elInsertLocation, wrapperDom) {
* @see {@link https://api.jquery.com/wrapInner/}
*/
exports.wrapInner = _wrap(function (el, elInsertLocation, wrapperDom) {
if (!domhandler_1.hasChildren(el))
if (!(0, domhandler_1.hasChildren)(el))
return;
parse_1.update(el.children, elInsertLocation);
parse_1.update(wrapperDom, el);
(0, parse_js_1.update)(el.children, elInsertLocation);
(0, parse_js_1.update)(wrapperDom, el);
});
/**
* The .unwrap() function, removes the parents of the set of matched elements
@ -511,9 +521,9 @@ function after() {
elems[_i] = arguments[_i];
}
var lastIdx = this.length - 1;
return utils_1.domEach(this, function (el, i) {
return (0, utils_js_1.domEach)(this, function (el, i) {
var parent = el.parent;
if (!htmlparser2_1.DomUtils.hasChildren(el) || !parent) {
if (!(0, domhandler_1.hasChildren)(el) || !parent) {
return;
}
var siblings = parent.children;
@ -523,7 +533,7 @@ function after() {
if (index < 0)
return;
var domSrc = typeof elems[0] === 'function'
? elems[0].call(el, i, static_1.html(el.children))
? elems[0].call(el, i, _this._render(el.children))
: elems;
var dom = _this._makeDomArray(domSrc, i < lastIdx);
// Add element after `this` element
@ -609,9 +619,9 @@ function before() {
elems[_i] = arguments[_i];
}
var lastIdx = this.length - 1;
return utils_1.domEach(this, function (el, i) {
return (0, utils_js_1.domEach)(this, function (el, i) {
var parent = el.parent;
if (!htmlparser2_1.DomUtils.hasChildren(el) || !parent) {
if (!(0, domhandler_1.hasChildren)(el) || !parent) {
return;
}
var siblings = parent.children;
@ -621,7 +631,7 @@ function before() {
if (index < 0)
return;
var domSrc = typeof elems[0] === 'function'
? elems[0].call(el, i, static_1.html(el.children))
? elems[0].call(el, i, _this._render(el.children))
: elems;
var dom = _this._makeDomArray(domSrc, i < lastIdx);
// Add element before `el` element
@ -656,7 +666,7 @@ function insertBefore(target) {
var targetArr = this._make(target);
this.remove();
var clones = [];
utils_1.domEach(targetArr, function (el) {
(0, utils_js_1.domEach)(targetArr, function (el) {
var clonedSelf = _this.clone().toArray();
var parent = el.parent;
if (!parent) {
@ -698,8 +708,8 @@ exports.insertBefore = insertBefore;
function remove(selector) {
// Filter if we have selector
var elems = selector ? this.filter(selector) : this;
utils_1.domEach(elems, function (el) {
htmlparser2_1.DomUtils.removeElement(el);
(0, utils_js_1.domEach)(elems, function (el) {
(0, domutils_1.removeElement)(el);
el.prev = el.next = el.parent = null;
});
return this;
@ -728,7 +738,7 @@ exports.remove = remove;
*/
function replaceWith(content) {
var _this = this;
return utils_1.domEach(this, function (el, i) {
return (0, utils_js_1.domEach)(this, function (el, i) {
var parent = el.parent;
if (!parent) {
return;
@ -740,7 +750,7 @@ function replaceWith(content) {
* In the case that `dom` contains nodes that already exist in other
* structures, ensure those nodes are properly removed.
*/
parse_1.update(dom, null);
(0, parse_js_1.update)(dom, null);
var index = siblings.indexOf(el);
// Completely remove old element
uniqueSplice(siblings, index, 1, dom, parent);
@ -766,8 +776,8 @@ exports.replaceWith = replaceWith;
* @see {@link https://api.jquery.com/empty/}
*/
function empty() {
return utils_1.domEach(this, function (el) {
if (!htmlparser2_1.DomUtils.hasChildren(el))
return (0, utils_js_1.domEach)(this, function (el) {
if (!(0, domhandler_1.hasChildren)(el))
return;
el.children.forEach(function (child) {
child.next = child.prev = child.parent = null;
@ -777,25 +787,23 @@ function empty() {
}
exports.empty = empty;
function html(str) {
var _this = this;
if (str === undefined) {
var el = this[0];
if (!el || !htmlparser2_1.DomUtils.hasChildren(el))
if (!el || !(0, domhandler_1.hasChildren)(el))
return null;
return static_1.html(el.children, this.options);
return this._render(el.children);
}
// Keep main options unchanged
var opts = tslib_1.__assign(tslib_1.__assign({}, this.options), { context: null });
return utils_1.domEach(this, function (el) {
if (!htmlparser2_1.DomUtils.hasChildren(el))
return (0, utils_js_1.domEach)(this, function (el) {
if (!(0, domhandler_1.hasChildren)(el))
return;
el.children.forEach(function (child) {
child.next = child.prev = child.parent = null;
});
opts.context = el;
var content = utils_1.isCheerio(str)
var content = (0, utils_js_1.isCheerio)(str)
? str.toArray()
: parse_1.default("" + str, opts, false).children;
parse_1.update(content, el);
: _this._parse("".concat(str), _this.options, false, el).children;
(0, parse_js_1.update)(content, el);
});
}
exports.html = html;
@ -806,30 +814,30 @@ exports.html = html;
* @returns The rendered document.
*/
function toString() {
return static_1.html(this, this.options);
return this._render(this);
}
exports.toString = toString;
function text(str) {
var _this = this;
// If `str` is undefined, act as a "getter"
if (str === undefined) {
return static_1.text(this);
return (0, static_js_1.text)(this);
}
if (typeof str === 'function') {
// Function support
return utils_1.domEach(this, function (el, i) {
text.call(_this._make(el), str.call(el, i, static_1.text([el])));
return (0, utils_js_1.domEach)(this, function (el, i) {
return _this._make(el).text(str.call(el, i, (0, static_js_1.text)([el])));
});
}
// Append text node to each selected elements
return utils_1.domEach(this, function (el) {
if (!htmlparser2_1.DomUtils.hasChildren(el))
return (0, utils_js_1.domEach)(this, function (el) {
if (!(0, domhandler_1.hasChildren)(el))
return;
el.children.forEach(function (child) {
child.next = child.prev = child.parent = null;
});
var textNode = new domhandler_2.Text(str);
parse_1.update(textNode, el);
var textNode = new domhandler_1.Text("".concat(str));
(0, parse_js_1.update)(textNode, el);
});
}
exports.text = text;
@ -847,6 +855,7 @@ exports.text = text;
* @see {@link https://api.jquery.com/clone/}
*/
function clone() {
return this._make(utils_1.cloneDom(this.get()));
return this._make((0, utils_js_1.cloneDom)(this.get()));
}
exports.clone = clone;
//# sourceMappingURL=manipulation.js.map

View file

@ -3,9 +3,9 @@
*
* @module cheerio/traversing
*/
import { Node, Element, Document } from 'domhandler';
import type { Cheerio } from '../cheerio';
import type { AcceptedFilters } from '../types';
import { AnyNode, Element, Document } from 'domhandler';
import type { Cheerio } from '../cheerio.js';
import type { AcceptedFilters } from '../types.js';
/**
* Get the descendants of each element in the current set of matched elements,
* filtered by a selector, jQuery object, or element.
@ -24,7 +24,7 @@ import type { AcceptedFilters } from '../types';
* @returns The found elements.
* @see {@link https://api.jquery.com/find/}
*/
export declare function find<T extends Node>(this: Cheerio<T>, selectorOrHaystack?: string | Cheerio<Element> | Element): Cheerio<Element>;
export declare function find<T extends AnyNode>(this: Cheerio<T>, selectorOrHaystack?: string | Cheerio<Element> | Element): Cheerio<Element>;
/**
* Get the parent of each element in the current set of matched elements,
* optionally filtered by a selector.
@ -41,7 +41,7 @@ export declare function find<T extends Node>(this: Cheerio<T>, selectorOrHaystac
* @returns The parents.
* @see {@link https://api.jquery.com/parent/}
*/
export declare const parent: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const parent: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Get a set of parents filtered by `selector` of each element in the current
* set of match elements.
@ -60,7 +60,7 @@ export declare const parent: <T extends Node>(this: Cheerio<T>, selector?: Accep
* @returns The parents.
* @see {@link https://api.jquery.com/parents/}
*/
export declare const parents: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const parents: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Get the ancestors of each element in the current set of matched elements, up
* to but not including the element matched by the selector, DOM node, or cheerio object.
@ -78,7 +78,7 @@ export declare const parents: <T extends Node>(this: Cheerio<T>, selector?: Acce
* @returns The parents.
* @see {@link https://api.jquery.com/parentsUntil/}
*/
export declare const parentsUntil: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null | undefined, filterSelector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const parentsUntil: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null, filterSelector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* For each element in the set, get the first element that matches the selector
* by testing the element itself and traversing up through its ancestors in the DOM tree.
@ -104,7 +104,7 @@ export declare const parentsUntil: <T extends Node>(this: Cheerio<T>, selector?:
* @returns The closest nodes.
* @see {@link https://api.jquery.com/closest/}
*/
export declare function closest<T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Node>): Cheerio<Node>;
export declare function closest<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<AnyNode>;
/**
* Gets the next sibling of the first selected element, optionally filtered by a selector.
*
@ -120,7 +120,7 @@ export declare function closest<T extends Node>(this: Cheerio<T>, selector?: Acc
* @returns The next nodes.
* @see {@link https://api.jquery.com/next/}
*/
export declare const next: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const next: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Gets all the following siblings of the first selected element, optionally
* filtered by a selector.
@ -139,7 +139,7 @@ export declare const next: <T extends Node>(this: Cheerio<T>, selector?: Accepte
* @returns The next nodes.
* @see {@link https://api.jquery.com/nextAll/}
*/
export declare const nextAll: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const nextAll: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Gets all the following siblings up to but not including the element matched
* by the selector, optionally filtered by another selector.
@ -157,7 +157,7 @@ export declare const nextAll: <T extends Node>(this: Cheerio<T>, selector?: Acce
* @returns The next nodes.
* @see {@link https://api.jquery.com/nextUntil/}
*/
export declare const nextUntil: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null | undefined, filterSelector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const nextUntil: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null, filterSelector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Gets the previous sibling of the first selected element optionally filtered
* by a selector.
@ -174,7 +174,7 @@ export declare const nextUntil: <T extends Node>(this: Cheerio<T>, selector?: Ac
* @returns The previous nodes.
* @see {@link https://api.jquery.com/prev/}
*/
export declare const prev: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const prev: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Gets all the preceding siblings of the first selected element, optionally
* filtered by a selector.
@ -194,7 +194,7 @@ export declare const prev: <T extends Node>(this: Cheerio<T>, selector?: Accepte
* @returns The previous nodes.
* @see {@link https://api.jquery.com/prevAll/}
*/
export declare const prevAll: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const prevAll: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Gets all the preceding siblings up to but not including the element matched
* by the selector, optionally filtered by another selector.
@ -212,7 +212,7 @@ export declare const prevAll: <T extends Node>(this: Cheerio<T>, selector?: Acce
* @returns The previous nodes.
* @see {@link https://api.jquery.com/prevUntil/}
*/
export declare const prevUntil: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null | undefined, filterSelector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const prevUntil: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null, filterSelector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Get the siblings of each element (excluding the element) in the set of
* matched elements, optionally filtered by a selector.
@ -232,9 +232,9 @@ export declare const prevUntil: <T extends Node>(this: Cheerio<T>, selector?: Ac
* @returns The siblings.
* @see {@link https://api.jquery.com/siblings/}
*/
export declare const siblings: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const siblings: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Gets the children of the first selected element.
* Gets the element children of each element in the set of matched elements.
*
* @category Traversing
* @example
@ -251,7 +251,7 @@ export declare const siblings: <T extends Node>(this: Cheerio<T>, selector?: Acc
* @returns The children.
* @see {@link https://api.jquery.com/children/}
*/
export declare const children: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
export declare const children: <T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>) => Cheerio<Element>;
/**
* Gets the children of each element in the set of matched elements, including
* text and comment nodes.
@ -267,7 +267,7 @@ export declare const children: <T extends Node>(this: Cheerio<T>, selector?: Acc
* @returns The children.
* @see {@link https://api.jquery.com/contents/}
*/
export declare function contents<T extends Node>(this: Cheerio<T>): Cheerio<Node>;
export declare function contents<T extends AnyNode>(this: Cheerio<T>): Cheerio<AnyNode>;
/**
* Iterates over a cheerio object, executing a function for each matched
* element. When the callback is fired, the function is fired in the context of
@ -384,9 +384,9 @@ export declare function filter<T, S extends T>(this: Cheerio<T>, match: (this: T
export declare function filter<T, S extends AcceptedFilters<T>>(this: Cheerio<T>, match: S): Cheerio<S extends string ? Element : T>;
export declare function filterArray<T>(nodes: T[], match: AcceptedFilters<T>, xmlMode?: boolean, root?: Document): Element[] | T[];
/**
* Checks the current list of elements and returns `true` if *any* of the
* Checks the current list of elements and returns `true` if _any_ of the
* elements match the selector. If using an element or Cheerio selection,
* returns `true` if *any* of the elements match. If using a predicate function,
* returns `true` if _any_ of the elements match. If using a predicate function,
* the function is executed in the context of the selected element, so `this`
* refers to the current element.
*
@ -429,7 +429,7 @@ export declare function is<T>(this: Cheerio<T>, selector?: AcceptedFilters<T>):
* @returns The filtered collection.
* @see {@link https://api.jquery.com/not/}
*/
export declare function not<T extends Node>(this: Cheerio<T>, match: AcceptedFilters<T>): Cheerio<T>;
export declare function not<T extends AnyNode>(this: Cheerio<T>, match: AcceptedFilters<T>): Cheerio<T>;
/**
* Filters the set of matched elements to only those which have the given DOM
* element as a descendant or which have a descendant that matches the given
@ -454,7 +454,7 @@ export declare function not<T extends Node>(this: Cheerio<T>, match: AcceptedFil
* @returns The filtered collection.
* @see {@link https://api.jquery.com/has/}
*/
export declare function has(this: Cheerio<Node | Element>, selectorOrHaystack: string | Cheerio<Element> | Element): Cheerio<Node | Element>;
export declare function has(this: Cheerio<AnyNode | Element>, selectorOrHaystack: string | Cheerio<Element> | Element): Cheerio<AnyNode | Element>;
/**
* Will select the first element of a cheerio object.
*
@ -469,7 +469,7 @@ export declare function has(this: Cheerio<Node | Element>, selectorOrHaystack: s
* @returns The first element.
* @see {@link https://api.jquery.com/first/}
*/
export declare function first<T extends Node>(this: Cheerio<T>): Cheerio<T>;
export declare function first<T extends AnyNode>(this: Cheerio<T>): Cheerio<T>;
/**
* Will select the last element of a cheerio object.
*
@ -520,7 +520,7 @@ export declare function eq<T>(this: Cheerio<T>, i: number): Cheerio<T>;
* @returns The element at the `i`th position.
* @see {@link https://api.jquery.com/get/}
*/
export declare function get<T>(this: Cheerio<T>, i: number): T;
export declare function get<T>(this: Cheerio<T>, i: number): T | undefined;
/**
* Retrieve all elements matched by the Cheerio object, as an array.
*
@ -567,7 +567,7 @@ export declare function toArray<T>(this: Cheerio<T>): T[];
* @returns The index of the element.
* @see {@link https://api.jquery.com/index/}
*/
export declare function index<T extends Node>(this: Cheerio<T>, selectorOrNeedle?: string | Cheerio<Node> | Node): number;
export declare function index<T extends AnyNode>(this: Cheerio<T>, selectorOrNeedle?: string | Cheerio<AnyNode> | AnyNode): number;
/**
* Gets the elements matching the specified range (0-based position).
*
@ -582,9 +582,9 @@ export declare function index<T extends Node>(this: Cheerio<T>, selectorOrNeedle
* //=> 1
* ```
*
* @param start - An position at which the elements begin to be selected. If
* @param start - A position at which the elements begin to be selected. If
* negative, it indicates an offset from the end of the set.
* @param end - An position at which the elements stop being selected. If
* @param end - A position at which the elements stop being selected. If
* negative, it indicates an offset from the end of the set. If omitted, the
* range continues until the end of the set.
* @returns The elements matching the specified range.
@ -606,7 +606,7 @@ export declare function slice<T>(this: Cheerio<T>, start?: number, end?: number)
* @returns The previous state of the set of matched elements.
* @see {@link https://api.jquery.com/end/}
*/
export declare function end<T>(this: Cheerio<T>): Cheerio<Node>;
export declare function end<T>(this: Cheerio<T>): Cheerio<AnyNode>;
/**
* Add elements to the set of matched elements.
*
@ -623,7 +623,7 @@ export declare function end<T>(this: Cheerio<T>): Cheerio<Node>;
* @returns The combined set.
* @see {@link https://api.jquery.com/add/}
*/
export declare function add<S extends Node, T extends Node>(this: Cheerio<T>, other: string | Cheerio<S> | S | S[], context?: Cheerio<S> | string): Cheerio<S | T>;
export declare function add<S extends AnyNode, T extends AnyNode>(this: Cheerio<T>, other: string | Cheerio<S> | S | S[], context?: Cheerio<S> | string): Cheerio<S | T>;
/**
* Add the previous set of elements on the stack to the current set, optionally
* filtered by a selector.
@ -640,5 +640,5 @@ export declare function add<S extends Node, T extends Node>(this: Cheerio<T>, ot
* @returns The combined set.
* @see {@link https://api.jquery.com/addBack/}
*/
export declare function addBack<T extends Node>(this: Cheerio<T>, selector?: string): Cheerio<Node>;
export declare function addBack<T extends AnyNode>(this: Cheerio<T>, selector?: string): Cheerio<AnyNode>;
//# sourceMappingURL=traversing.d.ts.map

File diff suppressed because one or more lines are too long

View file

@ -4,15 +4,45 @@
*
* @module cheerio/traversing
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addBack = exports.add = exports.end = exports.slice = exports.index = exports.toArray = exports.get = exports.eq = exports.last = exports.first = exports.has = exports.not = exports.is = exports.filterArray = exports.filter = exports.map = exports.each = exports.contents = exports.children = exports.siblings = exports.prevUntil = exports.prevAll = exports.prev = exports.nextUntil = exports.nextAll = exports.next = exports.closest = exports.parentsUntil = exports.parents = exports.parent = exports.find = void 0;
var tslib_1 = require("tslib");
var domhandler_1 = require("domhandler");
var select = tslib_1.__importStar(require("cheerio-select"));
var utils_1 = require("../utils");
var static_1 = require("../static");
var htmlparser2_1 = require("htmlparser2");
var uniqueSort = htmlparser2_1.DomUtils.uniqueSort;
var select = __importStar(require("cheerio-select"));
var utils_js_1 = require("../utils.js");
var static_js_1 = require("../static.js");
var domutils_1 = require("domutils");
var reSiblingSelector = /^\s*[~+]/;
/**
* Get the descendants of each element in the current set of matched elements,
@ -39,10 +69,10 @@ function find(selectorOrHaystack) {
}
var context = this.toArray();
if (typeof selectorOrHaystack !== 'string') {
var haystack = utils_1.isCheerio(selectorOrHaystack)
var haystack = (0, utils_js_1.isCheerio)(selectorOrHaystack)
? selectorOrHaystack.toArray()
: [selectorOrHaystack];
return this._make(haystack.filter(function (elem) { return context.some(function (node) { return static_1.contains(node, elem); }); }));
return this._make(haystack.filter(function (elem) { return context.some(function (node) { return (0, static_js_1.contains)(node, elem); }); }));
}
var elems = reSiblingSelector.test(selectorOrHaystack)
? context
@ -50,7 +80,12 @@ function find(selectorOrHaystack) {
var options = {
context: context,
root: (_a = this._root) === null || _a === void 0 ? void 0 : _a[0],
// Pass options that are recognized by `cheerio-select`
xmlMode: this.options.xmlMode,
lowerCaseTags: this.options.lowerCaseTags,
lowerCaseAttributeNames: this.options.lowerCaseAttributeNames,
pseudos: this.options.pseudos,
quirksMode: this.options.quirksMode,
};
return this._make(select.select(selectorOrHaystack, elems, options));
}
@ -118,7 +153,7 @@ function _matchUntil(nextElem) {
var matches = null;
var innerMatcher = _getMatcher(function (nextElem, elems) {
var matched = [];
utils_1.domEach(elems, function (elem) {
(0, utils_js_1.domEach)(elems, function (elem) {
for (var next_1; (next_1 = nextElem(elem)); elem = next_1) {
// FIXME: `matched` might contain duplicates here and the index is too large.
if (matches === null || matches === void 0 ? void 0 : matches(next_1, matched.length))
@ -127,7 +162,7 @@ function _matchUntil(nextElem) {
}
});
return matched;
}).apply(void 0, tslib_1.__spreadArray([nextElem], postFns));
}).apply(void 0, __spreadArray([nextElem], postFns, false));
return function (selector, filterSelector) {
var _this = this;
// Override `matches` variable with the new target.
@ -164,7 +199,7 @@ function _removeDuplicates(elems) {
*/
exports.parent = _singleMatcher(function (_a) {
var parent = _a.parent;
return (parent && !domhandler_1.isDocument(parent) ? parent : null);
return (parent && !(0, domhandler_1.isDocument)(parent) ? parent : null);
}, _removeDuplicates);
/**
* Get a set of parents filtered by `selector` of each element in the current
@ -186,12 +221,12 @@ exports.parent = _singleMatcher(function (_a) {
*/
exports.parents = _matcher(function (elem) {
var matched = [];
while (elem.parent && !domhandler_1.isDocument(elem.parent)) {
while (elem.parent && !(0, domhandler_1.isDocument)(elem.parent)) {
matched.push(elem.parent);
elem = elem.parent;
}
return matched;
}, uniqueSort, function (elems) { return elems.reverse(); });
}, domutils_1.uniqueSort, function (elems) { return elems.reverse(); });
/**
* Get the ancestors of each element in the current set of matched elements, up
* to but not including the element matched by the selector, DOM node, or cheerio object.
@ -211,8 +246,8 @@ exports.parents = _matcher(function (elem) {
*/
exports.parentsUntil = _matchUntil(function (_a) {
var parent = _a.parent;
return (parent && !domhandler_1.isDocument(parent) ? parent : null);
}, uniqueSort, function (elems) { return elems.reverse(); });
return (parent && !(0, domhandler_1.isDocument)(parent) ? parent : null);
}, domutils_1.uniqueSort, function (elems) { return elems.reverse(); });
/**
* For each element in the set, get the first element that matches the selector
* by testing the element itself and traversing up through its ancestors in the DOM tree.
@ -239,19 +274,23 @@ exports.parentsUntil = _matchUntil(function (_a) {
* @see {@link https://api.jquery.com/closest/}
*/
function closest(selector) {
var _this = this;
var _a;
var set = [];
if (!selector) {
return this._make(set);
}
utils_1.domEach(this, function (elem) {
var _a;
while (elem && elem.type !== 'root') {
if (!selector ||
filterArray([elem], selector, _this.options.xmlMode, (_a = _this._root) === null || _a === void 0 ? void 0 : _a[0])
.length) {
var selectOpts = {
xmlMode: this.options.xmlMode,
root: (_a = this._root) === null || _a === void 0 ? void 0 : _a[0],
};
var selectFn = typeof selector === 'string'
? function (elem) { return select.is(elem, selector, selectOpts); }
: getFilterFn(selector);
(0, utils_js_1.domEach)(this, function (elem) {
while (elem && (0, utils_js_1.isTag)(elem)) {
if (selectFn(elem, 0)) {
// Do not add duplicate elements to the set
if (elem && !set.includes(elem)) {
if (!set.includes(elem)) {
set.push(elem);
}
break;
@ -277,7 +316,7 @@ exports.closest = closest;
* @returns The next nodes.
* @see {@link https://api.jquery.com/next/}
*/
exports.next = _singleMatcher(function (elem) { return htmlparser2_1.DomUtils.nextElementSibling(elem); });
exports.next = _singleMatcher(function (elem) { return (0, domutils_1.nextElementSibling)(elem); });
/**
* Gets all the following siblings of the first selected element, optionally
* filtered by a selector.
@ -300,7 +339,7 @@ exports.nextAll = _matcher(function (elem) {
var matched = [];
while (elem.next) {
elem = elem.next;
if (utils_1.isTag(elem))
if ((0, utils_js_1.isTag)(elem))
matched.push(elem);
}
return matched;
@ -322,7 +361,7 @@ exports.nextAll = _matcher(function (elem) {
* @returns The next nodes.
* @see {@link https://api.jquery.com/nextUntil/}
*/
exports.nextUntil = _matchUntil(function (el) { return htmlparser2_1.DomUtils.nextElementSibling(el); }, _removeDuplicates);
exports.nextUntil = _matchUntil(function (el) { return (0, domutils_1.nextElementSibling)(el); }, _removeDuplicates);
/**
* Gets the previous sibling of the first selected element optionally filtered
* by a selector.
@ -339,7 +378,7 @@ exports.nextUntil = _matchUntil(function (el) { return htmlparser2_1.DomUtils.ne
* @returns The previous nodes.
* @see {@link https://api.jquery.com/prev/}
*/
exports.prev = _singleMatcher(function (elem) { return htmlparser2_1.DomUtils.prevElementSibling(elem); });
exports.prev = _singleMatcher(function (elem) { return (0, domutils_1.prevElementSibling)(elem); });
/**
* Gets all the preceding siblings of the first selected element, optionally
* filtered by a selector.
@ -363,7 +402,7 @@ exports.prevAll = _matcher(function (elem) {
var matched = [];
while (elem.prev) {
elem = elem.prev;
if (utils_1.isTag(elem))
if ((0, utils_js_1.isTag)(elem))
matched.push(elem);
}
return matched;
@ -385,7 +424,7 @@ exports.prevAll = _matcher(function (elem) {
* @returns The previous nodes.
* @see {@link https://api.jquery.com/prevUntil/}
*/
exports.prevUntil = _matchUntil(function (el) { return htmlparser2_1.DomUtils.prevElementSibling(el); }, _removeDuplicates);
exports.prevUntil = _matchUntil(function (el) { return (0, domutils_1.prevElementSibling)(el); }, _removeDuplicates);
/**
* Get the siblings of each element (excluding the element) in the set of
* matched elements, optionally filtered by a selector.
@ -406,10 +445,10 @@ exports.prevUntil = _matchUntil(function (el) { return htmlparser2_1.DomUtils.pr
* @see {@link https://api.jquery.com/siblings/}
*/
exports.siblings = _matcher(function (elem) {
return htmlparser2_1.DomUtils.getSiblings(elem).filter(function (el) { return utils_1.isTag(el) && el !== elem; });
}, uniqueSort);
return (0, domutils_1.getSiblings)(elem).filter(function (el) { return (0, utils_js_1.isTag)(el) && el !== elem; });
}, domutils_1.uniqueSort);
/**
* Gets the children of the first selected element.
* Gets the element children of each element in the set of matched elements.
*
* @category Traversing
* @example
@ -426,7 +465,7 @@ exports.siblings = _matcher(function (elem) {
* @returns The children.
* @see {@link https://api.jquery.com/children/}
*/
exports.children = _matcher(function (elem) { return htmlparser2_1.DomUtils.getChildren(elem).filter(utils_1.isTag); }, _removeDuplicates);
exports.children = _matcher(function (elem) { return (0, domutils_1.getChildren)(elem).filter(utils_js_1.isTag); }, _removeDuplicates);
/**
* Gets the children of each element in the set of matched elements, including
* text and comment nodes.
@ -444,7 +483,7 @@ exports.children = _matcher(function (elem) { return htmlparser2_1.DomUtils.getC
*/
function contents() {
var elems = this.toArray().reduce(function (newElems, elem) {
return domhandler_1.hasChildren(elem) ? newElems.concat(elem.children) : newElems;
return (0, domhandler_1.hasChildren)(elem) ? newElems.concat(elem.children) : newElems;
}, []);
return this._make(elems);
}
@ -530,7 +569,7 @@ function getFilterFn(match) {
if (typeof match === 'function') {
return function (el, i) { return match.call(el, i, el); };
}
if (utils_1.isCheerio(match)) {
if ((0, utils_js_1.isCheerio)(match)) {
return function (el) { return Array.prototype.includes.call(match, el); };
}
return function (el) {
@ -549,9 +588,9 @@ function filterArray(nodes, match, xmlMode, root) {
}
exports.filterArray = filterArray;
/**
* Checks the current list of elements and returns `true` if *any* of the
* Checks the current list of elements and returns `true` if _any_ of the
* elements match the selector. If using an element or Cheerio selection,
* returns `true` if *any* of the elements match. If using a predicate function,
* returns `true` if _any_ of the elements match. If using a predicate function,
* the function is executed in the context of the selected element, so `this`
* refers to the current element.
*
@ -563,7 +602,7 @@ exports.filterArray = filterArray;
function is(selector) {
var nodes = this.toArray();
return typeof selector === 'string'
? select.some(nodes.filter(utils_1.isTag), selector, this.options)
? select.some(nodes.filter(utils_js_1.isTag), selector, this.options)
: selector
? nodes.some(getFilterFn(selector))
: false;
@ -643,7 +682,7 @@ function has(selectorOrHaystack) {
var _this = this;
return this.filter(typeof selectorOrHaystack === 'string'
? // Using the `:has` selector here short-circuits searches.
":has(" + selectorOrHaystack + ")"
":has(".concat(selectorOrHaystack, ")")
: function (_, el) { return _this._make(el).find(selectorOrHaystack).length > 0; });
}
exports.has = has;
@ -766,8 +805,9 @@ function index(selectorOrNeedle) {
needle = this[0];
}
else {
// eslint-disable-next-line @typescript-eslint/no-this-alias
$haystack = this;
needle = utils_1.isCheerio(selectorOrNeedle)
needle = (0, utils_js_1.isCheerio)(selectorOrNeedle)
? selectorOrNeedle[0]
: selectorOrNeedle;
}
@ -788,9 +828,9 @@ exports.index = index;
* //=> 1
* ```
*
* @param start - An position at which the elements begin to be selected. If
* @param start - A position at which the elements begin to be selected. If
* negative, it indicates an offset from the end of the set.
* @param end - An position at which the elements stop being selected. If
* @param end - A position at which the elements stop being selected. If
* negative, it indicates an offset from the end of the set. If omitted, the
* range continues until the end of the set.
* @returns The elements matching the specified range.
@ -838,7 +878,7 @@ exports.end = end;
*/
function add(other, context) {
var selection = this._make(other, context);
var contents = uniqueSort(tslib_1.__spreadArray(tslib_1.__spreadArray([], this.get()), selection.get()));
var contents = (0, domutils_1.uniqueSort)(__spreadArray(__spreadArray([], this.get(), true), selection.get(), true));
return this._make(contents);
}
exports.add = add;
@ -864,3 +904,4 @@ function addBack(selector) {
: this;
}
exports.addBack = addBack;
//# sourceMappingURL=traversing.js.map

View file

@ -1,17 +1,18 @@
import { InternalOptions } from './options';
import type { Node, Document } from 'domhandler';
import { BasicAcceptedElems } from './types';
import * as Attributes from './api/attributes';
import * as Traversing from './api/traversing';
import * as Manipulation from './api/manipulation';
import * as Css from './api/css';
import * as Forms from './api/forms';
/// <reference types="node" />
import type { InternalOptions } from './options.js';
import type { AnyNode, Document, ParentNode } from 'domhandler';
import type { BasicAcceptedElems } from './types.js';
import * as Attributes from './api/attributes.js';
import * as Traversing from './api/traversing.js';
import * as Manipulation from './api/manipulation.js';
import * as Css from './api/css.js';
import * as Forms from './api/forms.js';
declare type AttributesType = typeof Attributes;
declare type TraversingType = typeof Traversing;
declare type ManipulationType = typeof Manipulation;
declare type CssType = typeof Css;
declare type FormsType = typeof Forms;
export declare class Cheerio<T> implements ArrayLike<T> {
export declare abstract class Cheerio<T> implements ArrayLike<T> {
length: number;
[index: number]: T;
options: InternalOptions;
@ -20,21 +21,18 @@ export declare class Cheerio<T> implements ArrayLike<T> {
*
* @private
*/
_root: Cheerio<Document> | undefined;
/** @function */
find: typeof Traversing.find;
_root: Cheerio<Document> | null;
/**
* Instance of cheerio. Methods are specified in the modules. Usage of this
* constructor is not recommended. Please use $.load instead.
* constructor is not recommended. Please use `$.load` instead.
*
* @private
* @param selector - The new selection.
* @param context - Context of the selection.
* @param elements - The new selection.
* @param root - Sets the root node.
* @param options - Options for the instance.
*/
constructor(selector?: T extends Node ? BasicAcceptedElems<T> : Cheerio<T> | T[], context?: BasicAcceptedElems<Node> | null, root?: BasicAcceptedElems<Document> | null, options?: InternalOptions);
prevObject: Cheerio<Node> | undefined;
constructor(elements: ArrayLike<T> | undefined, root: Cheerio<Document> | null, options: InternalOptions);
prevObject: Cheerio<any> | undefined;
/**
* Make a cheerio object.
*
@ -43,7 +41,25 @@ export declare class Cheerio<T> implements ArrayLike<T> {
* @param context - The context of the new object.
* @returns The new cheerio object.
*/
_make<T>(dom: Cheerio<T> | T[] | T | string, context?: BasicAcceptedElems<Node>): Cheerio<T>;
abstract _make<T>(dom: ArrayLike<T> | T | string, context?: BasicAcceptedElems<AnyNode>): Cheerio<T>;
/**
* Parses some content.
*
* @private
* @param content - Content to parse.
* @param options - Options for parsing.
* @param isDocument - Allows parser to be switched to fragment mode.
* @returns A document containing the `content`.
*/
abstract _parse(content: string | Document | AnyNode | AnyNode[] | Buffer, options: InternalOptions, isDocument: boolean, context: ParentNode | null): Document;
/**
* Render an element or a set of elements.
*
* @private
* @param dom - DOM to render.
* @returns The rendered DOM.
*/
abstract _render(dom: AnyNode | ArrayLike<AnyNode>): string;
}
export interface Cheerio<T> extends AttributesType, TraversingType, ManipulationType, CssType, FormsType, Iterable<T> {
cheerio: '[cheerio object]';

View file

@ -1 +1 @@
{"version":3,"file":"cheerio.d.ts","sourceRoot":"","sources":["../src/cheerio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA6B,MAAM,WAAW,CAAC;AAEvE,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,K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d,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,QAAQ,CAAC,CAAC,CAAC;IACb,OAAO,EAAE,kBAAkB,CAAC;IAE5B,MAAM,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;CACtC"}
{"version":3,"file":"cheerio.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["cheerio.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAExC,aAAK,cAAc,GAAG,OAAO,UAAU,CAAC;AACxC,aAAK,cAAc,GAAG,OAAO,UAAU,CAAC;AACxC,aAAK,gBAAgB,GAAG,OAAO,YAAY,CAAC;AAC5C,aAAK,OAAO,GAAG,OAAO,GAAG,CAAC;AAC1B,aAAK,SAAS,GAAG,OAAO,KAAK,CAAC;AAE9B,8BAAsB,OAAO,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IACtD,MAAM,SAAK;IACX,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC;IAEnB,OAAO,EAAE,eAAe,CAAC;IACzB;;;;OAIG;IACH,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IAEhC;;;;;;;;OAQG;gBAED,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,EAClC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,EAC9B,OAAO,EAAE,eAAe;IAa1B,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACrC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,CAAC,CAAC,EACd,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,EAC9B,OAAO,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,GACpC,OAAO,CAAC,CAAC,CAAC;IAEb;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,CACb,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,EACzD,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,UAAU,GAAG,IAAI,GACzB,QAAQ;IAEX;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM;CAC5D;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,CACxB,SAAQ,cAAc,EACpB,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,QAAQ,CAAC,CAAC,CAAC;IACb,OAAO,EAAE,kBAAkB,CAAC;IAE5B,MAAM,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;CACtC"}

121
node_modules/cheerio/lib/cheerio.js generated vendored
View file

@ -1,99 +1,55 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cheerio = void 0;
var tslib_1 = require("tslib");
var parse_1 = tslib_1.__importDefault(require("./parse"));
var options_1 = tslib_1.__importDefault(require("./options"));
var utils_1 = require("./utils");
var Attributes = tslib_1.__importStar(require("./api/attributes"));
var Traversing = tslib_1.__importStar(require("./api/traversing"));
var Manipulation = tslib_1.__importStar(require("./api/manipulation"));
var Css = tslib_1.__importStar(require("./api/css"));
var Forms = tslib_1.__importStar(require("./api/forms"));
var Attributes = __importStar(require("./api/attributes.js"));
var Traversing = __importStar(require("./api/traversing.js"));
var Manipulation = __importStar(require("./api/manipulation.js"));
var Css = __importStar(require("./api/css.js"));
var Forms = __importStar(require("./api/forms.js"));
var Cheerio = /** @class */ (function () {
/**
* Instance of cheerio. Methods are specified in the modules. Usage of this
* constructor is not recommended. Please use $.load instead.
* constructor is not recommended. Please use `$.load` instead.
*
* @private
* @param selector - The new selection.
* @param context - Context of the selection.
* @param elements - The new selection.
* @param root - Sets the root node.
* @param options - Options for the instance.
*/
function Cheerio(selector, context, root, options) {
var _this = this;
if (options === void 0) { options = options_1.default; }
function Cheerio(elements, root, options) {
this.length = 0;
this.options = options;
// $(), $(null), $(undefined), $(false)
if (!selector)
return this;
if (root) {
if (typeof root === 'string')
root = parse_1.default(root, this.options, false);
this._root = new this.constructor(root, null, null, this.options);
// Add a cyclic reference, so that calling methods on `_root` never fails.
this._root._root = this._root;
}
// $($)
if (utils_1.isCheerio(selector))
return selector;
var elements = typeof selector === 'string' && utils_1.isHtml(selector)
? // $(<html>)
parse_1.default(selector, this.options, false).children
: isNode(selector)
? // $(dom)
[selector]
: Array.isArray(selector)
? // $([dom])
selector
: null;
this._root = root;
if (elements) {
elements.forEach(function (elem, idx) {
_this[idx] = elem;
});
for (var idx = 0; idx < elements.length; idx++) {
this[idx] = elements[idx];
}
this.length = elements.length;
return this;
}
// We know that our selector is a string now.
var search = selector;
var searchContext = !context
? // If we don't have a context, maybe we have a root, from loading
this._root
: typeof context === 'string'
? utils_1.isHtml(context)
? // $('li', '<ul>...</ul>')
this._make(parse_1.default(context, this.options, false))
: // $('li', 'ul')
((search = context + " " + search), this._root)
: utils_1.isCheerio(context)
? // $('li', $)
context
: // $('li', node), $('li', [nodes])
this._make(context);
// If we still don't have a context, return
if (!searchContext)
return this;
/*
* #id, .class, tag
*/
// @ts-expect-error No good way to type this — we will always return `Cheerio<Element>` here.
return searchContext.find(search);
}
/**
* Make a cheerio object.
*
* @private
* @param dom - The contents of the new object.
* @param context - The context of the new object.
* @returns The new cheerio object.
*/
Cheerio.prototype._make = function (dom, context) {
var cheerio = new this.constructor(dom, context, this._root, this.options);
cheerio.prevObject = this;
return cheerio;
};
return Cheerio;
}());
exports.Cheerio = Cheerio;
@ -107,9 +63,4 @@ Cheerio.prototype.splice = Array.prototype.splice;
Cheerio.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
// Plug in the API
Object.assign(Cheerio.prototype, Attributes, Traversing, Manipulation, Css, Forms);
function isNode(obj) {
return (!!obj.name ||
obj.type === 'root' ||
obj.type === 'text' ||
obj.type === 'comment');
}
//# sourceMappingURL=cheerio.js.map

30
node_modules/cheerio/lib/index.d.ts generated vendored
View file

@ -1,31 +1,47 @@
/// <reference types="node" />
/**
* The main types of Cheerio objects.
*
* @category Cheerio
*/
export type { Cheerio } from './cheerio';
export type { Cheerio } from './cheerio.js';
/**
* Types used in signatures of Cheerio methods.
*
* @category Cheerio
*/
export * from './types';
export type { CheerioOptions, HTMLParser2Options, Parse5Options, } from './options';
export * from './types.js';
export type { CheerioOptions, HTMLParser2Options, Parse5Options, } from './options.js';
/**
* Re-exporting all of the node types.
*
* @category DOM Node
*/
export type { Node, NodeWithChildren, Element, Document } from 'domhandler';
export * from './load';
declare const _default: import("./load").CheerioAPI;
export type { Node, AnyNode, ParentNode, Element, Document } from 'domhandler';
export type { CheerioAPI } from './load.js';
/**
* Create a querying function, bound to a document created from the provided markup.
*
* Note that similar to web browser contexts, this operation may introduce
* `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
* switch to fragment mode and disable this.
*
* @param content - Markup to be loaded.
* @param options - Options for the created instance.
* @param isDocument - Allows parser to be switched to fragment mode.
* @returns The loaded document.
* @see {@link https://cheerio.js.org#loading} for additional usage information.
*/
export declare const load: (content: string | import("domhandler").AnyNode | import("domhandler").AnyNode[] | Buffer, options?: import("./options.js").CheerioOptions | null | undefined, isDocument?: boolean) => import("./load.js").CheerioAPI;
/**
* The default cheerio instance.
*
* @deprecated Use the function returned by `load` instead.
*/
declare const _default: import("./load.js").CheerioAPI;
export default _default;
import * as staticMethods from './static';
export { html, xml, text } from './static.js';
import * as staticMethods from './static.js';
/**
* In order to promote consistency with the jQuery library, users are encouraged
* to instead use the static method of the same name.

View file

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC;;;;GAIG;AACH,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,GACd,MAAM,WAAW,CAAC;AACnB;;;;GAIG;AACH,YAAY,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5E,cAAc,QAAQ,CAAC;;AAGvB;;;;GAIG;AACH,wBAAwB;AAExB,OAAO,KAAK,aAAa,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAQ,QAAQ,+BAAkB,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAQ,KAAK,4BAAkB,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAQ,SAAS,gCAAkB,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,eAAO,MAAQ,IAAI,2BAAkB,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;GAIG;AACH,cAAc,YAAY,CAAC;AAC3B,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,GACd,MAAM,cAAc,CAAC;AACtB;;;;GAIG;AACH,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE/E,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAc5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI,wNAIhB,CAAC;AAEF;;;;GAIG;;AACH,wBAAwB;AAExB,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,aAAa,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAQ,QAAQ,+BAAkB,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAQ,KAAK,4BAAkB,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAQ,SAAS,gCAAkB,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,eAAO,MAAQ,IAAI,2BAAkB,CAAC"}

74
node_modules/cheerio/lib/index.js generated vendored
View file

@ -1,22 +1,81 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
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);
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.root = exports.parseHTML = exports.merge = exports.contains = void 0;
var tslib_1 = require("tslib");
exports.root = exports.parseHTML = exports.merge = exports.contains = exports.text = exports.xml = exports.html = exports.load = void 0;
/**
* Types used in signatures of Cheerio methods.
*
* @category Cheerio
*/
tslib_1.__exportStar(require("./types"), exports);
tslib_1.__exportStar(require("./load"), exports);
var load_1 = require("./load");
__exportStar(require("./types.js"), exports);
var load_js_1 = require("./load.js");
var parse_js_1 = require("./parse.js");
var parse5_adapter_js_1 = require("./parsers/parse5-adapter.js");
var dom_serializer_1 = __importDefault(require("dom-serializer"));
var htmlparser2_1 = require("htmlparser2");
var parse = (0, parse_js_1.getParse)(function (content, options, isDocument, context) {
return options.xmlMode || options._useHtmlParser2
? (0, htmlparser2_1.parseDocument)(content, options)
: (0, parse5_adapter_js_1.parseWithParse5)(content, options, isDocument, context);
});
// Duplicate docs due to https://github.com/TypeStrong/typedoc/issues/1616
/**
* Create a querying function, bound to a document created from the provided markup.
*
* Note that similar to web browser contexts, this operation may introduce
* `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
* switch to fragment mode and disable this.
*
* @param content - Markup to be loaded.
* @param options - Options for the created instance.
* @param isDocument - Allows parser to be switched to fragment mode.
* @returns The loaded document.
* @see {@link https://cheerio.js.org#loading} for additional usage information.
*/
exports.load = (0, load_js_1.getLoad)(parse, function (dom, options) {
return options.xmlMode || options._useHtmlParser2
? (0, dom_serializer_1.default)(dom, options)
: (0, parse5_adapter_js_1.renderWithParse5)(dom);
});
/**
* The default cheerio instance.
*
* @deprecated Use the function returned by `load` instead.
*/
exports.default = load_1.load([]);
var staticMethods = tslib_1.__importStar(require("./static"));
exports.default = (0, exports.load)([]);
var static_js_1 = require("./static.js");
Object.defineProperty(exports, "html", { enumerable: true, get: function () { return static_js_1.html; } });
Object.defineProperty(exports, "xml", { enumerable: true, get: function () { return static_js_1.xml; } });
Object.defineProperty(exports, "text", { enumerable: true, get: function () { return static_js_1.text; } });
var staticMethods = __importStar(require("./static.js"));
/**
* In order to promote consistency with the jQuery library, users are encouraged
* to instead use the static method of the same name.
@ -79,3 +138,4 @@ exports.parseHTML = staticMethods.parseHTML;
* ```
*/
exports.root = staticMethods.root;
//# sourceMappingURL=index.js.map

31
node_modules/cheerio/lib/load.d.ts generated vendored
View file

@ -1,18 +1,16 @@
/// <reference types="node" />
import { CheerioOptions, InternalOptions } from './options';
import * as staticMethods from './static';
import { Cheerio } from './cheerio';
import type { Node, Document, Element } from 'domhandler';
import type * as Load from './load';
import { SelectorType, BasicAcceptedElems } from './types';
import { CheerioOptions, InternalOptions } from './options.js';
import * as staticMethods from './static.js';
import { Cheerio } from './cheerio.js';
import type { AnyNode, Document, Element } from 'domhandler';
import type { SelectorType, BasicAcceptedElems } from './types.js';
declare type StaticType = typeof staticMethods;
declare type LoadType = typeof Load;
/**
* A querying function, bound to a document created from the provided markup.
*
* Also provides several helper methods for dealing with the document as a whole.
*/
export interface CheerioAPI extends StaticType, LoadType {
export interface CheerioAPI extends StaticType {
/**
* This selector method is the starting point for traversing and manipulating
* the document. Like jQuery, it's the primary method for selecting elements
@ -40,7 +38,7 @@ export interface CheerioAPI extends StaticType, LoadType {
* contents of the document to query.
* @param root - Optional HTML document string.
*/
<T extends Node, S extends string>(selector?: S | BasicAcceptedElems<T>, context?: BasicAcceptedElems<Node> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions): Cheerio<S extends SelectorType ? Element : T>;
<T extends AnyNode, S extends string>(selector?: S | BasicAcceptedElems<T>, context?: BasicAcceptedElems<AnyNode> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions): Cheerio<S extends SelectorType ? Element : T>;
/**
* The root the document was originally loaded with.
*
@ -55,19 +53,8 @@ export interface CheerioAPI extends StaticType, LoadType {
_options: InternalOptions;
/** Mimic jQuery's prototype alias for plugin authors. */
fn: typeof Cheerio.prototype;
load: ReturnType<typeof getLoad>;
}
/**
* Create a querying function, bound to a document created from the provided
* markup. Note that similar to web browser contexts, this operation may
* introduce `<html>`, `<head>`, and `<body>` elements; set `isDocument` to
* `false` to switch to fragment mode and disable this.
*
* @param content - Markup to be loaded.
* @param options - Options for the created instance.
* @param isDocument - Allows parser to be switched to fragment mode.
* @returns The loaded document.
* @see {@link https://cheerio.js.org#loading} for additional usage information.
*/
export declare function load(content: string | Node | Node[] | Buffer, options?: CheerioOptions | null, isDocument?: boolean): CheerioAPI;
export declare function getLoad(parse: typeof Cheerio.prototype._parse, render: (dom: AnyNode | ArrayLike<AnyNode>, options: InternalOptions) => string): (content: string | AnyNode | AnyNode[] | Buffer, options?: CheerioOptions | null, isDocument?: boolean) => CheerioAPI;
export {};
//# sourceMappingURL=load.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":";AAAA,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,SAAS,CAAC,OAAO,CAAC,EACjC,OAAO,EAAE,eAAe,KACrB,MAAM,aAgBA,MAAM,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,YACpC,cAAc,GAAG,IAAI,2BAE9B,UAAU,CAyId"}

166
node_modules/cheerio/lib/load.js generated vendored
View file

@ -1,16 +1,66 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.load = void 0;
var tslib_1 = require("tslib");
var options_1 = tslib_1.__importStar(require("./options"));
var staticMethods = tslib_1.__importStar(require("./static"));
var cheerio_1 = require("./cheerio");
var parse_1 = tslib_1.__importDefault(require("./parse"));
exports.getLoad = void 0;
var options_js_1 = __importStar(require("./options.js"));
var staticMethods = __importStar(require("./static.js"));
var cheerio_js_1 = require("./cheerio.js");
var utils_js_1 = require("./utils.js");
function getLoad(parse, render) {
/**
* Create a querying function, bound to a document created from the provided
* markup. Note that similar to web browser contexts, this operation may
* introduce `<html>`, `<head>`, and `<body>` elements; set `isDocument` to
* `false` to switch to fragment mode and disable this.
* Create a querying function, bound to a document created from the provided markup.
*
* Note that similar to web browser contexts, this operation may introduce
* `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
* switch to fragment mode and disable this.
*
* @param content - Markup to be loaded.
* @param options - Options for the created instance.
@ -18,30 +68,98 @@ var parse_1 = tslib_1.__importDefault(require("./parse"));
* @returns The loaded document.
* @see {@link https://cheerio.js.org#loading} for additional usage information.
*/
function load(content, options, isDocument) {
return function load(content, options, isDocument) {
if (isDocument === void 0) { isDocument = true; }
if (content == null) {
throw new Error('cheerio.load() expects a string');
}
var internalOpts = tslib_1.__assign(tslib_1.__assign({}, options_1.default), options_1.flatten(options));
var root = parse_1.default(content, internalOpts, isDocument);
var internalOpts = __assign(__assign({}, options_js_1.default), (0, options_js_1.flatten)(options));
var initialRoot = parse(content, internalOpts, isDocument, null);
/** Create an extended class here, so that extensions only live on one instance. */
var LoadedCheerio = /** @class */ (function (_super) {
tslib_1.__extends(LoadedCheerio, _super);
__extends(LoadedCheerio, _super);
function LoadedCheerio() {
return _super !== null && _super.apply(this, arguments) || this;
}
LoadedCheerio.prototype._make = function (selector, context) {
var cheerio = initialize(selector, context);
cheerio.prevObject = this;
return cheerio;
};
LoadedCheerio.prototype._parse = function (content, options, isDocument, context) {
return parse(content, options, isDocument, context);
};
LoadedCheerio.prototype._render = function (dom) {
return render(dom, this.options);
};
return LoadedCheerio;
}(cheerio_1.Cheerio));
function initialize(selector, context, r, opts) {
if (r === void 0) { r = root; }
return new LoadedCheerio(selector, context, r, tslib_1.__assign(tslib_1.__assign({}, internalOpts), options_1.flatten(opts)));
}(cheerio_js_1.Cheerio));
function initialize(selector, context, root, opts) {
if (root === void 0) { root = initialRoot; }
// $($)
if (selector && (0, utils_js_1.isCheerio)(selector))
return selector;
var options = __assign(__assign({}, internalOpts), (0, options_js_1.flatten)(opts));
var r = typeof root === 'string'
? [parse(root, options, false, null)]
: 'length' in root
? root
: [root];
var rootInstance = (0, utils_js_1.isCheerio)(r)
? r
: new LoadedCheerio(r, null, options);
// Add a cyclic reference, so that calling methods on `_root` never fails.
rootInstance._root = rootInstance;
// $(), $(null), $(undefined), $(false)
if (!selector) {
return new LoadedCheerio(undefined, rootInstance, options);
}
var elements = typeof selector === 'string' && (0, utils_js_1.isHtml)(selector)
? // $(<html>)
parse(selector, options, false, null).children
: isNode(selector)
? // $(dom)
[selector]
: Array.isArray(selector)
? // $([dom])
selector
: undefined;
var instance = new LoadedCheerio(elements, rootInstance, options);
if (elements) {
return instance;
}
if (typeof selector !== 'string') {
throw new Error('Unexpected type of selector');
}
// We know that our selector is a string now.
var search = selector;
var searchContext = !context
? // If we don't have a context, maybe we have a root, from loading
rootInstance
: typeof context === 'string'
? (0, utils_js_1.isHtml)(context)
? // $('li', '<ul>...</ul>')
new LoadedCheerio([parse(context, options, false, null)], rootInstance, options)
: // $('li', 'ul')
((search = "".concat(context, " ").concat(search)), rootInstance)
: (0, utils_js_1.isCheerio)(context)
? // $('li', $)
context
: // $('li', node), $('li', [nodes])
new LoadedCheerio(Array.isArray(context) ? context : [context], rootInstance, options);
// If we still don't have a context, return
if (!searchContext)
return instance;
/*
* #id, .class, tag
*/
return searchContext.find(search);
}
// Add in static methods & properties
Object.assign(initialize, staticMethods, {
load: load,
// `_root` and `_options` are used in static methods.
_root: root,
_root: initialRoot,
_options: internalOpts,
// Add `fn` for plugins
fn: LoadedCheerio.prototype,
@ -49,5 +167,13 @@ function load(content, options, isDocument) {
prototype: LoadedCheerio.prototype,
});
return initialize;
};
}
exports.load = load;
exports.getLoad = getLoad;
function isNode(obj) {
return (!!obj.name ||
obj.type === 'root' ||
obj.type === 'text' ||
obj.type === 'comment');
}
//# sourceMappingURL=load.js.map

View file

@ -1,6 +1,12 @@
/// <reference types="node" />
import type { DomHandlerOptions } from 'domhandler';
import type { ParserOptions } from 'htmlparser2';
/** Options accepted by htmlparser2, the default parser for XML. */
import type { Options as SelectOptions } from 'cheerio-select';
/**
* Options accepted by htmlparser2, the default parser for XML.
*
* @see https://github.com/fb55/htmlparser2/wiki/Parser-options
*/
export interface HTMLParser2Options extends DomHandlerOptions, ParserOptions {
}
/** Options for parse5, the default parser for HTML. */
@ -10,22 +16,75 @@ export interface Parse5Options {
/** Enable location support for parse5. */
sourceCodeLocationInfo?: boolean;
}
/** Internal options for Cheerio. */
export interface InternalOptions extends HTMLParser2Options, Parse5Options {
_useHtmlParser2?: boolean;
}
/**
* Options accepted by Cheerio.
*
* Please note that parser-specific options are *only recognized* if the
* Please note that parser-specific options are _only recognized_ if the
* relevant parser is used.
*/
export interface CheerioOptions extends HTMLParser2Options, Parse5Options {
/** Suggested way of configuring htmlparser2 when wanting to parse XML. */
/** Recommended way of configuring htmlparser2 when wanting to parse XML. */
xml?: HTMLParser2Options | boolean;
/** The base URI for the document. Used for the `href` and `src` props. */
baseURI?: string | URL;
/**
* Is the document in quirks mode?
*
* This will lead to `.className` and `#id` being case-insensitive.
*
* @default false
*/
quirksMode?: SelectOptions['quirksMode'];
/**
* Extension point for pseudo-classes.
*
* Maps from names to either strings of functions.
*
* - A string value is a selector that the element must match to be selected.
* - A function is called with the element as its first argument, and optional
* parameters second. If it returns true, the element is selected.
*
* @example
*
* ```js
* const $ = cheerio.load(
* '<div class="foo"></div><div data-bar="boo"></div>',
* {
* pseudos: {
* // `:foo` is an alias for `div.foo`
* foo: 'div.foo',
* // `:bar(val)` is equivalent to `[data-bar=val s]`
* bar: (el, val) => el.attribs['data-bar'] === val,
* },
* }
* );
*
* $(':foo').length; // 1
* $('div:bar(boo)').length; // 1
* $('div:bar(baz)').length; // 0
* ```
*/
pseudos?: SelectOptions['pseudos'];
}
/** Internal options for Cheerio. */
export interface InternalOptions extends Omit<CheerioOptions, 'xml'> {
/**
* Whether to use htmlparser2.
*
* This is set to true if `xml` is set to true.
*/
_useHtmlParser2?: boolean;
}
declare const defaultOpts: CheerioOptions;
/** Cheerio default options. */
export default defaultOpts;
/**
* Flatten the options for Cheerio.
*
* This will set `_useHtmlParser2` to true if `xml` is set to true.
*
* @param options - The options to flatten.
* @returns The flattened options.
*/
export declare function flatten(options?: CheerioOptions | null): InternalOptions | undefined;
//# sourceMappingURL=options.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,mEAAmE;AACnE,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB,EAAE,aAAa;CAAG;AAC/E,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0CAA0C;IAC1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,oCAAoC;AACpC,MAAM,WAAW,eAAgB,SAAQ,kBAAkB,EAAE,aAAa;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,kBAAkB,EAAE,aAAa;IACvE,0EAA0E;IAC1E,GAAG,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC;CACpC;AAED,QAAA,MAAM,WAAW,EAAE,cAGlB,CAAC;AAEF,+BAA+B;AAC/B,eAAe,WAAW,CAAC;AAO3B,wBAAgB,OAAO,CACrB,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,GAC9B,eAAe,GAAG,SAAS,CAM7B"}
{"version":3,"file":"options.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["options.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB,EAAE,aAAa;CAAG;AAC/E,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0CAA0C;IAC1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,kBAAkB,EAAE,aAAa;IACvE,4EAA4E;IAC5E,GAAG,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAEnC,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IAEvB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACpC;AAED,oCAAoC;AACpC,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC;IAClE;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,QAAA,MAAM,WAAW,EAAE,cAGlB,CAAC;AAEF,+BAA+B;AAC/B,eAAe,WAAW,CAAC;AAO3B;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,GAC9B,eAAe,GAAG,SAAS,CAM7B"}

23
node_modules/cheerio/lib/options.js generated vendored
View file

@ -1,7 +1,17 @@
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.flatten = void 0;
var tslib_1 = require("tslib");
var defaultOpts = {
xml: false,
decodeEntities: true,
@ -12,11 +22,20 @@ var xmlModeDefault = {
_useHtmlParser2: true,
xmlMode: true,
};
/**
* Flatten the options for Cheerio.
*
* This will set `_useHtmlParser2` to true if `xml` is set to true.
*
* @param options - The options to flatten.
* @returns The flattened options.
*/
function flatten(options) {
return (options === null || options === void 0 ? void 0 : options.xml)
? typeof options.xml === 'boolean'
? xmlModeDefault
: tslib_1.__assign(tslib_1.__assign({}, xmlModeDefault), options.xml)
: __assign(__assign({}, xmlModeDefault), options.xml)
: options !== null && options !== void 0 ? options : undefined;
}
exports.flatten = flatten;
//# sourceMappingURL=options.js.map

14
node_modules/cheerio/lib/parse.d.ts generated vendored
View file

@ -1,7 +1,13 @@
/// <reference types="node" />
import { Node, Document, NodeWithChildren } from 'domhandler';
import type { InternalOptions } from './options';
export default function parse(content: string | Document | Node | Node[] | Buffer, options: InternalOptions, isDocument: boolean): Document;
import { AnyNode, Document, ParentNode } from 'domhandler';
import type { InternalOptions } from './options.js';
/**
* Get the parse function with options.
*
* @param parser - The parser function.
* @returns The parse function with options.
*/
export declare function getParse(parser: (content: string, options: InternalOptions, isDocument: boolean, context: ParentNode | null) => Document): (content: string | Document | AnyNode | AnyNode[] | Buffer, options: InternalOptions, isDocument: boolean, context: ParentNode | null) => Document;
/**
* Update the dom structure, for one changed layer.
*
@ -9,5 +15,5 @@ export default function parse(content: string | Document | Node | Node[] | Buffe
* @param parent - The new parent.
* @returns The parent node.
*/
export declare function update(newChilds: Node[] | Node, parent: NodeWithChildren | null): Node | null;
export declare function update(newChilds: AnyNode[] | AnyNode, parent: ParentNode | null): ParentNode | null;
//# sourceMappingURL=parse.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":";AAGA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAKjD,MAAM,CAAC,OAAO,UAAU,KAAK,CAC3B,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,EACnD,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,OAAO,GAClB,QAAQ,CAyBV;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,EACxB,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAC9B,IAAI,GAAG,IAAI,CA+Bb"}
{"version":3,"file":"parse.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["parse.ts"],"names":[],"mappings":";AACA,OAAO,EACL,OAAO,EACP,QAAQ,EACR,UAAU,EAEX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,CACN,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,UAAU,GAAG,IAAI,KACvB,QAAQ,aAYF,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,WAChD,eAAe,cACZ,OAAO,WACV,UAAU,GAAG,IAAI,KACzB,QAAQ,CAwBZ;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,EAC9B,MAAM,EAAE,UAAU,GAAG,IAAI,GACxB,UAAU,GAAG,IAAI,CA+BnB"}

37
node_modules/cheerio/lib/parse.js generated vendored
View file

@ -1,24 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.update = void 0;
var htmlparser2_1 = require("htmlparser2");
var htmlparser2_adapter_1 = require("./parsers/htmlparser2-adapter");
var parse5_adapter_1 = require("./parsers/parse5-adapter");
exports.update = exports.getParse = void 0;
var domutils_1 = require("domutils");
var domhandler_1 = require("domhandler");
/*
* Parser
/**
* Get the parse function with options.
*
* @param parser - The parser function.
* @returns The parse function with options.
*/
function parse(content, options, isDocument) {
function getParse(parser) {
/**
* Parse a HTML string or a node.
*
* @param content - The HTML string or node.
* @param options - The parser options.
* @param isDocument - If `content` is a document.
* @param context - The context node in the DOM tree.
* @returns The parsed document node.
*/
return function parse(content, options, isDocument, context) {
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(content)) {
content = content.toString();
}
if (typeof content === 'string') {
return options.xmlMode || options._useHtmlParser2
? htmlparser2_adapter_1.parse(content, options)
: parse5_adapter_1.parse(content, options, isDocument);
return parser(content, options, isDocument, context);
}
var doc = content;
if (!Array.isArray(doc) && domhandler_1.isDocument(doc)) {
if (!Array.isArray(doc) && (0, domhandler_1.isDocument)(doc)) {
// If `doc` is already a root, just return it
return doc;
}
@ -27,8 +36,9 @@ function parse(content, options, isDocument) {
// Update the DOM using the root
update(doc, root);
return root;
};
}
exports.default = parse;
exports.getParse = getParse;
/**
* Update the dom structure, for one changed layer.
*
@ -51,7 +61,7 @@ function update(newChilds, parent) {
var node = arr[i];
// Cleanly remove existing nodes from their previous structures.
if (node.parent && node.parent.children !== arr) {
htmlparser2_1.DomUtils.removeElement(node);
(0, domutils_1.removeElement)(node);
}
if (parent) {
node.prev = arr[i - 1] || null;
@ -65,3 +75,4 @@ function update(newChilds, parent) {
return parent;
}
exports.update = update;
//# sourceMappingURL=parse.js.map

View file

@ -1,3 +0,0 @@
export { parseDocument as parse } from 'htmlparser2';
export { default as render } from 'dom-serializer';
//# sourceMappingURL=htmlparser2-adapter.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"htmlparser2-adapter.d.ts","sourceRoot":"","sources":["../../src/parsers/htmlparser2-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAC"}

View file

@ -1,10 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.render = exports.parse = void 0;
var htmlparser2_1 = require("htmlparser2");
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return htmlparser2_1.parseDocument; } });
var dom_serializer_1 = require("dom-serializer");
Object.defineProperty(exports, "render", { enumerable: true, get: function () { return __importDefault(dom_serializer_1).default; } });

View file

@ -1,9 +1,20 @@
import { Node, Document } from 'domhandler';
import type { InternalOptions } from '../options';
interface Parse5Options extends InternalOptions {
context?: Node;
}
export declare function parse(content: string, options: Parse5Options, isDocument?: boolean): Document;
export declare function render(dom: Node | ArrayLike<Node>): string;
export {};
import { AnyNode, Document, ParentNode } from 'domhandler';
import type { InternalOptions } from '../options.js';
/**
* Parse the content with `parse5` in the context of the given `ParentNode`.
*
* @param content - The content to parse.
* @param options - A set of options to use to parse.
* @param isDocument - Whether to parse the content as a full HTML document.
* @param context - The context in which to parse the content.
* @returns The parsed content.
*/
export declare function parseWithParse5(content: string, options: InternalOptions, isDocument: boolean, context: ParentNode | null): Document;
/**
* Renders the given DOM tree with `parse5` and returns the result as a string.
*
* @param dom - The DOM tree to render.
* @returns The rendered document.
*/
export declare function renderWithParse5(dom: AnyNode | ArrayLike<AnyNode>): string;
//# sourceMappingURL=parse5-adapter.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"parse5-adapter.d.ts","sourceRoot":"","sources":["../../src/parsers/parse5-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAc,MAAM,YAAY,CAAC;AAGxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,UAAU,aAAc,SAAQ,eAAe;IAC7C,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAED,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,EACtB,UAAU,CAAC,EAAE,OAAO,GACnB,QAAQ,CAiBV;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAgB1D"}
{"version":3,"file":"parse5-adapter.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["parsers/parse5-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAc,UAAU,EAAE,MAAM,YAAY,CAAC;AAGvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,UAAU,GAAG,IAAI,GACzB,QAAQ,CAaV;AAID;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM,CAqB1E"}

View file

@ -1,27 +1,48 @@
"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.render = exports.parse = void 0;
var tslib_1 = require("tslib");
exports.renderWithParse5 = exports.parseWithParse5 = void 0;
var domhandler_1 = require("domhandler");
var parse5_1 = require("parse5");
var parse5_htmlparser2_tree_adapter_1 = tslib_1.__importDefault(require("parse5-htmlparser2-tree-adapter"));
function parse(content, options, isDocument) {
var parse5_htmlparser2_tree_adapter_1 = require("parse5-htmlparser2-tree-adapter");
/**
* Parse the content with `parse5` in the context of the given `ParentNode`.
*
* @param content - The content to parse.
* @param options - A set of options to use to parse.
* @param isDocument - Whether to parse the content as a full HTML document.
* @param context - The context in which to parse the content.
* @returns The parsed content.
*/
function parseWithParse5(content, options, isDocument, context) {
var opts = {
scriptingEnabled: typeof options.scriptingEnabled === 'boolean'
? options.scriptingEnabled
: true,
treeAdapter: parse5_htmlparser2_tree_adapter_1.default,
treeAdapter: parse5_htmlparser2_tree_adapter_1.adapter,
sourceCodeLocationInfo: options.sourceCodeLocationInfo,
};
var context = options.context;
// @ts-expect-error The tree adapter unfortunately doesn't return the exact types.
return isDocument
? parse5_1.parse(content, opts)
: // @ts-expect-error Same issue again.
parse5_1.parseFragment(context, content, opts);
? (0, parse5_1.parse)(content, opts)
: (0, parse5_1.parseFragment)(context, content, opts);
}
exports.parse = parse;
function render(dom) {
exports.parseWithParse5 = parseWithParse5;
var renderOpts = { treeAdapter: parse5_htmlparser2_tree_adapter_1.adapter };
/**
* Renders the given DOM tree with `parse5` and returns the result as a string.
*
* @param dom - The DOM tree to render.
* @returns The rendered document.
*/
function renderWithParse5(dom) {
var _a;
/*
* `dom-serializer` passes over the special "root" node and renders the
@ -31,11 +52,16 @@ function render(dom) {
var nodes = 'length' in dom ? dom : [dom];
for (var index = 0; index < nodes.length; index += 1) {
var node = nodes[index];
if (domhandler_1.isDocument(node)) {
(_a = Array.prototype.splice).call.apply(_a, tslib_1.__spreadArray([nodes, index, 1], node.children));
if ((0, domhandler_1.isDocument)(node)) {
(_a = Array.prototype.splice).call.apply(_a, __spreadArray([nodes, index, 1], node.children, false));
}
}
// @ts-expect-error Types don't align here either.
return parse5_1.serialize({ children: nodes }, { treeAdapter: parse5_htmlparser2_tree_adapter_1.default });
var result = '';
for (var index = 0; index < nodes.length; index += 1) {
var node = nodes[index];
result += (0, parse5_1.serializeOuter)(node, renderOpts);
}
exports.render = render;
return result;
}
exports.renderWithParse5 = renderWithParse5;
//# sourceMappingURL=parse5-adapter.js.map

21
node_modules/cheerio/lib/static.d.ts generated vendored
View file

@ -1,13 +1,14 @@
import type { BasicAcceptedElems } from './types.js';
import type { CheerioAPI, Cheerio } from '.';
import { Node, Document } from 'domhandler';
import { CheerioOptions } from './options';
import type { AnyNode, Document } from 'domhandler';
import { CheerioOptions } from './options.js';
/**
* Renders the document.
*
* @param options - Options for the renderer.
* @returns The rendered document.
*/
export declare function html(this: CheerioAPI | void, options?: CheerioOptions): string;
export declare function html(this: CheerioAPI, options?: CheerioOptions): string;
/**
* Renders the document.
*
@ -15,21 +16,25 @@ export declare function html(this: CheerioAPI | void, options?: CheerioOptions):
* @param options - Options for the renderer.
* @returns The rendered document.
*/
export declare function html(this: CheerioAPI | void, dom?: string | ArrayLike<Node> | Node, options?: CheerioOptions): string;
export declare function html(this: CheerioAPI, dom?: BasicAcceptedElems<AnyNode>, options?: CheerioOptions): string;
/**
* Render the document as XML.
*
* @param dom - Element to render.
* @returns THe rendered document.
*/
export declare function xml(this: CheerioAPI, dom?: string | ArrayLike<Node> | Node): string;
export declare function xml(this: CheerioAPI, dom?: BasicAcceptedElems<AnyNode>): string;
/**
* Render the document as text.
*
* This returns the `textContent` of the passed elements. The result will
* include the contents of `script` and `stype` elements. To avoid this, use
* `.prop('innerText')` instead.
*
* @param elements - Elements to render.
* @returns The rendered document.
*/
export declare function text(this: CheerioAPI | void, elements?: ArrayLike<Node>): string;
export declare function text(this: CheerioAPI | void, elements?: ArrayLike<AnyNode>): string;
/**
* Parses a string into an array of DOM nodes. The `context` argument has no
* meaning for Cheerio, but it is maintained for API compatibility with jQuery.
@ -42,7 +47,7 @@ export declare function text(this: CheerioAPI | void, elements?: ArrayLike<Node>
* @alias Cheerio.parseHTML
* @see {@link https://api.jquery.com/jQuery.parseHTML/}
*/
export declare function parseHTML(this: CheerioAPI, data: string, context?: unknown | boolean, keepScripts?: boolean): Node[];
export declare function parseHTML(this: CheerioAPI, data: string, context?: unknown | boolean, keepScripts?: boolean): AnyNode[];
export declare function parseHTML(this: CheerioAPI, data?: '' | null): null;
/**
* Sometimes you need to work with the top-level root element. To query it, you
@ -69,7 +74,7 @@ export declare function root(this: CheerioAPI): Cheerio<Document>;
* @alias Cheerio.contains
* @see {@link https://api.jquery.com/jQuery.contains/}
*/
export declare function contains(container: Node, contained: Node): boolean;
export declare function contains(container: AnyNode, contained: AnyNode): boolean;
interface WritableArrayLike<T> extends ArrayLike<T> {
length: number;
[n: number]: T;

View file

@ -1 +1 @@
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAEL,cAAc,EAGf,MAAM,WAAW,CAAC;AAiDnB;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;AAChF;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,UAAU,GAAG,IAAI,EACvB,GAAG,C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,SAAS,CAY1B"}
{"version":3,"file":"static.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["static.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAEL,cAAc,EAGf,MAAM,cAAc,CAAC;AAuCtB;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;AACzE;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,UAAU,EAChB,GAAG,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,EACjC,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAAC;AA2BV;;;;;GAKG;AACH,wBAAgB,GAAG,CACjB,IAAI,EAAE,UAAU,EAChB,GAAG,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAChC,MAAM,CAIR;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,UAAU,GAAG,IAAI,EACvB,QAAQ,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAC5B,MAAM,CAUR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,EAC3B,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,EAAE,CAAC;AACb,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AA8BpE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAExD;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAmBxE;AAED,UAAU,iBAAiB,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC1B,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GACjB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAY1B"}

89
node_modules/cheerio/lib/static.js generated vendored
View file

@ -1,12 +1,42 @@
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.merge = exports.contains = exports.root = exports.parseHTML = exports.text = exports.xml = exports.html = void 0;
var tslib_1 = require("tslib");
var options_1 = tslib_1.__importStar(require("./options"));
var cheerio_select_1 = require("cheerio-select");
var htmlparser2_1 = require("htmlparser2");
var parse5_adapter_1 = require("./parsers/parse5-adapter");
var htmlparser2_adapter_1 = require("./parsers/htmlparser2-adapter");
var domutils_1 = require("domutils");
var options_js_1 = __importStar(require("./options.js"));
/**
* Helper function to render a DOM.
*
@ -16,17 +46,9 @@ var htmlparser2_adapter_1 = require("./parsers/htmlparser2-adapter");
* @returns The rendered document.
*/
function render(that, dom, options) {
var _a;
var toRender = dom
? typeof dom === 'string'
? cheerio_select_1.select(dom, (_a = that === null || that === void 0 ? void 0 : that._root) !== null && _a !== void 0 ? _a : [], options)
: dom
: that === null || that === void 0 ? void 0 : that._root.children;
if (!toRender)
if (!that)
return '';
return options.xmlMode || options._useHtmlParser2
? htmlparser2_adapter_1.render(toRender, options)
: parse5_adapter_1.render(toRender);
return that(dom !== null && dom !== void 0 ? dom : that._root.children, null, undefined, options).toString();
}
/**
* Checks if a passed object is an options object.
@ -34,8 +56,9 @@ function render(that, dom, options) {
* @param dom - Object to check if it is an options object.
* @returns Whether the object is an options object.
*/
function isOptions(dom) {
return (typeof dom === 'object' &&
function isOptions(dom, options) {
return (!options &&
typeof dom === 'object' &&
dom != null &&
!('length' in dom) &&
!('type' in dom));
@ -47,16 +70,13 @@ function html(dom, options) {
* check dom argument for dom element specific properties
* assume there is no 'length' or 'type' properties in the options object
*/
if (!options && isOptions(dom)) {
options = dom;
dom = undefined;
}
var toRender = isOptions(dom) ? ((options = dom), undefined) : dom;
/*
* Sometimes `$.html()` is used without preloading html,
* so fallback non-existing options to the default ones.
*/
var opts = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, options_1.default), (this ? this._options : {})), options_1.flatten(options !== null && options !== void 0 ? options : {}));
return render(this || undefined, dom, opts);
var opts = __assign(__assign(__assign({}, options_js_1.default), this === null || this === void 0 ? void 0 : this._options), (0, options_js_1.flatten)(options !== null && options !== void 0 ? options : {}));
return render(this, toRender, opts);
}
exports.html = html;
/**
@ -66,13 +86,17 @@ exports.html = html;
* @returns THe rendered document.
*/
function xml(dom) {
var options = tslib_1.__assign(tslib_1.__assign({}, this._options), { xmlMode: true });
var options = __assign(__assign({}, this._options), { xmlMode: true });
return render(this, dom, options);
}
exports.xml = xml;
/**
* Render the document as text.
*
* This returns the `textContent` of the passed elements. The result will
* include the contents of `script` and `stype` elements. To avoid this, use
* `.prop('innerText')` instead.
*
* @param elements - Elements to render.
* @returns The rendered document.
*/
@ -80,15 +104,7 @@ function text(elements) {
var elems = elements ? elements : this ? this.root() : [];
var ret = '';
for (var i = 0; i < elems.length; i++) {
var elem = elems[i];
if (htmlparser2_1.DomUtils.isText(elem))
ret += elem.data;
else if (htmlparser2_1.DomUtils.hasChildren(elem) &&
elem.type !== htmlparser2_1.ElementType.Comment &&
elem.type !== htmlparser2_1.ElementType.Script &&
elem.type !== htmlparser2_1.ElementType.Style) {
ret += text(elem.children);
}
ret += (0, domutils_1.textContent)(elems[i]);
}
return ret;
}
@ -101,7 +117,7 @@ function parseHTML(data, context, keepScripts) {
if (typeof context === 'boolean') {
keepScripts = context;
}
var parsed = this.load(data, options_1.default, false);
var parsed = this.load(data, options_js_1.default, false);
if (!keepScripts) {
parsed('script').remove();
}
@ -185,6 +201,8 @@ function merge(arr1, arr2) {
}
exports.merge = merge;
/**
* Checks if an object is array-like.
*
* @param item - Item to check.
* @returns Indicates if the item is array-like.
*/
@ -205,3 +223,4 @@ function isArrayLike(item) {
}
return true;
}
//# sourceMappingURL=static.js.map

View file

@ -6,12 +6,12 @@ declare type SelectorSpecial = '.' | '#' | ':' | '|' | '>' | '+' | '~' | '[';
* selectors to return `Element`s.
*/
export declare type SelectorType = `${SelectorSpecial}${AlphaNumeric}${string}` | `${AlphaNumeric}${string}`;
import type { Cheerio } from './cheerio';
import type { Node } from 'domhandler';
import type { Cheerio } from './cheerio.js';
import type { AnyNode } from 'domhandler';
/** Elements that can be passed to manipulation methods. */
export declare type BasicAcceptedElems<T extends Node> = Cheerio<T> | T[] | T | string;
export declare type BasicAcceptedElems<T extends AnyNode> = Cheerio<T> | T[] | T | string;
/** Elements that can be passed to manipulation methods, including functions. */
export declare type AcceptedElems<T extends Node> = BasicAcceptedElems<T> | ((this: T, i: number, el: T) => BasicAcceptedElems<T>);
export declare type AcceptedElems<T extends AnyNode> = BasicAcceptedElems<T> | ((this: T, i: number, el: T) => BasicAcceptedElems<T>);
/** Function signature, for traversal methods. */
export declare type FilterFunction<T> = (this: T, i: number, el: T) => boolean;
/** Supported filter types, for traversal methods. */

View file

@ -1 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,aAAK,gBAAgB,GACjB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAER,aAAK,YAAY,GACb,gBAAgB,GAChB,SAAS,CAAC,gBAAgB,CAAC,GAC3B,GAAG,MAAM,EAAE,CAAC;AAEhB,aAAK,eAAe,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACrE;;;GAGG;AACH,oBAAY,YAAY,GACpB,GAAG,eAAe,GAAG,YAAY,GAAG,MAAM,EAAE,GAC5C,GAAG,YAAY,GAAG,MAAM,EAAE,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,2DAA2D;AAC3D,oBAAY,kBAAkB,CAAC,CAAC,SAAS,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAC/E,gFAAgF;AAChF,oBAAY,aAAa,CAAC,CAAC,SAAS,IAAI,IACpC,kBAAkB,CAAC,CAAC,CAAC,GACrB,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,iDAAiD;AACjD,oBAAY,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC;AACvE,qDAAqD;AACrD,oBAAY,eAAe,CAAC,CAAC,IAAI,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
{"version":3,"file":"types.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["types.ts"],"names":[],"mappings":"AAAA,aAAK,gBAAgB,GACjB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAER,aAAK,YAAY,GACb,gBAAgB,GAChB,SAAS,CAAC,gBAAgB,CAAC,GAC3B,GAAG,MAAM,EAAE,CAAC;AAEhB,aAAK,eAAe,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACrE;;;GAGG;AACH,oBAAY,YAAY,GACpB,GAAG,eAAe,GAAG,YAAY,GAAG,MAAM,EAAE,GAC5C,GAAG,YAAY,GAAG,MAAM,EAAE,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,2DAA2D;AAC3D,oBAAY,kBAAkB,CAAC,CAAC,SAAS,OAAO,IAC5C,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,EAAE,GACH,CAAC,GACD,MAAM,CAAC;AACX,gFAAgF;AAChF,oBAAY,aAAa,CAAC,CAAC,SAAS,OAAO,IACvC,kBAAkB,CAAC,CAAC,CAAC,GACrB,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,iDAAiD;AACjD,oBAAY,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC;AACvE,qDAAqD;AACrD,oBAAY,eAAe,CAAC,CAAC,IAAI,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}

1
node_modules/cheerio/lib/types.js generated vendored
View file

@ -1,2 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

26
node_modules/cheerio/lib/utils.d.ts generated vendored
View file

@ -1,6 +1,5 @@
import { DomUtils } from 'htmlparser2';
import { Node } from 'domhandler';
import type { Cheerio } from './cheerio';
import { type AnyNode } from 'domhandler';
import type { Cheerio } from './cheerio.js';
/**
* Check if the DOM element is a tag.
*
@ -8,10 +7,10 @@ import type { Cheerio } from './cheerio';
*
* @private
* @category Utils
* @param type - DOM node to check.
* @param type - The DOM node to check.
* @returns Whether the node is a tag.
*/
export declare const isTag: typeof DomUtils.isTag;
export { isTag } from 'domhandler';
/**
* Checks if an object is a Cheerio instance.
*
@ -25,7 +24,7 @@ export declare function isCheerio<T>(maybeCheerio: any): maybeCheerio is Cheerio
*
* @private
* @category Utils
* @param str - String to be converted.
* @param str - The string to be converted.
* @returns String in camel case notation.
*/
export declare function camelCase(str: string): string;
@ -35,7 +34,7 @@ export declare function camelCase(str: string): string;
*
* @private
* @category Utils
* @param str - String to be converted.
* @param str - The string to be converted.
* @returns String in "CSS case".
*/
export declare function cssCase(str: string): string;
@ -46,27 +45,30 @@ export declare function cssCase(str: string): string;
* pressure introduced by _make.
*
* @category Utils
* @param array - Array to iterate over.
* @param array - The array to iterate over.
* @param fn - Function to call.
* @returns The original instance.
*/
export declare function domEach<T extends Node, Arr extends ArrayLike<T> = Cheerio<T>>(array: Arr, fn: (elem: T, index: number) => void): Arr;
export declare function domEach<T extends AnyNode, Arr extends ArrayLike<T> = Cheerio<T>>(array: Arr, fn: (elem: T, index: number) => void): Arr;
/**
* Create a deep copy of the given DOM structure. Sets the parents of the copies
* of the passed nodes to `null`.
*
* @private
* @category Utils
* @param dom - The htmlparser2-compliant DOM structure.
* @param dom - The domhandler-compliant DOM structure.
* @returns - The cloned DOM.
*/
export declare function cloneDom<T extends Node>(dom: T | T[]): T[];
export declare function cloneDom<T extends AnyNode>(dom: T | T[]): T[];
/**
* Check if string is HTML.
*
* Tests for a `<` within a string, immediate followed by a letter and
* eventually followed by a `>`.
*
* @private
* @category Utils
* @param str - String to check.
* @param str - The string to check.
* @returns Indicates if `str` is HTML.
*/
export declare function isHtml(str: string): boolean;

View file

@ -1 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAuB,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;;;GASG;AACH,eAAO,MAAQ,KAAK,uBAAa,CAAC;AAElC;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,YAAY,EAAE,GAAG,GAAG,YAAY,IAAI,OAAO,CAAC,CAAC,CAAC,CAE1E;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC3E,KAAK,EAAE,GAAG,EACV,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACnC,GAAG,CAIL;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAa1D;AAUD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG3C"}
{"version":3,"file":"utils.d.ts","sourceRoot":"https://raw.githubusercontent.com/cheeriojs/cheerio/d1cbc66d53392ce8bf6cd0068f675836372d2bf3/src/","sources":["utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAuB,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,YAAY,EAAE,GAAG,GAAG,YAAY,IAAI,OAAO,CAAC,CAAC,CAAC,CAE1E;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,CAAC,SAAS,OAAO,EACjB,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACrC,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,GAAG,CAIvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAa7D;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAa3C"}

49
node_modules/cheerio/lib/utils.js generated vendored
View file

@ -1,7 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isHtml = exports.cloneDom = exports.domEach = exports.cssCase = exports.camelCase = exports.isCheerio = exports.isTag = void 0;
var htmlparser2_1 = require("htmlparser2");
var domhandler_1 = require("domhandler");
/**
* Check if the DOM element is a tag.
@ -10,10 +9,11 @@ var domhandler_1 = require("domhandler");
*
* @private
* @category Utils
* @param type - DOM node to check.
* @param type - The DOM node to check.
* @returns Whether the node is a tag.
*/
exports.isTag = htmlparser2_1.DomUtils.isTag;
var domhandler_2 = require("domhandler");
Object.defineProperty(exports, "isTag", { enumerable: true, get: function () { return domhandler_2.isTag; } });
/**
* Checks if an object is a Cheerio instance.
*
@ -30,7 +30,7 @@ exports.isCheerio = isCheerio;
*
* @private
* @category Utils
* @param str - String to be converted.
* @param str - The string to be converted.
* @returns String in camel case notation.
*/
function camelCase(str) {
@ -43,7 +43,7 @@ exports.camelCase = camelCase;
*
* @private
* @category Utils
* @param str - String to be converted.
* @param str - The string to be converted.
* @returns String in "CSS case".
*/
function cssCase(str) {
@ -57,7 +57,7 @@ exports.cssCase = cssCase;
* pressure introduced by _make.
*
* @category Utils
* @param array - Array to iterate over.
* @param array - The array to iterate over.
* @param fn - Function to call.
* @returns The original instance.
*/
@ -74,13 +74,13 @@ exports.domEach = domEach;
*
* @private
* @category Utils
* @param dom - The htmlparser2-compliant DOM structure.
* @param dom - The domhandler-compliant DOM structure.
* @returns - The cloned DOM.
*/
function cloneDom(dom) {
var clone = 'length' in dom
? Array.prototype.map.call(dom, function (el) { return domhandler_1.cloneNode(el, true); })
: [domhandler_1.cloneNode(dom, true)];
? Array.prototype.map.call(dom, function (el) { return (0, domhandler_1.cloneNode)(el, true); })
: [(0, domhandler_1.cloneNode)(dom, true)];
// Add a root node around the cloned nodes
var root = new domhandler_1.Document(clone);
clone.forEach(function (node) {
@ -89,23 +89,34 @@ function cloneDom(dom) {
return clone;
}
exports.cloneDom = cloneDom;
/**
* A simple way to check for HTML strings. Tests for a `<` within a string,
* immediate followed by a letter and eventually followed by a `>`.
*
* @private
*/
var quickExpr = /<[a-zA-Z][^]*>/;
var CharacterCodes;
(function (CharacterCodes) {
CharacterCodes[CharacterCodes["LowerA"] = 97] = "LowerA";
CharacterCodes[CharacterCodes["LowerZ"] = 122] = "LowerZ";
CharacterCodes[CharacterCodes["UpperA"] = 65] = "UpperA";
CharacterCodes[CharacterCodes["UpperZ"] = 90] = "UpperZ";
CharacterCodes[CharacterCodes["Exclamation"] = 33] = "Exclamation";
})(CharacterCodes || (CharacterCodes = {}));
/**
* Check if string is HTML.
*
* Tests for a `<` within a string, immediate followed by a letter and
* eventually followed by a `>`.
*
* @private
* @category Utils
* @param str - String to check.
* @param str - The string to check.
* @returns Indicates if `str` is HTML.
*/
function isHtml(str) {
// Run the regex
return quickExpr.test(str);
var tagStart = str.indexOf('<');
if (tagStart < 0 || tagStart > str.length - 3)
return false;
var tagChar = str.charCodeAt(tagStart + 1);
return (((tagChar >= CharacterCodes.LowerA && tagChar <= CharacterCodes.LowerZ) ||
(tagChar >= CharacterCodes.UpperA && tagChar <= CharacterCodes.UpperZ) ||
tagChar === CharacterCodes.Exclamation) &&
str.includes('>', tagStart + 2));
}
exports.isHtml = isHtml;
//# sourceMappingURL=utils.js.map

232
node_modules/cheerio/package.json generated vendored
View file

@ -1,92 +1,13 @@
{
"_from": "cheerio",
"_id": "cheerio@1.0.0-rc.10",
"_inBundle": false,
"_integrity": "sha512-g0J0q/O6mW8z5zxQ3A8E8J1hUgp4SMOvEoW/x84OwyHKe/Zccz83PVT4y5Crcr530FV6NgmKI1qvGTKVl9XXVw==",
"_location": "/cheerio",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "cheerio",
"name": "cheerio",
"escapedName": "cheerio",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.10.tgz",
"_shasum": "2ba3dcdfcc26e7956fc1f440e61d51c643379f3e",
"_spec": "cheerio",
"_where": "/home/runner/work/public_library_map/public_library_map",
"author": {
"name": "Matt Mueller",
"email": "mattmuelle@gmail.com"
},
"bugs": {
"url": "https://github.com/cheeriojs/cheerio/issues"
},
"bundleDependencies": false,
"dependencies": {
"cheerio-select": "^1.5.0",
"dom-serializer": "^1.3.2",
"domhandler": "^4.2.0",
"htmlparser2": "^6.1.0",
"parse5": "^6.0.1",
"parse5-htmlparser2-tree-adapter": "^6.0.1",
"tslib": "^2.2.0"
},
"deprecated": false,
"version": "1.0.0-rc.12",
"description": "Tiny, fast, and elegant implementation of core jQuery designed specifically for the server",
"devDependencies": {
"@octokit/graphql": "^4.6.2",
"@types/benchmark": "^2.1.0",
"@types/jest": "^26.0.23",
"@types/jsdom": "^16.2.10",
"@types/node": "^15.12.1",
"@types/node-fetch": "^2.5.10",
"@types/parse5": "^6.0.0",
"@types/parse5-htmlparser2-tree-adapter": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"benchmark": "^2.1.4",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-jsdoc": "^35.1.3",
"eslint-plugin-node": "^11.1.0",
"husky": "^4.3.8",
"jest": "^27.0.4",
"jquery": "^3.6.0",
"jsdom": "^16.6.0",
"lint-staged": "^11.0.0",
"node-fetch": "^2.6.1",
"prettier": "^2.3.1",
"prettier-plugin-jsdoc": "0.3.22",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",
"typedoc": "^0.20.36",
"typescript": "^4.2.4"
},
"engines": {
"node": ">= 6"
},
"files": [
"lib"
"author": "Matt Mueller <mattmuelle@gmail.com>",
"maintainers": [
"Felix Boehm <me@feedic.com>"
],
"funding": "https://github.com/cheeriojs/cheerio?sponsor=1",
"homepage": "https://cheerio.js.org/",
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testPathIgnorePatterns": [
"/__fixtures__/"
]
},
"license": "MIT",
"keywords": [
"htmlparser",
"jquery",
@ -95,7 +16,98 @@
"parser",
"html"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/cheeriojs/cheerio.git"
},
"bugs": {
"url": "https://github.com/cheeriojs/cheerio/issues"
},
"homepage": "https://cheerio.js.org/",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"module": "lib/esm/index.js",
"exports": {
".": {
"require": "./lib/index.js",
"import": "./lib/esm/index.js"
},
"./lib/slim": {
"require": "./lib/slim.js",
"import": "./lib/esm/slim.js"
},
"./lib/utils": {
"require": "./lib/utils.js",
"import": "./lib/esm/utils.js"
}
},
"files": [
"lib"
],
"engines": {
"node": ">= 6"
},
"dependencies": {
"cheerio-select": "^2.1.0",
"dom-serializer": "^2.0.0",
"domhandler": "^5.0.3",
"domutils": "^3.0.1",
"htmlparser2": "^8.0.1",
"parse5": "^7.0.0",
"parse5-htmlparser2-tree-adapter": "^7.0.0"
},
"devDependencies": {
"@octokit/graphql": "^4.8.0",
"@types/benchmark": "^2.1.1",
"@types/jest": "^28.1.3",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.29.0",
"@typescript-eslint/parser": "^5.29.0",
"benchmark": "^2.1.4",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.5.3",
"eslint-plugin-jsdoc": "^39.3.3",
"eslint-plugin-node": "^11.1.0",
"husky": "^8.0.1",
"jest": "^28.1.1",
"jquery": "^3.6.0",
"jsdom": "^20.0.0",
"lint-staged": "^13.0.2",
"prettier": "^2.7.1",
"prettier-plugin-jsdoc": "0.3.38",
"ts-jest": "^28.0.5",
"ts-node": "^10.8.1",
"typedoc": "^0.22.17",
"typescript": "^4.7.4",
"undici": "^5.5.1"
},
"scripts": {
"test": "npm run lint && npm run test:jest",
"test:jest": "jest",
"test:jest:cov": "npm run test:jest -- --coverage",
"lint": "npm run lint:es && npm run lint:prettier",
"lint:es": "eslint --ignore-path .gitignore .",
"lint:prettier": "npm run format:prettier:raw -- --check",
"format": "npm run format:es && npm run format:prettier",
"format:es": "npm run lint:es -- --fix",
"format:prettier": "npm run format:prettier:raw -- --write",
"format:prettier:raw": "prettier \"**/*.{{m,c,}js,ts,md,json,yml}\" --ignore-path .gitignore",
"build:docs": "typedoc --hideGenerator src/index.ts",
"benchmark": "npm run build:cjs && ts-node benchmark/benchmark.ts --regex \"^(?!.*highmem)\"",
"update-sponsors": "ts-node scripts/fetch-sponsors.ts",
"bench": "npm run benchmark",
"build": "npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --sourceRoot https://raw.githubusercontent.com/cheeriojs/cheerio/$(git rev-parse HEAD)/src/",
"build:esm": "npm run build:cjs -- --module esnext --target es2019 --outDir lib/esm && echo '{\"type\":\"module\"}' > lib/esm/package.json",
"prepublishOnly": "npm run build",
"prepare": "husky install"
},
"prettier": {
"singleQuote": true,
"tabWidth": 2,
"tsdoc": true
},
"lint-staged": {
"*.js": [
"prettier --write",
@ -105,42 +117,18 @@
"prettier --write"
]
},
"main": "lib/index.js",
"maintainers": [
{
"name": "Felix Boehm",
"email": "me@feedic.com"
}
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testPathIgnorePatterns": [
"/__fixtures__/"
],
"name": "cheerio",
"prettier": {
"singleQuote": true,
"tabWidth": 2,
"tsdoc": true
},
"repository": {
"type": "git",
"url": "git://github.com/cheeriojs/cheerio.git"
},
"scripts": {
"bench": "npm run benchmark",
"benchmark": "ts-node benchmark/benchmark.ts --regex \"^(?!.*highmem)\"",
"build": "tsc",
"build:docs": "typedoc --hideGenerator src/index.ts",
"format": "npm run format:es && npm run format:prettier",
"format:es": "npm run lint:es -- --fix",
"format:prettier": "npm run format:prettier:raw -- --write",
"format:prettier:raw": "prettier \"**/*.{js,ts,md,json,yml}\" --ignore-path .gitignore",
"lint": "npm run lint:es && npm run lint:prettier",
"lint:es": "eslint --ignore-path .gitignore .",
"lint:prettier": "npm run format:prettier:raw -- --check",
"pre-commit": "lint-staged",
"prepublishOnly": "npm run build",
"test": "npm run lint && npm run test:jest",
"test:jest": "jest",
"test:jest:cov": "npm run test:jest -- --coverage",
"update-sponsors": "ts-node scripts/fetch-sponsors.ts"
},
"types": "lib/index.d.ts",
"version": "1.0.0-rc.10"
"coverageProvider": "v8",
"moduleNameMapper": {
"^(.*)\\.js$": [
"$1.js",
"$1"
]
}
}
}

89
node_modules/css-select/README.md generated vendored
View file

@ -1,35 +1,42 @@
# css-select [![NPM version](http://img.shields.io/npm/v/css-select.svg)](https://npmjs.org/package/css-select) [![Build Status](https://travis-ci.com/fb55/css-select.svg?branch=master)](http://travis-ci.com/fb55/css-select) [![Downloads](https://img.shields.io/npm/dm/css-select.svg)](https://npmjs.org/package/css-select) [![Coverage](https://coveralls.io/repos/fb55/css-select/badge.svg?branch=master)](https://coveralls.io/r/fb55/css-select)
a CSS selector compiler/engine
A CSS selector compiler and engine
## What?
css-select turns CSS selectors into functions that tests if elements match them.
When searching for elements, testing is executed "from the top", similar to how
browsers execute CSS selectors.
As a **compiler**, css-select turns CSS selectors into functions that tests if
elements match them.
As an **engine**, css-select looks through a DOM tree, searching for elements.
Elements are tested "from the top", similar to how browsers execute CSS
selectors.
In its default configuration, css-select queries the DOM structure of the
[`domhandler`](https://github.com/fb55/domhandler) module (also known as
htmlparser2 DOM). It uses [`domutils`](https://github.com/fb55/domutils) as its
default adapter over the DOM structure. See Options below for details on
querying alternative DOM structures.
htmlparser2 DOM). To query alternative DOM structures, see [`Options`](#options)
below.
**Features:**
- Full implementation of CSS3 selectors
- Partial implementation of jQuery/Sizzle extensions
- Very high test coverage
- Pretty good performance
- 🔬 Full implementation of CSS3 selectors, as well as most CSS4 selectors
- 🧪 Partial implementation of jQuery/Sizzle extensions (see
[cheerio-select](https://github.com/cheeriojs/cheerio-select) for the
remaining selectors)
- 🧑‍🔬 High test coverage, including the full test suites from
[`Sizzle`](https://github.com/jquery/sizzle),
[`Qwery`](https://github.com/ded/qwery) and
[`NWMatcher`](https://github.com/dperini/nwmatcher/) and .
- 🥼 Reliably great performance
## Why?
The traditional approach of executing CSS selectors, named left-to-right
execution, is to execute every component of the selector in order, from left to
right _(duh)_. The execution of the selector `a b` for example will first query
for `a` elements, then search these for `b` elements. (That's the approach of
eg. [`Sizzle`](https://github.com/jquery/sizzle),
[`nwmatcher`](https://github.com/dperini/nwmatcher/) and
[`qwery`](https://github.com/ded/qwery).)
Most CSS engines written in JavaScript execute selectors left-to-right. That
means thet execute every component of the selector in order, from left to right.
As an example: For the selector `a b`, these engines will first query for `a`
elements, then search these for `b` elements. (That's the approach of eg.
[`Sizzle`](https://github.com/jquery/sizzle),
[`Qwery`](https://github.com/ded/qwery) and
[`NWMatcher`](https://github.com/dperini/nwmatcher/).)
While this works, it has some downsides: Children of `a`s will be checked
multiple times; first, to check if they are also `a`s, then, for every superior
@ -50,10 +57,9 @@ By building a stack of functions.
_Wait, what?_
Okay, so let's suppose we want to compile the selector `a b` again, for
right-to-left execution. We start by _parsing_ the selector, which means we turn
the selector into an array of the building-blocks of the selector, so we can
distinguish them easily. That's what the
Okay, so let's suppose we want to compile the selector `a b`, for right-to-left
execution. We start by _parsing_ the selector. This turns the selector into an
array of the building blocks. That's what the
[`css-what`](https://github.com/fb55/css-what) module is for, if you want to
have a look.
@ -67,24 +73,27 @@ Anyway, after parsing, we end up with an array like this one:
];
```
Actually, this array is wrapped in another array, but that's another story
(involving commas in selectors).
(Actually, this array is wrapped in another array, but that's another story,
involving commas in selectors.)
Now that we know the meaning of every part of the selector, we can compile it.
That's where it becomes interesting.
That is where things become interesting.
The basic idea is to turn every part of the selector into a function, which
takes an element as its only argument. The function checks whether a passed
element matches its part of the selector: If it does, the element is passed to
the next turned-into-a-function part of the selector, which does the same. If an
element is accepted by all parts of the selector, it _matches_ the selector and
double rainbow ALL THE WAY.
the next function representing the next part of the selector. That function does
the same. If an element is accepted by all parts of the selector, it _matches_
the selector and double rainbow ALL THE WAY.
As said before, we want to do right-to-left execution with all the big O
improvements nonsense, so elements are passed from the rightmost part of the
improvements. That means elements are passed from the rightmost part of the
selector (`b` in our example) to the leftmost (~~which would be `c`~~ of course
`a`).
For traversals, such as the _descendant_ operating the space between `a` and
`b`, we walk up the DOM tree, starting from the element passed as argument.
_//TODO: More in-depth description. Implementation details. Build a spaceship._
## API
@ -93,10 +102,9 @@ _//TODO: More in-depth description. Implementation details. Build a spaceship._
const CSSselect = require("css-select");
```
**Note:** css-select throws errors when invalid selectors are passed to it,
contrary to the behavior in browsers, which swallow them. This is done to aid
with writing css selectors, but can be unexpected when processing arbitrary
strings.
**Note:** css-select throws errors when invalid selectors are passed to it. This
is done to aid with writing css selectors, but can be unexpected when processing
arbitrary strings.
#### `CSSselect.selectAll(query, elems, options)`
@ -133,11 +141,18 @@ All options are optional.
- `adapter`: The adapter to use when interacting with the backing DOM
structure. By default it uses the `domutils` module.
- `context`: The context of the current query. Used to limit the scope of
searches. Can be matched directly using the `:scope` pseudo-selector.
searches. Can be matched directly using the `:scope` pseudo-class.
- `relativeSelector`: By default, selectors are relative to the `context`,
which means that no parent elements of the context will be matched. (Eg.
`a b c` with context `b` will never give any results.) If `relativeSelector`
is set to `false`, selectors won't be
[absolutized](http://www.w3.org/TR/selectors4/#absolutizing) and selectors
can test for parent elements outside of the `context`.
- `cacheResults`: Allow css-select to cache results for some selectors,
sometimes greatly improving querying performance. Disable this if your
document can change in between queries with the same compiled selector.
Default: `true`.
- `pseudos`: A map of pseudo-class names to functions or strings.
#### Custom Adapters
@ -178,8 +193,10 @@ _As defined by CSS 4 and / or jQuery._
- `^=`
- `$=`
- `!=`
- Also, `i` can be added after the comparison to make the comparison
case-insensitive (eg. `[attr=foo i]`)
- `i` and `s` can be added after the comparison to make the comparison
case-insensitive or case-sensitive (eg. `[attr=foo i]`). If neither is
supplied, css-select will follow the HTML spec's
[case-sensitivity rules](https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors).
- Pseudos:
- [`:not`](https://developer.mozilla.org/en-US/docs/Web/CSS/:not)
- [`:contains`](https://api.jquery.com/contains-selector)

View file

@ -1,4 +1,4 @@
import { CompiledQuery, InternalOptions } from "./types";
import type { CompiledQuery, InternalOptions } from "./types.js";
import type { AttributeSelector, AttributeAction } from "css-what";
/**
* Attribute selectors

View file

@ -1 +1 @@
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAanE;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAC/B,eAAe,EACf,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC3B,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,KAC1C,aAAa,CAAC,WAAW,CAAC,CA8KlC,CAAC"}
{"version":3,"file":"attributes.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["attributes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA+EnE;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAC/B,eAAe,EACf,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC3B,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,KAC1C,aAAa,CAAC,WAAW,CAAC,CAsLlC,CAAC"}

View file

@ -1,7 +1,10 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.attributeRules = void 0;
var boolbase_1 = require("boolbase");
var boolbase_1 = __importDefault(require("boolbase"));
/**
* All reserved characters in a regex, used for escaping.
*
@ -12,15 +15,76 @@ var reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
function escapeRegex(value) {
return value.replace(reChars, "\\$&");
}
/**
* Attributes that are case-insensitive in HTML.
*
* @private
* @see https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors
*/
var caseInsensitiveAttributes = new Set([
"accept",
"accept-charset",
"align",
"alink",
"axis",
"bgcolor",
"charset",
"checked",
"clear",
"codetype",
"color",
"compact",
"declare",
"defer",
"dir",
"direction",
"disabled",
"enctype",
"face",
"frame",
"hreflang",
"http-equiv",
"lang",
"language",
"link",
"media",
"method",
"multiple",
"nohref",
"noresize",
"noshade",
"nowrap",
"readonly",
"rel",
"rev",
"rules",
"scope",
"scrolling",
"selected",
"shape",
"target",
"text",
"type",
"valign",
"valuetype",
"vlink",
]);
function shouldIgnoreCase(selector, options) {
return typeof selector.ignoreCase === "boolean"
? selector.ignoreCase
: selector.ignoreCase === "quirks"
? !!options.quirksMode
: !options.xmlMode && caseInsensitiveAttributes.has(selector.name);
}
/**
* Attribute selectors
*/
exports.attributeRules = {
equals: function (next, data, _a) {
var adapter = _a.adapter;
equals: function (next, data, options) {
var adapter = options.adapter;
var name = data.name;
var value = data.value;
if (data.ignoreCase) {
if (shouldIgnoreCase(data, options)) {
value = value.toLowerCase();
return function (elem) {
var attr = adapter.getAttributeValue(elem, name);
@ -34,12 +98,12 @@ exports.attributeRules = {
return adapter.getAttributeValue(elem, name) === value && next(elem);
};
},
hyphen: function (next, data, _a) {
var adapter = _a.adapter;
hyphen: function (next, data, options) {
var adapter = options.adapter;
var name = data.name;
var value = data.value;
var len = value.length;
if (data.ignoreCase) {
if (shouldIgnoreCase(data, options)) {
value = value.toLowerCase();
return function hyphenIC(elem) {
var attr = adapter.getAttributeValue(elem, name);
@ -57,13 +121,13 @@ exports.attributeRules = {
next(elem));
};
},
element: function (next, _a, _b) {
var name = _a.name, value = _a.value, ignoreCase = _a.ignoreCase;
var adapter = _b.adapter;
element: function (next, data, options) {
var adapter = options.adapter;
var name = data.name, value = data.value;
if (/\s/.test(value)) {
return boolbase_1.falseFunc;
return boolbase_1.default.falseFunc;
}
var regex = new RegExp("(?:^|\\s)" + escapeRegex(value) + "(?:$|\\s)", ignoreCase ? "i" : "");
var regex = new RegExp("(?:^|\\s)".concat(escapeRegex(value), "(?:$|\\s)"), shouldIgnoreCase(data, options) ? "i" : "");
return function element(elem) {
var attr = adapter.getAttributeValue(elem, name);
return (attr != null &&
@ -77,15 +141,15 @@ exports.attributeRules = {
var adapter = _b.adapter;
return function (elem) { return adapter.hasAttrib(elem, name) && next(elem); };
},
start: function (next, data, _a) {
var adapter = _a.adapter;
start: function (next, data, options) {
var adapter = options.adapter;
var name = data.name;
var value = data.value;
var len = value.length;
if (len === 0) {
return boolbase_1.falseFunc;
return boolbase_1.default.falseFunc;
}
if (data.ignoreCase) {
if (shouldIgnoreCase(data, options)) {
value = value.toLowerCase();
return function (elem) {
var attr = adapter.getAttributeValue(elem, name);
@ -101,15 +165,15 @@ exports.attributeRules = {
next(elem);
};
},
end: function (next, data, _a) {
var adapter = _a.adapter;
end: function (next, data, options) {
var adapter = options.adapter;
var name = data.name;
var value = data.value;
var len = -value.length;
if (len === 0) {
return boolbase_1.falseFunc;
return boolbase_1.default.falseFunc;
}
if (data.ignoreCase) {
if (shouldIgnoreCase(data, options)) {
value = value.toLowerCase();
return function (elem) {
var _a;
@ -123,13 +187,13 @@ exports.attributeRules = {
next(elem);
};
},
any: function (next, data, _a) {
var adapter = _a.adapter;
any: function (next, data, options) {
var adapter = options.adapter;
var name = data.name, value = data.value;
if (value === "") {
return boolbase_1.falseFunc;
return boolbase_1.default.falseFunc;
}
if (data.ignoreCase) {
if (shouldIgnoreCase(data, options)) {
var regex_1 = new RegExp(escapeRegex(value), "i");
return function anyIC(elem) {
var attr = adapter.getAttributeValue(elem, name);
@ -145,8 +209,8 @@ exports.attributeRules = {
next(elem);
};
},
not: function (next, data, _a) {
var adapter = _a.adapter;
not: function (next, data, options) {
var adapter = options.adapter;
var name = data.name;
var value = data.value;
if (value === "") {
@ -154,7 +218,7 @@ exports.attributeRules = {
return !!adapter.getAttributeValue(elem, name) && next(elem);
};
}
else if (data.ignoreCase) {
else if (shouldIgnoreCase(data, options)) {
value = value.toLowerCase();
return function (elem) {
var attr = adapter.getAttributeValue(elem, name);
@ -169,3 +233,4 @@ exports.attributeRules = {
};
},
};
//# sourceMappingURL=attributes.js.map

View file

@ -1,6 +1,5 @@
import { InternalSelector } from "./types";
import { Selector } from "css-what";
import type { CompiledQuery, InternalOptions } from "./types";
import type { CompiledQuery, InternalOptions, InternalSelector } from "./types.js";
/**
* Compiles a selector to an executable function.
*

View file

@ -1 +1 @@
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAS,QAAQ,EAAE,MAAM,UAAU,CAAC;AAS3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAClD,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAC/B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,IAAI,CAAC,CAGrB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACxD,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAC/B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CAI5B;AA6CD,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACvD,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAC3B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CA2C5B"}
{"version":3,"file":"compile.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAgB,MAAM,UAAU,CAAC;AAQzD,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,gBAAgB,EACnB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAClD,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAC/B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,IAAI,CAAC,CAGrB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACxD,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAC/B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CAG5B;AAqDD,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACvD,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAC3B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CAsD5B"}

View file

@ -1,15 +1,37 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.compileToken = exports.compileUnsafe = exports.compile = void 0;
var css_what_1 = require("css-what");
var boolbase_1 = require("boolbase");
var sort_1 = __importDefault(require("./sort"));
var procedure_1 = require("./procedure");
var general_1 = require("./general");
var subselects_1 = require("./pseudo-selectors/subselects");
var boolbase_1 = __importDefault(require("boolbase"));
var sort_js_1 = __importStar(require("./sort.js"));
var general_js_1 = require("./general.js");
var subselects_js_1 = require("./pseudo-selectors/subselects.js");
/**
* Compiles a selector to an executable function.
*
@ -19,27 +41,31 @@ var subselects_1 = require("./pseudo-selectors/subselects");
*/
function compile(selector, options, context) {
var next = compileUnsafe(selector, options, context);
return subselects_1.ensureIsTag(next, options.adapter);
return (0, subselects_js_1.ensureIsTag)(next, options.adapter);
}
exports.compile = compile;
function compileUnsafe(selector, options, context) {
var token = typeof selector === "string" ? css_what_1.parse(selector, options) : selector;
var token = typeof selector === "string" ? (0, css_what_1.parse)(selector) : selector;
return compileToken(token, options, context);
}
exports.compileUnsafe = compileUnsafe;
function includesScopePseudo(t) {
return (t.type === "pseudo" &&
return (t.type === css_what_1.SelectorType.Pseudo &&
(t.name === "scope" ||
(Array.isArray(t.data) &&
t.data.some(function (data) { return data.some(includesScopePseudo); }))));
}
var DESCENDANT_TOKEN = { type: "descendant" };
var DESCENDANT_TOKEN = { type: css_what_1.SelectorType.Descendant };
var FLEXIBLE_DESCENDANT_TOKEN = {
type: "_flexibleDescendant",
};
var SCOPE_TOKEN = { type: "pseudo", name: "scope", data: null };
var SCOPE_TOKEN = {
type: css_what_1.SelectorType.Pseudo,
name: "scope",
data: null,
};
/*
* CSS 4 Spec (Draft): 3.3.1. Absolutizing a Scope-relative Selector
* CSS 4 Spec (Draft): 3.4.1. Absolutizing a Relative Selector
* http://www.w3.org/TR/selectors4/#absolutizing
*/
function absolutize(token, _a, context) {
@ -47,11 +73,13 @@ function absolutize(token, _a, context) {
// TODO Use better check if the context is a document
var hasContext = !!(context === null || context === void 0 ? void 0 : context.every(function (e) {
var parent = adapter.isTag(e) && adapter.getParent(e);
return e === subselects_1.PLACEHOLDER_ELEMENT || (parent && adapter.isTag(parent));
return e === subselects_js_1.PLACEHOLDER_ELEMENT || (parent && adapter.isTag(parent));
}));
for (var _i = 0, token_1 = token; _i < token_1.length; _i++) {
var t = token_1[_i];
if (t.length > 0 && procedure_1.isTraversal(t[0]) && t[0].type !== "descendant") {
if (t.length > 0 &&
(0, sort_js_1.isTraversal)(t[0]) &&
t[0].type !== css_what_1.SelectorType.Descendant) {
// Don't continue in else branch
}
else if (hasContext && !t.some(includesScopePseudo)) {
@ -65,31 +93,38 @@ function absolutize(token, _a, context) {
}
function compileToken(token, options, context) {
var _a;
token = token.filter(function (t) { return t.length > 0; });
token.forEach(sort_1.default);
token.forEach(sort_js_1.default);
context = (_a = options.context) !== null && _a !== void 0 ? _a : context;
var isArrayContext = Array.isArray(context);
var finalContext = context && (Array.isArray(context) ? context : [context]);
// Check if the selector is relative
if (options.relativeSelector !== false) {
absolutize(token, options, finalContext);
}
else if (token.some(function (t) { return t.length > 0 && (0, sort_js_1.isTraversal)(t[0]); })) {
throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");
}
var shouldTestNextSiblings = false;
var query = token
.map(function (rules) {
if (rules.length >= 2) {
var first = rules[0], second = rules[1];
if (first.type !== "pseudo" || first.name !== "scope") {
if (first.type !== css_what_1.SelectorType.Pseudo ||
first.name !== "scope") {
// Ignore
}
else if (isArrayContext && second.type === "descendant") {
else if (isArrayContext &&
second.type === css_what_1.SelectorType.Descendant) {
rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
}
else if (second.type === "adjacent" ||
second.type === "sibling") {
else if (second.type === css_what_1.SelectorType.Adjacent ||
second.type === css_what_1.SelectorType.Sibling) {
shouldTestNextSiblings = true;
}
}
return compileRules(rules, options, finalContext);
})
.reduce(reduceRules, boolbase_1.falseFunc);
.reduce(reduceRules, boolbase_1.default.falseFunc);
query.shouldTestNextSiblings = shouldTestNextSiblings;
return query;
}
@ -97,19 +132,20 @@ exports.compileToken = compileToken;
function compileRules(rules, options, context) {
var _a;
return rules.reduce(function (previous, rule) {
return previous === boolbase_1.falseFunc
? boolbase_1.falseFunc
: general_1.compileGeneralSelector(previous, rule, options, context, compileToken);
}, (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase_1.trueFunc);
return previous === boolbase_1.default.falseFunc
? boolbase_1.default.falseFunc
: (0, general_js_1.compileGeneralSelector)(previous, rule, options, context, compileToken);
}, (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase_1.default.trueFunc);
}
function reduceRules(a, b) {
if (b === boolbase_1.falseFunc || a === boolbase_1.trueFunc) {
if (b === boolbase_1.default.falseFunc || a === boolbase_1.default.trueFunc) {
return a;
}
if (a === boolbase_1.falseFunc || b === boolbase_1.trueFunc) {
if (a === boolbase_1.default.falseFunc || b === boolbase_1.default.trueFunc) {
return b;
}
return function combine(elem) {
return a(elem) || b(elem);
};
}
//# sourceMappingURL=compile.js.map

View file

@ -1,3 +1,3 @@
import type { CompiledQuery, InternalOptions, InternalSelector, CompileToken } from "./types";
import type { CompiledQuery, InternalOptions, InternalSelector, CompileToken } from "./types.js";
export declare function compileGeneralSelector<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, selector: InternalSelector, options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>): CompiledQuery<ElementNode>;
//# sourceMappingURL=general.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../src/general.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,YAAY,EACf,MAAM,SAAS,CAAC;AAMjB,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACjE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9C,aAAa,CAAC,WAAW,CAAC,CAwH5B"}
{"version":3,"file":"general.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["general.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAER,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,YAAY,EACf,MAAM,YAAY,CAAC;AAkBpB,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACjE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9C,aAAa,CAAC,WAAW,CAAC,CAiK5B"}

View file

@ -1,33 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compileGeneralSelector = void 0;
var attributes_1 = require("./attributes");
var pseudo_selectors_1 = require("./pseudo-selectors");
var attributes_js_1 = require("./attributes.js");
var index_js_1 = require("./pseudo-selectors/index.js");
var css_what_1 = require("css-what");
function getElementParent(node, adapter) {
var parent = adapter.getParent(node);
if (parent && adapter.isTag(parent)) {
return parent;
}
return null;
}
/*
* All available rules
*/
function compileGeneralSelector(next, selector, options, context, compileToken) {
var adapter = options.adapter, equals = options.equals;
switch (selector.type) {
case "pseudo-element":
case css_what_1.SelectorType.PseudoElement: {
throw new Error("Pseudo-elements are not supported by css-select");
case "attribute":
return attributes_1.attributeRules[selector.action](next, selector, options);
case "pseudo":
return pseudo_selectors_1.compilePseudoSelector(next, selector, options, context, compileToken);
}
case css_what_1.SelectorType.ColumnCombinator: {
throw new Error("Column combinators are not yet supported by css-select");
}
case css_what_1.SelectorType.Attribute: {
if (selector.namespace != null) {
throw new Error("Namespaced attributes are not yet supported by css-select");
}
if (!options.xmlMode || options.lowerCaseAttributeNames) {
selector.name = selector.name.toLowerCase();
}
return attributes_js_1.attributeRules[selector.action](next, selector, options);
}
case css_what_1.SelectorType.Pseudo: {
return (0, index_js_1.compilePseudoSelector)(next, selector, options, context, compileToken);
}
// Tags
case "tag":
case css_what_1.SelectorType.Tag: {
if (selector.namespace != null) {
throw new Error("Namespaced tag names are not yet supported by css-select");
}
var name_1 = selector.name;
if (!options.xmlMode || options.lowerCaseTags) {
name_1 = name_1.toLowerCase();
}
return function tag(elem) {
return adapter.getName(elem) === selector.name && next(elem);
return adapter.getName(elem) === name_1 && next(elem);
};
}
// Traversal
case "descendant":
case css_what_1.SelectorType.Descendant: {
if (options.cacheResults === false ||
typeof WeakSet === "undefined") {
return function descendant(elem) {
var current = elem;
while ((current = adapter.getParent(current))) {
if (adapter.isTag(current) && next(current)) {
while ((current = getElementParent(current, adapter))) {
if (next(current)) {
return true;
}
}
@ -35,11 +63,10 @@ function compileGeneralSelector(next, selector, options, context, compileToken)
};
}
// @ts-expect-error `ElementNode` is not extending object
// eslint-disable-next-line no-case-declarations
var isFalseCache_1 = new WeakSet();
return function cachedDescendant(elem) {
var current = elem;
while ((current = adapter.getParent(current))) {
while ((current = getElementParent(current, adapter))) {
if (!isFalseCache_1.has(current)) {
if (adapter.isTag(current) && next(current)) {
return true;
@ -49,28 +76,32 @@ function compileGeneralSelector(next, selector, options, context, compileToken)
}
return false;
};
case "_flexibleDescendant":
}
case "_flexibleDescendant": {
// Include element itself, only used while querying an array
return function flexibleDescendant(elem) {
var current = elem;
do {
if (adapter.isTag(current) && next(current))
if (next(current))
return true;
} while ((current = adapter.getParent(current)));
} while ((current = getElementParent(current, adapter)));
return false;
};
case "parent":
}
case css_what_1.SelectorType.Parent: {
return function parent(elem) {
return adapter
.getChildren(elem)
.some(function (elem) { return adapter.isTag(elem) && next(elem); });
};
case "child":
}
case css_what_1.SelectorType.Child: {
return function child(elem) {
var parent = adapter.getParent(elem);
return parent != null && adapter.isTag(parent) && next(parent);
};
case "sibling":
}
case css_what_1.SelectorType.Sibling: {
return function sibling(elem) {
var siblings = adapter.getSiblings(elem);
for (var i = 0; i < siblings.length; i++) {
@ -83,7 +114,14 @@ function compileGeneralSelector(next, selector, options, context, compileToken)
}
return false;
};
case "adjacent":
}
case css_what_1.SelectorType.Adjacent: {
if (adapter.prevElementSibling) {
return function adjacent(elem) {
var previous = adapter.prevElementSibling(elem);
return previous != null && next(previous);
};
}
return function adjacent(elem) {
var siblings = adapter.getSiblings(elem);
var lastElement;
@ -97,8 +135,14 @@ function compileGeneralSelector(next, selector, options, context, compileToken)
}
return !!lastElement && next(lastElement);
};
case "universal":
}
case css_what_1.SelectorType.Universal: {
if (selector.namespace != null && selector.namespace !== "*") {
throw new Error("Namespaced universal selectors are not yet supported by css-select");
}
return next;
}
}
}
exports.compileGeneralSelector = compileGeneralSelector;
//# sourceMappingURL=general.js.map

View file

@ -1,11 +1,11 @@
import type { CompiledQuery, Options, Query, Adapter } from "./types";
import type { CompiledQuery, Options, Query, Adapter } from "./types.js";
export type { Options };
/**
* Compiles the query, returns a function.
*/
export declare const compile: <Node_1, ElementNode extends Node_1>(selector: string | import("css-what").Selector[][], options?: Options<Node_1, ElementNode> | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery<Node_1>;
export declare const _compileUnsafe: <Node_1, ElementNode extends Node_1>(selector: string | import("css-what").Selector[][], options?: Options<Node_1, ElementNode> | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery<ElementNode>;
export declare const _compileToken: <Node_1, ElementNode extends Node_1>(selector: import("./types").InternalSelector[][], options?: Options<Node_1, ElementNode> | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery<ElementNode>;
export declare const compile: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<Node>;
export declare const _compileUnsafe: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
export declare const _compileToken: <Node, ElementNode extends Node>(selector: import("./types.js").InternalSelector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
export declare function prepareContext<Node, ElementNode extends Node>(elems: Node | Node[], adapter: Adapter<Node, ElementNode>, shouldTestNextSiblings?: boolean): Node[];
/**
* @template Node The generic Node type for the DOM adapter being used.
@ -17,7 +17,7 @@ export declare function prepareContext<Node, ElementNode extends Node>(elems: No
* @returns All matching elements.
*
*/
export declare const selectAll: <Node_1, ElementNode extends Node_1>(query: Query<ElementNode>, elements: Node_1 | Node_1[], options?: Options<Node_1, ElementNode> | undefined) => ElementNode[];
export declare const selectAll: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode[];
/**
* @template Node The generic Node type for the DOM adapter being used.
* @template ElementNode The Node type for elements for the DOM adapter being used.
@ -27,7 +27,7 @@ export declare const selectAll: <Node_1, ElementNode extends Node_1>(query: Quer
* @see compile for supported selector queries.
* @returns the first match, or null if there was no match.
*/
export declare const selectOne: <Node_1, ElementNode extends Node_1>(query: Query<ElementNode>, elements: Node_1 | Node_1[], options?: Options<Node_1, ElementNode> | undefined) => ElementNode | null;
export declare const selectOne: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode | null;
/**
* Tests whether or not an element is matched by query.
*
@ -45,5 +45,6 @@ export declare function is<Node, ElementNode extends Node>(elem: ElementNode, qu
* @see [compile] for supported selector queries.
*/
export default selectAll;
export { filters, pseudos, aliases } from "./pseudo-selectors";
/** @deprecated Use the `pseudos` option instead. */
export { filters, pseudos, aliases } from "./pseudo-selectors/index.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACR,aAAa,EACb,OAAO,EAEP,KAAK,EACL,OAAO,EAEV,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,OAAO,EAAE,CAAC;AA0CxB;;GAEG;AACH,eAAO,MAAM,OAAO,gNAA0B,CAAC;AAC/C,eAAO,MAAM,cAAc,qNAA6B,CAAC;AACzD,eAAO,MAAM,aAAa,mNAA4B,CAAC;AA6BvD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACzD,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,EACnC,sBAAsB,UAAQ,GAC/B,IAAI,EAAE,CAYR;AAgBD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,mKASrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,wKASrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC7C,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,EACzB,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACrC,OAAO,CAKT;AAED;;;GAGG;AACH,eAAe,SAAS,CAAC;AAGzB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACR,aAAa,EACb,OAAO,EAEP,KAAK,EACL,OAAO,EAEV,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,OAAO,EAAE,CAAC;AA0CxB;;GAEG;AACH,eAAO,MAAM,OAAO,oMAA0B,CAAC;AAC/C,eAAO,MAAM,cAAc,2MAA6B,CAAC;AACzD,eAAO,MAAM,aAAa,4MAA4B,CAAC;AA6BvD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACzD,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,EACnC,sBAAsB,UAAQ,GAC/B,IAAI,EAAE,CAYR;AAiBD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,yJASrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,8JASrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC7C,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,EACzB,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACrC,OAAO,CAKT;AAED;;;GAGG;AACH,eAAe,SAAS,CAAC;AAGzB,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC"}

44
node_modules/css-select/lib/index.js generated vendored
View file

@ -1,7 +1,11 @@
"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]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
@ -18,12 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.aliases = exports.pseudos = exports.filters = exports.is = exports.selectOne = exports.selectAll = exports.prepareContext = exports._compileToken = exports._compileUnsafe = exports.compile = void 0;
var DomUtils = __importStar(require("domutils"));
var boolbase_1 = require("boolbase");
var compile_1 = require("./compile");
var subselects_1 = require("./pseudo-selectors/subselects");
var boolbase_1 = __importDefault(require("boolbase"));
var compile_js_1 = require("./compile.js");
var subselects_js_1 = require("./pseudo-selectors/subselects.js");
var defaultEquals = function (a, b) { return a === b; };
var defaultOptions = {
adapter: DomUtils,
@ -51,14 +58,14 @@ function wrapCompile(func) {
/**
* Compiles the query, returns a function.
*/
exports.compile = wrapCompile(compile_1.compile);
exports._compileUnsafe = wrapCompile(compile_1.compileUnsafe);
exports._compileToken = wrapCompile(compile_1.compileToken);
exports.compile = wrapCompile(compile_js_1.compile);
exports._compileUnsafe = wrapCompile(compile_js_1.compileUnsafe);
exports._compileToken = wrapCompile(compile_js_1.compileToken);
function getSelectorFunc(searchFunc) {
return function select(query, elements, options) {
var opts = convertOptionFormats(options);
if (typeof query !== "function") {
query = compile_1.compileUnsafe(query, opts, elements);
query = (0, compile_js_1.compileUnsafe)(query, opts, elements);
}
var filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings);
return searchFunc(query, filteredElements, opts);
@ -81,8 +88,9 @@ exports.prepareContext = prepareContext;
function appendNextSiblings(elem, adapter) {
// Order matters because jQuery seems to check the children before the siblings
var elems = Array.isArray(elem) ? elem.slice(0) : [elem];
for (var i = 0; i < elems.length; i++) {
var nextSiblings = subselects_1.getNextSiblings(elems[i], adapter);
var elemsLength = elems.length;
for (var i = 0; i < elemsLength; i++) {
var nextSiblings = (0, subselects_js_1.getNextSiblings)(elems[i], adapter);
elems.push.apply(elems, nextSiblings);
}
return elems;
@ -98,7 +106,7 @@ function appendNextSiblings(elem, adapter) {
*
*/
exports.selectAll = getSelectorFunc(function (query, elems, options) {
return query === boolbase_1.falseFunc || !elems || elems.length === 0
return query === boolbase_1.default.falseFunc || !elems || elems.length === 0
? []
: options.adapter.findAll(query, elems);
});
@ -112,7 +120,7 @@ exports.selectAll = getSelectorFunc(function (query, elems, options) {
* @returns the first match, or null if there was no match.
*/
exports.selectOne = getSelectorFunc(function (query, elems, options) {
return query === boolbase_1.falseFunc || !elems || elems.length === 0
return query === boolbase_1.default.falseFunc || !elems || elems.length === 0
? null
: options.adapter.findOne(query, elems);
});
@ -129,7 +137,7 @@ exports.selectOne = getSelectorFunc(function (query, elems, options) {
*/
function is(elem, query, options) {
var opts = convertOptionFormats(options);
return (typeof query === "function" ? query : compile_1.compile(query, opts))(elem);
return (typeof query === "function" ? query : (0, compile_js_1.compile)(query, opts))(elem);
}
exports.is = is;
/**
@ -138,7 +146,9 @@ exports.is = is;
*/
exports.default = exports.selectAll;
// Export filters, pseudos and aliases to allow users to supply their own.
var pseudo_selectors_1 = require("./pseudo-selectors");
Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return pseudo_selectors_1.filters; } });
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return pseudo_selectors_1.pseudos; } });
Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return pseudo_selectors_1.aliases; } });
/** @deprecated Use the `pseudos` option instead. */
var index_js_1 = require("./pseudo-selectors/index.js");
Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return index_js_1.filters; } });
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return index_js_1.pseudos; } });
Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return index_js_1.aliases; } });
//# sourceMappingURL=index.js.map

View file

@ -1,5 +0,0 @@
import type { Traversal } from "css-what";
import type { InternalSelector } from "./types";
export declare const procedure: Record<InternalSelector["type"], number>;
export declare function isTraversal(t: InternalSelector): t is Traversal;
//# sourceMappingURL=procedure.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../src/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,CAY9D,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAAE,gBAAgB,GAAG,CAAC,IAAI,SAAS,CAE/D"}

View file

@ -1,20 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTraversal = exports.procedure = void 0;
exports.procedure = {
universal: 50,
tag: 30,
attribute: 1,
pseudo: 0,
"pseudo-element": 0,
descendant: -1,
child: -1,
parent: -1,
sibling: -1,
adjacent: -1,
_flexibleDescendant: -1,
};
function isTraversal(t) {
return exports.procedure[t.type] < 0;
}
exports.isTraversal = isTraversal;

View file

@ -1 +1 @@
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/aliases.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwC1C,CAAC"}
{"version":3,"file":"aliases.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/aliases.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwC1C,CAAC"}

View file

@ -31,3 +31,4 @@ exports.aliases = {
input: ":is(input, textarea, select, button)",
text: "input:is(:not([type!='']), [type=text])",
};
//# sourceMappingURL=aliases.js.map

View file

@ -1,4 +1,4 @@
import type { CompiledQuery, InternalOptions } from "../types";
import type { CompiledQuery, InternalOptions } from "../types.js";
export declare type Filter = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, text: string, options: InternalOptions<Node, ElementNode>, context?: Node[]) => CompiledQuery<ElementNode>;
export declare const filters: Record<string, Filter>;
//# sourceMappingURL=filters.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/filters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AAExE,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,KACf,aAAa,CAAC,WAAW,CAAC,CAAC;AAYhC,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2I1C,CAAC"}
{"version":3,"file":"filters.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/filters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAW,MAAM,aAAa,CAAC;AAE3E,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,KACf,aAAa,CAAC,WAAW,CAAC,CAAC;AAYhC,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2I1C,CAAC"}

View file

@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.filters = void 0;
var nth_check_1 = __importDefault(require("nth-check"));
var boolbase_1 = require("boolbase");
var boolbase_1 = __importDefault(require("boolbase"));
function getChildFunc(next, adapter) {
return function (elem) {
var parent = adapter.getParent(elem);
@ -30,10 +30,10 @@ exports.filters = {
// Location specific methods
"nth-child": function (next, rule, _a) {
var adapter = _a.adapter, equals = _a.equals;
var func = nth_check_1.default(rule);
if (func === boolbase_1.falseFunc)
return boolbase_1.falseFunc;
if (func === boolbase_1.trueFunc)
var func = (0, nth_check_1.default)(rule);
if (func === boolbase_1.default.falseFunc)
return boolbase_1.default.falseFunc;
if (func === boolbase_1.default.trueFunc)
return getChildFunc(next, adapter);
return function nthChild(elem) {
var siblings = adapter.getSiblings(elem);
@ -50,10 +50,10 @@ exports.filters = {
},
"nth-last-child": function (next, rule, _a) {
var adapter = _a.adapter, equals = _a.equals;
var func = nth_check_1.default(rule);
if (func === boolbase_1.falseFunc)
return boolbase_1.falseFunc;
if (func === boolbase_1.trueFunc)
var func = (0, nth_check_1.default)(rule);
if (func === boolbase_1.default.falseFunc)
return boolbase_1.default.falseFunc;
if (func === boolbase_1.default.trueFunc)
return getChildFunc(next, adapter);
return function nthLastChild(elem) {
var siblings = adapter.getSiblings(elem);
@ -70,10 +70,10 @@ exports.filters = {
},
"nth-of-type": function (next, rule, _a) {
var adapter = _a.adapter, equals = _a.equals;
var func = nth_check_1.default(rule);
if (func === boolbase_1.falseFunc)
return boolbase_1.falseFunc;
if (func === boolbase_1.trueFunc)
var func = (0, nth_check_1.default)(rule);
if (func === boolbase_1.default.falseFunc)
return boolbase_1.default.falseFunc;
if (func === boolbase_1.default.trueFunc)
return getChildFunc(next, adapter);
return function nthOfType(elem) {
var siblings = adapter.getSiblings(elem);
@ -92,10 +92,10 @@ exports.filters = {
},
"nth-last-of-type": function (next, rule, _a) {
var adapter = _a.adapter, equals = _a.equals;
var func = nth_check_1.default(rule);
if (func === boolbase_1.falseFunc)
return boolbase_1.falseFunc;
if (func === boolbase_1.trueFunc)
var func = (0, nth_check_1.default)(rule);
if (func === boolbase_1.default.falseFunc)
return boolbase_1.default.falseFunc;
if (func === boolbase_1.default.trueFunc)
return getChildFunc(next, adapter);
return function nthLastOfType(elem) {
var siblings = adapter.getSiblings(elem);
@ -124,7 +124,7 @@ exports.filters = {
var equals = options.equals;
if (!context || context.length === 0) {
// Equivalent to :root
return exports.filters.root(next, rule, options);
return exports.filters["root"](next, rule, options);
}
if (context.length === 1) {
// NOTE: can't be unpacked, as :has uses this for side-effects
@ -147,10 +147,11 @@ function dynamicStatePseudo(name) {
var adapter = _a.adapter;
var func = adapter[name];
if (typeof func !== "function") {
return boolbase_1.falseFunc;
return boolbase_1.default.falseFunc;
}
return function active(elem) {
return func(elem) && next(elem);
};
};
}
//# sourceMappingURL=filters.js.map

View file

@ -1,8 +1,8 @@
import type { CompiledQuery, InternalOptions, CompileToken } from "../types";
import type { CompiledQuery, InternalOptions, CompileToken } from "../types.js";
import { PseudoSelector } from "css-what";
import { filters } from "./filters";
import { pseudos } from "./pseudos";
import { aliases } from "./aliases";
import { filters } from "./filters.js";
import { pseudos } from "./pseudos.js";
import { aliases } from "./aliases.js";
export { filters, pseudos, aliases };
export declare function compilePseudoSelector<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, selector: PseudoSelector, options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>): CompiledQuery<ElementNode>;
//# sourceMappingURL=index.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAS,cAAc,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAoB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAErC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9C,aAAa,CAAC,WAAW,CAAC,CA6B5B"}
{"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAS,cAAc,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAErC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9C,aAAa,CAAC,WAAW,CAAC,CA4C5B"}

View file

@ -1,54 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compilePseudoSelector = exports.aliases = exports.pseudos = exports.filters = void 0;
/*
* Pseudo selectors
*
* Pseudo selectors are available in three forms:
*
* 1. Filters are called when the selector is compiled and return a function
* that has to return either false, or the results of `next()`.
* 2. Pseudos are called on execution. They have to return a boolean.
* 3. Subselects work like filters, but have an embedded selector that will be run separately.
*
* Filters are great if you want to do some pre-processing, or change the call order
* of `next()` and your code.
* Pseudos should be used to implement simple checks.
*/
var boolbase_1 = require("boolbase");
var css_what_1 = require("css-what");
var filters_1 = require("./filters");
Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return filters_1.filters; } });
var pseudos_1 = require("./pseudos");
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return pseudos_1.pseudos; } });
var aliases_1 = require("./aliases");
Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return aliases_1.aliases; } });
var subselects_1 = require("./subselects");
var filters_js_1 = require("./filters.js");
Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return filters_js_1.filters; } });
var pseudos_js_1 = require("./pseudos.js");
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return pseudos_js_1.pseudos; } });
var aliases_js_1 = require("./aliases.js");
Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return aliases_js_1.aliases; } });
var subselects_js_1 = require("./subselects.js");
function compilePseudoSelector(next, selector, options, context, compileToken) {
var _a;
var name = selector.name, data = selector.data;
if (Array.isArray(data)) {
return subselects_1.subselects[name](next, data, options, context, compileToken);
if (!(name in subselects_js_1.subselects)) {
throw new Error("Unknown pseudo-class :".concat(name, "(").concat(data, ")"));
}
if (name in aliases_1.aliases) {
return subselects_js_1.subselects[name](next, data, options, context, compileToken);
}
var userPseudo = (_a = options.pseudos) === null || _a === void 0 ? void 0 : _a[name];
var stringPseudo = typeof userPseudo === "string" ? userPseudo : aliases_js_1.aliases[name];
if (typeof stringPseudo === "string") {
if (data != null) {
throw new Error("Pseudo " + name + " doesn't have any arguments");
throw new Error("Pseudo ".concat(name, " doesn't have any arguments"));
}
// The alias has to be parsed here, to make sure options are respected.
var alias = css_what_1.parse(aliases_1.aliases[name], options);
return subselects_1.subselects.is(next, alias, options, context, compileToken);
var alias = (0, css_what_1.parse)(stringPseudo);
return subselects_js_1.subselects["is"](next, alias, options, context, compileToken);
}
if (name in filters_1.filters) {
return filters_1.filters[name](next, data, options, context);
if (typeof userPseudo === "function") {
(0, pseudos_js_1.verifyPseudoArgs)(userPseudo, name, data, 1);
return function (elem) { return userPseudo(elem, data) && next(elem); };
}
if (name in pseudos_1.pseudos) {
var pseudo_1 = pseudos_1.pseudos[name];
pseudos_1.verifyPseudoArgs(pseudo_1, name, data);
return pseudo_1 === boolbase_1.falseFunc
? boolbase_1.falseFunc
: next === boolbase_1.trueFunc
? function (elem) { return pseudo_1(elem, options, data); }
: function (elem) { return pseudo_1(elem, options, data) && next(elem); };
if (name in filters_js_1.filters) {
return filters_js_1.filters[name](next, data, options, context);
}
throw new Error("unmatched pseudo-class :" + name);
if (name in pseudos_js_1.pseudos) {
var pseudo_1 = pseudos_js_1.pseudos[name];
(0, pseudos_js_1.verifyPseudoArgs)(pseudo_1, name, data, 2);
return function (elem) { return pseudo_1(elem, options, data) && next(elem); };
}
throw new Error("Unknown pseudo-class :".concat(name));
}
exports.compilePseudoSelector = compilePseudoSelector;
//# sourceMappingURL=index.js.map

View file

@ -1,6 +1,6 @@
import { PseudoSelector } from "css-what";
import type { InternalOptions } from "../types";
export declare type Pseudo = <Node, ElementNode extends Node>(elem: ElementNode, options: InternalOptions<Node, ElementNode>, subselect?: ElementNode | string | null) => boolean;
import type { PseudoSelector } from "css-what";
import type { InternalOptions } from "../types.js";
export declare type Pseudo = <Node, ElementNode extends Node>(elem: ElementNode, options: InternalOptions<Node, ElementNode>, subselect?: string | null) => boolean;
export declare const pseudos: Record<string, Pseudo>;
export declare function verifyPseudoArgs(func: Pseudo, name: string, subselect: PseudoSelector["data"]): void;
export declare function verifyPseudoArgs<T extends Array<unknown>>(func: (...args: T) => boolean, name: string, subselect: PseudoSelector["data"], argIndex: number): void;
//# sourceMappingURL=pseudos.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"pseudos.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/pseudos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,KACtC,OAAO,CAAC;AAGb,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8E1C,CAAC;AAEF,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,GAClC,IAAI,CAQN"}
{"version":3,"file":"pseudos.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/pseudos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,KACxB,OAAO,CAAC;AAGb,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkF1C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EACrD,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,EAC7B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,EACjC,QAAQ,EAAE,MAAM,GACjB,IAAI,CAQN"}

View file

@ -12,6 +12,9 @@ exports.pseudos = {
},
"first-child": function (elem, _a) {
var adapter = _a.adapter, equals = _a.equals;
if (adapter.prevElementSibling) {
return adapter.prevElementSibling(elem) == null;
}
var firstChild = adapter
.getSiblings(elem)
.find(function (elem) { return adapter.isTag(elem); });
@ -76,14 +79,15 @@ exports.pseudos = {
.every(function (sibling) { return equals(elem, sibling) || !adapter.isTag(sibling); });
},
};
function verifyPseudoArgs(func, name, subselect) {
function verifyPseudoArgs(func, name, subselect, argIndex) {
if (subselect === null) {
if (func.length > 2) {
throw new Error("pseudo-selector :" + name + " requires an argument");
if (func.length > argIndex) {
throw new Error("Pseudo-class :".concat(name, " requires an argument"));
}
}
else if (func.length === 2) {
throw new Error("pseudo-selector :" + name + " doesn't have any arguments");
else if (func.length === argIndex) {
throw new Error("Pseudo-class :".concat(name, " doesn't have any arguments"));
}
}
exports.verifyPseudoArgs = verifyPseudoArgs;
//# sourceMappingURL=pseudos.js.map

View file

@ -1,6 +1,5 @@
import { CompileToken } from "./../types";
import type { Selector } from "css-what";
import type { CompiledQuery, InternalOptions, Adapter } from "../types";
import type { CompiledQuery, InternalOptions, CompileToken, Adapter } from "../types.js";
/** Used as a placeholder for :has. Will be replaced with the actual element. */
export declare const PLACEHOLDER_ELEMENT: {};
export declare function ensureIsTag<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, adapter: Adapter<Node, ElementNode>): CompiledQuery<Node>;

View file

@ -1 +1 @@
{"version":3,"file":"subselects.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/subselects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxE,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,IAAK,CAAC;AAEtC,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACtD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,aAAa,CAAC,IAAI,CAAC,CAGrB;AAED,oBAAY,SAAS,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACnD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,SAAS,EAAE,QAAQ,EAAE,EAAE,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,KAC5C,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhC,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC1D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,WAAW,EAAE,CAMf;AAkBD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CA4EhD,CAAC"}
{"version":3,"file":"subselects.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/subselects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,YAAY,EACZ,OAAO,EACV,MAAM,aAAa,CAAC;AAGrB,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,IAAK,CAAC;AAEtC,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACtD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,aAAa,CAAC,IAAI,CAAC,CAGrB;AAED,oBAAY,SAAS,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACnD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,SAAS,EAAE,QAAQ,EAAE,EAAE,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,KAC5C,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhC,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC1D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,WAAW,EAAE,CAMf;AAiCD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAgEhD,CAAC"}

View file

@ -1,18 +1,25 @@
"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.subselects = exports.getNextSiblings = exports.ensureIsTag = exports.PLACEHOLDER_ELEMENT = void 0;
var boolbase_1 = require("boolbase");
var procedure_1 = require("../procedure");
var boolbase_1 = __importDefault(require("boolbase"));
var sort_js_1 = require("../sort.js");
/** Used as a placeholder for :has. Will be replaced with the actual element. */
exports.PLACEHOLDER_ELEMENT = {};
function ensureIsTag(next, adapter) {
if (next === boolbase_1.falseFunc)
return boolbase_1.falseFunc;
if (next === boolbase_1.default.falseFunc)
return boolbase_1.default.falseFunc;
return function (elem) { return adapter.isTag(elem) && next(elem); };
}
exports.ensureIsTag = ensureIsTag;
@ -26,75 +33,74 @@ function getNextSiblings(elem, adapter) {
return siblings.slice(elemIndex + 1).filter(adapter.isTag);
}
exports.getNextSiblings = getNextSiblings;
var is = function (next, token, options, context, compileToken) {
var opts = {
function copyOptions(options) {
// Not copied: context, rootFunc
return {
xmlMode: !!options.xmlMode,
lowerCaseAttributeNames: !!options.lowerCaseAttributeNames,
lowerCaseTags: !!options.lowerCaseTags,
quirksMode: !!options.quirksMode,
cacheResults: !!options.cacheResults,
pseudos: options.pseudos,
adapter: options.adapter,
equals: options.equals,
};
var func = compileToken(token, opts, context);
return function (elem) { return func(elem) && next(elem); };
}
var is = function (next, token, options, context, compileToken) {
var func = compileToken(token, copyOptions(options), context);
return func === boolbase_1.default.trueFunc
? next
: func === boolbase_1.default.falseFunc
? boolbase_1.default.falseFunc
: function (elem) { return func(elem) && next(elem); };
};
/*
* :not, :has, :is and :matches have to compile selectors
* :not, :has, :is, :matches and :where have to compile selectors
* doing this in src/pseudos.ts would lead to circular dependencies,
* so we add them here
*/
exports.subselects = {
is: is,
/**
* `:matches` is an alias for `:is`.
* `:matches` and `:where` are aliases for `:is`.
*/
matches: is,
where: is,
not: function (next, token, options, context, compileToken) {
var opts = {
xmlMode: !!options.xmlMode,
adapter: options.adapter,
equals: options.equals,
};
var func = compileToken(token, opts, context);
if (func === boolbase_1.falseFunc)
return next;
if (func === boolbase_1.trueFunc)
return boolbase_1.falseFunc;
return function not(elem) {
return !func(elem) && next(elem);
};
var func = compileToken(token, copyOptions(options), context);
return func === boolbase_1.default.falseFunc
? next
: func === boolbase_1.default.trueFunc
? boolbase_1.default.falseFunc
: function (elem) { return !func(elem) && next(elem); };
},
has: function (next, subselect, options, _context, compileToken) {
var adapter = options.adapter;
var opts = {
xmlMode: !!options.xmlMode,
adapter: adapter,
equals: options.equals,
};
// @ts-expect-error Uses an array as a pointer to the current element (side effects)
var context = subselect.some(function (s) {
return s.some(procedure_1.isTraversal);
})
? [exports.PLACEHOLDER_ELEMENT]
var opts = copyOptions(options);
opts.relativeSelector = true;
var context = subselect.some(function (s) { return s.some(sort_js_1.isTraversal); })
? // Used as a placeholder. Will be replaced with the actual element.
[exports.PLACEHOLDER_ELEMENT]
: undefined;
var compiled = compileToken(subselect, opts, context);
if (compiled === boolbase_1.falseFunc)
return boolbase_1.falseFunc;
if (compiled === boolbase_1.trueFunc) {
return function (elem) {
return adapter.getChildren(elem).some(adapter.isTag) && next(elem);
};
}
if (compiled === boolbase_1.default.falseFunc)
return boolbase_1.default.falseFunc;
var hasElement = ensureIsTag(compiled, adapter);
var _a = compiled.shouldTestNextSiblings, shouldTestNextSiblings = _a === void 0 ? false : _a;
// If `compiled` is `trueFunc`, we can skip this.
if (context && compiled !== boolbase_1.default.trueFunc) {
/*
* `shouldTestNextSiblings` will only be true if the query starts with
* a traversal (sibling or adjacent). That means we will always have a context.
*/
if (context) {
var _a = compiled.shouldTestNextSiblings, shouldTestNextSiblings_1 = _a === void 0 ? false : _a;
return function (elem) {
if (!next(elem))
return false;
context[0] = elem;
var childs = adapter.getChildren(elem);
var nextElements = shouldTestNextSiblings
? __spreadArray(__spreadArray([], childs), getNextSiblings(elem, adapter)) : childs;
return (next(elem) && adapter.existsOne(hasElement, nextElements));
var nextElements = shouldTestNextSiblings_1
? __spreadArray(__spreadArray([], childs, true), getNextSiblings(elem, adapter), true) : childs;
return adapter.existsOne(hasElement, nextElements);
};
}
return function (elem) {
@ -103,3 +109,4 @@ exports.subselects = {
};
},
};
//# sourceMappingURL=subselects.js.map

View file

@ -1,4 +1,6 @@
import type { InternalSelector } from "./types";
import type { InternalSelector } from "./types.js";
import { type Traversal } from "css-what";
export declare function isTraversal(token: InternalSelector): token is Traversal;
/**
* Sort the parts of the passed selector,
* as there is potential for optimization

View file

@ -1 +1 @@
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../src/sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAehD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAerE"}
{"version":3,"file":"sort.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AASzE,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,SAAS,CAEvE;AAWD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAerE"}

64
node_modules/css-select/lib/sort.js generated vendored
View file

@ -1,16 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var procedure_1 = require("./procedure");
var attributes = {
exists: 10,
equals: 8,
not: 7,
start: 6,
end: 6,
any: 5,
hyphen: 4,
element: 4,
};
exports.isTraversal = void 0;
var css_what_1 = require("css-what");
var procedure = new Map([
[css_what_1.SelectorType.Universal, 50],
[css_what_1.SelectorType.Tag, 30],
[css_what_1.SelectorType.Attribute, 1],
[css_what_1.SelectorType.Pseudo, 0],
]);
function isTraversal(token) {
return !procedure.has(token.type);
}
exports.isTraversal = isTraversal;
var attributes = new Map([
[css_what_1.AttributeAction.Exists, 10],
[css_what_1.AttributeAction.Equals, 8],
[css_what_1.AttributeAction.Not, 7],
[css_what_1.AttributeAction.Start, 6],
[css_what_1.AttributeAction.End, 6],
[css_what_1.AttributeAction.Any, 5],
]);
/**
* Sort the parts of the passed selector,
* as there is potential for optimization
@ -35,10 +44,11 @@ function sortByProcedure(arr) {
}
exports.default = sortByProcedure;
function getProcedure(token) {
var proc = procedure_1.procedure[token.type];
if (token.type === "attribute") {
proc = attributes[token.action];
if (proc === attributes.equals && token.name === "id") {
var _a, _b;
var proc = (_a = procedure.get(token.type)) !== null && _a !== void 0 ? _a : -1;
if (token.type === css_what_1.SelectorType.Attribute) {
proc = (_b = attributes.get(token.action)) !== null && _b !== void 0 ? _b : 4;
if (token.action === css_what_1.AttributeAction.Equals && token.name === "id") {
// Prefer ID selectors (eg. #ID)
proc = 9;
}
@ -50,7 +60,7 @@ function getProcedure(token) {
proc >>= 1;
}
}
else if (token.type === "pseudo") {
else if (token.type === css_what_1.SelectorType.Pseudo) {
if (!token.data) {
proc = 3;
}
@ -58,27 +68,17 @@ function getProcedure(token) {
proc = 0; // Expensive in any case
}
else if (Array.isArray(token.data)) {
// "matches" and "not"
// Eg. :matches, :not
proc = Math.min.apply(Math, token.data.map(function (d) { return Math.min.apply(Math, d.map(getProcedure)); }));
// If we have traversals, try to avoid executing this selector
if (proc < 0) {
proc = 0;
for (var i = 0; i < token.data.length; i++) {
// TODO better handling of complex selectors
if (token.data[i].length !== 1)
continue;
var cur = getProcedure(token.data[i][0]);
// Avoid executing :has or :contains
if (cur === 0) {
proc = 0;
break;
}
if (cur > proc)
proc = cur;
}
if (token.data.length > 1 && proc > 0)
proc -= 1;
}
else {
proc = 1;
proc = 2;
}
}
return proc;
}
//# sourceMappingURL=sort.js.map

View file

@ -27,12 +27,16 @@ export interface Adapter<Node, ElementNode extends Node> {
/**
* Get the parent of the node
*/
getParent: (node: ElementNode) => ElementNode | null;
getParent: (node: ElementNode) => Node | null;
/**
* Get the siblings of the node. Note that unlike jQuery's `siblings` method,
* this is expected to include the current node as well
*/
getSiblings: (node: Node) => Node[];
/**
* Returns the previous element sibling of a node.
*/
prevElementSibling?: (node: Node) => ElementNode | null;
/**
* Get the text content of the node, and its children if it has any.
*/
@ -83,6 +87,35 @@ export interface Options<Node, ElementNode extends Node> {
* @default false
*/
xmlMode?: boolean;
/**
* Lower-case attribute names.
*
* @default !xmlMode
*/
lowerCaseAttributeNames?: boolean;
/**
* Lower-case tag names.
*
* @default !xmlMode
*/
lowerCaseTags?: boolean;
/**
* Is the document in quirks mode?
*
* This will lead to .className and #id being case-insensitive.
*
* @default false
*/
quirksMode?: boolean;
/**
* Pseudo-classes that override the default ones.
*
* Maps from names to either strings of functions.
* - A string value is a selector that the element must match to be selected.
* - A function is called with the element as its first argument, and optional
* parameters second. If it returns true, the element is selected.
*/
pseudos?: Record<string, string | ((elem: ElementNode, value?: string | null) => boolean)> | undefined;
/**
* The last function in the stack, will be called with the last element
* that's looked at.
@ -95,9 +128,23 @@ export interface Options<Node, ElementNode extends Node> {
adapter?: Adapter<Node, ElementNode>;
/**
* The context of the current query. Used to limit the scope of searches.
* Can be matched directly using the `:scope` pseudo-selector.
* Can be matched directly using the `:scope` pseudo-class.
*/
context?: Node | Node[];
/**
* Indicates whether to consider the selector as a relative selector.
*
* Relative selectors that don't include a `:scope` pseudo-class behave
* as if they have a `:scope ` prefix (a `:scope` pseudo-class, followed by
* a descendant selector).
*
* If relative selectors are disabled, selectors starting with a traversal
* will lead to an error.
*
* @default true
* @see {@link https://www.w3.org/TR/selectors-4/#relative}
*/
relativeSelector?: boolean;
/**
* Allow css-select to cache results for some selectors, sometimes greatly
* improving querying performance. Disable this if your document can

View file

@ -1 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,oBAAY,gBAAgB,GAAG,QAAQ,GAAG;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAE1E,oBAAY,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC;AACrD,MAAM,WAAW,OAAO,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI;IACnD;;OAEG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,IAAI,WAAW,CAAC;IAE3C;;OAEG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC;IAEpE;;OAEG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAE3E;;OAEG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,EAAE,CAAC;IAEpC;;OAEG;IACH,OAAO,EAA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;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAGD,MAAM,WAAW,eAAe,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,CAC3D,SAAQ,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC;CACzC;AAED,MAAM,WAAW,aAAa,CAAC,WAAW;IACtC,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC;AACD,oBAAY,KAAK,CAAC,WAAW,IACvB,MAAM,GACN,aAAa,CAAC,WAAW,CAAC,GAC1B,QAAQ,EAAE,EAAE,CAAC;AACnB,oBAAY,YAAY,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,IAAI,CACvD,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAC3B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,KACtB,aAAa,CAAC,WAAW,CAAC,CAAC"}

View file

@ -1,2 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

140
node_modules/css-select/package.json generated vendored
View file

@ -1,103 +1,81 @@
{
"_from": "css-select@^4.1.3",
"_id": "css-select@4.1.3",
"_inBundle": false,
"_integrity": "sha512-gT3wBNd9Nj49rAbmtFHj1cljIAOLYSX1nZ8CB7TBO3INYckygm5B7LISU/szY//YmdiSLbJvDLOx9VnMVpMBxA==",
"_location": "/css-select",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "css-select@^4.1.3",
"name": "css-select",
"escapedName": "css-select",
"rawSpec": "^4.1.3",
"saveSpec": null,
"fetchSpec": "^4.1.3"
},
"_requiredBy": [
"/cheerio-select"
],
"_resolved": "https://registry.npmjs.org/css-select/-/css-select-4.1.3.tgz",
"_shasum": "a70440f70317f2669118ad74ff105e65849c7067",
"_spec": "css-select@^4.1.3",
"_where": "/home/runner/work/public_library_map/public_library_map/node_modules/cheerio-select",
"author": {
"name": "Felix Boehm",
"email": "me@feedic.com"
},
"bugs": {
"url": "https://github.com/fb55/css-select/issues"
},
"bundleDependencies": false,
"dependencies": {
"boolbase": "^1.0.0",
"css-what": "^5.0.0",
"domhandler": "^4.2.0",
"domutils": "^2.6.0",
"nth-check": "^2.0.0"
},
"deprecated": false,
"version": "5.1.0",
"description": "a CSS selector compiler/engine",
"devDependencies": {
"@types/boolbase": "^1.0.0",
"@types/jest": "^26.0.14",
"@types/node": "^15.0.2",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"cheerio-soupselect": "^0.1.1",
"coveralls": "^3.0.2",
"eslint": "^7.9.0",
"eslint-config-prettier": "^8.1.0",
"htmlparser2": "^6.0.0",
"jest": "^27.0.3",
"prettier": "^2.1.2",
"ts-jest": "^27.0.1",
"typescript": "^4.0.2"
},
"files": [
"lib"
],
"author": "Felix Boehm <me@feedic.com>",
"funding": {
"url": "https://github.com/sponsors/fb55"
},
"homepage": "https://github.com/fb55/css-select#readme",
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testMatch": [
"<rootDir>/test/*.ts"
]
},
"keywords": [
"css",
"selector",
"sizzle"
],
"license": "BSD-2-Clause",
"main": "lib/index.js",
"name": "css-select",
"prettier": {
"tabWidth": 4,
"proseWrap": "always"
},
"repository": {
"type": "git",
"url": "git://github.com/fb55/css-select.git"
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"module": "lib/esm/index.js",
"exports": {
"require": "./lib/index.js",
"import": "./lib/esm/index.js"
},
"files": [
"lib"
],
"dependencies": {
"boolbase": "^1.0.0",
"css-what": "^6.1.0",
"domhandler": "^5.0.2",
"domutils": "^3.0.1",
"nth-check": "^2.0.1"
},
"devDependencies": {
"@types/boolbase": "^1.0.1",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.29",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"cheerio-soupselect": "^0.1.1",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"htmlparser2": "^8.0.0",
"jest": "^27.5.1",
"prettier": "^2.6.2",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
},
"scripts": {
"build": "tsc",
"coverage": "cat coverage/lcov.info | coveralls",
"format": "npm run format:es && npm run format:prettier",
"format:es": "npm run lint:es -- --fix",
"format:prettier": "npm run prettier -- --write",
"test": "npm run test:jest && npm run lint",
"test:jest": "jest",
"lint": "npm run lint:es && npm run lint:prettier",
"lint:es": "eslint src",
"lint:prettier": "npm run prettier -- --check",
"prepare": "npm run build",
"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}'",
"test": "jest --coverage && npm run lint"
"build": "npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --sourceRoot https://raw.githubusercontent.com/fb55/css-select/$(git rev-parse HEAD)/src/",
"build:esm": "npm run build:cjs -- --module esnext --target es2019 --outDir lib/esm && echo '{\"type\":\"module\"}' > lib/esm/package.json",
"prepare": "npm run build"
},
"types": "lib/index.d.ts",
"version": "4.1.3"
"license": "BSD-2-Clause",
"prettier": {
"tabWidth": 4,
"proseWrap": "always"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"coverageProvider": "v8",
"moduleNameMapper": {
"^(.*)\\.js$": "$1"
},
"testMatch": [
"<rootDir>/test/*.ts"
]
}
}

View file

@ -1,4 +0,0 @@
export * from "./parse";
export { default as parse } from "./parse";
export { default as stringify } from "./stringify";
//# sourceMappingURL=index.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC"}

21
node_modules/css-what/lib/index.js generated vendored
View file

@ -1,21 +0,0 @@
"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);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringify = exports.parse = void 0;
__exportStar(require("./parse"), exports);
var parse_1 = require("./parse");
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return __importDefault(parse_1).default; } });
var stringify_1 = require("./stringify");
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return __importDefault(stringify_1).default; } });

71
node_modules/css-what/lib/parse.d.ts generated vendored
View file

@ -1,71 +0,0 @@
export interface Options {
/**
* When false, tag names will not be lowercased.
* @default true
*/
lowerCaseAttributeNames?: boolean;
/**
* When false, attribute names will not be lowercased.
* @default true
*/
lowerCaseTags?: boolean;
/**
* When `true`, `xmlMode` implies both `lowerCaseTags` and `lowerCaseAttributeNames` are set to `false`.
* Also, `ignoreCase` on attributes will not be inferred based on HTML rules anymore.
* @default false
*/
xmlMode?: boolean;
}
export declare type Selector = PseudoSelector | PseudoElement | AttributeSelector | TagSelector | UniversalSelector | Traversal;
export interface AttributeSelector {
type: "attribute";
name: string;
action: AttributeAction;
value: string;
ignoreCase: boolean | null;
namespace: string | null;
}
declare type DataType = Selector[][] | null | string;
export interface PseudoSelector {
type: "pseudo";
name: string;
data: DataType;
}
export interface PseudoElement {
type: "pseudo-element";
name: string;
}
export interface TagSelector {
type: "tag";
name: string;
namespace: string | null;
}
export interface UniversalSelector {
type: "universal";
namespace: string | null;
}
export interface Traversal {
type: TraversalType;
}
export declare type AttributeAction = "any" | "element" | "end" | "equals" | "exists" | "hyphen" | "not" | "start";
export declare type TraversalType = "adjacent" | "child" | "descendant" | "parent" | "sibling";
/**
* Checks whether a specific selector is a traversal.
* This is useful eg. in swapping the order of elements that
* are not traversals.
*
* @param selector Selector to check.
*/
export declare function isTraversal(selector: Selector): selector is Traversal;
/**
* Parses `selector`, optionally with the passed `options`.
*
* @param selector Selector to parse.
* @param options Options for parsing.
* @returns Returns a two-dimensional array.
* The first dimension represents selectors separated by commas (eg. `sub1, sub2`),
* the second contains the relevant tokens for that selector.
*/
export default function parse(selector: string, options?: Options): Selector[][];
export {};
//# sourceMappingURL=parse.d.ts.map

Some files were not shown because too many files have changed in this diff Show more