progress on migrating to heex templates and font-icons

This commit is contained in:
Adam Piontek 2022-08-13 07:32:36 -04:00
parent d43daafdb7
commit 3eff955672
21793 changed files with 2161968 additions and 16895 deletions

11
assets_old/node_modules/css-select/LICENSE generated vendored Normal file
View 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.

221
assets_old/node_modules/css-select/README.md generated vendored Normal file
View file

@ -0,0 +1,221 @@
# css-select [![NPM version](http://img.shields.io/npm/v/css-select.svg)](https://npmjs.org/package/css-select) [![Build Status](https://travis-ci.org/fb55/css-select.svg?branch=master)](http://travis-ci.org/fb55/css-select) [![Downloads](https://img.shields.io/npm/dm/css-select.svg)](https://npmjs.org/package/css-select) [![Coverage](https://coveralls.io/repos/fb55/css-select/badge.svg?branch=master)](https://coveralls.io/r/fb55/css-select)
a CSS selector compiler/engine
## What?
css-select turns CSS selectors into functions that tests if elements match them. When searching for elements, testing is executed "from the top", similar to how browsers execute CSS selectors.
In its default configuration, css-select queries the DOM structure of the [`domhandler`](https://github.com/fb55/domhandler) module (also known as htmlparser2 DOM).
It uses [`domutils`](https://github.com/fb55/domutils) as its default adapter over the DOM structure. See Options below for details on querying alternative DOM structures.
__Features:__
- Full implementation of CSS3 selectors
- Partial implementation of jQuery/Sizzle extensions
- Very high test coverage
- Pretty good performance
## Why?
The traditional approach of executing CSS selectors, named left-to-right execution, is to execute every component of the selector in order, from left to right _(duh)_. The execution of the selector `a b` for example will first query for `a` elements, then search these for `b` elements. (That's the approach of eg. [`Sizzle`](https://github.com/jquery/sizzle), [`nwmatcher`](https://github.com/dperini/nwmatcher/) and [`qwery`](https://github.com/ded/qwery).)
While this works, it has some downsides: Children of `a`s will be checked multiple times; first, to check if they are also `a`s, then, for every superior `a` once, if they are `b`s. Using [Big O notation](http://en.wikipedia.org/wiki/Big_O_notation), that would be `O(n^(k+1))`, where `k` is the number of descendant selectors (that's the space in the example above).
The far more efficient approach is to first look for `b` elements, then check if they have superior `a` elements: Using big O notation again, that would be `O(n)`. That's called right-to-left execution.
And that's what css-select does and why it's quite performant.
## How does it work?
By building a stack of functions.
_Wait, what?_
Okay, so let's suppose we want to compile the selector `a b` again, for right-to-left execution. We start by _parsing_ the selector, which means we turn the selector into an array of the building-blocks of the selector, so we can distinguish them easily. That's what the [`css-what`](https://github.com/fb55/css-what) module is for, if you want to have a look.
Anyway, after parsing, we end up with an array like this one:
```js
[
{ type: 'tag', name: 'a' },
{ type: 'descendant' },
{ type: 'tag', name: 'b' }
]
```
Actually, this array is wrapped in another array, but that's another story (involving commas in selectors).
Now that we know the meaning of every part of the selector, we can compile it. That's where it becomes interesting.
The basic idea is to turn every part of the selector into a function, which takes an element as its only argument. The function checks whether a passed element matches its part of the selector: If it does, the element is passed to the next turned-into-a-function part of the selector, which does the same. If an element is accepted by all parts of the selector, it _matches_ the selector and double rainbow ALL THE WAY.
As said before, we want to do right-to-left execution with all the big O improvements nonsense, so elements are passed from the rightmost part of the selector (`b` in our example) to the leftmost (~~which would be `c`~~ of course `a`).
_//TODO: More in-depth description. Implementation details. Build a spaceship._
## API
```js
const CSSselect = require("css-select");
```
__Note:__ css-select throws errors when invalid selectors are passed to it, contrary to the behavior in browsers, which swallow them. This is done to aid with writing css selectors, but can be unexpected when processing arbitrary strings.
#### `CSSselect(query, elems, options)`
Queries `elems`, returns an array containing all matches.
- `query` can be either a CSS selector or a function.
- `elems` can be either an array of elements, or a single element. If it is an element, its children will be queried.
- `options` is described below.
Aliases: `CSSselect.selectAll(query, elems)`, `CSSselect.iterate(query, elems)`.
#### `CSSselect.compile(query)`
Compiles the query, returns a function.
#### `CSSselect.is(elem, query, options)`
Tests whether or not an element is matched by `query`. `query` can be either a CSS selector or a function.
#### `CSSselect.selectOne(query, elems, options)`
Arguments are the same as for `CSSselect(query, elems)`. Only returns the first match, or `null` if there was no match.
### Options
- `xmlMode`: When enabled, tag names will be case-sensitive. Default: `false`.
- `strict`: Limits the module to only use CSS3 selectors. Default: `false`.
- `rootFunc`: The last function in the stack, will be called with the last element that's looked at. Should return `true`.
- `adapter`: The adapter to use when interacting with the backing DOM structure. By default it uses [`domutils`](https://github.com/fb55/domutils).
#### Custom Adapters
A custom adapter must implement the following functions:
```
isTag, existsOne, getAttributeValue, getChildren, getName, getParent,
getSiblings, getText, hasAttrib, removeSubsets, findAll, findOne
```
The method signature notation used below should be fairly intuitive - if not,
see the [`rtype`](https://github.com/ericelliott/rtype) or
[`TypeScript`](https://www.typescriptlang.org/) docs, as it is very similar to
both of those. You may also want to look at
-[`domutils`](https://github.com/fb55/domutils) to see the default
-implementation, or at
-[`css-select-browser-adapter`](https://github.com/nrkn/css-select-browser-adapter/blob/master/index.js)
-for an implementation backed by the DOM.
```ts
{
// is the node a tag?
isTag: ( node:Node ) => isTag:Boolean,
// does at least one of passed element nodes pass the test predicate?
existsOne: ( test:Predicate, elems:[ElementNode] ) => existsOne:Boolean,
// get the attribute value
getAttributeValue: ( elem:ElementNode, name:String ) => value:String,
// get the node's children
getChildren: ( node:Node ) => children:[Node],
// get the name of the tag
getName: ( elem:ElementNode ) => tagName:String,
// get the parent of the node
getParent: ( node:Node ) => parentNode:Node,
/*
get the siblings of the node. Note that unlike jQuery's `siblings` method,
this is expected to include the current node as well
*/
getSiblings: ( node:Node ) => siblings:[Node],
// get the text content of the node, and its children if it has any
getText: ( node:Node ) => text:String,
// does the element have the named attribute?
hasAttrib: ( elem:ElementNode, name:String ) => hasAttrib:Boolean,
// takes an array of nodes, and removes any duplicates, as well as any nodes
// whose ancestors are also in the array
removeSubsets: ( nodes:[Node] ) => unique:[Node],
// finds all of the element nodes in the array that match the test predicate,
// as well as any of their children that match it
findAll: ( test:Predicate, nodes:[Node] ) => elems:[ElementNode],
// finds the first node in the array that matches the test predicate, or one
// of its children
findOne: ( test:Predicate, elems:[ElementNode] ) => findOne:ElementNode,
/*
The adapter can also optionally include an equals method, if your DOM
structure needs a custom equality test to compare two objects which refer
to the same underlying node. If not provided, `css-select` will fall back to
`a === b`.
*/
equals: ( a:Node, b:Node ) => Boolean
}
```
## Supported selectors
_As defined by CSS 4 and / or jQuery._
* Universal (`*`)
* Tag (`<tagname>`)
* Descendant (` `)
* Child (`>`)
* Parent (`<`) *
* Sibling (`+`)
* Adjacent (`~`)
* Attribute (`[attr=foo]`), with supported comparisons:
* `[attr]` (existential)
* `=`
* `~=`
* `|=`
* `*=`
* `^=`
* `$=`
* `!=` *
* Also, `i` can be added after the comparison to make the comparison case-insensitive (eg. `[attr=foo i]`) *
* Pseudos:
* `:not`
* `:contains` *
* `:icontains` * (case-insensitive version of `:contains`)
* `:has` *
* `:root`
* `:empty`
* `:parent` *
* `:[first|last]-child[-of-type]`
* `:only-of-type`, `:only-child`
* `:nth-[last-]child[-of-type]`
* `:link`
* `:visited`, `:hover`, `:active` * (these depend on optional Adapter methods, so these will work only if implemented in Adapter)
* `:selected` *, `:checked`
* `:enabled`, `:disabled`
* `:required`, `:optional`
* `:header`, `:button`, `:input`, `:text`, `:checkbox`, `:file`, `:password`, `:reset`, `:radio` etc. *
* `:matches` *
__*__: Not part of CSS3
---
License: BSD-2-Clause
## Security contact information
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
## `css-select` for enterprise
Available as part of the Tidelift Subscription
The maintainers of `css-select` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-css-select?utm_source=npm-css-select&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

219
assets_old/node_modules/css-select/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,219 @@
export = CSSselect;
/**
* Alias for CSSselect.selectAll(query, elems, options).
* @see [CSSselect.compile] for supported selector queries.
*/
declare function CSSselect<Node, ElementNode extends Node>(
query: CSSselect.Query,
elems: Array<ElementNode> | ElementNode,
options?: CSSselect.Options<Node, ElementNode>
): Array<ElementNode>;
declare namespace CSSselect {
type Predicate<Value> = (v: Value) => boolean;
interface Adapter<Node, ElementNode extends Node> {
/**
* is the node a tag?
*/
isTag(node: Node): node is ElementNode;
/**
* Does at least one of passed element nodes pass the test predicate?
*/
existsOne(test: Predicate<ElementNode>, elems: Array<ElementNode>): boolean;
/**
* get the attribute value.
*/
getAttributeValue(elem: ElementNode, name: string): string;
/**
* get the node's children
*/
getChildren(node: Node): Array<Node>;
/**
* get the name of the tag
*/
getName(elem: ElementNode): string;
/**
* get the parent of the node
*/
getParent(node: Node): Node;
/*
Get the siblings of the node. Note that unlike jQuery's `siblings` method,
this is expected to include the current node as well
*/
getSiblings(node: Node): Array<Node>;
/*
* Get the text content of the node, and its children if it has any.
*/
getText(node: Node): string;
/**
* Does the element have the named attribute?
*/
hasAttrib(elem: ElementNode, name: string): boolean;
/**
* takes an array of nodes, and removes any duplicates, as well as any
* nodes whose ancestors are also in the array.
*/
removeSubsets(nodes: Array<Node>): Array<Node>;
/**
* finds all of the element nodes in the array that match the test predicate,
* as well as any of their children that match it.
*/
findAll(test: Predicate<ElementNode>, nodes: Array<Node>): Array<ElementNode>;
/**
* finds the first node in the array that matches the test predicate, or one
* of its children.
*/
findOne(test: Predicate<ElementNode>, elems: Array<ElementNode>): ElementNode | undefined,
/**
The adapter can also optionally include an equals method, if your DOM
structure needs a custom equality test to compare two objects which refer
to the same underlying node. If not provided, `css-select` will fall back to
`a === b`.
*/
equals?: (a: Node, b: Node) => boolean;
/**
* is the element in hovered state?
*/
isHovered?: (elem: ElementNode) => boolean;
/**
* is the element in visited state?
*/
isVisited?: (elem: ElementNode) => boolean;
/**
* is the element in active state?
*/
isActive?: (elem: ElementNode) => boolean;
}
// TODO default types to the domutil/httpparser2 types
interface Options<Node, ElementNode extends Node> {
/**
* When enabled, tag names will be case-sensitive. Default: false.
*/
xmlMode?: boolean;
/**
* Limits the module to only use CSS3 selectors. Default: false.
*/
strict?: boolean;
/**
* The last function in the stack, will be called with the last element
* that's looked at. Should return true.
*/
rootFunc?: (element: ElementNode) => true;
/**
* The adapter to use when interacting with the backing DOM structure. By
* default it uses domutils.
*/
adapter?: Adapter<Node, ElementNode>;
}
type CompiledQuery = (node: any) => boolean;
type Query = string | CompiledQuery;
/**
* Compiles the query, returns a function.
*
* Supported simple selectors:
* * Universal (*)
* * Tag (<tagname>)
* * Attribute ([attr=foo]), with supported comparisons:
* * [attr] (existential)
* * =
* * ~=
* * |=
* * *=
* * ^=
* * $=
* * !=
* * Can be case insensitive (E.g. [attr=foo i])
* * Pseudos:
* * :not
* * :root
* * :empty
* * :[first|last]-child[-of-type]
* * :only-of-type, :only-child
* * :nth-[last-]child[-of-type]
* * :link, :visited (the latter doesn't match any elements)
* * :checked
* * :enabled, :disabled
* * :required, :optional
* * Nonstandard Pseudos (available when strict mode is not enabled):
* * `:contains`
* * `:icontains` (case-insensitive version of :contains)
* * `:has`
* * `:parent`
* * `:selected`
* * `:header, :button, :input, :text, :checkbox, :file, :password, :reset, :radio etc.
* * :matches
*
* Supported Combinators:
*
* * Descendant (` `)
* * Child (`>`)
* * Parent (`<`) (when strict mode is not enabled)
* * Sibling (`~`)
* * Adjacent (`+`)
*/
function compile(query: string): CompiledQuery;
/**
* @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 CSSselect.compile for supported selector queries.
* @returns All matching elements.
*/
function selectAll<Node, ElementNode extends Node>(
query: Query,
elems: Array<ElementNode> | ElementNode,
options?: Options<Node, ElementNode>
): Array<ElementNode>;
/**
* @template Node The generic Node type for the DOM adapter being used.
* @template ElementNode The Node type for elements for the DOM adapter being used.
* @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 CSSselect.compile for supported selector queries.
* @returns the first match, or null if there was no match.
*/
function selectOne<Node, ElementNode extends Node>(
query: Query,
elems: Array<ElementNode> | ElementNode,
options?: Options<Node, ElementNode>
): ElementNode | null;
/**
* 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 CSSselect.compile for supported selector queries.
* @returns
*/
function is<Node, ElementNode extends Node>(
elem: ElementNode,
query: Query,
options?: Options<Node, ElementNode>
): boolean;
}

94
assets_old/node_modules/css-select/index.js generated vendored Normal file
View file

@ -0,0 +1,94 @@
"use strict";
module.exports = CSSselect;
var DomUtils = require("domutils");
var falseFunc = require("boolbase").falseFunc;
var compileRaw = require("./lib/compile.js");
function wrapCompile(func) {
return function addAdapter(selector, options, context) {
options = options || {};
options.adapter = options.adapter || DomUtils;
return func(selector, options, context);
};
}
var compile = wrapCompile(compileRaw);
var compileUnsafe = wrapCompile(compileRaw.compileUnsafe);
function getSelectorFunc(searchFunc) {
return function select(query, elems, options) {
options = options || {};
options.adapter = options.adapter || DomUtils;
if (typeof query !== "function") {
query = compileUnsafe(query, options, elems);
}
if (query.shouldTestNextSiblings) {
elems = appendNextSiblings((options && options.context) || elems, options.adapter);
}
if (!Array.isArray(elems)) elems = options.adapter.getChildren(elems);
else elems = options.adapter.removeSubsets(elems);
return searchFunc(query, elems, options);
};
}
function getNextSiblings(elem, adapter) {
var siblings = adapter.getSiblings(elem);
if (!Array.isArray(siblings)) return [];
siblings = siblings.slice(0);
while (siblings.shift() !== elem);
return siblings;
}
function appendNextSiblings(elems, adapter) {
// Order matters because jQuery seems to check the children before the siblings
if (!Array.isArray(elems)) elems = [elems];
var newElems = elems.slice(0);
for (var i = 0, len = elems.length; i < len; i++) {
var nextSiblings = getNextSiblings(newElems[i], adapter);
newElems.push.apply(newElems, nextSiblings);
}
return newElems;
}
var selectAll = getSelectorFunc(function selectAll(query, elems, options) {
return query === falseFunc || !elems || elems.length === 0 ? [] : options.adapter.findAll(query, elems);
});
var selectOne = getSelectorFunc(function selectOne(query, elems, options) {
return query === falseFunc || !elems || elems.length === 0 ? null : options.adapter.findOne(query, elems);
});
function is(elem, query, options) {
options = options || {};
options.adapter = options.adapter || DomUtils;
return (typeof query === "function" ? query : compile(query, options))(elem);
}
/*
the exported interface
*/
function CSSselect(query, elems, options) {
return selectAll(query, elems, options);
}
CSSselect.compile = compile;
CSSselect.filters = compileRaw.Pseudos.filters;
CSSselect.pseudos = compileRaw.Pseudos.pseudos;
CSSselect.selectAll = selectAll;
CSSselect.selectOne = selectOne;
CSSselect.is = is;
//legacy methods (might be removed)
CSSselect.parse = compile;
CSSselect.iterate = selectAll;
//hooks
CSSselect._compileUnsafe = compileUnsafe;
CSSselect._compileToken = compileRaw.compileToken;

190
assets_old/node_modules/css-select/lib/attributes.js generated vendored Normal file
View file

@ -0,0 +1,190 @@
var falseFunc = require("boolbase").falseFunc;
//https://github.com/slevithan/XRegExp/blob/master/src/xregexp.js#L469
var reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
/*
attribute selectors
*/
var attributeRules = {
__proto__: null,
equals: function(next, data, options) {
var name = data.name;
var value = data.value;
var adapter = options.adapter;
if (data.ignoreCase) {
value = value.toLowerCase();
return function equalsIC(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && attr.toLowerCase() === value && next(elem);
};
}
return function equals(elem) {
return adapter.getAttributeValue(elem, name) === value && next(elem);
};
},
hyphen: function(next, data, options) {
var name = data.name;
var value = data.value;
var len = value.length;
var adapter = options.adapter;
if (data.ignoreCase) {
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.substr(0, len) === value &&
(attr.length === len || attr.charAt(len) === "-") &&
next(elem)
);
};
},
element: function(next, data, options) {
var name = data.name;
var value = data.value;
var adapter = options.adapter;
if (/\s/.test(value)) {
return falseFunc;
}
value = value.replace(reChars, "\\$&");
var pattern = "(?:^|\\s)" + value + "(?:$|\\s)",
flags = data.ignoreCase ? "i" : "",
regex = new RegExp(pattern, flags);
return function element(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && regex.test(attr) && next(elem);
};
},
exists: function(next, data, options) {
var name = data.name;
var adapter = options.adapter;
return function exists(elem) {
return adapter.hasAttrib(elem, name) && next(elem);
};
},
start: function(next, data, options) {
var name = data.name;
var value = data.value;
var len = value.length;
var adapter = options.adapter;
if (len === 0) {
return falseFunc;
}
if (data.ignoreCase) {
value = value.toLowerCase();
return function startIC(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && attr.substr(0, len).toLowerCase() === value && next(elem);
};
}
return function start(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && attr.substr(0, len) === value && next(elem);
};
},
end: function(next, data, options) {
var name = data.name;
var value = data.value;
var len = -value.length;
var adapter = options.adapter;
if (len === 0) {
return falseFunc;
}
if (data.ignoreCase) {
value = value.toLowerCase();
return function endIC(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && attr.substr(len).toLowerCase() === value && next(elem);
};
}
return function end(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && attr.substr(len) === value && next(elem);
};
},
any: function(next, data, options) {
var name = data.name;
var value = data.value;
var adapter = options.adapter;
if (value === "") {
return falseFunc;
}
if (data.ignoreCase) {
var regex = new RegExp(value.replace(reChars, "\\$&"), "i");
return function anyIC(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && regex.test(attr) && next(elem);
};
}
return function any(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && attr.indexOf(value) >= 0 && next(elem);
};
},
not: function(next, data, options) {
var name = data.name;
var value = data.value;
var adapter = options.adapter;
if (value === "") {
return function notEmpty(elem) {
return !!adapter.getAttributeValue(elem, name) && next(elem);
};
} else if (data.ignoreCase) {
value = value.toLowerCase();
return function notIC(elem) {
var attr = adapter.getAttributeValue(elem, name);
return attr != null && attr.toLowerCase() !== value && next(elem);
};
}
return function not(elem) {
return adapter.getAttributeValue(elem, name) !== value && next(elem);
};
}
};
module.exports = {
compile: function(next, data, options) {
if (options && options.strict && (data.ignoreCase || data.action === "not")) {
throw new Error("Unsupported attribute selector");
}
return attributeRules[data.action](next, data, options);
},
rules: attributeRules
};

219
assets_old/node_modules/css-select/lib/compile.js generated vendored Normal file
View file

@ -0,0 +1,219 @@
/*
compiles a selector to an executable function
*/
module.exports = compile;
var parse = require("css-what").parse;
var BaseFuncs = require("boolbase");
var sortRules = require("./sort.js");
var procedure = require("./procedure.json");
var Rules = require("./general.js");
var Pseudos = require("./pseudos.js");
var trueFunc = BaseFuncs.trueFunc;
var falseFunc = BaseFuncs.falseFunc;
var filters = Pseudos.filters;
function compile(selector, options, context) {
var next = compileUnsafe(selector, options, context);
return wrap(next, options);
}
function wrap(next, options) {
var adapter = options.adapter;
return function base(elem) {
return adapter.isTag(elem) && next(elem);
};
}
function compileUnsafe(selector, options, context) {
var token = parse(selector, options);
return compileToken(token, options, context);
}
function includesScopePseudo(t) {
return (
t.type === "pseudo" &&
(t.name === "scope" ||
(Array.isArray(t.data) &&
t.data.some(function(data) {
return data.some(includesScopePseudo);
})))
);
}
var DESCENDANT_TOKEN = { type: "descendant" };
var FLEXIBLE_DESCENDANT_TOKEN = { type: "_flexibleDescendant" };
var SCOPE_TOKEN = { type: "pseudo", name: "scope" };
var PLACEHOLDER_ELEMENT = {};
//CSS 4 Spec (Draft): 3.3.1. Absolutizing a Scope-relative Selector
//http://www.w3.org/TR/selectors4/#absolutizing
function absolutize(token, options, context) {
var adapter = options.adapter;
//TODO better check if context is document
var hasContext =
!!context &&
!!context.length &&
context.every(function(e) {
return e === PLACEHOLDER_ELEMENT || !!adapter.getParent(e);
});
token.forEach(function(t) {
if (t.length > 0 && isTraversal(t[0]) && t[0].type !== "descendant") {
//don't return in else branch
} else if (hasContext && !(Array.isArray(t) ? t.some(includesScopePseudo) : includesScopePseudo(t))) {
t.unshift(DESCENDANT_TOKEN);
} else {
return;
}
t.unshift(SCOPE_TOKEN);
});
}
function compileToken(token, options, context) {
token = token.filter(function(t) {
return t.length > 0;
});
token.forEach(sortRules);
var isArrayContext = Array.isArray(context);
context = (options && options.context) || context;
if (context && !isArrayContext) context = [context];
absolutize(token, options, context);
var shouldTestNextSiblings = false;
var query = token
.map(function(rules) {
if (rules[0] && rules[1] && rules[0].name === "scope") {
var ruleType = rules[1].type;
if (isArrayContext && ruleType === "descendant") {
rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
} else if (ruleType === "adjacent" || ruleType === "sibling") {
shouldTestNextSiblings = true;
}
}
return compileRules(rules, options, context);
})
.reduce(reduceRules, falseFunc);
query.shouldTestNextSiblings = shouldTestNextSiblings;
return query;
}
function isTraversal(t) {
return procedure[t.type] < 0;
}
function compileRules(rules, options, context) {
return rules.reduce(function(func, rule) {
if (func === falseFunc) return func;
if (!(rule.type in Rules)) {
throw new Error("Rule type " + rule.type + " is not supported by css-select");
}
return Rules[rule.type](func, rule, options, context);
}, (options && options.rootFunc) || trueFunc);
}
function reduceRules(a, b) {
if (b === falseFunc || a === trueFunc) {
return a;
}
if (a === falseFunc || b === trueFunc) {
return b;
}
return function combine(elem) {
return a(elem) || b(elem);
};
}
function containsTraversal(t) {
return t.some(isTraversal);
}
//:not, :has and :matches have to compile selectors
//doing this in lib/pseudos.js would lead to circular dependencies,
//so we add them here
filters.not = function(next, token, options, context) {
var opts = {
xmlMode: !!(options && options.xmlMode),
strict: !!(options && options.strict),
adapter: options.adapter
};
if (opts.strict) {
if (token.length > 1 || token.some(containsTraversal)) {
throw new Error("complex selectors in :not aren't allowed in strict mode");
}
}
var func = compileToken(token, opts, context);
if (func === falseFunc) return next;
if (func === trueFunc) return falseFunc;
return function not(elem) {
return !func(elem) && next(elem);
};
};
filters.has = function(next, token, options) {
var adapter = options.adapter;
var opts = {
xmlMode: !!(options && options.xmlMode),
strict: !!(options && options.strict),
adapter: adapter
};
//FIXME: Uses an array as a pointer to the current element (side effects)
var context = token.some(containsTraversal) ? [PLACEHOLDER_ELEMENT] : null;
var func = compileToken(token, opts, context);
if (func === falseFunc) return falseFunc;
if (func === trueFunc) {
return function hasChild(elem) {
return adapter.getChildren(elem).some(adapter.isTag) && next(elem);
};
}
func = wrap(func, options);
if (context) {
return function has(elem) {
return next(elem) && ((context[0] = elem), adapter.existsOne(func, adapter.getChildren(elem)));
};
}
return function has(elem) {
return next(elem) && adapter.existsOne(func, adapter.getChildren(elem));
};
};
filters.matches = function(next, token, options, context) {
var opts = {
xmlMode: !!(options && options.xmlMode),
strict: !!(options && options.strict),
rootFunc: next,
adapter: options.adapter
};
return compileToken(token, opts, context);
};
compile.compileToken = compileToken;
compile.compileUnsafe = compileUnsafe;
compile.Pseudos = Pseudos;

117
assets_old/node_modules/css-select/lib/general.js generated vendored Normal file
View file

@ -0,0 +1,117 @@
var attributes = require("./attributes.js");
var Pseudos = require("./pseudos");
/*
all available rules
*/
module.exports = {
__proto__: null,
attribute: attributes.compile,
pseudo: Pseudos.compile,
//tags
tag: function(next, data, options) {
var name = data.name;
var adapter = options.adapter;
return function tag(elem) {
return adapter.getName(elem) === name && next(elem);
};
},
//traversal
descendant: function(next, data, options) {
// eslint-disable-next-line no-undef
var isFalseCache = typeof WeakSet !== "undefined" ? new WeakSet() : null;
var adapter = options.adapter;
return function descendant(elem) {
var found = false;
while (!found && (elem = adapter.getParent(elem))) {
if (!isFalseCache || !isFalseCache.has(elem)) {
found = next(elem);
if (!found && isFalseCache) {
isFalseCache.add(elem);
}
}
}
return found;
};
},
_flexibleDescendant: function(next, data, options) {
var adapter = options.adapter;
// Include element itself, only used while querying an array
return function descendant(elem) {
var found = next(elem);
while (!found && (elem = adapter.getParent(elem))) {
found = next(elem);
}
return found;
};
},
parent: function(next, data, options) {
if (options && options.strict) {
throw new Error("Parent selector isn't part of CSS3");
}
var adapter = options.adapter;
return function parent(elem) {
return adapter.getChildren(elem).some(test);
};
function test(elem) {
return adapter.isTag(elem) && next(elem);
}
},
child: function(next, data, options) {
var adapter = options.adapter;
return function child(elem) {
var parent = adapter.getParent(elem);
return !!parent && next(parent);
};
},
sibling: function(next, data, options) {
var adapter = options.adapter;
return function sibling(elem) {
var siblings = adapter.getSiblings(elem);
for (var i = 0; i < siblings.length; i++) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) break;
if (next(siblings[i])) return true;
}
}
return false;
};
},
adjacent: function(next, data, options) {
var adapter = options.adapter;
return function adjacent(elem) {
var siblings = adapter.getSiblings(elem),
lastElement;
for (var i = 0; i < siblings.length; i++) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) break;
lastElement = siblings[i];
}
}
return !!lastElement && next(lastElement);
};
},
universal: function(next) {
return next;
}
};

11
assets_old/node_modules/css-select/lib/procedure.json generated vendored Normal file
View file

@ -0,0 +1,11 @@
{
"universal": 50,
"tag": 30,
"attribute": 1,
"pseudo": 0,
"descendant": -1,
"child": -1,
"parent": -1,
"sibling": -1,
"adjacent": -1
}

453
assets_old/node_modules/css-select/lib/pseudos.js generated vendored Normal file
View file

@ -0,0 +1,453 @@
/*
pseudo selectors
---
they are available in two forms:
* filters called when the selector
is compiled and return a function
that needs to return next()
* pseudos get called on execution
they need to return a boolean
*/
var getNCheck = require("nth-check");
var BaseFuncs = require("boolbase");
var attributes = require("./attributes.js");
var trueFunc = BaseFuncs.trueFunc;
var falseFunc = BaseFuncs.falseFunc;
var checkAttrib = attributes.rules.equals;
function getAttribFunc(name, value) {
var data = { name: name, value: value };
return function attribFunc(next, rule, options) {
return checkAttrib(next, data, options);
};
}
function getChildFunc(next, adapter) {
return function(elem) {
return !!adapter.getParent(elem) && next(elem);
};
}
var filters = {
contains: function(next, text, options) {
var adapter = options.adapter;
return function contains(elem) {
return next(elem) && adapter.getText(elem).indexOf(text) >= 0;
};
},
icontains: function(next, text, options) {
var itext = text.toLowerCase();
var adapter = options.adapter;
return function icontains(elem) {
return (
next(elem) &&
adapter
.getText(elem)
.toLowerCase()
.indexOf(itext) >= 0
);
};
},
//location specific methods
"nth-child": function(next, rule, options) {
var func = getNCheck(rule);
var adapter = options.adapter;
if (func === falseFunc) return func;
if (func === trueFunc) return getChildFunc(next, adapter);
return function nthChild(elem) {
var siblings = adapter.getSiblings(elem);
for (var i = 0, pos = 0; i < siblings.length; i++) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) break;
else pos++;
}
}
return func(pos) && next(elem);
};
},
"nth-last-child": function(next, rule, options) {
var func = getNCheck(rule);
var adapter = options.adapter;
if (func === falseFunc) return func;
if (func === trueFunc) return getChildFunc(next, adapter);
return function nthLastChild(elem) {
var siblings = adapter.getSiblings(elem);
for (var pos = 0, i = siblings.length - 1; i >= 0; i--) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) break;
else pos++;
}
}
return func(pos) && next(elem);
};
},
"nth-of-type": function(next, rule, options) {
var func = getNCheck(rule);
var adapter = options.adapter;
if (func === falseFunc) return func;
if (func === trueFunc) return getChildFunc(next, adapter);
return function nthOfType(elem) {
var siblings = adapter.getSiblings(elem);
for (var pos = 0, i = 0; i < siblings.length; i++) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) break;
if (adapter.getName(siblings[i]) === adapter.getName(elem)) pos++;
}
}
return func(pos) && next(elem);
};
},
"nth-last-of-type": function(next, rule, options) {
var func = getNCheck(rule);
var adapter = options.adapter;
if (func === falseFunc) return func;
if (func === trueFunc) return getChildFunc(next, adapter);
return function nthLastOfType(elem) {
var siblings = adapter.getSiblings(elem);
for (var pos = 0, i = siblings.length - 1; i >= 0; i--) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) break;
if (adapter.getName(siblings[i]) === adapter.getName(elem)) pos++;
}
}
return func(pos) && next(elem);
};
},
//TODO determine the actual root element
root: function(next, rule, options) {
var adapter = options.adapter;
return function(elem) {
return !adapter.getParent(elem) && next(elem);
};
},
scope: function(next, rule, options, context) {
var adapter = options.adapter;
if (!context || context.length === 0) {
//equivalent to :root
return filters.root(next, rule, options);
}
function equals(a, b) {
if (typeof adapter.equals === "function") return adapter.equals(a, b);
return a === b;
}
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.indexOf(elem) >= 0 && next(elem);
};
},
//jQuery extensions (others follow as pseudos)
checkbox: getAttribFunc("type", "checkbox"),
file: getAttribFunc("type", "file"),
password: getAttribFunc("type", "password"),
radio: getAttribFunc("type", "radio"),
reset: getAttribFunc("type", "reset"),
image: getAttribFunc("type", "image"),
submit: getAttribFunc("type", "submit"),
//dynamic state pseudos. These depend on optional Adapter methods.
hover: function(next, rule, options) {
var adapter = options.adapter;
if (typeof adapter.isHovered === 'function') {
return function hover(elem) {
return next(elem) && adapter.isHovered(elem);
};
}
return falseFunc;
},
visited: function(next, rule, options) {
var adapter = options.adapter;
if (typeof adapter.isVisited === 'function') {
return function visited(elem) {
return next(elem) && adapter.isVisited(elem);
};
}
return falseFunc;
},
active: function(next, rule, options) {
var adapter = options.adapter;
if (typeof adapter.isActive === 'function') {
return function active(elem) {
return next(elem) && adapter.isActive(elem);
};
}
return falseFunc;
}
};
//helper methods
function getFirstElement(elems, adapter) {
for (var i = 0; elems && i < elems.length; i++) {
if (adapter.isTag(elems[i])) return elems[i];
}
}
//while filters are precompiled, pseudos get called when they are needed
var pseudos = {
empty: function(elem, adapter) {
return !adapter.getChildren(elem).some(function(elem) {
return adapter.isTag(elem) || elem.type === "text";
});
},
"first-child": function(elem, adapter) {
return getFirstElement(adapter.getSiblings(elem), adapter) === elem;
},
"last-child": function(elem, adapter) {
var siblings = adapter.getSiblings(elem);
for (var i = siblings.length - 1; i >= 0; i--) {
if (siblings[i] === elem) return true;
if (adapter.isTag(siblings[i])) break;
}
return false;
},
"first-of-type": function(elem, adapter) {
var siblings = adapter.getSiblings(elem);
for (var i = 0; i < siblings.length; i++) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) return true;
if (adapter.getName(siblings[i]) === adapter.getName(elem)) break;
}
}
return false;
},
"last-of-type": function(elem, adapter) {
var siblings = adapter.getSiblings(elem);
for (var i = siblings.length - 1; i >= 0; i--) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) return true;
if (adapter.getName(siblings[i]) === adapter.getName(elem)) break;
}
}
return false;
},
"only-of-type": function(elem, adapter) {
var siblings = adapter.getSiblings(elem);
for (var i = 0, j = siblings.length; i < j; i++) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) continue;
if (adapter.getName(siblings[i]) === adapter.getName(elem)) {
return false;
}
}
}
return true;
},
"only-child": function(elem, adapter) {
var siblings = adapter.getSiblings(elem);
for (var i = 0; i < siblings.length; i++) {
if (adapter.isTag(siblings[i]) && siblings[i] !== elem) return false;
}
return true;
},
//:matches(a, area, link)[href]
link: function(elem, adapter) {
return adapter.hasAttrib(elem, "href");
},
//TODO: :any-link once the name is finalized (as an alias of :link)
//forms
//to consider: :target
//:matches([selected], select:not([multiple]):not(> option[selected]) > option:first-of-type)
selected: function(elem, adapter) {
if (adapter.hasAttrib(elem, "selected")) return true;
else if (adapter.getName(elem) !== "option") return false;
//the first <option> in a <select> is also selected
var parent = adapter.getParent(elem);
if (!parent || adapter.getName(parent) !== "select" || adapter.hasAttrib(parent, "multiple")) {
return false;
}
var siblings = adapter.getChildren(parent);
var sawElem = false;
for (var i = 0; i < siblings.length; i++) {
if (adapter.isTag(siblings[i])) {
if (siblings[i] === elem) {
sawElem = true;
} else if (!sawElem) {
return false;
} else if (adapter.hasAttrib(siblings[i], "selected")) {
return false;
}
}
}
return sawElem;
},
//https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements
//:matches(
// :matches(button, input, select, textarea, menuitem, optgroup, option)[disabled],
// optgroup[disabled] > option),
// fieldset[disabled] * //TODO not child of first <legend>
//)
disabled: function(elem, adapter) {
return adapter.hasAttrib(elem, "disabled");
},
enabled: function(elem, adapter) {
return !adapter.hasAttrib(elem, "disabled");
},
//:matches(:matches(:radio, :checkbox)[checked], :selected) (TODO menuitem)
checked: function(elem, adapter) {
return adapter.hasAttrib(elem, "checked") || pseudos.selected(elem, adapter);
},
//:matches(input, select, textarea)[required]
required: function(elem, adapter) {
return adapter.hasAttrib(elem, "required");
},
//:matches(input, select, textarea):not([required])
optional: function(elem, adapter) {
return !adapter.hasAttrib(elem, "required");
},
//jQuery extensions
//:not(:empty)
parent: function(elem, adapter) {
return !pseudos.empty(elem, adapter);
},
//:matches(h1, h2, h3, h4, h5, h6)
header: namePseudo(["h1", "h2", "h3", "h4", "h5", "h6"]),
//:matches(button, input[type=button])
button: function(elem, adapter) {
var name = adapter.getName(elem);
return (
name === "button" || (name === "input" && adapter.getAttributeValue(elem, "type") === "button")
);
},
//:matches(input, textarea, select, button)
input: namePseudo(["input", "textarea", "select", "button"]),
//input:matches(:not([type!='']), [type='text' i])
text: function(elem, adapter) {
var attr;
return (
adapter.getName(elem) === "input" &&
(!(attr = adapter.getAttributeValue(elem, "type")) || attr.toLowerCase() === "text")
);
}
};
function namePseudo(names) {
if (typeof Set !== "undefined") {
// eslint-disable-next-line no-undef
var nameSet = new Set(names);
return function(elem, adapter) {
return nameSet.has(adapter.getName(elem));
};
}
return function(elem, adapter) {
return names.indexOf(adapter.getName(elem)) >= 0;
};
}
function verifyArgs(func, name, subselect) {
if (subselect === null) {
if (func.length > 2 && name !== "scope") {
throw new Error("pseudo-selector :" + name + " requires an argument");
}
} else {
if (func.length === 2) {
throw new Error("pseudo-selector :" + name + " doesn't have any arguments");
}
}
}
//FIXME this feels hacky
var re_CSS3 = /^(?:(?:nth|last|first|only)-(?:child|of-type)|root|empty|(?:en|dis)abled|checked|not)$/;
module.exports = {
compile: function(next, data, options, context) {
var name = data.name;
var subselect = data.data;
var adapter = options.adapter;
if (options && options.strict && !re_CSS3.test(name)) {
throw new Error(":" + name + " isn't part of CSS3");
}
if (typeof filters[name] === "function") {
return filters[name](next, subselect, options, context);
} else if (typeof pseudos[name] === "function") {
var func = pseudos[name];
verifyArgs(func, name, subselect);
if (func === falseFunc) {
return func;
}
if (next === trueFunc) {
return function pseudoRoot(elem) {
return func(elem, adapter, subselect);
};
}
return function pseudoArgs(elem) {
return func(elem, adapter, subselect) && next(elem);
};
} else {
throw new Error("unmatched pseudo-class :" + name);
}
},
filters: filters,
pseudos: pseudos
};

80
assets_old/node_modules/css-select/lib/sort.js generated vendored Normal file
View file

@ -0,0 +1,80 @@
module.exports = sortByProcedure;
/*
sort the parts of the passed selector,
as there is potential for optimization
(some types of selectors are faster than others)
*/
var procedure = require("./procedure.json");
var attributes = {
__proto__: null,
exists: 10,
equals: 8,
not: 7,
start: 6,
end: 6,
any: 5,
hyphen: 4,
element: 4
};
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;
}
}
}
function getProcedure(token) {
var proc = procedure[token.type];
if (proc === procedure.attribute) {
proc = attributes[token.action];
if (proc === attributes.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 (proc === procedure.pseudo) {
if (!token.data) {
proc = 3;
} else if (token.name === "has" || token.name === "contains") {
proc = 0; //expensive in any case
} else if (token.name === "matches" || token.name === "not") {
proc = 0;
for (var i = 0; i < token.data.length; i++) {
//TODO better handling of complex selectors
if (token.data[i].length !== 1) continue;
var cur = getProcedure(token.data[i][0]);
//avoid executing :has or :contains
if (cur === 0) {
proc = 0;
break;
}
if (cur > proc) proc = cur;
}
if (token.data.length > 1 && proc > 0) proc -= 1;
} else {
proc = 1;
}
}
return proc;
}

47
assets_old/node_modules/css-select/package.json generated vendored Normal file
View file

@ -0,0 +1,47 @@
{
"name": "css-select",
"version": "2.1.0",
"description": "a CSS selector compiler/engine",
"author": "Felix Boehm <me@feedic.com>",
"keywords": [
"css",
"selector",
"sizzle"
],
"repository": {
"type": "git",
"url": "git://github.com/fb55/css-select.git"
},
"files": [
"index.js",
"index.d.ts",
"lib"
],
"dependencies": {
"boolbase": "^1.0.0",
"css-what": "^3.2.1",
"domutils": "^1.7.0",
"nth-check": "^1.0.2"
},
"devDependencies": {
"cheerio-soupselect": "^0.1.1",
"coveralls": "^3.0.2",
"eslint": "^6.0.0",
"expect.js": "^0.3.1",
"htmlparser2": "^4.0.0",
"istanbul": "^0.4.5",
"mocha": "^6.0.0",
"mocha-lcov-reporter": "^1.3.0"
},
"scripts": {
"test": "mocha && npm run lint",
"lint": "eslint index.js lib/*.js test/*.js",
"lcov": "istanbul cover _mocha --report lcovonly -- -R spec",
"coveralls": "npm run lint && npm run lcov && (cat coverage/lcov.info | coveralls || exit 0)"
},
"license": "BSD-2-Clause",
"types": "index.d.ts",
"prettier": {
"tabWidth": 4
}
}