Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
11
node_modules/css-select/LICENSE
generated
vendored
Normal file
11
node_modules/css-select/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
Copyright (c) Felix Böhm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
264
node_modules/css-select/README.md
generated
vendored
Normal file
264
node_modules/css-select/README.md
generated
vendored
Normal file
|
@ -0,0 +1,264 @@
|
|||
# css-select [](https://npmjs.org/package/css-select) [](http://travis-ci.com/fb55/css-select) [](https://npmjs.org/package/css-select) [](https://coveralls.io/r/fb55/css-select)
|
||||
|
||||
A CSS selector compiler and engine
|
||||
|
||||
## What?
|
||||
|
||||
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). To query alternative DOM structures, see [`Options`](#options)
|
||||
below.
|
||||
|
||||
**Features:**
|
||||
|
||||
- 🔬 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?
|
||||
|
||||
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
|
||||
`a` once, if they are `b`s. Using
|
||||
[Big O notation](http://en.wikipedia.org/wiki/Big_O_notation), that would be
|
||||
`O(n^(k+1))`, where `k` is the number of descendant selectors (that's the space
|
||||
in the example above).
|
||||
|
||||
The far more efficient approach is to first look for `b` elements, then check if
|
||||
they have superior `a` elements: Using big O notation again, that would be
|
||||
`O(n)`. That's called right-to-left execution.
|
||||
|
||||
And that's what css-select does – and why it's quite performant.
|
||||
|
||||
## How does it work?
|
||||
|
||||
By building a stack of functions.
|
||||
|
||||
_Wait, what?_
|
||||
|
||||
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.
|
||||
|
||||
Anyway, after parsing, we end up with an array like this one:
|
||||
|
||||
```js
|
||||
[
|
||||
{ type: "tag", name: "a" },
|
||||
{ type: "descendant" },
|
||||
{ type: "tag", name: "b" },
|
||||
];
|
||||
```
|
||||
|
||||
(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 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 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. 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
|
||||
|
||||
```js
|
||||
const CSSselect = require("css-select");
|
||||
```
|
||||
|
||||
**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)`
|
||||
|
||||
Queries `elems`, returns an array containing all matches.
|
||||
|
||||
- `query` can be either a CSS selector or a function.
|
||||
- `elems` can be either an array of elements, or a single element. If it is an
|
||||
element, its children will be queried.
|
||||
- `options` is described below.
|
||||
|
||||
Aliases: `default` export, `CSSselect.iterate(query, elems)`.
|
||||
|
||||
#### `CSSselect.compile(query, options)`
|
||||
|
||||
Compiles the query, returns a function.
|
||||
|
||||
#### `CSSselect.is(elem, query, options)`
|
||||
|
||||
Tests whether or not an element is matched by `query`. `query` can be either a
|
||||
CSS selector or a function.
|
||||
|
||||
#### `CSSselect.selectOne(query, elems, options)`
|
||||
|
||||
Arguments are the same as for `CSSselect.selectAll(query, elems)`. Only returns
|
||||
the first match, or `null` if there was no match.
|
||||
|
||||
### Options
|
||||
|
||||
All options are optional.
|
||||
|
||||
- `xmlMode`: When enabled, tag names will be case-sensitive. Default: `false`.
|
||||
- `rootFunc`: The last function in the stack, will be called with the last
|
||||
element that's looked at.
|
||||
- `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-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
|
||||
|
||||
A custom adapter must match the interface described
|
||||
[here](https://github.com/fb55/css-select/blob/1aa44bdd64aaf2ebdfd7f338e2e76bed36521957/src/types.ts#L6-L96).
|
||||
|
||||
You may want to have a look at [`domutils`](https://github.com/fb55/domutils) to
|
||||
see the default implementation, or at
|
||||
[`css-select-browser-adapter`](https://github.com/nrkn/css-select-browser-adapter/blob/master/index.js)
|
||||
for an implementation backed by the DOM.
|
||||
|
||||
## Supported selectors
|
||||
|
||||
_As defined by CSS 4 and / or jQuery._
|
||||
|
||||
- [Selector lists](https://developer.mozilla.org/en-US/docs/Web/CSS/Selector_list)
|
||||
(`,`)
|
||||
- [Universal](https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors)
|
||||
(`*`)
|
||||
- [Type](https://developer.mozilla.org/en-US/docs/Web/CSS/Type_selectors)
|
||||
(`<tagname>`)
|
||||
- [Descendant](https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator)
|
||||
(` `)
|
||||
- [Child](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator)
|
||||
(`>`)
|
||||
- Parent (`<`)
|
||||
- [Adjacent sibling](https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_combinator)
|
||||
(`+`)
|
||||
- [General sibling](https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_combinator)
|
||||
(`~`)
|
||||
- [Attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)
|
||||
(`[attr=foo]`), with supported comparisons:
|
||||
- `[attr]` (existential)
|
||||
- `=`
|
||||
- `~=`
|
||||
- `|=`
|
||||
- `*=`
|
||||
- `^=`
|
||||
- `$=`
|
||||
- `!=`
|
||||
- `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)
|
||||
- `:icontains` (case-insensitive version of `:contains`)
|
||||
- [`:has`](https://developer.mozilla.org/en-US/docs/Web/CSS/:has)
|
||||
- [`:root`](https://developer.mozilla.org/en-US/docs/Web/CSS/:root)
|
||||
- [`:empty`](https://developer.mozilla.org/en-US/docs/Web/CSS/:empty)
|
||||
- [`:parent`](https://api.jquery.com/parent-selector)
|
||||
- [`:first-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:first-child),
|
||||
[`:last-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:last-child),
|
||||
[`:first-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:first-of-type),
|
||||
[`:last-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:last-of-type)
|
||||
- [`:only-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:only-of-type),
|
||||
[`:only-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:only-child)
|
||||
- [`:nth-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child),
|
||||
[`:nth-last-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-child),
|
||||
[`:nth-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type),
|
||||
[`:nth-last-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-of-type),
|
||||
- [`:link`](https://developer.mozilla.org/en-US/docs/Web/CSS/:link),
|
||||
[`:any-link`](https://developer.mozilla.org/en-US/docs/Web/CSS/:any-link)
|
||||
- [`:visited`](https://developer.mozilla.org/en-US/docs/Web/CSS/:visited),
|
||||
[`:hover`](https://developer.mozilla.org/en-US/docs/Web/CSS/:hover),
|
||||
[`:active`](https://developer.mozilla.org/en-US/docs/Web/CSS/:active)
|
||||
(these depend on optional `Adapter` methods, so these will only match
|
||||
elements if implemented in `Adapter`)
|
||||
- [`:selected`](https://api.jquery.com/selected-selector),
|
||||
[`:checked`](https://developer.mozilla.org/en-US/docs/Web/CSS/:checked)
|
||||
- [`:enabled`](https://developer.mozilla.org/en-US/docs/Web/CSS/:enabled),
|
||||
[`:disabled`](https://developer.mozilla.org/en-US/docs/Web/CSS/:disabled)
|
||||
- [`:required`](https://developer.mozilla.org/en-US/docs/Web/CSS/:required),
|
||||
[`:optional`](https://developer.mozilla.org/en-US/docs/Web/CSS/:optional)
|
||||
- [`:header`](https://api.jquery.com/header-selector),
|
||||
[`:button`](https://api.jquery.com/button-selector),
|
||||
[`:input`](https://api.jquery.com/input-selector),
|
||||
[`:text`](https://api.jquery.com/text-selector),
|
||||
[`:checkbox`](https://api.jquery.com/checkbox-selector),
|
||||
[`:file`](https://api.jquery.com/file-selector),
|
||||
[`:password`](https://api.jquery.com/password-selector),
|
||||
[`:reset`](https://api.jquery.com/reset-selector),
|
||||
[`:radio`](https://api.jquery.com/radio-selector) etc.
|
||||
- [`:is`](https://developer.mozilla.org/en-US/docs/Web/CSS/:is), plus its
|
||||
legacy alias `:matches`
|
||||
- [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope)
|
||||
(uses the context from the passed options)
|
||||
|
||||
---
|
||||
|
||||
License: BSD-2-Clause
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security). Tidelift will
|
||||
coordinate the fix and disclosure.
|
||||
|
||||
## `css-select` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of `css-select` and thousands of other packages are working with
|
||||
Tidelift to deliver commercial support and maintenance for the open source
|
||||
dependencies you use to build your applications. Save time, reduce risk, and
|
||||
improve code health, while paying the maintainers of the exact dependencies you
|
||||
use.
|
||||
[Learn more.](https://tidelift.com/subscription/pkg/npm-css-select?utm_source=npm-css-select&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
236
node_modules/css-select/lib/attributes.js
generated
vendored
Normal file
236
node_modules/css-select/lib/attributes.js
generated
vendored
Normal file
|
@ -0,0 +1,236 @@
|
|||
"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 = __importDefault(require("boolbase"));
|
||||
/**
|
||||
* All reserved characters in a regex, used for escaping.
|
||||
*
|
||||
* Taken from XRegExp, (c) 2007-2020 Steven Levithan under the MIT license
|
||||
* https://github.com/slevithan/xregexp/blob/95eeebeb8fac8754d54eafe2b4743661ac1cf028/src/xregexp.js#L794
|
||||
*/
|
||||
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, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name;
|
||||
var value = data.value;
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function (elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length === value.length &&
|
||||
attr.toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
return adapter.getAttributeValue(elem, name) === value && next(elem);
|
||||
};
|
||||
},
|
||||
hyphen: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name;
|
||||
var value = data.value;
|
||||
var len = value.length;
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function hyphenIC(elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
(attr.length === len || attr.charAt(len) === "-") &&
|
||||
attr.substr(0, len).toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function hyphen(elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
(attr.length === len || attr.charAt(len) === "-") &&
|
||||
attr.substr(0, len) === value &&
|
||||
next(elem));
|
||||
};
|
||||
},
|
||||
element: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name, value = data.value;
|
||||
if (/\s/.test(value)) {
|
||||
return boolbase_1.default.falseFunc;
|
||||
}
|
||||
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 &&
|
||||
attr.length >= value.length &&
|
||||
regex.test(attr) &&
|
||||
next(elem));
|
||||
};
|
||||
},
|
||||
exists: function (next, _a, _b) {
|
||||
var name = _a.name;
|
||||
var adapter = _b.adapter;
|
||||
return function (elem) { return adapter.hasAttrib(elem, name) && next(elem); };
|
||||
},
|
||||
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.default.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function (elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= len &&
|
||||
attr.substr(0, len).toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
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.default.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function (elem) {
|
||||
var _a;
|
||||
return ((_a = adapter
|
||||
.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem);
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
any: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name, value = data.value;
|
||||
if (value === "") {
|
||||
return boolbase_1.default.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
var regex_1 = new RegExp(escapeRegex(value), "i");
|
||||
return function anyIC(elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= value.length &&
|
||||
regex_1.test(attr) &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
not: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name;
|
||||
var value = data.value;
|
||||
if (value === "") {
|
||||
return function (elem) {
|
||||
return !!adapter.getAttributeValue(elem, name) && next(elem);
|
||||
};
|
||||
}
|
||||
else if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function (elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return ((attr == null ||
|
||||
attr.length !== value.length ||
|
||||
attr.toLowerCase() !== value) &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
return adapter.getAttributeValue(elem, name) !== value && next(elem);
|
||||
};
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=attributes.js.map
|
151
node_modules/css-select/lib/compile.js
generated
vendored
Normal file
151
node_modules/css-select/lib/compile.js
generated
vendored
Normal file
|
@ -0,0 +1,151 @@
|
|||
"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 = __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.
|
||||
*
|
||||
* @param selector Selector to compile.
|
||||
* @param options Compilation options.
|
||||
* @param context Optional context for the selector.
|
||||
*/
|
||||
function compile(selector, options, context) {
|
||||
var next = compileUnsafe(selector, options, context);
|
||||
return (0, subselects_js_1.ensureIsTag)(next, options.adapter);
|
||||
}
|
||||
exports.compile = compile;
|
||||
function compileUnsafe(selector, options, context) {
|
||||
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 === 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: css_what_1.SelectorType.Descendant };
|
||||
var FLEXIBLE_DESCENDANT_TOKEN = {
|
||||
type: "_flexibleDescendant",
|
||||
};
|
||||
var SCOPE_TOKEN = {
|
||||
type: css_what_1.SelectorType.Pseudo,
|
||||
name: "scope",
|
||||
data: null,
|
||||
};
|
||||
/*
|
||||
* CSS 4 Spec (Draft): 3.4.1. Absolutizing a Relative Selector
|
||||
* http://www.w3.org/TR/selectors4/#absolutizing
|
||||
*/
|
||||
function absolutize(token, _a, context) {
|
||||
var adapter = _a.adapter;
|
||||
// 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_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 &&
|
||||
(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)) {
|
||||
t.unshift(DESCENDANT_TOKEN);
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
t.unshift(SCOPE_TOKEN);
|
||||
}
|
||||
}
|
||||
function compileToken(token, options, context) {
|
||||
var _a;
|
||||
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 !== css_what_1.SelectorType.Pseudo ||
|
||||
first.name !== "scope") {
|
||||
// Ignore
|
||||
}
|
||||
else if (isArrayContext &&
|
||||
second.type === css_what_1.SelectorType.Descendant) {
|
||||
rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
|
||||
}
|
||||
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.default.falseFunc);
|
||||
query.shouldTestNextSiblings = shouldTestNextSiblings;
|
||||
return query;
|
||||
}
|
||||
exports.compileToken = compileToken;
|
||||
function compileRules(rules, options, context) {
|
||||
var _a;
|
||||
return rules.reduce(function (previous, rule) {
|
||||
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.default.falseFunc || a === boolbase_1.default.trueFunc) {
|
||||
return a;
|
||||
}
|
||||
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
|
148
node_modules/css-select/lib/general.js
generated
vendored
Normal file
148
node_modules/css-select/lib/general.js
generated
vendored
Normal file
|
@ -0,0 +1,148 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileGeneralSelector = void 0;
|
||||
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 css_what_1.SelectorType.PseudoElement: {
|
||||
throw new Error("Pseudo-elements are not supported by css-select");
|
||||
}
|
||||
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 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) === name_1 && next(elem);
|
||||
};
|
||||
}
|
||||
// Traversal
|
||||
case css_what_1.SelectorType.Descendant: {
|
||||
if (options.cacheResults === false ||
|
||||
typeof WeakSet === "undefined") {
|
||||
return function descendant(elem) {
|
||||
var current = elem;
|
||||
while ((current = getElementParent(current, adapter))) {
|
||||
if (next(current)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
// @ts-expect-error `ElementNode` is not extending object
|
||||
var isFalseCache_1 = new WeakSet();
|
||||
return function cachedDescendant(elem) {
|
||||
var current = elem;
|
||||
while ((current = getElementParent(current, adapter))) {
|
||||
if (!isFalseCache_1.has(current)) {
|
||||
if (adapter.isTag(current) && next(current)) {
|
||||
return true;
|
||||
}
|
||||
isFalseCache_1.add(current);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case "_flexibleDescendant": {
|
||||
// Include element itself, only used while querying an array
|
||||
return function flexibleDescendant(elem) {
|
||||
var current = elem;
|
||||
do {
|
||||
if (next(current))
|
||||
return true;
|
||||
} while ((current = getElementParent(current, adapter)));
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case css_what_1.SelectorType.Parent: {
|
||||
return function parent(elem) {
|
||||
return adapter
|
||||
.getChildren(elem)
|
||||
.some(function (elem) { return adapter.isTag(elem) && next(elem); });
|
||||
};
|
||||
}
|
||||
case css_what_1.SelectorType.Child: {
|
||||
return function child(elem) {
|
||||
var parent = adapter.getParent(elem);
|
||||
return parent != null && adapter.isTag(parent) && next(parent);
|
||||
};
|
||||
}
|
||||
case css_what_1.SelectorType.Sibling: {
|
||||
return function sibling(elem) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) && next(currentSibling)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
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;
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling)) {
|
||||
lastElement = currentSibling;
|
||||
}
|
||||
}
|
||||
return !!lastElement && next(lastElement);
|
||||
};
|
||||
}
|
||||
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
|
84
node_modules/css-select/lib/sort.js
generated
vendored
Normal file
84
node_modules/css-select/lib/sort.js
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
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
|
||||
* (some types of selectors are faster than others)
|
||||
*
|
||||
* @param arr Selector to sort
|
||||
*/
|
||||
function sortByProcedure(arr) {
|
||||
var procs = arr.map(getProcedure);
|
||||
for (var i = 1; i < arr.length; i++) {
|
||||
var procNew = procs[i];
|
||||
if (procNew < 0)
|
||||
continue;
|
||||
for (var j = i - 1; j >= 0 && procNew < procs[j]; j--) {
|
||||
var token = arr[j + 1];
|
||||
arr[j + 1] = arr[j];
|
||||
arr[j] = token;
|
||||
procs[j + 1] = procs[j];
|
||||
procs[j] = procNew;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = sortByProcedure;
|
||||
function getProcedure(token) {
|
||||
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;
|
||||
}
|
||||
if (token.ignoreCase) {
|
||||
/*
|
||||
* IgnoreCase adds some overhead, prefer "normal" token
|
||||
* this is a binary operation, to ensure it's still an int
|
||||
*/
|
||||
proc >>= 1;
|
||||
}
|
||||
}
|
||||
else if (token.type === css_what_1.SelectorType.Pseudo) {
|
||||
if (!token.data) {
|
||||
proc = 3;
|
||||
}
|
||||
else if (token.name === "has" || token.name === "contains") {
|
||||
proc = 0; // Expensive in any case
|
||||
}
|
||||
else if (Array.isArray(token.data)) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
proc = 2;
|
||||
}
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
//# sourceMappingURL=sort.js.map
|
81
node_modules/css-select/package.json
generated
vendored
Normal file
81
node_modules/css-select/package.json
generated
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"name": "css-select",
|
||||
"version": "5.1.0",
|
||||
"description": "a CSS selector compiler/engine",
|
||||
"author": "Felix Boehm <me@feedic.com>",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
},
|
||||
"keywords": [
|
||||
"css",
|
||||
"selector",
|
||||
"sizzle"
|
||||
],
|
||||
"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": {
|
||||
"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",
|
||||
"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}'",
|
||||
"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"
|
||||
},
|
||||
"license": "BSD-2-Clause",
|
||||
"prettier": {
|
||||
"tabWidth": 4,
|
||||
"proseWrap": "always"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node",
|
||||
"coverageProvider": "v8",
|
||||
"moduleNameMapper": {
|
||||
"^(.*)\\.js$": "$1"
|
||||
},
|
||||
"testMatch": [
|
||||
"<rootDir>/test/*.ts"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue