mirror of
https://github.com/a-sync/game-server-watcher.git
synced 2026-08-04 19:25:08 -04:00
include prod deps in vcs with some exceptions
* cloudno.de has problems installing new dependencies lately..
This commit is contained in:
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.
|
||||
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
|
||||
222
node_modules/css-select/lib/esm/attributes.js
generated
vendored
Normal file
222
node_modules/css-select/lib/esm/attributes.js
generated
vendored
Normal file
@@ -0,0 +1,222 @@
|
||||
import boolbase from "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
|
||||
*/
|
||||
const 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
|
||||
*/
|
||||
const 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
|
||||
*/
|
||||
export const attributeRules = {
|
||||
equals(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return (elem) => {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length === value.length &&
|
||||
attr.toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return (elem) => adapter.getAttributeValue(elem, name) === value && next(elem);
|
||||
},
|
||||
hyphen(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
const len = value.length;
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function hyphenIC(elem) {
|
||||
const 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) {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
(attr.length === len || attr.charAt(len) === "-") &&
|
||||
attr.substr(0, len) === value &&
|
||||
next(elem));
|
||||
};
|
||||
},
|
||||
element(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name, value } = data;
|
||||
if (/\s/.test(value)) {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
const regex = new RegExp(`(?:^|\\s)${escapeRegex(value)}(?:$|\\s)`, shouldIgnoreCase(data, options) ? "i" : "");
|
||||
return function element(elem) {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= value.length &&
|
||||
regex.test(attr) &&
|
||||
next(elem));
|
||||
};
|
||||
},
|
||||
exists(next, { name }, { adapter }) {
|
||||
return (elem) => adapter.hasAttrib(elem, name) && next(elem);
|
||||
},
|
||||
start(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
const len = value.length;
|
||||
if (len === 0) {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return (elem) => {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= len &&
|
||||
attr.substr(0, len).toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return (elem) => {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
end(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
const len = -value.length;
|
||||
if (len === 0) {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return (elem) => {
|
||||
var _a;
|
||||
return ((_a = adapter
|
||||
.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem);
|
||||
};
|
||||
}
|
||||
return (elem) => {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
any(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name, value } = data;
|
||||
if (value === "") {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
const regex = new RegExp(escapeRegex(value), "i");
|
||||
return function anyIC(elem) {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= value.length &&
|
||||
regex.test(attr) &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return (elem) => {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
not(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
if (value === "") {
|
||||
return (elem) => !!adapter.getAttributeValue(elem, name) && next(elem);
|
||||
}
|
||||
else if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return (elem) => {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return ((attr == null ||
|
||||
attr.length !== value.length ||
|
||||
attr.toLowerCase() !== value) &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return (elem) => adapter.getAttributeValue(elem, name) !== value && next(elem);
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=attributes.js.map
|
||||
115
node_modules/css-select/lib/esm/compile.js
generated
vendored
Normal file
115
node_modules/css-select/lib/esm/compile.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import { parse, SelectorType } from "css-what";
|
||||
import boolbase from "boolbase";
|
||||
import sortRules, { isTraversal } from "./sort.js";
|
||||
import { compileGeneralSelector } from "./general.js";
|
||||
import { ensureIsTag, PLACEHOLDER_ELEMENT, } from "./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.
|
||||
*/
|
||||
export function compile(selector, options, context) {
|
||||
const next = compileUnsafe(selector, options, context);
|
||||
return ensureIsTag(next, options.adapter);
|
||||
}
|
||||
export function compileUnsafe(selector, options, context) {
|
||||
const token = typeof selector === "string" ? parse(selector) : selector;
|
||||
return compileToken(token, options, context);
|
||||
}
|
||||
function includesScopePseudo(t) {
|
||||
return (t.type === SelectorType.Pseudo &&
|
||||
(t.name === "scope" ||
|
||||
(Array.isArray(t.data) &&
|
||||
t.data.some((data) => data.some(includesScopePseudo)))));
|
||||
}
|
||||
const DESCENDANT_TOKEN = { type: SelectorType.Descendant };
|
||||
const FLEXIBLE_DESCENDANT_TOKEN = {
|
||||
type: "_flexibleDescendant",
|
||||
};
|
||||
const SCOPE_TOKEN = {
|
||||
type: 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, { adapter }, context) {
|
||||
// TODO Use better check if the context is a document
|
||||
const hasContext = !!(context === null || context === void 0 ? void 0 : context.every((e) => {
|
||||
const parent = adapter.isTag(e) && adapter.getParent(e);
|
||||
return e === PLACEHOLDER_ELEMENT || (parent && adapter.isTag(parent));
|
||||
}));
|
||||
for (const t of token) {
|
||||
if (t.length > 0 &&
|
||||
isTraversal(t[0]) &&
|
||||
t[0].type !== SelectorType.Descendant) {
|
||||
// Don't continue in else branch
|
||||
}
|
||||
else if (hasContext && !t.some(includesScopePseudo)) {
|
||||
t.unshift(DESCENDANT_TOKEN);
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
t.unshift(SCOPE_TOKEN);
|
||||
}
|
||||
}
|
||||
export function compileToken(token, options, context) {
|
||||
var _a;
|
||||
token.forEach(sortRules);
|
||||
context = (_a = options.context) !== null && _a !== void 0 ? _a : context;
|
||||
const isArrayContext = Array.isArray(context);
|
||||
const 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((t) => t.length > 0 && isTraversal(t[0]))) {
|
||||
throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");
|
||||
}
|
||||
let shouldTestNextSiblings = false;
|
||||
const query = token
|
||||
.map((rules) => {
|
||||
if (rules.length >= 2) {
|
||||
const [first, second] = rules;
|
||||
if (first.type !== SelectorType.Pseudo ||
|
||||
first.name !== "scope") {
|
||||
// Ignore
|
||||
}
|
||||
else if (isArrayContext &&
|
||||
second.type === SelectorType.Descendant) {
|
||||
rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
|
||||
}
|
||||
else if (second.type === SelectorType.Adjacent ||
|
||||
second.type === SelectorType.Sibling) {
|
||||
shouldTestNextSiblings = true;
|
||||
}
|
||||
}
|
||||
return compileRules(rules, options, finalContext);
|
||||
})
|
||||
.reduce(reduceRules, boolbase.falseFunc);
|
||||
query.shouldTestNextSiblings = shouldTestNextSiblings;
|
||||
return query;
|
||||
}
|
||||
function compileRules(rules, options, context) {
|
||||
var _a;
|
||||
return rules.reduce((previous, rule) => previous === boolbase.falseFunc
|
||||
? boolbase.falseFunc
|
||||
: compileGeneralSelector(previous, rule, options, context, compileToken), (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase.trueFunc);
|
||||
}
|
||||
function reduceRules(a, b) {
|
||||
if (b === boolbase.falseFunc || a === boolbase.trueFunc) {
|
||||
return a;
|
||||
}
|
||||
if (a === boolbase.falseFunc || b === boolbase.trueFunc) {
|
||||
return b;
|
||||
}
|
||||
return function combine(elem) {
|
||||
return a(elem) || b(elem);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=compile.js.map
|
||||
144
node_modules/css-select/lib/esm/general.js
generated
vendored
Normal file
144
node_modules/css-select/lib/esm/general.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
import { attributeRules } from "./attributes.js";
|
||||
import { compilePseudoSelector } from "./pseudo-selectors/index.js";
|
||||
import { SelectorType } from "css-what";
|
||||
function getElementParent(node, adapter) {
|
||||
const parent = adapter.getParent(node);
|
||||
if (parent && adapter.isTag(parent)) {
|
||||
return parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* All available rules
|
||||
*/
|
||||
export function compileGeneralSelector(next, selector, options, context, compileToken) {
|
||||
const { adapter, equals } = options;
|
||||
switch (selector.type) {
|
||||
case SelectorType.PseudoElement: {
|
||||
throw new Error("Pseudo-elements are not supported by css-select");
|
||||
}
|
||||
case SelectorType.ColumnCombinator: {
|
||||
throw new Error("Column combinators are not yet supported by css-select");
|
||||
}
|
||||
case 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 attributeRules[selector.action](next, selector, options);
|
||||
}
|
||||
case SelectorType.Pseudo: {
|
||||
return compilePseudoSelector(next, selector, options, context, compileToken);
|
||||
}
|
||||
// Tags
|
||||
case SelectorType.Tag: {
|
||||
if (selector.namespace != null) {
|
||||
throw new Error("Namespaced tag names are not yet supported by css-select");
|
||||
}
|
||||
let { name } = selector;
|
||||
if (!options.xmlMode || options.lowerCaseTags) {
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
return function tag(elem) {
|
||||
return adapter.getName(elem) === name && next(elem);
|
||||
};
|
||||
}
|
||||
// Traversal
|
||||
case SelectorType.Descendant: {
|
||||
if (options.cacheResults === false ||
|
||||
typeof WeakSet === "undefined") {
|
||||
return function descendant(elem) {
|
||||
let current = elem;
|
||||
while ((current = getElementParent(current, adapter))) {
|
||||
if (next(current)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
// @ts-expect-error `ElementNode` is not extending object
|
||||
const isFalseCache = new WeakSet();
|
||||
return function cachedDescendant(elem) {
|
||||
let current = elem;
|
||||
while ((current = getElementParent(current, adapter))) {
|
||||
if (!isFalseCache.has(current)) {
|
||||
if (adapter.isTag(current) && next(current)) {
|
||||
return true;
|
||||
}
|
||||
isFalseCache.add(current);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case "_flexibleDescendant": {
|
||||
// Include element itself, only used while querying an array
|
||||
return function flexibleDescendant(elem) {
|
||||
let current = elem;
|
||||
do {
|
||||
if (next(current))
|
||||
return true;
|
||||
} while ((current = getElementParent(current, adapter)));
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case SelectorType.Parent: {
|
||||
return function parent(elem) {
|
||||
return adapter
|
||||
.getChildren(elem)
|
||||
.some((elem) => adapter.isTag(elem) && next(elem));
|
||||
};
|
||||
}
|
||||
case SelectorType.Child: {
|
||||
return function child(elem) {
|
||||
const parent = adapter.getParent(elem);
|
||||
return parent != null && adapter.isTag(parent) && next(parent);
|
||||
};
|
||||
}
|
||||
case SelectorType.Sibling: {
|
||||
return function sibling(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) && next(currentSibling)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case SelectorType.Adjacent: {
|
||||
if (adapter.prevElementSibling) {
|
||||
return function adjacent(elem) {
|
||||
const previous = adapter.prevElementSibling(elem);
|
||||
return previous != null && next(previous);
|
||||
};
|
||||
}
|
||||
return function adjacent(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let lastElement;
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling)) {
|
||||
lastElement = currentSibling;
|
||||
}
|
||||
}
|
||||
return !!lastElement && next(lastElement);
|
||||
};
|
||||
}
|
||||
case SelectorType.Universal: {
|
||||
if (selector.namespace != null && selector.namespace !== "*") {
|
||||
throw new Error("Namespaced universal selectors are not yet supported by css-select");
|
||||
}
|
||||
return next;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=general.js.map
|
||||
115
node_modules/css-select/lib/esm/index.js
generated
vendored
Normal file
115
node_modules/css-select/lib/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import * as DomUtils from "domutils";
|
||||
import boolbase from "boolbase";
|
||||
import { compile as compileRaw, compileUnsafe, compileToken, } from "./compile.js";
|
||||
import { getNextSiblings } from "./pseudo-selectors/subselects.js";
|
||||
const defaultEquals = (a, b) => a === b;
|
||||
const defaultOptions = {
|
||||
adapter: DomUtils,
|
||||
equals: defaultEquals,
|
||||
};
|
||||
function convertOptionFormats(options) {
|
||||
var _a, _b, _c, _d;
|
||||
/*
|
||||
* We force one format of options to the other one.
|
||||
*/
|
||||
// @ts-expect-error Default options may have incompatible `Node` / `ElementNode`.
|
||||
const opts = options !== null && options !== void 0 ? options : defaultOptions;
|
||||
// @ts-expect-error Same as above.
|
||||
(_a = opts.adapter) !== null && _a !== void 0 ? _a : (opts.adapter = DomUtils);
|
||||
// @ts-expect-error `equals` does not exist on `Options`
|
||||
(_b = opts.equals) !== null && _b !== void 0 ? _b : (opts.equals = (_d = (_c = opts.adapter) === null || _c === void 0 ? void 0 : _c.equals) !== null && _d !== void 0 ? _d : defaultEquals);
|
||||
return opts;
|
||||
}
|
||||
function wrapCompile(func) {
|
||||
return function addAdapter(selector, options, context) {
|
||||
const opts = convertOptionFormats(options);
|
||||
return func(selector, opts, context);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Compiles the query, returns a function.
|
||||
*/
|
||||
export const compile = wrapCompile(compileRaw);
|
||||
export const _compileUnsafe = wrapCompile(compileUnsafe);
|
||||
export const _compileToken = wrapCompile(compileToken);
|
||||
function getSelectorFunc(searchFunc) {
|
||||
return function select(query, elements, options) {
|
||||
const opts = convertOptionFormats(options);
|
||||
if (typeof query !== "function") {
|
||||
query = compileUnsafe(query, opts, elements);
|
||||
}
|
||||
const filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings);
|
||||
return searchFunc(query, filteredElements, opts);
|
||||
};
|
||||
}
|
||||
export function prepareContext(elems, adapter, shouldTestNextSiblings = false) {
|
||||
/*
|
||||
* Add siblings if the query requires them.
|
||||
* See https://github.com/fb55/css-select/pull/43#issuecomment-225414692
|
||||
*/
|
||||
if (shouldTestNextSiblings) {
|
||||
elems = appendNextSiblings(elems, adapter);
|
||||
}
|
||||
return Array.isArray(elems)
|
||||
? adapter.removeSubsets(elems)
|
||||
: adapter.getChildren(elems);
|
||||
}
|
||||
function appendNextSiblings(elem, adapter) {
|
||||
// Order matters because jQuery seems to check the children before the siblings
|
||||
const elems = Array.isArray(elem) ? elem.slice(0) : [elem];
|
||||
const elemsLength = elems.length;
|
||||
for (let i = 0; i < elemsLength; i++) {
|
||||
const nextSiblings = getNextSiblings(elems[i], adapter);
|
||||
elems.push(...nextSiblings);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
/**
|
||||
* @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.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns All matching elements.
|
||||
*
|
||||
*/
|
||||
export const selectAll = getSelectorFunc((query, elems, options) => query === boolbase.falseFunc || !elems || elems.length === 0
|
||||
? []
|
||||
: options.adapter.findAll(query, elems));
|
||||
/**
|
||||
* @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.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns the first match, or null if there was no match.
|
||||
*/
|
||||
export const selectOne = getSelectorFunc((query, elems, options) => query === boolbase.falseFunc || !elems || elems.length === 0
|
||||
? null
|
||||
: options.adapter.findOne(query, elems));
|
||||
/**
|
||||
* Tests whether or not an element is matched by query.
|
||||
*
|
||||
* @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.
|
||||
* @param elem The element to test if it matches the query.
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns
|
||||
*/
|
||||
export function is(elem, query, options) {
|
||||
const opts = convertOptionFormats(options);
|
||||
return (typeof query === "function" ? query : compileRaw(query, opts))(elem);
|
||||
}
|
||||
/**
|
||||
* Alias for selectAll(query, elems, options).
|
||||
* @see [compile] for supported selector queries.
|
||||
*/
|
||||
export default selectAll;
|
||||
// Export filters, pseudos and aliases to allow users to supply their own.
|
||||
/** @deprecated Use the `pseudos` option instead. */
|
||||
export { filters, pseudos, aliases } from "./pseudo-selectors/index.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/css-select/lib/esm/package.json
generated
vendored
Normal file
1
node_modules/css-select/lib/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
35
node_modules/css-select/lib/esm/pseudo-selectors/aliases.js
generated
vendored
Normal file
35
node_modules/css-select/lib/esm/pseudo-selectors/aliases.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Aliases are pseudos that are expressed as selectors.
|
||||
*/
|
||||
export const aliases = {
|
||||
// Links
|
||||
"any-link": ":is(a, area, link)[href]",
|
||||
link: ":any-link:not(:visited)",
|
||||
// Forms
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements
|
||||
disabled: `:is(
|
||||
:is(button, input, select, textarea, optgroup, option)[disabled],
|
||||
optgroup[disabled] > option,
|
||||
fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
|
||||
)`,
|
||||
enabled: ":not(:disabled)",
|
||||
checked: ":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",
|
||||
required: ":is(input, select, textarea)[required]",
|
||||
optional: ":is(input, select, textarea):not([required])",
|
||||
// JQuery extensions
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
|
||||
selected: "option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",
|
||||
checkbox: "[type=checkbox]",
|
||||
file: "[type=file]",
|
||||
password: "[type=password]",
|
||||
radio: "[type=radio]",
|
||||
reset: "[type=reset]",
|
||||
image: "[type=image]",
|
||||
submit: "[type=submit]",
|
||||
parent: ":not(:empty)",
|
||||
header: ":is(h1, h2, h3, h4, h5, h6)",
|
||||
button: ":is(button, input[type=button])",
|
||||
input: ":is(input, textarea, select, button)",
|
||||
text: "input:is(:not([type!='']), [type=text])",
|
||||
};
|
||||
//# sourceMappingURL=aliases.js.map
|
||||
143
node_modules/css-select/lib/esm/pseudo-selectors/filters.js
generated
vendored
Normal file
143
node_modules/css-select/lib/esm/pseudo-selectors/filters.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
import getNCheck from "nth-check";
|
||||
import boolbase from "boolbase";
|
||||
function getChildFunc(next, adapter) {
|
||||
return (elem) => {
|
||||
const parent = adapter.getParent(elem);
|
||||
return parent != null && adapter.isTag(parent) && next(elem);
|
||||
};
|
||||
}
|
||||
export const filters = {
|
||||
contains(next, text, { adapter }) {
|
||||
return function contains(elem) {
|
||||
return next(elem) && adapter.getText(elem).includes(text);
|
||||
};
|
||||
},
|
||||
icontains(next, text, { adapter }) {
|
||||
const itext = text.toLowerCase();
|
||||
return function icontains(elem) {
|
||||
return (next(elem) &&
|
||||
adapter.getText(elem).toLowerCase().includes(itext));
|
||||
};
|
||||
},
|
||||
// Location specific methods
|
||||
"nth-child"(next, rule, { adapter, equals }) {
|
||||
const func = getNCheck(rule);
|
||||
if (func === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
if (func === boolbase.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthChild(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let pos = 0;
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
if (equals(elem, siblings[i]))
|
||||
break;
|
||||
if (adapter.isTag(siblings[i])) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-last-child"(next, rule, { adapter, equals }) {
|
||||
const func = getNCheck(rule);
|
||||
if (func === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
if (func === boolbase.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthLastChild(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let pos = 0;
|
||||
for (let i = siblings.length - 1; i >= 0; i--) {
|
||||
if (equals(elem, siblings[i]))
|
||||
break;
|
||||
if (adapter.isTag(siblings[i])) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-of-type"(next, rule, { adapter, equals }) {
|
||||
const func = getNCheck(rule);
|
||||
if (func === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
if (func === boolbase.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthOfType(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let pos = 0;
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === adapter.getName(elem)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-last-of-type"(next, rule, { adapter, equals }) {
|
||||
const func = getNCheck(rule);
|
||||
if (func === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
if (func === boolbase.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthLastOfType(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let pos = 0;
|
||||
for (let i = siblings.length - 1; i >= 0; i--) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === adapter.getName(elem)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
// TODO determine the actual root element
|
||||
root(next, _rule, { adapter }) {
|
||||
return (elem) => {
|
||||
const parent = adapter.getParent(elem);
|
||||
return (parent == null || !adapter.isTag(parent)) && next(elem);
|
||||
};
|
||||
},
|
||||
scope(next, rule, options, context) {
|
||||
const { equals } = options;
|
||||
if (!context || context.length === 0) {
|
||||
// Equivalent to :root
|
||||
return filters["root"](next, rule, options);
|
||||
}
|
||||
if (context.length === 1) {
|
||||
// NOTE: can't be unpacked, as :has uses this for side-effects
|
||||
return (elem) => equals(context[0], elem) && next(elem);
|
||||
}
|
||||
return (elem) => context.includes(elem) && next(elem);
|
||||
},
|
||||
hover: dynamicStatePseudo("isHovered"),
|
||||
visited: dynamicStatePseudo("isVisited"),
|
||||
active: dynamicStatePseudo("isActive"),
|
||||
};
|
||||
/**
|
||||
* Dynamic state pseudos. These depend on optional Adapter methods.
|
||||
*
|
||||
* @param name The name of the adapter method to call.
|
||||
* @returns Pseudo for the `filters` object.
|
||||
*/
|
||||
function dynamicStatePseudo(name) {
|
||||
return function dynamicPseudo(next, _rule, { adapter }) {
|
||||
const func = adapter[name];
|
||||
if (typeof func !== "function") {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
return function active(elem) {
|
||||
return func(elem) && next(elem);
|
||||
};
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=filters.js.map
|
||||
40
node_modules/css-select/lib/esm/pseudo-selectors/index.js
generated
vendored
Normal file
40
node_modules/css-select/lib/esm/pseudo-selectors/index.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { parse } from "css-what";
|
||||
import { filters } from "./filters.js";
|
||||
import { pseudos, verifyPseudoArgs } from "./pseudos.js";
|
||||
import { aliases } from "./aliases.js";
|
||||
import { subselects } from "./subselects.js";
|
||||
export { filters, pseudos, aliases };
|
||||
export function compilePseudoSelector(next, selector, options, context, compileToken) {
|
||||
var _a;
|
||||
const { name, data } = selector;
|
||||
if (Array.isArray(data)) {
|
||||
if (!(name in subselects)) {
|
||||
throw new Error(`Unknown pseudo-class :${name}(${data})`);
|
||||
}
|
||||
return subselects[name](next, data, options, context, compileToken);
|
||||
}
|
||||
const userPseudo = (_a = options.pseudos) === null || _a === void 0 ? void 0 : _a[name];
|
||||
const stringPseudo = typeof userPseudo === "string" ? userPseudo : aliases[name];
|
||||
if (typeof stringPseudo === "string") {
|
||||
if (data != null) {
|
||||
throw new Error(`Pseudo ${name} doesn't have any arguments`);
|
||||
}
|
||||
// The alias has to be parsed here, to make sure options are respected.
|
||||
const alias = parse(stringPseudo);
|
||||
return subselects["is"](next, alias, options, context, compileToken);
|
||||
}
|
||||
if (typeof userPseudo === "function") {
|
||||
verifyPseudoArgs(userPseudo, name, data, 1);
|
||||
return (elem) => userPseudo(elem, data) && next(elem);
|
||||
}
|
||||
if (name in filters) {
|
||||
return filters[name](next, data, options, context);
|
||||
}
|
||||
if (name in pseudos) {
|
||||
const pseudo = pseudos[name];
|
||||
verifyPseudoArgs(pseudo, name, data, 2);
|
||||
return (elem) => pseudo(elem, options, data) && next(elem);
|
||||
}
|
||||
throw new Error(`Unknown pseudo-class :${name}`);
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
79
node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js
generated
vendored
Normal file
79
node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
// While filters are precompiled, pseudos get called when they are needed
|
||||
export const pseudos = {
|
||||
empty(elem, { adapter }) {
|
||||
return !adapter.getChildren(elem).some((elem) =>
|
||||
// FIXME: `getText` call is potentially expensive.
|
||||
adapter.isTag(elem) || adapter.getText(elem) !== "");
|
||||
},
|
||||
"first-child"(elem, { adapter, equals }) {
|
||||
if (adapter.prevElementSibling) {
|
||||
return adapter.prevElementSibling(elem) == null;
|
||||
}
|
||||
const firstChild = adapter
|
||||
.getSiblings(elem)
|
||||
.find((elem) => adapter.isTag(elem));
|
||||
return firstChild != null && equals(elem, firstChild);
|
||||
},
|
||||
"last-child"(elem, { adapter, equals }) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
for (let i = siblings.length - 1; i >= 0; i--) {
|
||||
if (equals(elem, siblings[i]))
|
||||
return true;
|
||||
if (adapter.isTag(siblings[i]))
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"first-of-type"(elem, { adapter, equals }) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
const elemName = adapter.getName(elem);
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
return true;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === elemName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"last-of-type"(elem, { adapter, equals }) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
const elemName = adapter.getName(elem);
|
||||
for (let i = siblings.length - 1; i >= 0; i--) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
return true;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === elemName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"only-of-type"(elem, { adapter, equals }) {
|
||||
const elemName = adapter.getName(elem);
|
||||
return adapter
|
||||
.getSiblings(elem)
|
||||
.every((sibling) => equals(elem, sibling) ||
|
||||
!adapter.isTag(sibling) ||
|
||||
adapter.getName(sibling) !== elemName);
|
||||
},
|
||||
"only-child"(elem, { adapter, equals }) {
|
||||
return adapter
|
||||
.getSiblings(elem)
|
||||
.every((sibling) => equals(elem, sibling) || !adapter.isTag(sibling));
|
||||
},
|
||||
};
|
||||
export function verifyPseudoArgs(func, name, subselect, argIndex) {
|
||||
if (subselect === null) {
|
||||
if (func.length > argIndex) {
|
||||
throw new Error(`Pseudo-class :${name} requires an argument`);
|
||||
}
|
||||
}
|
||||
else if (func.length === argIndex) {
|
||||
throw new Error(`Pseudo-class :${name} doesn't have any arguments`);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=pseudos.js.map
|
||||
94
node_modules/css-select/lib/esm/pseudo-selectors/subselects.js
generated
vendored
Normal file
94
node_modules/css-select/lib/esm/pseudo-selectors/subselects.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
import boolbase from "boolbase";
|
||||
import { isTraversal } from "../sort.js";
|
||||
/** Used as a placeholder for :has. Will be replaced with the actual element. */
|
||||
export const PLACEHOLDER_ELEMENT = {};
|
||||
export function ensureIsTag(next, adapter) {
|
||||
if (next === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
return (elem) => adapter.isTag(elem) && next(elem);
|
||||
}
|
||||
export function getNextSiblings(elem, adapter) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
if (siblings.length <= 1)
|
||||
return [];
|
||||
const elemIndex = siblings.indexOf(elem);
|
||||
if (elemIndex < 0 || elemIndex === siblings.length - 1)
|
||||
return [];
|
||||
return siblings.slice(elemIndex + 1).filter(adapter.isTag);
|
||||
}
|
||||
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,
|
||||
};
|
||||
}
|
||||
const is = (next, token, options, context, compileToken) => {
|
||||
const func = compileToken(token, copyOptions(options), context);
|
||||
return func === boolbase.trueFunc
|
||||
? next
|
||||
: func === boolbase.falseFunc
|
||||
? boolbase.falseFunc
|
||||
: (elem) => func(elem) && next(elem);
|
||||
};
|
||||
/*
|
||||
* :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
|
||||
*/
|
||||
export const subselects = {
|
||||
is,
|
||||
/**
|
||||
* `:matches` and `:where` are aliases for `:is`.
|
||||
*/
|
||||
matches: is,
|
||||
where: is,
|
||||
not(next, token, options, context, compileToken) {
|
||||
const func = compileToken(token, copyOptions(options), context);
|
||||
return func === boolbase.falseFunc
|
||||
? next
|
||||
: func === boolbase.trueFunc
|
||||
? boolbase.falseFunc
|
||||
: (elem) => !func(elem) && next(elem);
|
||||
},
|
||||
has(next, subselect, options, _context, compileToken) {
|
||||
const { adapter } = options;
|
||||
const opts = copyOptions(options);
|
||||
opts.relativeSelector = true;
|
||||
const context = subselect.some((s) => s.some(isTraversal))
|
||||
? // Used as a placeholder. Will be replaced with the actual element.
|
||||
[PLACEHOLDER_ELEMENT]
|
||||
: undefined;
|
||||
const compiled = compileToken(subselect, opts, context);
|
||||
if (compiled === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
const hasElement = ensureIsTag(compiled, adapter);
|
||||
// If `compiled` is `trueFunc`, we can skip this.
|
||||
if (context && compiled !== boolbase.trueFunc) {
|
||||
/*
|
||||
* `shouldTestNextSiblings` will only be true if the query starts with
|
||||
* a traversal (sibling or adjacent). That means we will always have a context.
|
||||
*/
|
||||
const { shouldTestNextSiblings = false } = compiled;
|
||||
return (elem) => {
|
||||
if (!next(elem))
|
||||
return false;
|
||||
context[0] = elem;
|
||||
const childs = adapter.getChildren(elem);
|
||||
const nextElements = shouldTestNextSiblings
|
||||
? [...childs, ...getNextSiblings(elem, adapter)]
|
||||
: childs;
|
||||
return adapter.existsOne(hasElement, nextElements);
|
||||
};
|
||||
}
|
||||
return (elem) => next(elem) &&
|
||||
adapter.existsOne(hasElement, adapter.getChildren(elem));
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=subselects.js.map
|
||||
79
node_modules/css-select/lib/esm/sort.js
generated
vendored
Normal file
79
node_modules/css-select/lib/esm/sort.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import { AttributeAction, SelectorType } from "css-what";
|
||||
const procedure = new Map([
|
||||
[SelectorType.Universal, 50],
|
||||
[SelectorType.Tag, 30],
|
||||
[SelectorType.Attribute, 1],
|
||||
[SelectorType.Pseudo, 0],
|
||||
]);
|
||||
export function isTraversal(token) {
|
||||
return !procedure.has(token.type);
|
||||
}
|
||||
const attributes = new Map([
|
||||
[AttributeAction.Exists, 10],
|
||||
[AttributeAction.Equals, 8],
|
||||
[AttributeAction.Not, 7],
|
||||
[AttributeAction.Start, 6],
|
||||
[AttributeAction.End, 6],
|
||||
[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
|
||||
*/
|
||||
export default function sortByProcedure(arr) {
|
||||
const procs = arr.map(getProcedure);
|
||||
for (let i = 1; i < arr.length; i++) {
|
||||
const procNew = procs[i];
|
||||
if (procNew < 0)
|
||||
continue;
|
||||
for (let j = i - 1; j >= 0 && procNew < procs[j]; j--) {
|
||||
const token = arr[j + 1];
|
||||
arr[j + 1] = arr[j];
|
||||
arr[j] = token;
|
||||
procs[j + 1] = procs[j];
|
||||
procs[j] = procNew;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getProcedure(token) {
|
||||
var _a, _b;
|
||||
let proc = (_a = procedure.get(token.type)) !== null && _a !== void 0 ? _a : -1;
|
||||
if (token.type === SelectorType.Attribute) {
|
||||
proc = (_b = attributes.get(token.action)) !== null && _b !== void 0 ? _b : 4;
|
||||
if (token.action === 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 === 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(...token.data.map((d) => Math.min(...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
|
||||
2
node_modules/css-select/lib/esm/types.js
generated
vendored
Normal file
2
node_modules/css-select/lib/esm/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=types.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
|
||||
154
node_modules/css-select/lib/index.js
generated
vendored
Normal file
154
node_modules/css-select/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
"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.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 = __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,
|
||||
equals: defaultEquals,
|
||||
};
|
||||
function convertOptionFormats(options) {
|
||||
var _a, _b, _c, _d;
|
||||
/*
|
||||
* We force one format of options to the other one.
|
||||
*/
|
||||
// @ts-expect-error Default options may have incompatible `Node` / `ElementNode`.
|
||||
var opts = options !== null && options !== void 0 ? options : defaultOptions;
|
||||
// @ts-expect-error Same as above.
|
||||
(_a = opts.adapter) !== null && _a !== void 0 ? _a : (opts.adapter = DomUtils);
|
||||
// @ts-expect-error `equals` does not exist on `Options`
|
||||
(_b = opts.equals) !== null && _b !== void 0 ? _b : (opts.equals = (_d = (_c = opts.adapter) === null || _c === void 0 ? void 0 : _c.equals) !== null && _d !== void 0 ? _d : defaultEquals);
|
||||
return opts;
|
||||
}
|
||||
function wrapCompile(func) {
|
||||
return function addAdapter(selector, options, context) {
|
||||
var opts = convertOptionFormats(options);
|
||||
return func(selector, opts, context);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Compiles the query, returns a function.
|
||||
*/
|
||||
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 = (0, compile_js_1.compileUnsafe)(query, opts, elements);
|
||||
}
|
||||
var filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings);
|
||||
return searchFunc(query, filteredElements, opts);
|
||||
};
|
||||
}
|
||||
function prepareContext(elems, adapter, shouldTestNextSiblings) {
|
||||
if (shouldTestNextSiblings === void 0) { shouldTestNextSiblings = false; }
|
||||
/*
|
||||
* Add siblings if the query requires them.
|
||||
* See https://github.com/fb55/css-select/pull/43#issuecomment-225414692
|
||||
*/
|
||||
if (shouldTestNextSiblings) {
|
||||
elems = appendNextSiblings(elems, adapter);
|
||||
}
|
||||
return Array.isArray(elems)
|
||||
? adapter.removeSubsets(elems)
|
||||
: adapter.getChildren(elems);
|
||||
}
|
||||
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];
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* @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.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns All matching elements.
|
||||
*
|
||||
*/
|
||||
exports.selectAll = getSelectorFunc(function (query, elems, options) {
|
||||
return query === boolbase_1.default.falseFunc || !elems || elems.length === 0
|
||||
? []
|
||||
: options.adapter.findAll(query, elems);
|
||||
});
|
||||
/**
|
||||
* @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.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns the first match, or null if there was no match.
|
||||
*/
|
||||
exports.selectOne = getSelectorFunc(function (query, elems, options) {
|
||||
return query === boolbase_1.default.falseFunc || !elems || elems.length === 0
|
||||
? null
|
||||
: options.adapter.findOne(query, elems);
|
||||
});
|
||||
/**
|
||||
* Tests whether or not an element is matched by query.
|
||||
*
|
||||
* @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.
|
||||
* @param elem The element to test if it matches the query.
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns
|
||||
*/
|
||||
function is(elem, query, options) {
|
||||
var opts = convertOptionFormats(options);
|
||||
return (typeof query === "function" ? query : (0, compile_js_1.compile)(query, opts))(elem);
|
||||
}
|
||||
exports.is = is;
|
||||
/**
|
||||
* Alias for selectAll(query, elems, options).
|
||||
* @see [compile] for supported selector queries.
|
||||
*/
|
||||
exports.default = exports.selectAll;
|
||||
// Export filters, pseudos and aliases to allow users to supply their own.
|
||||
/** @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
|
||||
34
node_modules/css-select/lib/pseudo-selectors/aliases.js
generated
vendored
Normal file
34
node_modules/css-select/lib/pseudo-selectors/aliases.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.aliases = void 0;
|
||||
/**
|
||||
* Aliases are pseudos that are expressed as selectors.
|
||||
*/
|
||||
exports.aliases = {
|
||||
// Links
|
||||
"any-link": ":is(a, area, link)[href]",
|
||||
link: ":any-link:not(:visited)",
|
||||
// Forms
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements
|
||||
disabled: ":is(\n :is(button, input, select, textarea, optgroup, option)[disabled],\n optgroup[disabled] > option,\n fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)\n )",
|
||||
enabled: ":not(:disabled)",
|
||||
checked: ":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",
|
||||
required: ":is(input, select, textarea)[required]",
|
||||
optional: ":is(input, select, textarea):not([required])",
|
||||
// JQuery extensions
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
|
||||
selected: "option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",
|
||||
checkbox: "[type=checkbox]",
|
||||
file: "[type=file]",
|
||||
password: "[type=password]",
|
||||
radio: "[type=radio]",
|
||||
reset: "[type=reset]",
|
||||
image: "[type=image]",
|
||||
submit: "[type=submit]",
|
||||
parent: ":not(:empty)",
|
||||
header: ":is(h1, h2, h3, h4, h5, h6)",
|
||||
button: ":is(button, input[type=button])",
|
||||
input: ":is(input, textarea, select, button)",
|
||||
text: "input:is(:not([type!='']), [type=text])",
|
||||
};
|
||||
//# sourceMappingURL=aliases.js.map
|
||||
157
node_modules/css-select/lib/pseudo-selectors/filters.js
generated
vendored
Normal file
157
node_modules/css-select/lib/pseudo-selectors/filters.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.filters = void 0;
|
||||
var nth_check_1 = __importDefault(require("nth-check"));
|
||||
var boolbase_1 = __importDefault(require("boolbase"));
|
||||
function getChildFunc(next, adapter) {
|
||||
return function (elem) {
|
||||
var parent = adapter.getParent(elem);
|
||||
return parent != null && adapter.isTag(parent) && next(elem);
|
||||
};
|
||||
}
|
||||
exports.filters = {
|
||||
contains: function (next, text, _a) {
|
||||
var adapter = _a.adapter;
|
||||
return function contains(elem) {
|
||||
return next(elem) && adapter.getText(elem).includes(text);
|
||||
};
|
||||
},
|
||||
icontains: function (next, text, _a) {
|
||||
var adapter = _a.adapter;
|
||||
var itext = text.toLowerCase();
|
||||
return function icontains(elem) {
|
||||
return (next(elem) &&
|
||||
adapter.getText(elem).toLowerCase().includes(itext));
|
||||
};
|
||||
},
|
||||
// Location specific methods
|
||||
"nth-child": function (next, rule, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
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);
|
||||
var pos = 0;
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
if (equals(elem, siblings[i]))
|
||||
break;
|
||||
if (adapter.isTag(siblings[i])) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-last-child": function (next, rule, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
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);
|
||||
var pos = 0;
|
||||
for (var i = siblings.length - 1; i >= 0; i--) {
|
||||
if (equals(elem, siblings[i]))
|
||||
break;
|
||||
if (adapter.isTag(siblings[i])) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-of-type": function (next, rule, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
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);
|
||||
var pos = 0;
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === adapter.getName(elem)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-last-of-type": function (next, rule, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
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);
|
||||
var pos = 0;
|
||||
for (var i = siblings.length - 1; i >= 0; i--) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === adapter.getName(elem)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
// TODO determine the actual root element
|
||||
root: function (next, _rule, _a) {
|
||||
var adapter = _a.adapter;
|
||||
return function (elem) {
|
||||
var parent = adapter.getParent(elem);
|
||||
return (parent == null || !adapter.isTag(parent)) && next(elem);
|
||||
};
|
||||
},
|
||||
scope: function (next, rule, options, context) {
|
||||
var equals = options.equals;
|
||||
if (!context || context.length === 0) {
|
||||
// Equivalent to :root
|
||||
return exports.filters["root"](next, rule, options);
|
||||
}
|
||||
if (context.length === 1) {
|
||||
// NOTE: can't be unpacked, as :has uses this for side-effects
|
||||
return function (elem) { return equals(context[0], elem) && next(elem); };
|
||||
}
|
||||
return function (elem) { return context.includes(elem) && next(elem); };
|
||||
},
|
||||
hover: dynamicStatePseudo("isHovered"),
|
||||
visited: dynamicStatePseudo("isVisited"),
|
||||
active: dynamicStatePseudo("isActive"),
|
||||
};
|
||||
/**
|
||||
* Dynamic state pseudos. These depend on optional Adapter methods.
|
||||
*
|
||||
* @param name The name of the adapter method to call.
|
||||
* @returns Pseudo for the `filters` object.
|
||||
*/
|
||||
function dynamicStatePseudo(name) {
|
||||
return function dynamicPseudo(next, _rule, _a) {
|
||||
var adapter = _a.adapter;
|
||||
var func = adapter[name];
|
||||
if (typeof func !== "function") {
|
||||
return boolbase_1.default.falseFunc;
|
||||
}
|
||||
return function active(elem) {
|
||||
return func(elem) && next(elem);
|
||||
};
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=filters.js.map
|
||||
46
node_modules/css-select/lib/pseudo-selectors/index.js
generated
vendored
Normal file
46
node_modules/css-select/lib/pseudo-selectors/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compilePseudoSelector = exports.aliases = exports.pseudos = exports.filters = void 0;
|
||||
var css_what_1 = require("css-what");
|
||||
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)) {
|
||||
if (!(name in subselects_js_1.subselects)) {
|
||||
throw new Error("Unknown pseudo-class :".concat(name, "(").concat(data, ")"));
|
||||
}
|
||||
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 ".concat(name, " doesn't have any arguments"));
|
||||
}
|
||||
// The alias has to be parsed here, to make sure options are respected.
|
||||
var alias = (0, css_what_1.parse)(stringPseudo);
|
||||
return subselects_js_1.subselects["is"](next, alias, options, context, compileToken);
|
||||
}
|
||||
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 filters_js_1.filters) {
|
||||
return filters_js_1.filters[name](next, data, options, context);
|
||||
}
|
||||
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
|
||||
93
node_modules/css-select/lib/pseudo-selectors/pseudos.js
generated
vendored
Normal file
93
node_modules/css-select/lib/pseudo-selectors/pseudos.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.verifyPseudoArgs = exports.pseudos = void 0;
|
||||
// While filters are precompiled, pseudos get called when they are needed
|
||||
exports.pseudos = {
|
||||
empty: function (elem, _a) {
|
||||
var adapter = _a.adapter;
|
||||
return !adapter.getChildren(elem).some(function (elem) {
|
||||
// FIXME: `getText` call is potentially expensive.
|
||||
return adapter.isTag(elem) || adapter.getText(elem) !== "";
|
||||
});
|
||||
},
|
||||
"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); });
|
||||
return firstChild != null && equals(elem, firstChild);
|
||||
},
|
||||
"last-child": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
for (var i = siblings.length - 1; i >= 0; i--) {
|
||||
if (equals(elem, siblings[i]))
|
||||
return true;
|
||||
if (adapter.isTag(siblings[i]))
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"first-of-type": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var elemName = adapter.getName(elem);
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
return true;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === elemName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"last-of-type": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var elemName = adapter.getName(elem);
|
||||
for (var i = siblings.length - 1; i >= 0; i--) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
return true;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === elemName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"only-of-type": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var elemName = adapter.getName(elem);
|
||||
return adapter
|
||||
.getSiblings(elem)
|
||||
.every(function (sibling) {
|
||||
return equals(elem, sibling) ||
|
||||
!adapter.isTag(sibling) ||
|
||||
adapter.getName(sibling) !== elemName;
|
||||
});
|
||||
},
|
||||
"only-child": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
return adapter
|
||||
.getSiblings(elem)
|
||||
.every(function (sibling) { return equals(elem, sibling) || !adapter.isTag(sibling); });
|
||||
},
|
||||
};
|
||||
function verifyPseudoArgs(func, name, subselect, argIndex) {
|
||||
if (subselect === null) {
|
||||
if (func.length > argIndex) {
|
||||
throw new Error("Pseudo-class :".concat(name, " requires an argument"));
|
||||
}
|
||||
}
|
||||
else if (func.length === argIndex) {
|
||||
throw new Error("Pseudo-class :".concat(name, " doesn't have any arguments"));
|
||||
}
|
||||
}
|
||||
exports.verifyPseudoArgs = verifyPseudoArgs;
|
||||
//# sourceMappingURL=pseudos.js.map
|
||||
112
node_modules/css-select/lib/pseudo-selectors/subselects.js
generated
vendored
Normal file
112
node_modules/css-select/lib/pseudo-selectors/subselects.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
"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));
|
||||
};
|
||||
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 = __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.default.falseFunc)
|
||||
return boolbase_1.default.falseFunc;
|
||||
return function (elem) { return adapter.isTag(elem) && next(elem); };
|
||||
}
|
||||
exports.ensureIsTag = ensureIsTag;
|
||||
function getNextSiblings(elem, adapter) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
if (siblings.length <= 1)
|
||||
return [];
|
||||
var elemIndex = siblings.indexOf(elem);
|
||||
if (elemIndex < 0 || elemIndex === siblings.length - 1)
|
||||
return [];
|
||||
return siblings.slice(elemIndex + 1).filter(adapter.isTag);
|
||||
}
|
||||
exports.getNextSiblings = getNextSiblings;
|
||||
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 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, :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` and `:where` are aliases for `:is`.
|
||||
*/
|
||||
matches: is,
|
||||
where: is,
|
||||
not: function (next, token, options, context, compileToken) {
|
||||
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 = 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.default.falseFunc)
|
||||
return boolbase_1.default.falseFunc;
|
||||
var hasElement = ensureIsTag(compiled, adapter);
|
||||
// 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.
|
||||
*/
|
||||
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_1
|
||||
? __spreadArray(__spreadArray([], childs, true), getNextSiblings(elem, adapter), true) : childs;
|
||||
return adapter.existsOne(hasElement, nextElements);
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
return next(elem) &&
|
||||
adapter.existsOne(hasElement, adapter.getChildren(elem));
|
||||
};
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=subselects.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
|
||||
3
node_modules/css-select/lib/types.js
generated
vendored
Normal file
3
node_modules/css-select/lib/types.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=types.js.map
|
||||
116
node_modules/css-select/package.json
generated
vendored
Normal file
116
node_modules/css-select/package.json
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"css-select@5.1.0",
|
||||
"C:\\Users\\Smith\\repos\\game-server-watcher"
|
||||
]
|
||||
],
|
||||
"_from": "css-select@5.1.0",
|
||||
"_id": "css-select@5.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==",
|
||||
"_location": "/css-select",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "css-select@5.1.0",
|
||||
"name": "css-select",
|
||||
"escapedName": "css-select",
|
||||
"rawSpec": "5.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "5.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cheerio-select"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz",
|
||||
"_spec": "5.1.0",
|
||||
"_where": "C:\\Users\\Smith\\repos\\game-server-watcher",
|
||||
"author": {
|
||||
"name": "Felix Boehm",
|
||||
"email": "me@feedic.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/fb55/css-select/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0",
|
||||
"css-what": "^6.1.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"domutils": "^3.0.1",
|
||||
"nth-check": "^2.0.1"
|
||||
},
|
||||
"description": "a CSS selector compiler/engine",
|
||||
"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"
|
||||
},
|
||||
"exports": {
|
||||
"require": "./lib/index.js",
|
||||
"import": "./lib/esm/index.js"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
},
|
||||
"homepage": "https://github.com/fb55/css-select#readme",
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node",
|
||||
"coverageProvider": "v8",
|
||||
"moduleNameMapper": {
|
||||
"^(.*)\\.js$": "$1"
|
||||
},
|
||||
"testMatch": [
|
||||
"<rootDir>/test/*.ts"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"css",
|
||||
"selector",
|
||||
"sizzle"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "lib/index.js",
|
||||
"module": "lib/esm/index.js",
|
||||
"name": "css-select",
|
||||
"prettier": {
|
||||
"tabWidth": 4,
|
||||
"proseWrap": "always"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/fb55/css-select.git"
|
||||
},
|
||||
"scripts": {
|
||||
"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",
|
||||
"format": "npm run format:es && npm run format:prettier",
|
||||
"format:es": "npm run lint:es -- --fix",
|
||||
"format:prettier": "npm run prettier -- --write",
|
||||
"lint": "npm run lint:es && npm run lint:prettier",
|
||||
"lint:es": "eslint src",
|
||||
"lint:prettier": "npm run prettier -- --check",
|
||||
"prepare": "npm run build",
|
||||
"prettier": "prettier '**/*.{ts,md,json,yml}'",
|
||||
"test": "npm run test:jest && npm run lint",
|
||||
"test:jest": "jest"
|
||||
},
|
||||
"types": "lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user