add hw2
This commit is contained in:
1
node_modules/.bin/acorn
generated
vendored
1
node_modules/.bin/acorn
generated
vendored
@@ -1 +0,0 @@
|
||||
../acorn/bin/acorn
|
||||
1
node_modules/.bin/browsers
generated
vendored
1
node_modules/.bin/browsers
generated
vendored
@@ -1 +0,0 @@
|
||||
../@puppeteer/browsers/lib/cjs/main-cli.js
|
||||
1
node_modules/.bin/cssesc
generated
vendored
1
node_modules/.bin/cssesc
generated
vendored
@@ -1 +0,0 @@
|
||||
../cssesc/bin/cssesc
|
||||
1
node_modules/.bin/csv2json
generated
vendored
1
node_modules/.bin/csv2json
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/dsv2json.js
|
||||
1
node_modules/.bin/csv2tsv
generated
vendored
1
node_modules/.bin/csv2tsv
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/dsv2dsv.js
|
||||
1
node_modules/.bin/dsv2dsv
generated
vendored
1
node_modules/.bin/dsv2dsv
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/dsv2dsv.js
|
||||
1
node_modules/.bin/dsv2json
generated
vendored
1
node_modules/.bin/dsv2json
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/dsv2json.js
|
||||
1
node_modules/.bin/escodegen
generated
vendored
1
node_modules/.bin/escodegen
generated
vendored
@@ -1 +0,0 @@
|
||||
../escodegen/bin/escodegen.js
|
||||
1
node_modules/.bin/esgenerate
generated
vendored
1
node_modules/.bin/esgenerate
generated
vendored
@@ -1 +0,0 @@
|
||||
../escodegen/bin/esgenerate.js
|
||||
1
node_modules/.bin/esparse
generated
vendored
1
node_modules/.bin/esparse
generated
vendored
@@ -1 +0,0 @@
|
||||
../esprima/bin/esparse.js
|
||||
1
node_modules/.bin/esvalidate
generated
vendored
1
node_modules/.bin/esvalidate
generated
vendored
@@ -1 +0,0 @@
|
||||
../esprima/bin/esvalidate.js
|
||||
1
node_modules/.bin/extract-zip
generated
vendored
1
node_modules/.bin/extract-zip
generated
vendored
@@ -1 +0,0 @@
|
||||
../extract-zip/cli.js
|
||||
1
node_modules/.bin/glob
generated
vendored
1
node_modules/.bin/glob
generated
vendored
@@ -1 +0,0 @@
|
||||
../glob/dist/esm/bin.mjs
|
||||
1
node_modules/.bin/installServerIntoExtension
generated
vendored
1
node_modules/.bin/installServerIntoExtension
generated
vendored
@@ -1 +0,0 @@
|
||||
../vscode-languageserver/bin/installServerIntoExtension
|
||||
1
node_modules/.bin/jiti
generated
vendored
1
node_modules/.bin/jiti
generated
vendored
@@ -1 +0,0 @@
|
||||
../jiti/bin/jiti.js
|
||||
1
node_modules/.bin/js-yaml
generated
vendored
1
node_modules/.bin/js-yaml
generated
vendored
@@ -1 +0,0 @@
|
||||
../js-yaml/bin/js-yaml.js
|
||||
1
node_modules/.bin/json2csv
generated
vendored
1
node_modules/.bin/json2csv
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/json2dsv.js
|
||||
1
node_modules/.bin/json2dsv
generated
vendored
1
node_modules/.bin/json2dsv
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/json2dsv.js
|
||||
1
node_modules/.bin/json2tsv
generated
vendored
1
node_modules/.bin/json2tsv
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/json2dsv.js
|
||||
1
node_modules/.bin/katex
generated
vendored
1
node_modules/.bin/katex
generated
vendored
@@ -1 +0,0 @@
|
||||
../katex/cli.js
|
||||
1
node_modules/.bin/marked
generated
vendored
1
node_modules/.bin/marked
generated
vendored
@@ -1 +0,0 @@
|
||||
../marked/bin/marked.js
|
||||
1
node_modules/.bin/mmdc
generated
vendored
1
node_modules/.bin/mmdc
generated
vendored
@@ -1 +0,0 @@
|
||||
../@mermaid-js/mermaid-cli/src/cli.js
|
||||
1
node_modules/.bin/nanoid
generated
vendored
1
node_modules/.bin/nanoid
generated
vendored
@@ -1 +0,0 @@
|
||||
../nanoid/bin/nanoid.cjs
|
||||
1
node_modules/.bin/node-which
generated
vendored
1
node_modules/.bin/node-which
generated
vendored
@@ -1 +0,0 @@
|
||||
../which/bin/node-which
|
||||
1
node_modules/.bin/pino
generated
vendored
1
node_modules/.bin/pino
generated
vendored
@@ -1 +0,0 @@
|
||||
../pino/bin.js
|
||||
1
node_modules/.bin/puppeteer
generated
vendored
1
node_modules/.bin/puppeteer
generated
vendored
@@ -1 +0,0 @@
|
||||
../puppeteer/lib/cjs/puppeteer/node/cli.js
|
||||
1
node_modules/.bin/resolve
generated
vendored
1
node_modules/.bin/resolve
generated
vendored
@@ -1 +0,0 @@
|
||||
../resolve/bin/resolve
|
||||
1
node_modules/.bin/semver
generated
vendored
1
node_modules/.bin/semver
generated
vendored
@@ -1 +0,0 @@
|
||||
../semver/bin/semver.js
|
||||
1
node_modules/.bin/sucrase
generated
vendored
1
node_modules/.bin/sucrase
generated
vendored
@@ -1 +0,0 @@
|
||||
../sucrase/bin/sucrase
|
||||
1
node_modules/.bin/sucrase-node
generated
vendored
1
node_modules/.bin/sucrase-node
generated
vendored
@@ -1 +0,0 @@
|
||||
../sucrase/bin/sucrase-node
|
||||
1
node_modules/.bin/tailwind
generated
vendored
1
node_modules/.bin/tailwind
generated
vendored
@@ -1 +0,0 @@
|
||||
../tailwindcss/lib/cli.js
|
||||
1
node_modules/.bin/tailwindcss
generated
vendored
1
node_modules/.bin/tailwindcss
generated
vendored
@@ -1 +0,0 @@
|
||||
../tailwindcss/lib/cli.js
|
||||
1
node_modules/.bin/tsv2csv
generated
vendored
1
node_modules/.bin/tsv2csv
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/dsv2dsv.js
|
||||
1
node_modules/.bin/tsv2json
generated
vendored
1
node_modules/.bin/tsv2json
generated
vendored
@@ -1 +0,0 @@
|
||||
../d3-dsv/bin/dsv2json.js
|
||||
1
node_modules/.bin/uuid
generated
vendored
1
node_modules/.bin/uuid
generated
vendored
@@ -1 +0,0 @@
|
||||
../uuid/dist/esm/bin/uuid
|
||||
5052
node_modules/.package-lock.json
generated
vendored
5052
node_modules/.package-lock.json
generated
vendored
File diff suppressed because it is too large
Load Diff
128
node_modules/@alloc/quick-lru/index.d.ts
generated
vendored
128
node_modules/@alloc/quick-lru/index.d.ts
generated
vendored
@@ -1,128 +0,0 @@
|
||||
declare namespace QuickLRU {
|
||||
interface Options<KeyType, ValueType> {
|
||||
/**
|
||||
The maximum number of milliseconds an item should remain in the cache.
|
||||
|
||||
@default Infinity
|
||||
|
||||
By default, `maxAge` will be `Infinity`, which means that items will never expire.
|
||||
Lazy expiration upon the next write or read call.
|
||||
|
||||
Individual expiration of an item can be specified by the `set(key, value, maxAge)` method.
|
||||
*/
|
||||
readonly maxAge?: number;
|
||||
|
||||
/**
|
||||
The maximum number of items before evicting the least recently used items.
|
||||
*/
|
||||
readonly maxSize: number;
|
||||
|
||||
/**
|
||||
Called right before an item is evicted from the cache.
|
||||
|
||||
Useful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).
|
||||
*/
|
||||
onEviction?: (key: KeyType, value: ValueType) => void;
|
||||
}
|
||||
}
|
||||
|
||||
declare class QuickLRU<KeyType, ValueType>
|
||||
implements Iterable<[KeyType, ValueType]> {
|
||||
/**
|
||||
The stored item count.
|
||||
*/
|
||||
readonly size: number;
|
||||
|
||||
/**
|
||||
Simple ["Least Recently Used" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29).
|
||||
|
||||
The instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.
|
||||
|
||||
@example
|
||||
```
|
||||
import QuickLRU = require('quick-lru');
|
||||
|
||||
const lru = new QuickLRU({maxSize: 1000});
|
||||
|
||||
lru.set('🦄', '🌈');
|
||||
|
||||
lru.has('🦄');
|
||||
//=> true
|
||||
|
||||
lru.get('🦄');
|
||||
//=> '🌈'
|
||||
```
|
||||
*/
|
||||
constructor(options: QuickLRU.Options<KeyType, ValueType>);
|
||||
|
||||
[Symbol.iterator](): IterableIterator<[KeyType, ValueType]>;
|
||||
|
||||
/**
|
||||
Set an item. Returns the instance.
|
||||
|
||||
Individual expiration of an item can be specified with the `maxAge` option. If not specified, the global `maxAge` value will be used in case it is specified in the constructor, otherwise the item will never expire.
|
||||
|
||||
@returns The list instance.
|
||||
*/
|
||||
set(key: KeyType, value: ValueType, options?: {maxAge?: number}): this;
|
||||
|
||||
/**
|
||||
Get an item.
|
||||
|
||||
@returns The stored item or `undefined`.
|
||||
*/
|
||||
get(key: KeyType): ValueType | undefined;
|
||||
|
||||
/**
|
||||
Check if an item exists.
|
||||
*/
|
||||
has(key: KeyType): boolean;
|
||||
|
||||
/**
|
||||
Get an item without marking it as recently used.
|
||||
|
||||
@returns The stored item or `undefined`.
|
||||
*/
|
||||
peek(key: KeyType): ValueType | undefined;
|
||||
|
||||
/**
|
||||
Delete an item.
|
||||
|
||||
@returns `true` if the item is removed or `false` if the item doesn't exist.
|
||||
*/
|
||||
delete(key: KeyType): boolean;
|
||||
|
||||
/**
|
||||
Delete all items.
|
||||
*/
|
||||
clear(): void;
|
||||
|
||||
/**
|
||||
Update the `maxSize` in-place, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.
|
||||
|
||||
Useful for on-the-fly tuning of cache sizes in live systems.
|
||||
*/
|
||||
resize(maxSize: number): void;
|
||||
|
||||
/**
|
||||
Iterable for all the keys.
|
||||
*/
|
||||
keys(): IterableIterator<KeyType>;
|
||||
|
||||
/**
|
||||
Iterable for all the values.
|
||||
*/
|
||||
values(): IterableIterator<ValueType>;
|
||||
|
||||
/**
|
||||
Iterable for all entries, starting with the oldest (ascending in recency).
|
||||
*/
|
||||
entriesAscending(): IterableIterator<[KeyType, ValueType]>;
|
||||
|
||||
/**
|
||||
Iterable for all entries, starting with the newest (descending in recency).
|
||||
*/
|
||||
entriesDescending(): IterableIterator<[KeyType, ValueType]>;
|
||||
}
|
||||
|
||||
export = QuickLRU;
|
||||
263
node_modules/@alloc/quick-lru/index.js
generated
vendored
263
node_modules/@alloc/quick-lru/index.js
generated
vendored
@@ -1,263 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
class QuickLRU {
|
||||
constructor(options = {}) {
|
||||
if (!(options.maxSize && options.maxSize > 0)) {
|
||||
throw new TypeError('`maxSize` must be a number greater than 0');
|
||||
}
|
||||
|
||||
if (typeof options.maxAge === 'number' && options.maxAge === 0) {
|
||||
throw new TypeError('`maxAge` must be a number greater than 0');
|
||||
}
|
||||
|
||||
this.maxSize = options.maxSize;
|
||||
this.maxAge = options.maxAge || Infinity;
|
||||
this.onEviction = options.onEviction;
|
||||
this.cache = new Map();
|
||||
this.oldCache = new Map();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
_emitEvictions(cache) {
|
||||
if (typeof this.onEviction !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const [key, item] of cache) {
|
||||
this.onEviction(key, item.value);
|
||||
}
|
||||
}
|
||||
|
||||
_deleteIfExpired(key, item) {
|
||||
if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
|
||||
if (typeof this.onEviction === 'function') {
|
||||
this.onEviction(key, item.value);
|
||||
}
|
||||
|
||||
return this.delete(key);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
_getOrDeleteIfExpired(key, item) {
|
||||
const deleted = this._deleteIfExpired(key, item);
|
||||
if (deleted === false) {
|
||||
return item.value;
|
||||
}
|
||||
}
|
||||
|
||||
_getItemValue(key, item) {
|
||||
return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
|
||||
}
|
||||
|
||||
_peek(key, cache) {
|
||||
const item = cache.get(key);
|
||||
|
||||
return this._getItemValue(key, item);
|
||||
}
|
||||
|
||||
_set(key, value) {
|
||||
this.cache.set(key, value);
|
||||
this._size++;
|
||||
|
||||
if (this._size >= this.maxSize) {
|
||||
this._size = 0;
|
||||
this._emitEvictions(this.oldCache);
|
||||
this.oldCache = this.cache;
|
||||
this.cache = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
_moveToRecent(key, item) {
|
||||
this.oldCache.delete(key);
|
||||
this._set(key, item);
|
||||
}
|
||||
|
||||
* _entriesAscending() {
|
||||
for (const item of this.oldCache) {
|
||||
const [key, value] = item;
|
||||
if (!this.cache.has(key)) {
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of this.cache) {
|
||||
const [key, value] = item;
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get(key) {
|
||||
if (this.cache.has(key)) {
|
||||
const item = this.cache.get(key);
|
||||
|
||||
return this._getItemValue(key, item);
|
||||
}
|
||||
|
||||
if (this.oldCache.has(key)) {
|
||||
const item = this.oldCache.get(key);
|
||||
if (this._deleteIfExpired(key, item) === false) {
|
||||
this._moveToRecent(key, item);
|
||||
return item.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set(key, value, {maxAge = this.maxAge === Infinity ? undefined : Date.now() + this.maxAge} = {}) {
|
||||
if (this.cache.has(key)) {
|
||||
this.cache.set(key, {
|
||||
value,
|
||||
maxAge
|
||||
});
|
||||
} else {
|
||||
this._set(key, {value, expiry: maxAge});
|
||||
}
|
||||
}
|
||||
|
||||
has(key) {
|
||||
if (this.cache.has(key)) {
|
||||
return !this._deleteIfExpired(key, this.cache.get(key));
|
||||
}
|
||||
|
||||
if (this.oldCache.has(key)) {
|
||||
return !this._deleteIfExpired(key, this.oldCache.get(key));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
peek(key) {
|
||||
if (this.cache.has(key)) {
|
||||
return this._peek(key, this.cache);
|
||||
}
|
||||
|
||||
if (this.oldCache.has(key)) {
|
||||
return this._peek(key, this.oldCache);
|
||||
}
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
const deleted = this.cache.delete(key);
|
||||
if (deleted) {
|
||||
this._size--;
|
||||
}
|
||||
|
||||
return this.oldCache.delete(key) || deleted;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.cache.clear();
|
||||
this.oldCache.clear();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
resize(newSize) {
|
||||
if (!(newSize && newSize > 0)) {
|
||||
throw new TypeError('`maxSize` must be a number greater than 0');
|
||||
}
|
||||
|
||||
const items = [...this._entriesAscending()];
|
||||
const removeCount = items.length - newSize;
|
||||
if (removeCount < 0) {
|
||||
this.cache = new Map(items);
|
||||
this.oldCache = new Map();
|
||||
this._size = items.length;
|
||||
} else {
|
||||
if (removeCount > 0) {
|
||||
this._emitEvictions(items.slice(0, removeCount));
|
||||
}
|
||||
|
||||
this.oldCache = new Map(items.slice(removeCount));
|
||||
this.cache = new Map();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
this.maxSize = newSize;
|
||||
}
|
||||
|
||||
* keys() {
|
||||
for (const [key] of this) {
|
||||
yield key;
|
||||
}
|
||||
}
|
||||
|
||||
* values() {
|
||||
for (const [, value] of this) {
|
||||
yield value;
|
||||
}
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
for (const item of this.cache) {
|
||||
const [key, value] = item;
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of this.oldCache) {
|
||||
const [key, value] = item;
|
||||
if (!this.cache.has(key)) {
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
* entriesDescending() {
|
||||
let items = [...this.cache];
|
||||
for (let i = items.length - 1; i >= 0; --i) {
|
||||
const item = items[i];
|
||||
const [key, value] = item;
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
|
||||
items = [...this.oldCache];
|
||||
for (let i = items.length - 1; i >= 0; --i) {
|
||||
const item = items[i];
|
||||
const [key, value] = item;
|
||||
if (!this.cache.has(key)) {
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
* entriesAscending() {
|
||||
for (const [key, value] of this._entriesAscending()) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
if (!this._size) {
|
||||
return this.oldCache.size;
|
||||
}
|
||||
|
||||
let oldCacheSize = 0;
|
||||
for (const key of this.oldCache.keys()) {
|
||||
if (!this.cache.has(key)) {
|
||||
oldCacheSize++;
|
||||
}
|
||||
}
|
||||
|
||||
return Math.min(this._size + oldCacheSize, this.maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = QuickLRU;
|
||||
9
node_modules/@alloc/quick-lru/license
generated
vendored
9
node_modules/@alloc/quick-lru/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
43
node_modules/@alloc/quick-lru/package.json
generated
vendored
43
node_modules/@alloc/quick-lru/package.json
generated
vendored
@@ -1,43 +0,0 @@
|
||||
{
|
||||
"name": "@alloc/quick-lru",
|
||||
"version": "5.2.0",
|
||||
"description": "Simple “Least Recently Used” (LRU) cache",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/quick-lru",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"lru",
|
||||
"quick",
|
||||
"cache",
|
||||
"caching",
|
||||
"least",
|
||||
"recently",
|
||||
"used",
|
||||
"fast",
|
||||
"map",
|
||||
"hash",
|
||||
"buffer"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^2.0.0",
|
||||
"coveralls": "^3.0.3",
|
||||
"nyc": "^15.0.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.26.0"
|
||||
}
|
||||
}
|
||||
139
node_modules/@alloc/quick-lru/readme.md
generated
vendored
139
node_modules/@alloc/quick-lru/readme.md
generated
vendored
@@ -1,139 +0,0 @@
|
||||
# quick-lru [](https://travis-ci.org/sindresorhus/quick-lru) [](https://coveralls.io/github/sindresorhus/quick-lru?branch=master)
|
||||
|
||||
> Simple [“Least Recently Used” (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29)
|
||||
|
||||
Useful when you need to cache something and limit memory usage.
|
||||
|
||||
Inspired by the [`hashlru` algorithm](https://github.com/dominictarr/hashlru#algorithm), but instead uses [`Map`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map) to support keys of any type, not just strings, and values can be `undefined`.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install quick-lru
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const QuickLRU = require('quick-lru');
|
||||
|
||||
const lru = new QuickLRU({maxSize: 1000});
|
||||
|
||||
lru.set('🦄', '🌈');
|
||||
|
||||
lru.has('🦄');
|
||||
//=> true
|
||||
|
||||
lru.get('🦄');
|
||||
//=> '🌈'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### new QuickLRU(options?)
|
||||
|
||||
Returns a new instance.
|
||||
|
||||
### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
#### maxSize
|
||||
|
||||
*Required*\
|
||||
Type: `number`
|
||||
|
||||
The maximum number of items before evicting the least recently used items.
|
||||
|
||||
#### maxAge
|
||||
|
||||
Type: `number`\
|
||||
Default: `Infinity`
|
||||
|
||||
The maximum number of milliseconds an item should remain in cache.
|
||||
By default maxAge will be Infinity, which means that items will never expire.
|
||||
|
||||
Lazy expiration happens upon the next `write` or `read` call.
|
||||
|
||||
Individual expiration of an item can be specified by the `set(key, value, options)` method.
|
||||
|
||||
#### onEviction
|
||||
|
||||
*Optional*\
|
||||
Type: `(key, value) => void`
|
||||
|
||||
Called right before an item is evicted from the cache.
|
||||
|
||||
Useful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).
|
||||
|
||||
### Instance
|
||||
|
||||
The instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.
|
||||
|
||||
Both `key` and `value` can be of any type.
|
||||
|
||||
#### .set(key, value, options?)
|
||||
|
||||
Set an item. Returns the instance.
|
||||
|
||||
Individual expiration of an item can be specified with the `maxAge` option. If not specified, the global `maxAge` value will be used in case it is specified on the constructor, otherwise the item will never expire.
|
||||
|
||||
#### .get(key)
|
||||
|
||||
Get an item.
|
||||
|
||||
#### .has(key)
|
||||
|
||||
Check if an item exists.
|
||||
|
||||
#### .peek(key)
|
||||
|
||||
Get an item without marking it as recently used.
|
||||
|
||||
#### .delete(key)
|
||||
|
||||
Delete an item.
|
||||
|
||||
Returns `true` if the item is removed or `false` if the item doesn't exist.
|
||||
|
||||
#### .clear()
|
||||
|
||||
Delete all items.
|
||||
|
||||
#### .resize(maxSize)
|
||||
|
||||
Update the `maxSize`, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.
|
||||
|
||||
Useful for on-the-fly tuning of cache sizes in live systems.
|
||||
|
||||
#### .keys()
|
||||
|
||||
Iterable for all the keys.
|
||||
|
||||
#### .values()
|
||||
|
||||
Iterable for all the values.
|
||||
|
||||
#### .entriesAscending()
|
||||
|
||||
Iterable for all entries, starting with the oldest (ascending in recency).
|
||||
|
||||
#### .entriesDescending()
|
||||
|
||||
Iterable for all entries, starting with the newest (descending in recency).
|
||||
|
||||
#### .size
|
||||
|
||||
The stored item count.
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-quick-lru?utm_source=npm-quick-lru&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
21
node_modules/@antfu/install-pkg/LICENSE
generated
vendored
21
node_modules/@antfu/install-pkg/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
27
node_modules/@antfu/install-pkg/README.md
generated
vendored
27
node_modules/@antfu/install-pkg/README.md
generated
vendored
@@ -1,27 +0,0 @@
|
||||
# install-pkg
|
||||
|
||||
[](https://www.npmjs.com/package/@antfu/install-pkg)
|
||||
|
||||
Install package programmatically. Detect package managers automatically (`npm`, `yarn`, `bun` and `pnpm`).
|
||||
|
||||
```bash
|
||||
npm i @antfu/install-pkg
|
||||
```
|
||||
|
||||
```ts
|
||||
import { installPackage } from '@antfu/install-pkg'
|
||||
|
||||
await installPackage('vite', { silent: true })
|
||||
```
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)
|
||||
135
node_modules/@antfu/install-pkg/dist/index.cjs
generated
vendored
135
node_modules/@antfu/install-pkg/dist/index.cjs
generated
vendored
@@ -1,135 +0,0 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
detectPackageManager: () => detectPackageManager,
|
||||
installPackage: () => installPackage,
|
||||
uninstallPackage: () => uninstallPackage
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
// src/detect.ts
|
||||
var import_node_process = __toESM(require("process"), 1);
|
||||
var import_detect = require("package-manager-detector/detect");
|
||||
async function detectPackageManager(cwd = import_node_process.default.cwd()) {
|
||||
const result = await (0, import_detect.detect)({
|
||||
cwd,
|
||||
onUnknown(packageManager) {
|
||||
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
||||
return void 0;
|
||||
}
|
||||
});
|
||||
return result?.agent || null;
|
||||
}
|
||||
|
||||
// src/install.ts
|
||||
var import_node_fs = require("fs");
|
||||
var import_node_path = require("path");
|
||||
var import_node_process2 = __toESM(require("process"), 1);
|
||||
var import_tinyexec = require("tinyexec");
|
||||
async function installPackage(names, options = {}) {
|
||||
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
||||
const [agent] = detectedAgent.split("@");
|
||||
if (!Array.isArray(names))
|
||||
names = [names];
|
||||
const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
|
||||
if (options.preferOffline) {
|
||||
if (detectedAgent === "yarn@berry")
|
||||
args.unshift("--cached");
|
||||
else
|
||||
args.unshift("--prefer-offline");
|
||||
}
|
||||
if (agent === "pnpm") {
|
||||
args.unshift(
|
||||
/**
|
||||
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
|
||||
* @see https://pnpm.io/cli/install#--prod--p
|
||||
*/
|
||||
"--prod=false"
|
||||
);
|
||||
if ((0, import_node_fs.existsSync)((0, import_node_path.resolve)(options.cwd ?? import_node_process2.default.cwd(), "pnpm-workspace.yaml"))) {
|
||||
args.unshift("-w");
|
||||
}
|
||||
}
|
||||
return (0, import_tinyexec.x)(
|
||||
agent,
|
||||
[
|
||||
agent === "yarn" ? "add" : "install",
|
||||
options.dev ? "-D" : "",
|
||||
...args,
|
||||
...names
|
||||
].filter(Boolean),
|
||||
{
|
||||
nodeOptions: {
|
||||
stdio: options.silent ? "ignore" : "inherit",
|
||||
cwd: options.cwd
|
||||
},
|
||||
throwOnError: true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// src/uninstall.ts
|
||||
var import_node_fs2 = require("fs");
|
||||
var import_node_process3 = __toESM(require("process"), 1);
|
||||
var import_node_path2 = require("path");
|
||||
var import_tinyexec2 = require("tinyexec");
|
||||
async function uninstallPackage(names, options = {}) {
|
||||
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
||||
const [agent] = detectedAgent.split("@");
|
||||
if (!Array.isArray(names))
|
||||
names = [names];
|
||||
const args = options.additionalArgs || [];
|
||||
if (agent === "pnpm" && (0, import_node_fs2.existsSync)((0, import_node_path2.resolve)(options.cwd ?? import_node_process3.default.cwd(), "pnpm-workspace.yaml")))
|
||||
args.unshift("-w");
|
||||
return (0, import_tinyexec2.x)(
|
||||
agent,
|
||||
[
|
||||
agent === "yarn" ? "remove" : "uninstall",
|
||||
options.dev ? "-D" : "",
|
||||
...args,
|
||||
...names
|
||||
].filter(Boolean),
|
||||
{
|
||||
nodeOptions: {
|
||||
stdio: options.silent ? "ignore" : "inherit",
|
||||
cwd: options.cwd
|
||||
},
|
||||
throwOnError: true
|
||||
}
|
||||
);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
detectPackageManager,
|
||||
installPackage,
|
||||
uninstallPackage
|
||||
});
|
||||
27
node_modules/@antfu/install-pkg/dist/index.d.cts
generated
vendored
27
node_modules/@antfu/install-pkg/dist/index.d.cts
generated
vendored
@@ -1,27 +0,0 @@
|
||||
import { Agent } from 'package-manager-detector';
|
||||
export { Agent } from 'package-manager-detector';
|
||||
import * as tinyexec from 'tinyexec';
|
||||
|
||||
type PackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
|
||||
declare function detectPackageManager(cwd?: string): Promise<Agent | null>;
|
||||
|
||||
interface InstallPackageOptions {
|
||||
cwd?: string;
|
||||
dev?: boolean;
|
||||
silent?: boolean;
|
||||
packageManager?: string;
|
||||
preferOffline?: boolean;
|
||||
additionalArgs?: string[] | ((agent: string, detectedAgent: string) => string[] | undefined);
|
||||
}
|
||||
declare function installPackage(names: string | string[], options?: InstallPackageOptions): Promise<tinyexec.Output>;
|
||||
|
||||
interface UninstallPackageOptions {
|
||||
cwd?: string;
|
||||
dev?: boolean;
|
||||
silent?: boolean;
|
||||
packageManager?: string;
|
||||
additionalArgs?: string[];
|
||||
}
|
||||
declare function uninstallPackage(names: string | string[], options?: UninstallPackageOptions): Promise<tinyexec.Output>;
|
||||
|
||||
export { type InstallPackageOptions, type PackageManager, type UninstallPackageOptions, detectPackageManager, installPackage, uninstallPackage };
|
||||
27
node_modules/@antfu/install-pkg/dist/index.d.ts
generated
vendored
27
node_modules/@antfu/install-pkg/dist/index.d.ts
generated
vendored
@@ -1,27 +0,0 @@
|
||||
import { Agent } from 'package-manager-detector';
|
||||
export { Agent } from 'package-manager-detector';
|
||||
import * as tinyexec from 'tinyexec';
|
||||
|
||||
type PackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
|
||||
declare function detectPackageManager(cwd?: string): Promise<Agent | null>;
|
||||
|
||||
interface InstallPackageOptions {
|
||||
cwd?: string;
|
||||
dev?: boolean;
|
||||
silent?: boolean;
|
||||
packageManager?: string;
|
||||
preferOffline?: boolean;
|
||||
additionalArgs?: string[] | ((agent: string, detectedAgent: string) => string[] | undefined);
|
||||
}
|
||||
declare function installPackage(names: string | string[], options?: InstallPackageOptions): Promise<tinyexec.Output>;
|
||||
|
||||
interface UninstallPackageOptions {
|
||||
cwd?: string;
|
||||
dev?: boolean;
|
||||
silent?: boolean;
|
||||
packageManager?: string;
|
||||
additionalArgs?: string[];
|
||||
}
|
||||
declare function uninstallPackage(names: string | string[], options?: UninstallPackageOptions): Promise<tinyexec.Output>;
|
||||
|
||||
export { type InstallPackageOptions, type PackageManager, type UninstallPackageOptions, detectPackageManager, installPackage, uninstallPackage };
|
||||
96
node_modules/@antfu/install-pkg/dist/index.js
generated
vendored
96
node_modules/@antfu/install-pkg/dist/index.js
generated
vendored
@@ -1,96 +0,0 @@
|
||||
// src/detect.ts
|
||||
import process from "node:process";
|
||||
import { detect } from "package-manager-detector/detect";
|
||||
async function detectPackageManager(cwd = process.cwd()) {
|
||||
const result = await detect({
|
||||
cwd,
|
||||
onUnknown(packageManager) {
|
||||
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
||||
return void 0;
|
||||
}
|
||||
});
|
||||
return result?.agent || null;
|
||||
}
|
||||
|
||||
// src/install.ts
|
||||
import { existsSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import process2 from "node:process";
|
||||
import { x } from "tinyexec";
|
||||
async function installPackage(names, options = {}) {
|
||||
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
||||
const [agent] = detectedAgent.split("@");
|
||||
if (!Array.isArray(names))
|
||||
names = [names];
|
||||
const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
|
||||
if (options.preferOffline) {
|
||||
if (detectedAgent === "yarn@berry")
|
||||
args.unshift("--cached");
|
||||
else
|
||||
args.unshift("--prefer-offline");
|
||||
}
|
||||
if (agent === "pnpm") {
|
||||
args.unshift(
|
||||
/**
|
||||
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
|
||||
* @see https://pnpm.io/cli/install#--prod--p
|
||||
*/
|
||||
"--prod=false"
|
||||
);
|
||||
if (existsSync(resolve(options.cwd ?? process2.cwd(), "pnpm-workspace.yaml"))) {
|
||||
args.unshift("-w");
|
||||
}
|
||||
}
|
||||
return x(
|
||||
agent,
|
||||
[
|
||||
agent === "yarn" ? "add" : "install",
|
||||
options.dev ? "-D" : "",
|
||||
...args,
|
||||
...names
|
||||
].filter(Boolean),
|
||||
{
|
||||
nodeOptions: {
|
||||
stdio: options.silent ? "ignore" : "inherit",
|
||||
cwd: options.cwd
|
||||
},
|
||||
throwOnError: true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// src/uninstall.ts
|
||||
import { existsSync as existsSync2 } from "node:fs";
|
||||
import process3 from "node:process";
|
||||
import { resolve as resolve2 } from "node:path";
|
||||
import { x as x2 } from "tinyexec";
|
||||
async function uninstallPackage(names, options = {}) {
|
||||
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
||||
const [agent] = detectedAgent.split("@");
|
||||
if (!Array.isArray(names))
|
||||
names = [names];
|
||||
const args = options.additionalArgs || [];
|
||||
if (agent === "pnpm" && existsSync2(resolve2(options.cwd ?? process3.cwd(), "pnpm-workspace.yaml")))
|
||||
args.unshift("-w");
|
||||
return x2(
|
||||
agent,
|
||||
[
|
||||
agent === "yarn" ? "remove" : "uninstall",
|
||||
options.dev ? "-D" : "",
|
||||
...args,
|
||||
...names
|
||||
].filter(Boolean),
|
||||
{
|
||||
nodeOptions: {
|
||||
stdio: options.silent ? "ignore" : "inherit",
|
||||
cwd: options.cwd
|
||||
},
|
||||
throwOnError: true
|
||||
}
|
||||
);
|
||||
}
|
||||
export {
|
||||
detectPackageManager,
|
||||
installPackage,
|
||||
uninstallPackage
|
||||
};
|
||||
58
node_modules/@antfu/install-pkg/package.json
generated
vendored
58
node_modules/@antfu/install-pkg/package.json
generated
vendored
@@ -1,58 +0,0 @@
|
||||
{
|
||||
"name": "@antfu/install-pkg",
|
||||
"type": "module",
|
||||
"version": "1.1.0",
|
||||
"description": "Install package programmatically.",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/antfu",
|
||||
"homepage": "https://github.com/antfu/install-pkg#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/antfu/install-pkg.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/antfu/install-pkg/issues"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.cts",
|
||||
"default": "./dist/index.cjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"package-manager-detector": "^1.3.0",
|
||||
"tinyexec": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^4.12.1",
|
||||
"@antfu/ni": "^24.3.0",
|
||||
"@types/node": "^22.15.12",
|
||||
"bumpp": "^10.1.0",
|
||||
"eslint": "^9.26.0",
|
||||
"publint": "^0.3.12",
|
||||
"tsup": "^8.4.0",
|
||||
"tsx": "^4.19.4",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "nr build --watch",
|
||||
"start": "tsx src/index.ts",
|
||||
"build": "tsup src/index.ts --format cjs,esm --dts --no-splitting",
|
||||
"release": "bumpp --commit --push --tag && pnpm publish",
|
||||
"lint": "eslint ."
|
||||
}
|
||||
}
|
||||
21
node_modules/@antfu/utils/LICENSE
generated
vendored
21
node_modules/@antfu/utils/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
24
node_modules/@antfu/utils/README.md
generated
vendored
24
node_modules/@antfu/utils/README.md
generated
vendored
@@ -1,24 +0,0 @@
|
||||
# @antfu/utils
|
||||
|
||||
[](https://www.npmjs.com/package/@antfu/utils)
|
||||
[](https://www.jsdocs.io/package/@antfu/utils)
|
||||
|
||||
Opinionated collection of common JavaScript / TypeScript utils by [@antfu](https://github.com/antfu).
|
||||
|
||||
- Tree-shakable ESM
|
||||
- Fully typed - with TSDocs
|
||||
- Type utilities - `Arrayable<T>`, `ElementOf<T>`, etc.
|
||||
|
||||
> This package is designed to be used as `devDependencies` and bundled into your dist.
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)
|
||||
549
node_modules/@antfu/utils/dist/index.d.mts
generated
vendored
549
node_modules/@antfu/utils/dist/index.d.mts
generated
vendored
@@ -1,549 +0,0 @@
|
||||
/**
|
||||
* Promise, or maybe not
|
||||
*/
|
||||
type Awaitable<T> = T | PromiseLike<T>;
|
||||
/**
|
||||
* Null or whatever
|
||||
*/
|
||||
type Nullable<T> = T | null | undefined;
|
||||
/**
|
||||
* Array, or not yet
|
||||
*/
|
||||
type Arrayable<T> = T | Array<T>;
|
||||
/**
|
||||
* Function
|
||||
*/
|
||||
type Fn<T = void> = () => T;
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
type Constructor<T = void> = new (...args: any[]) => T;
|
||||
/**
|
||||
* Infers the element type of an array
|
||||
*/
|
||||
type ElementOf<T> = T extends (infer E)[] ? E : never;
|
||||
/**
|
||||
* Defines an intersection type of all union items.
|
||||
*
|
||||
* @param U Union of any types that will be intersected.
|
||||
* @returns U items intersected
|
||||
* @see https://stackoverflow.com/a/50375286/9259330
|
||||
*/
|
||||
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
||||
/**
|
||||
* Infers the arguments type of a function
|
||||
*/
|
||||
type ArgumentsType<T> = T extends ((...args: infer A) => any) ? A : never;
|
||||
type MergeInsertions<T> = T extends object ? {
|
||||
[K in keyof T]: MergeInsertions<T[K]>;
|
||||
} : T;
|
||||
type DeepMerge<F, S> = MergeInsertions<{
|
||||
[K in keyof F | keyof S]: K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Convert `Arrayable<T>` to `Array<T>`
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T>;
|
||||
/**
|
||||
* Convert `Arrayable<T>` to `Array<T>` and flatten it
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function flattenArrayable<T>(array?: Nullable<Arrayable<T | Array<T>>>): Array<T>;
|
||||
/**
|
||||
* Use rest arguments to merge arrays
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function mergeArrayable<T>(...args: Nullable<Arrayable<T>>[]): Array<T>;
|
||||
type PartitionFilter<T> = (i: T, idx: number, arr: readonly T[]) => any;
|
||||
/**
|
||||
* Divide an array into two parts by a filter function
|
||||
*
|
||||
* @category Array
|
||||
* @example const [odd, even] = partition([1, 2, 3, 4], i => i % 2 != 0)
|
||||
*/
|
||||
declare function partition<T>(array: readonly T[], f1: PartitionFilter<T>): [T[], T[]];
|
||||
declare function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>): [T[], T[], T[]];
|
||||
declare function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>, f3: PartitionFilter<T>): [T[], T[], T[], T[]];
|
||||
declare function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>, f3: PartitionFilter<T>, f4: PartitionFilter<T>): [T[], T[], T[], T[], T[]];
|
||||
declare function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>, f3: PartitionFilter<T>, f4: PartitionFilter<T>, f5: PartitionFilter<T>): [T[], T[], T[], T[], T[], T[]];
|
||||
declare function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>, f3: PartitionFilter<T>, f4: PartitionFilter<T>, f5: PartitionFilter<T>, f6: PartitionFilter<T>): [T[], T[], T[], T[], T[], T[], T[]];
|
||||
/**
|
||||
* Unique an Array
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function uniq<T>(array: readonly T[]): T[];
|
||||
/**
|
||||
* Unique an Array by a custom equality function
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function uniqueBy<T>(array: readonly T[], equalFn: (a: any, b: any) => boolean): T[];
|
||||
/**
|
||||
* Get last item
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function last(array: readonly []): undefined;
|
||||
declare function last<T>(array: readonly T[]): T;
|
||||
/**
|
||||
* Remove an item from Array
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function remove<T>(array: T[], value: T): boolean;
|
||||
/**
|
||||
* Get nth item of Array. Negative for backward
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function at(array: readonly [], index: number): undefined;
|
||||
declare function at<T>(array: readonly T[], index: number): T;
|
||||
/**
|
||||
* Genrate a range array of numbers. The `stop` is exclusive.
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function range(stop: number): number[];
|
||||
declare function range(start: number, stop: number, step?: number): number[];
|
||||
/**
|
||||
* Move element in an Array
|
||||
*
|
||||
* @category Array
|
||||
* @param arr
|
||||
* @param from
|
||||
* @param to
|
||||
*/
|
||||
declare function move<T>(arr: T[], from: number, to: number): T[];
|
||||
/**
|
||||
* Clamp a number to the index range of an array
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function clampArrayRange(n: number, arr: readonly unknown[]): number;
|
||||
/**
|
||||
* Get random item(s) from an array
|
||||
*
|
||||
* @param arr
|
||||
* @param quantity - quantity of random items which will be returned
|
||||
*/
|
||||
declare function sample<T>(arr: T[], quantity: number): T[];
|
||||
/**
|
||||
* Shuffle an array. This function mutates the array.
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function shuffle<T>(array: T[]): T[];
|
||||
/**
|
||||
* Filter out items from an array in place.
|
||||
* This function mutates the array.
|
||||
* `predicate` get through the array from the end to the start for performance.
|
||||
*
|
||||
* Expect this function to be faster than using `Array.prototype.filter` on large arrays.
|
||||
*
|
||||
* @category Array
|
||||
*/
|
||||
declare function filterInPlace<T>(array: T[], predicate: (item: T, index: number, arr: T[]) => unknown): T[];
|
||||
|
||||
declare function assert(condition: boolean, message: string): asserts condition;
|
||||
declare const toString: (v: any) => string;
|
||||
declare function getTypeName(v: any): string;
|
||||
declare function noop(): void;
|
||||
|
||||
declare function isDeepEqual(value1: any, value2: any): boolean;
|
||||
|
||||
/**
|
||||
* Call every function in an array
|
||||
*/
|
||||
declare function batchInvoke(functions: Nullable<Fn>[]): void;
|
||||
/**
|
||||
* Call the function, returning the result
|
||||
*/
|
||||
declare function invoke<T>(fn: () => T): T;
|
||||
/**
|
||||
* Pass the value through the callback, and return the value
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* function createUser(name: string): User {
|
||||
* return tap(new User, user => {
|
||||
* user.name = name
|
||||
* })
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function tap<T>(value: T, callback: (value: T) => void): T;
|
||||
|
||||
/**
|
||||
* Type guard to filter out null-ish values
|
||||
*
|
||||
* @category Guards
|
||||
* @example array.filter(notNullish)
|
||||
*/
|
||||
declare function notNullish<T>(v: T | null | undefined): v is NonNullable<T>;
|
||||
/**
|
||||
* Type guard to filter out null values
|
||||
*
|
||||
* @category Guards
|
||||
* @example array.filter(noNull)
|
||||
*/
|
||||
declare function noNull<T>(v: T | null): v is Exclude<T, null>;
|
||||
/**
|
||||
* Type guard to filter out null-ish values
|
||||
*
|
||||
* @category Guards
|
||||
* @example array.filter(notUndefined)
|
||||
*/
|
||||
declare function notUndefined<T>(v: T): v is Exclude<T, undefined>;
|
||||
/**
|
||||
* Type guard to filter out falsy values
|
||||
*
|
||||
* @category Guards
|
||||
* @example array.filter(isTruthy)
|
||||
*/
|
||||
declare function isTruthy<T>(v: T): v is NonNullable<T>;
|
||||
|
||||
declare const isDef: <T = any>(val?: T) => val is T;
|
||||
declare const isBoolean: (val: any) => val is boolean;
|
||||
declare const isFunction: <T extends Function>(val: any) => val is T;
|
||||
declare const isNumber: (val: any) => val is number;
|
||||
declare const isString: (val: unknown) => val is string;
|
||||
declare const isObject: (val: any) => val is object;
|
||||
declare const isUndefined: (val: any) => val is undefined;
|
||||
declare const isNull: (val: any) => val is null;
|
||||
declare const isRegExp: (val: any) => val is RegExp;
|
||||
declare const isDate: (val: any) => val is Date;
|
||||
/**
|
||||
* Check if a value is primitive
|
||||
*/
|
||||
declare function isPrimitive(val: any): val is string | number | boolean | symbol | bigint | null | undefined;
|
||||
declare const isWindow: (val: any) => boolean;
|
||||
declare const isBrowser: boolean;
|
||||
|
||||
declare function clamp(n: number, min: number, max: number): number;
|
||||
declare function sum(...args: number[] | number[][]): number;
|
||||
/**
|
||||
* Linearly interpolates between `min` and `max` based on `t`
|
||||
*
|
||||
* @category Math
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param t The interpolation value clamped between 0 and 1
|
||||
* @example
|
||||
* ```
|
||||
* const value = lerp(0, 2, 0.5) // value will be 1
|
||||
* ```
|
||||
*/
|
||||
declare function lerp(min: number, max: number, t: number): number;
|
||||
/**
|
||||
* Linearly remaps a clamped value from its source range [`inMin`, `inMax`] to the destination range [`outMin`, `outMax`]
|
||||
*
|
||||
* @category Math
|
||||
* @example
|
||||
* ```
|
||||
* const value = remap(0.5, 0, 1, 200, 400) // value will be 300
|
||||
* ```
|
||||
*/
|
||||
declare function remap(n: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
|
||||
|
||||
/**
|
||||
* Map key/value pairs for an object, and construct a new one
|
||||
*
|
||||
*
|
||||
* @category Object
|
||||
*
|
||||
* Transform:
|
||||
* @example
|
||||
* ```
|
||||
* objectMap({ a: 1, b: 2 }, (k, v) => [k.toString().toUpperCase(), v.toString()])
|
||||
* // { A: '1', B: '2' }
|
||||
* ```
|
||||
*
|
||||
* Swap key/value:
|
||||
* @example
|
||||
* ```
|
||||
* objectMap({ a: 1, b: 2 }, (k, v) => [v, k])
|
||||
* // { 1: 'a', 2: 'b' }
|
||||
* ```
|
||||
*
|
||||
* Filter keys:
|
||||
* @example
|
||||
* ```
|
||||
* objectMap({ a: 1, b: 2 }, (k, v) => k === 'a' ? undefined : [k, v])
|
||||
* // { b: 2 }
|
||||
* ```
|
||||
*/
|
||||
declare function objectMap<K extends string, V, NK extends string | number | symbol = K, NV = V>(obj: Record<K, V>, fn: (key: K, value: V) => [NK, NV] | undefined): Record<NK, NV>;
|
||||
/**
|
||||
* Type guard for any key, `k`.
|
||||
* Marks `k` as a key of `T` if `k` is in `obj`.
|
||||
*
|
||||
* @category Object
|
||||
* @param obj object to query for key `k`
|
||||
* @param k key to check existence in `obj`
|
||||
*/
|
||||
declare function isKeyOf<T extends object>(obj: T, k: keyof any): k is keyof T;
|
||||
/**
|
||||
* Strict typed `Object.keys`
|
||||
*
|
||||
* @category Object
|
||||
*/
|
||||
declare function objectKeys<T extends object>(obj: T): Array<`${keyof T & (string | number | boolean | null | undefined)}`>;
|
||||
/**
|
||||
* Strict typed `Object.entries`
|
||||
*
|
||||
* @category Object
|
||||
*/
|
||||
declare function objectEntries<T extends object>(obj: T): Array<[keyof T, T[keyof T]]>;
|
||||
/**
|
||||
* Deep merge
|
||||
*
|
||||
* The first argument is the target object, the rest are the sources.
|
||||
* The target object will be mutated and returned.
|
||||
*
|
||||
* @category Object
|
||||
*/
|
||||
declare function deepMerge<T extends object = object, S extends object = T>(target: T, ...sources: S[]): DeepMerge<T, S>;
|
||||
/**
|
||||
* Deep merge
|
||||
*
|
||||
* Differs from `deepMerge` in that it merges arrays instead of overriding them.
|
||||
*
|
||||
* The first argument is the target object, the rest are the sources.
|
||||
* The target object will be mutated and returned.
|
||||
*
|
||||
* @category Object
|
||||
*/
|
||||
declare function deepMergeWithArray<T extends object = object, S extends object = T>(target: T, ...sources: S[]): DeepMerge<T, S>;
|
||||
/**
|
||||
* Create a new subset object by giving keys
|
||||
*
|
||||
* @category Object
|
||||
*/
|
||||
declare function objectPick<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Pick<O, T>;
|
||||
/**
|
||||
* Clear undefined fields from an object. It mutates the object
|
||||
*
|
||||
* @category Object
|
||||
*/
|
||||
declare function clearUndefined<T extends object>(obj: T): T;
|
||||
/**
|
||||
* Determines whether an object has a property with the specified name
|
||||
*
|
||||
* @see https://eslint.org/docs/rules/no-prototype-builtins
|
||||
* @category Object
|
||||
*/
|
||||
declare function hasOwnProperty<T>(obj: T, v: PropertyKey): boolean;
|
||||
/**
|
||||
* Get an object's unique identifier
|
||||
*
|
||||
* Same object will always return the same id
|
||||
*
|
||||
* Expect argument to be a non-primitive object/array. Primitive values will be returned as is.
|
||||
*
|
||||
* @category Object
|
||||
*/
|
||||
declare function objectId(obj: WeakKey): string;
|
||||
|
||||
interface POptions {
|
||||
/**
|
||||
* How many promises are resolved at the same time.
|
||||
*/
|
||||
concurrency?: number | undefined;
|
||||
}
|
||||
declare class PInstance<T = any> extends Promise<Awaited<T>[]> {
|
||||
items: Iterable<T>;
|
||||
options?: POptions | undefined;
|
||||
private promises;
|
||||
get promise(): Promise<Awaited<T>[]>;
|
||||
constructor(items?: Iterable<T>, options?: POptions | undefined);
|
||||
add(...args: (T | Promise<T>)[]): void;
|
||||
map<U>(fn: (value: Awaited<T>, index: number) => U): PInstance<Promise<U>>;
|
||||
filter(fn: (value: Awaited<T>, index: number) => boolean | Promise<boolean>): PInstance<Promise<T>>;
|
||||
forEach(fn: (value: Awaited<T>, index: number) => void): Promise<void>;
|
||||
reduce<U>(fn: (previousValue: U, currentValue: Awaited<T>, currentIndex: number, array: Awaited<T>[]) => U, initialValue: U): Promise<U>;
|
||||
clear(): void;
|
||||
then<TResult1 = Awaited<T>[], TResult2 = never>(onfulfilled?: ((value: Awaited<T>[]) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
||||
catch(fn?: (err: unknown) => PromiseLike<any>): Promise<any>;
|
||||
finally(fn?: () => void): Promise<Awaited<T>[]>;
|
||||
}
|
||||
/**
|
||||
* Utility for managing multiple promises.
|
||||
*
|
||||
* @see https://github.com/antfu/utils/tree/main/docs/p.md
|
||||
* @category Promise
|
||||
* @example
|
||||
* ```
|
||||
* import { p } from '@antfu/utils'
|
||||
*
|
||||
* const items = [1, 2, 3, 4, 5]
|
||||
*
|
||||
* await p(items)
|
||||
* .map(async i => await multiply(i, 3))
|
||||
* .filter(async i => await isEven(i))
|
||||
* // [6, 12]
|
||||
* ```
|
||||
*/
|
||||
declare function p<T = any>(items?: Iterable<T>, options?: POptions): PInstance<T>;
|
||||
|
||||
interface SingletonPromiseReturn<T> {
|
||||
(): Promise<T>;
|
||||
/**
|
||||
* Reset current staled promise.
|
||||
* Await it to have proper shutdown.
|
||||
*/
|
||||
reset: () => Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Create singleton promise function
|
||||
*
|
||||
* @category Promise
|
||||
*/
|
||||
declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>;
|
||||
/**
|
||||
* Promised `setTimeout`
|
||||
*
|
||||
* @category Promise
|
||||
*/
|
||||
declare function sleep(ms: number, callback?: Fn<any>): Promise<void>;
|
||||
/**
|
||||
* Create a promise lock
|
||||
*
|
||||
* @category Promise
|
||||
* @example
|
||||
* ```
|
||||
* const lock = createPromiseLock()
|
||||
*
|
||||
* lock.run(async () => {
|
||||
* await doSomething()
|
||||
* })
|
||||
*
|
||||
* // in anther context:
|
||||
* await lock.wait() // it will wait all tasking finished
|
||||
* ```
|
||||
*/
|
||||
declare function createPromiseLock(): {
|
||||
run<T = void>(fn: () => Promise<T>): Promise<T>;
|
||||
wait(): Promise<void>;
|
||||
isWaiting(): boolean;
|
||||
clear(): void;
|
||||
};
|
||||
/**
|
||||
* Promise with `resolve` and `reject` methods of itself
|
||||
*/
|
||||
interface ControlledPromise<T = void> extends Promise<T> {
|
||||
resolve: (value: T | PromiseLike<T>) => void;
|
||||
reject: (reason?: any) => void;
|
||||
}
|
||||
/**
|
||||
* Return a Promise with `resolve` and `reject` methods
|
||||
*
|
||||
* @category Promise
|
||||
* @example
|
||||
* ```
|
||||
* const promise = createControlledPromise()
|
||||
*
|
||||
* await promise
|
||||
*
|
||||
* // in anther context:
|
||||
* promise.resolve(data)
|
||||
* ```
|
||||
*/
|
||||
declare function createControlledPromise<T>(): ControlledPromise<T>;
|
||||
|
||||
/**
|
||||
* Replace backslash to slash
|
||||
*
|
||||
* @category String
|
||||
*/
|
||||
declare function slash(str: string): string;
|
||||
/**
|
||||
* Ensure prefix of a string
|
||||
*
|
||||
* @category String
|
||||
*/
|
||||
declare function ensurePrefix(prefix: string, str: string): string;
|
||||
/**
|
||||
* Ensure suffix of a string
|
||||
*
|
||||
* @category String
|
||||
*/
|
||||
declare function ensureSuffix(suffix: string, str: string): string;
|
||||
/**
|
||||
* Dead simple template engine, just like Python's `.format()`
|
||||
* Support passing variables as either in index based or object/name based approach
|
||||
* While using object/name based approach, you can pass a fallback value as the third argument
|
||||
*
|
||||
* @category String
|
||||
* @example
|
||||
* ```
|
||||
* const result = template(
|
||||
* 'Hello {0}! My name is {1}.',
|
||||
* 'Inès',
|
||||
* 'Anthony'
|
||||
* ) // Hello Inès! My name is Anthony.
|
||||
* ```
|
||||
*
|
||||
* ```
|
||||
* const result = namedTemplate(
|
||||
* '{greet}! My name is {name}.',
|
||||
* { greet: 'Hello', name: 'Anthony' }
|
||||
* ) // Hello! My name is Anthony.
|
||||
* ```
|
||||
*
|
||||
* const result = namedTemplate(
|
||||
* '{greet}! My name is {name}.',
|
||||
* { greet: 'Hello' }, // name isn't passed hence fallback will be used for name
|
||||
* 'placeholder'
|
||||
* ) // Hello! My name is placeholder.
|
||||
* ```
|
||||
*/
|
||||
declare function template(str: string, object: Record<string | number, any>, fallback?: string | ((key: string) => string)): string;
|
||||
declare function template(str: string, ...args: (string | number | bigint | undefined | null)[]): string;
|
||||
/**
|
||||
* Generate a random string
|
||||
* @category String
|
||||
*/
|
||||
declare function randomStr(size?: number, dict?: string): string;
|
||||
/**
|
||||
* First letter uppercase, other lowercase
|
||||
* @category string
|
||||
* @example
|
||||
* ```
|
||||
* capitalize('hello') => 'Hello'
|
||||
* ```
|
||||
*/
|
||||
declare function capitalize(str: string): string;
|
||||
/**
|
||||
* Remove common leading whitespace from a template string.
|
||||
* Will also remove empty lines at the beginning and end.
|
||||
* @category string
|
||||
* @example
|
||||
* ```ts
|
||||
* const str = unindent`
|
||||
* if (a) {
|
||||
* b()
|
||||
* }
|
||||
* `
|
||||
*/
|
||||
declare function unindent(str: TemplateStringsArray | string): string;
|
||||
|
||||
declare const timestamp: () => number;
|
||||
|
||||
interface CancelOptions {
|
||||
upcomingOnly?: boolean;
|
||||
}
|
||||
interface ReturnWithCancel<T extends (...args: any[]) => any> {
|
||||
(...args: Parameters<T>): void;
|
||||
cancel: (options?: CancelOptions) => void;
|
||||
}
|
||||
declare function throttle<T extends (...args: any[]) => any>(...args: any[]): ReturnWithCancel<T>;
|
||||
declare function debounce<T extends (...args: any[]) => any>(...args: any[]): ReturnWithCancel<T>;
|
||||
|
||||
export { assert, at, batchInvoke, capitalize, clamp, clampArrayRange, clearUndefined, createControlledPromise, createPromiseLock, createSingletonPromise, debounce, deepMerge, deepMergeWithArray, ensurePrefix, ensureSuffix, filterInPlace, flattenArrayable, getTypeName, hasOwnProperty, invoke, isBoolean, isBrowser, isDate, isDeepEqual, isDef, isFunction, isKeyOf, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isTruthy, isUndefined, isWindow, last, lerp, mergeArrayable, move, noNull, noop, notNullish, notUndefined, objectEntries, objectId, objectKeys, objectMap, objectPick, p, partition, randomStr, range, remap, remove, sample, shuffle, slash, sleep, sum, tap, template, throttle, timestamp, toArray, toString, unindent, uniq, uniqueBy };
|
||||
export type { ArgumentsType, Arrayable, Awaitable, Constructor, ControlledPromise, DeepMerge, ElementOf, Fn, MergeInsertions, Nullable, PartitionFilter, SingletonPromiseReturn, UnionToIntersection };
|
||||
837
node_modules/@antfu/utils/dist/index.mjs
generated
vendored
837
node_modules/@antfu/utils/dist/index.mjs
generated
vendored
@@ -1,837 +0,0 @@
|
||||
function clamp(n, min, max) {
|
||||
return Math.min(max, Math.max(min, n));
|
||||
}
|
||||
function sum(...args) {
|
||||
return flattenArrayable(args).reduce((a, b) => a + b, 0);
|
||||
}
|
||||
function lerp(min, max, t) {
|
||||
const interpolation = clamp(t, 0, 1);
|
||||
return min + (max - min) * interpolation;
|
||||
}
|
||||
function remap(n, inMin, inMax, outMin, outMax) {
|
||||
const interpolation = (n - inMin) / (inMax - inMin);
|
||||
return lerp(outMin, outMax, interpolation);
|
||||
}
|
||||
|
||||
function toArray(array) {
|
||||
array = array ?? [];
|
||||
return Array.isArray(array) ? array : [array];
|
||||
}
|
||||
function flattenArrayable(array) {
|
||||
return toArray(array).flat(1);
|
||||
}
|
||||
function mergeArrayable(...args) {
|
||||
return args.flatMap((i) => toArray(i));
|
||||
}
|
||||
function partition(array, ...filters) {
|
||||
const result = Array.from({ length: filters.length + 1 }).fill(null).map(() => []);
|
||||
array.forEach((e, idx, arr) => {
|
||||
let i = 0;
|
||||
for (const filter of filters) {
|
||||
if (filter(e, idx, arr)) {
|
||||
result[i].push(e);
|
||||
return;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
result[i].push(e);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
function uniq(array) {
|
||||
return Array.from(new Set(array));
|
||||
}
|
||||
function uniqueBy(array, equalFn) {
|
||||
return array.reduce((acc, cur) => {
|
||||
const index = acc.findIndex((item) => equalFn(cur, item));
|
||||
if (index === -1)
|
||||
acc.push(cur);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
function last(array) {
|
||||
return at(array, -1);
|
||||
}
|
||||
function remove(array, value) {
|
||||
if (!array)
|
||||
return false;
|
||||
const index = array.indexOf(value);
|
||||
if (index >= 0) {
|
||||
array.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function at(array, index) {
|
||||
const len = array.length;
|
||||
if (!len)
|
||||
return void 0;
|
||||
if (index < 0)
|
||||
index += len;
|
||||
return array[index];
|
||||
}
|
||||
function range(...args) {
|
||||
let start, stop, step;
|
||||
if (args.length === 1) {
|
||||
start = 0;
|
||||
step = 1;
|
||||
[stop] = args;
|
||||
} else {
|
||||
[start, stop, step = 1] = args;
|
||||
}
|
||||
const arr = [];
|
||||
let current = start;
|
||||
while (current < stop) {
|
||||
arr.push(current);
|
||||
current += step || 1;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
function move(arr, from, to) {
|
||||
arr.splice(to, 0, arr.splice(from, 1)[0]);
|
||||
return arr;
|
||||
}
|
||||
function clampArrayRange(n, arr) {
|
||||
return clamp(n, 0, arr.length - 1);
|
||||
}
|
||||
function sample(arr, quantity) {
|
||||
return Array.from({ length: quantity }, (_) => arr[Math.round(Math.random() * (arr.length - 1))]);
|
||||
}
|
||||
function shuffle(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
function filterInPlace(array, predicate) {
|
||||
for (let i = array.length; i--; i >= 0) {
|
||||
if (!predicate(array[i], i, array))
|
||||
array.splice(i, 1);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
function assert(condition, message) {
|
||||
if (!condition)
|
||||
throw new Error(message);
|
||||
}
|
||||
const toString = (v) => Object.prototype.toString.call(v);
|
||||
function getTypeName(v) {
|
||||
if (v === null)
|
||||
return "null";
|
||||
const type = toString(v).slice(8, -1).toLowerCase();
|
||||
return typeof v === "object" || typeof v === "function" ? type : typeof v;
|
||||
}
|
||||
function noop() {
|
||||
}
|
||||
|
||||
function isDeepEqual(value1, value2) {
|
||||
const type1 = getTypeName(value1);
|
||||
const type2 = getTypeName(value2);
|
||||
if (type1 !== type2)
|
||||
return false;
|
||||
if (type1 === "array") {
|
||||
if (value1.length !== value2.length)
|
||||
return false;
|
||||
return value1.every((item, i) => {
|
||||
return isDeepEqual(item, value2[i]);
|
||||
});
|
||||
}
|
||||
if (type1 === "object") {
|
||||
const keyArr = Object.keys(value1);
|
||||
if (keyArr.length !== Object.keys(value2).length)
|
||||
return false;
|
||||
return keyArr.every((key) => {
|
||||
return isDeepEqual(value1[key], value2[key]);
|
||||
});
|
||||
}
|
||||
return Object.is(value1, value2);
|
||||
}
|
||||
|
||||
function batchInvoke(functions) {
|
||||
functions.forEach((fn) => fn && fn());
|
||||
}
|
||||
function invoke(fn) {
|
||||
return fn();
|
||||
}
|
||||
function tap(value, callback) {
|
||||
callback(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
function notNullish(v) {
|
||||
return v != null;
|
||||
}
|
||||
function noNull(v) {
|
||||
return v !== null;
|
||||
}
|
||||
function notUndefined(v) {
|
||||
return v !== void 0;
|
||||
}
|
||||
function isTruthy(v) {
|
||||
return Boolean(v);
|
||||
}
|
||||
|
||||
const isDef = (val) => typeof val !== "undefined";
|
||||
const isBoolean = (val) => typeof val === "boolean";
|
||||
const isFunction = (val) => typeof val === "function";
|
||||
const isNumber = (val) => typeof val === "number";
|
||||
const isString = (val) => typeof val === "string";
|
||||
const isObject = (val) => toString(val) === "[object Object]";
|
||||
const isUndefined = (val) => toString(val) === "[object Undefined]";
|
||||
const isNull = (val) => toString(val) === "[object Null]";
|
||||
const isRegExp = (val) => toString(val) === "[object RegExp]";
|
||||
const isDate = (val) => toString(val) === "[object Date]";
|
||||
function isPrimitive(val) {
|
||||
return !val || Object(val) !== val;
|
||||
}
|
||||
const isWindow = (val) => typeof window !== "undefined" && toString(val) === "[object Window]";
|
||||
const isBrowser = typeof window !== "undefined";
|
||||
|
||||
function slash(str) {
|
||||
return str.replace(/\\/g, "/");
|
||||
}
|
||||
function ensurePrefix(prefix, str) {
|
||||
if (!str.startsWith(prefix))
|
||||
return prefix + str;
|
||||
return str;
|
||||
}
|
||||
function ensureSuffix(suffix, str) {
|
||||
if (!str.endsWith(suffix))
|
||||
return str + suffix;
|
||||
return str;
|
||||
}
|
||||
function template(str, ...args) {
|
||||
const [firstArg, fallback] = args;
|
||||
if (isObject(firstArg)) {
|
||||
const vars = firstArg;
|
||||
return str.replace(/\{(\w+)\}/g, (_, key) => vars[key] || ((typeof fallback === "function" ? fallback(key) : fallback) ?? key));
|
||||
} else {
|
||||
return str.replace(/\{(\d+)\}/g, (_, key) => {
|
||||
const index = Number(key);
|
||||
if (Number.isNaN(index))
|
||||
return key;
|
||||
return args[index];
|
||||
});
|
||||
}
|
||||
}
|
||||
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
||||
function randomStr(size = 16, dict = urlAlphabet) {
|
||||
let id = "";
|
||||
let i = size;
|
||||
const len = dict.length;
|
||||
while (i--)
|
||||
id += dict[Math.random() * len | 0];
|
||||
return id;
|
||||
}
|
||||
function capitalize(str) {
|
||||
return str[0].toUpperCase() + str.slice(1).toLowerCase();
|
||||
}
|
||||
const _reFullWs = /^\s*$/;
|
||||
function unindent(str) {
|
||||
const lines = (typeof str === "string" ? str : str[0]).split("\n");
|
||||
const whitespaceLines = lines.map((line) => _reFullWs.test(line));
|
||||
const commonIndent = lines.reduce((min, line, idx) => {
|
||||
if (whitespaceLines[idx])
|
||||
return min;
|
||||
const indent = line.match(/^\s*/)?.[0].length;
|
||||
return indent === void 0 ? min : Math.min(min, indent);
|
||||
}, Number.POSITIVE_INFINITY);
|
||||
let emptyLinesHead = 0;
|
||||
while (emptyLinesHead < lines.length && whitespaceLines[emptyLinesHead])
|
||||
emptyLinesHead++;
|
||||
let emptyLinesTail = 0;
|
||||
while (emptyLinesTail < lines.length && whitespaceLines[lines.length - emptyLinesTail - 1])
|
||||
emptyLinesTail++;
|
||||
return lines.slice(emptyLinesHead, lines.length - emptyLinesTail).map((line) => line.slice(commonIndent)).join("\n");
|
||||
}
|
||||
|
||||
function objectMap(obj, fn) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(obj).map(([k, v]) => fn(k, v)).filter(notNullish)
|
||||
);
|
||||
}
|
||||
function isKeyOf(obj, k) {
|
||||
return k in obj;
|
||||
}
|
||||
function objectKeys(obj) {
|
||||
return Object.keys(obj);
|
||||
}
|
||||
function objectEntries(obj) {
|
||||
return Object.entries(obj);
|
||||
}
|
||||
function deepMerge(target, ...sources) {
|
||||
if (!sources.length)
|
||||
return target;
|
||||
const source = sources.shift();
|
||||
if (source === void 0)
|
||||
return target;
|
||||
if (isMergableObject(target) && isMergableObject(source)) {
|
||||
objectKeys(source).forEach((key) => {
|
||||
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
||||
return;
|
||||
if (isMergableObject(source[key])) {
|
||||
if (!target[key])
|
||||
target[key] = {};
|
||||
if (isMergableObject(target[key])) {
|
||||
deepMerge(target[key], source[key]);
|
||||
} else {
|
||||
target[key] = source[key];
|
||||
}
|
||||
} else {
|
||||
target[key] = source[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
return deepMerge(target, ...sources);
|
||||
}
|
||||
function deepMergeWithArray(target, ...sources) {
|
||||
if (!sources.length)
|
||||
return target;
|
||||
const source = sources.shift();
|
||||
if (source === void 0)
|
||||
return target;
|
||||
if (Array.isArray(target) && Array.isArray(source))
|
||||
target.push(...source);
|
||||
if (isMergableObject(target) && isMergableObject(source)) {
|
||||
objectKeys(source).forEach((key) => {
|
||||
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
||||
return;
|
||||
if (Array.isArray(source[key])) {
|
||||
if (!target[key])
|
||||
target[key] = [];
|
||||
deepMergeWithArray(target[key], source[key]);
|
||||
} else if (isMergableObject(source[key])) {
|
||||
if (!target[key])
|
||||
target[key] = {};
|
||||
deepMergeWithArray(target[key], source[key]);
|
||||
} else {
|
||||
target[key] = source[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
return deepMergeWithArray(target, ...sources);
|
||||
}
|
||||
function isMergableObject(item) {
|
||||
return isObject(item) && !Array.isArray(item);
|
||||
}
|
||||
function objectPick(obj, keys, omitUndefined = false) {
|
||||
return keys.reduce((n, k) => {
|
||||
if (k in obj) {
|
||||
if (!omitUndefined || obj[k] !== void 0)
|
||||
n[k] = obj[k];
|
||||
}
|
||||
return n;
|
||||
}, {});
|
||||
}
|
||||
function clearUndefined(obj) {
|
||||
Object.keys(obj).forEach((key) => obj[key] === void 0 ? delete obj[key] : {});
|
||||
return obj;
|
||||
}
|
||||
function hasOwnProperty(obj, v) {
|
||||
if (obj == null)
|
||||
return false;
|
||||
return Object.prototype.hasOwnProperty.call(obj, v);
|
||||
}
|
||||
const _objectIdMap = /* @__PURE__ */ new WeakMap();
|
||||
function objectId(obj) {
|
||||
if (isPrimitive(obj))
|
||||
return obj;
|
||||
if (!_objectIdMap.has(obj)) {
|
||||
_objectIdMap.set(obj, randomStr());
|
||||
}
|
||||
return _objectIdMap.get(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
How it works:
|
||||
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
||||
*/
|
||||
|
||||
class Node {
|
||||
value;
|
||||
next;
|
||||
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
class Queue {
|
||||
#head;
|
||||
#tail;
|
||||
#size;
|
||||
|
||||
constructor() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
enqueue(value) {
|
||||
const node = new Node(value);
|
||||
|
||||
if (this.#head) {
|
||||
this.#tail.next = node;
|
||||
this.#tail = node;
|
||||
} else {
|
||||
this.#head = node;
|
||||
this.#tail = node;
|
||||
}
|
||||
|
||||
this.#size++;
|
||||
}
|
||||
|
||||
dequeue() {
|
||||
const current = this.#head;
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#head = this.#head.next;
|
||||
this.#size--;
|
||||
return current.value;
|
||||
}
|
||||
|
||||
peek() {
|
||||
if (!this.#head) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.#head.value;
|
||||
|
||||
// TODO: Node.js 18.
|
||||
// return this.#head?.value;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.#head = undefined;
|
||||
this.#tail = undefined;
|
||||
this.#size = 0;
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.#size;
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
let current = this.#head;
|
||||
|
||||
while (current) {
|
||||
yield current.value;
|
||||
current = current.next;
|
||||
}
|
||||
}
|
||||
|
||||
* drain() {
|
||||
while (this.#head) {
|
||||
yield this.dequeue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pLimit(concurrency) {
|
||||
validateConcurrency(concurrency);
|
||||
|
||||
const queue = new Queue();
|
||||
let activeCount = 0;
|
||||
|
||||
const resumeNext = () => {
|
||||
// Process the next queued function if we're under the concurrency limit
|
||||
if (activeCount < concurrency && queue.size > 0) {
|
||||
activeCount++;
|
||||
queue.dequeue()();
|
||||
}
|
||||
};
|
||||
|
||||
const next = () => {
|
||||
activeCount--;
|
||||
resumeNext();
|
||||
};
|
||||
|
||||
const run = async (function_, resolve, arguments_) => {
|
||||
// Execute the function and capture the result promise
|
||||
const result = (async () => function_(...arguments_))();
|
||||
|
||||
// Resolve immediately with the promise (don't wait for completion)
|
||||
resolve(result);
|
||||
|
||||
// Wait for the function to complete (success or failure)
|
||||
// We catch errors here to prevent unhandled rejections,
|
||||
// but the original promise rejection is preserved for the caller
|
||||
try {
|
||||
await result;
|
||||
} catch {}
|
||||
|
||||
// Decrement active count and process next queued function
|
||||
next();
|
||||
};
|
||||
|
||||
const enqueue = (function_, resolve, arguments_) => {
|
||||
// Queue the internal resolve function instead of the run function
|
||||
// to preserve the asynchronous execution context.
|
||||
new Promise(internalResolve => { // eslint-disable-line promise/param-names
|
||||
queue.enqueue(internalResolve);
|
||||
}).then(run.bind(undefined, function_, resolve, arguments_)); // eslint-disable-line promise/prefer-await-to-then
|
||||
|
||||
// Start processing immediately if we haven't reached the concurrency limit
|
||||
if (activeCount < concurrency) {
|
||||
resumeNext();
|
||||
}
|
||||
};
|
||||
|
||||
const generator = (function_, ...arguments_) => new Promise(resolve => {
|
||||
enqueue(function_, resolve, arguments_);
|
||||
});
|
||||
|
||||
Object.defineProperties(generator, {
|
||||
activeCount: {
|
||||
get: () => activeCount,
|
||||
},
|
||||
pendingCount: {
|
||||
get: () => queue.size,
|
||||
},
|
||||
clearQueue: {
|
||||
value() {
|
||||
queue.clear();
|
||||
},
|
||||
},
|
||||
concurrency: {
|
||||
get: () => concurrency,
|
||||
|
||||
set(newConcurrency) {
|
||||
validateConcurrency(newConcurrency);
|
||||
concurrency = newConcurrency;
|
||||
|
||||
queueMicrotask(() => {
|
||||
// eslint-disable-next-line no-unmodified-loop-condition
|
||||
while (activeCount < concurrency && queue.size > 0) {
|
||||
resumeNext();
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
map: {
|
||||
async value(array, function_) {
|
||||
const promises = array.map((value, index) => this(function_, value, index));
|
||||
return Promise.all(promises);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return generator;
|
||||
}
|
||||
|
||||
function validateConcurrency(concurrency) {
|
||||
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
||||
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
||||
}
|
||||
}
|
||||
|
||||
const VOID = Symbol("p-void");
|
||||
class PInstance extends Promise {
|
||||
constructor(items = [], options) {
|
||||
super(() => {
|
||||
});
|
||||
this.items = items;
|
||||
this.options = options;
|
||||
}
|
||||
promises = /* @__PURE__ */ new Set();
|
||||
get promise() {
|
||||
let batch;
|
||||
const items = [...Array.from(this.items), ...Array.from(this.promises)];
|
||||
if (this.options?.concurrency) {
|
||||
const limit = pLimit(this.options.concurrency);
|
||||
batch = Promise.all(items.map((p2) => limit(() => p2)));
|
||||
} else {
|
||||
batch = Promise.all(items);
|
||||
}
|
||||
return batch.then((l) => l.filter((i) => i !== VOID));
|
||||
}
|
||||
add(...args) {
|
||||
args.forEach((i) => {
|
||||
this.promises.add(i);
|
||||
});
|
||||
}
|
||||
map(fn) {
|
||||
return new PInstance(
|
||||
Array.from(this.items).map(async (i, idx) => {
|
||||
const v = await i;
|
||||
if (v === VOID)
|
||||
return VOID;
|
||||
return fn(v, idx);
|
||||
}),
|
||||
this.options
|
||||
);
|
||||
}
|
||||
filter(fn) {
|
||||
return new PInstance(
|
||||
Array.from(this.items).map(async (i, idx) => {
|
||||
const v = await i;
|
||||
const r = await fn(v, idx);
|
||||
if (!r)
|
||||
return VOID;
|
||||
return v;
|
||||
}),
|
||||
this.options
|
||||
);
|
||||
}
|
||||
forEach(fn) {
|
||||
return this.map(fn).then();
|
||||
}
|
||||
reduce(fn, initialValue) {
|
||||
return this.promise.then((array) => array.reduce(fn, initialValue));
|
||||
}
|
||||
clear() {
|
||||
this.promises.clear();
|
||||
}
|
||||
then(onfulfilled, onrejected) {
|
||||
return this.promise.then(onfulfilled, onrejected);
|
||||
}
|
||||
catch(fn) {
|
||||
return this.promise.catch(fn);
|
||||
}
|
||||
finally(fn) {
|
||||
return this.promise.finally(fn);
|
||||
}
|
||||
}
|
||||
function p(items, options) {
|
||||
return new PInstance(items, options);
|
||||
}
|
||||
|
||||
function createSingletonPromise(fn) {
|
||||
let _promise;
|
||||
function wrapper() {
|
||||
if (!_promise)
|
||||
_promise = fn();
|
||||
return _promise;
|
||||
}
|
||||
wrapper.reset = async () => {
|
||||
const _prev = _promise;
|
||||
_promise = void 0;
|
||||
if (_prev)
|
||||
await _prev;
|
||||
};
|
||||
return wrapper;
|
||||
}
|
||||
function sleep(ms, callback) {
|
||||
return new Promise(
|
||||
(resolve) => setTimeout(async () => {
|
||||
await callback?.();
|
||||
resolve();
|
||||
}, ms)
|
||||
);
|
||||
}
|
||||
function createPromiseLock() {
|
||||
const locks = [];
|
||||
return {
|
||||
async run(fn) {
|
||||
const p = fn();
|
||||
locks.push(p);
|
||||
try {
|
||||
return await p;
|
||||
} finally {
|
||||
remove(locks, p);
|
||||
}
|
||||
},
|
||||
async wait() {
|
||||
await Promise.allSettled(locks);
|
||||
},
|
||||
isWaiting() {
|
||||
return Boolean(locks.length);
|
||||
},
|
||||
clear() {
|
||||
locks.length = 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
function createControlledPromise() {
|
||||
let resolve, reject;
|
||||
const promise = new Promise((_resolve, _reject) => {
|
||||
resolve = _resolve;
|
||||
reject = _reject;
|
||||
});
|
||||
promise.resolve = resolve;
|
||||
promise.reject = reject;
|
||||
return promise;
|
||||
}
|
||||
|
||||
const timestamp = () => +Date.now();
|
||||
|
||||
/* eslint-disable no-undefined,no-param-reassign,no-shadow */
|
||||
|
||||
/**
|
||||
* Throttle execution of a function. Especially useful for rate limiting
|
||||
* execution of handlers on events like resize and scroll.
|
||||
*
|
||||
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
|
||||
* are most useful.
|
||||
* @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
|
||||
* as-is, to `callback` when the throttled-function is executed.
|
||||
* @param {object} [options] - An object to configure options.
|
||||
* @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
|
||||
* while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
|
||||
* one final time after the last throttled-function call. (After the throttled-function has not been called for
|
||||
* `delay` milliseconds, the internal counter is reset).
|
||||
* @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
|
||||
* immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
|
||||
* callback will never executed if both noLeading = true and noTrailing = true.
|
||||
* @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
|
||||
* false (at end), schedule `callback` to execute after `delay` ms.
|
||||
*
|
||||
* @returns {Function} A new, throttled, function.
|
||||
*/
|
||||
function throttle$1 (delay, callback, options) {
|
||||
var _ref = options || {},
|
||||
_ref$noTrailing = _ref.noTrailing,
|
||||
noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing,
|
||||
_ref$noLeading = _ref.noLeading,
|
||||
noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading,
|
||||
_ref$debounceMode = _ref.debounceMode,
|
||||
debounceMode = _ref$debounceMode === void 0 ? undefined : _ref$debounceMode;
|
||||
/*
|
||||
* After wrapper has stopped being called, this timeout ensures that
|
||||
* `callback` is executed at the proper times in `throttle` and `end`
|
||||
* debounce modes.
|
||||
*/
|
||||
|
||||
|
||||
var timeoutID;
|
||||
var cancelled = false; // Keep track of the last time `callback` was executed.
|
||||
|
||||
var lastExec = 0; // Function to clear existing timeout
|
||||
|
||||
function clearExistingTimeout() {
|
||||
if (timeoutID) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
} // Function to cancel next exec
|
||||
|
||||
|
||||
function cancel(options) {
|
||||
var _ref2 = options || {},
|
||||
_ref2$upcomingOnly = _ref2.upcomingOnly,
|
||||
upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly;
|
||||
|
||||
clearExistingTimeout();
|
||||
cancelled = !upcomingOnly;
|
||||
}
|
||||
/*
|
||||
* The `wrapper` function encapsulates all of the throttling / debouncing
|
||||
* functionality and when executed will limit the rate at which `callback`
|
||||
* is executed.
|
||||
*/
|
||||
|
||||
|
||||
function wrapper() {
|
||||
for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
arguments_[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var elapsed = Date.now() - lastExec;
|
||||
|
||||
if (cancelled) {
|
||||
return;
|
||||
} // Execute `callback` and update the `lastExec` timestamp.
|
||||
|
||||
|
||||
function exec() {
|
||||
lastExec = Date.now();
|
||||
callback.apply(self, arguments_);
|
||||
}
|
||||
/*
|
||||
* If `debounceMode` is true (at begin) this is used to clear the flag
|
||||
* to allow future `callback` executions.
|
||||
*/
|
||||
|
||||
|
||||
function clear() {
|
||||
timeoutID = undefined;
|
||||
}
|
||||
|
||||
if (!noLeading && debounceMode && !timeoutID) {
|
||||
/*
|
||||
* Since `wrapper` is being called for the first time and
|
||||
* `debounceMode` is true (at begin), execute `callback`
|
||||
* and noLeading != true.
|
||||
*/
|
||||
exec();
|
||||
}
|
||||
|
||||
clearExistingTimeout();
|
||||
|
||||
if (debounceMode === undefined && elapsed > delay) {
|
||||
if (noLeading) {
|
||||
/*
|
||||
* In throttle mode with noLeading, if `delay` time has
|
||||
* been exceeded, update `lastExec` and schedule `callback`
|
||||
* to execute after `delay` ms.
|
||||
*/
|
||||
lastExec = Date.now();
|
||||
|
||||
if (!noTrailing) {
|
||||
timeoutID = setTimeout(debounceMode ? clear : exec, delay);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* In throttle mode without noLeading, if `delay` time has been exceeded, execute
|
||||
* `callback`.
|
||||
*/
|
||||
exec();
|
||||
}
|
||||
} else if (noTrailing !== true) {
|
||||
/*
|
||||
* In trailing throttle mode, since `delay` time has not been
|
||||
* exceeded, schedule `callback` to execute `delay` ms after most
|
||||
* recent execution.
|
||||
*
|
||||
* If `debounceMode` is true (at begin), schedule `clear` to execute
|
||||
* after `delay` ms.
|
||||
*
|
||||
* If `debounceMode` is false (at end), schedule `callback` to
|
||||
* execute after `delay` ms.
|
||||
*/
|
||||
timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
|
||||
}
|
||||
}
|
||||
|
||||
wrapper.cancel = cancel; // Return the wrapper function.
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/* eslint-disable no-undefined */
|
||||
/**
|
||||
* Debounce execution of a function. Debouncing, unlike throttling,
|
||||
* guarantees that a function is only executed a single time, either at the
|
||||
* very beginning of a series of calls, or at the very end.
|
||||
*
|
||||
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
||||
* @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
||||
* to `callback` when the debounced-function is executed.
|
||||
* @param {object} [options] - An object to configure options.
|
||||
* @param {boolean} [options.atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
|
||||
* after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
|
||||
* (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
|
||||
*
|
||||
* @returns {Function} A new, debounced function.
|
||||
*/
|
||||
|
||||
function debounce$1 (delay, callback, options) {
|
||||
var _ref = options || {},
|
||||
_ref$atBegin = _ref.atBegin,
|
||||
atBegin = _ref$atBegin === void 0 ? false : _ref$atBegin;
|
||||
|
||||
return throttle$1(delay, callback, {
|
||||
debounceMode: atBegin !== false
|
||||
});
|
||||
}
|
||||
|
||||
function throttle(...args) {
|
||||
return throttle$1(...args);
|
||||
}
|
||||
function debounce(...args) {
|
||||
return debounce$1(...args);
|
||||
}
|
||||
|
||||
export { assert, at, batchInvoke, capitalize, clamp, clampArrayRange, clearUndefined, createControlledPromise, createPromiseLock, createSingletonPromise, debounce, deepMerge, deepMergeWithArray, ensurePrefix, ensureSuffix, filterInPlace, flattenArrayable, getTypeName, hasOwnProperty, invoke, isBoolean, isBrowser, isDate, isDeepEqual, isDef, isFunction, isKeyOf, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isTruthy, isUndefined, isWindow, last, lerp, mergeArrayable, move, noNull, noop, notNullish, notUndefined, objectEntries, objectId, objectKeys, objectMap, objectPick, p, partition, randomStr, range, remap, remove, sample, shuffle, slash, sleep, sum, tap, template, throttle, timestamp, toArray, toString, unindent, uniq, uniqueBy };
|
||||
55
node_modules/@antfu/utils/package.json
generated
vendored
55
node_modules/@antfu/utils/package.json
generated
vendored
@@ -1,55 +0,0 @@
|
||||
{
|
||||
"name": "@antfu/utils",
|
||||
"type": "module",
|
||||
"version": "9.2.1",
|
||||
"description": "Opinionated collection of common JavaScript / TypeScript utils by @antfu",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/antfu",
|
||||
"homepage": "https://github.com/antfu/utils#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/antfu/utils.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/antfu/utils/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"utils"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": "./dist/index.mjs"
|
||||
},
|
||||
"main": "dist/index.mjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.mts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^5.4.0",
|
||||
"@antfu/ni": "^26.0.1",
|
||||
"@types/node": "^24.5.2",
|
||||
"@types/throttle-debounce": "^5.0.2",
|
||||
"bumpp": "^10.2.3",
|
||||
"eslint": "^9.36.0",
|
||||
"p-limit": "^7.1.1",
|
||||
"throttle-debounce": "5.0.0",
|
||||
"tsx": "^4.20.5",
|
||||
"typescript": "^5.9.2",
|
||||
"unbuild": "^3.6.1",
|
||||
"vite": "^7.1.6",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "unbuild --stub",
|
||||
"lint": "eslint .",
|
||||
"lint-fix": "nr lint --fix",
|
||||
"release": "bumpp",
|
||||
"start": "tsx src/index.ts",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest"
|
||||
}
|
||||
}
|
||||
22
node_modules/@babel/code-frame/LICENSE
generated
vendored
22
node_modules/@babel/code-frame/LICENSE
generated
vendored
@@ -1,22 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
19
node_modules/@babel/code-frame/README.md
generated
vendored
19
node_modules/@babel/code-frame/README.md
generated
vendored
@@ -1,19 +0,0 @@
|
||||
# @babel/code-frame
|
||||
|
||||
> Generate errors that contain a code frame that point to source locations.
|
||||
|
||||
See our website [@babel/code-frame](https://babeljs.io/docs/babel-code-frame) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/code-frame
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/code-frame --dev
|
||||
```
|
||||
216
node_modules/@babel/code-frame/lib/index.js
generated
vendored
216
node_modules/@babel/code-frame/lib/index.js
generated
vendored
@@ -1,216 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var picocolors = require('picocolors');
|
||||
var jsTokens = require('js-tokens');
|
||||
var helperValidatorIdentifier = require('@babel/helper-validator-identifier');
|
||||
|
||||
function isColorSupported() {
|
||||
return (typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported
|
||||
);
|
||||
}
|
||||
const compose = (f, g) => v => f(g(v));
|
||||
function buildDefs(colors) {
|
||||
return {
|
||||
keyword: colors.cyan,
|
||||
capitalized: colors.yellow,
|
||||
jsxIdentifier: colors.yellow,
|
||||
punctuator: colors.yellow,
|
||||
number: colors.magenta,
|
||||
string: colors.green,
|
||||
regex: colors.magenta,
|
||||
comment: colors.gray,
|
||||
invalid: compose(compose(colors.white, colors.bgRed), colors.bold),
|
||||
gutter: colors.gray,
|
||||
marker: compose(colors.red, colors.bold),
|
||||
message: compose(colors.red, colors.bold),
|
||||
reset: colors.reset
|
||||
};
|
||||
}
|
||||
const defsOn = buildDefs(picocolors.createColors(true));
|
||||
const defsOff = buildDefs(picocolors.createColors(false));
|
||||
function getDefs(enabled) {
|
||||
return enabled ? defsOn : defsOff;
|
||||
}
|
||||
|
||||
const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
|
||||
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
|
||||
const BRACKET = /^[()[\]{}]$/;
|
||||
let tokenize;
|
||||
{
|
||||
const JSX_TAG = /^[a-z][\w-]*$/i;
|
||||
const getTokenType = function (token, offset, text) {
|
||||
if (token.type === "name") {
|
||||
if (helperValidatorIdentifier.isKeyword(token.value) || helperValidatorIdentifier.isStrictReservedWord(token.value, true) || sometimesKeywords.has(token.value)) {
|
||||
return "keyword";
|
||||
}
|
||||
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
|
||||
return "jsxIdentifier";
|
||||
}
|
||||
if (token.value[0] !== token.value[0].toLowerCase()) {
|
||||
return "capitalized";
|
||||
}
|
||||
}
|
||||
if (token.type === "punctuator" && BRACKET.test(token.value)) {
|
||||
return "bracket";
|
||||
}
|
||||
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
|
||||
return "punctuator";
|
||||
}
|
||||
return token.type;
|
||||
};
|
||||
tokenize = function* (text) {
|
||||
let match;
|
||||
while (match = jsTokens.default.exec(text)) {
|
||||
const token = jsTokens.matchToToken(match);
|
||||
yield {
|
||||
type: getTokenType(token, match.index, text),
|
||||
value: token.value
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
function highlight(text) {
|
||||
if (text === "") return "";
|
||||
const defs = getDefs(true);
|
||||
let highlighted = "";
|
||||
for (const {
|
||||
type,
|
||||
value
|
||||
} of tokenize(text)) {
|
||||
if (type in defs) {
|
||||
highlighted += value.split(NEWLINE$1).map(str => defs[type](str)).join("\n");
|
||||
} else {
|
||||
highlighted += value;
|
||||
}
|
||||
}
|
||||
return highlighted;
|
||||
}
|
||||
|
||||
let deprecationWarningShown = false;
|
||||
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
||||
function getMarkerLines(loc, source, opts) {
|
||||
const startLoc = Object.assign({
|
||||
column: 0,
|
||||
line: -1
|
||||
}, loc.start);
|
||||
const endLoc = Object.assign({}, startLoc, loc.end);
|
||||
const {
|
||||
linesAbove = 2,
|
||||
linesBelow = 3
|
||||
} = opts || {};
|
||||
const startLine = startLoc.line;
|
||||
const startColumn = startLoc.column;
|
||||
const endLine = endLoc.line;
|
||||
const endColumn = endLoc.column;
|
||||
let start = Math.max(startLine - (linesAbove + 1), 0);
|
||||
let end = Math.min(source.length, endLine + linesBelow);
|
||||
if (startLine === -1) {
|
||||
start = 0;
|
||||
}
|
||||
if (endLine === -1) {
|
||||
end = source.length;
|
||||
}
|
||||
const lineDiff = endLine - startLine;
|
||||
const markerLines = {};
|
||||
if (lineDiff) {
|
||||
for (let i = 0; i <= lineDiff; i++) {
|
||||
const lineNumber = i + startLine;
|
||||
if (!startColumn) {
|
||||
markerLines[lineNumber] = true;
|
||||
} else if (i === 0) {
|
||||
const sourceLength = source[lineNumber - 1].length;
|
||||
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
|
||||
} else if (i === lineDiff) {
|
||||
markerLines[lineNumber] = [0, endColumn];
|
||||
} else {
|
||||
const sourceLength = source[lineNumber - i].length;
|
||||
markerLines[lineNumber] = [0, sourceLength];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (startColumn === endColumn) {
|
||||
if (startColumn) {
|
||||
markerLines[startLine] = [startColumn, 0];
|
||||
} else {
|
||||
markerLines[startLine] = true;
|
||||
}
|
||||
} else {
|
||||
markerLines[startLine] = [startColumn, endColumn - startColumn];
|
||||
}
|
||||
}
|
||||
return {
|
||||
start,
|
||||
end,
|
||||
markerLines
|
||||
};
|
||||
}
|
||||
function codeFrameColumns(rawLines, loc, opts = {}) {
|
||||
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
|
||||
const defs = getDefs(shouldHighlight);
|
||||
const lines = rawLines.split(NEWLINE);
|
||||
const {
|
||||
start,
|
||||
end,
|
||||
markerLines
|
||||
} = getMarkerLines(loc, lines, opts);
|
||||
const hasColumns = loc.start && typeof loc.start.column === "number";
|
||||
const numberMaxWidth = String(end).length;
|
||||
const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
|
||||
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
|
||||
const number = start + 1 + index;
|
||||
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
||||
const gutter = ` ${paddedNumber} |`;
|
||||
const hasMarker = markerLines[number];
|
||||
const lastMarkerLine = !markerLines[number + 1];
|
||||
if (hasMarker) {
|
||||
let markerLine = "";
|
||||
if (Array.isArray(hasMarker)) {
|
||||
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
||||
const numberOfMarkers = hasMarker[1] || 1;
|
||||
markerLine = ["\n ", defs.gutter(gutter.replace(/\d/g, " ")), " ", markerSpacing, defs.marker("^").repeat(numberOfMarkers)].join("");
|
||||
if (lastMarkerLine && opts.message) {
|
||||
markerLine += " " + defs.message(opts.message);
|
||||
}
|
||||
}
|
||||
return [defs.marker(">"), defs.gutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
|
||||
} else {
|
||||
return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
|
||||
}
|
||||
}).join("\n");
|
||||
if (opts.message && !hasColumns) {
|
||||
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
||||
}
|
||||
if (shouldHighlight) {
|
||||
return defs.reset(frame);
|
||||
} else {
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
function index (rawLines, lineNumber, colNumber, opts = {}) {
|
||||
if (!deprecationWarningShown) {
|
||||
deprecationWarningShown = true;
|
||||
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
|
||||
if (process.emitWarning) {
|
||||
process.emitWarning(message, "DeprecationWarning");
|
||||
} else {
|
||||
const deprecationError = new Error(message);
|
||||
deprecationError.name = "DeprecationWarning";
|
||||
console.warn(new Error(message));
|
||||
}
|
||||
}
|
||||
colNumber = Math.max(colNumber, 0);
|
||||
const location = {
|
||||
start: {
|
||||
column: colNumber,
|
||||
line: lineNumber
|
||||
}
|
||||
};
|
||||
return codeFrameColumns(rawLines, location, opts);
|
||||
}
|
||||
|
||||
exports.codeFrameColumns = codeFrameColumns;
|
||||
exports.default = index;
|
||||
exports.highlight = highlight;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@babel/code-frame/lib/index.js.map
generated
vendored
1
node_modules/@babel/code-frame/lib/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
31
node_modules/@babel/code-frame/package.json
generated
vendored
31
node_modules/@babel/code-frame/package.json
generated
vendored
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "@babel/code-frame",
|
||||
"version": "7.27.1",
|
||||
"description": "Generate errors that contain a code frame that point to source locations.",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-code-frame",
|
||||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-code-frame"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-validator-identifier": "^7.27.1",
|
||||
"js-tokens": "^4.0.0",
|
||||
"picocolors": "^1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"import-meta-resolve": "^4.1.0",
|
||||
"strip-ansi": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"type": "commonjs"
|
||||
}
|
||||
22
node_modules/@babel/helper-validator-identifier/LICENSE
generated
vendored
22
node_modules/@babel/helper-validator-identifier/LICENSE
generated
vendored
@@ -1,22 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
19
node_modules/@babel/helper-validator-identifier/README.md
generated
vendored
19
node_modules/@babel/helper-validator-identifier/README.md
generated
vendored
@@ -1,19 +0,0 @@
|
||||
# @babel/helper-validator-identifier
|
||||
|
||||
> Validate identifier/keywords name
|
||||
|
||||
See our website [@babel/helper-validator-identifier](https://babeljs.io/docs/babel-helper-validator-identifier) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-validator-identifier
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-validator-identifier
|
||||
```
|
||||
70
node_modules/@babel/helper-validator-identifier/lib/identifier.js
generated
vendored
70
node_modules/@babel/helper-validator-identifier/lib/identifier.js
generated
vendored
@@ -1,70 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isIdentifierChar = isIdentifierChar;
|
||||
exports.isIdentifierName = isIdentifierName;
|
||||
exports.isIdentifierStart = isIdentifierStart;
|
||||
let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c8a\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7cd\ua7d0\ua7d1\ua7d3\ua7d5-\ua7dc\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
|
||||
let nonASCIIidentifierChars = "\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0897-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
|
||||
const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
||||
const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
||||
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
|
||||
const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 2, 60, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 42, 9, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 496, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191];
|
||||
const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 80, 3, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 343, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 726, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
||||
function isInAstralSet(code, set) {
|
||||
let pos = 0x10000;
|
||||
for (let i = 0, length = set.length; i < length; i += 2) {
|
||||
pos += set[i];
|
||||
if (pos > code) return false;
|
||||
pos += set[i + 1];
|
||||
if (pos >= code) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isIdentifierStart(code) {
|
||||
if (code < 65) return code === 36;
|
||||
if (code <= 90) return true;
|
||||
if (code < 97) return code === 95;
|
||||
if (code <= 122) return true;
|
||||
if (code <= 0xffff) {
|
||||
return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
|
||||
}
|
||||
return isInAstralSet(code, astralIdentifierStartCodes);
|
||||
}
|
||||
function isIdentifierChar(code) {
|
||||
if (code < 48) return code === 36;
|
||||
if (code < 58) return true;
|
||||
if (code < 65) return false;
|
||||
if (code <= 90) return true;
|
||||
if (code < 97) return code === 95;
|
||||
if (code <= 122) return true;
|
||||
if (code <= 0xffff) {
|
||||
return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
|
||||
}
|
||||
return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
|
||||
}
|
||||
function isIdentifierName(name) {
|
||||
let isFirst = true;
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
let cp = name.charCodeAt(i);
|
||||
if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
|
||||
const trail = name.charCodeAt(++i);
|
||||
if ((trail & 0xfc00) === 0xdc00) {
|
||||
cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
|
||||
}
|
||||
}
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
if (!isIdentifierStart(cp)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!isIdentifierChar(cp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !isFirst;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=identifier.js.map
|
||||
1
node_modules/@babel/helper-validator-identifier/lib/identifier.js.map
generated
vendored
1
node_modules/@babel/helper-validator-identifier/lib/identifier.js.map
generated
vendored
File diff suppressed because one or more lines are too long
57
node_modules/@babel/helper-validator-identifier/lib/index.js
generated
vendored
57
node_modules/@babel/helper-validator-identifier/lib/index.js
generated
vendored
@@ -1,57 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierChar", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierChar;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierName", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierName;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierStart", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierStart;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isKeyword", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isKeyword;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictBindOnlyReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictBindReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictBindReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictReservedWord;
|
||||
}
|
||||
});
|
||||
var _identifier = require("./identifier.js");
|
||||
var _keyword = require("./keyword.js");
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@babel/helper-validator-identifier/lib/index.js.map
generated
vendored
1
node_modules/@babel/helper-validator-identifier/lib/index.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"names":["_identifier","require","_keyword"],"sources":["../src/index.ts"],"sourcesContent":["export {\n isIdentifierName,\n isIdentifierChar,\n isIdentifierStart,\n} from \"./identifier.ts\";\nexport {\n isReservedWord,\n isStrictBindOnlyReservedWord,\n isStrictBindReservedWord,\n isStrictReservedWord,\n isKeyword,\n} from \"./keyword.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}
|
||||
35
node_modules/@babel/helper-validator-identifier/lib/keyword.js
generated
vendored
35
node_modules/@babel/helper-validator-identifier/lib/keyword.js
generated
vendored
@@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isKeyword = isKeyword;
|
||||
exports.isReservedWord = isReservedWord;
|
||||
exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
|
||||
exports.isStrictBindReservedWord = isStrictBindReservedWord;
|
||||
exports.isStrictReservedWord = isStrictReservedWord;
|
||||
const reservedWords = {
|
||||
keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
|
||||
strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
|
||||
strictBind: ["eval", "arguments"]
|
||||
};
|
||||
const keywords = new Set(reservedWords.keyword);
|
||||
const reservedWordsStrictSet = new Set(reservedWords.strict);
|
||||
const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
|
||||
function isReservedWord(word, inModule) {
|
||||
return inModule && word === "await" || word === "enum";
|
||||
}
|
||||
function isStrictReservedWord(word, inModule) {
|
||||
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
|
||||
}
|
||||
function isStrictBindOnlyReservedWord(word) {
|
||||
return reservedWordsStrictBindSet.has(word);
|
||||
}
|
||||
function isStrictBindReservedWord(word, inModule) {
|
||||
return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
|
||||
}
|
||||
function isKeyword(word) {
|
||||
return keywords.has(word);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=keyword.js.map
|
||||
1
node_modules/@babel/helper-validator-identifier/lib/keyword.js.map
generated
vendored
1
node_modules/@babel/helper-validator-identifier/lib/keyword.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"names":["reservedWords","keyword","strict","strictBind","keywords","Set","reservedWordsStrictSet","reservedWordsStrictBindSet","isReservedWord","word","inModule","isStrictReservedWord","has","isStrictBindOnlyReservedWord","isStrictBindReservedWord","isKeyword"],"sources":["../src/keyword.ts"],"sourcesContent":["const reservedWords = {\n keyword: [\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"return\",\n \"switch\",\n \"throw\",\n \"try\",\n \"var\",\n \"const\",\n \"while\",\n \"with\",\n \"new\",\n \"this\",\n \"super\",\n \"class\",\n \"extends\",\n \"export\",\n \"import\",\n \"null\",\n \"true\",\n \"false\",\n \"in\",\n \"instanceof\",\n \"typeof\",\n \"void\",\n \"delete\",\n ],\n strict: [\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n ],\n strictBind: [\"eval\", \"arguments\"],\n};\nconst keywords = new Set(reservedWords.keyword);\nconst reservedWordsStrictSet = new Set(reservedWords.strict);\nconst reservedWordsStrictBindSet = new Set(reservedWords.strictBind);\n\n/**\n * Checks if word is a reserved word in non-strict mode\n */\nexport function isReservedWord(word: string, inModule: boolean): boolean {\n return (inModule && word === \"await\") || word === \"enum\";\n}\n\n/**\n * Checks if word is a reserved word in non-binding strict mode\n *\n * Includes non-strict reserved words\n */\nexport function isStrictReservedWord(word: string, inModule: boolean): boolean {\n return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode, but it is allowed as\n * a normal identifier.\n */\nexport function isStrictBindOnlyReservedWord(word: string): boolean {\n return reservedWordsStrictBindSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode\n *\n * Includes non-strict reserved words and non-binding strict reserved words\n */\nexport function isStrictBindReservedWord(\n word: string,\n inModule: boolean,\n): boolean {\n return (\n isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word)\n );\n}\n\nexport function isKeyword(word: string): boolean {\n return keywords.has(word);\n}\n"],"mappings":";;;;;;;;;;AAAA,MAAMA,aAAa,GAAG;EACpBC,OAAO,EAAE,CACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,CACT;EACDC,MAAM,EAAE,CACN,YAAY,EACZ,WAAW,EACX,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,OAAO,CACR;EACDC,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW;AAClC,CAAC;AACD,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAACL,aAAa,CAACC,OAAO,CAAC;AAC/C,MAAMK,sBAAsB,GAAG,IAAID,GAAG,CAACL,aAAa,CAACE,MAAM,CAAC;AAC5D,MAAMK,0BAA0B,GAAG,IAAIF,GAAG,CAACL,aAAa,CAACG,UAAU,CAAC;AAK7D,SAASK,cAAcA,CAACC,IAAY,EAAEC,QAAiB,EAAW;EACvE,OAAQA,QAAQ,IAAID,IAAI,KAAK,OAAO,IAAKA,IAAI,KAAK,MAAM;AAC1D;AAOO,SAASE,oBAAoBA,CAACF,IAAY,EAAEC,QAAiB,EAAW;EAC7E,OAAOF,cAAc,CAACC,IAAI,EAAEC,QAAQ,CAAC,IAAIJ,sBAAsB,CAACM,GAAG,CAACH,IAAI,CAAC;AAC3E;AAMO,SAASI,4BAA4BA,CAACJ,IAAY,EAAW;EAClE,OAAOF,0BAA0B,CAACK,GAAG,CAACH,IAAI,CAAC;AAC7C;AAOO,SAASK,wBAAwBA,CACtCL,IAAY,EACZC,QAAiB,EACR;EACT,OACEC,oBAAoB,CAACF,IAAI,EAAEC,QAAQ,CAAC,IAAIG,4BAA4B,CAACJ,IAAI,CAAC;AAE9E;AAEO,SAASM,SAASA,CAACN,IAAY,EAAW;EAC/C,OAAOL,QAAQ,CAACQ,GAAG,CAACH,IAAI,CAAC;AAC3B","ignoreList":[]}
|
||||
31
node_modules/@babel/helper-validator-identifier/package.json
generated
vendored
31
node_modules/@babel/helper-validator-identifier/package.json
generated
vendored
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "@babel/helper-validator-identifier",
|
||||
"version": "7.27.1",
|
||||
"description": "Validate identifier/keywords name",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-helper-validator-identifier"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@unicode/unicode-16.0.0": "^1.0.0",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
2
node_modules/@braintree/sanitize-url/.eslintignore
generated
vendored
2
node_modules/@braintree/sanitize-url/.eslintignore
generated
vendored
@@ -1,2 +0,0 @@
|
||||
dist
|
||||
coverage
|
||||
6
node_modules/@braintree/sanitize-url/.eslintrc
generated
vendored
6
node_modules/@braintree/sanitize-url/.eslintrc
generated
vendored
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "braintree/client",
|
||||
"rules": {
|
||||
"no-control-regex": 0
|
||||
}
|
||||
}
|
||||
1
node_modules/@braintree/sanitize-url/.github/CODEOWNERS
generated
vendored
1
node_modules/@braintree/sanitize-url/.github/CODEOWNERS
generated
vendored
@@ -1 +0,0 @@
|
||||
* @braintree/team-sdk-js
|
||||
17
node_modules/@braintree/sanitize-url/.github/workflows/ci.yml
generated
vendored
17
node_modules/@braintree/sanitize-url/.github/workflows/ci.yml
generated
vendored
@@ -1,17 +0,0 @@
|
||||
name: "Unit Tests"
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: "Unit Tests on Ubuntu"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "18.x"
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
1
node_modules/@braintree/sanitize-url/.nvmrc
generated
vendored
1
node_modules/@braintree/sanitize-url/.nvmrc
generated
vendored
@@ -1 +0,0 @@
|
||||
v18
|
||||
3
node_modules/@braintree/sanitize-url/.prettierignore
generated
vendored
3
node_modules/@braintree/sanitize-url/.prettierignore
generated
vendored
@@ -1,3 +0,0 @@
|
||||
*-lock.json
|
||||
dist
|
||||
coverage
|
||||
142
node_modules/@braintree/sanitize-url/CHANGELOG.md
generated
vendored
142
node_modules/@braintree/sanitize-url/CHANGELOG.md
generated
vendored
@@ -1,142 +0,0 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 7.1.1
|
||||
|
||||
- DevDependency Changes
|
||||
|
||||
- happy-dom to 15.11.6
|
||||
|
||||
- Update (sub-)dependencies
|
||||
- cross-spawn to 7.0.6
|
||||
- micromatch to 4.0.8
|
||||
- vite to 4.5.5
|
||||
|
||||
## 7.1.0
|
||||
|
||||
- Updated to handle back-slashes
|
||||
|
||||
## 7.0.4
|
||||
|
||||
- Updates get-func-name to 2.0.2
|
||||
|
||||
## 7.0.3
|
||||
|
||||
- Dependencies
|
||||
- Update braces to 3.0.3
|
||||
|
||||
## 7.0.2
|
||||
|
||||
- Improve sanitization of whitespace escapes
|
||||
|
||||
## 7.0.1
|
||||
|
||||
- Improve sanitization of HTML entities
|
||||
|
||||
## 7.0.0
|
||||
|
||||
- Move constant declarations from index file to `constants.ts` file
|
||||
- Update to node v18
|
||||
|
||||
- Dev Dependency Updates
|
||||
- Update to TypeScript 5
|
||||
- Other minor dependency updates
|
||||
|
||||
## 6.0.4
|
||||
|
||||
- Add additional null byte sanitization prior to html decoding (#48)
|
||||
|
||||
## 6.0.3
|
||||
|
||||
- Add null check to beginning of `sanitizeUrl` function ([#54](https://github.com/braintree/sanitize-url/issues/54))
|
||||
|
||||
## 6.0.2
|
||||
|
||||
- Fix issue where urls in the form `https://example.com

/something` were not properly sanitized
|
||||
|
||||
## 6.0.1
|
||||
|
||||
- Fix issue where urls in the form `javascript:alert('xss');` were not properly sanitized
|
||||
- Fix issue where urls in the form `javasc	ript:alert('XSS');` were not properly sanitized
|
||||
|
||||
## 6.0.0
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
- Decode HTML characters automatically that would result in an XSS vulnerability when rendering links via a server rendered HTML file
|
||||
|
||||
```js
|
||||
// decodes to javacript:alert('XSS')
|
||||
const vulnerableUrl =
|
||||
"javascript:alert('XSS')";
|
||||
|
||||
sanitizeUrl(vulnerableUrl); // 'about:blank'
|
||||
|
||||
const okUrl = "https://example.com/" + vulnerableUrl;
|
||||
|
||||
// since the javascript bit is in the path instead of the protocol
|
||||
// this is successfully sanitized
|
||||
sanitizeUrl(okUrl); // 'https://example.com/javascript:alert('XSS');
|
||||
```
|
||||
|
||||
## 5.0.2
|
||||
|
||||
- Fix issue where certain invisible white space characters were not being sanitized (#35)
|
||||
|
||||
## 5.0.1
|
||||
|
||||
- Fix issue where certain safe characters were being filtered out (#31 thanks @akirchmyer)
|
||||
|
||||
## 5.0.0
|
||||
|
||||
_Breaking Changes_
|
||||
|
||||
- Sanitize vbscript urls (thanks @vicnicius)
|
||||
|
||||
## 4.1.1
|
||||
|
||||
- Fixup path to type declaration (closes #25)
|
||||
|
||||
## 4.1.0
|
||||
|
||||
- Add typescript types
|
||||
|
||||
## 4.0.1
|
||||
|
||||
- Fix issue where urls with accented characters were incorrectly sanitized
|
||||
|
||||
## 4.0.0
|
||||
|
||||
_Breaking Changes_
|
||||
|
||||
- Protocol-less urls (ie: www.example.com) will be sanitised and passed on instead of sending out `about:blank` (Thanks @chawes13 #18)
|
||||
|
||||
## 3.1.0
|
||||
|
||||
- Trim whitespace from urls
|
||||
|
||||
## 3.0.0
|
||||
|
||||
_breaking changes_
|
||||
|
||||
- Replace blank strings with about:blank
|
||||
- Replace null values with about:blank
|
||||
|
||||
## 2.1.0
|
||||
|
||||
- Allow relative urls to be sanitized
|
||||
|
||||
## 2.0.2
|
||||
|
||||
- Sanitize malicious URLs that begin with `\s`
|
||||
|
||||
## 2.0.1
|
||||
|
||||
- Sanitize malicious URLs that begin with %20
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- sanitize data: urls
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- sanitize javascript: urls
|
||||
21
node_modules/@braintree/sanitize-url/LICENSE
generated
vendored
21
node_modules/@braintree/sanitize-url/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Braintree
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
39
node_modules/@braintree/sanitize-url/README.md
generated
vendored
39
node_modules/@braintree/sanitize-url/README.md
generated
vendored
@@ -1,39 +0,0 @@
|
||||
# sanitize-url
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install -S @braintree/sanitize-url
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var sanitizeUrl = require("@braintree/sanitize-url").sanitizeUrl;
|
||||
|
||||
sanitizeUrl("https://example.com"); // 'https://example.com'
|
||||
sanitizeUrl("http://example.com"); // 'http://example.com'
|
||||
sanitizeUrl("www.example.com"); // 'www.example.com'
|
||||
sanitizeUrl("mailto:hello@example.com"); // 'mailto:hello@example.com'
|
||||
sanitizeUrl(
|
||||
"https://example.com"
|
||||
); // https://example.com
|
||||
|
||||
sanitizeUrl("javascript:alert(document.domain)"); // 'about:blank'
|
||||
sanitizeUrl("jAvasCrIPT:alert(document.domain)"); // 'about:blank'
|
||||
sanitizeUrl(decodeURIComponent("JaVaScRiP%0at:alert(document.domain)")); // 'about:blank'
|
||||
// HTML encoded javascript:alert('XSS')
|
||||
sanitizeUrl(
|
||||
"javascript:alert('XSS')"
|
||||
); // 'about:blank'
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
This library uses [Vitest](https://vitest.dev/). All testing dependencies
|
||||
will be installed upon `npm install` and the test suite can be executed with
|
||||
`npm test`. Running the test suite will also run lint checks upon exiting.
|
||||
|
||||
npm test
|
||||
|
||||
To generate a coverage report, use `npm run coverage`.
|
||||
8
node_modules/@braintree/sanitize-url/dist/constants.d.ts
generated
vendored
8
node_modules/@braintree/sanitize-url/dist/constants.d.ts
generated
vendored
@@ -1,8 +0,0 @@
|
||||
export declare const invalidProtocolRegex: RegExp;
|
||||
export declare const htmlEntitiesRegex: RegExp;
|
||||
export declare const htmlCtrlEntityRegex: RegExp;
|
||||
export declare const ctrlCharactersRegex: RegExp;
|
||||
export declare const urlSchemeRegex: RegExp;
|
||||
export declare const whitespaceEscapeCharsRegex: RegExp;
|
||||
export declare const relativeFirstCharacters: string[];
|
||||
export declare const BLANK_URL = "about:blank";
|
||||
11
node_modules/@braintree/sanitize-url/dist/constants.js
generated
vendored
11
node_modules/@braintree/sanitize-url/dist/constants.js
generated
vendored
@@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BLANK_URL = exports.relativeFirstCharacters = exports.whitespaceEscapeCharsRegex = exports.urlSchemeRegex = exports.ctrlCharactersRegex = exports.htmlCtrlEntityRegex = exports.htmlEntitiesRegex = exports.invalidProtocolRegex = void 0;
|
||||
exports.invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im;
|
||||
exports.htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g;
|
||||
exports.htmlCtrlEntityRegex = /&(newline|tab);/gi;
|
||||
exports.ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
|
||||
exports.urlSchemeRegex = /^.+(:|:)/gim;
|
||||
exports.whitespaceEscapeCharsRegex = /(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;
|
||||
exports.relativeFirstCharacters = [".", "/"];
|
||||
exports.BLANK_URL = "about:blank";
|
||||
1
node_modules/@braintree/sanitize-url/dist/index.d.ts
generated
vendored
1
node_modules/@braintree/sanitize-url/dist/index.d.ts
generated
vendored
@@ -1 +0,0 @@
|
||||
export declare function sanitizeUrl(url?: string): string;
|
||||
81
node_modules/@braintree/sanitize-url/dist/index.js
generated
vendored
81
node_modules/@braintree/sanitize-url/dist/index.js
generated
vendored
@@ -1,81 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sanitizeUrl = void 0;
|
||||
var constants_1 = require("./constants");
|
||||
function isRelativeUrlWithoutProtocol(url) {
|
||||
return constants_1.relativeFirstCharacters.indexOf(url[0]) > -1;
|
||||
}
|
||||
function decodeHtmlCharacters(str) {
|
||||
var removedNullByte = str.replace(constants_1.ctrlCharactersRegex, "");
|
||||
return removedNullByte.replace(constants_1.htmlEntitiesRegex, function (match, dec) {
|
||||
return String.fromCharCode(dec);
|
||||
});
|
||||
}
|
||||
function isValidUrl(url) {
|
||||
return URL.canParse(url);
|
||||
}
|
||||
function decodeURI(uri) {
|
||||
try {
|
||||
return decodeURIComponent(uri);
|
||||
}
|
||||
catch (e) {
|
||||
// Ignoring error
|
||||
// It is possible that the URI contains a `%` not associated
|
||||
// with URI/URL-encoding.
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
function sanitizeUrl(url) {
|
||||
if (!url) {
|
||||
return constants_1.BLANK_URL;
|
||||
}
|
||||
var charsToDecode;
|
||||
var decodedUrl = decodeURI(url.trim());
|
||||
do {
|
||||
decodedUrl = decodeHtmlCharacters(decodedUrl)
|
||||
.replace(constants_1.htmlCtrlEntityRegex, "")
|
||||
.replace(constants_1.ctrlCharactersRegex, "")
|
||||
.replace(constants_1.whitespaceEscapeCharsRegex, "")
|
||||
.trim();
|
||||
decodedUrl = decodeURI(decodedUrl);
|
||||
charsToDecode =
|
||||
decodedUrl.match(constants_1.ctrlCharactersRegex) ||
|
||||
decodedUrl.match(constants_1.htmlEntitiesRegex) ||
|
||||
decodedUrl.match(constants_1.htmlCtrlEntityRegex) ||
|
||||
decodedUrl.match(constants_1.whitespaceEscapeCharsRegex);
|
||||
} while (charsToDecode && charsToDecode.length > 0);
|
||||
var sanitizedUrl = decodedUrl;
|
||||
if (!sanitizedUrl) {
|
||||
return constants_1.BLANK_URL;
|
||||
}
|
||||
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
||||
return sanitizedUrl;
|
||||
}
|
||||
// Remove any leading whitespace before checking the URL scheme
|
||||
var trimmedUrl = sanitizedUrl.trimStart();
|
||||
var urlSchemeParseResults = trimmedUrl.match(constants_1.urlSchemeRegex);
|
||||
if (!urlSchemeParseResults) {
|
||||
return sanitizedUrl;
|
||||
}
|
||||
var urlScheme = urlSchemeParseResults[0].toLowerCase().trim();
|
||||
if (constants_1.invalidProtocolRegex.test(urlScheme)) {
|
||||
return constants_1.BLANK_URL;
|
||||
}
|
||||
var backSanitized = trimmedUrl.replace(/\\/g, "/");
|
||||
// Handle special cases for mailto: and custom deep-link protocols
|
||||
if (urlScheme === "mailto:" || urlScheme.includes("://")) {
|
||||
return backSanitized;
|
||||
}
|
||||
// For http and https URLs, perform additional validation
|
||||
if (urlScheme === "http:" || urlScheme === "https:") {
|
||||
if (!isValidUrl(backSanitized)) {
|
||||
return constants_1.BLANK_URL;
|
||||
}
|
||||
var url_1 = new URL(backSanitized);
|
||||
url_1.protocol = url_1.protocol.toLowerCase();
|
||||
url_1.hostname = url_1.hostname.toLowerCase();
|
||||
return url_1.toString();
|
||||
}
|
||||
return backSanitized;
|
||||
}
|
||||
exports.sanitizeUrl = sanitizeUrl;
|
||||
40
node_modules/@braintree/sanitize-url/package.json
generated
vendored
40
node_modules/@braintree/sanitize-url/package.json
generated
vendored
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"name": "@braintree/sanitize-url",
|
||||
"version": "7.1.1",
|
||||
"description": "A url sanitizer",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"author": "",
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm run build",
|
||||
"prebuild": "prettier --write .",
|
||||
"build": "tsc --declaration",
|
||||
"lint": "eslint --ext js,ts .",
|
||||
"posttest": "npm run lint",
|
||||
"test": "vitest",
|
||||
"coverage": "vitest run --coverage"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/braintree/sanitize-url.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/braintree/sanitize-url/issues"
|
||||
},
|
||||
"homepage": "https://github.com/braintree/sanitize-url#readme",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
||||
"@vitest/coverage-v8": "^0.34.2",
|
||||
"chai": "^4.3.7",
|
||||
"eslint": "^8.36.0",
|
||||
"eslint-config-braintree": "^6.0.0-typescript-prep-rc.2",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"happy-dom": "^15.11.6",
|
||||
"prettier": "^2.8.4",
|
||||
"typescript": "^5.1.6",
|
||||
"vitest": "^0.34.2"
|
||||
}
|
||||
}
|
||||
261
node_modules/@braintree/sanitize-url/src/__tests__/index.test.ts
generated
vendored
261
node_modules/@braintree/sanitize-url/src/__tests__/index.test.ts
generated
vendored
@@ -1,261 +0,0 @@
|
||||
/* eslint-disable no-script-url */
|
||||
import { sanitizeUrl } from "..";
|
||||
import { BLANK_URL } from "../constants";
|
||||
|
||||
describe("sanitizeUrl", () => {
|
||||
it("does not alter http URLs with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("http://example.com/path/to:something")).toBe(
|
||||
"http://example.com/path/to:something"
|
||||
);
|
||||
});
|
||||
|
||||
it("does not alter http URLs with ports with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("http://example.com:4567/path/to:something")).toBe(
|
||||
"http://example.com:4567/path/to:something"
|
||||
);
|
||||
});
|
||||
|
||||
it("does not alter https URLs with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("https://example.com")).toBe("https://example.com/");
|
||||
});
|
||||
|
||||
it("does not alter https URLs with ports with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("https://example.com:4567/path/to:something")).toBe(
|
||||
"https://example.com:4567/path/to:something"
|
||||
);
|
||||
});
|
||||
|
||||
it("does not alter relative-path reference URLs with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("./path/to/my.json")).toBe("./path/to/my.json");
|
||||
});
|
||||
|
||||
it("does not alter absolute-path reference URLs with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("/path/to/my.json")).toBe("/path/to/my.json");
|
||||
});
|
||||
|
||||
it("does not alter protocol-less network-path URLs with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("//google.com/robots.txt")).toBe(
|
||||
"//google.com/robots.txt"
|
||||
);
|
||||
});
|
||||
|
||||
it("does not alter protocol-less URLs with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("www.example.com")).toBe("www.example.com");
|
||||
});
|
||||
|
||||
it("does not alter deep-link urls with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("com.braintreepayments.demo://example")).toBe(
|
||||
"com.braintreepayments.demo://example"
|
||||
);
|
||||
});
|
||||
|
||||
it("does not alter mailto urls with alphanumeric characters", () => {
|
||||
expect(sanitizeUrl("mailto:test@example.com?subject=hello+world")).toBe(
|
||||
"mailto:test@example.com?subject=hello+world"
|
||||
);
|
||||
});
|
||||
|
||||
it("does not alter urls with accented characters", () => {
|
||||
expect(sanitizeUrl("www.example.com/with-áccêntš")).toBe(
|
||||
"www.example.com/with-áccêntš"
|
||||
);
|
||||
});
|
||||
|
||||
it("does not strip harmless unicode characters", () => {
|
||||
expect(sanitizeUrl("www.example.com/лот.рфшишкиü–")).toBe(
|
||||
"www.example.com/лот.рфшишкиü–"
|
||||
);
|
||||
});
|
||||
|
||||
it("strips out ctrl chars", () => {
|
||||
expect(
|
||||
sanitizeUrl("www.example.com/\u200D\u0000\u001F\x00\x1F\uFEFFfoo")
|
||||
).toBe("www.example.com/foo");
|
||||
});
|
||||
|
||||
it(`replaces blank urls with ${BLANK_URL}`, () => {
|
||||
expect(sanitizeUrl("")).toBe(BLANK_URL);
|
||||
});
|
||||
|
||||
it(`replaces null values with ${BLANK_URL}`, () => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
expect(sanitizeUrl(null)).toBe(BLANK_URL);
|
||||
});
|
||||
|
||||
it(`replaces undefined values with ${BLANK_URL}`, () => {
|
||||
expect(sanitizeUrl()).toBe(BLANK_URL);
|
||||
});
|
||||
|
||||
it("removes whitespace from urls", () => {
|
||||
expect(sanitizeUrl(" http://example.com/path/to:something ")).toBe(
|
||||
"http://example.com/path/to:something"
|
||||
);
|
||||
});
|
||||
|
||||
it("removes newline entities from urls", () => {
|
||||
expect(sanitizeUrl("https://example.com

/something")).toBe(
|
||||
"https://example.com/something"
|
||||
);
|
||||
});
|
||||
|
||||
it("decodes html entities", () => {
|
||||
// all these decode to javascript:alert('xss');
|
||||
const attackVectors = [
|
||||
"javascript:alert('XSS')",
|
||||
"javascript:alert('XSS')",
|
||||
"javascript:alert('XSS')",
|
||||
"jav	ascript:alert('XSS');",
|
||||
"  javascript:alert('XSS');",
|
||||
"javasc	ript: alert('XSS');",
|
||||
"javasc&#\u0000x09;ript:alert(1)",
|
||||
"java&&#78;ewLine&newline;;script:alert('XSS')",
|
||||
"java&NewLine&newline;;script:alert('XSS')",
|
||||
];
|
||||
|
||||
attackVectors.forEach((vector) => {
|
||||
expect(sanitizeUrl(vector)).toBe(BLANK_URL);
|
||||
});
|
||||
|
||||
// https://example.com/javascript:alert('XSS')
|
||||
// since the javascript is the url path, and not the protocol,
|
||||
// this url is technically sanitized
|
||||
expect(
|
||||
sanitizeUrl(
|
||||
"https://example.com/javascript:alert('XSS')"
|
||||
)
|
||||
).toBe("https://example.com/javascript:alert('XSS')");
|
||||
});
|
||||
|
||||
it("removes whitespace escape sequences", () => {
|
||||
const attackVectors = [
|
||||
"javascri\npt:alert('xss')",
|
||||
"javascri\rpt:alert('xss')",
|
||||
"javascri\tpt:alert('xss')",
|
||||
"javascrip\\%74t:alert('XSS')",
|
||||
"javascrip%5c%72t:alert()",
|
||||
"javascrip%5Ctt:alert()",
|
||||
"javascrip%255Ctt:alert()",
|
||||
"javascrip%25%35Ctt:alert()",
|
||||
"javascrip%25%35%43tt:alert()",
|
||||
"javascrip%25%32%35%25%33%35%25%34%33rt:alert()",
|
||||
"javascrip%255Crt:alert('%25xss')",
|
||||
];
|
||||
|
||||
attackVectors.forEach((vector) => {
|
||||
expect(sanitizeUrl(vector)).toBe(BLANK_URL);
|
||||
});
|
||||
});
|
||||
|
||||
it("backslash prefixed attack vectors", () => {
|
||||
const attackVectors = [
|
||||
"\fjavascript:alert()",
|
||||
"\vjavascript:alert()",
|
||||
"\tjavascript:alert()",
|
||||
"\njavascript:alert()",
|
||||
"\rjavascript:alert()",
|
||||
"\u0000javascript:alert()",
|
||||
"\u0001javascript:alert()",
|
||||
];
|
||||
|
||||
attackVectors.forEach((vector) => {
|
||||
expect(sanitizeUrl(vector)).toBe(BLANK_URL);
|
||||
});
|
||||
});
|
||||
|
||||
it("reverses backslashes", () => {
|
||||
const attack = "\\j\\av\\a\\s\\cript:alert()";
|
||||
|
||||
expect(sanitizeUrl(attack)).toBe("/j/av/a/s/cript:alert()");
|
||||
});
|
||||
|
||||
describe("invalid protocols", () => {
|
||||
describe.each(["javascript", "data", "vbscript"])("%s", (protocol) => {
|
||||
it(`replaces ${protocol} urls with ${BLANK_URL}`, () => {
|
||||
expect(sanitizeUrl(`${protocol}:alert(document.domain)`)).toBe(
|
||||
BLANK_URL
|
||||
);
|
||||
});
|
||||
|
||||
it(`allows ${protocol} urls that start with a letter prefix`, () => {
|
||||
expect(sanitizeUrl(`not_${protocol}:alert(document.domain)`)).toBe(
|
||||
`not_${protocol}:alert(document.domain)`
|
||||
);
|
||||
});
|
||||
|
||||
it(`disallows ${protocol} urls that start with non-\w characters as a suffix for the protocol`, () => {
|
||||
expect(sanitizeUrl(`&!*${protocol}:alert(document.domain)`)).toBe(
|
||||
BLANK_URL
|
||||
);
|
||||
});
|
||||
|
||||
it(`disallows ${protocol} urls that use : for the colon portion of the url`, () => {
|
||||
expect(sanitizeUrl(`${protocol}:alert(document.domain)`)).toBe(
|
||||
BLANK_URL
|
||||
);
|
||||
expect(sanitizeUrl(`${protocol}&COLON;alert(document.domain)`)).toBe(
|
||||
BLANK_URL
|
||||
);
|
||||
});
|
||||
|
||||
it(`disregards capitalization for ${protocol} urls`, () => {
|
||||
// upper case every other letter in protocol name
|
||||
const mixedCapitalizationProtocol = protocol
|
||||
.split("")
|
||||
.map((character, index) => {
|
||||
if (index % 2 === 0) {
|
||||
return character.toUpperCase();
|
||||
}
|
||||
return character;
|
||||
})
|
||||
.join("");
|
||||
|
||||
expect(
|
||||
sanitizeUrl(`${mixedCapitalizationProtocol}:alert(document.domain)`)
|
||||
).toBe(BLANK_URL);
|
||||
});
|
||||
|
||||
it(`ignores invisible ctrl characters in ${protocol} urls`, () => {
|
||||
const protocolWithControlCharacters = protocol
|
||||
.split("")
|
||||
.map((character, index) => {
|
||||
if (index === 1) {
|
||||
return character + "%EF%BB%BF%EF%BB%BF";
|
||||
} else if (index === 2) {
|
||||
return character + "%e2%80%8b";
|
||||
}
|
||||
return character;
|
||||
})
|
||||
.join("");
|
||||
|
||||
expect(
|
||||
sanitizeUrl(
|
||||
decodeURIComponent(
|
||||
`${protocolWithControlCharacters}:alert(document.domain)`
|
||||
)
|
||||
)
|
||||
).toBe(BLANK_URL);
|
||||
});
|
||||
|
||||
it(`replaces ${protocol} urls with ${BLANK_URL} when url begins with %20`, () => {
|
||||
expect(
|
||||
sanitizeUrl(
|
||||
decodeURIComponent(`%20%20%20%20${protocol}:alert(document.domain)`)
|
||||
)
|
||||
).toBe(BLANK_URL);
|
||||
});
|
||||
|
||||
it(`replaces ${protocol} urls with ${BLANK_URL} when ${protocol} url begins with spaces`, () => {
|
||||
expect(sanitizeUrl(` ${protocol}:alert(document.domain)`)).toBe(
|
||||
BLANK_URL
|
||||
);
|
||||
});
|
||||
|
||||
it(`does not replace ${protocol}: if it is not in the scheme of the URL`, () => {
|
||||
expect(sanitizeUrl(`http://example.com#${protocol}:foo`)).toBe(
|
||||
`http://example.com#${protocol}:foo`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
10
node_modules/@braintree/sanitize-url/src/constants.ts
generated
vendored
10
node_modules/@braintree/sanitize-url/src/constants.ts
generated
vendored
@@ -1,10 +0,0 @@
|
||||
export const invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im;
|
||||
export const htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g;
|
||||
export const htmlCtrlEntityRegex = /&(newline|tab);/gi;
|
||||
export const ctrlCharactersRegex =
|
||||
/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
|
||||
export const urlSchemeRegex = /^.+(:|:)/gim;
|
||||
export const whitespaceEscapeCharsRegex =
|
||||
/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;
|
||||
export const relativeFirstCharacters = [".", "/"];
|
||||
export const BLANK_URL = "about:blank";
|
||||
107
node_modules/@braintree/sanitize-url/src/index.ts
generated
vendored
107
node_modules/@braintree/sanitize-url/src/index.ts
generated
vendored
@@ -1,107 +0,0 @@
|
||||
import {
|
||||
BLANK_URL,
|
||||
ctrlCharactersRegex,
|
||||
htmlCtrlEntityRegex,
|
||||
htmlEntitiesRegex,
|
||||
invalidProtocolRegex,
|
||||
relativeFirstCharacters,
|
||||
whitespaceEscapeCharsRegex,
|
||||
urlSchemeRegex,
|
||||
} from "./constants";
|
||||
|
||||
function isRelativeUrlWithoutProtocol(url: string): boolean {
|
||||
return relativeFirstCharacters.indexOf(url[0]) > -1;
|
||||
}
|
||||
|
||||
function decodeHtmlCharacters(str: string) {
|
||||
const removedNullByte = str.replace(ctrlCharactersRegex, "");
|
||||
return removedNullByte.replace(htmlEntitiesRegex, (match, dec) => {
|
||||
return String.fromCharCode(dec);
|
||||
});
|
||||
}
|
||||
|
||||
function isValidUrl(url: string): boolean {
|
||||
return URL.canParse(url);
|
||||
}
|
||||
|
||||
function decodeURI(uri: string): string {
|
||||
try {
|
||||
return decodeURIComponent(uri);
|
||||
} catch (e: unknown) {
|
||||
// Ignoring error
|
||||
// It is possible that the URI contains a `%` not associated
|
||||
// with URI/URL-encoding.
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
||||
export function sanitizeUrl(url?: string): string {
|
||||
if (!url) {
|
||||
return BLANK_URL;
|
||||
}
|
||||
|
||||
let charsToDecode;
|
||||
let decodedUrl = decodeURI(url.trim());
|
||||
|
||||
do {
|
||||
decodedUrl = decodeHtmlCharacters(decodedUrl)
|
||||
.replace(htmlCtrlEntityRegex, "")
|
||||
.replace(ctrlCharactersRegex, "")
|
||||
.replace(whitespaceEscapeCharsRegex, "")
|
||||
.trim();
|
||||
|
||||
decodedUrl = decodeURI(decodedUrl);
|
||||
|
||||
charsToDecode =
|
||||
decodedUrl.match(ctrlCharactersRegex) ||
|
||||
decodedUrl.match(htmlEntitiesRegex) ||
|
||||
decodedUrl.match(htmlCtrlEntityRegex) ||
|
||||
decodedUrl.match(whitespaceEscapeCharsRegex);
|
||||
} while (charsToDecode && charsToDecode.length > 0);
|
||||
|
||||
const sanitizedUrl = decodedUrl;
|
||||
|
||||
if (!sanitizedUrl) {
|
||||
return BLANK_URL;
|
||||
}
|
||||
|
||||
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
||||
return sanitizedUrl;
|
||||
}
|
||||
|
||||
// Remove any leading whitespace before checking the URL scheme
|
||||
const trimmedUrl = sanitizedUrl.trimStart();
|
||||
const urlSchemeParseResults = trimmedUrl.match(urlSchemeRegex);
|
||||
|
||||
if (!urlSchemeParseResults) {
|
||||
return sanitizedUrl;
|
||||
}
|
||||
|
||||
const urlScheme = urlSchemeParseResults[0].toLowerCase().trim();
|
||||
|
||||
if (invalidProtocolRegex.test(urlScheme)) {
|
||||
return BLANK_URL;
|
||||
}
|
||||
|
||||
const backSanitized = trimmedUrl.replace(/\\/g, "/");
|
||||
|
||||
// Handle special cases for mailto: and custom deep-link protocols
|
||||
if (urlScheme === "mailto:" || urlScheme.includes("://")) {
|
||||
return backSanitized;
|
||||
}
|
||||
|
||||
// For http and https URLs, perform additional validation
|
||||
if (urlScheme === "http:" || urlScheme === "https:") {
|
||||
if (!isValidUrl(backSanitized)) {
|
||||
return BLANK_URL;
|
||||
}
|
||||
|
||||
const url = new URL(backSanitized);
|
||||
url.protocol = url.protocol.toLowerCase();
|
||||
url.hostname = url.hostname.toLowerCase();
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
return backSanitized;
|
||||
}
|
||||
12
node_modules/@braintree/sanitize-url/tsconfig.json
generated
vendored
12
node_modules/@braintree/sanitize-url/tsconfig.json
generated
vendored
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"allowJs": true,
|
||||
"strict": true,
|
||||
"target": "es5",
|
||||
"resolveJsonModule": true,
|
||||
"lib": ["es2015", "dom"]
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"exclude": ["**/__tests__/*"]
|
||||
}
|
||||
8
node_modules/@braintree/sanitize-url/vitest.config.ts
generated
vendored
8
node_modules/@braintree/sanitize-url/vitest.config.ts
generated
vendored
@@ -1,8 +0,0 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
environment: "happy-dom",
|
||||
},
|
||||
});
|
||||
202
node_modules/@chevrotain/cst-dts-gen/LICENSE.txt
generated
vendored
202
node_modules/@chevrotain/cst-dts-gen/LICENSE.txt
generated
vendored
@@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
2
node_modules/@chevrotain/cst-dts-gen/lib/src/api.d.ts
generated
vendored
2
node_modules/@chevrotain/cst-dts-gen/lib/src/api.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { GenerateDtsOptions, Rule } from "@chevrotain/types";
|
||||
export declare function generateCstDts(productions: Record<string, Rule>, options?: GenerateDtsOptions): string;
|
||||
12
node_modules/@chevrotain/cst-dts-gen/lib/src/api.js
generated
vendored
12
node_modules/@chevrotain/cst-dts-gen/lib/src/api.js
generated
vendored
@@ -1,12 +0,0 @@
|
||||
import { buildModel } from "./model.js";
|
||||
import { genDts } from "./generate.js";
|
||||
const defaultOptions = {
|
||||
includeVisitorInterface: true,
|
||||
visitorInterfaceName: "ICstNodeVisitor",
|
||||
};
|
||||
export function generateCstDts(productions, options) {
|
||||
const effectiveOptions = Object.assign(Object.assign({}, defaultOptions), options);
|
||||
const model = buildModel(productions);
|
||||
return genDts(model, effectiveOptions);
|
||||
}
|
||||
//# sourceMappingURL=api.js.map
|
||||
1
node_modules/@chevrotain/cst-dts-gen/lib/src/api.js.map
generated
vendored
1
node_modules/@chevrotain/cst-dts-gen/lib/src/api.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,MAAM,cAAc,GAAiC;IACnD,uBAAuB,EAAE,IAAI;IAC7B,oBAAoB,EAAE,iBAAiB;CACxC,CAAC;AAEF,MAAM,UAAU,cAAc,CAC5B,WAAiC,EACjC,OAA4B;IAE5B,MAAM,gBAAgB,mCACjB,cAAc,GACd,OAAO,CACX,CAAC;IAEF,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACzC,CAAC"}
|
||||
3
node_modules/@chevrotain/cst-dts-gen/lib/src/generate.d.ts
generated
vendored
3
node_modules/@chevrotain/cst-dts-gen/lib/src/generate.d.ts
generated
vendored
@@ -1,3 +0,0 @@
|
||||
import { GenerateDtsOptions } from "@chevrotain/types";
|
||||
import { CstNodeTypeDefinition } from "./model.js";
|
||||
export declare function genDts(model: CstNodeTypeDefinition[], options: Required<GenerateDtsOptions>): string;
|
||||
65
node_modules/@chevrotain/cst-dts-gen/lib/src/generate.js
generated
vendored
65
node_modules/@chevrotain/cst-dts-gen/lib/src/generate.js
generated
vendored
@@ -1,65 +0,0 @@
|
||||
import { flatten, isArray, map, reduce, uniq, upperFirst } from "lodash-es";
|
||||
export function genDts(model, options) {
|
||||
let contentParts = [];
|
||||
contentParts = contentParts.concat(`import type { CstNode, ICstVisitor, IToken } from "chevrotain";`);
|
||||
contentParts = contentParts.concat(flatten(map(model, (node) => genCstNodeTypes(node))));
|
||||
if (options.includeVisitorInterface) {
|
||||
contentParts = contentParts.concat(genVisitor(options.visitorInterfaceName, model));
|
||||
}
|
||||
return contentParts.join("\n\n") + "\n";
|
||||
}
|
||||
function genCstNodeTypes(node) {
|
||||
const nodeCstInterface = genNodeInterface(node);
|
||||
const nodeChildrenInterface = genNodeChildrenType(node);
|
||||
return [nodeCstInterface, nodeChildrenInterface];
|
||||
}
|
||||
function genNodeInterface(node) {
|
||||
const nodeInterfaceName = getNodeInterfaceName(node.name);
|
||||
const childrenTypeName = getNodeChildrenTypeName(node.name);
|
||||
return `export interface ${nodeInterfaceName} extends CstNode {
|
||||
name: "${node.name}";
|
||||
children: ${childrenTypeName};
|
||||
}`;
|
||||
}
|
||||
function genNodeChildrenType(node) {
|
||||
const typeName = getNodeChildrenTypeName(node.name);
|
||||
return `export type ${typeName} = {
|
||||
${map(node.properties, (property) => genChildProperty(property)).join("\n ")}
|
||||
};`;
|
||||
}
|
||||
function genChildProperty(prop) {
|
||||
const typeName = buildTypeString(prop.type);
|
||||
return `${prop.name}${prop.optional ? "?" : ""}: ${typeName}[];`;
|
||||
}
|
||||
function genVisitor(name, nodes) {
|
||||
return `export interface ${name}<IN, OUT> extends ICstVisitor<IN, OUT> {
|
||||
${map(nodes, (node) => genVisitorFunction(node)).join("\n ")}
|
||||
}`;
|
||||
}
|
||||
function genVisitorFunction(node) {
|
||||
const childrenTypeName = getNodeChildrenTypeName(node.name);
|
||||
return `${node.name}(children: ${childrenTypeName}, param?: IN): OUT;`;
|
||||
}
|
||||
function buildTypeString(type) {
|
||||
if (isArray(type)) {
|
||||
const typeNames = uniq(map(type, (t) => getTypeString(t)));
|
||||
const typeString = reduce(typeNames, (sum, t) => sum + " | " + t);
|
||||
return "(" + typeString + ")";
|
||||
}
|
||||
else {
|
||||
return getTypeString(type);
|
||||
}
|
||||
}
|
||||
function getTypeString(type) {
|
||||
if (type.kind === "token") {
|
||||
return "IToken";
|
||||
}
|
||||
return getNodeInterfaceName(type.name);
|
||||
}
|
||||
function getNodeInterfaceName(ruleName) {
|
||||
return upperFirst(ruleName) + "CstNode";
|
||||
}
|
||||
function getNodeChildrenTypeName(ruleName) {
|
||||
return upperFirst(ruleName) + "CstChildren";
|
||||
}
|
||||
//# sourceMappingURL=generate.js.map
|
||||
1
node_modules/@chevrotain/cst-dts-gen/lib/src/generate.js.map
generated
vendored
1
node_modules/@chevrotain/cst-dts-gen/lib/src/generate.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAU5E,MAAM,UAAU,MAAM,CACpB,KAA8B,EAC9B,OAAqC;IAErC,IAAI,YAAY,GAAa,EAAE,CAAC;IAEhC,YAAY,GAAG,YAAY,CAAC,MAAM,CAChC,iEAAiE,CAClE,CAAC;IAEF,YAAY,GAAG,YAAY,CAAC,MAAM,CAChC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CACrD,CAAC;IAEF,IAAI,OAAO,CAAC,uBAAuB,EAAE;QACnC,YAAY,GAAG,YAAY,CAAC,MAAM,CAChC,UAAU,CAAC,OAAO,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAChD,CAAC;KACH;IAED,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAC1C,CAAC;AAED,SAAS,eAAe,CAAC,IAA2B;IAClD,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAExD,OAAO,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,gBAAgB,CAAC,IAA2B;IACnD,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE5D,OAAO,oBAAoB,iBAAiB;WACnC,IAAI,CAAC,IAAI;cACN,gBAAgB;EAC5B,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,IAA2B;IACtD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpD,OAAO,eAAe,QAAQ;IAC5B,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;GAC5E,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,IAA4B;IACpD,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,KAAK,CAAC;AACnE,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,KAA8B;IAC9D,OAAO,oBAAoB,IAAI;IAC7B,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;EAC7D,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA2B;IACrD,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,OAAO,GAAG,IAAI,CAAC,IAAI,cAAc,gBAAgB,qBAAqB,CAAC;AACzE,CAAC;AAED,SAAS,eAAe,CAAC,IAAuB;IAC9C,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;QAClE,OAAO,GAAG,GAAG,UAAU,GAAG,GAAG,CAAC;KAC/B;SAAM;QACL,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;KAC5B;AACH,CAAC;AAED,SAAS,aAAa,CAAC,IAAoC;IACzD,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;QACzB,OAAO,QAAQ,CAAC;KACjB;IACD,OAAO,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,OAAO,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;AAC1C,CAAC;AAED,SAAS,uBAAuB,CAAC,QAAgB;IAC/C,OAAO,UAAU,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC;AAC9C,CAAC"}
|
||||
19
node_modules/@chevrotain/cst-dts-gen/lib/src/model.d.ts
generated
vendored
19
node_modules/@chevrotain/cst-dts-gen/lib/src/model.d.ts
generated
vendored
@@ -1,19 +0,0 @@
|
||||
import type { Rule } from "@chevrotain/types";
|
||||
export declare function buildModel(productions: Record<string, Rule>): CstNodeTypeDefinition[];
|
||||
export type CstNodeTypeDefinition = {
|
||||
name: string;
|
||||
properties: PropertyTypeDefinition[];
|
||||
};
|
||||
export type PropertyTypeDefinition = {
|
||||
name: string;
|
||||
type: PropertyArrayType;
|
||||
optional: boolean;
|
||||
};
|
||||
export type PropertyArrayType = TokenArrayType | RuleArrayType | (TokenArrayType | RuleArrayType)[];
|
||||
export type TokenArrayType = {
|
||||
kind: "token";
|
||||
};
|
||||
export type RuleArrayType = {
|
||||
kind: "rule";
|
||||
name: string;
|
||||
};
|
||||
96
node_modules/@chevrotain/cst-dts-gen/lib/src/model.js
generated
vendored
96
node_modules/@chevrotain/cst-dts-gen/lib/src/model.js
generated
vendored
@@ -1,96 +0,0 @@
|
||||
import { GAstVisitor, NonTerminal } from "@chevrotain/gast";
|
||||
import { assign, flatten, groupBy, map, some, values } from "lodash-es";
|
||||
export function buildModel(productions) {
|
||||
const generator = new CstNodeDefinitionGenerator();
|
||||
const allRules = values(productions);
|
||||
return map(allRules, (rule) => generator.visitRule(rule));
|
||||
}
|
||||
class CstNodeDefinitionGenerator extends GAstVisitor {
|
||||
visitRule(node) {
|
||||
const rawElements = this.visitEach(node.definition);
|
||||
const grouped = groupBy(rawElements, (el) => el.propertyName);
|
||||
const properties = map(grouped, (group, propertyName) => {
|
||||
const allNullable = !some(group, (el) => !el.canBeNull);
|
||||
// In an alternation with a label a property name can have
|
||||
// multiple types.
|
||||
let propertyType = group[0].type;
|
||||
if (group.length > 1) {
|
||||
propertyType = map(group, (g) => g.type);
|
||||
}
|
||||
return {
|
||||
name: propertyName,
|
||||
type: propertyType,
|
||||
optional: allNullable,
|
||||
};
|
||||
});
|
||||
return {
|
||||
name: node.name,
|
||||
properties: properties,
|
||||
};
|
||||
}
|
||||
visitAlternative(node) {
|
||||
return this.visitEachAndOverrideWith(node.definition, { canBeNull: true });
|
||||
}
|
||||
visitOption(node) {
|
||||
return this.visitEachAndOverrideWith(node.definition, { canBeNull: true });
|
||||
}
|
||||
visitRepetition(node) {
|
||||
return this.visitEachAndOverrideWith(node.definition, { canBeNull: true });
|
||||
}
|
||||
visitRepetitionMandatory(node) {
|
||||
return this.visitEach(node.definition);
|
||||
}
|
||||
visitRepetitionMandatoryWithSeparator(node) {
|
||||
return this.visitEach(node.definition).concat({
|
||||
propertyName: node.separator.name,
|
||||
canBeNull: true,
|
||||
type: getType(node.separator),
|
||||
});
|
||||
}
|
||||
visitRepetitionWithSeparator(node) {
|
||||
return this.visitEachAndOverrideWith(node.definition, {
|
||||
canBeNull: true,
|
||||
}).concat({
|
||||
propertyName: node.separator.name,
|
||||
canBeNull: true,
|
||||
type: getType(node.separator),
|
||||
});
|
||||
}
|
||||
visitAlternation(node) {
|
||||
return this.visitEachAndOverrideWith(node.definition, { canBeNull: true });
|
||||
}
|
||||
visitTerminal(node) {
|
||||
return [
|
||||
{
|
||||
propertyName: node.label || node.terminalType.name,
|
||||
canBeNull: false,
|
||||
type: getType(node),
|
||||
},
|
||||
];
|
||||
}
|
||||
visitNonTerminal(node) {
|
||||
return [
|
||||
{
|
||||
propertyName: node.label || node.nonTerminalName,
|
||||
canBeNull: false,
|
||||
type: getType(node),
|
||||
},
|
||||
];
|
||||
}
|
||||
visitEachAndOverrideWith(definition, override) {
|
||||
return map(this.visitEach(definition), (definition) => assign({}, definition, override));
|
||||
}
|
||||
visitEach(definition) {
|
||||
return flatten(map(definition, (definition) => this.visit(definition)));
|
||||
}
|
||||
}
|
||||
function getType(production) {
|
||||
if (production instanceof NonTerminal) {
|
||||
return {
|
||||
kind: "rule",
|
||||
name: production.referencedRule.name,
|
||||
};
|
||||
}
|
||||
return { kind: "token" };
|
||||
}
|
||||
//# sourceMappingURL=model.js.map
|
||||
1
node_modules/@chevrotain/cst-dts-gen/lib/src/model.js.map
generated
vendored
1
node_modules/@chevrotain/cst-dts-gen/lib/src/model.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExE,MAAM,UAAU,UAAU,CACxB,WAAiC;IAEjC,MAAM,SAAS,GAAG,IAAI,0BAA0B,EAAE,CAAC;IACnD,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IACrC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5D,CAAC;AAwBD,MAAM,0BAA2B,SAAQ,WAAW;IAClD,SAAS,CAAC,IAAU;QAClB,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEpD,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;YACtD,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;YAExD,0DAA0D;YAC1D,kBAAkB;YAClB,IAAI,YAAY,GAAsB,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACpD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpB,YAAY,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;aAC1C;YAED,OAAO;gBACL,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,YAAY;gBAClB,QAAQ,EAAE,WAAW;aACI,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,UAAU;SACvB,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,IAAiB;QAChC,OAAO,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,OAAO,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,eAAe,CAAC,IAAgB;QAC9B,OAAO,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,wBAAwB,CAAC,IAAyB;QAChD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,qCAAqC,CACnC,IAAsC;QAEtC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;YAC5C,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;YACjC,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,4BAA4B,CAAC,IAA6B;QACxD,OAAO,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,UAAU,EAAE;YACpD,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC,MAAM,CAAC;YACR,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;YACjC,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,IAAiB;QAChC,OAAO,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,aAAa,CAAC,IAAc;QAC1B,OAAO;YACL;gBACE,YAAY,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI;gBAClD,SAAS,EAAE,KAAK;gBAChB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;aACpB;SACF,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,IAAiB;QAChC,OAAO;YACL;gBACE,YAAY,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe;gBAChD,SAAS,EAAE,KAAK;gBAChB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;aACpB;SACF,CAAC;IACJ,CAAC;IAEO,wBAAwB,CAC9B,UAAyB,EACzB,QAAuC;QAEvC,OAAO,GAAG,CACR,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAC1B,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAyB,CACzE,CAAC;IACJ,CAAC;IAEO,SAAS,CAAC,UAAyB;QACzC,OAAO,OAAO,CACZ,GAAG,CACD,UAAU,EACV,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAA2B,CACjE,CACF,CAAC;IACJ,CAAC;CACF;AAQD,SAAS,OAAO,CACd,UAA8C;IAE9C,IAAI,UAAU,YAAY,WAAW,EAAE;QACrC,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,IAAI;SACrC,CAAC;KACH;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
|
||||
50
node_modules/@chevrotain/cst-dts-gen/package.json
generated
vendored
50
node_modules/@chevrotain/cst-dts-gen/package.json
generated
vendored
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "@chevrotain/cst-dts-gen",
|
||||
"version": "11.0.3",
|
||||
"description": "Generates type definitions for Chevrotain CST nodes",
|
||||
"keywords": [],
|
||||
"bugs": {
|
||||
"url": "https://github.com/Chevrotain/chevrotain/issues"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"types": "./lib/src/api.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./lib/src/api.js",
|
||||
"types": "./lib/src/api.d.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"lib/src/**/*.js",
|
||||
"lib/src/**/*.map",
|
||||
"lib/src/**/*.d.ts",
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Chevrotain/chevrotain.git"
|
||||
},
|
||||
"scripts": {
|
||||
"---------- CI FLOWS --------": "",
|
||||
"ci": "pnpm run build test",
|
||||
"build": "npm-run-all clean compile",
|
||||
"test": "echo \"tests are in a different package\"",
|
||||
"---------- BUILD STEPS --------": "",
|
||||
"clean": "shx rm -rf lib",
|
||||
"compile:watch": "tsc -w",
|
||||
"compile": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@chevrotain/gast": "11.0.3",
|
||||
"@chevrotain/types": "11.0.3",
|
||||
"lodash-es": "4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash-es": "4.17.7"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "ac5806631779035c2c1955744a47d8ed4f25a175"
|
||||
}
|
||||
22
node_modules/@chevrotain/cst-dts-gen/src/api.ts
generated
vendored
22
node_modules/@chevrotain/cst-dts-gen/src/api.ts
generated
vendored
@@ -1,22 +0,0 @@
|
||||
import { GenerateDtsOptions, Rule } from "@chevrotain/types";
|
||||
import { buildModel } from "./model.js";
|
||||
import { genDts } from "./generate.js";
|
||||
|
||||
const defaultOptions: Required<GenerateDtsOptions> = {
|
||||
includeVisitorInterface: true,
|
||||
visitorInterfaceName: "ICstNodeVisitor",
|
||||
};
|
||||
|
||||
export function generateCstDts(
|
||||
productions: Record<string, Rule>,
|
||||
options?: GenerateDtsOptions,
|
||||
): string {
|
||||
const effectiveOptions = {
|
||||
...defaultOptions,
|
||||
...options,
|
||||
};
|
||||
|
||||
const model = buildModel(productions);
|
||||
|
||||
return genDts(model, effectiveOptions);
|
||||
}
|
||||
98
node_modules/@chevrotain/cst-dts-gen/src/generate.ts
generated
vendored
98
node_modules/@chevrotain/cst-dts-gen/src/generate.ts
generated
vendored
@@ -1,98 +0,0 @@
|
||||
import { flatten, isArray, map, reduce, uniq, upperFirst } from "lodash-es";
|
||||
import { GenerateDtsOptions } from "@chevrotain/types";
|
||||
import {
|
||||
CstNodeTypeDefinition,
|
||||
PropertyArrayType,
|
||||
PropertyTypeDefinition,
|
||||
RuleArrayType,
|
||||
TokenArrayType,
|
||||
} from "./model.js";
|
||||
|
||||
export function genDts(
|
||||
model: CstNodeTypeDefinition[],
|
||||
options: Required<GenerateDtsOptions>,
|
||||
): string {
|
||||
let contentParts: string[] = [];
|
||||
|
||||
contentParts = contentParts.concat(
|
||||
`import type { CstNode, ICstVisitor, IToken } from "chevrotain";`,
|
||||
);
|
||||
|
||||
contentParts = contentParts.concat(
|
||||
flatten(map(model, (node) => genCstNodeTypes(node))),
|
||||
);
|
||||
|
||||
if (options.includeVisitorInterface) {
|
||||
contentParts = contentParts.concat(
|
||||
genVisitor(options.visitorInterfaceName, model),
|
||||
);
|
||||
}
|
||||
|
||||
return contentParts.join("\n\n") + "\n";
|
||||
}
|
||||
|
||||
function genCstNodeTypes(node: CstNodeTypeDefinition) {
|
||||
const nodeCstInterface = genNodeInterface(node);
|
||||
const nodeChildrenInterface = genNodeChildrenType(node);
|
||||
|
||||
return [nodeCstInterface, nodeChildrenInterface];
|
||||
}
|
||||
|
||||
function genNodeInterface(node: CstNodeTypeDefinition) {
|
||||
const nodeInterfaceName = getNodeInterfaceName(node.name);
|
||||
const childrenTypeName = getNodeChildrenTypeName(node.name);
|
||||
|
||||
return `export interface ${nodeInterfaceName} extends CstNode {
|
||||
name: "${node.name}";
|
||||
children: ${childrenTypeName};
|
||||
}`;
|
||||
}
|
||||
|
||||
function genNodeChildrenType(node: CstNodeTypeDefinition) {
|
||||
const typeName = getNodeChildrenTypeName(node.name);
|
||||
|
||||
return `export type ${typeName} = {
|
||||
${map(node.properties, (property) => genChildProperty(property)).join("\n ")}
|
||||
};`;
|
||||
}
|
||||
|
||||
function genChildProperty(prop: PropertyTypeDefinition) {
|
||||
const typeName = buildTypeString(prop.type);
|
||||
return `${prop.name}${prop.optional ? "?" : ""}: ${typeName}[];`;
|
||||
}
|
||||
|
||||
function genVisitor(name: string, nodes: CstNodeTypeDefinition[]) {
|
||||
return `export interface ${name}<IN, OUT> extends ICstVisitor<IN, OUT> {
|
||||
${map(nodes, (node) => genVisitorFunction(node)).join("\n ")}
|
||||
}`;
|
||||
}
|
||||
|
||||
function genVisitorFunction(node: CstNodeTypeDefinition) {
|
||||
const childrenTypeName = getNodeChildrenTypeName(node.name);
|
||||
return `${node.name}(children: ${childrenTypeName}, param?: IN): OUT;`;
|
||||
}
|
||||
|
||||
function buildTypeString(type: PropertyArrayType) {
|
||||
if (isArray(type)) {
|
||||
const typeNames = uniq(map(type, (t) => getTypeString(t)));
|
||||
const typeString = reduce(typeNames, (sum, t) => sum + " | " + t);
|
||||
return "(" + typeString + ")";
|
||||
} else {
|
||||
return getTypeString(type);
|
||||
}
|
||||
}
|
||||
|
||||
function getTypeString(type: TokenArrayType | RuleArrayType) {
|
||||
if (type.kind === "token") {
|
||||
return "IToken";
|
||||
}
|
||||
return getNodeInterfaceName(type.name);
|
||||
}
|
||||
|
||||
function getNodeInterfaceName(ruleName: string) {
|
||||
return upperFirst(ruleName) + "CstNode";
|
||||
}
|
||||
|
||||
function getNodeChildrenTypeName(ruleName: string) {
|
||||
return upperFirst(ruleName) + "CstChildren";
|
||||
}
|
||||
172
node_modules/@chevrotain/cst-dts-gen/src/model.ts
generated
vendored
172
node_modules/@chevrotain/cst-dts-gen/src/model.ts
generated
vendored
@@ -1,172 +0,0 @@
|
||||
import type {
|
||||
Alternation,
|
||||
Alternative,
|
||||
IProduction,
|
||||
Option,
|
||||
Repetition,
|
||||
RepetitionMandatory,
|
||||
RepetitionMandatoryWithSeparator,
|
||||
RepetitionWithSeparator,
|
||||
Rule,
|
||||
Terminal,
|
||||
TokenType,
|
||||
} from "@chevrotain/types";
|
||||
import { GAstVisitor, NonTerminal } from "@chevrotain/gast";
|
||||
import { assign, flatten, groupBy, map, some, values } from "lodash-es";
|
||||
|
||||
export function buildModel(
|
||||
productions: Record<string, Rule>,
|
||||
): CstNodeTypeDefinition[] {
|
||||
const generator = new CstNodeDefinitionGenerator();
|
||||
const allRules = values(productions);
|
||||
return map(allRules, (rule) => generator.visitRule(rule));
|
||||
}
|
||||
|
||||
export type CstNodeTypeDefinition = {
|
||||
name: string;
|
||||
properties: PropertyTypeDefinition[];
|
||||
};
|
||||
|
||||
export type PropertyTypeDefinition = {
|
||||
name: string;
|
||||
type: PropertyArrayType;
|
||||
optional: boolean;
|
||||
};
|
||||
|
||||
export type PropertyArrayType =
|
||||
| TokenArrayType
|
||||
| RuleArrayType
|
||||
| (TokenArrayType | RuleArrayType)[];
|
||||
|
||||
export type TokenArrayType = { kind: "token" };
|
||||
export type RuleArrayType = {
|
||||
kind: "rule";
|
||||
name: string;
|
||||
};
|
||||
|
||||
class CstNodeDefinitionGenerator extends GAstVisitor {
|
||||
visitRule(node: Rule): CstNodeTypeDefinition {
|
||||
const rawElements = this.visitEach(node.definition);
|
||||
|
||||
const grouped = groupBy(rawElements, (el) => el.propertyName);
|
||||
const properties = map(grouped, (group, propertyName) => {
|
||||
const allNullable = !some(group, (el) => !el.canBeNull);
|
||||
|
||||
// In an alternation with a label a property name can have
|
||||
// multiple types.
|
||||
let propertyType: PropertyArrayType = group[0].type;
|
||||
if (group.length > 1) {
|
||||
propertyType = map(group, (g) => g.type);
|
||||
}
|
||||
|
||||
return {
|
||||
name: propertyName,
|
||||
type: propertyType,
|
||||
optional: allNullable,
|
||||
} as PropertyTypeDefinition;
|
||||
});
|
||||
|
||||
return {
|
||||
name: node.name,
|
||||
properties: properties,
|
||||
};
|
||||
}
|
||||
|
||||
visitAlternative(node: Alternative) {
|
||||
return this.visitEachAndOverrideWith(node.definition, { canBeNull: true });
|
||||
}
|
||||
|
||||
visitOption(node: Option) {
|
||||
return this.visitEachAndOverrideWith(node.definition, { canBeNull: true });
|
||||
}
|
||||
|
||||
visitRepetition(node: Repetition) {
|
||||
return this.visitEachAndOverrideWith(node.definition, { canBeNull: true });
|
||||
}
|
||||
|
||||
visitRepetitionMandatory(node: RepetitionMandatory) {
|
||||
return this.visitEach(node.definition);
|
||||
}
|
||||
|
||||
visitRepetitionMandatoryWithSeparator(
|
||||
node: RepetitionMandatoryWithSeparator,
|
||||
) {
|
||||
return this.visitEach(node.definition).concat({
|
||||
propertyName: node.separator.name,
|
||||
canBeNull: true,
|
||||
type: getType(node.separator),
|
||||
});
|
||||
}
|
||||
|
||||
visitRepetitionWithSeparator(node: RepetitionWithSeparator) {
|
||||
return this.visitEachAndOverrideWith(node.definition, {
|
||||
canBeNull: true,
|
||||
}).concat({
|
||||
propertyName: node.separator.name,
|
||||
canBeNull: true,
|
||||
type: getType(node.separator),
|
||||
});
|
||||
}
|
||||
|
||||
visitAlternation(node: Alternation) {
|
||||
return this.visitEachAndOverrideWith(node.definition, { canBeNull: true });
|
||||
}
|
||||
|
||||
visitTerminal(node: Terminal): PropertyTupleElement[] {
|
||||
return [
|
||||
{
|
||||
propertyName: node.label || node.terminalType.name,
|
||||
canBeNull: false,
|
||||
type: getType(node),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
visitNonTerminal(node: NonTerminal): PropertyTupleElement[] {
|
||||
return [
|
||||
{
|
||||
propertyName: node.label || node.nonTerminalName,
|
||||
canBeNull: false,
|
||||
type: getType(node),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
private visitEachAndOverrideWith(
|
||||
definition: IProduction[],
|
||||
override: Partial<PropertyTupleElement>,
|
||||
) {
|
||||
return map(
|
||||
this.visitEach(definition),
|
||||
(definition) => assign({}, definition, override) as PropertyTupleElement,
|
||||
);
|
||||
}
|
||||
|
||||
private visitEach(definition: IProduction[]) {
|
||||
return flatten<PropertyTupleElement>(
|
||||
map(
|
||||
definition,
|
||||
(definition) => this.visit(definition) as PropertyTupleElement[],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
type PropertyTupleElement = {
|
||||
propertyName: string;
|
||||
canBeNull: boolean;
|
||||
type: TokenArrayType | RuleArrayType;
|
||||
};
|
||||
|
||||
function getType(
|
||||
production: Terminal | NonTerminal | TokenType,
|
||||
): TokenArrayType | RuleArrayType {
|
||||
if (production instanceof NonTerminal) {
|
||||
return {
|
||||
kind: "rule",
|
||||
name: production.referencedRule.name,
|
||||
};
|
||||
}
|
||||
|
||||
return { kind: "token" };
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user