This commit is contained in:
2025-05-09 05:30:08 +02:00
parent 7bb10e7df4
commit 73367bad9e
5322 changed files with 1266973 additions and 313 deletions

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K mC","2340":"D E F A B"},B:{"2":"C L M G N O P","1025":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"0 9 c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"nC LC qC","513":"0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b","545":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB rC"},D:{"2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB","1025":"0 9 eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC"},E:{"1":"A B C L M G TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB sC SC tC","164":"K","4644":"D E F uC vC wC"},F:{"2":"1 2 3 4 5 6 7 8 F B G N O P QB 4C 5C 6C 7C FC kC","545":"C 8C GC","1025":"0 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z"},G:{"1":"GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"SC 9C lC","4260":"AD BD","4644":"E CD DD ED FD"},H:{"2":"WD"},I:{"2":"LC J XD YD ZD aD lC bD cD","1025":"I"},J:{"2":"D","4260":"A"},K:{"2":"A B FC kC","545":"C GC","1025":"H"},L:{"1025":"I"},M:{"1":"EC"},N:{"2340":"A B"},O:{"1025":"HC"},P:{"1025":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1025":"oD"},R:{"1025":"pD"},S:{"1":"rD","4097":"qD"}},B:4,C:"Crisp edges/pixelated images",D:true};

View File

@@ -0,0 +1,412 @@
<table><thead>
<tr>
<th>Linux</th>
<th>OS X</th>
<th>Windows</th>
<th>Coverage</th>
<th>Downloads</th>
</tr>
</thead><tbody><tr>
<td colspan="2" align="center">
<a href="https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml">
<img
src="https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml/badge.svg"
alt="Build Status" /></a>
</td>
<td align="center">
<a href="https://ci.appveyor.com/project/kaelzhang/node-ignore">
<img
src="https://ci.appveyor.com/api/projects/status/github/kaelzhang/node-ignore?branch=master&svg=true"
alt="Windows Build Status" /></a>
</td>
<td align="center">
<a href="https://codecov.io/gh/kaelzhang/node-ignore">
<img
src="https://codecov.io/gh/kaelzhang/node-ignore/branch/master/graph/badge.svg"
alt="Coverage Status" /></a>
</td>
<td align="center">
<a href="https://www.npmjs.org/package/ignore">
<img
src="http://img.shields.io/npm/dm/ignore.svg"
alt="npm module downloads per month" /></a>
</td>
</tr></tbody></table>
# ignore
`ignore` is a manager, filter and parser which implemented in pure JavaScript according to the [.gitignore spec 2.22.1](http://git-scm.com/docs/gitignore).
`ignore` is used by eslint, gitbook and [many others](https://www.npmjs.com/browse/depended/ignore).
Pay **ATTENTION** that [`minimatch`](https://www.npmjs.org/package/minimatch) (which used by `fstream-ignore`) does not follow the gitignore spec.
To filter filenames according to a .gitignore file, I recommend this npm package, `ignore`.
To parse an `.npmignore` file, you should use `minimatch`, because an `.npmignore` file is parsed by npm using `minimatch` and it does not work in the .gitignore way.
### Tested on
`ignore` is fully tested, and has more than **five hundreds** of unit tests.
- Linux + Node: `0.8` - `7.x`
- Windows + Node: `0.10` - `7.x`, node < `0.10` is not tested due to the lack of support of appveyor.
Actually, `ignore` does not rely on any versions of node specially.
Since `4.0.0`, ignore will no longer support `node < 6` by default, to use in node < 6, `require('ignore/legacy')`. For details, see [CHANGELOG](https://github.com/kaelzhang/node-ignore/blob/master/CHANGELOG.md).
## Table Of Main Contents
- [Usage](#usage)
- [`Pathname` Conventions](#pathname-conventions)
- See Also:
- [`glob-gitignore`](https://www.npmjs.com/package/glob-gitignore) matches files using patterns and filters them according to gitignore rules.
- [Upgrade Guide](#upgrade-guide)
## Install
```sh
npm i ignore
```
## Usage
```js
import ignore from 'ignore'
const ig = ignore().add(['.abc/*', '!.abc/d/'])
```
### Filter the given paths
```js
const paths = [
'.abc/a.js', // filtered out
'.abc/d/e.js' // included
]
ig.filter(paths) // ['.abc/d/e.js']
ig.ignores('.abc/a.js') // true
```
### As the filter function
```js
paths.filter(ig.createFilter()); // ['.abc/d/e.js']
```
### Win32 paths will be handled
```js
ig.filter(['.abc\\a.js', '.abc\\d\\e.js'])
// if the code above runs on windows, the result will be
// ['.abc\\d\\e.js']
```
## Why another ignore?
- `ignore` is a standalone module, and is much simpler so that it could easy work with other programs, unlike [isaacs](https://npmjs.org/~isaacs)'s [fstream-ignore](https://npmjs.org/package/fstream-ignore) which must work with the modules of the fstream family.
- `ignore` only contains utility methods to filter paths according to the specified ignore rules, so
- `ignore` never try to find out ignore rules by traversing directories or fetching from git configurations.
- `ignore` don't cares about sub-modules of git projects.
- Exactly according to [gitignore man page](http://git-scm.com/docs/gitignore), fixes some known matching issues of fstream-ignore, such as:
- '`/*.js`' should only match '`a.js`', but not '`abc/a.js`'.
- '`**/foo`' should match '`foo`' anywhere.
- Prevent re-including a file if a parent directory of that file is excluded.
- Handle trailing whitespaces:
- `'a '`(one space) should not match `'a '`(two spaces).
- `'a \ '` matches `'a '`
- All test cases are verified with the result of `git check-ignore`.
# Methods
## .add(pattern: string | Ignore): this
## .add(patterns: Array<string | Ignore>): this
- **pattern** `String | Ignore` An ignore pattern string, or the `Ignore` instance
- **patterns** `Array<String | Ignore>` Array of ignore patterns.
Adds a rule or several rules to the current manager.
Returns `this`
Notice that a line starting with `'#'`(hash) is treated as a comment. Put a backslash (`'\'`) in front of the first hash for patterns that begin with a hash, if you want to ignore a file with a hash at the beginning of the filename.
```js
ignore().add('#abc').ignores('#abc') // false
ignore().add('\\#abc').ignores('#abc') // true
```
`pattern` could either be a line of ignore pattern or a string of multiple ignore patterns, which means we could just `ignore().add()` the content of a ignore file:
```js
ignore()
.add(fs.readFileSync(filenameOfGitignore).toString())
.filter(filenames)
```
`pattern` could also be an `ignore` instance, so that we could easily inherit the rules of another `Ignore` instance.
## <strike>.addIgnoreFile(path)</strike>
REMOVED in `3.x` for now.
To upgrade `ignore@2.x` up to `3.x`, use
```js
import fs from 'fs'
if (fs.existsSync(filename)) {
ignore().add(fs.readFileSync(filename).toString())
}
```
instead.
## .filter(paths: Array&lt;Pathname&gt;): Array&lt;Pathname&gt;
```ts
type Pathname = string
```
Filters the given array of pathnames, and returns the filtered array.
- **paths** `Array.<Pathname>` The array of `pathname`s to be filtered.
### `Pathname` Conventions:
#### 1. `Pathname` should be a `path.relative()`d pathname
`Pathname` should be a string that have been `path.join()`ed, or the return value of `path.relative()` to the current directory,
```js
// WRONG, an error will be thrown
ig.ignores('./abc')
// WRONG, for it will never happen, and an error will be thrown
// If the gitignore rule locates at the root directory,
// `'/abc'` should be changed to `'abc'`.
// ```
// path.relative('/', '/abc') -> 'abc'
// ```
ig.ignores('/abc')
// WRONG, that it is an absolute path on Windows, an error will be thrown
ig.ignores('C:\\abc')
// Right
ig.ignores('abc')
// Right
ig.ignores(path.join('./abc')) // path.join('./abc') -> 'abc'
```
In other words, each `Pathname` here should be a relative path to the directory of the gitignore rules.
Suppose the dir structure is:
```
/path/to/your/repo
|-- a
| |-- a.js
|
|-- .b
|
|-- .c
|-- .DS_store
```
Then the `paths` might be like this:
```js
[
'a/a.js'
'.b',
'.c/.DS_store'
]
```
#### 2. filenames and dirnames
`node-ignore` does NO `fs.stat` during path matching, so for the example below:
```js
// First, we add a ignore pattern to ignore a directory
ig.add('config/')
// `ig` does NOT know if 'config', in the real world,
// is a normal file, directory or something.
ig.ignores('config')
// `ig` treats `config` as a file, so it returns `false`
ig.ignores('config/')
// returns `true`
```
Specially for people who develop some library based on `node-ignore`, it is important to understand that.
Usually, you could use [`glob`](http://npmjs.org/package/glob) with `option.mark = true` to fetch the structure of the current directory:
```js
import glob from 'glob'
glob('**', {
// Adds a / character to directory matches.
mark: true
}, (err, files) => {
if (err) {
return console.error(err)
}
let filtered = ignore().add(patterns).filter(files)
console.log(filtered)
})
```
## .ignores(pathname: Pathname): boolean
> new in 3.2.0
Returns `Boolean` whether `pathname` should be ignored.
```js
ig.ignores('.abc/a.js') // true
```
## .createFilter()
Creates a filter function which could filter an array of paths with `Array.prototype.filter`.
Returns `function(path)` the filter function.
## .test(pathname: Pathname) since 5.0.0
Returns `TestResult`
```ts
interface TestResult {
ignored: boolean
// true if the `pathname` is finally unignored by some negative pattern
unignored: boolean
}
```
- `{ignored: true, unignored: false}`: the `pathname` is ignored
- `{ignored: false, unignored: true}`: the `pathname` is unignored
- `{ignored: false, unignored: false}`: the `pathname` is never matched by any ignore rules.
## static `ignore.isPathValid(pathname): boolean` since 5.0.0
Check whether the `pathname` is an valid `path.relative()`d path according to the [convention](#1-pathname-should-be-a-pathrelatived-pathname).
This method is **NOT** used to check if an ignore pattern is valid.
```js
ignore.isPathValid('./foo') // false
```
## ignore(options)
### `options.ignorecase` since 4.0.0
Similar as the `core.ignorecase` option of [git-config](https://git-scm.com/docs/git-config), `node-ignore` will be case insensitive if `options.ignorecase` is set to `true` (the default value), otherwise case sensitive.
```js
const ig = ignore({
ignorecase: false
})
ig.add('*.png')
ig.ignores('*.PNG') // false
```
### `options.ignoreCase?: boolean` since 5.2.0
Which is alternative to `options.ignoreCase`
### `options.allowRelativePaths?: boolean` since 5.2.0
This option brings backward compatibility with projects which based on `ignore@4.x`. If `options.allowRelativePaths` is `true`, `ignore` will not check whether the given path to be tested is [`path.relative()`d](#pathname-conventions).
However, passing a relative path, such as `'./foo'` or `'../foo'`, to test if it is ignored or not is not a good practise, which might lead to unexpected behavior
```js
ignore({
allowRelativePaths: true
}).ignores('../foo/bar.js') // And it will not throw
```
****
# Upgrade Guide
## Upgrade 4.x -> 5.x
Since `5.0.0`, if an invalid `Pathname` passed into `ig.ignores()`, an error will be thrown, unless `options.allowRelative = true` is passed to the `Ignore` factory.
While `ignore < 5.0.0` did not make sure what the return value was, as well as
```ts
.ignores(pathname: Pathname): boolean
.filter(pathnames: Array<Pathname>): Array<Pathname>
.createFilter(): (pathname: Pathname) => boolean
.test(pathname: Pathname): {ignored: boolean, unignored: boolean}
```
See the convention [here](#1-pathname-should-be-a-pathrelatived-pathname) for details.
If there are invalid pathnames, the conversion and filtration should be done by users.
```js
import {isPathValid} from 'ignore' // introduced in 5.0.0
const paths = [
// invalid
//////////////////
'',
false,
'../foo',
'.',
//////////////////
// valid
'foo'
]
.filter(isValidPath)
ig.filter(paths)
```
## Upgrade 3.x -> 4.x
Since `4.0.0`, `ignore` will no longer support node < 6, to use `ignore` in node < 6:
```js
var ignore = require('ignore/legacy')
```
## Upgrade 2.x -> 3.x
- All `options` of 2.x are unnecessary and removed, so just remove them.
- `ignore()` instance is no longer an [`EventEmitter`](nodejs.org/api/events.html), and all events are unnecessary and removed.
- `.addIgnoreFile()` is removed, see the [.addIgnoreFile](#addignorefilepath) section for details.
****
# Collaborators
- [@whitecolor](https://github.com/whitecolor) *Alex*
- [@SamyPesse](https://github.com/SamyPesse) *Samy Pessé*
- [@azproduction](https://github.com/azproduction) *Mikhail Davydov*
- [@TrySound](https://github.com/TrySound) *Bogdan Chadkin*
- [@JanMattner](https://github.com/JanMattner) *Jan Mattner*
- [@ntwb](https://github.com/ntwb) *Stephen Edgar*
- [@kasperisager](https://github.com/kasperisager) *Kasper Isager*
- [@sandersn](https://github.com/sandersn) *Nathan Shively-Sanders*

View File

@@ -0,0 +1,721 @@
/**
* @fileoverview Object to handle access and retrieval of tokens.
* @author Brandon Mills
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const { isCommentToken } = require("@eslint-community/eslint-utils");
const assert = require("../../../../shared/assert");
const cursors = require("./cursors");
const ForwardTokenCursor = require("./forward-token-cursor");
const PaddedTokenCursor = require("./padded-token-cursor");
const utils = require("./utils");
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
const TOKENS = Symbol("tokens");
const COMMENTS = Symbol("comments");
const INDEX_MAP = Symbol("indexMap");
/**
* Creates the map from locations to indices in `tokens`.
*
* The first/last location of tokens is mapped to the index of the token.
* The first/last location of comments is mapped to the index of the next token of each comment.
* @param {Token[]} tokens The array of tokens.
* @param {Comment[]} comments The array of comments.
* @returns {Object} The map from locations to indices in `tokens`.
* @private
*/
function createIndexMap(tokens, comments) {
const map = Object.create(null);
let tokenIndex = 0;
let commentIndex = 0;
let nextStart;
let range;
while (tokenIndex < tokens.length || commentIndex < comments.length) {
nextStart =
commentIndex < comments.length
? comments[commentIndex].range[0]
: Number.MAX_SAFE_INTEGER;
while (
tokenIndex < tokens.length &&
(range = tokens[tokenIndex].range)[0] < nextStart
) {
map[range[0]] = tokenIndex;
map[range[1] - 1] = tokenIndex;
tokenIndex += 1;
}
nextStart =
tokenIndex < tokens.length
? tokens[tokenIndex].range[0]
: Number.MAX_SAFE_INTEGER;
while (
commentIndex < comments.length &&
(range = comments[commentIndex].range)[0] < nextStart
) {
map[range[0]] = tokenIndex;
map[range[1] - 1] = tokenIndex;
commentIndex += 1;
}
}
return map;
}
/**
* Creates the cursor iterates tokens with options.
* @param {CursorFactory} factory The cursor factory to initialize cursor.
* @param {Token[]} tokens The array of tokens.
* @param {Comment[]} comments The array of comments.
* @param {Object} indexMap The map from locations to indices in `tokens`.
* @param {number} startLoc The start location of the iteration range.
* @param {number} endLoc The end location of the iteration range.
* @param {number|Function|Object} [opts=0] The option object. If this is a number then it's `opts.skip`. If this is a function then it's `opts.filter`.
* @param {boolean} [opts.includeComments=false] The flag to iterate comments as well.
* @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
* @param {number} [opts.skip=0] The count of tokens the cursor skips.
* @returns {Cursor} The created cursor.
* @private
*/
function createCursorWithSkip(
factory,
tokens,
comments,
indexMap,
startLoc,
endLoc,
opts,
) {
let includeComments = false;
let skip = 0;
let filter = null;
if (typeof opts === "number") {
skip = opts | 0;
} else if (typeof opts === "function") {
filter = opts;
} else if (opts) {
includeComments = !!opts.includeComments;
skip = opts.skip | 0;
filter = opts.filter || null;
}
assert(skip >= 0, "options.skip should be zero or a positive integer.");
assert(
!filter || typeof filter === "function",
"options.filter should be a function.",
);
return factory.createCursor(
tokens,
comments,
indexMap,
startLoc,
endLoc,
includeComments,
filter,
skip,
-1,
);
}
/**
* Creates the cursor iterates tokens with options.
* @param {CursorFactory} factory The cursor factory to initialize cursor.
* @param {Token[]} tokens The array of tokens.
* @param {Comment[]} comments The array of comments.
* @param {Object} indexMap The map from locations to indices in `tokens`.
* @param {number} startLoc The start location of the iteration range.
* @param {number} endLoc The end location of the iteration range.
* @param {number|Function|Object} [opts=0] The option object. If this is a number then it's `opts.count`. If this is a function then it's `opts.filter`.
* @param {boolean} [opts.includeComments] The flag to iterate comments as well.
* @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
* @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
* @returns {Cursor} The created cursor.
* @private
*/
function createCursorWithCount(
factory,
tokens,
comments,
indexMap,
startLoc,
endLoc,
opts,
) {
let includeComments = false;
let count = 0;
let countExists = false;
let filter = null;
if (typeof opts === "number") {
count = opts | 0;
countExists = true;
} else if (typeof opts === "function") {
filter = opts;
} else if (opts) {
includeComments = !!opts.includeComments;
count = opts.count | 0;
countExists = typeof opts.count === "number";
filter = opts.filter || null;
}
assert(count >= 0, "options.count should be zero or a positive integer.");
assert(
!filter || typeof filter === "function",
"options.filter should be a function.",
);
return factory.createCursor(
tokens,
comments,
indexMap,
startLoc,
endLoc,
includeComments,
filter,
0,
countExists ? count : -1,
);
}
/**
* Creates the cursor iterates tokens with options.
* This is overload function of the below.
* @param {Token[]} tokens The array of tokens.
* @param {Comment[]} comments The array of comments.
* @param {Object} indexMap The map from locations to indices in `tokens`.
* @param {number} startLoc The start location of the iteration range.
* @param {number} endLoc The end location of the iteration range.
* @param {Function|Object} opts The option object. If this is a function then it's `opts.filter`.
* @param {boolean} [opts.includeComments] The flag to iterate comments as well.
* @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
* @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
* @returns {Cursor} The created cursor.
* @private
*/
/**
* Creates the cursor iterates tokens with options.
* @param {Token[]} tokens The array of tokens.
* @param {Comment[]} comments The array of comments.
* @param {Object} indexMap The map from locations to indices in `tokens`.
* @param {number} startLoc The start location of the iteration range.
* @param {number} endLoc The end location of the iteration range.
* @param {number} [beforeCount=0] The number of tokens before the node to retrieve.
* @param {boolean} [afterCount=0] The number of tokens after the node to retrieve.
* @returns {Cursor} The created cursor.
* @private
*/
function createCursorWithPadding(
tokens,
comments,
indexMap,
startLoc,
endLoc,
beforeCount,
afterCount,
) {
if (
typeof beforeCount === "undefined" &&
typeof afterCount === "undefined"
) {
return new ForwardTokenCursor(
tokens,
comments,
indexMap,
startLoc,
endLoc,
);
}
if (typeof beforeCount === "number" || typeof beforeCount === "undefined") {
return new PaddedTokenCursor(
tokens,
comments,
indexMap,
startLoc,
endLoc,
beforeCount | 0,
afterCount | 0,
);
}
return createCursorWithCount(
cursors.forward,
tokens,
comments,
indexMap,
startLoc,
endLoc,
beforeCount,
);
}
/**
* Gets comment tokens that are adjacent to the current cursor position.
* @param {Cursor} cursor A cursor instance.
* @returns {Array} An array of comment tokens adjacent to the current cursor position.
* @private
*/
function getAdjacentCommentTokensFromCursor(cursor) {
const tokens = [];
let currentToken = cursor.getOneToken();
while (currentToken && isCommentToken(currentToken)) {
tokens.push(currentToken);
currentToken = cursor.getOneToken();
}
return tokens;
}
//------------------------------------------------------------------------------
// Exports
//------------------------------------------------------------------------------
/**
* The token store.
*
* This class provides methods to get tokens by locations as fast as possible.
* The methods are a part of public API, so we should be careful if it changes this class.
*
* People can get tokens in O(1) by the hash map which is mapping from the location of tokens/comments to tokens.
* Also people can get a mix of tokens and comments in O(log k), the k is the number of comments.
* Assuming that comments to be much fewer than tokens, this does not make hash map from token's locations to comments to reduce memory cost.
* This uses binary-searching instead for comments.
*/
module.exports = class TokenStore {
/**
* Initializes this token store.
* @param {Token[]} tokens The array of tokens.
* @param {Comment[]} comments The array of comments.
*/
constructor(tokens, comments) {
this[TOKENS] = tokens;
this[COMMENTS] = comments;
this[INDEX_MAP] = createIndexMap(tokens, comments);
}
//--------------------------------------------------------------------------
// Gets single token.
//--------------------------------------------------------------------------
/**
* Gets the token starting at the specified index.
* @param {number} offset Index of the start of the token's range.
* @param {Object} [options=0] The option object.
* @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
* @returns {Token|null} The token starting at index, or null if no such token.
*/
getTokenByRangeStart(offset, options) {
const includeComments = options && options.includeComments;
const token = cursors.forward
.createBaseCursor(
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
offset,
-1,
includeComments,
)
.getOneToken();
if (token && token.range[0] === offset) {
return token;
}
return null;
}
/**
* Gets the first token of the given node.
* @param {ASTNode} node The AST node.
* @param {number|Function|Object} [options=0] The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
* @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
* @param {Function|null} [options.filter=null] The predicate function to choose tokens.
* @param {number} [options.skip=0] The count of tokens the cursor skips.
* @returns {Token|null} An object representing the token.
*/
getFirstToken(node, options) {
return createCursorWithSkip(
cursors.forward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
node.range[0],
node.range[1],
options,
).getOneToken();
}
/**
* Gets the last token of the given node.
* @param {ASTNode} node The AST node.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
* @returns {Token|null} An object representing the token.
*/
getLastToken(node, options) {
return createCursorWithSkip(
cursors.backward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
node.range[0],
node.range[1],
options,
).getOneToken();
}
/**
* Gets the token that precedes a given node or token.
* @param {ASTNode|Token|Comment} node The AST node or token.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
* @returns {Token|null} An object representing the token.
*/
getTokenBefore(node, options) {
return createCursorWithSkip(
cursors.backward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
-1,
node.range[0],
options,
).getOneToken();
}
/**
* Gets the token that follows a given node or token.
* @param {ASTNode|Token|Comment} node The AST node or token.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
* @returns {Token|null} An object representing the token.
*/
getTokenAfter(node, options) {
return createCursorWithSkip(
cursors.forward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
node.range[1],
-1,
options,
).getOneToken();
}
/**
* Gets the first token between two non-overlapping nodes.
* @param {ASTNode|Token|Comment} left Node before the desired token range.
* @param {ASTNode|Token|Comment} right Node after the desired token range.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
* @returns {Token|null} An object representing the token.
*/
getFirstTokenBetween(left, right, options) {
return createCursorWithSkip(
cursors.forward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
left.range[1],
right.range[0],
options,
).getOneToken();
}
/**
* Gets the last token between two non-overlapping nodes.
* @param {ASTNode|Token|Comment} left Node before the desired token range.
* @param {ASTNode|Token|Comment} right Node after the desired token range.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
* @returns {Token|null} An object representing the token.
*/
getLastTokenBetween(left, right, options) {
return createCursorWithSkip(
cursors.backward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
left.range[1],
right.range[0],
options,
).getOneToken();
}
/**
* Gets the token that precedes a given node or token in the token stream.
* This is defined for backward compatibility. Use `includeComments` option instead.
* TODO: We have a plan to remove this in a future major version.
* @param {ASTNode|Token|Comment} node The AST node or token.
* @param {number} [skip=0] A number of tokens to skip.
* @returns {Token|null} An object representing the token.
* @deprecated
*/
getTokenOrCommentBefore(node, skip) {
return this.getTokenBefore(node, { includeComments: true, skip });
}
/**
* Gets the token that follows a given node or token in the token stream.
* This is defined for backward compatibility. Use `includeComments` option instead.
* TODO: We have a plan to remove this in a future major version.
* @param {ASTNode|Token|Comment} node The AST node or token.
* @param {number} [skip=0] A number of tokens to skip.
* @returns {Token|null} An object representing the token.
* @deprecated
*/
getTokenOrCommentAfter(node, skip) {
return this.getTokenAfter(node, { includeComments: true, skip });
}
//--------------------------------------------------------------------------
// Gets multiple tokens.
//--------------------------------------------------------------------------
/**
* Gets the first `count` tokens of the given node.
* @param {ASTNode} node The AST node.
* @param {number|Function|Object} [options=0] The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
* @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
* @param {Function|null} [options.filter=null] The predicate function to choose tokens.
* @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
* @returns {Token[]} Tokens.
*/
getFirstTokens(node, options) {
return createCursorWithCount(
cursors.forward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
node.range[0],
node.range[1],
options,
).getAllTokens();
}
/**
* Gets the last `count` tokens of the given node.
* @param {ASTNode} node The AST node.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
* @returns {Token[]} Tokens.
*/
getLastTokens(node, options) {
return createCursorWithCount(
cursors.backward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
node.range[0],
node.range[1],
options,
)
.getAllTokens()
.reverse();
}
/**
* Gets the `count` tokens that precedes a given node or token.
* @param {ASTNode|Token|Comment} node The AST node or token.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
* @returns {Token[]} Tokens.
*/
getTokensBefore(node, options) {
return createCursorWithCount(
cursors.backward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
-1,
node.range[0],
options,
)
.getAllTokens()
.reverse();
}
/**
* Gets the `count` tokens that follows a given node or token.
* @param {ASTNode|Token|Comment} node The AST node or token.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
* @returns {Token[]} Tokens.
*/
getTokensAfter(node, options) {
return createCursorWithCount(
cursors.forward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
node.range[1],
-1,
options,
).getAllTokens();
}
/**
* Gets the first `count` tokens between two non-overlapping nodes.
* @param {ASTNode|Token|Comment} left Node before the desired token range.
* @param {ASTNode|Token|Comment} right Node after the desired token range.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
* @returns {Token[]} Tokens between left and right.
*/
getFirstTokensBetween(left, right, options) {
return createCursorWithCount(
cursors.forward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
left.range[1],
right.range[0],
options,
).getAllTokens();
}
/**
* Gets the last `count` tokens between two non-overlapping nodes.
* @param {ASTNode|Token|Comment} left Node before the desired token range.
* @param {ASTNode|Token|Comment} right Node after the desired token range.
* @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
* @returns {Token[]} Tokens between left and right.
*/
getLastTokensBetween(left, right, options) {
return createCursorWithCount(
cursors.backward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
left.range[1],
right.range[0],
options,
)
.getAllTokens()
.reverse();
}
/**
* Gets all tokens that are related to the given node.
* @param {ASTNode} node The AST node.
* @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
* @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
* @param {Function|null} [options.filter=null] The predicate function to choose tokens.
* @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
* @returns {Token[]} Array of objects representing tokens.
*/
/**
* Gets all tokens that are related to the given node.
* @param {ASTNode} node The AST node.
* @param {int} [beforeCount=0] The number of tokens before the node to retrieve.
* @param {int} [afterCount=0] The number of tokens after the node to retrieve.
* @returns {Token[]} Array of objects representing tokens.
*/
getTokens(node, beforeCount, afterCount) {
return createCursorWithPadding(
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
node.range[0],
node.range[1],
beforeCount,
afterCount,
).getAllTokens();
}
/**
* Gets all of the tokens between two non-overlapping nodes.
* @param {ASTNode|Token|Comment} left Node before the desired token range.
* @param {ASTNode|Token|Comment} right Node after the desired token range.
* @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
* @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
* @param {Function|null} [options.filter=null] The predicate function to choose tokens.
* @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
* @returns {Token[]} Tokens between left and right.
*/
/**
* Gets all of the tokens between two non-overlapping nodes.
* @param {ASTNode|Token|Comment} left Node before the desired token range.
* @param {ASTNode|Token|Comment} right Node after the desired token range.
* @param {int} [padding=0] Number of extra tokens on either side of center.
* @returns {Token[]} Tokens between left and right.
*/
getTokensBetween(left, right, padding) {
return createCursorWithPadding(
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
left.range[1],
right.range[0],
padding,
padding,
).getAllTokens();
}
//--------------------------------------------------------------------------
// Others.
//--------------------------------------------------------------------------
/**
* Checks whether any comments exist or not between the given 2 nodes.
* @param {ASTNode} left The node to check.
* @param {ASTNode} right The node to check.
* @returns {boolean} `true` if one or more comments exist.
*/
commentsExistBetween(left, right) {
const index = utils.search(this[COMMENTS], left.range[1]);
return (
index < this[COMMENTS].length &&
this[COMMENTS][index].range[1] <= right.range[0]
);
}
/**
* Gets all comment tokens directly before the given node or token.
* @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens.
* @returns {Array} An array of comments in occurrence order.
*/
getCommentsBefore(nodeOrToken) {
const cursor = createCursorWithCount(
cursors.backward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
-1,
nodeOrToken.range[0],
{ includeComments: true },
);
return getAdjacentCommentTokensFromCursor(cursor).reverse();
}
/**
* Gets all comment tokens directly after the given node or token.
* @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens.
* @returns {Array} An array of comments in occurrence order.
*/
getCommentsAfter(nodeOrToken) {
const cursor = createCursorWithCount(
cursors.forward,
this[TOKENS],
this[COMMENTS],
this[INDEX_MAP],
nodeOrToken.range[1],
-1,
{ includeComments: true },
);
return getAdjacentCommentTokensFromCursor(cursor);
}
/**
* Gets all comment tokens inside the given node.
* @param {ASTNode} node The AST node to get the comments for.
* @returns {Array} An array of comments in occurrence order.
*/
getCommentsInside(node) {
return this.getTokens(node, {
includeComments: true,
filter: isCommentToken,
});
}
};

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P"},C:{"1":"0 9 yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB qC rC"},D:{"1":"0 9 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B"},E:{"1":"B C L M G TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F A sC SC tC uC vC wC"},F:{"1":"0 zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD GD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 iD jD kD lD mD IC JC KC nD","2":"J dD eD fD gD hD TC"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"rD","2":"qD"}},B:5,C:"prefers-reduced-motion media query",D:true};

View File

@@ -0,0 +1,35 @@
const url = require('url')
const tunnel = require('tunnel-agent')
const util = require('./util')
function applyProxy (reqOpts, opts) {
const log = opts.log || util.noopLogger
const proxy = opts['https-proxy'] || opts.proxy
if (proxy) {
// eslint-disable-next-line node/no-deprecated-api
const parsedDownloadUrl = url.parse(reqOpts.url)
// eslint-disable-next-line node/no-deprecated-api
const parsedProxy = url.parse(proxy)
const uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http')
const proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http')
const tunnelFnName = [uriProtocol, proxyProtocol].join('Over')
reqOpts.agent = tunnel[tunnelFnName]({
proxy: {
host: parsedProxy.hostname,
port: +parsedProxy.port,
proxyAuth: parsedProxy.auth
}
})
log.http('request', 'Proxy setup detected (Host: ' +
parsedProxy.hostname + ', Port: ' +
parsedProxy.port + ', Authentication: ' +
(parsedProxy.auth ? 'Yes' : 'No') + ')' +
' Tunneling with ' + tunnelFnName)
}
return reqOpts
}
module.exports = applyProxy

View File

@@ -0,0 +1,70 @@
'use strict';
var singleComment = 1;
var multiComment = 2;
function stripWithoutWhitespace() {
return '';
}
function stripWithWhitespace(str, start, end) {
return str.slice(start, end).replace(/\S/g, ' ');
}
module.exports = function (str, opts) {
opts = opts || {};
var currentChar;
var nextChar;
var insideString = false;
var insideComment = false;
var offset = 0;
var ret = '';
var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
for (var i = 0; i < str.length; i++) {
currentChar = str[i];
nextChar = str[i + 1];
if (!insideComment && currentChar === '"') {
var escaped = str[i - 1] === '\\' && str[i - 2] !== '\\';
if (!escaped) {
insideString = !insideString;
}
}
if (insideString) {
continue;
}
if (!insideComment && currentChar + nextChar === '//') {
ret += str.slice(offset, i);
offset = i;
insideComment = singleComment;
i++;
} else if (insideComment === singleComment && currentChar + nextChar === '\r\n') {
i++;
insideComment = false;
ret += strip(str, offset, i);
offset = i;
continue;
} else if (insideComment === singleComment && currentChar === '\n') {
insideComment = false;
ret += strip(str, offset, i);
offset = i;
} else if (!insideComment && currentChar + nextChar === '/*') {
ret += str.slice(offset, i);
offset = i;
insideComment = multiComment;
i++;
continue;
} else if (insideComment === multiComment && currentChar + nextChar === '*/') {
i++;
insideComment = false;
ret += strip(str, offset, i + 1);
offset = i + 1;
continue;
}
}
return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
};

View File

@@ -0,0 +1,31 @@
import { jsx } from "react/jsx-runtime";
import { Matches } from "./Matches.js";
import { getRouterContext } from "./routerContext.js";
function RouterContextProvider({
router,
children,
...rest
}) {
router.update({
...router.options,
...rest,
context: {
...router.options.context,
...rest.context
}
});
const routerContext = getRouterContext();
const provider = /* @__PURE__ */ jsx(routerContext.Provider, { value: router, children });
if (router.options.Wrap) {
return /* @__PURE__ */ jsx(router.options.Wrap, { children: provider });
}
return provider;
}
function RouterProvider({ router, ...rest }) {
return /* @__PURE__ */ jsx(RouterContextProvider, { router, ...rest, children: /* @__PURE__ */ jsx(Matches, {}) });
}
export {
RouterContextProvider,
RouterProvider
};
//# sourceMappingURL=RouterProvider.js.map

View File

@@ -0,0 +1 @@
module.exports={C:{"43":0.00326,"47":0.00163,"52":0.00163,"65":0.00326,"72":0.00163,"78":0.00163,"85":0.00163,"99":0.00163,"100":0.00163,"109":0.00163,"112":0.00163,"113":0.00163,"114":0.00163,"115":0.30118,"125":0.00163,"127":0.00488,"128":0.21164,"132":0.00163,"133":0.00488,"134":0.00488,"135":0.10256,"136":0.29304,"137":0.00977,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 45 46 48 49 50 51 53 54 55 56 57 58 59 60 61 62 63 64 66 67 68 69 70 71 73 74 75 76 77 79 80 81 82 83 84 86 87 88 89 90 91 92 93 94 95 96 97 98 101 102 103 104 105 106 107 108 110 111 116 117 118 119 120 121 122 123 124 126 129 130 131 138 139 140 3.5 3.6"},D:{"11":0.00163,"43":0.00163,"46":0.00163,"47":0.01628,"49":0.00163,"50":0.00163,"55":0.00163,"56":0.00163,"58":0.00488,"59":0.00163,"62":0.00814,"63":0.00488,"64":0.00488,"65":0.00163,"68":0.00488,"69":0.00326,"70":0.02442,"72":0.00163,"73":0.00163,"74":0.00651,"75":0.00326,"76":0.00488,"77":0.00326,"78":0.01465,"79":0.01465,"80":0.00488,"81":0.00326,"83":0.00488,"84":0.00163,"85":0.00163,"86":0.00651,"87":0.01302,"88":0.00488,"89":0.00163,"90":0.00326,"91":0.00326,"92":0.00163,"93":0.00977,"94":0.00163,"95":0.00814,"96":0.00163,"97":0.00163,"98":0.00163,"100":0.00326,"101":0.00163,"102":0.00163,"103":0.01465,"104":0.01465,"105":0.00814,"106":0.0114,"107":0.00326,"108":0.0114,"109":0.48352,"110":0.00488,"111":0.01465,"112":0.00488,"113":0.00326,"114":0.00814,"115":0.00163,"116":0.02279,"117":0.00326,"118":0.00488,"119":0.03419,"120":0.0114,"121":0.00651,"122":0.01302,"123":0.01628,"124":0.06675,"125":0.0114,"126":0.03744,"127":0.02116,"128":0.0407,"129":0.01628,"130":0.04233,"131":0.16443,"132":0.14652,"133":1.78266,"134":2.849,"135":0.00977,"136":0.00163,_:"4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 45 48 51 52 53 54 57 60 61 66 67 71 99 137 138"},F:{"46":0.00163,"58":0.00163,"79":0.00326,"83":0.00163,"84":0.00326,"85":0.00977,"86":0.02605,"87":0.28327,"88":0.04233,"95":0.01465,"100":0.01465,"102":0.00163,"113":0.00163,"114":0.00326,"115":0.00326,"116":0.02116,"117":0.24908,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 57 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 89 90 91 92 93 94 96 97 98 99 101 103 104 105 106 107 108 109 110 111 112 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"12":0.00163,"14":0.00163,"15":0.00163,"16":0.00163,"17":0.00163,"18":0.01791,"84":0.00163,"89":0.00326,"90":0.00814,"92":0.01791,"100":0.00488,"107":0.00163,"109":0.00651,"111":0.00163,"112":0.00326,"114":0.01628,"120":0.00163,"122":0.00326,"123":0.00163,"124":0.00163,"125":0.00163,"126":0.00163,"127":0.00163,"128":0.00651,"129":0.00326,"130":0.00488,"131":0.02279,"132":0.0293,"133":0.28653,"134":0.53073,_:"13 79 80 81 83 85 86 87 88 91 93 94 95 96 97 98 99 101 102 103 104 105 106 108 110 113 115 116 117 118 119 121"},E:{"11":0.00163,"13":0.00326,"14":0.00163,_:"0 4 5 6 7 8 9 10 12 15 3.1 3.2 6.1 9.1 10.1","5.1":0.00163,"7.1":0.00163,"11.1":0.00326,"12.1":0.00163,"13.1":0.00977,"14.1":0.00651,"15.1":0.00163,"15.2-15.3":0.00163,"15.4":0.00163,"15.5":0.00326,"15.6":0.02605,"16.0":0.00163,"16.1":0.00163,"16.2":0.00163,"16.3":0.00326,"16.4":0.00163,"16.5":0.00651,"16.6":0.01465,"17.0":0.00163,"17.1":0.00326,"17.2":0.00163,"17.3":0.00163,"17.4":0.01954,"17.5":0.00814,"17.6":0.01791,"18.0":0.0114,"18.1":0.02442,"18.2":0.00977,"18.3":0.07,"18.4":0.00326},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00122,"5.0-5.1":0,"6.0-6.1":0.00365,"7.0-7.1":0.00243,"8.1-8.4":0,"9.0-9.2":0.00183,"9.3":0.00852,"10.0-10.2":0.00061,"10.3":0.014,"11.0-11.2":0.06452,"11.3-11.4":0.00426,"12.0-12.1":0.00243,"12.2-12.5":0.06026,"13.0-13.1":0.00122,"13.2":0.00183,"13.3":0.00243,"13.4-13.7":0.00852,"14.0-14.4":0.0213,"14.5-14.8":0.02556,"15.0-15.1":0.014,"15.2-15.3":0.014,"15.4":0.01704,"15.5":0.01948,"15.6-15.8":0.23981,"16.0":0.03408,"16.1":0.06999,"16.2":0.03652,"16.3":0.0633,"16.4":0.014,"16.5":0.02617,"16.6-16.7":0.28424,"17.0":0.01704,"17.1":0.03043,"17.2":0.02313,"17.3":0.03226,"17.4":0.06452,"17.5":0.14364,"17.6-17.7":0.41692,"18.0":0.11686,"18.1":0.38223,"18.2":0.17103,"18.3":3.57457,"18.4":0.05295},P:{"4":0.01033,"20":0.01033,"21":0.01033,"22":0.03098,"23":0.02065,"24":0.0826,"25":0.0826,"26":0.0826,"27":0.51627,_:"5.0-5.4 6.2-6.4 8.2 10.1 12.0 13.0 14.0 15.0 18.0","7.2-7.4":0.02065,"9.2":0.02065,"11.1-11.2":0.01033,"16.0":0.01033,"17.0":0.01033,"19.0":0.01033},I:{"0":0.03342,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00004},K:{"0":25.27527,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.01302,_:"6 7 8 9 10 5.5"},S:{"2.5":0.01674,_:"3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.30976},Q:{"14.9":0.00837},O:{"0":0.39348},H:{"0":2.57},L:{"0":54.79964}};

View File

@@ -0,0 +1,132 @@
// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
#include "ImageData.h"
#include "InstanceData.h"
/*
* Initialize ImageData.
*/
void
ImageData::Initialize(Napi::Env& env, Napi::Object& exports) {
Napi::HandleScope scope(env);
InstanceData *data = env.GetInstanceData<InstanceData>();
Napi::Function ctor = DefineClass(env, "ImageData", {
InstanceAccessor<&ImageData::GetWidth>("width", napi_default_jsproperty),
InstanceAccessor<&ImageData::GetHeight>("height", napi_default_jsproperty)
});
exports.Set("ImageData", ctor);
data->ImageDataCtor = Napi::Persistent(ctor);
}
/*
* Initialize a new ImageData object.
*/
ImageData::ImageData(const Napi::CallbackInfo& info) : Napi::ObjectWrap<ImageData>(info), env(info.Env()) {
Napi::TypedArray dataArray;
uint32_t width;
uint32_t height;
int length;
if (info[0].IsNumber() && info[1].IsNumber()) {
width = info[0].As<Napi::Number>().Uint32Value();
if (width == 0) {
Napi::RangeError::New(env, "The source width is zero.").ThrowAsJavaScriptException();
return;
}
height = info[1].As<Napi::Number>().Uint32Value();
if (height == 0) {
Napi::RangeError::New(env, "The source height is zero.").ThrowAsJavaScriptException();
return;
}
length = width * height * 4; // ImageData(w, h) constructor assumes 4 BPP; documented.
dataArray = Napi::Uint8Array::New(env, length, napi_uint8_clamped_array);
} else if (
info[0].IsTypedArray() &&
info[0].As<Napi::TypedArray>().TypedArrayType() == napi_uint8_clamped_array &&
info[1].IsNumber()
) {
dataArray = info[0].As<Napi::Uint8Array>();
length = dataArray.ElementLength();
if (length == 0) {
Napi::RangeError::New(env, "The input data has a zero byte length.").ThrowAsJavaScriptException();
return;
}
// Don't assert that the ImageData length is a multiple of four because some
// data formats are not 4 BPP.
width = info[1].As<Napi::Number>().Uint32Value();
if (width == 0) {
Napi::RangeError::New(env, "The source width is zero.").ThrowAsJavaScriptException();
return;
}
// Don't assert that the byte length is a multiple of 4 * width, ditto.
if (info[2].IsNumber()) { // Explicit height given
height = info[2].As<Napi::Number>().Uint32Value();
} else { // Calculate height assuming 4 BPP
int size = length / 4;
height = size / width;
}
} else if (
info[0].IsTypedArray() &&
info[0].As<Napi::TypedArray>().TypedArrayType() == napi_uint16_array &&
info[1].IsNumber()
) { // Intended for RGB16_565 format
dataArray = info[0].As<Napi::TypedArray>();
length = dataArray.ElementLength();
if (length == 0) {
Napi::RangeError::New(env, "The input data has a zero byte length.").ThrowAsJavaScriptException();
return;
}
width = info[1].As<Napi::Number>().Uint32Value();
if (width == 0) {
Napi::RangeError::New(env, "The source width is zero.").ThrowAsJavaScriptException();
return;
}
if (info[2].IsNumber()) { // Explicit height given
height = info[2].As<Napi::Number>().Uint32Value();
} else { // Calculate height assuming 2 BPP
int size = length / 2;
height = size / width;
}
} else {
Napi::TypeError::New(env, "Expected (Uint8ClampedArray, width[, height]), (Uint16Array, width[, height]) or (width, height)").ThrowAsJavaScriptException();
return;
}
_width = width;
_height = height;
_data = dataArray.As<Napi::Uint8Array>().Data();
info.This().As<Napi::Object>().Set("data", dataArray);
}
/*
* Get width.
*/
Napi::Value
ImageData::GetWidth(const Napi::CallbackInfo& info) {
return Napi::Number::New(env, width());
}
/*
* Get height.
*/
Napi::Value
ImageData::GetHeight(const Napi::CallbackInfo& info) {
return Napi::Number::New(env, height());
}

View File

@@ -0,0 +1,61 @@
'use strict'
let Container = require('./container')
let LazyResult, Processor
class Root extends Container {
constructor(defaults) {
super(defaults)
this.type = 'root'
if (!this.nodes) this.nodes = []
}
normalize(child, sample, type) {
let nodes = super.normalize(child)
if (sample) {
if (type === 'prepend') {
if (this.nodes.length > 1) {
sample.raws.before = this.nodes[1].raws.before
} else {
delete sample.raws.before
}
} else if (this.first !== sample) {
for (let node of nodes) {
node.raws.before = sample.raws.before
}
}
}
return nodes
}
removeChild(child, ignore) {
let index = this.index(child)
if (!ignore && index === 0 && this.nodes.length > 1) {
this.nodes[1].raws.before = this.nodes[index].raws.before
}
return super.removeChild(child)
}
toResult(opts = {}) {
let lazy = new LazyResult(new Processor(), this, opts)
return lazy.stringify()
}
}
Root.registerLazyResult = dependant => {
LazyResult = dependant
}
Root.registerProcessor = dependant => {
Processor = dependant
}
module.exports = Root
Root.default = Root
Container.registerRoot(Root)

View File

@@ -0,0 +1,12 @@
function BrowserslistError(message) {
this.name = 'BrowserslistError'
this.message = message
this.browserslist = true
if (Error.captureStackTrace) {
Error.captureStackTrace(this, BrowserslistError)
}
}
BrowserslistError.prototype = Error.prototype
module.exports = BrowserslistError

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P"},C:{"1":"0 9 Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC qC rC"},D:{"1":"0 9 AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B"},E:{"1":"G zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F A B C L M sC SC tC uC vC wC TC FC GC xC yC"},F:{"1":"0 xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 iD jD kD lD mD IC JC KC nD","2":"J dD eD fD gD hD TC"},Q:{"16":"oD"},R:{"16":"pD"},S:{"2":"qD","16":"rD"}},B:5,C:"WebAssembly Bulk Memory Operations",D:true};

View File

@@ -0,0 +1,13 @@
import type { RouteById } from './routeInfo'
import type { AnyRouter } from './router'
import type { Expand } from './utils'
export type ResolveUseLoaderDeps<TRouter extends AnyRouter, TFrom> = Expand<
RouteById<TRouter['routeTree'], TFrom>['types']['loaderDeps']
>
export type UseLoaderDepsResult<
TRouter extends AnyRouter,
TFrom,
TSelected,
> = unknown extends TSelected ? ResolveUseLoaderDeps<TRouter, TFrom> : TSelected

View File

@@ -0,0 +1,243 @@
/**
* @fileoverview Validate strings passed to the RegExp constructor
* @author Michael Ficarra
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const RegExpValidator = require("@eslint-community/regexpp").RegExpValidator;
const validator = new RegExpValidator();
const validFlags = "dgimsuvy";
const undefined1 = void 0;
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "problem",
defaultOptions: [{}],
docs: {
description:
"Disallow invalid regular expression strings in `RegExp` constructors",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-invalid-regexp",
},
schema: [
{
type: "object",
properties: {
allowConstructorFlags: {
type: "array",
items: {
type: "string",
},
},
},
additionalProperties: false,
},
],
messages: {
regexMessage: "{{message}}.",
},
},
create(context) {
const [{ allowConstructorFlags }] = context.options;
let allowedFlags = [];
if (allowConstructorFlags) {
const temp = allowConstructorFlags
.join("")
.replace(new RegExp(`[${validFlags}]`, "gu"), "");
if (temp) {
allowedFlags = [...new Set(temp)];
}
}
/**
* Reports error with the provided message.
* @param {ASTNode} node The node holding the invalid RegExp
* @param {string} message The message to report.
* @returns {void}
*/
function report(node, message) {
context.report({
node,
messageId: "regexMessage",
data: { message },
});
}
/**
* Check if node is a string
* @param {ASTNode} node node to evaluate
* @returns {boolean} True if its a string
* @private
*/
function isString(node) {
return (
node &&
node.type === "Literal" &&
typeof node.value === "string"
);
}
/**
* Gets flags of a regular expression created by the given `RegExp()` or `new RegExp()` call
* Examples:
* new RegExp(".") // => ""
* new RegExp(".", "gu") // => "gu"
* new RegExp(".", flags) // => null
* @param {ASTNode} node `CallExpression` or `NewExpression` node
* @returns {string|null} flags if they can be determined, `null` otherwise
* @private
*/
function getFlags(node) {
if (node.arguments.length < 2) {
return "";
}
if (isString(node.arguments[1])) {
return node.arguments[1].value;
}
return null;
}
/**
* Check syntax error in a given pattern.
* @param {string} pattern The RegExp pattern to validate.
* @param {Object} flags The RegExp flags to validate.
* @param {boolean} [flags.unicode] The Unicode flag.
* @param {boolean} [flags.unicodeSets] The UnicodeSets flag.
* @returns {string|null} The syntax error.
*/
function validateRegExpPattern(pattern, flags) {
try {
validator.validatePattern(
pattern,
undefined1,
undefined1,
flags,
);
return null;
} catch (err) {
return err.message;
}
}
/**
* Check syntax error in a given flags.
* @param {string|null} flags The RegExp flags to validate.
* @param {string|null} flagsToCheck The RegExp invalid flags.
* @param {string} allFlags all valid and allowed flags.
* @returns {string|null} The syntax error.
*/
function validateRegExpFlags(flags, flagsToCheck, allFlags) {
const duplicateFlags = [];
if (typeof flagsToCheck === "string") {
for (const flag of flagsToCheck) {
if (allFlags.includes(flag)) {
duplicateFlags.push(flag);
}
}
}
/*
* `regexpp` checks the combination of `u` and `v` flags when parsing `Pattern` according to `ecma262`,
* but this rule may check only the flag when the pattern is unidentifiable, so check it here.
* https://tc39.es/ecma262/multipage/text-processing.html#sec-parsepattern
*/
if (flags && flags.includes("u") && flags.includes("v")) {
return "Regex 'u' and 'v' flags cannot be used together";
}
if (duplicateFlags.length > 0) {
return `Duplicate flags ('${duplicateFlags.join("")}') supplied to RegExp constructor`;
}
if (!flagsToCheck) {
return null;
}
return `Invalid flags supplied to RegExp constructor '${flagsToCheck}'`;
}
return {
"CallExpression, NewExpression"(node) {
if (
node.callee.type !== "Identifier" ||
node.callee.name !== "RegExp"
) {
return;
}
const flags = getFlags(node);
let flagsToCheck = flags;
const allFlags =
allowedFlags.length > 0
? validFlags.split("").concat(allowedFlags)
: validFlags.split("");
if (flags) {
allFlags.forEach(flag => {
flagsToCheck = flagsToCheck.replace(flag, "");
});
}
let message = validateRegExpFlags(
flags,
flagsToCheck,
allFlags,
);
if (message) {
report(node, message);
return;
}
if (!isString(node.arguments[0])) {
return;
}
const pattern = node.arguments[0].value;
message =
// If flags are unknown, report the regex only if its pattern is invalid both with and without the "u" flag
flags === null
? validateRegExpPattern(pattern, {
unicode: true,
unicodeSets: false,
}) &&
validateRegExpPattern(pattern, {
unicode: false,
unicodeSets: true,
}) &&
validateRegExpPattern(pattern, {
unicode: false,
unicodeSets: false,
})
: validateRegExpPattern(pattern, {
unicode: flags.includes("u"),
unicodeSets: flags.includes("v"),
});
if (message) {
report(node, message);
}
},
};
},
};