update - clean
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,4 +1,7 @@
|
|||||||
.env
|
.env
|
||||||
data/
|
data
|
||||||
data_bak/
|
data_bak
|
||||||
static-files/
|
static-files
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.pnpm-store
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"names":["_fs","data","require","_gensync","readFile","exports","gensync","sync","fs","readFileSync","errback","stat","statSync"],"sources":["../../src/gensync-utils/fs.ts"],"sourcesContent":["import fs from \"fs\";\nimport gensync from \"gensync\";\n\nexport const readFile = gensync<[filepath: string, encoding: \"utf8\"], string>({\n sync: fs.readFileSync,\n errback: fs.readFile,\n});\n\nexport const stat = gensync({\n sync: fs.statSync,\n errback: fs.stat,\n});\n"],"mappings":";;;;;;AAAA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAMG,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGE,SAAMA,CAAC,CAA+C;EAC5EC,IAAI,EAAEC,IAACA,CAAC,CAACC,YAAY;EACrBC,OAAO,EAAEF,IAACA,CAAC,CAACJ;AACd,CAAC,CAAC;AAEK,MAAMO,IAAI,GAAAN,OAAA,CAAAM,IAAA,GAAGL,SAAMA,CAAC,CAAC;EAC1BC,IAAI,EAAEC,IAACA,CAAC,CAACI,QAAQ;EACjBF,OAAO,EAAEF,IAACA,CAAC,CAACG;AACd,CAAC,CAAC;AAAC","ignoreList":[]}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag.
|
|
||||||
|
|
||||||
@param flag - CLI flag to look for. The `--` prefix is optional.
|
|
||||||
@param argv - CLI arguments. Default: `process.argv`.
|
|
||||||
@returns Whether the flag exists.
|
|
||||||
|
|
||||||
@example
|
|
||||||
```
|
|
||||||
// $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow
|
|
||||||
|
|
||||||
// foo.ts
|
|
||||||
import hasFlag = require('has-flag');
|
|
||||||
|
|
||||||
hasFlag('unicorn');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('--unicorn');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('f');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('-f');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('foo=bar');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('foo');
|
|
||||||
//=> false
|
|
||||||
|
|
||||||
hasFlag('rainbow');
|
|
||||||
//=> false
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
declare function hasFlag(flag: string, argv?: string[]): boolean;
|
|
||||||
|
|
||||||
export = hasFlag;
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/**
|
|
||||||
* @license React
|
|
||||||
* use-sync-external-store-shim.native.production.js
|
|
||||||
*
|
|
||||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
var React = require("react");
|
|
||||||
function is(x, y) {
|
|
||||||
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
|
|
||||||
}
|
|
||||||
var objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
||||||
useState = React.useState,
|
|
||||||
useEffect = React.useEffect,
|
|
||||||
useLayoutEffect = React.useLayoutEffect,
|
|
||||||
useDebugValue = React.useDebugValue;
|
|
||||||
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
||||||
var value = getSnapshot(),
|
|
||||||
_useState = useState({ inst: { value: value, getSnapshot: getSnapshot } }),
|
|
||||||
inst = _useState[0].inst,
|
|
||||||
forceUpdate = _useState[1];
|
|
||||||
useLayoutEffect(
|
|
||||||
function () {
|
|
||||||
inst.value = value;
|
|
||||||
inst.getSnapshot = getSnapshot;
|
|
||||||
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
||||||
},
|
|
||||||
[subscribe, value, getSnapshot]
|
|
||||||
);
|
|
||||||
useEffect(
|
|
||||||
function () {
|
|
||||||
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
||||||
return subscribe(function () {
|
|
||||||
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[subscribe]
|
|
||||||
);
|
|
||||||
useDebugValue(value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
function checkIfSnapshotChanged(inst) {
|
|
||||||
var latestGetSnapshot = inst.getSnapshot;
|
|
||||||
inst = inst.value;
|
|
||||||
try {
|
|
||||||
var nextValue = latestGetSnapshot();
|
|
||||||
return !objectIs(inst, nextValue);
|
|
||||||
} catch (error) {
|
|
||||||
return !0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.useSyncExternalStore =
|
|
||||||
void 0 !== React.useSyncExternalStore
|
|
||||||
? React.useSyncExternalStore
|
|
||||||
: useSyncExternalStore$1;
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,35 +0,0 @@
|
|||||||
const unicode = require('../lib/unicode')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
isSpaceSeparator (c) {
|
|
||||||
return typeof c === 'string' && unicode.Space_Separator.test(c)
|
|
||||||
},
|
|
||||||
|
|
||||||
isIdStartChar (c) {
|
|
||||||
return typeof c === 'string' && (
|
|
||||||
(c >= 'a' && c <= 'z') ||
|
|
||||||
(c >= 'A' && c <= 'Z') ||
|
|
||||||
(c === '$') || (c === '_') ||
|
|
||||||
unicode.ID_Start.test(c)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
isIdContinueChar (c) {
|
|
||||||
return typeof c === 'string' && (
|
|
||||||
(c >= 'a' && c <= 'z') ||
|
|
||||||
(c >= 'A' && c <= 'Z') ||
|
|
||||||
(c >= '0' && c <= '9') ||
|
|
||||||
(c === '$') || (c === '_') ||
|
|
||||||
(c === '\u200C') || (c === '\u200D') ||
|
|
||||||
unicode.ID_Continue.test(c)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
isDigit (c) {
|
|
||||||
return typeof c === 'string' && /[0-9]/.test(c)
|
|
||||||
},
|
|
||||||
|
|
||||||
isHexDigit (c) {
|
|
||||||
return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
type Pathname = string
|
|
||||||
|
|
||||||
interface TestResult {
|
|
||||||
ignored: boolean
|
|
||||||
unignored: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Ignore {
|
|
||||||
/**
|
|
||||||
* Adds one or several rules to the current manager.
|
|
||||||
* @param {string[]} patterns
|
|
||||||
* @returns IgnoreBase
|
|
||||||
*/
|
|
||||||
add(patterns: string | Ignore | readonly (string | Ignore)[]): this
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters the given array of pathnames, and returns the filtered array.
|
|
||||||
* NOTICE that each path here should be a relative path to the root of your repository.
|
|
||||||
* @param paths the array of paths to be filtered.
|
|
||||||
* @returns The filtered array of paths
|
|
||||||
*/
|
|
||||||
filter(pathnames: readonly Pathname[]): Pathname[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a filter function which could filter
|
|
||||||
* an array of paths with Array.prototype.filter.
|
|
||||||
*/
|
|
||||||
createFilter(): (pathname: Pathname) => boolean
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Boolean whether pathname should be ignored.
|
|
||||||
* @param {string} pathname a path to check
|
|
||||||
* @returns boolean
|
|
||||||
*/
|
|
||||||
ignores(pathname: Pathname): boolean
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether pathname should be ignored or unignored
|
|
||||||
* @param {string} pathname a path to check
|
|
||||||
* @returns TestResult
|
|
||||||
*/
|
|
||||||
test(pathname: Pathname): TestResult
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Options {
|
|
||||||
ignorecase?: boolean
|
|
||||||
// For compatibility
|
|
||||||
ignoreCase?: boolean
|
|
||||||
allowRelativePaths?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new ignore manager.
|
|
||||||
*/
|
|
||||||
declare function ignore(options?: Options): Ignore
|
|
||||||
|
|
||||||
declare namespace ignore {
|
|
||||||
export function isPathValid (pathname: string): boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ignore
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "esrecurse",
|
|
||||||
"description": "ECMAScript AST recursive visitor",
|
|
||||||
"homepage": "https://github.com/estools/esrecurse",
|
|
||||||
"main": "esrecurse.js",
|
|
||||||
"version": "4.3.0",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.0"
|
|
||||||
},
|
|
||||||
"maintainers": [
|
|
||||||
{
|
|
||||||
"name": "Yusuke Suzuki",
|
|
||||||
"email": "utatane.tea@gmail.com",
|
|
||||||
"web": "https://github.com/Constellation"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/estools/esrecurse.git"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"estraverse": "^5.2.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"babel-cli": "^6.24.1",
|
|
||||||
"babel-eslint": "^7.2.3",
|
|
||||||
"babel-preset-es2015": "^6.24.1",
|
|
||||||
"babel-register": "^6.24.1",
|
|
||||||
"chai": "^4.0.2",
|
|
||||||
"esprima": "^4.0.0",
|
|
||||||
"gulp": "^3.9.0",
|
|
||||||
"gulp-bump": "^2.7.0",
|
|
||||||
"gulp-eslint": "^4.0.0",
|
|
||||||
"gulp-filter": "^5.0.0",
|
|
||||||
"gulp-git": "^2.4.1",
|
|
||||||
"gulp-mocha": "^4.3.1",
|
|
||||||
"gulp-tag-version": "^1.2.1",
|
|
||||||
"jsdoc": "^3.3.0-alpha10",
|
|
||||||
"minimist": "^1.1.0"
|
|
||||||
},
|
|
||||||
"license": "BSD-2-Clause",
|
|
||||||
"scripts": {
|
|
||||||
"test": "gulp travis",
|
|
||||||
"unit-test": "gulp test",
|
|
||||||
"lint": "gulp lint"
|
|
||||||
},
|
|
||||||
"babel": {
|
|
||||||
"presets": [
|
|
||||||
"es2015"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
const path = require('path');
|
|
||||||
const binaryExtensions = require('binary-extensions');
|
|
||||||
|
|
||||||
const extensions = new Set(binaryExtensions);
|
|
||||||
|
|
||||||
module.exports = filePath => extensions.has(path.extname(filePath).slice(1).toLowerCase());
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,5 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports.isClean = Symbol('isClean')
|
|
||||||
|
|
||||||
module.exports.my = Symbol('my')
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
y: 1 << 0,
|
|
||||||
n: 1 << 1,
|
|
||||||
a: 1 << 2,
|
|
||||||
p: 1 << 3,
|
|
||||||
u: 1 << 4,
|
|
||||||
x: 1 << 5,
|
|
||||||
d: 1 << 6
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
var defer = require('./defer.js');
|
|
||||||
|
|
||||||
// API
|
|
||||||
module.exports = async;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs provided callback asynchronously
|
|
||||||
* even if callback itself is not
|
|
||||||
*
|
|
||||||
* @param {function} callback - callback to invoke
|
|
||||||
* @returns {function} - augmented callback
|
|
||||||
*/
|
|
||||||
function async(callback)
|
|
||||||
{
|
|
||||||
var isAsync = false;
|
|
||||||
|
|
||||||
// check if async happened
|
|
||||||
defer(function() { isAsync = true; });
|
|
||||||
|
|
||||||
return function async_callback(err, result)
|
|
||||||
{
|
|
||||||
if (isAsync)
|
|
||||||
{
|
|
||||||
callback(err, result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
defer(function nextTick_callback()
|
|
||||||
{
|
|
||||||
callback(err, result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
|||||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P H R S T U V W","16":"Q"},C:{"1":"0 9 T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S qC rC"},D:{"1":"0 9 X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W"},E:{"1":"F A B C L M G wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E sC SC tC uC vC"},F:{"1":"0 AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 mD IC JC KC nD","2":"J dD eD fD gD hD TC iD jD kD lD"},Q:{"2":"oD"},R:{"1":"pD"},S:{"1":"rD","2":"qD"}},B:5,C:"selector list argument of :not()",D:true};
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports={A:{A:{"2":"K D E F mC","33":"A B"},B:{"1":"0 9 o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","33":"C L M G N O P","132":"Q H R S T U V W","260":"X Y Z a b c d e f g h i j k l m n"},C:{"1":"0 9 gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"nC LC J PB qC rC","33":"1 2 3 4 5 6 7 8 K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB"},D:{"1":"0 9 X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB","132":"sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W"},E:{"1":"JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB sC SC","33":"K D E F A B C L M G tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C"},F:{"1":"0 a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB 4C 5C 6C 7C FC kC 8C GC","132":"fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z"},G:{"1":"JC bC cC dC eC fC VD KC gC hC iC jC","2":"SC 9C","33":"E lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 eD fD gD hD TC iD jD kD lD mD IC JC KC nD","2":"J","132":"dD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:4,C:"CSS Hyphenation",D:true};
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
# combined-stream
|
|
||||||
|
|
||||||
A stream that emits multiple other streams one after another.
|
|
||||||
|
|
||||||
**NB** Currently `combined-stream` works with streams version 1 only. There is ongoing effort to switch this library to streams version 2. Any help is welcome. :) Meanwhile you can explore other libraries that provide streams2 support with more or less compatibility with `combined-stream`.
|
|
||||||
|
|
||||||
- [combined-stream2](https://www.npmjs.com/package/combined-stream2): A drop-in streams2-compatible replacement for the combined-stream module.
|
|
||||||
|
|
||||||
- [multistream](https://www.npmjs.com/package/multistream): A stream that emits multiple other streams one after another.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
npm install combined-stream
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Here is a simple example that shows how you can use combined-stream to combine
|
|
||||||
two files into one:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var CombinedStream = require('combined-stream');
|
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
var combinedStream = CombinedStream.create();
|
|
||||||
combinedStream.append(fs.createReadStream('file1.txt'));
|
|
||||||
combinedStream.append(fs.createReadStream('file2.txt'));
|
|
||||||
|
|
||||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
|
||||||
```
|
|
||||||
|
|
||||||
While the example above works great, it will pause all source streams until
|
|
||||||
they are needed. If you don't want that to happen, you can set `pauseStreams`
|
|
||||||
to `false`:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var CombinedStream = require('combined-stream');
|
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
var combinedStream = CombinedStream.create({pauseStreams: false});
|
|
||||||
combinedStream.append(fs.createReadStream('file1.txt'));
|
|
||||||
combinedStream.append(fs.createReadStream('file2.txt'));
|
|
||||||
|
|
||||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
|
||||||
```
|
|
||||||
|
|
||||||
However, what if you don't have all the source streams yet, or you don't want
|
|
||||||
to allocate the resources (file descriptors, memory, etc.) for them right away?
|
|
||||||
Well, in that case you can simply provide a callback that supplies the stream
|
|
||||||
by calling a `next()` function:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var CombinedStream = require('combined-stream');
|
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
var combinedStream = CombinedStream.create();
|
|
||||||
combinedStream.append(function(next) {
|
|
||||||
next(fs.createReadStream('file1.txt'));
|
|
||||||
});
|
|
||||||
combinedStream.append(function(next) {
|
|
||||||
next(fs.createReadStream('file2.txt'));
|
|
||||||
});
|
|
||||||
|
|
||||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### CombinedStream.create([options])
|
|
||||||
|
|
||||||
Returns a new combined stream object. Available options are:
|
|
||||||
|
|
||||||
* `maxDataSize`
|
|
||||||
* `pauseStreams`
|
|
||||||
|
|
||||||
The effect of those options is described below.
|
|
||||||
|
|
||||||
### combinedStream.pauseStreams = `true`
|
|
||||||
|
|
||||||
Whether to apply back pressure to the underlaying streams. If set to `false`,
|
|
||||||
the underlaying streams will never be paused. If set to `true`, the
|
|
||||||
underlaying streams will be paused right after being appended, as well as when
|
|
||||||
`delayedStream.pipe()` wants to throttle.
|
|
||||||
|
|
||||||
### combinedStream.maxDataSize = `2 * 1024 * 1024`
|
|
||||||
|
|
||||||
The maximum amount of bytes (or characters) to buffer for all source streams.
|
|
||||||
If this value is exceeded, `combinedStream` emits an `'error'` event.
|
|
||||||
|
|
||||||
### combinedStream.dataSize = `0`
|
|
||||||
|
|
||||||
The amount of bytes (or characters) currently buffered by `combinedStream`.
|
|
||||||
|
|
||||||
### combinedStream.append(stream)
|
|
||||||
|
|
||||||
Appends the given `stream` to the combinedStream object. If `pauseStreams` is
|
|
||||||
set to `true, this stream will also be paused right away.
|
|
||||||
|
|
||||||
`streams` can also be a function that takes one parameter called `next`. `next`
|
|
||||||
is a function that must be invoked in order to provide the `next` stream, see
|
|
||||||
example above.
|
|
||||||
|
|
||||||
Regardless of how the `stream` is appended, combined-stream always attaches an
|
|
||||||
`'error'` listener to it, so you don't have to do that manually.
|
|
||||||
|
|
||||||
Special case: `stream` can also be a String or Buffer.
|
|
||||||
|
|
||||||
### combinedStream.write(data)
|
|
||||||
|
|
||||||
You should not call this, `combinedStream` takes care of piping the appended
|
|
||||||
streams into itself for you.
|
|
||||||
|
|
||||||
### combinedStream.resume()
|
|
||||||
|
|
||||||
Causes `combinedStream` to start drain the streams it manages. The function is
|
|
||||||
idempotent, and also emits a `'resume'` event each time which usually goes to
|
|
||||||
the stream that is currently being drained.
|
|
||||||
|
|
||||||
### combinedStream.pause();
|
|
||||||
|
|
||||||
If `combinedStream.pauseStreams` is set to `false`, this does nothing.
|
|
||||||
Otherwise a `'pause'` event is emitted, this goes to the stream that is
|
|
||||||
currently being drained, so you can use it to apply back pressure.
|
|
||||||
|
|
||||||
### combinedStream.end();
|
|
||||||
|
|
||||||
Sets `combinedStream.writable` to false, emits an `'end'` event, and removes
|
|
||||||
all streams from the queue.
|
|
||||||
|
|
||||||
### combinedStream.destroy();
|
|
||||||
|
|
||||||
Same as `combinedStream.end()`, except it emits a `'close'` event instead of
|
|
||||||
`'end'`.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
combined-stream is licensed under the MIT license.
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
# @eslint/config-helpers
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
Helper utilities for creating ESLint configuration.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
For Node.js and compatible runtimes:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
npm install @eslint/config-helpers
|
|
||||||
# or
|
|
||||||
yarn add @eslint/config-helpers
|
|
||||||
# or
|
|
||||||
pnpm install @eslint/config-helpers
|
|
||||||
# or
|
|
||||||
bun install @eslint/config-helpers
|
|
||||||
```
|
|
||||||
|
|
||||||
For Deno:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
deno add @eslint/config-helpers
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### `defineConfig()`
|
|
||||||
|
|
||||||
The `defineConfig()` function allows you to specify an ESLint configuration with full type checking and additional capabilities, such as `extends`. Here's an example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
// eslint.config.js
|
|
||||||
import { defineConfig } from "@eslint/config-helpers";
|
|
||||||
import js from "@eslint/js";
|
|
||||||
|
|
||||||
export default defineConfig([
|
|
||||||
{
|
|
||||||
files: ["src/**/*.js"],
|
|
||||||
plugins: { js },
|
|
||||||
extends: ["js/recommended"],
|
|
||||||
rules: {
|
|
||||||
semi: "error",
|
|
||||||
"prefer-const": "error",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ["test/**/*.js"],
|
|
||||||
rules: {
|
|
||||||
"no-console": "off",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
```
|
|
||||||
|
|
||||||
### `globalIgnores()`
|
|
||||||
|
|
||||||
The `globalIgnores()` function allows you to specify patterns for files and directories that should be globally ignored by ESLint. This is useful for excluding files that you don't want to lint, such as build directories or third-party libraries. Here's an example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
// eslint.config.js
|
|
||||||
import { defineConfig, globalIgnores } from "@eslint/config-helpers";
|
|
||||||
|
|
||||||
export default defineConfig([
|
|
||||||
{
|
|
||||||
files: ["src/**/*.js"],
|
|
||||||
rules: {
|
|
||||||
semi: "error",
|
|
||||||
"prefer-const": "error",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
globalIgnores(["node_modules/", "dist/", "coverage/"]),
|
|
||||||
]);
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Apache 2.0
|
|
||||||
|
|
||||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
|
||||||
<!--sponsorsstart-->
|
|
||||||
|
|
||||||
## Sponsors
|
|
||||||
|
|
||||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
|
||||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
|
||||||
|
|
||||||
<h3>Platinum Sponsors</h3>
|
|
||||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
|
||||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
|
|
||||||
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
|
|
||||||
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nolebase.ayaka.io"><img src="https://avatars.githubusercontent.com/u/11081491" alt="Neko" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
|
|
||||||
<h3>Technology Sponsors</h3>
|
|
||||||
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
|
|
||||||
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
|
|
||||||
<!--sponsorsend-->
|
|
||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1,89 +0,0 @@
|
|||||||
# has-flag [](https://travis-ci.org/sindresorhus/has-flag)
|
|
||||||
|
|
||||||
> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
|
|
||||||
|
|
||||||
Correctly stops looking after an `--` argument terminator.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
<b>
|
|
||||||
<a href="https://tidelift.com/subscription/pkg/npm-has-flag?utm_source=npm-has-flag&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>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```
|
|
||||||
$ npm install has-flag
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
// foo.js
|
|
||||||
const hasFlag = require('has-flag');
|
|
||||||
|
|
||||||
hasFlag('unicorn');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('--unicorn');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('f');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('-f');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('foo=bar');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
hasFlag('foo');
|
|
||||||
//=> false
|
|
||||||
|
|
||||||
hasFlag('rainbow');
|
|
||||||
//=> false
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
$ node foo.js -f --unicorn --foo=bar -- --rainbow
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### hasFlag(flag, [argv])
|
|
||||||
|
|
||||||
Returns a boolean for whether the flag exists.
|
|
||||||
|
|
||||||
#### flag
|
|
||||||
|
|
||||||
Type: `string`
|
|
||||||
|
|
||||||
CLI flag to look for. The `--` prefix is optional.
|
|
||||||
|
|
||||||
#### argv
|
|
||||||
|
|
||||||
Type: `string[]`<br>
|
|
||||||
Default: `process.argv`
|
|
||||||
|
|
||||||
CLI arguments.
|
|
||||||
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "cookie",
|
|
||||||
"version": "1.0.2",
|
|
||||||
"description": "HTTP server cookie parsing and serialization",
|
|
||||||
"keywords": [
|
|
||||||
"cookie",
|
|
||||||
"cookies"
|
|
||||||
],
|
|
||||||
"repository": "jshttp/cookie",
|
|
||||||
"license": "MIT",
|
|
||||||
"author": "Roman Shtylman <shtylman@gmail.com>",
|
|
||||||
"contributors": [
|
|
||||||
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
|
||||||
],
|
|
||||||
"main": "dist/index.js",
|
|
||||||
"types": "dist/index.d.ts",
|
|
||||||
"files": [
|
|
||||||
"dist/"
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"bench": "vitest bench",
|
|
||||||
"build": "ts-scripts build",
|
|
||||||
"format": "ts-scripts format",
|
|
||||||
"prepare": "ts-scripts install",
|
|
||||||
"prepublishOnly": "npm run build",
|
|
||||||
"specs": "ts-scripts specs",
|
|
||||||
"test": "ts-scripts test"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@borderless/ts-scripts": "^0.15.0",
|
|
||||||
"@vitest/coverage-v8": "^2.1.2",
|
|
||||||
"top-sites": "1.1.194",
|
|
||||||
"typescript": "^5.6.2",
|
|
||||||
"vitest": "^2.1.2"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18"
|
|
||||||
},
|
|
||||||
"ts-scripts": {
|
|
||||||
"project": "tsconfig.build.json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,396 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
/* eslint-disable jsdoc/valid-types -- doesn't allow `readonly`.
|
|
||||||
TODO: remove eslint-disable when https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/164 is fixed
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
|
||||||
*/
|
|
||||||
/* eslint-enable jsdoc/valid-types -- doesn't allow `readonly string[]`. TODO: check why */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {VisitorKeys}
|
|
||||||
*/
|
|
||||||
const KEYS = {
|
|
||||||
ArrayExpression: [
|
|
||||||
"elements"
|
|
||||||
],
|
|
||||||
ArrayPattern: [
|
|
||||||
"elements"
|
|
||||||
],
|
|
||||||
ArrowFunctionExpression: [
|
|
||||||
"params",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
AssignmentExpression: [
|
|
||||||
"left",
|
|
||||||
"right"
|
|
||||||
],
|
|
||||||
AssignmentPattern: [
|
|
||||||
"left",
|
|
||||||
"right"
|
|
||||||
],
|
|
||||||
AwaitExpression: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
BinaryExpression: [
|
|
||||||
"left",
|
|
||||||
"right"
|
|
||||||
],
|
|
||||||
BlockStatement: [
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
BreakStatement: [
|
|
||||||
"label"
|
|
||||||
],
|
|
||||||
CallExpression: [
|
|
||||||
"callee",
|
|
||||||
"arguments"
|
|
||||||
],
|
|
||||||
CatchClause: [
|
|
||||||
"param",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
ChainExpression: [
|
|
||||||
"expression"
|
|
||||||
],
|
|
||||||
ClassBody: [
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
ClassDeclaration: [
|
|
||||||
"id",
|
|
||||||
"superClass",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
ClassExpression: [
|
|
||||||
"id",
|
|
||||||
"superClass",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
ConditionalExpression: [
|
|
||||||
"test",
|
|
||||||
"consequent",
|
|
||||||
"alternate"
|
|
||||||
],
|
|
||||||
ContinueStatement: [
|
|
||||||
"label"
|
|
||||||
],
|
|
||||||
DebuggerStatement: [],
|
|
||||||
DoWhileStatement: [
|
|
||||||
"body",
|
|
||||||
"test"
|
|
||||||
],
|
|
||||||
EmptyStatement: [],
|
|
||||||
ExperimentalRestProperty: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
ExperimentalSpreadProperty: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
ExportAllDeclaration: [
|
|
||||||
"exported",
|
|
||||||
"source",
|
|
||||||
"attributes"
|
|
||||||
],
|
|
||||||
ExportDefaultDeclaration: [
|
|
||||||
"declaration"
|
|
||||||
],
|
|
||||||
ExportNamedDeclaration: [
|
|
||||||
"declaration",
|
|
||||||
"specifiers",
|
|
||||||
"source",
|
|
||||||
"attributes"
|
|
||||||
],
|
|
||||||
ExportSpecifier: [
|
|
||||||
"exported",
|
|
||||||
"local"
|
|
||||||
],
|
|
||||||
ExpressionStatement: [
|
|
||||||
"expression"
|
|
||||||
],
|
|
||||||
ForInStatement: [
|
|
||||||
"left",
|
|
||||||
"right",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
ForOfStatement: [
|
|
||||||
"left",
|
|
||||||
"right",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
ForStatement: [
|
|
||||||
"init",
|
|
||||||
"test",
|
|
||||||
"update",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
FunctionDeclaration: [
|
|
||||||
"id",
|
|
||||||
"params",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
FunctionExpression: [
|
|
||||||
"id",
|
|
||||||
"params",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
Identifier: [],
|
|
||||||
IfStatement: [
|
|
||||||
"test",
|
|
||||||
"consequent",
|
|
||||||
"alternate"
|
|
||||||
],
|
|
||||||
ImportAttribute: [
|
|
||||||
"key",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
ImportDeclaration: [
|
|
||||||
"specifiers",
|
|
||||||
"source",
|
|
||||||
"attributes"
|
|
||||||
],
|
|
||||||
ImportDefaultSpecifier: [
|
|
||||||
"local"
|
|
||||||
],
|
|
||||||
ImportExpression: [
|
|
||||||
"source",
|
|
||||||
"options"
|
|
||||||
],
|
|
||||||
ImportNamespaceSpecifier: [
|
|
||||||
"local"
|
|
||||||
],
|
|
||||||
ImportSpecifier: [
|
|
||||||
"imported",
|
|
||||||
"local"
|
|
||||||
],
|
|
||||||
JSXAttribute: [
|
|
||||||
"name",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
JSXClosingElement: [
|
|
||||||
"name"
|
|
||||||
],
|
|
||||||
JSXClosingFragment: [],
|
|
||||||
JSXElement: [
|
|
||||||
"openingElement",
|
|
||||||
"children",
|
|
||||||
"closingElement"
|
|
||||||
],
|
|
||||||
JSXEmptyExpression: [],
|
|
||||||
JSXExpressionContainer: [
|
|
||||||
"expression"
|
|
||||||
],
|
|
||||||
JSXFragment: [
|
|
||||||
"openingFragment",
|
|
||||||
"children",
|
|
||||||
"closingFragment"
|
|
||||||
],
|
|
||||||
JSXIdentifier: [],
|
|
||||||
JSXMemberExpression: [
|
|
||||||
"object",
|
|
||||||
"property"
|
|
||||||
],
|
|
||||||
JSXNamespacedName: [
|
|
||||||
"namespace",
|
|
||||||
"name"
|
|
||||||
],
|
|
||||||
JSXOpeningElement: [
|
|
||||||
"name",
|
|
||||||
"attributes"
|
|
||||||
],
|
|
||||||
JSXOpeningFragment: [],
|
|
||||||
JSXSpreadAttribute: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
JSXSpreadChild: [
|
|
||||||
"expression"
|
|
||||||
],
|
|
||||||
JSXText: [],
|
|
||||||
LabeledStatement: [
|
|
||||||
"label",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
Literal: [],
|
|
||||||
LogicalExpression: [
|
|
||||||
"left",
|
|
||||||
"right"
|
|
||||||
],
|
|
||||||
MemberExpression: [
|
|
||||||
"object",
|
|
||||||
"property"
|
|
||||||
],
|
|
||||||
MetaProperty: [
|
|
||||||
"meta",
|
|
||||||
"property"
|
|
||||||
],
|
|
||||||
MethodDefinition: [
|
|
||||||
"key",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
NewExpression: [
|
|
||||||
"callee",
|
|
||||||
"arguments"
|
|
||||||
],
|
|
||||||
ObjectExpression: [
|
|
||||||
"properties"
|
|
||||||
],
|
|
||||||
ObjectPattern: [
|
|
||||||
"properties"
|
|
||||||
],
|
|
||||||
PrivateIdentifier: [],
|
|
||||||
Program: [
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
Property: [
|
|
||||||
"key",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
PropertyDefinition: [
|
|
||||||
"key",
|
|
||||||
"value"
|
|
||||||
],
|
|
||||||
RestElement: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
ReturnStatement: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
SequenceExpression: [
|
|
||||||
"expressions"
|
|
||||||
],
|
|
||||||
SpreadElement: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
StaticBlock: [
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
Super: [],
|
|
||||||
SwitchCase: [
|
|
||||||
"test",
|
|
||||||
"consequent"
|
|
||||||
],
|
|
||||||
SwitchStatement: [
|
|
||||||
"discriminant",
|
|
||||||
"cases"
|
|
||||||
],
|
|
||||||
TaggedTemplateExpression: [
|
|
||||||
"tag",
|
|
||||||
"quasi"
|
|
||||||
],
|
|
||||||
TemplateElement: [],
|
|
||||||
TemplateLiteral: [
|
|
||||||
"quasis",
|
|
||||||
"expressions"
|
|
||||||
],
|
|
||||||
ThisExpression: [],
|
|
||||||
ThrowStatement: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
TryStatement: [
|
|
||||||
"block",
|
|
||||||
"handler",
|
|
||||||
"finalizer"
|
|
||||||
],
|
|
||||||
UnaryExpression: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
UpdateExpression: [
|
|
||||||
"argument"
|
|
||||||
],
|
|
||||||
VariableDeclaration: [
|
|
||||||
"declarations"
|
|
||||||
],
|
|
||||||
VariableDeclarator: [
|
|
||||||
"id",
|
|
||||||
"init"
|
|
||||||
],
|
|
||||||
WhileStatement: [
|
|
||||||
"test",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
WithStatement: [
|
|
||||||
"object",
|
|
||||||
"body"
|
|
||||||
],
|
|
||||||
YieldExpression: [
|
|
||||||
"argument"
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
// Types.
|
|
||||||
const NODE_TYPES = Object.keys(KEYS);
|
|
||||||
|
|
||||||
// Freeze the keys.
|
|
||||||
for (const type of NODE_TYPES) {
|
|
||||||
Object.freeze(KEYS[type]);
|
|
||||||
}
|
|
||||||
Object.freeze(KEYS);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
||||||
* See LICENSE file in root directory for full license.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
|
|
||||||
*/
|
|
||||||
|
|
||||||
// List to ignore keys.
|
|
||||||
const KEY_BLACKLIST = new Set([
|
|
||||||
"parent",
|
|
||||||
"leadingComments",
|
|
||||||
"trailingComments"
|
|
||||||
]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether a given key should be used or not.
|
|
||||||
* @param {string} key The key to check.
|
|
||||||
* @returns {boolean} `true` if the key should be used.
|
|
||||||
*/
|
|
||||||
function filterKey(key) {
|
|
||||||
return !KEY_BLACKLIST.has(key) && key[0] !== "_";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* eslint-disable jsdoc/valid-types -- doesn't allow `readonly`.
|
|
||||||
TODO: remove eslint-disable when https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/164 is fixed
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Get visitor keys of a given node.
|
|
||||||
* @param {Object} node The AST node to get keys.
|
|
||||||
* @returns {readonly string[]} Visitor keys of the node.
|
|
||||||
*/
|
|
||||||
function getKeys(node) {
|
|
||||||
return Object.keys(node).filter(filterKey);
|
|
||||||
}
|
|
||||||
/* eslint-enable jsdoc/valid-types -- doesn't allow `readonly` */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make the union set with `KEYS` and given keys.
|
|
||||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
|
||||||
* @returns {VisitorKeys} The union set.
|
|
||||||
*/
|
|
||||||
function unionWith(additionalKeys) {
|
|
||||||
const retv = /** @type {{ [type: string]: ReadonlyArray<string> }} */
|
|
||||||
(Object.assign({}, KEYS));
|
|
||||||
|
|
||||||
for (const type of Object.keys(additionalKeys)) {
|
|
||||||
if (Object.hasOwn(retv, type)) {
|
|
||||||
const keys = new Set(additionalKeys[type]);
|
|
||||||
|
|
||||||
for (const key of retv[type]) {
|
|
||||||
keys.add(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
retv[type] = Object.freeze(Array.from(keys));
|
|
||||||
} else {
|
|
||||||
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.freeze(retv);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.KEYS = KEYS;
|
|
||||||
exports.getKeys = getKeys;
|
|
||||||
exports.unionWith = unionWith;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports={C:{"135":0.04712,"136":0.11781,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 137 138 139 140 3.5 3.6"},D:{"43":0.04712,"48":0.02356,"51":0.02356,"122":0.04712,"132":0.1885,"133":1.34089,"134":4.89661,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 45 46 47 49 50 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 123 124 125 126 127 128 129 130 131 135 136 137 138"},F:{"85":0.02356,"117":0.09425,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"118":0.14137,"131":0.04712,"132":0.84823,"133":0.61261,"134":1.48226,_:"12 13 14 15 16 17 18 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 119 120 121 122 123 124 125 126 127 128 129 130"},E:{_:"0 4 5 6 7 8 9 10 11 12 13 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 12.1 13.1 14.1 15.1 15.2-15.3 15.4 15.5 15.6 16.0 16.1 16.2 16.3 16.4 16.5 17.0 17.1 17.2 17.3 17.4 17.5 17.6 18.0 18.2 18.4","16.6":0.44768,"18.1":0.07069,"18.3":0.23562},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00121,"5.0-5.1":0,"6.0-6.1":0.00364,"7.0-7.1":0.00242,"8.1-8.4":0,"9.0-9.2":0.00182,"9.3":0.00848,"10.0-10.2":0.00061,"10.3":0.01393,"11.0-11.2":0.06422,"11.3-11.4":0.00424,"12.0-12.1":0.00242,"12.2-12.5":0.05998,"13.0-13.1":0.00121,"13.2":0.00182,"13.3":0.00242,"13.4-13.7":0.00848,"14.0-14.4":0.0212,"14.5-14.8":0.02545,"15.0-15.1":0.01393,"15.2-15.3":0.01393,"15.4":0.01696,"15.5":0.01939,"15.6-15.8":0.23871,"16.0":0.03393,"16.1":0.06967,"16.2":0.03635,"16.3":0.06301,"16.4":0.01393,"16.5":0.02605,"16.6-16.7":0.28293,"17.0":0.01696,"17.1":0.03029,"17.2":0.02302,"17.3":0.03211,"17.4":0.06422,"17.5":0.14298,"17.6-17.7":0.41501,"18.0":0.11632,"18.1":0.38047,"18.2":0.17024,"18.3":3.55817,"18.4":0.05271},P:{"23":0.05071,"24":0.02028,"25":0.09127,"26":0.02028,"27":1.00401,_:"4 20 21 22 5.0-5.4 6.2-6.4 7.2-7.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0"},I:{"0":0.11762,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00004,"4.4":0,"4.4.3-4.4.4":0.00013},K:{"0":0.33004,_:"10 11 12 11.1 11.5 12.1"},A:{_:"6 7 8 9 10 11 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{_:"0"},Q:{_:"14.9"},O:{"0":0.07072},H:{"0":0},L:{"0":80.52874}};
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
export type Manifest = {
|
|
||||||
routes: Record<
|
|
||||||
string,
|
|
||||||
{
|
|
||||||
filePath?: string
|
|
||||||
preloads?: Array<string>
|
|
||||||
assets?: Array<RouterManagedTag>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type RouterManagedTag =
|
|
||||||
| {
|
|
||||||
tag: 'title'
|
|
||||||
attrs?: Record<string, any>
|
|
||||||
children: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
tag: 'meta' | 'link'
|
|
||||||
attrs?: Record<string, any>
|
|
||||||
children?: never
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
tag: 'script'
|
|
||||||
attrs?: Record<string, any>
|
|
||||||
children?: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
tag: 'style'
|
|
||||||
attrs?: Record<string, any>
|
|
||||||
children?: string
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright 2022 Andrey Sitnik <andrey@sitnik.ru> 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.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"names":["_importDeferProxy","init","ns","constValue","v","proxy","run","_target","p","receiver","Proxy","defineProperty","deleteProperty","get","Reflect","getOwnPropertyDescriptor","getPrototypeOf","isExtensible","has","ownKeys","preventExtensions","set","setPrototypeOf"],"sources":["../../src/helpers/importDeferProxy.ts"],"sourcesContent":["/* @minVersion 7.23.0 */\n\nexport default function _importDeferProxy<T extends object>(\n init: () => T,\n): ProxyHandler<T> {\n var ns: T | null = null;\n\n var constValue = function <V extends boolean | null>(v: V) {\n return function (): V {\n return v;\n };\n };\n\n var proxy = function (run: Function) {\n return function (_target: T, p?: string | symbol, receiver?: any) {\n if (ns === null) ns = init();\n return run(ns, p, receiver);\n };\n };\n\n return new Proxy(\n {},\n {\n defineProperty: constValue(false),\n deleteProperty: constValue(false),\n get: proxy(Reflect.get),\n getOwnPropertyDescriptor: proxy(Reflect.getOwnPropertyDescriptor),\n getPrototypeOf: constValue(null),\n isExtensible: constValue(false),\n has: proxy(Reflect.has),\n ownKeys: proxy(Reflect.ownKeys),\n preventExtensions: constValue(true),\n set: constValue(false),\n setPrototypeOf: constValue(false),\n },\n );\n}\n"],"mappings":";;;;;;AAEe,SAASA,iBAAiBA,CACvCC,IAAa,EACI;EACjB,IAAIC,EAAY,GAAG,IAAI;EAEvB,IAAIC,UAAU,GAAG,SAAAA,CAAoCC,CAAI,EAAE;IACzD,OAAO,YAAe;MACpB,OAAOA,CAAC;IACV,CAAC;EACH,CAAC;EAED,IAAIC,KAAK,GAAG,SAAAA,CAAUC,GAAa,EAAE;IACnC,OAAO,UAAUC,OAAU,EAAEC,CAAmB,EAAEC,QAAc,EAAE;MAChE,IAAIP,EAAE,KAAK,IAAI,EAAEA,EAAE,GAAGD,IAAI,CAAC,CAAC;MAC5B,OAAOK,GAAG,CAACJ,EAAE,EAAEM,CAAC,EAAEC,QAAQ,CAAC;IAC7B,CAAC;EACH,CAAC;EAED,OAAO,IAAIC,KAAK,CACd,CAAC,CAAC,EACF;IACEC,cAAc,EAAER,UAAU,CAAC,KAAK,CAAC;IACjCS,cAAc,EAAET,UAAU,CAAC,KAAK,CAAC;IACjCU,GAAG,EAAER,KAAK,CAACS,OAAO,CAACD,GAAG,CAAC;IACvBE,wBAAwB,EAAEV,KAAK,CAACS,OAAO,CAACC,wBAAwB,CAAC;IACjEC,cAAc,EAAEb,UAAU,CAAC,IAAI,CAAC;IAChCc,YAAY,EAAEd,UAAU,CAAC,KAAK,CAAC;IAC/Be,GAAG,EAAEb,KAAK,CAACS,OAAO,CAACI,GAAG,CAAC;IACvBC,OAAO,EAAEd,KAAK,CAACS,OAAO,CAACK,OAAO,CAAC;IAC/BC,iBAAiB,EAAEjB,UAAU,CAAC,IAAI,CAAC;IACnCkB,GAAG,EAAElB,UAAU,CAAC,KAAK,CAAC;IACtBmB,cAAc,EAAEnB,UAAU,CAAC,KAAK;EAClC,CACF,CAAC;AACH","ignoreList":[]}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports={A:{A:{"1":"D E F A B","2":"mC","8":"K"},B:{"1":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"0 1 2 3 4 5 6 7 8 9 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC qC rC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC"},E:{"1":"J PB K D E F A B C L M G sC SC tC uC vC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","1025":"wC"},F:{"1":"0 1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"E DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"SC 9C lC","132":"AD BD CD"},H:{"2":"WD"},I:{"1":"LC I bD cD","260":"XD YD ZD","513":"J aD lC"},J:{"1":"D A"},K:{"1":"A B C H FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:2,C:"CSS position:fixed",D:true};
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview enforce the location of arrow function bodies
|
|
||||||
* @author Sharmila Jesupaul
|
|
||||||
* @deprecated in ESLint v8.53.0
|
|
||||||
*/
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const { isCommentToken, isNotOpeningParenToken } = require("./utils/ast-utils");
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Rule Definition
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
deprecated: {
|
|
||||||
message: "Formatting rules are being moved out of ESLint core.",
|
|
||||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
||||||
deprecatedSince: "8.53.0",
|
|
||||||
availableUntil: "10.0.0",
|
|
||||||
replacedBy: [
|
|
||||||
{
|
|
||||||
message:
|
|
||||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
||||||
url: "https://eslint.style/guide/migration",
|
|
||||||
plugin: {
|
|
||||||
name: "@stylistic/eslint-plugin-js",
|
|
||||||
url: "https://eslint.style/packages/js",
|
|
||||||
},
|
|
||||||
rule: {
|
|
||||||
name: "implicit-arrow-linebreak",
|
|
||||||
url: "https://eslint.style/rules/js/implicit-arrow-linebreak",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
type: "layout",
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description: "Enforce the location of arrow function bodies",
|
|
||||||
recommended: false,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/implicit-arrow-linebreak",
|
|
||||||
},
|
|
||||||
|
|
||||||
fixable: "whitespace",
|
|
||||||
|
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
enum: ["beside", "below"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
messages: {
|
|
||||||
expected: "Expected a linebreak before this expression.",
|
|
||||||
unexpected: "Expected no linebreak before this expression.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
const sourceCode = context.sourceCode;
|
|
||||||
const option = context.options[0] || "beside";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates the location of an arrow function body
|
|
||||||
* @param {ASTNode} node The arrow function body
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
function validateExpression(node) {
|
|
||||||
if (node.body.type === "BlockStatement") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const arrowToken = sourceCode.getTokenBefore(
|
|
||||||
node.body,
|
|
||||||
isNotOpeningParenToken,
|
|
||||||
);
|
|
||||||
const firstTokenOfBody = sourceCode.getTokenAfter(arrowToken);
|
|
||||||
|
|
||||||
if (
|
|
||||||
arrowToken.loc.end.line === firstTokenOfBody.loc.start.line &&
|
|
||||||
option === "below"
|
|
||||||
) {
|
|
||||||
context.report({
|
|
||||||
node: firstTokenOfBody,
|
|
||||||
messageId: "expected",
|
|
||||||
fix: fixer =>
|
|
||||||
fixer.insertTextBefore(firstTokenOfBody, "\n"),
|
|
||||||
});
|
|
||||||
} else if (
|
|
||||||
arrowToken.loc.end.line !== firstTokenOfBody.loc.start.line &&
|
|
||||||
option === "beside"
|
|
||||||
) {
|
|
||||||
context.report({
|
|
||||||
node: firstTokenOfBody,
|
|
||||||
messageId: "unexpected",
|
|
||||||
fix(fixer) {
|
|
||||||
if (
|
|
||||||
sourceCode.getFirstTokenBetween(
|
|
||||||
arrowToken,
|
|
||||||
firstTokenOfBody,
|
|
||||||
{
|
|
||||||
includeComments: true,
|
|
||||||
filter: isCommentToken,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fixer.replaceTextRange(
|
|
||||||
[arrowToken.range[1], firstTokenOfBody.range[0]],
|
|
||||||
" ",
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// Public
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
return {
|
|
||||||
ArrowFunctionExpression: node => validateExpression(node),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Define 2 token factories; forward and backward.
|
|
||||||
* @author Toru Nagashima
|
|
||||||
*/
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Requirements
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const BackwardTokenCommentCursor = require("./backward-token-comment-cursor");
|
|
||||||
const BackwardTokenCursor = require("./backward-token-cursor");
|
|
||||||
const FilterCursor = require("./filter-cursor");
|
|
||||||
const ForwardTokenCommentCursor = require("./forward-token-comment-cursor");
|
|
||||||
const ForwardTokenCursor = require("./forward-token-cursor");
|
|
||||||
const LimitCursor = require("./limit-cursor");
|
|
||||||
const SkipCursor = require("./skip-cursor");
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The cursor factory.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
class CursorFactory {
|
|
||||||
/**
|
|
||||||
* Initializes this cursor.
|
|
||||||
* @param {Function} TokenCursor The class of the cursor which iterates tokens only.
|
|
||||||
* @param {Function} TokenCommentCursor The class of the cursor which iterates the mix of tokens and comments.
|
|
||||||
*/
|
|
||||||
constructor(TokenCursor, TokenCommentCursor) {
|
|
||||||
this.TokenCursor = TokenCursor;
|
|
||||||
this.TokenCommentCursor = TokenCommentCursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a base cursor instance that can be decorated by createCursor.
|
|
||||||
* @param {Token[]} tokens The array of tokens.
|
|
||||||
* @param {Comment[]} comments The array of comments.
|
|
||||||
* @param {Object} indexMap The map from locations to indices in `tokens`.
|
|
||||||
* @param {number} startLoc The start location of the iteration range.
|
|
||||||
* @param {number} endLoc The end location of the iteration range.
|
|
||||||
* @param {boolean} includeComments The flag to iterate comments as well.
|
|
||||||
* @returns {Cursor} The created base cursor.
|
|
||||||
*/
|
|
||||||
createBaseCursor(
|
|
||||||
tokens,
|
|
||||||
comments,
|
|
||||||
indexMap,
|
|
||||||
startLoc,
|
|
||||||
endLoc,
|
|
||||||
includeComments,
|
|
||||||
) {
|
|
||||||
const Cursor = includeComments
|
|
||||||
? this.TokenCommentCursor
|
|
||||||
: this.TokenCursor;
|
|
||||||
|
|
||||||
return new Cursor(tokens, comments, indexMap, startLoc, endLoc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a cursor that iterates tokens with normalized options.
|
|
||||||
* @param {Token[]} tokens The array of tokens.
|
|
||||||
* @param {Comment[]} comments The array of comments.
|
|
||||||
* @param {Object} indexMap The map from locations to indices in `tokens`.
|
|
||||||
* @param {number} startLoc The start location of the iteration range.
|
|
||||||
* @param {number} endLoc The end location of the iteration range.
|
|
||||||
* @param {boolean} includeComments The flag to iterate comments as well.
|
|
||||||
* @param {Function|null} filter The predicate function to choose tokens.
|
|
||||||
* @param {number} skip The count of tokens the cursor skips.
|
|
||||||
* @param {number} count The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
|
|
||||||
* @returns {Cursor} The created cursor.
|
|
||||||
*/
|
|
||||||
createCursor(
|
|
||||||
tokens,
|
|
||||||
comments,
|
|
||||||
indexMap,
|
|
||||||
startLoc,
|
|
||||||
endLoc,
|
|
||||||
includeComments,
|
|
||||||
filter,
|
|
||||||
skip,
|
|
||||||
count,
|
|
||||||
) {
|
|
||||||
let cursor = this.createBaseCursor(
|
|
||||||
tokens,
|
|
||||||
comments,
|
|
||||||
indexMap,
|
|
||||||
startLoc,
|
|
||||||
endLoc,
|
|
||||||
includeComments,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (filter) {
|
|
||||||
cursor = new FilterCursor(cursor, filter);
|
|
||||||
}
|
|
||||||
if (skip >= 1) {
|
|
||||||
cursor = new SkipCursor(cursor, skip);
|
|
||||||
}
|
|
||||||
if (count >= 0) {
|
|
||||||
cursor = new LimitCursor(cursor, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Exports
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
forward: new CursorFactory(ForwardTokenCursor, ForwardTokenCommentCursor),
|
|
||||||
backward: new CursorFactory(
|
|
||||||
BackwardTokenCursor,
|
|
||||||
BackwardTokenCommentCursor,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
exports.default = populatePlaceholders;
|
|
||||||
var _t = require("@babel/types");
|
|
||||||
const {
|
|
||||||
blockStatement,
|
|
||||||
cloneNode,
|
|
||||||
emptyStatement,
|
|
||||||
expressionStatement,
|
|
||||||
identifier,
|
|
||||||
isStatement,
|
|
||||||
isStringLiteral,
|
|
||||||
stringLiteral,
|
|
||||||
validate
|
|
||||||
} = _t;
|
|
||||||
function populatePlaceholders(metadata, replacements) {
|
|
||||||
const ast = cloneNode(metadata.ast);
|
|
||||||
if (replacements) {
|
|
||||||
metadata.placeholders.forEach(placeholder => {
|
|
||||||
if (!hasOwnProperty.call(replacements, placeholder.name)) {
|
|
||||||
const placeholderName = placeholder.name;
|
|
||||||
throw new Error(`Error: No substitution given for "${placeholderName}". If this is not meant to be a
|
|
||||||
placeholder you may want to consider passing one of the following options to @babel/template:
|
|
||||||
- { placeholderPattern: false, placeholderWhitelist: new Set(['${placeholderName}'])}
|
|
||||||
- { placeholderPattern: /^${placeholderName}$/ }`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Object.keys(replacements).forEach(key => {
|
|
||||||
if (!metadata.placeholderNames.has(key)) {
|
|
||||||
throw new Error(`Unknown substitution "${key}" given`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
metadata.placeholders.slice().reverse().forEach(placeholder => {
|
|
||||||
try {
|
|
||||||
applyReplacement(placeholder, ast, replacements && replacements[placeholder.name] || null);
|
|
||||||
} catch (e) {
|
|
||||||
e.message = `@babel/template placeholder "${placeholder.name}": ${e.message}`;
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return ast;
|
|
||||||
}
|
|
||||||
function applyReplacement(placeholder, ast, replacement) {
|
|
||||||
if (placeholder.isDuplicate) {
|
|
||||||
if (Array.isArray(replacement)) {
|
|
||||||
replacement = replacement.map(node => cloneNode(node));
|
|
||||||
} else if (typeof replacement === "object") {
|
|
||||||
replacement = cloneNode(replacement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const {
|
|
||||||
parent,
|
|
||||||
key,
|
|
||||||
index
|
|
||||||
} = placeholder.resolve(ast);
|
|
||||||
if (placeholder.type === "string") {
|
|
||||||
if (typeof replacement === "string") {
|
|
||||||
replacement = stringLiteral(replacement);
|
|
||||||
}
|
|
||||||
if (!replacement || !isStringLiteral(replacement)) {
|
|
||||||
throw new Error("Expected string substitution");
|
|
||||||
}
|
|
||||||
} else if (placeholder.type === "statement") {
|
|
||||||
if (index === undefined) {
|
|
||||||
if (!replacement) {
|
|
||||||
replacement = emptyStatement();
|
|
||||||
} else if (Array.isArray(replacement)) {
|
|
||||||
replacement = blockStatement(replacement);
|
|
||||||
} else if (typeof replacement === "string") {
|
|
||||||
replacement = expressionStatement(identifier(replacement));
|
|
||||||
} else if (!isStatement(replacement)) {
|
|
||||||
replacement = expressionStatement(replacement);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (replacement && !Array.isArray(replacement)) {
|
|
||||||
if (typeof replacement === "string") {
|
|
||||||
replacement = identifier(replacement);
|
|
||||||
}
|
|
||||||
if (!isStatement(replacement)) {
|
|
||||||
replacement = expressionStatement(replacement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (placeholder.type === "param") {
|
|
||||||
if (typeof replacement === "string") {
|
|
||||||
replacement = identifier(replacement);
|
|
||||||
}
|
|
||||||
if (index === undefined) throw new Error("Assertion failure.");
|
|
||||||
} else {
|
|
||||||
if (typeof replacement === "string") {
|
|
||||||
replacement = identifier(replacement);
|
|
||||||
}
|
|
||||||
if (Array.isArray(replacement)) {
|
|
||||||
throw new Error("Cannot replace single expression with an array.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function set(parent, key, value) {
|
|
||||||
const node = parent[key];
|
|
||||||
parent[key] = value;
|
|
||||||
if (node.type === "Identifier" || node.type === "Placeholder") {
|
|
||||||
if (node.typeAnnotation) {
|
|
||||||
value.typeAnnotation = node.typeAnnotation;
|
|
||||||
}
|
|
||||||
if (node.optional) {
|
|
||||||
value.optional = node.optional;
|
|
||||||
}
|
|
||||||
if (node.decorators) {
|
|
||||||
value.decorators = node.decorators;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (index === undefined) {
|
|
||||||
validate(parent, key, replacement);
|
|
||||||
set(parent, key, replacement);
|
|
||||||
} else {
|
|
||||||
const items = parent[key].slice();
|
|
||||||
if (placeholder.type === "statement" || placeholder.type === "param") {
|
|
||||||
if (replacement == null) {
|
|
||||||
items.splice(index, 1);
|
|
||||||
} else if (Array.isArray(replacement)) {
|
|
||||||
items.splice(index, 1, ...replacement);
|
|
||||||
} else {
|
|
||||||
set(items, index, replacement);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
set(items, index, replacement);
|
|
||||||
}
|
|
||||||
validate(parent, key, items);
|
|
||||||
parent[key] = items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//# sourceMappingURL=populate.js.map
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "gensync",
|
|
||||||
"version": "1.0.0-beta.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"description": "Allows users to use generators in order to write common functions that can be both sync or async.",
|
|
||||||
"main": "index.js",
|
|
||||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
|
||||||
"homepage": "https://github.com/loganfsmyth/gensync",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/loganfsmyth/gensync.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "jest"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.9.0"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"async",
|
|
||||||
"sync",
|
|
||||||
"generators",
|
|
||||||
"async-await",
|
|
||||||
"callbacks"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
|
||||||
"babel-core": "^6.26.3",
|
|
||||||
"babel-preset-env": "^1.6.1",
|
|
||||||
"eslint": "^4.19.1",
|
|
||||||
"eslint-config-prettier": "^2.9.0",
|
|
||||||
"eslint-plugin-node": "^6.0.1",
|
|
||||||
"eslint-plugin-prettier": "^2.6.0",
|
|
||||||
"flow-bin": "^0.71.0",
|
|
||||||
"jest": "^22.4.3",
|
|
||||||
"prettier": "^1.12.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"2":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"2 3 4 5 6 7 8 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB","2":"0 1 9 nC LC J PB K D E F A B C L M G N O P QB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC qC rC","322":"sB tB uB vB MC wB"},D:{"2":"0 9 J PB K D E F A B C L M G N O P QB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","194":"1 2 3 4 5 6 7 8 RB SB TB UB VB WB XB YB ZB"},E:{"2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"2":"0 1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC"},G:{"2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"2":"WD"},I:{"2":"LC J I XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"2":"A B C H FC kC GC"},L:{"2":"I"},M:{"2":"EC"},N:{"2":"A B"},O:{"2":"HC"},P:{"2":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"2":"oD"},R:{"2":"pD"},S:{"1":"qD","2":"rD"}},B:7,C:"Scoped attribute",D:true};
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "lru-cache",
|
|
||||||
"description": "A cache object that deletes the least-recently-used items.",
|
|
||||||
"version": "5.1.1",
|
|
||||||
"author": "Isaac Z. Schlueter <i@izs.me>",
|
|
||||||
"keywords": [
|
|
||||||
"mru",
|
|
||||||
"lru",
|
|
||||||
"cache"
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"test": "tap test/*.js --100 -J",
|
|
||||||
"snap": "TAP_SNAPSHOT=1 tap test/*.js -J",
|
|
||||||
"coveragerport": "tap --coverage-report=html",
|
|
||||||
"preversion": "npm test",
|
|
||||||
"postversion": "npm publish",
|
|
||||||
"postpublish": "git push origin --all; git push origin --tags"
|
|
||||||
},
|
|
||||||
"main": "index.js",
|
|
||||||
"repository": "git://github.com/isaacs/node-lru-cache.git",
|
|
||||||
"devDependencies": {
|
|
||||||
"benchmark": "^2.1.4",
|
|
||||||
"tap": "^12.1.0"
|
|
||||||
},
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"yallist": "^3.0.2"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { shallow } from 'zustand/vanilla/shallow';
|
|
||||||
|
|
||||||
function useShallow(selector) {
|
|
||||||
const prev = React.useRef(undefined);
|
|
||||||
return (state) => {
|
|
||||||
const next = selector(state);
|
|
||||||
return shallow(prev.current, next) ? prev.current : prev.current = next;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export { useShallow };
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
# brace-expansion
|
|
||||||
|
|
||||||
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
|
|
||||||
as known from sh/bash, in JavaScript.
|
|
||||||
|
|
||||||
[](http://travis-ci.org/juliangruber/brace-expansion)
|
|
||||||
[](https://www.npmjs.org/package/brace-expansion)
|
|
||||||
[](https://greenkeeper.io/)
|
|
||||||
|
|
||||||
[](https://ci.testling.com/juliangruber/brace-expansion)
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
var expand = require('brace-expansion');
|
|
||||||
|
|
||||||
expand('file-{a,b,c}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
|
||||||
|
|
||||||
expand('-v{,,}')
|
|
||||||
// => ['-v', '-v', '-v']
|
|
||||||
|
|
||||||
expand('file{0..2}.jpg')
|
|
||||||
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
|
|
||||||
|
|
||||||
expand('file-{a..c}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
|
||||||
|
|
||||||
expand('file{2..0}.jpg')
|
|
||||||
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
|
|
||||||
|
|
||||||
expand('file{0..4..2}.jpg')
|
|
||||||
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
|
|
||||||
|
|
||||||
expand('file-{a..e..2}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
|
|
||||||
|
|
||||||
expand('file{00..10..5}.jpg')
|
|
||||||
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
|
|
||||||
|
|
||||||
expand('{{A..C},{a..c}}')
|
|
||||||
// => ['A', 'B', 'C', 'a', 'b', 'c']
|
|
||||||
|
|
||||||
expand('ppp{,config,oe{,conf}}')
|
|
||||||
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
```js
|
|
||||||
var expand = require('brace-expansion');
|
|
||||||
```
|
|
||||||
|
|
||||||
### var expanded = expand(str)
|
|
||||||
|
|
||||||
Return an array of all possible and valid expansions of `str`. If none are
|
|
||||||
found, `[str]` is returned.
|
|
||||||
|
|
||||||
Valid expansions are:
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^(.*,)+(.+)?$/
|
|
||||||
// {a,b,...}
|
|
||||||
```
|
|
||||||
|
|
||||||
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
|
||||||
// {x..y[..incr]}
|
|
||||||
```
|
|
||||||
|
|
||||||
A numeric sequence from `x` to `y` inclusive, with optional increment.
|
|
||||||
If `x` or `y` start with a leading `0`, all the numbers will be padded
|
|
||||||
to have equal length. Negative numbers and backwards iteration work too.
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
|
||||||
// {x..y[..incr]}
|
|
||||||
```
|
|
||||||
|
|
||||||
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
|
|
||||||
`x` and `y` must be exactly one character, and if given, `incr` must be a
|
|
||||||
number.
|
|
||||||
|
|
||||||
For compatibility reasons, the string `${` is not eligible for brace expansion.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
With [npm](https://npmjs.org) do:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install brace-expansion
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
- [Julian Gruber](https://github.com/juliangruber)
|
|
||||||
- [Isaac Z. Schlueter](https://github.com/isaacs)
|
|
||||||
|
|
||||||
## Sponsors
|
|
||||||
|
|
||||||
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
|
|
||||||
|
|
||||||
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
(MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.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.
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
const numeric = /^[0-9]+$/
|
|
||||||
const compareIdentifiers = (a, b) => {
|
|
||||||
const anum = numeric.test(a)
|
|
||||||
const bnum = numeric.test(b)
|
|
||||||
|
|
||||||
if (anum && bnum) {
|
|
||||||
a = +a
|
|
||||||
b = +b
|
|
||||||
}
|
|
||||||
|
|
||||||
return a === b ? 0
|
|
||||||
: (anum && !bnum) ? -1
|
|
||||||
: (bnum && !anum) ? 1
|
|
||||||
: a < b ? -1
|
|
||||||
: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
compareIdentifiers,
|
|
||||||
rcompareIdentifiers,
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
||||||
Author Tobias Koppers @sokra
|
|
||||||
*/
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/** @typedef {import("./Resolver")} Resolver */
|
|
||||||
/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
|
|
||||||
|
|
||||||
module.exports = class DirectoryExistsPlugin {
|
|
||||||
/**
|
|
||||||
* @param {string | ResolveStepHook} source source
|
|
||||||
* @param {string | ResolveStepHook} target target
|
|
||||||
*/
|
|
||||||
constructor(source, target) {
|
|
||||||
this.source = source;
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Resolver} resolver the resolver
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
apply(resolver) {
|
|
||||||
const target = resolver.ensureHook(this.target);
|
|
||||||
resolver
|
|
||||||
.getHook(this.source)
|
|
||||||
.tapAsync(
|
|
||||||
"DirectoryExistsPlugin",
|
|
||||||
(request, resolveContext, callback) => {
|
|
||||||
const fs = resolver.fileSystem;
|
|
||||||
const directory = request.path;
|
|
||||||
if (!directory) return callback();
|
|
||||||
fs.stat(directory, (err, stat) => {
|
|
||||||
if (err || !stat) {
|
|
||||||
if (resolveContext.missingDependencies)
|
|
||||||
resolveContext.missingDependencies.add(directory);
|
|
||||||
if (resolveContext.log)
|
|
||||||
resolveContext.log(directory + " doesn't exist");
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
if (!stat.isDirectory()) {
|
|
||||||
if (resolveContext.missingDependencies)
|
|
||||||
resolveContext.missingDependencies.add(directory);
|
|
||||||
if (resolveContext.log)
|
|
||||||
resolveContext.log(directory + " is not a directory");
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
if (resolveContext.fileDependencies)
|
|
||||||
resolveContext.fileDependencies.add(directory);
|
|
||||||
resolver.doResolve(
|
|
||||||
target,
|
|
||||||
request,
|
|
||||||
`existing directory ${directory}`,
|
|
||||||
resolveContext,
|
|
||||||
callback
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import index from './index.js';
|
|
||||||
|
|
||||||
const { transform, transformStyleAttribute, bundle, bundleAsync, browserslistToTargets, composeVisitors, Features } = index;
|
|
||||||
export { transform, transformStyleAttribute, bundle, bundleAsync, browserslistToTargets, composeVisitors, Features };
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
exports.default = void 0;
|
|
||||||
var _rewriteStackTrace = require("./rewrite-stack-trace.js");
|
|
||||||
class ConfigError extends Error {
|
|
||||||
constructor(message, filename) {
|
|
||||||
super(message);
|
|
||||||
(0, _rewriteStackTrace.expectedError)(this);
|
|
||||||
if (filename) (0, _rewriteStackTrace.injectVirtualStackFrame)(this, filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.default = ConfigError;
|
|
||||||
0 && 0;
|
|
||||||
|
|
||||||
//# sourceMappingURL=config-error.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"names":["_findSuggestion","require","OptionValidator","constructor","descriptor","validateTopLevelOptions","options","TopLevelOptionShape","validOptionNames","Object","keys","option","includes","Error","formatMessage","findSuggestion","validateBooleanOption","name","value","defaultValue","undefined","invariant","validateStringOption","condition","message","exports"],"sources":["../src/validator.ts"],"sourcesContent":["import { findSuggestion } from \"./find-suggestion.ts\";\n\nexport class OptionValidator {\n declare descriptor: string;\n constructor(descriptor: string) {\n this.descriptor = descriptor;\n }\n\n /**\n * Validate if the given `options` follow the name of keys defined in the `TopLevelOptionShape`\n *\n * @param {Object} options\n * @param {Object} TopLevelOptionShape\n * An object with all the valid key names that `options` should be allowed to have\n * The property values of `TopLevelOptionShape` can be arbitrary\n * @memberof OptionValidator\n */\n validateTopLevelOptions(options: object, TopLevelOptionShape: object): void {\n const validOptionNames = Object.keys(TopLevelOptionShape);\n for (const option of Object.keys(options)) {\n if (!validOptionNames.includes(option)) {\n throw new Error(\n this.formatMessage(`'${option}' is not a valid top-level option.\n- Did you mean '${findSuggestion(option, validOptionNames)}'?`),\n );\n }\n }\n }\n\n // note: we do not consider rewrite them to high order functions\n // until we have to support `validateNumberOption`.\n validateBooleanOption<T extends boolean>(\n name: string,\n value?: boolean,\n defaultValue?: T,\n ): boolean | T {\n if (value === undefined) {\n return defaultValue;\n } else {\n this.invariant(\n typeof value === \"boolean\",\n `'${name}' option must be a boolean.`,\n );\n }\n return value;\n }\n\n validateStringOption<T extends string>(\n name: string,\n value?: string,\n defaultValue?: T,\n ): string | T {\n if (value === undefined) {\n return defaultValue;\n } else {\n this.invariant(\n typeof value === \"string\",\n `'${name}' option must be a string.`,\n );\n }\n return value;\n }\n /**\n * A helper interface copied from the `invariant` npm package.\n * It throws given `message` when `condition` is not met\n *\n * @param {boolean} condition\n * @param {string} message\n * @memberof OptionValidator\n */\n invariant(condition: boolean, message: string): void {\n if (!condition) {\n throw new Error(this.formatMessage(message));\n }\n }\n\n formatMessage(message: string): string {\n return `${this.descriptor}: ${message}`;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEO,MAAMC,eAAe,CAAC;EAE3BC,WAAWA,CAACC,UAAkB,EAAE;IAC9B,IAAI,CAACA,UAAU,GAAGA,UAAU;EAC9B;EAWAC,uBAAuBA,CAACC,OAAe,EAAEC,mBAA2B,EAAQ;IAC1E,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CAACH,mBAAmB,CAAC;IACzD,KAAK,MAAMI,MAAM,IAAIF,MAAM,CAACC,IAAI,CAACJ,OAAO,CAAC,EAAE;MACzC,IAAI,CAACE,gBAAgB,CAACI,QAAQ,CAACD,MAAM,CAAC,EAAE;QACtC,MAAM,IAAIE,KAAK,CACb,IAAI,CAACC,aAAa,CAAC,IAAIH,MAAM;AACvC,kBAAkB,IAAAI,8BAAc,EAACJ,MAAM,EAAEH,gBAAgB,CAAC,IAAI,CACtD,CAAC;MACH;IACF;EACF;EAIAQ,qBAAqBA,CACnBC,IAAY,EACZC,KAAe,EACfC,YAAgB,EACH;IACb,IAAID,KAAK,KAAKE,SAAS,EAAE;MACvB,OAAOD,YAAY;IACrB,CAAC,MAAM;MACL,IAAI,CAACE,SAAS,CACZ,OAAOH,KAAK,KAAK,SAAS,EAC1B,IAAID,IAAI,6BACV,CAAC;IACH;IACA,OAAOC,KAAK;EACd;EAEAI,oBAAoBA,CAClBL,IAAY,EACZC,KAAc,EACdC,YAAgB,EACJ;IACZ,IAAID,KAAK,KAAKE,SAAS,EAAE;MACvB,OAAOD,YAAY;IACrB,CAAC,MAAM;MACL,IAAI,CAACE,SAAS,CACZ,OAAOH,KAAK,KAAK,QAAQ,EACzB,IAAID,IAAI,4BACV,CAAC;IACH;IACA,OAAOC,KAAK;EACd;EASAG,SAASA,CAACE,SAAkB,EAAEC,OAAe,EAAQ;IACnD,IAAI,CAACD,SAAS,EAAE;MACd,MAAM,IAAIV,KAAK,CAAC,IAAI,CAACC,aAAa,CAACU,OAAO,CAAC,CAAC;IAC9C;EACF;EAEAV,aAAaA,CAACU,OAAe,EAAU;IACrC,OAAO,GAAG,IAAI,CAACpB,UAAU,KAAKoB,OAAO,EAAE;EACzC;AACF;AAACC,OAAA,CAAAvB,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports={C:{"52":0.01428,"54":0.00476,"78":0.01904,"82":0.00476,"88":0.01904,"102":0.00476,"103":0.00476,"109":0.00476,"115":0.15229,"123":0.00476,"125":0.00952,"127":0.00476,"128":0.04759,"130":0.00476,"131":0.00952,"132":0.00952,"133":0.03807,"134":0.02855,"135":0.44735,"136":1.26589,"137":0.00476,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 53 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 79 80 81 83 84 85 86 87 89 90 91 92 93 94 95 96 97 98 99 100 101 104 105 106 107 108 110 111 112 113 114 116 117 118 119 120 121 122 124 126 129 138 139 140 3.5 3.6"},D:{"25":0.03807,"26":0.00476,"34":0.00952,"38":0.05711,"39":0.0238,"40":0.0238,"41":0.02855,"42":0.0238,"43":0.02855,"44":0.0238,"45":0.0238,"46":0.02855,"47":0.02855,"48":0.02855,"49":0.03331,"50":0.0238,"51":0.0238,"52":0.02855,"53":0.02855,"54":0.02855,"55":0.02855,"56":0.02855,"57":0.02855,"58":0.02855,"59":0.02855,"60":0.02855,"66":0.00476,"73":0.00476,"74":0.00476,"76":0.00476,"78":0.00476,"79":0.05235,"80":0.00952,"81":0.03807,"85":0.0238,"86":0.00952,"87":0.04283,"88":0.02855,"89":0.00476,"90":0.00476,"91":0.00476,"92":0.00476,"93":0.00476,"94":0.00476,"97":0.00476,"98":0.00952,"99":0.00476,"100":0.00476,"101":0.00476,"102":0.00476,"103":0.0809,"104":0.0238,"105":0.00476,"106":0.00476,"107":0.01428,"108":0.03807,"109":0.42831,"110":0.00952,"111":0.03807,"112":0.01428,"113":0.01904,"114":0.04283,"115":0.00952,"116":0.19988,"117":0.01428,"118":0.00952,"119":0.02855,"120":0.03807,"121":0.05711,"122":0.09042,"123":0.07139,"124":0.08566,"125":0.17608,"126":0.11898,"127":0.09994,"128":0.22367,"129":0.09518,"130":0.16657,"131":0.98035,"132":1.05174,"133":8.50433,"134":13.6964,"135":0.01904,"136":0.01904,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 27 28 29 30 31 32 33 35 36 37 61 62 63 64 65 67 68 69 70 71 72 75 77 83 84 95 96 137 138"},F:{"46":0.01428,"87":0.00476,"95":0.00952,"114":0.00952,"115":0.00476,"116":0.28554,"117":0.65674,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 88 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"12":0.00952,"17":0.00476,"18":0.00952,"85":0.00952,"92":0.00476,"109":0.03807,"110":0.00476,"111":0.00476,"112":0.00476,"113":0.00952,"114":0.00952,"115":0.00476,"117":0.00476,"119":0.00476,"120":0.00952,"121":0.00476,"122":0.00952,"123":0.00476,"124":0.00476,"125":0.00952,"126":0.01428,"127":0.00952,"128":0.01428,"129":0.01904,"130":0.03331,"131":0.07614,"132":0.11422,"133":2.17486,"134":4.62099,_:"13 14 15 16 79 80 81 83 84 86 87 88 89 90 91 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 116 118"},E:{"13":0.00476,"14":0.04283,"15":0.00476,_:"0 4 5 6 7 8 9 10 11 12 3.1 3.2 5.1 6.1 7.1 9.1 10.1","11.1":0.00476,"12.1":0.01904,"13.1":0.08566,"14.1":0.13325,"15.1":0.01428,"15.2-15.3":0.01428,"15.4":0.03331,"15.5":0.04759,"15.6":0.46162,"16.0":0.06187,"16.1":0.0809,"16.2":0.05235,"16.3":0.12849,"16.4":0.04283,"16.5":0.05711,"16.6":0.5568,"17.0":0.01428,"17.1":0.41879,"17.2":0.04759,"17.3":0.05711,"17.4":0.14753,"17.5":0.24271,"17.6":0.6853,"18.0":0.07614,"18.1":0.32361,"18.2":0.13801,"18.3":3.81196,"18.4":0.04283},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00456,"5.0-5.1":0,"6.0-6.1":0.01369,"7.0-7.1":0.00913,"8.1-8.4":0,"9.0-9.2":0.00685,"9.3":0.03195,"10.0-10.2":0.00228,"10.3":0.05248,"11.0-11.2":0.24188,"11.3-11.4":0.01597,"12.0-12.1":0.00913,"12.2-12.5":0.22591,"13.0-13.1":0.00456,"13.2":0.00685,"13.3":0.00913,"13.4-13.7":0.03195,"14.0-14.4":0.07987,"14.5-14.8":0.09584,"15.0-15.1":0.05248,"15.2-15.3":0.05248,"15.4":0.06389,"15.5":0.07302,"15.6-15.8":0.89908,"16.0":0.12779,"16.1":0.26242,"16.2":0.13692,"16.3":0.23732,"16.4":0.05248,"16.5":0.09812,"16.6-16.7":1.06566,"17.0":0.06389,"17.1":0.1141,"17.2":0.08671,"17.3":0.12094,"17.4":0.24188,"17.5":0.53854,"17.6-17.7":1.56312,"18.0":0.43813,"18.1":1.43305,"18.2":0.64122,"18.3":13.40178,"18.4":0.19853},P:{"4":0.09767,"20":0.01085,"21":0.03256,"22":0.01085,"23":0.0217,"24":0.03256,"25":0.03256,"26":0.07597,"27":2.7131,"5.0-5.4":0.01085,"6.2-6.4":0.01085,"7.2-7.4":0.01085,_:"8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 17.0 18.0","19.0":0.01085},I:{"0":0.02092,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00002},K:{"0":0.14151,_:"10 11 12 11.1 11.5 12.1"},A:{"9":0.03127,"11":0.07818,_:"6 7 8 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.56079},Q:{"14.9":0.01048},O:{"0":0.04717},H:{"0":0},L:{"0":26.14679}};
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
struct Closure;
|
|
||||||
|
|
||||||
#include "backend/Backend.h"
|
|
||||||
#include "closure.h"
|
|
||||||
#include <cairo.h>
|
|
||||||
#include "dll_visibility.h"
|
|
||||||
#include <napi.h>
|
|
||||||
#include <pango/pangocairo.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FontFace describes a font file in terms of one PangoFontDescription that
|
|
||||||
* will resolve to it and one that the user describes it as (like @font-face)
|
|
||||||
*/
|
|
||||||
class FontFace {
|
|
||||||
public:
|
|
||||||
PangoFontDescription *sys_desc = nullptr;
|
|
||||||
PangoFontDescription *user_desc = nullptr;
|
|
||||||
unsigned char file_path[1024];
|
|
||||||
};
|
|
||||||
|
|
||||||
enum text_baseline_t : uint8_t {
|
|
||||||
TEXT_BASELINE_ALPHABETIC = 0,
|
|
||||||
TEXT_BASELINE_TOP = 1,
|
|
||||||
TEXT_BASELINE_BOTTOM = 2,
|
|
||||||
TEXT_BASELINE_MIDDLE = 3,
|
|
||||||
TEXT_BASELINE_IDEOGRAPHIC = 4,
|
|
||||||
TEXT_BASELINE_HANGING = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
enum text_align_t : int8_t {
|
|
||||||
TEXT_ALIGNMENT_LEFT = -1,
|
|
||||||
TEXT_ALIGNMENT_CENTER = 0,
|
|
||||||
TEXT_ALIGNMENT_RIGHT = 1,
|
|
||||||
TEXT_ALIGNMENT_START = -2,
|
|
||||||
TEXT_ALIGNMENT_END = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum canvas_draw_mode_t : uint8_t {
|
|
||||||
TEXT_DRAW_PATHS,
|
|
||||||
TEXT_DRAW_GLYPHS
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Canvas.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Canvas : public Napi::ObjectWrap<Canvas> {
|
|
||||||
public:
|
|
||||||
Canvas(const Napi::CallbackInfo& info);
|
|
||||||
static void Initialize(Napi::Env& env, Napi::Object& target);
|
|
||||||
|
|
||||||
Napi::Value ToBuffer(const Napi::CallbackInfo& info);
|
|
||||||
Napi::Value GetType(const Napi::CallbackInfo& info);
|
|
||||||
Napi::Value GetStride(const Napi::CallbackInfo& info);
|
|
||||||
Napi::Value GetWidth(const Napi::CallbackInfo& info);
|
|
||||||
Napi::Value GetHeight(const Napi::CallbackInfo& info);
|
|
||||||
void SetWidth(const Napi::CallbackInfo& info, const Napi::Value& value);
|
|
||||||
void SetHeight(const Napi::CallbackInfo& info, const Napi::Value& value);
|
|
||||||
void StreamPNGSync(const Napi::CallbackInfo& info);
|
|
||||||
void StreamPDFSync(const Napi::CallbackInfo& info);
|
|
||||||
void StreamJPEGSync(const Napi::CallbackInfo& info);
|
|
||||||
static void RegisterFont(const Napi::CallbackInfo& info);
|
|
||||||
static void DeregisterAllFonts(const Napi::CallbackInfo& info);
|
|
||||||
static Napi::Value ParseFont(const Napi::CallbackInfo& info);
|
|
||||||
Napi::Error CairoError(cairo_status_t status);
|
|
||||||
static void ToPngBufferAsync(Closure* closure);
|
|
||||||
static void ToJpegBufferAsync(Closure* closure);
|
|
||||||
static PangoWeight GetWeightFromCSSString(const char *weight);
|
|
||||||
static PangoStyle GetStyleFromCSSString(const char *style);
|
|
||||||
static PangoFontDescription *ResolveFontDescription(const PangoFontDescription *desc);
|
|
||||||
|
|
||||||
DLL_PUBLIC inline Backend* backend() { return _backend; }
|
|
||||||
DLL_PUBLIC inline cairo_surface_t* surface(){ return backend()->getSurface(); }
|
|
||||||
cairo_t* createCairoContext();
|
|
||||||
|
|
||||||
DLL_PUBLIC inline uint8_t *data(){ return cairo_image_surface_get_data(surface()); }
|
|
||||||
DLL_PUBLIC inline int stride(){ return cairo_image_surface_get_stride(surface()); }
|
|
||||||
DLL_PUBLIC inline std::size_t nBytes(){
|
|
||||||
return static_cast<std::size_t>(backend()->getHeight()) * stride();
|
|
||||||
}
|
|
||||||
|
|
||||||
DLL_PUBLIC inline int getWidth() { return backend()->getWidth(); }
|
|
||||||
DLL_PUBLIC inline int getHeight() { return backend()->getHeight(); }
|
|
||||||
|
|
||||||
void resurface(Napi::Object This);
|
|
||||||
|
|
||||||
Napi::Env env;
|
|
||||||
static int fontSerial;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Backend* _backend;
|
|
||||||
Napi::ObjectReference _jsBackend;
|
|
||||||
Napi::FunctionReference ctor;
|
|
||||||
static std::vector<FontFace> font_face_list;
|
|
||||||
};
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
1.0.0 / 2024-08-31
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Drop support for node <18
|
|
||||||
* Added an option preferred encodings array #59
|
|
||||||
|
|
||||||
0.6.3 / 2022-01-22
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Revert "Lazy-load modules from main entry point"
|
|
||||||
|
|
||||||
0.6.2 / 2019-04-29
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix sorting charset, encoding, and language with extra parameters
|
|
||||||
|
|
||||||
0.6.1 / 2016-05-02
|
|
||||||
==================
|
|
||||||
|
|
||||||
* perf: improve `Accept` parsing speed
|
|
||||||
* perf: improve `Accept-Charset` parsing speed
|
|
||||||
* perf: improve `Accept-Encoding` parsing speed
|
|
||||||
* perf: improve `Accept-Language` parsing speed
|
|
||||||
|
|
||||||
0.6.0 / 2015-09-29
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix including type extensions in parameters in `Accept` parsing
|
|
||||||
* Fix parsing `Accept` parameters with quoted equals
|
|
||||||
* Fix parsing `Accept` parameters with quoted semicolons
|
|
||||||
* Lazy-load modules from main entry point
|
|
||||||
* perf: delay type concatenation until needed
|
|
||||||
* perf: enable strict mode
|
|
||||||
* perf: hoist regular expressions
|
|
||||||
* perf: remove closures getting spec properties
|
|
||||||
* perf: remove a closure from media type parsing
|
|
||||||
* perf: remove property delete from media type parsing
|
|
||||||
|
|
||||||
0.5.3 / 2015-05-10
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix media type parameter matching to be case-insensitive
|
|
||||||
|
|
||||||
0.5.2 / 2015-05-06
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix comparing media types with quoted values
|
|
||||||
* Fix splitting media types with quoted commas
|
|
||||||
|
|
||||||
0.5.1 / 2015-02-14
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix preference sorting to be stable for long acceptable lists
|
|
||||||
|
|
||||||
0.5.0 / 2014-12-18
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix list return order when large accepted list
|
|
||||||
* Fix missing identity encoding when q=0 exists
|
|
||||||
* Remove dynamic building of Negotiator class
|
|
||||||
|
|
||||||
0.4.9 / 2014-10-14
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix error when media type has invalid parameter
|
|
||||||
|
|
||||||
0.4.8 / 2014-09-28
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix all negotiations to be case-insensitive
|
|
||||||
* Stable sort preferences of same quality according to client order
|
|
||||||
* Support Node.js 0.6
|
|
||||||
|
|
||||||
0.4.7 / 2014-06-24
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Handle invalid provided languages
|
|
||||||
* Handle invalid provided media types
|
|
||||||
|
|
||||||
0.4.6 / 2014-06-11
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Order by specificity when quality is the same
|
|
||||||
|
|
||||||
0.4.5 / 2014-05-29
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix regression in empty header handling
|
|
||||||
|
|
||||||
0.4.4 / 2014-05-29
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix behaviors when headers are not present
|
|
||||||
|
|
||||||
0.4.3 / 2014-04-16
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Handle slashes on media params correctly
|
|
||||||
|
|
||||||
0.4.2 / 2014-02-28
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix media type sorting
|
|
||||||
* Handle media types params strictly
|
|
||||||
|
|
||||||
0.4.1 / 2014-01-16
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Use most specific matches
|
|
||||||
|
|
||||||
0.4.0 / 2014-01-09
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Remove preferred prefix from methods
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
exports.default = _classPrivateFieldSet2;
|
|
||||||
var _assertClassBrand = require("./assertClassBrand.js");
|
|
||||||
function _classPrivateFieldSet2(privateMap, receiver, value) {
|
|
||||||
privateMap.set((0, _assertClassBrand.default)(privateMap, receiver), value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//# sourceMappingURL=classPrivateFieldSet2.js.map
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
presets: [
|
|
||||||
["env", { targets: { node: "current" }}],
|
|
||||||
],
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { Parser } from "../index.js";
|
|
||||||
|
|
||||||
export declare const parsers: {
|
|
||||||
markdown: Parser;
|
|
||||||
mdx: Parser;
|
|
||||||
remark: Parser;
|
|
||||||
};
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,43 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var $TypeError = require('es-errors/type');
|
|
||||||
var inspect = require('object-inspect');
|
|
||||||
var getSideChannelList = require('side-channel-list');
|
|
||||||
var getSideChannelMap = require('side-channel-map');
|
|
||||||
var getSideChannelWeakMap = require('side-channel-weakmap');
|
|
||||||
|
|
||||||
var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList;
|
|
||||||
|
|
||||||
/** @type {import('.')} */
|
|
||||||
module.exports = function getSideChannel() {
|
|
||||||
/** @typedef {ReturnType<typeof getSideChannel>} Channel */
|
|
||||||
|
|
||||||
/** @type {Channel | undefined} */ var $channelData;
|
|
||||||
|
|
||||||
/** @type {Channel} */
|
|
||||||
var channel = {
|
|
||||||
assert: function (key) {
|
|
||||||
if (!channel.has(key)) {
|
|
||||||
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'delete': function (key) {
|
|
||||||
return !!$channelData && $channelData['delete'](key);
|
|
||||||
},
|
|
||||||
get: function (key) {
|
|
||||||
return $channelData && $channelData.get(key);
|
|
||||||
},
|
|
||||||
has: function (key) {
|
|
||||||
return !!$channelData && $channelData.has(key);
|
|
||||||
},
|
|
||||||
set: function (key, value) {
|
|
||||||
if (!$channelData) {
|
|
||||||
$channelData = makeChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
$channelData.set(key, value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// @ts-expect-error TODO: figure out why this is erroring
|
|
||||||
return channel;
|
|
||||||
};
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "decompress-response",
|
|
||||||
"version": "6.0.0",
|
|
||||||
"description": "Decompress a HTTP response if needed",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": "sindresorhus/decompress-response",
|
|
||||||
"funding": "https://github.com/sponsors/sindresorhus",
|
|
||||||
"author": {
|
|
||||||
"name": "Sindre Sorhus",
|
|
||||||
"email": "sindresorhus@gmail.com",
|
|
||||||
"url": "https://sindresorhus.com"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "xo && ava && tsd"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js",
|
|
||||||
"index.d.ts"
|
|
||||||
],
|
|
||||||
"keywords": [
|
|
||||||
"decompress",
|
|
||||||
"response",
|
|
||||||
"http",
|
|
||||||
"https",
|
|
||||||
"zlib",
|
|
||||||
"gzip",
|
|
||||||
"zip",
|
|
||||||
"deflate",
|
|
||||||
"unzip",
|
|
||||||
"ungzip",
|
|
||||||
"incoming",
|
|
||||||
"message",
|
|
||||||
"stream",
|
|
||||||
"compressed",
|
|
||||||
"brotli"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"mimic-response": "^3.1.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^14.0.1",
|
|
||||||
"ava": "^2.2.0",
|
|
||||||
"get-stream": "^5.0.0",
|
|
||||||
"pify": "^5.0.0",
|
|
||||||
"tsd": "^0.11.0",
|
|
||||||
"xo": "^0.30.0"
|
|
||||||
},
|
|
||||||
"xo": {
|
|
||||||
"rules": {
|
|
||||||
"@typescript-eslint/prefer-readonly-parameter-types": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
export let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e<63?"_":"-"),"");
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@babel/helper-validator-option",
|
|
||||||
"version": "7.25.9",
|
|
||||||
"description": "Validate plugin/preset options",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/babel/babel.git",
|
|
||||||
"directory": "packages/babel-helper-validator-option"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"main": "./lib/index.js",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./lib/index.d.ts",
|
|
||||||
"default": "./lib/index.js"
|
|
||||||
},
|
|
||||||
"./package.json": "./package.json"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.9.0"
|
|
||||||
},
|
|
||||||
"author": "The Babel Team (https://babel.dev/team)",
|
|
||||||
"type": "commonjs"
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
declare function setToStringTag(
|
|
||||||
object: object & { [Symbol.toStringTag]?: unknown },
|
|
||||||
value: string | unknown,
|
|
||||||
options?: {
|
|
||||||
force?: boolean;
|
|
||||||
nonConfigurable?: boolean;
|
|
||||||
},
|
|
||||||
): void;
|
|
||||||
|
|
||||||
export = setToStringTag;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports={A:{A:{"1":"A B","2":"K D E F mC"},B:{"1":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"0 1 2 3 4 5 6 7 8 9 LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC qC rC","2":"nC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"J","4":"PB K D"},E:{"1":"K D E F A B C L M G uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB sC SC tC"},F:{"1":"0 1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"E BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"SC 9C lC AD"},H:{"1":"WD"},I:{"1":"I bD cD","2":"LC J XD YD ZD aD lC"},J:{"1":"A","2":"D"},K:{"1":"A B C H FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:2,C:"SVG filters",D:true};
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var fs = require('fs')
|
|
||||||
, path = require('path')
|
|
||||||
, browserify = require('browserify')
|
|
||||||
, uglify = require('uglify-js');
|
|
||||||
|
|
||||||
var pkg = process.argv[2]
|
|
||||||
, standalone = process.argv[3]
|
|
||||||
, compress = process.argv[4];
|
|
||||||
|
|
||||||
var packageDir = path.join(__dirname, '..');
|
|
||||||
if (pkg != '.') packageDir = path.join(packageDir, 'node_modules', pkg);
|
|
||||||
|
|
||||||
var json = require(path.join(packageDir, 'package.json'));
|
|
||||||
|
|
||||||
var distDir = path.join(__dirname, '..', 'dist');
|
|
||||||
if (!fs.existsSync(distDir)) fs.mkdirSync(distDir);
|
|
||||||
|
|
||||||
var bOpts = {};
|
|
||||||
if (standalone) bOpts.standalone = standalone;
|
|
||||||
|
|
||||||
browserify(bOpts)
|
|
||||||
.require(path.join(packageDir, json.main), {expose: json.name})
|
|
||||||
.bundle(function (err, buf) {
|
|
||||||
if (err) {
|
|
||||||
console.error('browserify error:', err);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var outputFile = path.join(distDir, json.name);
|
|
||||||
var uglifyOpts = {
|
|
||||||
warnings: true,
|
|
||||||
compress: {},
|
|
||||||
output: {
|
|
||||||
preamble: '/* ' + json.name + ' ' + json.version + ': ' + json.description + ' */'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (compress) {
|
|
||||||
var compressOpts = compress.split(',');
|
|
||||||
for (var i=0, il = compressOpts.length; i<il; ++i) {
|
|
||||||
var pair = compressOpts[i].split('=');
|
|
||||||
uglifyOpts.compress[pair[0]] = pair.length < 1 || pair[1] != 'false';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (standalone) {
|
|
||||||
uglifyOpts.sourceMap = {
|
|
||||||
filename: json.name + '.min.js',
|
|
||||||
url: json.name + '.min.js.map'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = uglify.minify(buf.toString(), uglifyOpts);
|
|
||||||
fs.writeFileSync(outputFile + '.min.js', result.code);
|
|
||||||
if (result.map) fs.writeFileSync(outputFile + '.min.js.map', result.map);
|
|
||||||
if (standalone) fs.writeFileSync(outputFile + '.bundle.js', buf);
|
|
||||||
if (result.warnings) {
|
|
||||||
for (var j=0, jl = result.warnings.length; j<jl; ++j)
|
|
||||||
console.warn('UglifyJS warning:', result.warnings[j]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"names":["_index","require","isType","nodeType","targetType","ALIAS_KEYS","aliases","FLIPPED_ALIAS_KEYS","includes"],"sources":["../../src/validators/isType.ts"],"sourcesContent":["import { FLIPPED_ALIAS_KEYS, ALIAS_KEYS } from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function isType<T extends t.Node[\"type\"]>(\n nodeType: string,\n targetType: T,\n): nodeType is T;\n\nexport default function isType(\n nodeType: string | null | undefined,\n targetType: string,\n): boolean;\n\n/**\n * Test if a `nodeType` is a `targetType` or if `targetType` is an alias of `nodeType`.\n */\nexport default function isType(nodeType: string, targetType: string): boolean {\n if (nodeType === targetType) return true;\n\n // If nodeType is nullish, it can't be an alias of targetType.\n if (nodeType == null) return false;\n\n // This is a fast-path. If the test above failed, but an alias key is found, then the\n // targetType was a primary node type, so there's no need to check the aliases.\n // @ts-expect-error targetType may not index ALIAS_KEYS\n if (ALIAS_KEYS[targetType]) return false;\n\n const aliases: Array<string> | undefined = FLIPPED_ALIAS_KEYS[targetType];\n if (aliases?.includes(nodeType)) return true;\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAgBe,SAASC,MAAMA,CAACC,QAAgB,EAAEC,UAAkB,EAAW;EAC5E,IAAID,QAAQ,KAAKC,UAAU,EAAE,OAAO,IAAI;EAGxC,IAAID,QAAQ,IAAI,IAAI,EAAE,OAAO,KAAK;EAKlC,IAAIE,iBAAU,CAACD,UAAU,CAAC,EAAE,OAAO,KAAK;EAExC,MAAME,OAAkC,GAAGC,yBAAkB,CAACH,UAAU,CAAC;EACzE,IAAIE,OAAO,YAAPA,OAAO,CAAEE,QAAQ,CAACL,QAAQ,CAAC,EAAE,OAAO,IAAI;EAE5C,OAAO,KAAK;AACd","ignoreList":[]}
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Rule to require parens in arrow function arguments.
|
|
||||||
* @author Jxck
|
|
||||||
* @deprecated in ESLint v8.53.0
|
|
||||||
*/
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Requirements
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const astUtils = require("./utils/ast-utils");
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if the given arrow function has block body.
|
|
||||||
* @param {ASTNode} node `ArrowFunctionExpression` node.
|
|
||||||
* @returns {boolean} `true` if the function has block body.
|
|
||||||
*/
|
|
||||||
function hasBlockBody(node) {
|
|
||||||
return node.body.type === "BlockStatement";
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Rule Definition
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
deprecated: {
|
|
||||||
message: "Formatting rules are being moved out of ESLint core.",
|
|
||||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
||||||
deprecatedSince: "8.53.0",
|
|
||||||
availableUntil: "10.0.0",
|
|
||||||
replacedBy: [
|
|
||||||
{
|
|
||||||
message:
|
|
||||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
||||||
url: "https://eslint.style/guide/migration",
|
|
||||||
plugin: {
|
|
||||||
name: "@stylistic/eslint-plugin-js",
|
|
||||||
url: "https://eslint.style/packages/js",
|
|
||||||
},
|
|
||||||
rule: {
|
|
||||||
name: "arrow-parens",
|
|
||||||
url: "https://eslint.style/rules/js/arrow-parens",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
type: "layout",
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description: "Require parentheses around arrow function arguments",
|
|
||||||
recommended: false,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/arrow-parens",
|
|
||||||
},
|
|
||||||
|
|
||||||
fixable: "code",
|
|
||||||
|
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
enum: ["always", "as-needed"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
requireForBlockBody: {
|
|
||||||
type: "boolean",
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
additionalProperties: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
messages: {
|
|
||||||
unexpectedParens:
|
|
||||||
"Unexpected parentheses around single function argument.",
|
|
||||||
expectedParens:
|
|
||||||
"Expected parentheses around arrow function argument.",
|
|
||||||
|
|
||||||
unexpectedParensInline:
|
|
||||||
"Unexpected parentheses around single function argument having a body with no curly braces.",
|
|
||||||
expectedParensBlock:
|
|
||||||
"Expected parentheses around arrow function argument having a body with curly braces.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
const asNeeded = context.options[0] === "as-needed";
|
|
||||||
const requireForBlockBody =
|
|
||||||
asNeeded &&
|
|
||||||
context.options[1] &&
|
|
||||||
context.options[1].requireForBlockBody === true;
|
|
||||||
|
|
||||||
const sourceCode = context.sourceCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds opening paren of parameters for the given arrow function, if it exists.
|
|
||||||
* It is assumed that the given arrow function has exactly one parameter.
|
|
||||||
* @param {ASTNode} node `ArrowFunctionExpression` node.
|
|
||||||
* @returns {Token|null} the opening paren, or `null` if the given arrow function doesn't have parens of parameters.
|
|
||||||
*/
|
|
||||||
function findOpeningParenOfParams(node) {
|
|
||||||
const tokenBeforeParams = sourceCode.getTokenBefore(node.params[0]);
|
|
||||||
|
|
||||||
if (
|
|
||||||
tokenBeforeParams &&
|
|
||||||
astUtils.isOpeningParenToken(tokenBeforeParams) &&
|
|
||||||
node.range[0] <= tokenBeforeParams.range[0]
|
|
||||||
) {
|
|
||||||
return tokenBeforeParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds closing paren of parameters for the given arrow function.
|
|
||||||
* It is assumed that the given arrow function has parens of parameters and that it has exactly one parameter.
|
|
||||||
* @param {ASTNode} node `ArrowFunctionExpression` node.
|
|
||||||
* @returns {Token} the closing paren of parameters.
|
|
||||||
*/
|
|
||||||
function getClosingParenOfParams(node) {
|
|
||||||
return sourceCode.getTokenAfter(
|
|
||||||
node.params[0],
|
|
||||||
astUtils.isClosingParenToken,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the given arrow function has comments inside parens of parameters.
|
|
||||||
* It is assumed that the given arrow function has parens of parameters.
|
|
||||||
* @param {ASTNode} node `ArrowFunctionExpression` node.
|
|
||||||
* @param {Token} openingParen Opening paren of parameters.
|
|
||||||
* @returns {boolean} `true` if the function has at least one comment inside of parens of parameters.
|
|
||||||
*/
|
|
||||||
function hasCommentsInParensOfParams(node, openingParen) {
|
|
||||||
return sourceCode.commentsExistBetween(
|
|
||||||
openingParen,
|
|
||||||
getClosingParenOfParams(node),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the given arrow function has unexpected tokens before opening paren of parameters,
|
|
||||||
* in which case it will be assumed that the existing parens of parameters are necessary.
|
|
||||||
* Only tokens within the range of the arrow function (tokens that are part of the arrow function) are taken into account.
|
|
||||||
* Example: <T>(a) => b
|
|
||||||
* @param {ASTNode} node `ArrowFunctionExpression` node.
|
|
||||||
* @param {Token} openingParen Opening paren of parameters.
|
|
||||||
* @returns {boolean} `true` if the function has at least one unexpected token.
|
|
||||||
*/
|
|
||||||
function hasUnexpectedTokensBeforeOpeningParen(node, openingParen) {
|
|
||||||
const expectedCount = node.async ? 1 : 0;
|
|
||||||
|
|
||||||
return (
|
|
||||||
sourceCode.getFirstToken(node, { skip: expectedCount }) !==
|
|
||||||
openingParen
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
"ArrowFunctionExpression[params.length=1]"(node) {
|
|
||||||
const shouldHaveParens =
|
|
||||||
!asNeeded || (requireForBlockBody && hasBlockBody(node));
|
|
||||||
const openingParen = findOpeningParenOfParams(node);
|
|
||||||
const hasParens = openingParen !== null;
|
|
||||||
const [param] = node.params;
|
|
||||||
|
|
||||||
if (shouldHaveParens && !hasParens) {
|
|
||||||
context.report({
|
|
||||||
node,
|
|
||||||
messageId: requireForBlockBody
|
|
||||||
? "expectedParensBlock"
|
|
||||||
: "expectedParens",
|
|
||||||
loc: param.loc,
|
|
||||||
*fix(fixer) {
|
|
||||||
yield fixer.insertTextBefore(param, "(");
|
|
||||||
yield fixer.insertTextAfter(param, ")");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
!shouldHaveParens &&
|
|
||||||
hasParens &&
|
|
||||||
param.type === "Identifier" &&
|
|
||||||
!param.typeAnnotation &&
|
|
||||||
!node.returnType &&
|
|
||||||
!hasCommentsInParensOfParams(node, openingParen) &&
|
|
||||||
!hasUnexpectedTokensBeforeOpeningParen(node, openingParen)
|
|
||||||
) {
|
|
||||||
context.report({
|
|
||||||
node,
|
|
||||||
messageId: requireForBlockBody
|
|
||||||
? "unexpectedParensInline"
|
|
||||||
: "unexpectedParens",
|
|
||||||
loc: param.loc,
|
|
||||||
*fix(fixer) {
|
|
||||||
const tokenBeforeOpeningParen =
|
|
||||||
sourceCode.getTokenBefore(openingParen);
|
|
||||||
const closingParen = getClosingParenOfParams(node);
|
|
||||||
|
|
||||||
if (
|
|
||||||
tokenBeforeOpeningParen &&
|
|
||||||
tokenBeforeOpeningParen.range[1] ===
|
|
||||||
openingParen.range[0] &&
|
|
||||||
!astUtils.canTokensBeAdjacent(
|
|
||||||
tokenBeforeOpeningParen,
|
|
||||||
sourceCode.getFirstToken(param),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
yield fixer.insertTextBefore(openingParen, " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove parens, whitespace inside parens, and possible trailing comma
|
|
||||||
yield fixer.removeRange([
|
|
||||||
openingParen.range[0],
|
|
||||||
param.range[0],
|
|
||||||
]);
|
|
||||||
yield fixer.removeRange([
|
|
||||||
param.range[1],
|
|
||||||
closingParen.range[1],
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# Installation
|
|
||||||
> `npm install --save @types/babel__generator`
|
|
||||||
|
|
||||||
# Summary
|
|
||||||
This package contains type definitions for @babel/generator (https://github.com/babel/babel/tree/master/packages/babel-generator).
|
|
||||||
|
|
||||||
# Details
|
|
||||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__generator.
|
|
||||||
|
|
||||||
### Additional Details
|
|
||||||
* Last updated: Thu, 03 Apr 2025 16:02:41 GMT
|
|
||||||
* Dependencies: [@babel/types](https://npmjs.com/package/@babel/types)
|
|
||||||
|
|
||||||
# Credits
|
|
||||||
These definitions were written by [Troy Gerwien](https://github.com/yortus), [Melvin Groenhoff](https://github.com/mgroenhoff), [Cameron Yan](https://github.com/khell), and [Lyanbin](https://github.com/Lyanbin).
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
|
|
||||||
<style>
|
|
||||||
@media not (prefers-reduced-motion) {
|
|
||||||
@keyframes loadingRotate {
|
|
||||||
from { rotate: 0; } to { rotate: 360deg }
|
|
||||||
}
|
|
||||||
#circle-arrows {
|
|
||||||
animation: loadingRotate 1.8s linear infinite;
|
|
||||||
transform-origin: 50% 50%;
|
|
||||||
}
|
|
||||||
#hourglass {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion) {
|
|
||||||
#circle-arrows {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<path id="circle-arrows" d="M9 5.528c0 .42.508.63.804.333l2.528-2.528a.47.47 0 0 0 0-.666L9.805.14A.471.471 0 0 0 9 .472v1.866A5.756 5.756 0 0 0 2.25 8c0 .942.232 1.83.635 2.615l1.143-1.143A4.208 4.208 0 0 1 3.75 8 4.254 4.254 0 0 1 8 3.75c.345 0 .68.042 1 .122v1.656zM7 10.472v1.656c.32.08.655.122 1 .122A4.254 4.254 0 0 0 12.25 8c0-.52-.107-1.013-.279-1.474l1.143-1.143c.404.786.636 1.674.636 2.617A5.756 5.756 0 0 1 7 13.662v1.866a.47.47 0 0 1-.804.333l-2.528-2.528a.47.47 0 0 1 0-.666l2.528-2.528a.47.47 0 0 1 .804.333z"/>
|
|
||||||
<g id="hourglass">
|
|
||||||
<path d="M13,1 C13.5522847,1 14,1.44771525 14,2 C14,2.55228475 13.5522847,3 13,3 L12.9854217,2.99990801 C12.9950817,3.16495885 13,3.33173274 13,3.5 C13,5.24679885 10.9877318,6.01090495 10.9877318,8.0017538 C10.9877318,9.99260264 13,10.7536922 13,12.5 C13,12.6686079 12.9950617,12.8357163 12.985363,13.0010943 L13,13 C13.5522847,13 14,13.4477153 14,14 C14,14.5522847 13.5522847,15 13,15 L3,15 C2.44771525,15 2,14.5522847 2,14 C2,13.4477153 2.44771525,13 3,13 L3.01463704,13.0010943 C3.00493827,12.8357163 3,12.6686079 3,12.5 C3,10.7536922 4.9877318,9.99260264 5,8.0017538 C5.0122682,6.01090495 3,5.24679885 3,3.5 C3,3.33173274 3.00491834,3.16495885 3.01457832,2.99990801 L3,3 C2.44771525,3 2,2.55228475 2,2 C2,1.44771525 2.44771525,1 3,1 L13,1 Z M10.987,3 L5.012,3 L5.00308914,3.24815712 C5.00103707,3.33163368 5,3.4155948 5,3.5 C5,5.36125069 6.99153646,6.01774089 6.99153646,8.0017538 C6.99153646,9.98576671 5,10.6393737 5,12.5 L5.00307746,12.7513676 L5.01222201,12.9998392 L5.60191711,12.9988344 L6.0425138,12.2959826 C7.02362731,10.7653275 7.67612271,10 8,10 C8.37014547,10 9.16950644,10.9996115 10.3980829,12.9988344 L10.987778,12.9998392 C10.9958674,12.8352104 11,12.66849 11,12.5 C11,10.6393737 8.98689779,10.0147381 8.98689779,8.0017538 C8.98689779,5.98876953 11,5.36125069 11,3.5 L10.9969109,3.24815712 L10.987,3 Z"/>
|
|
||||||
<path d="M6,4 L10,4 C8.95166016,6 8.28499349,7 8,7 C7.71500651,7 7.04833984,6 6,4 Z"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 2.6 KiB |
File diff suppressed because it is too large
Load Diff
@@ -1,96 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Rule to flag variable leak in CatchClauses in IE 8 and earlier
|
|
||||||
* @author Ian Christian Myers
|
|
||||||
* @deprecated in ESLint v5.1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Requirements
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const astUtils = require("./utils/ast-utils");
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Rule Definition
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
type: "suggestion",
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description:
|
|
||||||
"Disallow `catch` clause parameters from shadowing variables in the outer scope",
|
|
||||||
recommended: false,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/no-catch-shadow",
|
|
||||||
},
|
|
||||||
|
|
||||||
deprecated: {
|
|
||||||
message: "This rule was renamed.",
|
|
||||||
url: "https://eslint.org/blog/2018/07/eslint-v5.1.0-released/",
|
|
||||||
deprecatedSince: "5.1.0",
|
|
||||||
availableUntil: null,
|
|
||||||
replacedBy: [
|
|
||||||
{
|
|
||||||
rule: {
|
|
||||||
name: "no-shadow",
|
|
||||||
url: "https://eslint.org/docs/rules/no-shadow",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
schema: [],
|
|
||||||
|
|
||||||
messages: {
|
|
||||||
mutable:
|
|
||||||
"Value of '{{name}}' may be overwritten in IE 8 and earlier.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
const sourceCode = context.sourceCode;
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the parameters are been shadowed
|
|
||||||
* @param {Object} scope current scope
|
|
||||||
* @param {string} name parameter name
|
|
||||||
* @returns {boolean} True is its been shadowed
|
|
||||||
*/
|
|
||||||
function paramIsShadowing(scope, name) {
|
|
||||||
return astUtils.getVariableByName(scope, name) !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Public API
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return {
|
|
||||||
"CatchClause[param!=null]"(node) {
|
|
||||||
let scope = sourceCode.getScope(node);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When ecmaVersion >= 6, CatchClause creates its own scope
|
|
||||||
* so start from one upper scope to exclude the current node
|
|
||||||
*/
|
|
||||||
if (scope.block === node) {
|
|
||||||
scope = scope.upper;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paramIsShadowing(scope, node.param.name)) {
|
|
||||||
context.report({
|
|
||||||
node,
|
|
||||||
messageId: "mutable",
|
|
||||||
data: { name: node.param.name },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
var test = require('tape');
|
|
||||||
var equal = require('../');
|
|
||||||
|
|
||||||
test('equal', function (t) {
|
|
||||||
t.ok(equal(
|
|
||||||
{ a : [ 2, 3 ], b : [ 4 ] },
|
|
||||||
{ a : [ 2, 3 ], b : [ 4 ] }
|
|
||||||
));
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('not equal', function (t) {
|
|
||||||
t.notOk(equal(
|
|
||||||
{ x : 5, y : [6] },
|
|
||||||
{ x : 5, y : 6 }
|
|
||||||
));
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('nested nulls', function (t) {
|
|
||||||
t.ok(equal([ null, null, null ], [ null, null, null ]));
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports={C:{"49":0.00165,"64":0.00165,"81":0.00165,"84":0.0033,"94":0.00165,"112":0.0033,"115":0.02803,"127":0.00165,"128":0.01814,"133":0.00165,"134":0.00495,"135":0.20118,"136":0.54912,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 50 51 52 53 54 55 56 57 58 59 60 61 62 63 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 82 83 85 86 87 88 89 90 91 92 93 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 113 114 116 117 118 119 120 121 122 123 124 125 126 129 130 131 132 137 138 139 140 3.5 3.6"},D:{"22":0.0033,"37":0.00165,"39":0.00165,"42":0.00165,"44":0.00165,"46":0.00825,"47":0.00825,"59":0.00165,"64":0.01154,"65":0.00165,"67":0.00989,"68":0.02803,"69":0.00165,"73":0.00165,"74":0.00165,"75":0.00165,"76":0.00825,"79":0.00165,"80":0.00495,"81":0.00165,"83":0.00165,"84":0.00165,"86":0.0033,"87":0.00989,"88":0.00495,"89":0.00165,"90":0.0066,"92":0.01484,"93":0.01649,"94":0.0066,"96":0.00165,"97":0.00165,"98":0.00165,"100":0.00165,"102":0.00989,"103":0.02968,"104":0.00165,"105":0.00495,"106":0.00165,"108":0.00495,"109":0.16325,"111":0.03463,"114":0.01814,"115":0.00495,"116":0.01814,"117":0.00495,"118":0.01814,"119":0.0033,"120":0.00825,"121":0.00495,"122":0.02474,"123":0.00825,"124":0.01814,"125":0.01814,"126":0.03463,"127":0.01814,"128":0.03133,"129":0.01649,"130":0.02474,"131":0.18964,"132":0.10059,"133":1.27303,"134":2.3086,"135":0.00495,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 40 41 43 45 48 49 50 51 52 53 54 55 56 57 58 60 61 62 63 66 70 71 72 77 78 85 91 95 99 101 107 110 112 113 136 137 138"},F:{"35":0.00495,"36":0.00825,"40":0.00165,"46":0.0033,"86":0.00165,"87":0.0907,"88":0.00165,"95":0.0066,"99":0.0033,"101":0.00165,"112":0.00165,"113":0.00165,"114":0.0033,"115":0.0033,"116":0.01814,"117":0.36938,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 37 38 39 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 89 90 91 92 93 94 96 97 98 100 102 103 104 105 106 107 108 109 110 111 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"12":0.01979,"13":0.0066,"14":0.0066,"15":0.00165,"16":0.0033,"17":0.00165,"18":0.05112,"84":0.0066,"89":0.00989,"90":0.01154,"91":0.00165,"92":0.06101,"99":0.00825,"100":0.01154,"102":0.00825,"107":0.00165,"108":0.00165,"109":0.0033,"110":0.00165,"111":0.00165,"112":0.00165,"114":0.00165,"118":0.00165,"119":0.00825,"120":0.03793,"122":0.00825,"123":0.0033,"124":0.0066,"125":0.00165,"126":0.00495,"127":0.0066,"128":0.04782,"129":0.02144,"130":0.02968,"131":0.10883,"132":0.04452,"133":0.6662,"134":1.09659,_:"79 80 81 83 85 86 87 88 93 94 95 96 97 98 101 103 104 105 106 113 115 116 117 121"},E:{"10":0.00165,"11":0.00495,"13":0.0066,_:"0 4 5 6 7 8 9 12 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 12.1 15.1 15.2-15.3 15.4 15.5 16.2 17.0 17.3","11.1":0.0033,"13.1":0.01814,"14.1":0.01154,"15.6":0.01319,"16.0":0.00165,"16.1":0.00165,"16.3":0.0033,"16.4":0.00165,"16.5":0.00989,"16.6":0.01649,"17.1":0.01154,"17.2":0.0033,"17.4":0.00825,"17.5":0.01319,"17.6":0.11543,"18.0":0.0066,"18.1":0.00495,"18.2":0.00495,"18.3":0.09564,"18.4":0.00165},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.0011,"5.0-5.1":0,"6.0-6.1":0.0033,"7.0-7.1":0.0022,"8.1-8.4":0,"9.0-9.2":0.00165,"9.3":0.0077,"10.0-10.2":0.00055,"10.3":0.01266,"11.0-11.2":0.05834,"11.3-11.4":0.00385,"12.0-12.1":0.0022,"12.2-12.5":0.05448,"13.0-13.1":0.0011,"13.2":0.00165,"13.3":0.0022,"13.4-13.7":0.0077,"14.0-14.4":0.01926,"14.5-14.8":0.02311,"15.0-15.1":0.01266,"15.2-15.3":0.01266,"15.4":0.01541,"15.5":0.01761,"15.6-15.8":0.21683,"16.0":0.03082,"16.1":0.06329,"16.2":0.03302,"16.3":0.05723,"16.4":0.01266,"16.5":0.02366,"16.6-16.7":0.257,"17.0":0.01541,"17.1":0.02752,"17.2":0.02091,"17.3":0.02917,"17.4":0.05834,"17.5":0.12988,"17.6-17.7":0.37698,"18.0":0.10566,"18.1":0.34561,"18.2":0.15464,"18.3":3.23209,"18.4":0.04788},P:{"4":0.04002,"20":0.01,"21":0.01,"22":0.06002,"23":0.04002,"24":0.11004,"25":0.10004,"26":0.09003,"27":0.40015,_:"5.0-5.4 8.2 10.1 12.0 14.0 15.0 17.0 18.0","6.2-6.4":0.01,"7.2-7.4":0.02001,"9.2":0.01,"11.1-11.2":0.02001,"13.0":0.01,"16.0":0.02001,"19.0":0.01},I:{"0":0.04167,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00005},K:{"0":3.04601,_:"10 11 12 11.1 11.5 12.1"},A:{"10":0.00406,"11":0.02232,_:"6 7 8 9 5.5"},S:{"2.5":0.00835,_:"3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.07516},Q:{"14.9":0.05011},O:{"0":0.48436},H:{"0":4.52},L:{"0":76.33148}};
|
|
||||||
Binary file not shown.
@@ -1,3 +0,0 @@
|
|||||||
import type { OutlineContextType } from './shared/types.js';
|
|
||||||
declare const outlineContext: React.Context<OutlineContextType>;
|
|
||||||
export default outlineContext;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"names":["_iterableToArrayLimit","arr","i","iterator","Symbol","_arr","iteratorNormalCompletion","didIteratorError","step","iteratorError","next","_return","call","Object","done","push","value","length","err"],"sources":["../../src/helpers/iterableToArrayLimit.ts"],"sourcesContent":["/* @minVersion 7.0.0-beta.0 */\n\nexport default function _iterableToArrayLimit<T>(arr: Iterable<T>, i: number) {\n // this is an expanded form of \\`for...of\\` that properly supports abrupt completions of\n // iterators etc.\n\n var iterator: Iterator<T> =\n arr == null\n ? null\n : (typeof Symbol !== \"undefined\" && arr[Symbol.iterator]) ||\n (arr as any)[\"@@iterator\"];\n if (iterator == null) return;\n\n var _arr: T[] = [];\n var iteratorNormalCompletion = true;\n var didIteratorError = false;\n var step, iteratorError, next, _return;\n try {\n next = (iterator = (iterator as unknown as Function).call(arr)).next;\n if (i === 0) {\n if (Object(iterator) !== iterator) return;\n iteratorNormalCompletion = false;\n } else {\n for (\n ;\n !(iteratorNormalCompletion = (step = next.call(iterator)).done);\n iteratorNormalCompletion = true\n ) {\n _arr.push(step.value);\n if (_arr.length === i) break;\n }\n }\n } catch (err) {\n didIteratorError = true;\n iteratorError = err;\n } finally {\n try {\n if (!iteratorNormalCompletion && iterator[\"return\"] != null) {\n _return = iterator[\"return\"]();\n // eslint-disable-next-line no-unsafe-finally\n if (Object(_return) !== _return) return;\n }\n } finally {\n // eslint-disable-next-line no-unsafe-finally\n if (didIteratorError) throw iteratorError;\n }\n }\n return _arr;\n}\n"],"mappings":";;;;;;AAEe,SAASA,qBAAqBA,CAAIC,GAAgB,EAAEC,CAAS,EAAE;EAI5E,IAAIC,QAAqB,GACvBF,GAAG,IAAI,IAAI,GACP,IAAI,GACH,OAAOG,MAAM,KAAK,WAAW,IAAIH,GAAG,CAACG,MAAM,CAACD,QAAQ,CAAC,IACrDF,GAAG,CAAS,YAAY,CAAC;EAChC,IAAIE,QAAQ,IAAI,IAAI,EAAE;EAEtB,IAAIE,IAAS,GAAG,EAAE;EAClB,IAAIC,wBAAwB,GAAG,IAAI;EACnC,IAAIC,gBAAgB,GAAG,KAAK;EAC5B,IAAIC,IAAI,EAAEC,aAAa,EAAEC,IAAI,EAAEC,OAAO;EACtC,IAAI;IACFD,IAAI,GAAG,CAACP,QAAQ,GAAIA,QAAQ,CAAyBS,IAAI,CAACX,GAAG,CAAC,EAAES,IAAI;IACpE,IAAIR,CAAC,KAAK,CAAC,EAAE;MACX,IAAIW,MAAM,CAACV,QAAQ,CAAC,KAAKA,QAAQ,EAAE;MACnCG,wBAAwB,GAAG,KAAK;IAClC,CAAC,MAAM;MACL,OAEE,EAAEA,wBAAwB,GAAG,CAACE,IAAI,GAAGE,IAAI,CAACE,IAAI,CAACT,QAAQ,CAAC,EAAEW,IAAI,CAAC,EAC/DR,wBAAwB,GAAG,IAAI,EAC/B;QACAD,IAAI,CAACU,IAAI,CAACP,IAAI,CAACQ,KAAK,CAAC;QACrB,IAAIX,IAAI,CAACY,MAAM,KAAKf,CAAC,EAAE;MACzB;IACF;EACF,CAAC,CAAC,OAAOgB,GAAG,EAAE;IACZX,gBAAgB,GAAG,IAAI;IACvBE,aAAa,GAAGS,GAAG;EACrB,CAAC,SAAS;IACR,IAAI;MACF,IAAI,CAACZ,wBAAwB,IAAIH,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE;QAC3DQ,OAAO,GAAGR,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE9B,IAAIU,MAAM,CAACF,OAAO,CAAC,KAAKA,OAAO,EAAE;MACnC;IACF,CAAC,SAAS;MAER,IAAIJ,gBAAgB,EAAE,MAAME,aAAa;IAC3C;EACF;EACA,OAAOJ,IAAI;AACb","ignoreList":[]}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@rollup/rollup-linux-arm64-gnu",
|
|
||||||
"version": "4.39.0",
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"files": [
|
|
||||||
"rollup.linux-arm64-gnu.node"
|
|
||||||
],
|
|
||||||
"description": "Native bindings for Rollup",
|
|
||||||
"author": "Lukas Taegert-Atkinson",
|
|
||||||
"homepage": "https://rollupjs.org/",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": "rollup/rollup",
|
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"main": "./rollup.linux-arm64-gnu.node"
|
|
||||||
}
|
|
||||||
@@ -1,249 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Require or disallow newlines around directives.
|
|
||||||
* @author Kai Cataldo
|
|
||||||
* @deprecated in ESLint v4.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const astUtils = require("./utils/ast-utils");
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Rule Definition
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
type: "layout",
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description: "Require or disallow newlines around directives",
|
|
||||||
recommended: false,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/lines-around-directive",
|
|
||||||
},
|
|
||||||
|
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
oneOf: [
|
|
||||||
{
|
|
||||||
enum: ["always", "never"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
before: {
|
|
||||||
enum: ["always", "never"],
|
|
||||||
},
|
|
||||||
after: {
|
|
||||||
enum: ["always", "never"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
additionalProperties: false,
|
|
||||||
minProperties: 2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
fixable: "whitespace",
|
|
||||||
messages: {
|
|
||||||
expected: 'Expected newline {{location}} "{{value}}" directive.',
|
|
||||||
unexpected:
|
|
||||||
'Unexpected newline {{location}} "{{value}}" directive.',
|
|
||||||
},
|
|
||||||
deprecated: {
|
|
||||||
message: "The rule was replaced with a more general rule.",
|
|
||||||
url: "https://eslint.org/blog/2017/06/eslint-v4.0.0-released/",
|
|
||||||
deprecatedSince: "4.0.0",
|
|
||||||
availableUntil: null,
|
|
||||||
replacedBy: [
|
|
||||||
{
|
|
||||||
message: "The new rule moved to a plugin.",
|
|
||||||
url: "https://eslint.org/docs/latest/rules/padding-line-between-statements#examples",
|
|
||||||
plugin: {
|
|
||||||
name: "@stylistic/eslint-plugin-js",
|
|
||||||
url: "https://eslint.style/packages/js",
|
|
||||||
},
|
|
||||||
rule: {
|
|
||||||
name: "padding-line-between-statements",
|
|
||||||
url: "https://eslint.style/rules/js/padding-line-between-statements",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
const sourceCode = context.sourceCode;
|
|
||||||
const config = context.options[0] || "always";
|
|
||||||
const expectLineBefore =
|
|
||||||
typeof config === "string" ? config : config.before;
|
|
||||||
const expectLineAfter =
|
|
||||||
typeof config === "string" ? config : config.after;
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if node is preceded by a blank newline.
|
|
||||||
* @param {ASTNode} node Node to check.
|
|
||||||
* @returns {boolean} Whether or not the passed in node is preceded by a blank newline.
|
|
||||||
*/
|
|
||||||
function hasNewlineBefore(node) {
|
|
||||||
const tokenBefore = sourceCode.getTokenBefore(node, {
|
|
||||||
includeComments: true,
|
|
||||||
});
|
|
||||||
const tokenLineBefore = tokenBefore ? tokenBefore.loc.end.line : 0;
|
|
||||||
|
|
||||||
return node.loc.start.line - tokenLineBefore >= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the last token of a node that is on the same line as the rest of the node.
|
|
||||||
* This will usually be the last token of the node, but it will be the second-to-last token if the node has a trailing
|
|
||||||
* semicolon on a different line.
|
|
||||||
* @param {ASTNode} node A directive node
|
|
||||||
* @returns {Token} The last token of the node on the line
|
|
||||||
*/
|
|
||||||
function getLastTokenOnLine(node) {
|
|
||||||
const lastToken = sourceCode.getLastToken(node);
|
|
||||||
const secondToLastToken = sourceCode.getTokenBefore(lastToken);
|
|
||||||
|
|
||||||
return astUtils.isSemicolonToken(lastToken) &&
|
|
||||||
lastToken.loc.start.line > secondToLastToken.loc.end.line
|
|
||||||
? secondToLastToken
|
|
||||||
: lastToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if node is followed by a blank newline.
|
|
||||||
* @param {ASTNode} node Node to check.
|
|
||||||
* @returns {boolean} Whether or not the passed in node is followed by a blank newline.
|
|
||||||
*/
|
|
||||||
function hasNewlineAfter(node) {
|
|
||||||
const lastToken = getLastTokenOnLine(node);
|
|
||||||
const tokenAfter = sourceCode.getTokenAfter(lastToken, {
|
|
||||||
includeComments: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Report errors for newlines around directives.
|
|
||||||
* @param {ASTNode} node Node to check.
|
|
||||||
* @param {string} location Whether the error was found before or after the directive.
|
|
||||||
* @param {boolean} expected Whether or not a newline was expected or unexpected.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
function reportError(node, location, expected) {
|
|
||||||
context.report({
|
|
||||||
node,
|
|
||||||
messageId: expected ? "expected" : "unexpected",
|
|
||||||
data: {
|
|
||||||
value: node.expression.value,
|
|
||||||
location,
|
|
||||||
},
|
|
||||||
fix(fixer) {
|
|
||||||
const lastToken = getLastTokenOnLine(node);
|
|
||||||
|
|
||||||
if (expected) {
|
|
||||||
return location === "before"
|
|
||||||
? fixer.insertTextBefore(node, "\n")
|
|
||||||
: fixer.insertTextAfter(lastToken, "\n");
|
|
||||||
}
|
|
||||||
return fixer.removeRange(
|
|
||||||
location === "before"
|
|
||||||
? [node.range[0] - 1, node.range[0]]
|
|
||||||
: [lastToken.range[1], lastToken.range[1] + 1],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check lines around directives in node
|
|
||||||
* @param {ASTNode} node node to check
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
function checkDirectives(node) {
|
|
||||||
const directives = astUtils.getDirectivePrologue(node);
|
|
||||||
|
|
||||||
if (!directives.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const firstDirective = directives[0];
|
|
||||||
const leadingComments =
|
|
||||||
sourceCode.getCommentsBefore(firstDirective);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Only check before the first directive if it is preceded by a comment or if it is at the top of
|
|
||||||
* the file and expectLineBefore is set to "never". This is to not force a newline at the top of
|
|
||||||
* the file if there are no comments as well as for compatibility with padded-blocks.
|
|
||||||
*/
|
|
||||||
if (leadingComments.length) {
|
|
||||||
if (
|
|
||||||
expectLineBefore === "always" &&
|
|
||||||
!hasNewlineBefore(firstDirective)
|
|
||||||
) {
|
|
||||||
reportError(firstDirective, "before", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
expectLineBefore === "never" &&
|
|
||||||
hasNewlineBefore(firstDirective)
|
|
||||||
) {
|
|
||||||
reportError(firstDirective, "before", false);
|
|
||||||
}
|
|
||||||
} else if (
|
|
||||||
node.type === "Program" &&
|
|
||||||
expectLineBefore === "never" &&
|
|
||||||
!leadingComments.length &&
|
|
||||||
hasNewlineBefore(firstDirective)
|
|
||||||
) {
|
|
||||||
reportError(firstDirective, "before", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
const lastDirective = directives.at(-1);
|
|
||||||
const statements =
|
|
||||||
node.type === "Program" ? node.body : node.body.body;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Do not check after the last directive if the body only
|
|
||||||
* contains a directive prologue and isn't followed by a comment to ensure
|
|
||||||
* this rule behaves well with padded-blocks.
|
|
||||||
*/
|
|
||||||
if (
|
|
||||||
lastDirective === statements.at(-1) &&
|
|
||||||
!lastDirective.trailingComments
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
expectLineAfter === "always" &&
|
|
||||||
!hasNewlineAfter(lastDirective)
|
|
||||||
) {
|
|
||||||
reportError(lastDirective, "after", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (expectLineAfter === "never" && hasNewlineAfter(lastDirective)) {
|
|
||||||
reportError(lastDirective, "after", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Public
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return {
|
|
||||||
Program: checkDirectives,
|
|
||||||
FunctionDeclaration: checkDirectives,
|
|
||||||
FunctionExpression: checkDirectives,
|
|
||||||
ArrowFunctionExpression: checkDirectives,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
/** @type {import('./reflectApply')} */
|
|
||||||
module.exports = typeof Reflect !== 'undefined' && Reflect && Reflect.apply;
|
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Enforce return after a callback.
|
|
||||||
* @author Jamund Ferguson
|
|
||||||
* @deprecated in ESLint v7.0.0
|
|
||||||
*/
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Rule Definition
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
deprecated: {
|
|
||||||
message: "Node.js rules were moved out of ESLint core.",
|
|
||||||
url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
|
|
||||||
deprecatedSince: "7.0.0",
|
|
||||||
availableUntil: null,
|
|
||||||
replacedBy: [
|
|
||||||
{
|
|
||||||
message:
|
|
||||||
"eslint-plugin-n now maintains deprecated Node.js-related rules.",
|
|
||||||
plugin: {
|
|
||||||
name: "eslint-plugin-n",
|
|
||||||
url: "https://github.com/eslint-community/eslint-plugin-n",
|
|
||||||
},
|
|
||||||
rule: {
|
|
||||||
name: "callback-return",
|
|
||||||
url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/callback-return.md",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
type: "suggestion",
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description: "Require `return` statements after callbacks",
|
|
||||||
recommended: false,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/callback-return",
|
|
||||||
},
|
|
||||||
|
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
type: "array",
|
|
||||||
items: { type: "string" },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
messages: {
|
|
||||||
missingReturn: "Expected return with your callback function.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
const callbacks = context.options[0] || ["callback", "cb", "next"],
|
|
||||||
sourceCode = context.sourceCode;
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the closest parent matching a list of types.
|
|
||||||
* @param {ASTNode} node The node whose parents we are searching
|
|
||||||
* @param {Array} types The node types to match
|
|
||||||
* @returns {ASTNode} The matched node or undefined.
|
|
||||||
*/
|
|
||||||
function findClosestParentOfType(node, types) {
|
|
||||||
if (!node.parent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!types.includes(node.parent.type)) {
|
|
||||||
return findClosestParentOfType(node.parent, types);
|
|
||||||
}
|
|
||||||
return node.parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see if a node contains only identifiers
|
|
||||||
* @param {ASTNode} node The node to check
|
|
||||||
* @returns {boolean} Whether or not the node contains only identifiers
|
|
||||||
*/
|
|
||||||
function containsOnlyIdentifiers(node) {
|
|
||||||
if (node.type === "Identifier") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.type === "MemberExpression") {
|
|
||||||
if (node.object.type === "Identifier") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (node.object.type === "MemberExpression") {
|
|
||||||
return containsOnlyIdentifiers(node.object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see if a CallExpression is in our callback list.
|
|
||||||
* @param {ASTNode} node The node to check against our callback names list.
|
|
||||||
* @returns {boolean} Whether or not this function matches our callback name.
|
|
||||||
*/
|
|
||||||
function isCallback(node) {
|
|
||||||
return (
|
|
||||||
containsOnlyIdentifiers(node.callee) &&
|
|
||||||
callbacks.includes(sourceCode.getText(node.callee))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether or not the callback is part of a callback expression.
|
|
||||||
* @param {ASTNode} node The callback node
|
|
||||||
* @param {ASTNode} parentNode The expression node
|
|
||||||
* @returns {boolean} Whether or not this is part of a callback expression
|
|
||||||
*/
|
|
||||||
function isCallbackExpression(node, parentNode) {
|
|
||||||
// ensure the parent node exists and is an expression
|
|
||||||
if (!parentNode || parentNode.type !== "ExpressionStatement") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cb()
|
|
||||||
if (parentNode.expression === node) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// special case for cb && cb() and similar
|
|
||||||
if (
|
|
||||||
parentNode.expression.type === "BinaryExpression" ||
|
|
||||||
parentNode.expression.type === "LogicalExpression"
|
|
||||||
) {
|
|
||||||
if (parentNode.expression.right === node) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Public
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return {
|
|
||||||
CallExpression(node) {
|
|
||||||
// if we're not a callback we can return
|
|
||||||
if (!isCallback(node)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the closest block, return or loop
|
|
||||||
const closestBlock =
|
|
||||||
findClosestParentOfType(node, [
|
|
||||||
"BlockStatement",
|
|
||||||
"ReturnStatement",
|
|
||||||
"ArrowFunctionExpression",
|
|
||||||
]) || {};
|
|
||||||
|
|
||||||
// if our parent is a return we know we're ok
|
|
||||||
if (closestBlock.type === "ReturnStatement") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// arrow functions don't always have blocks and implicitly return
|
|
||||||
if (closestBlock.type === "ArrowFunctionExpression") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// block statements are part of functions and most if statements
|
|
||||||
if (closestBlock.type === "BlockStatement") {
|
|
||||||
// find the last item in the block
|
|
||||||
const lastItem = closestBlock.body.at(-1);
|
|
||||||
|
|
||||||
// if the callback is the last thing in a block that might be ok
|
|
||||||
if (isCallbackExpression(node, lastItem)) {
|
|
||||||
const parentType = closestBlock.parent.type;
|
|
||||||
|
|
||||||
// but only if the block is part of a function
|
|
||||||
if (
|
|
||||||
parentType === "FunctionExpression" ||
|
|
||||||
parentType === "FunctionDeclaration" ||
|
|
||||||
parentType === "ArrowFunctionExpression"
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ending a block with a return is also ok
|
|
||||||
if (lastItem.type === "ReturnStatement") {
|
|
||||||
// but only if the callback is immediately before
|
|
||||||
if (
|
|
||||||
isCallbackExpression(node, closestBlock.body.at(-2))
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// as long as you're the child of a function at this point you should be asked to return
|
|
||||||
if (
|
|
||||||
findClosestParentOfType(node, [
|
|
||||||
"FunctionDeclaration",
|
|
||||||
"FunctionExpression",
|
|
||||||
"ArrowFunctionExpression",
|
|
||||||
])
|
|
||||||
) {
|
|
||||||
context.report({ node, messageId: "missingReturn" });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
export class BaseFilterFactory {
|
|
||||||
addFilter(maps: any): string;
|
|
||||||
addHCMFilter(fgColor: any, bgColor: any): string;
|
|
||||||
addAlphaFilter(map: any): string;
|
|
||||||
addLuminosityFilter(map: any): string;
|
|
||||||
addHighlightHCMFilter(filterName: any, fgColor: any, bgColor: any, newFgColor: any, newBgColor: any): string;
|
|
||||||
destroy(keepHCM?: boolean): void;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* FilterFactory aims to create some SVG filters we can use when drawing an
|
|
||||||
* image (or whatever) on a canvas.
|
|
||||||
* Filters aren't applied with ctx.putImageData because it just overwrites the
|
|
||||||
* underlying pixels.
|
|
||||||
* With these filters, it's possible for example to apply some transfer maps on
|
|
||||||
* an image without the need to apply them on the pixel arrays: the renderer
|
|
||||||
* does the magic for us.
|
|
||||||
*/
|
|
||||||
export class DOMFilterFactory extends BaseFilterFactory {
|
|
||||||
constructor({ docId, ownerDocument }: {
|
|
||||||
docId: any;
|
|
||||||
ownerDocument?: Document | undefined;
|
|
||||||
});
|
|
||||||
addFilter(maps: any): any;
|
|
||||||
addHCMFilter(fgColor: any, bgColor: any): any;
|
|
||||||
addAlphaFilter(map: any): any;
|
|
||||||
addLuminosityFilter(map: any): any;
|
|
||||||
addHighlightHCMFilter(filterName: any, fgColor: any, bgColor: any, newFgColor: any, newBgColor: any): any;
|
|
||||||
#private;
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Rule to flag use of certain node types
|
|
||||||
* @author Burak Yigit Kaya
|
|
||||||
*/
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Rule Definition
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
type: "suggestion",
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description: "Disallow specified syntax",
|
|
||||||
recommended: false,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/no-restricted-syntax",
|
|
||||||
},
|
|
||||||
|
|
||||||
schema: {
|
|
||||||
type: "array",
|
|
||||||
items: {
|
|
||||||
oneOf: [
|
|
||||||
{
|
|
||||||
type: "string",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
selector: { type: "string" },
|
|
||||||
message: { type: "string" },
|
|
||||||
},
|
|
||||||
required: ["selector"],
|
|
||||||
additionalProperties: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
uniqueItems: true,
|
|
||||||
minItems: 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
messages: {
|
|
||||||
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
|
|
||||||
restrictedSyntax: "{{message}}",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
return context.options.reduce((result, selectorOrObject) => {
|
|
||||||
const isStringFormat = typeof selectorOrObject === "string";
|
|
||||||
const hasCustomMessage =
|
|
||||||
!isStringFormat && Boolean(selectorOrObject.message);
|
|
||||||
|
|
||||||
const selector = isStringFormat
|
|
||||||
? selectorOrObject
|
|
||||||
: selectorOrObject.selector;
|
|
||||||
const message = hasCustomMessage
|
|
||||||
? selectorOrObject.message
|
|
||||||
: `Using '${selector}' is not allowed.`;
|
|
||||||
|
|
||||||
return Object.assign(result, {
|
|
||||||
[selector](node) {
|
|
||||||
context.report({
|
|
||||||
node,
|
|
||||||
messageId: "restrictedSyntax",
|
|
||||||
data: { message },
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}, {});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "object-assign",
|
|
||||||
"version": "4.1.1",
|
|
||||||
"description": "ES2015 `Object.assign()` ponyfill",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": "sindresorhus/object-assign",
|
|
||||||
"author": {
|
|
||||||
"name": "Sindre Sorhus",
|
|
||||||
"email": "sindresorhus@gmail.com",
|
|
||||||
"url": "sindresorhus.com"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "xo && ava",
|
|
||||||
"bench": "matcha bench.js"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"keywords": [
|
|
||||||
"object",
|
|
||||||
"assign",
|
|
||||||
"extend",
|
|
||||||
"properties",
|
|
||||||
"es2015",
|
|
||||||
"ecmascript",
|
|
||||||
"harmony",
|
|
||||||
"ponyfill",
|
|
||||||
"prollyfill",
|
|
||||||
"polyfill",
|
|
||||||
"shim",
|
|
||||||
"browser"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
|
||||||
"ava": "^0.16.0",
|
|
||||||
"lodash": "^4.16.4",
|
|
||||||
"matcha": "^0.7.0",
|
|
||||||
"xo": "^0.16.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
||||||
const router = require("./router.cjs");
|
|
||||||
const TSR_DEFERRED_PROMISE = Symbol.for("TSR_DEFERRED_PROMISE");
|
|
||||||
function defer(_promise, options) {
|
|
||||||
const promise = _promise;
|
|
||||||
if (promise[TSR_DEFERRED_PROMISE]) {
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
promise[TSR_DEFERRED_PROMISE] = { status: "pending" };
|
|
||||||
promise.then((data) => {
|
|
||||||
promise[TSR_DEFERRED_PROMISE].status = "success";
|
|
||||||
promise[TSR_DEFERRED_PROMISE].data = data;
|
|
||||||
}).catch((error) => {
|
|
||||||
promise[TSR_DEFERRED_PROMISE].status = "error";
|
|
||||||
promise[TSR_DEFERRED_PROMISE].error = {
|
|
||||||
data: ((options == null ? void 0 : options.serializeError) ?? router.defaultSerializeError)(error),
|
|
||||||
__isServerError: true
|
|
||||||
};
|
|
||||||
});
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
exports.TSR_DEFERRED_PROMISE = TSR_DEFERRED_PROMISE;
|
|
||||||
exports.defer = defer;
|
|
||||||
//# sourceMappingURL=defer.cjs.map
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,286 +0,0 @@
|
|||||||
export type VisitTraversalStep = import("@eslint/core").VisitTraversalStep;
|
|
||||||
export type CallTraversalStep = import("@eslint/core").CallTraversalStep;
|
|
||||||
export type TextSourceCode = import("@eslint/core").TextSourceCode;
|
|
||||||
export type TraversalStep = import("@eslint/core").TraversalStep;
|
|
||||||
export type SourceLocation = import("@eslint/core").SourceLocation;
|
|
||||||
export type SourceLocationWithOffset = import("@eslint/core").SourceLocationWithOffset;
|
|
||||||
export type SourceRange = import("@eslint/core").SourceRange;
|
|
||||||
export type IDirective = import("@eslint/core").Directive;
|
|
||||||
export type DirectiveType = import("@eslint/core").DirectiveType;
|
|
||||||
export type RuleConfig = import("@eslint/core").RuleConfig;
|
|
||||||
export type RulesConfig = import("@eslint/core").RulesConfig;
|
|
||||||
export type StringConfig = import("./types.ts").StringConfig;
|
|
||||||
export type BooleanConfig = import("./types.ts").BooleanConfig;
|
|
||||||
/**
|
|
||||||
* A class to represent a step in the traversal process where a
|
|
||||||
* method is called.
|
|
||||||
* @implements {CallTraversalStep}
|
|
||||||
*/
|
|
||||||
export class CallMethodStep implements CallTraversalStep {
|
|
||||||
/**
|
|
||||||
* Creates a new instance.
|
|
||||||
* @param {Object} options The options for the step.
|
|
||||||
* @param {string} options.target The target of the step.
|
|
||||||
* @param {Array<any>} options.args The arguments of the step.
|
|
||||||
*/
|
|
||||||
constructor({ target, args }: {
|
|
||||||
target: string;
|
|
||||||
args: Array<any>;
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* The type of the step.
|
|
||||||
* @type {"call"}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
readonly type: "call";
|
|
||||||
/**
|
|
||||||
* The kind of the step. Represents the same data as the `type` property
|
|
||||||
* but it's a number for performance.
|
|
||||||
* @type {2}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
readonly kind: 2;
|
|
||||||
/**
|
|
||||||
* The name of the method to call.
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
target: string;
|
|
||||||
/**
|
|
||||||
* The arguments to pass to the method.
|
|
||||||
* @type {Array<any>}
|
|
||||||
*/
|
|
||||||
args: Array<any>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Object to parse ESLint configuration comments.
|
|
||||||
*/
|
|
||||||
export class ConfigCommentParser {
|
|
||||||
/**
|
|
||||||
* Parses a list of "name:string_value" or/and "name" options divided by comma or
|
|
||||||
* whitespace. Used for "global" comments.
|
|
||||||
* @param {string} string The string to parse.
|
|
||||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
|
||||||
*/
|
|
||||||
parseStringConfig(string: string): StringConfig;
|
|
||||||
/**
|
|
||||||
* Parses a JSON-like config.
|
|
||||||
* @param {string} string The string to parse.
|
|
||||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
|
||||||
*/
|
|
||||||
parseJSONLikeConfig(string: string): ({
|
|
||||||
ok: true;
|
|
||||||
config: RulesConfig;
|
|
||||||
} | {
|
|
||||||
ok: false;
|
|
||||||
error: {
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* Parses a config of values separated by comma.
|
|
||||||
* @param {string} string The string to parse.
|
|
||||||
* @returns {BooleanConfig} Result map of values and true values
|
|
||||||
*/
|
|
||||||
parseListConfig(string: string): BooleanConfig;
|
|
||||||
/**
|
|
||||||
* Parses a directive comment into directive text and value.
|
|
||||||
* @param {string} string The string with the directive to be parsed.
|
|
||||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
|
||||||
*/
|
|
||||||
parseDirective(string: string): DirectiveComment | undefined;
|
|
||||||
#private;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A class to represent a directive comment.
|
|
||||||
* @implements {IDirective}
|
|
||||||
*/
|
|
||||||
export class Directive implements IDirective {
|
|
||||||
/**
|
|
||||||
* Creates a new instance.
|
|
||||||
* @param {Object} options The options for the directive.
|
|
||||||
* @param {"disable"|"enable"|"disable-next-line"|"disable-line"} options.type The type of directive.
|
|
||||||
* @param {unknown} options.node The node representing the directive.
|
|
||||||
* @param {string} options.value The value of the directive.
|
|
||||||
* @param {string} options.justification The justification for the directive.
|
|
||||||
*/
|
|
||||||
constructor({ type, node, value, justification }: {
|
|
||||||
type: "disable" | "enable" | "disable-next-line" | "disable-line";
|
|
||||||
node: unknown;
|
|
||||||
value: string;
|
|
||||||
justification: string;
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* The type of directive.
|
|
||||||
* @type {DirectiveType}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
readonly type: DirectiveType;
|
|
||||||
/**
|
|
||||||
* The node representing the directive.
|
|
||||||
* @type {unknown}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
readonly node: unknown;
|
|
||||||
/**
|
|
||||||
* Everything after the "eslint-disable" portion of the directive,
|
|
||||||
* but before the "--" that indicates the justification.
|
|
||||||
* @type {string}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
readonly value: string;
|
|
||||||
/**
|
|
||||||
* The justification for the directive.
|
|
||||||
* @type {string}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
readonly justification: string;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Source Code Base Object
|
|
||||||
* @implements {TextSourceCode}
|
|
||||||
*/
|
|
||||||
export class TextSourceCodeBase implements TextSourceCode {
|
|
||||||
/**
|
|
||||||
* Creates a new instance.
|
|
||||||
* @param {Object} options The options for the instance.
|
|
||||||
* @param {string} options.text The source code text.
|
|
||||||
* @param {object} options.ast The root AST node.
|
|
||||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code.
|
|
||||||
*/
|
|
||||||
constructor({ text, ast, lineEndingPattern }: {
|
|
||||||
text: string;
|
|
||||||
ast: object;
|
|
||||||
lineEndingPattern?: RegExp;
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* The AST of the source code.
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
ast: object;
|
|
||||||
/**
|
|
||||||
* The text of the source code.
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
text: string;
|
|
||||||
/**
|
|
||||||
* Returns the loc information for the given node or token.
|
|
||||||
* @param {object} nodeOrToken The node or token to get the loc information for.
|
|
||||||
* @returns {SourceLocation} The loc information for the node or token.
|
|
||||||
*/
|
|
||||||
getLoc(nodeOrToken: object): SourceLocation;
|
|
||||||
/**
|
|
||||||
* Returns the range information for the given node or token.
|
|
||||||
* @param {object} nodeOrToken The node or token to get the range information for.
|
|
||||||
* @returns {SourceRange} The range information for the node or token.
|
|
||||||
*/
|
|
||||||
getRange(nodeOrToken: object): SourceRange;
|
|
||||||
/**
|
|
||||||
* Returns the parent of the given node.
|
|
||||||
* @param {object} node The node to get the parent of.
|
|
||||||
* @returns {object|undefined} The parent of the node.
|
|
||||||
*/
|
|
||||||
getParent(node: object): object | undefined;
|
|
||||||
/**
|
|
||||||
* Gets all the ancestors of a given node
|
|
||||||
* @param {object} node The node
|
|
||||||
* @returns {Array<object>} All the ancestor nodes in the AST, not including the provided node, starting
|
|
||||||
* from the root node at index 0 and going inwards to the parent node.
|
|
||||||
* @throws {TypeError} When `node` is missing.
|
|
||||||
*/
|
|
||||||
getAncestors(node: object): Array<object>;
|
|
||||||
/**
|
|
||||||
* Gets the source code for the given node.
|
|
||||||
* @param {object} [node] The AST node to get the text for.
|
|
||||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
|
||||||
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
|
||||||
* @returns {string} The text representing the AST node.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
public getText(node?: object, beforeCount?: number, afterCount?: number): string;
|
|
||||||
/**
|
|
||||||
* Gets the entire source text split into an array of lines.
|
|
||||||
* @returns {Array<string>} The source text as an array of lines.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
public get lines(): Array<string>;
|
|
||||||
/**
|
|
||||||
* Traverse the source code and return the steps that were taken.
|
|
||||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
|
||||||
*/
|
|
||||||
traverse(): Iterable<TraversalStep>;
|
|
||||||
#private;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A class to represent a step in the traversal process where a node is visited.
|
|
||||||
* @implements {VisitTraversalStep}
|
|
||||||
*/
|
|
||||||
export class VisitNodeStep implements VisitTraversalStep {
|
|
||||||
/**
|
|
||||||
* Creates a new instance.
|
|
||||||
* @param {Object} options The options for the step.
|
|
||||||
* @param {object} options.target The target of the step.
|
|
||||||
* @param {1|2} options.phase The phase of the step.
|
|
||||||
* @param {Array<any>} options.args The arguments of the step.
|
|
||||||
*/
|
|
||||||
constructor({ target, phase, args }: {
|
|
||||||
target: object;
|
|
||||||
phase: 1 | 2;
|
|
||||||
args: Array<any>;
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* The type of the step.
|
|
||||||
* @type {"visit"}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
readonly type: "visit";
|
|
||||||
/**
|
|
||||||
* The kind of the step. Represents the same data as the `type` property
|
|
||||||
* but it's a number for performance.
|
|
||||||
* @type {1}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
readonly kind: 1;
|
|
||||||
/**
|
|
||||||
* The target of the step.
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
target: object;
|
|
||||||
/**
|
|
||||||
* The phase of the step.
|
|
||||||
* @type {1|2}
|
|
||||||
*/
|
|
||||||
phase: 1 | 2;
|
|
||||||
/**
|
|
||||||
* The arguments of the step.
|
|
||||||
* @type {Array<any>}
|
|
||||||
*/
|
|
||||||
args: Array<any>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Represents a directive comment.
|
|
||||||
*/
|
|
||||||
declare class DirectiveComment {
|
|
||||||
/**
|
|
||||||
* Creates a new directive comment.
|
|
||||||
* @param {string} label The label of the directive.
|
|
||||||
* @param {string} value The value of the directive.
|
|
||||||
* @param {string} justification The justification of the directive.
|
|
||||||
*/
|
|
||||||
constructor(label: string, value: string, justification: string);
|
|
||||||
/**
|
|
||||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
label: string;
|
|
||||||
/**
|
|
||||||
* The value of the directive (the string after the label).
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
value: string;
|
|
||||||
/**
|
|
||||||
* The justification of the directive (the string after the --).
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
justification: string;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
// This alphabet uses `A-Za-z0-9_-` symbols.
|
|
||||||
// The order of characters is optimized for better gzip and brotli compression.
|
|
||||||
// References to the same file (works both for gzip and brotli):
|
|
||||||
// `'use`, `andom`, and `rict'`
|
|
||||||
// References to the brotli default dictionary:
|
|
||||||
// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
|
|
||||||
let urlAlphabet =
|
|
||||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
||||||
|
|
||||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
||||||
return (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
|
||||||
let i = size | 0
|
|
||||||
while (i--) {
|
|
||||||
// `| 0` is more compact and faster than `Math.floor()`.
|
|
||||||
id += alphabet[(Math.random() * alphabet.length) | 0]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let nanoid = (size = 21) => {
|
|
||||||
let id = ''
|
|
||||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
|
||||||
let i = size | 0
|
|
||||||
while (i--) {
|
|
||||||
// `| 0` is more compact and faster than `Math.floor()`.
|
|
||||||
id += urlAlphabet[(Math.random() * 64) | 0]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { nanoid, customAlphabet }
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
||||||
const jsxRuntime = require("react/jsx-runtime");
|
|
||||||
const React = require("react");
|
|
||||||
const Match = require("./Match.cjs");
|
|
||||||
function _interopNamespaceDefault(e) {
|
|
||||||
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
||||||
if (e) {
|
|
||||||
for (const k in e) {
|
|
||||||
if (k !== "default") {
|
|
||||||
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
||||||
Object.defineProperty(n, k, d.get ? d : {
|
|
||||||
enumerable: true,
|
|
||||||
get: () => e[k]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
n.default = e;
|
|
||||||
return Object.freeze(n);
|
|
||||||
}
|
|
||||||
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
||||||
function isModuleNotFoundError(error) {
|
|
||||||
if (typeof (error == null ? void 0 : error.message) !== "string") return false;
|
|
||||||
return error.message.startsWith("Failed to fetch dynamically imported module") || error.message.startsWith("error loading dynamically imported module") || error.message.startsWith("Importing a module script failed");
|
|
||||||
}
|
|
||||||
function ClientOnly({
|
|
||||||
children,
|
|
||||||
fallback = null
|
|
||||||
}) {
|
|
||||||
return useHydrated() ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
|
|
||||||
}
|
|
||||||
function subscribe() {
|
|
||||||
return () => {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function useHydrated() {
|
|
||||||
return React__namespace.useSyncExternalStore(
|
|
||||||
subscribe,
|
|
||||||
() => true,
|
|
||||||
() => false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
function lazyRouteComponent(importer, exportName, ssr) {
|
|
||||||
let loadPromise;
|
|
||||||
let comp;
|
|
||||||
let error;
|
|
||||||
let reload;
|
|
||||||
const load = () => {
|
|
||||||
if (typeof document === "undefined" && (ssr == null ? void 0 : ssr()) === false) {
|
|
||||||
comp = () => null;
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
if (!loadPromise) {
|
|
||||||
loadPromise = importer().then((res) => {
|
|
||||||
loadPromise = void 0;
|
|
||||||
comp = res[exportName ?? "default"];
|
|
||||||
}).catch((err) => {
|
|
||||||
error = err;
|
|
||||||
if (isModuleNotFoundError(error)) {
|
|
||||||
if (error instanceof Error && typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
|
|
||||||
const storageKey = `tanstack_router_reload:${error.message}`;
|
|
||||||
if (!sessionStorage.getItem(storageKey)) {
|
|
||||||
sessionStorage.setItem(storageKey, "1");
|
|
||||||
reload = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return loadPromise;
|
|
||||||
};
|
|
||||||
const lazyComp = function Lazy(props) {
|
|
||||||
if (reload) {
|
|
||||||
window.location.reload();
|
|
||||||
throw new Promise(() => {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
if (!comp) {
|
|
||||||
throw load();
|
|
||||||
}
|
|
||||||
if ((ssr == null ? void 0 : ssr()) === false) {
|
|
||||||
return /* @__PURE__ */ jsxRuntime.jsx(ClientOnly, { fallback: /* @__PURE__ */ jsxRuntime.jsx(Match.Outlet, {}), children: React__namespace.createElement(comp, props) });
|
|
||||||
}
|
|
||||||
return React__namespace.createElement(comp, props);
|
|
||||||
};
|
|
||||||
lazyComp.preload = load;
|
|
||||||
return lazyComp;
|
|
||||||
}
|
|
||||||
exports.ClientOnly = ClientOnly;
|
|
||||||
exports.lazyRouteComponent = lazyRouteComponent;
|
|
||||||
exports.useHydrated = useHydrated;
|
|
||||||
//# sourceMappingURL=lazyRouteComponent.cjs.map
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
/*!
|
|
||||||
* is-extglob <https://github.com/jonschlinkert/is-extglob>
|
|
||||||
*
|
|
||||||
* Copyright (c) 2014-2016, Jon Schlinkert.
|
|
||||||
* Licensed under the MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = function isExtglob(str) {
|
|
||||||
if (typeof str !== 'string' || str === '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var match;
|
|
||||||
while ((match = /(\\).|([@?!+*]\(.*\))/g.exec(str))) {
|
|
||||||
if (match[2]) return true;
|
|
||||||
str = str.slice(match.index + match[0].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
@@ -1,294 +0,0 @@
|
|||||||
/**
|
|
||||||
* negotiator
|
|
||||||
* Copyright(c) 2012 Isaac Z. Schlueter
|
|
||||||
* Copyright(c) 2014 Federico Romero
|
|
||||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
||||||
* MIT Licensed
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module exports.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = preferredMediaTypes;
|
|
||||||
module.exports.preferredMediaTypes = preferredMediaTypes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module variables.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
var simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse the Accept header.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function parseAccept(accept) {
|
|
||||||
var accepts = splitMediaTypes(accept);
|
|
||||||
|
|
||||||
for (var i = 0, j = 0; i < accepts.length; i++) {
|
|
||||||
var mediaType = parseMediaType(accepts[i].trim(), i);
|
|
||||||
|
|
||||||
if (mediaType) {
|
|
||||||
accepts[j++] = mediaType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// trim accepts
|
|
||||||
accepts.length = j;
|
|
||||||
|
|
||||||
return accepts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a media type from the Accept header.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function parseMediaType(str, i) {
|
|
||||||
var match = simpleMediaTypeRegExp.exec(str);
|
|
||||||
if (!match) return null;
|
|
||||||
|
|
||||||
var params = Object.create(null);
|
|
||||||
var q = 1;
|
|
||||||
var subtype = match[2];
|
|
||||||
var type = match[1];
|
|
||||||
|
|
||||||
if (match[3]) {
|
|
||||||
var kvps = splitParameters(match[3]).map(splitKeyValuePair);
|
|
||||||
|
|
||||||
for (var j = 0; j < kvps.length; j++) {
|
|
||||||
var pair = kvps[j];
|
|
||||||
var key = pair[0].toLowerCase();
|
|
||||||
var val = pair[1];
|
|
||||||
|
|
||||||
// get the value, unwrapping quotes
|
|
||||||
var value = val && val[0] === '"' && val[val.length - 1] === '"'
|
|
||||||
? val.slice(1, -1)
|
|
||||||
: val;
|
|
||||||
|
|
||||||
if (key === 'q') {
|
|
||||||
q = parseFloat(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// store parameter
|
|
||||||
params[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
type: type,
|
|
||||||
subtype: subtype,
|
|
||||||
params: params,
|
|
||||||
q: q,
|
|
||||||
i: i
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the priority of a media type.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function getMediaTypePriority(type, accepted, index) {
|
|
||||||
var priority = {o: -1, q: 0, s: 0};
|
|
||||||
|
|
||||||
for (var i = 0; i < accepted.length; i++) {
|
|
||||||
var spec = specify(type, accepted[i], index);
|
|
||||||
|
|
||||||
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
|
|
||||||
priority = spec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the specificity of the media type.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function specify(type, spec, index) {
|
|
||||||
var p = parseMediaType(type);
|
|
||||||
var s = 0;
|
|
||||||
|
|
||||||
if (!p) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(spec.type.toLowerCase() == p.type.toLowerCase()) {
|
|
||||||
s |= 4
|
|
||||||
} else if(spec.type != '*') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(spec.subtype.toLowerCase() == p.subtype.toLowerCase()) {
|
|
||||||
s |= 2
|
|
||||||
} else if(spec.subtype != '*') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var keys = Object.keys(spec.params);
|
|
||||||
if (keys.length > 0) {
|
|
||||||
if (keys.every(function (k) {
|
|
||||||
return spec.params[k] == '*' || (spec.params[k] || '').toLowerCase() == (p.params[k] || '').toLowerCase();
|
|
||||||
})) {
|
|
||||||
s |= 1
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
i: index,
|
|
||||||
o: spec.i,
|
|
||||||
q: spec.q,
|
|
||||||
s: s,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the preferred media types from an Accept header.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
|
|
||||||
function preferredMediaTypes(accept, provided) {
|
|
||||||
// RFC 2616 sec 14.2: no header = */*
|
|
||||||
var accepts = parseAccept(accept === undefined ? '*/*' : accept || '');
|
|
||||||
|
|
||||||
if (!provided) {
|
|
||||||
// sorted list of all types
|
|
||||||
return accepts
|
|
||||||
.filter(isQuality)
|
|
||||||
.sort(compareSpecs)
|
|
||||||
.map(getFullType);
|
|
||||||
}
|
|
||||||
|
|
||||||
var priorities = provided.map(function getPriority(type, index) {
|
|
||||||
return getMediaTypePriority(type, accepts, index);
|
|
||||||
});
|
|
||||||
|
|
||||||
// sorted list of accepted types
|
|
||||||
return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) {
|
|
||||||
return provided[priorities.indexOf(priority)];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare two specs.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function compareSpecs(a, b) {
|
|
||||||
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get full type string.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function getFullType(spec) {
|
|
||||||
return spec.type + '/' + spec.subtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a spec has any quality.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function isQuality(spec) {
|
|
||||||
return spec.q > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Count the number of quotes in a string.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function quoteCount(string) {
|
|
||||||
var count = 0;
|
|
||||||
var index = 0;
|
|
||||||
|
|
||||||
while ((index = string.indexOf('"', index)) !== -1) {
|
|
||||||
count++;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Split a key value pair.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function splitKeyValuePair(str) {
|
|
||||||
var index = str.indexOf('=');
|
|
||||||
var key;
|
|
||||||
var val;
|
|
||||||
|
|
||||||
if (index === -1) {
|
|
||||||
key = str;
|
|
||||||
} else {
|
|
||||||
key = str.slice(0, index);
|
|
||||||
val = str.slice(index + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [key, val];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Split an Accept header into media types.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function splitMediaTypes(accept) {
|
|
||||||
var accepts = accept.split(',');
|
|
||||||
|
|
||||||
for (var i = 1, j = 0; i < accepts.length; i++) {
|
|
||||||
if (quoteCount(accepts[j]) % 2 == 0) {
|
|
||||||
accepts[++j] = accepts[i];
|
|
||||||
} else {
|
|
||||||
accepts[j] += ',' + accepts[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// trim accepts
|
|
||||||
accepts.length = j + 1;
|
|
||||||
|
|
||||||
return accepts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Split a string of parameters.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function splitParameters(str) {
|
|
||||||
var parameters = str.split(';');
|
|
||||||
|
|
||||||
for (var i = 1, j = 0; i < parameters.length; i++) {
|
|
||||||
if (quoteCount(parameters[j]) % 2 == 0) {
|
|
||||||
parameters[++j] = parameters[i];
|
|
||||||
} else {
|
|
||||||
parameters[j] += ';' + parameters[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// trim parameters
|
|
||||||
parameters.length = j + 1;
|
|
||||||
|
|
||||||
for (var i = 0; i < parameters.length; i++) {
|
|
||||||
parameters[i] = parameters[i].trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
@@ -1,360 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
exports.default = rewriteLiveReferences;
|
|
||||||
var _core = require("@babel/core");
|
|
||||||
function isInType(path) {
|
|
||||||
do {
|
|
||||||
switch (path.parent.type) {
|
|
||||||
case "TSTypeAnnotation":
|
|
||||||
case "TSTypeAliasDeclaration":
|
|
||||||
case "TSTypeReference":
|
|
||||||
case "TypeAnnotation":
|
|
||||||
case "TypeAlias":
|
|
||||||
return true;
|
|
||||||
case "ExportSpecifier":
|
|
||||||
return path.parentPath.parent.exportKind === "type";
|
|
||||||
default:
|
|
||||||
if (path.parentPath.isStatement() || path.parentPath.isExpression()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (path = path.parentPath);
|
|
||||||
}
|
|
||||||
function rewriteLiveReferences(programPath, metadata, wrapReference) {
|
|
||||||
const imported = new Map();
|
|
||||||
const exported = new Map();
|
|
||||||
const requeueInParent = path => {
|
|
||||||
programPath.requeue(path);
|
|
||||||
};
|
|
||||||
for (const [source, data] of metadata.source) {
|
|
||||||
for (const [localName, importName] of data.imports) {
|
|
||||||
imported.set(localName, [source, importName, null]);
|
|
||||||
}
|
|
||||||
for (const localName of data.importsNamespace) {
|
|
||||||
imported.set(localName, [source, null, localName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const [local, data] of metadata.local) {
|
|
||||||
let exportMeta = exported.get(local);
|
|
||||||
if (!exportMeta) {
|
|
||||||
exportMeta = [];
|
|
||||||
exported.set(local, exportMeta);
|
|
||||||
}
|
|
||||||
exportMeta.push(...data.names);
|
|
||||||
}
|
|
||||||
const rewriteBindingInitVisitorState = {
|
|
||||||
metadata,
|
|
||||||
requeueInParent,
|
|
||||||
scope: programPath.scope,
|
|
||||||
exported
|
|
||||||
};
|
|
||||||
programPath.traverse(rewriteBindingInitVisitor, rewriteBindingInitVisitorState);
|
|
||||||
const rewriteReferencesVisitorState = {
|
|
||||||
seen: new WeakSet(),
|
|
||||||
metadata,
|
|
||||||
requeueInParent,
|
|
||||||
scope: programPath.scope,
|
|
||||||
imported,
|
|
||||||
exported,
|
|
||||||
buildImportReference([source, importName, localName], identNode) {
|
|
||||||
const meta = metadata.source.get(source);
|
|
||||||
meta.referenced = true;
|
|
||||||
if (localName) {
|
|
||||||
if (meta.wrap) {
|
|
||||||
var _wrapReference;
|
|
||||||
identNode = (_wrapReference = wrapReference(identNode, meta.wrap)) != null ? _wrapReference : identNode;
|
|
||||||
}
|
|
||||||
return identNode;
|
|
||||||
}
|
|
||||||
let namespace = _core.types.identifier(meta.name);
|
|
||||||
if (meta.wrap) {
|
|
||||||
var _wrapReference2;
|
|
||||||
namespace = (_wrapReference2 = wrapReference(namespace, meta.wrap)) != null ? _wrapReference2 : namespace;
|
|
||||||
}
|
|
||||||
if (importName === "default" && meta.interop === "node-default") {
|
|
||||||
return namespace;
|
|
||||||
}
|
|
||||||
const computed = metadata.stringSpecifiers.has(importName);
|
|
||||||
return _core.types.memberExpression(namespace, computed ? _core.types.stringLiteral(importName) : _core.types.identifier(importName), computed);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
programPath.traverse(rewriteReferencesVisitor, rewriteReferencesVisitorState);
|
|
||||||
}
|
|
||||||
const rewriteBindingInitVisitor = {
|
|
||||||
Scope(path) {
|
|
||||||
path.skip();
|
|
||||||
},
|
|
||||||
ClassDeclaration(path) {
|
|
||||||
const {
|
|
||||||
requeueInParent,
|
|
||||||
exported,
|
|
||||||
metadata
|
|
||||||
} = this;
|
|
||||||
const {
|
|
||||||
id
|
|
||||||
} = path.node;
|
|
||||||
if (!id) throw new Error("Expected class to have a name");
|
|
||||||
const localName = id.name;
|
|
||||||
const exportNames = exported.get(localName) || [];
|
|
||||||
if (exportNames.length > 0) {
|
|
||||||
const statement = _core.types.expressionStatement(buildBindingExportAssignmentExpression(metadata, exportNames, _core.types.identifier(localName), path.scope));
|
|
||||||
statement._blockHoist = path.node._blockHoist;
|
|
||||||
requeueInParent(path.insertAfter(statement)[0]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
VariableDeclaration(path) {
|
|
||||||
const {
|
|
||||||
requeueInParent,
|
|
||||||
exported,
|
|
||||||
metadata
|
|
||||||
} = this;
|
|
||||||
const isVar = path.node.kind === "var";
|
|
||||||
for (const decl of path.get("declarations")) {
|
|
||||||
const {
|
|
||||||
id
|
|
||||||
} = decl.node;
|
|
||||||
let {
|
|
||||||
init
|
|
||||||
} = decl.node;
|
|
||||||
if (_core.types.isIdentifier(id) && exported.has(id.name) && !_core.types.isArrowFunctionExpression(init) && (!_core.types.isFunctionExpression(init) || init.id) && (!_core.types.isClassExpression(init) || init.id)) {
|
|
||||||
if (!init) {
|
|
||||||
if (isVar) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
init = path.scope.buildUndefinedNode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
decl.node.init = buildBindingExportAssignmentExpression(metadata, exported.get(id.name), init, path.scope);
|
|
||||||
requeueInParent(decl.get("init"));
|
|
||||||
} else {
|
|
||||||
for (const localName of Object.keys(decl.getOuterBindingIdentifiers())) {
|
|
||||||
if (exported.has(localName)) {
|
|
||||||
const statement = _core.types.expressionStatement(buildBindingExportAssignmentExpression(metadata, exported.get(localName), _core.types.identifier(localName), path.scope));
|
|
||||||
statement._blockHoist = path.node._blockHoist;
|
|
||||||
requeueInParent(path.insertAfter(statement)[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const buildBindingExportAssignmentExpression = (metadata, exportNames, localExpr, scope) => {
|
|
||||||
const exportsObjectName = metadata.exportName;
|
|
||||||
for (let currentScope = scope; currentScope != null; currentScope = currentScope.parent) {
|
|
||||||
if (currentScope.hasOwnBinding(exportsObjectName)) {
|
|
||||||
currentScope.rename(exportsObjectName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (exportNames || []).reduce((expr, exportName) => {
|
|
||||||
const {
|
|
||||||
stringSpecifiers
|
|
||||||
} = metadata;
|
|
||||||
const computed = stringSpecifiers.has(exportName);
|
|
||||||
return _core.types.assignmentExpression("=", _core.types.memberExpression(_core.types.identifier(exportsObjectName), computed ? _core.types.stringLiteral(exportName) : _core.types.identifier(exportName), computed), expr);
|
|
||||||
}, localExpr);
|
|
||||||
};
|
|
||||||
const buildImportThrow = localName => {
|
|
||||||
return _core.template.expression.ast`
|
|
||||||
(function() {
|
|
||||||
throw new Error('"' + '${localName}' + '" is read-only.');
|
|
||||||
})()
|
|
||||||
`;
|
|
||||||
};
|
|
||||||
const rewriteReferencesVisitor = {
|
|
||||||
ReferencedIdentifier(path) {
|
|
||||||
const {
|
|
||||||
seen,
|
|
||||||
buildImportReference,
|
|
||||||
scope,
|
|
||||||
imported,
|
|
||||||
requeueInParent
|
|
||||||
} = this;
|
|
||||||
if (seen.has(path.node)) return;
|
|
||||||
seen.add(path.node);
|
|
||||||
const localName = path.node.name;
|
|
||||||
const importData = imported.get(localName);
|
|
||||||
if (importData) {
|
|
||||||
if (isInType(path)) {
|
|
||||||
throw path.buildCodeFrameError(`Cannot transform the imported binding "${localName}" since it's also used in a type annotation. ` + `Please strip type annotations using @babel/preset-typescript or @babel/preset-flow.`);
|
|
||||||
}
|
|
||||||
const localBinding = path.scope.getBinding(localName);
|
|
||||||
const rootBinding = scope.getBinding(localName);
|
|
||||||
if (rootBinding !== localBinding) return;
|
|
||||||
const ref = buildImportReference(importData, path.node);
|
|
||||||
ref.loc = path.node.loc;
|
|
||||||
if ((path.parentPath.isCallExpression({
|
|
||||||
callee: path.node
|
|
||||||
}) || path.parentPath.isOptionalCallExpression({
|
|
||||||
callee: path.node
|
|
||||||
}) || path.parentPath.isTaggedTemplateExpression({
|
|
||||||
tag: path.node
|
|
||||||
})) && _core.types.isMemberExpression(ref)) {
|
|
||||||
path.replaceWith(_core.types.sequenceExpression([_core.types.numericLiteral(0), ref]));
|
|
||||||
} else if (path.isJSXIdentifier() && _core.types.isMemberExpression(ref)) {
|
|
||||||
const {
|
|
||||||
object,
|
|
||||||
property
|
|
||||||
} = ref;
|
|
||||||
path.replaceWith(_core.types.jsxMemberExpression(_core.types.jsxIdentifier(object.name), _core.types.jsxIdentifier(property.name)));
|
|
||||||
} else {
|
|
||||||
path.replaceWith(ref);
|
|
||||||
}
|
|
||||||
requeueInParent(path);
|
|
||||||
path.skip();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
UpdateExpression(path) {
|
|
||||||
const {
|
|
||||||
scope,
|
|
||||||
seen,
|
|
||||||
imported,
|
|
||||||
exported,
|
|
||||||
requeueInParent,
|
|
||||||
buildImportReference
|
|
||||||
} = this;
|
|
||||||
if (seen.has(path.node)) return;
|
|
||||||
seen.add(path.node);
|
|
||||||
const arg = path.get("argument");
|
|
||||||
if (arg.isMemberExpression()) return;
|
|
||||||
const update = path.node;
|
|
||||||
if (arg.isIdentifier()) {
|
|
||||||
const localName = arg.node.name;
|
|
||||||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const exportedNames = exported.get(localName);
|
|
||||||
const importData = imported.get(localName);
|
|
||||||
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) {
|
|
||||||
if (importData) {
|
|
||||||
path.replaceWith(_core.types.assignmentExpression(update.operator[0] + "=", buildImportReference(importData, arg.node), buildImportThrow(localName)));
|
|
||||||
} else if (update.prefix) {
|
|
||||||
path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, _core.types.cloneNode(update), path.scope));
|
|
||||||
} else {
|
|
||||||
const ref = scope.generateDeclaredUidIdentifier(localName);
|
|
||||||
path.replaceWith(_core.types.sequenceExpression([_core.types.assignmentExpression("=", _core.types.cloneNode(ref), _core.types.cloneNode(update)), buildBindingExportAssignmentExpression(this.metadata, exportedNames, _core.types.identifier(localName), path.scope), _core.types.cloneNode(ref)]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
requeueInParent(path);
|
|
||||||
path.skip();
|
|
||||||
},
|
|
||||||
AssignmentExpression: {
|
|
||||||
exit(path) {
|
|
||||||
const {
|
|
||||||
scope,
|
|
||||||
seen,
|
|
||||||
imported,
|
|
||||||
exported,
|
|
||||||
requeueInParent,
|
|
||||||
buildImportReference
|
|
||||||
} = this;
|
|
||||||
if (seen.has(path.node)) return;
|
|
||||||
seen.add(path.node);
|
|
||||||
const left = path.get("left");
|
|
||||||
if (left.isMemberExpression()) return;
|
|
||||||
if (left.isIdentifier()) {
|
|
||||||
const localName = left.node.name;
|
|
||||||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const exportedNames = exported.get(localName);
|
|
||||||
const importData = imported.get(localName);
|
|
||||||
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) {
|
|
||||||
const assignment = path.node;
|
|
||||||
if (importData) {
|
|
||||||
assignment.left = buildImportReference(importData, left.node);
|
|
||||||
assignment.right = _core.types.sequenceExpression([assignment.right, buildImportThrow(localName)]);
|
|
||||||
}
|
|
||||||
const {
|
|
||||||
operator
|
|
||||||
} = assignment;
|
|
||||||
let newExpr;
|
|
||||||
if (operator === "=") {
|
|
||||||
newExpr = assignment;
|
|
||||||
} else if (operator === "&&=" || operator === "||=" || operator === "??=") {
|
|
||||||
newExpr = _core.types.assignmentExpression("=", assignment.left, _core.types.logicalExpression(operator.slice(0, -1), _core.types.cloneNode(assignment.left), assignment.right));
|
|
||||||
} else {
|
|
||||||
newExpr = _core.types.assignmentExpression("=", assignment.left, _core.types.binaryExpression(operator.slice(0, -1), _core.types.cloneNode(assignment.left), assignment.right));
|
|
||||||
}
|
|
||||||
path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, newExpr, path.scope));
|
|
||||||
requeueInParent(path);
|
|
||||||
path.skip();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const ids = left.getOuterBindingIdentifiers();
|
|
||||||
const programScopeIds = Object.keys(ids).filter(localName => scope.getBinding(localName) === path.scope.getBinding(localName));
|
|
||||||
const id = programScopeIds.find(localName => imported.has(localName));
|
|
||||||
if (id) {
|
|
||||||
path.node.right = _core.types.sequenceExpression([path.node.right, buildImportThrow(id)]);
|
|
||||||
}
|
|
||||||
const items = [];
|
|
||||||
programScopeIds.forEach(localName => {
|
|
||||||
const exportedNames = exported.get(localName) || [];
|
|
||||||
if (exportedNames.length > 0) {
|
|
||||||
items.push(buildBindingExportAssignmentExpression(this.metadata, exportedNames, _core.types.identifier(localName), path.scope));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (items.length > 0) {
|
|
||||||
let node = _core.types.sequenceExpression(items);
|
|
||||||
if (path.parentPath.isExpressionStatement()) {
|
|
||||||
node = _core.types.expressionStatement(node);
|
|
||||||
node._blockHoist = path.parentPath.node._blockHoist;
|
|
||||||
}
|
|
||||||
const statement = path.insertAfter(node)[0];
|
|
||||||
requeueInParent(statement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ForXStatement(path) {
|
|
||||||
const {
|
|
||||||
scope,
|
|
||||||
node
|
|
||||||
} = path;
|
|
||||||
const {
|
|
||||||
left
|
|
||||||
} = node;
|
|
||||||
const {
|
|
||||||
exported,
|
|
||||||
imported,
|
|
||||||
scope: programScope
|
|
||||||
} = this;
|
|
||||||
if (!_core.types.isVariableDeclaration(left)) {
|
|
||||||
let didTransformExport = false,
|
|
||||||
importConstViolationName;
|
|
||||||
const loopBodyScope = path.get("body").scope;
|
|
||||||
for (const name of Object.keys(_core.types.getOuterBindingIdentifiers(left))) {
|
|
||||||
if (programScope.getBinding(name) === scope.getBinding(name)) {
|
|
||||||
if (exported.has(name)) {
|
|
||||||
didTransformExport = true;
|
|
||||||
if (loopBodyScope.hasOwnBinding(name)) {
|
|
||||||
loopBodyScope.rename(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (imported.has(name) && !importConstViolationName) {
|
|
||||||
importConstViolationName = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!didTransformExport && !importConstViolationName) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
path.ensureBlock();
|
|
||||||
const bodyPath = path.get("body");
|
|
||||||
const newLoopId = scope.generateUidIdentifierBasedOnNode(left);
|
|
||||||
path.get("left").replaceWith(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(_core.types.cloneNode(newLoopId))]));
|
|
||||||
scope.registerDeclaration(path.get("left"));
|
|
||||||
if (didTransformExport) {
|
|
||||||
bodyPath.unshiftContainer("body", _core.types.expressionStatement(_core.types.assignmentExpression("=", left, newLoopId)));
|
|
||||||
}
|
|
||||||
if (importConstViolationName) {
|
|
||||||
bodyPath.unshiftContainer("body", _core.types.expressionStatement(buildImportThrow(importConstViolationName)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//# sourceMappingURL=rewrite-live-references.js.map
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Rule to check for tabs inside a file
|
|
||||||
* @author Gyandeep Singh
|
|
||||||
* @deprecated in ESLint v8.53.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const tabRegex = /\t+/gu;
|
|
||||||
const anyNonWhitespaceRegex = /\S/u;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Public Interface
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
deprecated: {
|
|
||||||
message: "Formatting rules are being moved out of ESLint core.",
|
|
||||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
||||||
deprecatedSince: "8.53.0",
|
|
||||||
availableUntil: "10.0.0",
|
|
||||||
replacedBy: [
|
|
||||||
{
|
|
||||||
message:
|
|
||||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
||||||
url: "https://eslint.style/guide/migration",
|
|
||||||
plugin: {
|
|
||||||
name: "@stylistic/eslint-plugin-js",
|
|
||||||
url: "https://eslint.style/packages/js",
|
|
||||||
},
|
|
||||||
rule: {
|
|
||||||
name: "no-tabs",
|
|
||||||
url: "https://eslint.style/rules/js/no-tabs",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
type: "layout",
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description: "Disallow all tabs",
|
|
||||||
recommended: false,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/no-tabs",
|
|
||||||
},
|
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
allowIndentationTabs: {
|
|
||||||
type: "boolean",
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
additionalProperties: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
messages: {
|
|
||||||
unexpectedTab: "Unexpected tab character.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
const sourceCode = context.sourceCode;
|
|
||||||
const allowIndentationTabs =
|
|
||||||
context.options &&
|
|
||||||
context.options[0] &&
|
|
||||||
context.options[0].allowIndentationTabs;
|
|
||||||
|
|
||||||
return {
|
|
||||||
Program(node) {
|
|
||||||
sourceCode.getLines().forEach((line, index) => {
|
|
||||||
let match;
|
|
||||||
|
|
||||||
while ((match = tabRegex.exec(line)) !== null) {
|
|
||||||
if (
|
|
||||||
allowIndentationTabs &&
|
|
||||||
!anyNonWhitespaceRegex.test(
|
|
||||||
line.slice(0, match.index),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.report({
|
|
||||||
node,
|
|
||||||
loc: {
|
|
||||||
start: {
|
|
||||||
line: index + 1,
|
|
||||||
column: match.index,
|
|
||||||
},
|
|
||||||
end: {
|
|
||||||
line: index + 1,
|
|
||||||
column: match.index + match[0].length,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
messageId: "unexpectedTab",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "binary-extensions",
|
|
||||||
"version": "2.3.0",
|
|
||||||
"description": "List of binary file extensions",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": "sindresorhus/binary-extensions",
|
|
||||||
"funding": "https://github.com/sponsors/sindresorhus",
|
|
||||||
"author": {
|
|
||||||
"name": "Sindre Sorhus",
|
|
||||||
"email": "sindresorhus@gmail.com",
|
|
||||||
"url": "https://sindresorhus.com"
|
|
||||||
},
|
|
||||||
"sideEffects": false,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "xo && ava && tsd"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js",
|
|
||||||
"index.d.ts",
|
|
||||||
"binary-extensions.json",
|
|
||||||
"binary-extensions.json.d.ts"
|
|
||||||
],
|
|
||||||
"keywords": [
|
|
||||||
"binary",
|
|
||||||
"extensions",
|
|
||||||
"extension",
|
|
||||||
"file",
|
|
||||||
"json",
|
|
||||||
"list",
|
|
||||||
"array"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
|
||||||
"ava": "^1.4.1",
|
|
||||||
"tsd": "^0.7.2",
|
|
||||||
"xo": "^0.24.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
declare namespace pLocate {
|
|
||||||
interface Options {
|
|
||||||
/**
|
|
||||||
Number of concurrently pending promises returned by `tester`. Minimum: `1`.
|
|
||||||
|
|
||||||
@default Infinity
|
|
||||||
*/
|
|
||||||
readonly concurrency?: number;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Preserve `input` order when searching.
|
|
||||||
|
|
||||||
Disable this to improve performance if you don't care about the order.
|
|
||||||
|
|
||||||
@default true
|
|
||||||
*/
|
|
||||||
readonly preserveOrder?: boolean;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the first fulfilled promise that satisfies the provided testing function.
|
|
||||||
|
|
||||||
@param input - An iterable of promises/values to test.
|
|
||||||
@param tester - This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.
|
|
||||||
@returns A `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
|
|
||||||
|
|
||||||
@example
|
|
||||||
```
|
|
||||||
import pathExists = require('path-exists');
|
|
||||||
import pLocate = require('p-locate');
|
|
||||||
|
|
||||||
const files = [
|
|
||||||
'unicorn.png',
|
|
||||||
'rainbow.png', // Only this one actually exists on disk
|
|
||||||
'pony.png'
|
|
||||||
];
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const foundPath = await pLocate(files, file => pathExists(file));
|
|
||||||
|
|
||||||
console.log(foundPath);
|
|
||||||
//=> 'rainbow'
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
declare function pLocate<ValueType>(
|
|
||||||
input: Iterable<PromiseLike<ValueType> | ValueType>,
|
|
||||||
tester: (element: ValueType) => PromiseLike<boolean> | boolean,
|
|
||||||
options?: pLocate.Options
|
|
||||||
): Promise<ValueType | undefined>;
|
|
||||||
|
|
||||||
export = pLocate;
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# @babel/helper-string-parser
|
|
||||||
|
|
||||||
> A utility package to parse strings
|
|
||||||
|
|
||||||
See our website [@babel/helper-string-parser](https://babeljs.io/docs/babel-helper-string-parser) for more information.
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
Using npm:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --save @babel/helper-string-parser
|
|
||||||
```
|
|
||||||
|
|
||||||
or using yarn:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
yarn add @babel/helper-string-parser
|
|
||||||
```
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
var serialOrdered = require('../serialOrdered.js');
|
|
||||||
|
|
||||||
// API
|
|
||||||
module.exports = ReadableSerialOrdered;
|
|
||||||
// expose sort helpers
|
|
||||||
module.exports.ascending = serialOrdered.ascending;
|
|
||||||
module.exports.descending = serialOrdered.descending;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Streaming wrapper to `asynckit.serialOrdered`
|
|
||||||
*
|
|
||||||
* @param {array|object} list - array or object (named list) to iterate over
|
|
||||||
* @param {function} iterator - iterator to run
|
|
||||||
* @param {function} sortMethod - custom sort function
|
|
||||||
* @param {function} callback - invoked when all elements processed
|
|
||||||
* @returns {stream.Readable#}
|
|
||||||
*/
|
|
||||||
function ReadableSerialOrdered(list, iterator, sortMethod, callback)
|
|
||||||
{
|
|
||||||
if (!(this instanceof ReadableSerialOrdered))
|
|
||||||
{
|
|
||||||
return new ReadableSerialOrdered(list, iterator, sortMethod, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// turn on object mode
|
|
||||||
ReadableSerialOrdered.super_.call(this, {objectMode: true});
|
|
||||||
|
|
||||||
this._start(serialOrdered, list, iterator, sortMethod, callback);
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
throw new Error(
|
|
||||||
'react-dom/profiling is not supported in React Server Components.'
|
|
||||||
);
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
const minimatch = require('minimatch');
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
const debug = require('debug')('nodemon:match');
|
|
||||||
const utils = require('../utils');
|
|
||||||
|
|
||||||
module.exports = match;
|
|
||||||
module.exports.rulesToMonitor = rulesToMonitor;
|
|
||||||
|
|
||||||
function rulesToMonitor(watch, ignore, config) {
|
|
||||||
var monitor = [];
|
|
||||||
|
|
||||||
if (!Array.isArray(ignore)) {
|
|
||||||
if (ignore) {
|
|
||||||
ignore = [ignore];
|
|
||||||
} else {
|
|
||||||
ignore = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Array.isArray(watch)) {
|
|
||||||
if (watch) {
|
|
||||||
watch = [watch];
|
|
||||||
} else {
|
|
||||||
watch = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (watch && watch.length) {
|
|
||||||
monitor = utils.clone(watch);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ignore) {
|
|
||||||
[].push.apply(
|
|
||||||
monitor,
|
|
||||||
(ignore || []).map(function (rule) {
|
|
||||||
return '!' + rule;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var cwd = process.cwd();
|
|
||||||
|
|
||||||
// next check if the monitored paths are actual directories
|
|
||||||
// or just patterns - and expand the rule to include *.*
|
|
||||||
monitor = monitor.map(function (rule) {
|
|
||||||
var not = rule.slice(0, 1) === '!';
|
|
||||||
|
|
||||||
if (not) {
|
|
||||||
rule = rule.slice(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rule === '.' || rule === '.*') {
|
|
||||||
rule = '*.*';
|
|
||||||
}
|
|
||||||
|
|
||||||
var dir = path.resolve(cwd, rule);
|
|
||||||
|
|
||||||
try {
|
|
||||||
var stat = fs.statSync(dir);
|
|
||||||
if (stat.isDirectory()) {
|
|
||||||
rule = dir;
|
|
||||||
if (rule.slice(-1) !== '/') {
|
|
||||||
rule += '/';
|
|
||||||
}
|
|
||||||
rule += '**/*';
|
|
||||||
|
|
||||||
// `!not` ... sorry.
|
|
||||||
if (!not) {
|
|
||||||
config.dirs.push(dir);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// ensures we end up in the check that tries to get a base directory
|
|
||||||
// and then adds it to the watch list
|
|
||||||
throw new Error();
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
var base = tryBaseDir(dir);
|
|
||||||
if (!not && base) {
|
|
||||||
if (config.dirs.indexOf(base) === -1) {
|
|
||||||
config.dirs.push(base);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rule.slice(-1) === '/') {
|
|
||||||
// just slap on a * anyway
|
|
||||||
rule += '*';
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the url ends with * but not **/* and not *.*
|
|
||||||
// then convert to **/* - somehow it was missed :-\
|
|
||||||
if (
|
|
||||||
rule.slice(-4) !== '**/*' &&
|
|
||||||
rule.slice(-1) === '*' &&
|
|
||||||
rule.indexOf('*.') === -1
|
|
||||||
) {
|
|
||||||
if (rule.slice(-2) !== '**') {
|
|
||||||
rule += '*/*';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (not ? '!' : '') + rule;
|
|
||||||
});
|
|
||||||
|
|
||||||
return monitor;
|
|
||||||
}
|
|
||||||
|
|
||||||
function tryBaseDir(dir) {
|
|
||||||
var stat;
|
|
||||||
if (/[?*\{\[]+/.test(dir)) {
|
|
||||||
// if this is pattern, then try to find the base
|
|
||||||
try {
|
|
||||||
var base = path.dirname(dir.replace(/([?*\{\[]+.*$)/, 'foo'));
|
|
||||||
stat = fs.statSync(base);
|
|
||||||
if (stat.isDirectory()) {
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
// console.log(error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
stat = fs.statSync(dir);
|
|
||||||
// if this path is actually a single file that exists, then just monitor
|
|
||||||
// that, *specifically*.
|
|
||||||
if (stat.isFile() || stat.isDirectory()) {
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function match(files, monitor, ext) {
|
|
||||||
// sort the rules by highest specificity (based on number of slashes)
|
|
||||||
// ignore rules (!) get sorted highest as they take precedent
|
|
||||||
const cwd = process.cwd();
|
|
||||||
var rules = monitor
|
|
||||||
.sort(function (a, b) {
|
|
||||||
var r = b.split(path.sep).length - a.split(path.sep).length;
|
|
||||||
var aIsIgnore = a.slice(0, 1) === '!';
|
|
||||||
var bIsIgnore = b.slice(0, 1) === '!';
|
|
||||||
|
|
||||||
if (aIsIgnore || bIsIgnore) {
|
|
||||||
if (aIsIgnore) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r === 0) {
|
|
||||||
return b.length - a.length;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
})
|
|
||||||
.map(function (s) {
|
|
||||||
var prefix = s.slice(0, 1);
|
|
||||||
|
|
||||||
if (prefix === '!') {
|
|
||||||
if (s.indexOf('!' + cwd) === 0) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it starts with a period, then let's get the relative path
|
|
||||||
if (s.indexOf('!.') === 0) {
|
|
||||||
return '!' + path.resolve(cwd, s.substring(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return '!**' + (prefix !== path.sep ? path.sep : '') + s.slice(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it starts with a period, then let's get the relative path
|
|
||||||
if (s.indexOf('.') === 0) {
|
|
||||||
return path.resolve(cwd, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s.indexOf(cwd) === 0) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '**' + (prefix !== path.sep ? path.sep : '') + s;
|
|
||||||
});
|
|
||||||
|
|
||||||
debug('rules', rules);
|
|
||||||
|
|
||||||
var good = [];
|
|
||||||
var whitelist = []; // files that we won't check against the extension
|
|
||||||
var ignored = 0;
|
|
||||||
var watched = 0;
|
|
||||||
var usedRules = [];
|
|
||||||
var minimatchOpts = {
|
|
||||||
dot: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
// enable case-insensitivity on Windows
|
|
||||||
if (utils.isWindows) {
|
|
||||||
minimatchOpts.nocase = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
files.forEach(function (file) {
|
|
||||||
file = path.resolve(cwd, file);
|
|
||||||
|
|
||||||
var matched = false;
|
|
||||||
for (var i = 0; i < rules.length; i++) {
|
|
||||||
if (rules[i].slice(0, 1) === '!') {
|
|
||||||
if (!minimatch(file, rules[i], minimatchOpts)) {
|
|
||||||
debug('ignored', file, 'rule:', rules[i]);
|
|
||||||
ignored++;
|
|
||||||
matched = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug('matched', file, 'rule:', rules[i]);
|
|
||||||
if (minimatch(file, rules[i], minimatchOpts)) {
|
|
||||||
watched++;
|
|
||||||
|
|
||||||
// don't repeat the output if a rule is matched
|
|
||||||
if (usedRules.indexOf(rules[i]) === -1) {
|
|
||||||
usedRules.push(rules[i]);
|
|
||||||
utils.log.detail('matched rule: ' + rules[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the rule doesn't match the WATCH EVERYTHING
|
|
||||||
// but *does* match a rule that ends with *.*, then
|
|
||||||
// white list it - in that we don't run it through
|
|
||||||
// the extension check too.
|
|
||||||
if (
|
|
||||||
rules[i] !== '**' + path.sep + '*.*' &&
|
|
||||||
rules[i].slice(-3) === '*.*'
|
|
||||||
) {
|
|
||||||
whitelist.push(file);
|
|
||||||
} else if (path.basename(file) === path.basename(rules[i])) {
|
|
||||||
// if the file matches the actual rule, then it's put on whitelist
|
|
||||||
whitelist.push(file);
|
|
||||||
} else {
|
|
||||||
good.push(file);
|
|
||||||
}
|
|
||||||
matched = true;
|
|
||||||
} else {
|
|
||||||
// utils.log.detail('no match: ' + rules[i], file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!matched) {
|
|
||||||
ignored++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// finally check the good files against the extensions that we're monitoring
|
|
||||||
if (ext) {
|
|
||||||
if (ext.indexOf(',') === -1) {
|
|
||||||
ext = '**/*.' + ext;
|
|
||||||
} else {
|
|
||||||
ext = '**/*.{' + ext + '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
good = good.filter(function (file) {
|
|
||||||
// only compare the filename to the extension test
|
|
||||||
return minimatch(path.basename(file), ext, minimatchOpts);
|
|
||||||
});
|
|
||||||
debug('good (filtered by ext)', good);
|
|
||||||
} else {
|
|
||||||
// else assume *.*
|
|
||||||
debug('good', good);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (whitelist.length) debug('whitelist', whitelist);
|
|
||||||
|
|
||||||
var result = good.concat(whitelist);
|
|
||||||
|
|
||||||
if (utils.isWindows) {
|
|
||||||
// fix for windows testing - I *think* this is okay to do
|
|
||||||
result = result.map(function (file) {
|
|
||||||
return file.slice(0, 1).toLowerCase() + file.slice(1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
result: result,
|
|
||||||
ignored: ignored,
|
|
||||||
watched: watched,
|
|
||||||
total: files.length,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,242 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Enforces that a return statement is present in property getters.
|
|
||||||
* @author Aladdin-ADD(hh_2013@foxmail.com)
|
|
||||||
*/
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Requirements
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const astUtils = require("./utils/ast-utils");
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks all segments in a set and returns true if any are reachable.
|
|
||||||
* @param {Set<CodePathSegment>} segments The segments to check.
|
|
||||||
* @returns {boolean} True if any segment is reachable; false otherwise.
|
|
||||||
*/
|
|
||||||
function isAnySegmentReachable(segments) {
|
|
||||||
for (const segment of segments) {
|
|
||||||
if (segment.reachable) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Rule Definition
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
type: "problem",
|
|
||||||
|
|
||||||
defaultOptions: [
|
|
||||||
{
|
|
||||||
allowImplicit: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description: "Enforce `return` statements in getters",
|
|
||||||
recommended: true,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/getter-return",
|
|
||||||
},
|
|
||||||
|
|
||||||
fixable: null,
|
|
||||||
|
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
allowImplicit: {
|
|
||||||
type: "boolean",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
additionalProperties: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
messages: {
|
|
||||||
expected: "Expected to return a value in {{name}}.",
|
|
||||||
expectedAlways: "Expected {{name}} to always return a value.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
const [{ allowImplicit }] = context.options;
|
|
||||||
const sourceCode = context.sourceCode;
|
|
||||||
|
|
||||||
let funcInfo = {
|
|
||||||
upper: null,
|
|
||||||
codePath: null,
|
|
||||||
hasReturn: false,
|
|
||||||
shouldCheck: false,
|
|
||||||
node: null,
|
|
||||||
currentSegments: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether or not the last code path segment is reachable.
|
|
||||||
* Then reports this function if the segment is reachable.
|
|
||||||
*
|
|
||||||
* If the last code path segment is reachable, there are paths which are not
|
|
||||||
* returned or thrown.
|
|
||||||
* @param {ASTNode} node A node to check.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
function checkLastSegment(node) {
|
|
||||||
if (
|
|
||||||
funcInfo.shouldCheck &&
|
|
||||||
isAnySegmentReachable(funcInfo.currentSegments)
|
|
||||||
) {
|
|
||||||
context.report({
|
|
||||||
node,
|
|
||||||
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
|
|
||||||
messageId: funcInfo.hasReturn
|
|
||||||
? "expectedAlways"
|
|
||||||
: "expected",
|
|
||||||
data: {
|
|
||||||
name: astUtils.getFunctionNameWithKind(funcInfo.node),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether a node means a getter function.
|
|
||||||
* @param {ASTNode} node a node to check.
|
|
||||||
* @returns {boolean} if node means a getter, return true; else return false.
|
|
||||||
*/
|
|
||||||
function isGetter(node) {
|
|
||||||
const parent = node.parent;
|
|
||||||
|
|
||||||
if (
|
|
||||||
TARGET_NODE_TYPE.test(node.type) &&
|
|
||||||
node.body.type === "BlockStatement"
|
|
||||||
) {
|
|
||||||
if (parent.kind === "get") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
parent.type === "Property" &&
|
|
||||||
astUtils.getStaticPropertyName(parent) === "get" &&
|
|
||||||
parent.parent.type === "ObjectExpression"
|
|
||||||
) {
|
|
||||||
// Object.defineProperty() or Reflect.defineProperty()
|
|
||||||
if (parent.parent.parent.type === "CallExpression") {
|
|
||||||
const callNode = parent.parent.parent.callee;
|
|
||||||
|
|
||||||
if (
|
|
||||||
astUtils.isSpecificMemberAccess(
|
|
||||||
callNode,
|
|
||||||
"Object",
|
|
||||||
"defineProperty",
|
|
||||||
) ||
|
|
||||||
astUtils.isSpecificMemberAccess(
|
|
||||||
callNode,
|
|
||||||
"Reflect",
|
|
||||||
"defineProperty",
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Object.defineProperties() or Object.create()
|
|
||||||
if (
|
|
||||||
parent.parent.parent.type === "Property" &&
|
|
||||||
parent.parent.parent.parent.type ===
|
|
||||||
"ObjectExpression" &&
|
|
||||||
parent.parent.parent.parent.parent.type ===
|
|
||||||
"CallExpression"
|
|
||||||
) {
|
|
||||||
const callNode =
|
|
||||||
parent.parent.parent.parent.parent.callee;
|
|
||||||
|
|
||||||
return (
|
|
||||||
astUtils.isSpecificMemberAccess(
|
|
||||||
callNode,
|
|
||||||
"Object",
|
|
||||||
"defineProperties",
|
|
||||||
) ||
|
|
||||||
astUtils.isSpecificMemberAccess(
|
|
||||||
callNode,
|
|
||||||
"Object",
|
|
||||||
"create",
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
// Stacks this function's information.
|
|
||||||
onCodePathStart(codePath, node) {
|
|
||||||
funcInfo = {
|
|
||||||
upper: funcInfo,
|
|
||||||
codePath,
|
|
||||||
hasReturn: false,
|
|
||||||
shouldCheck: isGetter(node),
|
|
||||||
node,
|
|
||||||
currentSegments: new Set(),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
// Pops this function's information.
|
|
||||||
onCodePathEnd() {
|
|
||||||
funcInfo = funcInfo.upper;
|
|
||||||
},
|
|
||||||
onUnreachableCodePathSegmentStart(segment) {
|
|
||||||
funcInfo.currentSegments.add(segment);
|
|
||||||
},
|
|
||||||
|
|
||||||
onUnreachableCodePathSegmentEnd(segment) {
|
|
||||||
funcInfo.currentSegments.delete(segment);
|
|
||||||
},
|
|
||||||
|
|
||||||
onCodePathSegmentStart(segment) {
|
|
||||||
funcInfo.currentSegments.add(segment);
|
|
||||||
},
|
|
||||||
|
|
||||||
onCodePathSegmentEnd(segment) {
|
|
||||||
funcInfo.currentSegments.delete(segment);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Checks the return statement is valid.
|
|
||||||
ReturnStatement(node) {
|
|
||||||
if (funcInfo.shouldCheck) {
|
|
||||||
funcInfo.hasReturn = true;
|
|
||||||
|
|
||||||
// if allowImplicit: false, should also check node.argument
|
|
||||||
if (!allowImplicit && !node.argument) {
|
|
||||||
context.report({
|
|
||||||
node,
|
|
||||||
messageId: "expected",
|
|
||||||
data: {
|
|
||||||
name: astUtils.getFunctionNameWithKind(
|
|
||||||
funcInfo.node,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Reports a given function if the last path is reachable.
|
|
||||||
"FunctionExpression:exit": checkLastSegment,
|
|
||||||
"ArrowFunctionExpression:exit": checkLastSegment,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,581 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Enforces empty lines around comments.
|
|
||||||
* @author Jamund Ferguson
|
|
||||||
* @deprecated in ESLint v8.53.0
|
|
||||||
*/
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Requirements
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const astUtils = require("./utils/ast-utils");
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an array with any line numbers that are empty.
|
|
||||||
* @param {Array} lines An array of each line of the file.
|
|
||||||
* @returns {Array} An array of line numbers.
|
|
||||||
*/
|
|
||||||
function getEmptyLineNums(lines) {
|
|
||||||
const emptyLines = lines
|
|
||||||
.map((line, i) => ({
|
|
||||||
code: line.trim(),
|
|
||||||
num: i + 1,
|
|
||||||
}))
|
|
||||||
.filter(line => !line.code)
|
|
||||||
.map(line => line.num);
|
|
||||||
|
|
||||||
return emptyLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an array with any line numbers that contain comments.
|
|
||||||
* @param {Array} comments An array of comment tokens.
|
|
||||||
* @returns {Array} An array of line numbers.
|
|
||||||
*/
|
|
||||||
function getCommentLineNums(comments) {
|
|
||||||
const lines = [];
|
|
||||||
|
|
||||||
comments.forEach(token => {
|
|
||||||
const start = token.loc.start.line;
|
|
||||||
const end = token.loc.end.line;
|
|
||||||
|
|
||||||
lines.push(start, end);
|
|
||||||
});
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Rule Definition
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** @type {import('../shared/types').Rule} */
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
|
||||||
deprecated: {
|
|
||||||
message: "Formatting rules are being moved out of ESLint core.",
|
|
||||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
||||||
deprecatedSince: "8.53.0",
|
|
||||||
availableUntil: "10.0.0",
|
|
||||||
replacedBy: [
|
|
||||||
{
|
|
||||||
message:
|
|
||||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
||||||
url: "https://eslint.style/guide/migration",
|
|
||||||
plugin: {
|
|
||||||
name: "@stylistic/eslint-plugin-js",
|
|
||||||
url: "https://eslint.style/packages/js",
|
|
||||||
},
|
|
||||||
rule: {
|
|
||||||
name: "lines-around-comment",
|
|
||||||
url: "https://eslint.style/rules/js/lines-around-comment",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
type: "layout",
|
|
||||||
|
|
||||||
docs: {
|
|
||||||
description: "Require empty lines around comments",
|
|
||||||
recommended: false,
|
|
||||||
url: "https://eslint.org/docs/latest/rules/lines-around-comment",
|
|
||||||
},
|
|
||||||
|
|
||||||
fixable: "whitespace",
|
|
||||||
|
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
beforeBlockComment: {
|
|
||||||
type: "boolean",
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
afterBlockComment: {
|
|
||||||
type: "boolean",
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
beforeLineComment: {
|
|
||||||
type: "boolean",
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
afterLineComment: {
|
|
||||||
type: "boolean",
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
allowBlockStart: {
|
|
||||||
type: "boolean",
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
allowBlockEnd: {
|
|
||||||
type: "boolean",
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
allowClassStart: {
|
|
||||||
type: "boolean",
|
|
||||||
},
|
|
||||||
allowClassEnd: {
|
|
||||||
type: "boolean",
|
|
||||||
},
|
|
||||||
allowObjectStart: {
|
|
||||||
type: "boolean",
|
|
||||||
},
|
|
||||||
allowObjectEnd: {
|
|
||||||
type: "boolean",
|
|
||||||
},
|
|
||||||
allowArrayStart: {
|
|
||||||
type: "boolean",
|
|
||||||
},
|
|
||||||
allowArrayEnd: {
|
|
||||||
type: "boolean",
|
|
||||||
},
|
|
||||||
ignorePattern: {
|
|
||||||
type: "string",
|
|
||||||
},
|
|
||||||
applyDefaultIgnorePatterns: {
|
|
||||||
type: "boolean",
|
|
||||||
},
|
|
||||||
afterHashbangComment: {
|
|
||||||
type: "boolean",
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
additionalProperties: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
messages: {
|
|
||||||
after: "Expected line after comment.",
|
|
||||||
before: "Expected line before comment.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
const options = Object.assign({}, context.options[0]);
|
|
||||||
const ignorePattern = options.ignorePattern;
|
|
||||||
const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
|
|
||||||
const customIgnoreRegExp = new RegExp(ignorePattern, "u");
|
|
||||||
const applyDefaultIgnorePatterns =
|
|
||||||
options.applyDefaultIgnorePatterns !== false;
|
|
||||||
|
|
||||||
options.beforeBlockComment =
|
|
||||||
typeof options.beforeBlockComment !== "undefined"
|
|
||||||
? options.beforeBlockComment
|
|
||||||
: true;
|
|
||||||
|
|
||||||
const sourceCode = context.sourceCode;
|
|
||||||
|
|
||||||
const lines = sourceCode.lines,
|
|
||||||
numLines = lines.length + 1,
|
|
||||||
comments = sourceCode.getAllComments(),
|
|
||||||
commentLines = getCommentLineNums(comments),
|
|
||||||
emptyLines = getEmptyLineNums(lines),
|
|
||||||
commentAndEmptyLines = new Set(commentLines.concat(emptyLines));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are on lines starting with or ending with code
|
|
||||||
* @param {token} token The comment token to check.
|
|
||||||
* @returns {boolean} True if the comment is not alone.
|
|
||||||
*/
|
|
||||||
function codeAroundComment(token) {
|
|
||||||
let currentToken = token;
|
|
||||||
|
|
||||||
do {
|
|
||||||
currentToken = sourceCode.getTokenBefore(currentToken, {
|
|
||||||
includeComments: true,
|
|
||||||
});
|
|
||||||
} while (currentToken && astUtils.isCommentToken(currentToken));
|
|
||||||
|
|
||||||
if (
|
|
||||||
currentToken &&
|
|
||||||
astUtils.isTokenOnSameLine(currentToken, token)
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentToken = token;
|
|
||||||
do {
|
|
||||||
currentToken = sourceCode.getTokenAfter(currentToken, {
|
|
||||||
includeComments: true,
|
|
||||||
});
|
|
||||||
} while (currentToken && astUtils.isCommentToken(currentToken));
|
|
||||||
|
|
||||||
if (
|
|
||||||
currentToken &&
|
|
||||||
astUtils.isTokenOnSameLine(token, currentToken)
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are inside a node type or not.
|
|
||||||
* @param {ASTNode} parent The Comment parent node.
|
|
||||||
* @param {string} nodeType The parent type to check against.
|
|
||||||
* @returns {boolean} True if the comment is inside nodeType.
|
|
||||||
*/
|
|
||||||
function isParentNodeType(parent, nodeType) {
|
|
||||||
return (
|
|
||||||
parent.type === nodeType ||
|
|
||||||
(parent.body && parent.body.type === nodeType) ||
|
|
||||||
(parent.consequent && parent.consequent.type === nodeType)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the parent node that contains the given token.
|
|
||||||
* @param {token} token The token to check.
|
|
||||||
* @returns {ASTNode|null} The parent node that contains the given token.
|
|
||||||
*/
|
|
||||||
function getParentNodeOfToken(token) {
|
|
||||||
const node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For the purpose of this rule, the comment token is in a `StaticBlock` node only
|
|
||||||
* if it's inside the braces of that `StaticBlock` node.
|
|
||||||
*
|
|
||||||
* Example where this function returns `null`:
|
|
||||||
*
|
|
||||||
* static
|
|
||||||
* // comment
|
|
||||||
* {
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Example where this function returns `StaticBlock` node:
|
|
||||||
*
|
|
||||||
* static
|
|
||||||
* {
|
|
||||||
* // comment
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (node && node.type === "StaticBlock") {
|
|
||||||
const openingBrace = sourceCode.getFirstToken(node, {
|
|
||||||
skip: 1,
|
|
||||||
}); // skip the `static` token
|
|
||||||
|
|
||||||
return token.range[0] >= openingBrace.range[0] ? node : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the parent start or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @param {string} nodeType The parent type to check against.
|
|
||||||
* @returns {boolean} True if the comment is at parent start.
|
|
||||||
*/
|
|
||||||
function isCommentAtParentStart(token, nodeType) {
|
|
||||||
const parent = getParentNodeOfToken(token);
|
|
||||||
|
|
||||||
if (parent && isParentNodeType(parent, nodeType)) {
|
|
||||||
let parentStartNodeOrToken = parent;
|
|
||||||
|
|
||||||
if (parent.type === "StaticBlock") {
|
|
||||||
parentStartNodeOrToken = sourceCode.getFirstToken(parent, {
|
|
||||||
skip: 1,
|
|
||||||
}); // opening brace of the static block
|
|
||||||
} else if (parent.type === "SwitchStatement") {
|
|
||||||
parentStartNodeOrToken = sourceCode.getTokenAfter(
|
|
||||||
parent.discriminant,
|
|
||||||
{
|
|
||||||
filter: astUtils.isOpeningBraceToken,
|
|
||||||
},
|
|
||||||
); // opening brace of the switch statement
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
token.loc.start.line -
|
|
||||||
parentStartNodeOrToken.loc.start.line ===
|
|
||||||
1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the parent end or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @param {string} nodeType The parent type to check against.
|
|
||||||
* @returns {boolean} True if the comment is at parent end.
|
|
||||||
*/
|
|
||||||
function isCommentAtParentEnd(token, nodeType) {
|
|
||||||
const parent = getParentNodeOfToken(token);
|
|
||||||
|
|
||||||
return (
|
|
||||||
!!parent &&
|
|
||||||
isParentNodeType(parent, nodeType) &&
|
|
||||||
parent.loc.end.line - token.loc.end.line === 1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the block start or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @returns {boolean} True if the comment is at block start.
|
|
||||||
*/
|
|
||||||
function isCommentAtBlockStart(token) {
|
|
||||||
return (
|
|
||||||
isCommentAtParentStart(token, "ClassBody") ||
|
|
||||||
isCommentAtParentStart(token, "BlockStatement") ||
|
|
||||||
isCommentAtParentStart(token, "StaticBlock") ||
|
|
||||||
isCommentAtParentStart(token, "SwitchCase") ||
|
|
||||||
isCommentAtParentStart(token, "SwitchStatement")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the block end or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @returns {boolean} True if the comment is at block end.
|
|
||||||
*/
|
|
||||||
function isCommentAtBlockEnd(token) {
|
|
||||||
return (
|
|
||||||
isCommentAtParentEnd(token, "ClassBody") ||
|
|
||||||
isCommentAtParentEnd(token, "BlockStatement") ||
|
|
||||||
isCommentAtParentEnd(token, "StaticBlock") ||
|
|
||||||
isCommentAtParentEnd(token, "SwitchCase") ||
|
|
||||||
isCommentAtParentEnd(token, "SwitchStatement")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the class start or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @returns {boolean} True if the comment is at class start.
|
|
||||||
*/
|
|
||||||
function isCommentAtClassStart(token) {
|
|
||||||
return isCommentAtParentStart(token, "ClassBody");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the class end or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @returns {boolean} True if the comment is at class end.
|
|
||||||
*/
|
|
||||||
function isCommentAtClassEnd(token) {
|
|
||||||
return isCommentAtParentEnd(token, "ClassBody");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the object start or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @returns {boolean} True if the comment is at object start.
|
|
||||||
*/
|
|
||||||
function isCommentAtObjectStart(token) {
|
|
||||||
return (
|
|
||||||
isCommentAtParentStart(token, "ObjectExpression") ||
|
|
||||||
isCommentAtParentStart(token, "ObjectPattern")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the object end or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @returns {boolean} True if the comment is at object end.
|
|
||||||
*/
|
|
||||||
function isCommentAtObjectEnd(token) {
|
|
||||||
return (
|
|
||||||
isCommentAtParentEnd(token, "ObjectExpression") ||
|
|
||||||
isCommentAtParentEnd(token, "ObjectPattern")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the array start or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @returns {boolean} True if the comment is at array start.
|
|
||||||
*/
|
|
||||||
function isCommentAtArrayStart(token) {
|
|
||||||
return (
|
|
||||||
isCommentAtParentStart(token, "ArrayExpression") ||
|
|
||||||
isCommentAtParentStart(token, "ArrayPattern")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not comments are at the array end or not.
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @returns {boolean} True if the comment is at array end.
|
|
||||||
*/
|
|
||||||
function isCommentAtArrayEnd(token) {
|
|
||||||
return (
|
|
||||||
isCommentAtParentEnd(token, "ArrayExpression") ||
|
|
||||||
isCommentAtParentEnd(token, "ArrayPattern")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a comment token has lines around it (ignores inline comments)
|
|
||||||
* @param {token} token The Comment token.
|
|
||||||
* @param {Object} opts Options to determine the newline.
|
|
||||||
* @param {boolean} opts.after Should have a newline after this line.
|
|
||||||
* @param {boolean} opts.before Should have a newline before this line.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
function checkForEmptyLine(token, opts) {
|
|
||||||
if (
|
|
||||||
applyDefaultIgnorePatterns &&
|
|
||||||
defaultIgnoreRegExp.test(token.value)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ignorePattern && customIgnoreRegExp.test(token.value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let after = opts.after,
|
|
||||||
before = opts.before;
|
|
||||||
|
|
||||||
const prevLineNum = token.loc.start.line - 1,
|
|
||||||
nextLineNum = token.loc.end.line + 1,
|
|
||||||
commentIsNotAlone = codeAroundComment(token);
|
|
||||||
|
|
||||||
const blockStartAllowed =
|
|
||||||
options.allowBlockStart &&
|
|
||||||
isCommentAtBlockStart(token) &&
|
|
||||||
!(
|
|
||||||
options.allowClassStart === false &&
|
|
||||||
isCommentAtClassStart(token)
|
|
||||||
),
|
|
||||||
blockEndAllowed =
|
|
||||||
options.allowBlockEnd &&
|
|
||||||
isCommentAtBlockEnd(token) &&
|
|
||||||
!(
|
|
||||||
options.allowClassEnd === false &&
|
|
||||||
isCommentAtClassEnd(token)
|
|
||||||
),
|
|
||||||
classStartAllowed =
|
|
||||||
options.allowClassStart && isCommentAtClassStart(token),
|
|
||||||
classEndAllowed =
|
|
||||||
options.allowClassEnd && isCommentAtClassEnd(token),
|
|
||||||
objectStartAllowed =
|
|
||||||
options.allowObjectStart && isCommentAtObjectStart(token),
|
|
||||||
objectEndAllowed =
|
|
||||||
options.allowObjectEnd && isCommentAtObjectEnd(token),
|
|
||||||
arrayStartAllowed =
|
|
||||||
options.allowArrayStart && isCommentAtArrayStart(token),
|
|
||||||
arrayEndAllowed =
|
|
||||||
options.allowArrayEnd && isCommentAtArrayEnd(token);
|
|
||||||
|
|
||||||
const exceptionStartAllowed =
|
|
||||||
blockStartAllowed ||
|
|
||||||
classStartAllowed ||
|
|
||||||
objectStartAllowed ||
|
|
||||||
arrayStartAllowed;
|
|
||||||
const exceptionEndAllowed =
|
|
||||||
blockEndAllowed ||
|
|
||||||
classEndAllowed ||
|
|
||||||
objectEndAllowed ||
|
|
||||||
arrayEndAllowed;
|
|
||||||
|
|
||||||
// ignore top of the file and bottom of the file
|
|
||||||
if (prevLineNum < 1) {
|
|
||||||
before = false;
|
|
||||||
}
|
|
||||||
if (nextLineNum >= numLines) {
|
|
||||||
after = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we ignore all inline comments
|
|
||||||
if (commentIsNotAlone) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const previousTokenOrComment = sourceCode.getTokenBefore(token, {
|
|
||||||
includeComments: true,
|
|
||||||
});
|
|
||||||
const nextTokenOrComment = sourceCode.getTokenAfter(token, {
|
|
||||||
includeComments: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// check for newline before
|
|
||||||
if (
|
|
||||||
!exceptionStartAllowed &&
|
|
||||||
before &&
|
|
||||||
!commentAndEmptyLines.has(prevLineNum) &&
|
|
||||||
!(
|
|
||||||
astUtils.isCommentToken(previousTokenOrComment) &&
|
|
||||||
astUtils.isTokenOnSameLine(previousTokenOrComment, token)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
const lineStart = token.range[0] - token.loc.start.column;
|
|
||||||
const range = [lineStart, lineStart];
|
|
||||||
|
|
||||||
context.report({
|
|
||||||
node: token,
|
|
||||||
messageId: "before",
|
|
||||||
fix(fixer) {
|
|
||||||
return fixer.insertTextBeforeRange(range, "\n");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for newline after
|
|
||||||
if (
|
|
||||||
!exceptionEndAllowed &&
|
|
||||||
after &&
|
|
||||||
!commentAndEmptyLines.has(nextLineNum) &&
|
|
||||||
!(
|
|
||||||
astUtils.isCommentToken(nextTokenOrComment) &&
|
|
||||||
astUtils.isTokenOnSameLine(token, nextTokenOrComment)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
context.report({
|
|
||||||
node: token,
|
|
||||||
messageId: "after",
|
|
||||||
fix(fixer) {
|
|
||||||
return fixer.insertTextAfter(token, "\n");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Public
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return {
|
|
||||||
Program() {
|
|
||||||
comments.forEach(token => {
|
|
||||||
if (token.type === "Line") {
|
|
||||||
if (
|
|
||||||
options.beforeLineComment ||
|
|
||||||
options.afterLineComment
|
|
||||||
) {
|
|
||||||
checkForEmptyLine(token, {
|
|
||||||
after: options.afterLineComment,
|
|
||||||
before: options.beforeLineComment,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (token.type === "Block") {
|
|
||||||
if (
|
|
||||||
options.beforeBlockComment ||
|
|
||||||
options.afterBlockComment
|
|
||||||
) {
|
|
||||||
checkForEmptyLine(token, {
|
|
||||||
after: options.afterBlockComment,
|
|
||||||
before: options.beforeBlockComment,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (token.type === "Shebang") {
|
|
||||||
if (options.afterHashbangComment) {
|
|
||||||
checkForEmptyLine(token, {
|
|
||||||
after: options.afterHashbangComment,
|
|
||||||
before: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import { useMatch } from './useMatch'
|
|
||||||
import type {
|
|
||||||
StructuralSharingOption,
|
|
||||||
ValidateSelected,
|
|
||||||
} from './structuralSharing'
|
|
||||||
import type {
|
|
||||||
AnyRouter,
|
|
||||||
RegisteredRouter,
|
|
||||||
ResolveUseLoaderDeps,
|
|
||||||
StrictOrFrom,
|
|
||||||
UseLoaderDepsResult,
|
|
||||||
} from '@tanstack/router-core'
|
|
||||||
|
|
||||||
export interface UseLoaderDepsBaseOptions<
|
|
||||||
TRouter extends AnyRouter,
|
|
||||||
TFrom,
|
|
||||||
TSelected,
|
|
||||||
TStructuralSharing,
|
|
||||||
> {
|
|
||||||
select?: (
|
|
||||||
deps: ResolveUseLoaderDeps<TRouter, TFrom>,
|
|
||||||
) => ValidateSelected<TRouter, TSelected, TStructuralSharing>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UseLoaderDepsOptions<
|
|
||||||
TRouter extends AnyRouter,
|
|
||||||
TFrom extends string | undefined,
|
|
||||||
TSelected,
|
|
||||||
TStructuralSharing,
|
|
||||||
> = StrictOrFrom<TRouter, TFrom> &
|
|
||||||
UseLoaderDepsBaseOptions<TRouter, TFrom, TSelected, TStructuralSharing> &
|
|
||||||
StructuralSharingOption<TRouter, TSelected, TStructuralSharing>
|
|
||||||
|
|
||||||
export type UseLoaderDepsRoute<out TId> = <
|
|
||||||
TRouter extends AnyRouter = RegisteredRouter,
|
|
||||||
TSelected = unknown,
|
|
||||||
TStructuralSharing extends boolean = boolean,
|
|
||||||
>(
|
|
||||||
opts?: UseLoaderDepsBaseOptions<TRouter, TId, TSelected, TStructuralSharing> &
|
|
||||||
StructuralSharingOption<TRouter, TSelected, false>,
|
|
||||||
) => UseLoaderDepsResult<TRouter, TId, TSelected>
|
|
||||||
|
|
||||||
export function useLoaderDeps<
|
|
||||||
TRouter extends AnyRouter = RegisteredRouter,
|
|
||||||
const TFrom extends string | undefined = undefined,
|
|
||||||
TSelected = unknown,
|
|
||||||
TStructuralSharing extends boolean = boolean,
|
|
||||||
>(
|
|
||||||
opts: UseLoaderDepsOptions<TRouter, TFrom, TSelected, TStructuralSharing>,
|
|
||||||
): UseLoaderDepsResult<TRouter, TFrom, TSelected> {
|
|
||||||
const { select, ...rest } = opts
|
|
||||||
return useMatch({
|
|
||||||
...rest,
|
|
||||||
select: (s) => {
|
|
||||||
return select ? select(s.loaderDeps) : s.loaderDeps
|
|
||||||
},
|
|
||||||
}) as UseLoaderDepsResult<TRouter, TFrom, TSelected>
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/**
|
|
||||||
Regular expression for matching a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) line.
|
|
||||||
|
|
||||||
@example
|
|
||||||
```
|
|
||||||
import shebangRegex = require('shebang-regex');
|
|
||||||
|
|
||||||
const string = '#!/usr/bin/env node\nconsole.log("unicorns");';
|
|
||||||
|
|
||||||
shebangRegex.test(string);
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
shebangRegex.exec(string)[0];
|
|
||||||
//=> '#!/usr/bin/env node'
|
|
||||||
|
|
||||||
shebangRegex.exec(string)[1];
|
|
||||||
//=> '/usr/bin/env node'
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
declare const shebangRegex: RegExp;
|
|
||||||
|
|
||||||
export = shebangRegex;
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
|||||||
module.exports={C:{"109":0.00479,"115":0.22532,"118":0.00959,"128":0.05273,"132":0.00479,"134":0.00479,"135":1.86007,"136":7.85257,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 110 111 112 113 114 116 117 119 120 121 122 123 124 125 126 127 129 130 131 133 137 138 139 140 3.5 3.6"},D:{"39":0.00479,"40":0.00479,"41":0.00479,"42":0.00959,"43":0.00479,"44":0.00479,"45":0.03835,"46":0.00479,"47":0.00479,"48":0.00479,"49":0.00479,"51":0.00479,"52":0.00479,"53":0.00479,"54":0.00479,"55":0.00479,"56":0.00479,"57":0.00479,"58":0.00479,"59":0.00479,"60":0.00479,"79":0.00479,"88":0.00479,"94":0.00479,"99":0.01438,"101":0.00959,"102":0.00479,"103":0.08629,"104":0.00959,"105":0.16779,"108":0.02397,"109":0.16779,"111":0.00479,"112":0.01438,"116":0.12464,"117":0.01438,"119":0.01918,"120":0.02397,"122":0.00479,"123":0.00479,"124":0.02876,"125":0.02876,"126":0.60404,"127":0.08629,"128":0.06712,"129":0.01918,"130":0.06232,"131":0.28764,"132":0.69034,"133":6.90815,"134":8.8689,"135":0.00959,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 50 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 83 84 85 86 87 89 90 91 92 93 95 96 97 98 100 106 107 110 113 114 115 118 121 136 137 138"},F:{"95":0.02876,"116":0.12944,"117":0.27805,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"92":0.02397,"100":0.01438,"104":0.14382,"107":0.03356,"109":0.09588,"110":0.00959,"114":0.00479,"115":0.03835,"116":0.00959,"120":0.00479,"121":0.00479,"122":0.01438,"123":0.00479,"126":0.02397,"127":0.00959,"128":0.01918,"129":0.01918,"130":0.02876,"131":0.05273,"132":0.12464,"133":2.84764,"134":6.34726,_:"12 13 14 15 16 17 18 79 80 81 83 84 85 86 87 88 89 90 91 93 94 95 96 97 98 99 101 102 103 105 106 108 111 112 113 117 118 119 124 125"},E:{"13":0.0815,_:"0 4 5 6 7 8 9 10 11 12 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 12.1 15.2-15.3","13.1":0.02876,"14.1":0.10067,"15.1":0.00479,"15.4":0.00959,"15.5":0.00479,"15.6":0.62322,"16.0":0.18697,"16.1":0.04315,"16.2":0.00479,"16.3":0.02397,"16.4":0.07191,"16.5":0.11026,"16.6":0.73828,"17.0":0.00479,"17.1":0.64719,"17.2":0.04315,"17.3":0.25888,"17.4":0.10067,"17.5":0.12944,"17.6":0.51296,"18.0":0.06712,"18.1":0.52255,"18.2":0.10547,"18.3":3.55715,"18.4":0.00959},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00587,"5.0-5.1":0,"6.0-6.1":0.0176,"7.0-7.1":0.01174,"8.1-8.4":0,"9.0-9.2":0.0088,"9.3":0.04108,"10.0-10.2":0.00293,"10.3":0.06749,"11.0-11.2":0.31102,"11.3-11.4":0.02054,"12.0-12.1":0.01174,"12.2-12.5":0.29048,"13.0-13.1":0.00587,"13.2":0.0088,"13.3":0.01174,"13.4-13.7":0.04108,"14.0-14.4":0.1027,"14.5-14.8":0.12323,"15.0-15.1":0.06749,"15.2-15.3":0.06749,"15.4":0.08216,"15.5":0.09389,"15.6-15.8":1.15605,"16.0":0.16431,"16.1":0.33743,"16.2":0.17605,"16.3":0.30515,"16.4":0.06749,"16.5":0.12617,"16.6-16.7":1.37025,"17.0":0.08216,"17.1":0.14671,"17.2":0.1115,"17.3":0.15551,"17.4":0.31102,"17.5":0.69246,"17.6-17.7":2.00989,"18.0":0.56336,"18.1":1.84264,"18.2":0.82449,"18.3":17.23223,"18.4":0.25527},P:{"4":0.02168,"22":0.02168,"27":1.76697,_:"20 21 23 24 25 26 5.0-5.4 6.2-6.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 17.0 18.0","7.2-7.4":0.01084,"19.0":0.03252},I:{"0":0.03118,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00003},K:{"0":0.05728,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.05753,_:"6 7 8 9 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.61443},Q:{_:"14.9"},O:{"0":0.00521},H:{"0":0},L:{"0":20.54603}};
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
var concatMap = require('concat-map');
|
|
||||||
var balanced = require('balanced-match');
|
|
||||||
|
|
||||||
module.exports = expandTop;
|
|
||||||
|
|
||||||
var escSlash = '\0SLASH'+Math.random()+'\0';
|
|
||||||
var escOpen = '\0OPEN'+Math.random()+'\0';
|
|
||||||
var escClose = '\0CLOSE'+Math.random()+'\0';
|
|
||||||
var escComma = '\0COMMA'+Math.random()+'\0';
|
|
||||||
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
|
||||||
|
|
||||||
function numeric(str) {
|
|
||||||
return parseInt(str, 10) == str
|
|
||||||
? parseInt(str, 10)
|
|
||||||
: str.charCodeAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapeBraces(str) {
|
|
||||||
return str.split('\\\\').join(escSlash)
|
|
||||||
.split('\\{').join(escOpen)
|
|
||||||
.split('\\}').join(escClose)
|
|
||||||
.split('\\,').join(escComma)
|
|
||||||
.split('\\.').join(escPeriod);
|
|
||||||
}
|
|
||||||
|
|
||||||
function unescapeBraces(str) {
|
|
||||||
return str.split(escSlash).join('\\')
|
|
||||||
.split(escOpen).join('{')
|
|
||||||
.split(escClose).join('}')
|
|
||||||
.split(escComma).join(',')
|
|
||||||
.split(escPeriod).join('.');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Basically just str.split(","), but handling cases
|
|
||||||
// where we have nested braced sections, which should be
|
|
||||||
// treated as individual members, like {a,{b,c},d}
|
|
||||||
function parseCommaParts(str) {
|
|
||||||
if (!str)
|
|
||||||
return [''];
|
|
||||||
|
|
||||||
var parts = [];
|
|
||||||
var m = balanced('{', '}', str);
|
|
||||||
|
|
||||||
if (!m)
|
|
||||||
return str.split(',');
|
|
||||||
|
|
||||||
var pre = m.pre;
|
|
||||||
var body = m.body;
|
|
||||||
var post = m.post;
|
|
||||||
var p = pre.split(',');
|
|
||||||
|
|
||||||
p[p.length-1] += '{' + body + '}';
|
|
||||||
var postParts = parseCommaParts(post);
|
|
||||||
if (post.length) {
|
|
||||||
p[p.length-1] += postParts.shift();
|
|
||||||
p.push.apply(p, postParts);
|
|
||||||
}
|
|
||||||
|
|
||||||
parts.push.apply(parts, p);
|
|
||||||
|
|
||||||
return parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
function expandTop(str) {
|
|
||||||
if (!str)
|
|
||||||
return [];
|
|
||||||
|
|
||||||
// I don't know why Bash 4.3 does this, but it does.
|
|
||||||
// Anything starting with {} will have the first two bytes preserved
|
|
||||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
||||||
// but a{},b}c will be expanded to [a}c,abc].
|
|
||||||
// One could argue that this is a bug in Bash, but since the goal of
|
|
||||||
// this module is to match Bash's rules, we escape a leading {}
|
|
||||||
if (str.substr(0, 2) === '{}') {
|
|
||||||
str = '\\{\\}' + str.substr(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return expand(escapeBraces(str), true).map(unescapeBraces);
|
|
||||||
}
|
|
||||||
|
|
||||||
function identity(e) {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
function embrace(str) {
|
|
||||||
return '{' + str + '}';
|
|
||||||
}
|
|
||||||
function isPadded(el) {
|
|
||||||
return /^-?0\d/.test(el);
|
|
||||||
}
|
|
||||||
|
|
||||||
function lte(i, y) {
|
|
||||||
return i <= y;
|
|
||||||
}
|
|
||||||
function gte(i, y) {
|
|
||||||
return i >= y;
|
|
||||||
}
|
|
||||||
|
|
||||||
function expand(str, isTop) {
|
|
||||||
var expansions = [];
|
|
||||||
|
|
||||||
var m = balanced('{', '}', str);
|
|
||||||
if (!m || /\$$/.test(m.pre)) return [str];
|
|
||||||
|
|
||||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
||||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
||||||
var isSequence = isNumericSequence || isAlphaSequence;
|
|
||||||
var isOptions = m.body.indexOf(',') >= 0;
|
|
||||||
if (!isSequence && !isOptions) {
|
|
||||||
// {a},b}
|
|
||||||
if (m.post.match(/,.*\}/)) {
|
|
||||||
str = m.pre + '{' + m.body + escClose + m.post;
|
|
||||||
return expand(str);
|
|
||||||
}
|
|
||||||
return [str];
|
|
||||||
}
|
|
||||||
|
|
||||||
var n;
|
|
||||||
if (isSequence) {
|
|
||||||
n = m.body.split(/\.\./);
|
|
||||||
} else {
|
|
||||||
n = parseCommaParts(m.body);
|
|
||||||
if (n.length === 1) {
|
|
||||||
// x{{a,b}}y ==> x{a}y x{b}y
|
|
||||||
n = expand(n[0], false).map(embrace);
|
|
||||||
if (n.length === 1) {
|
|
||||||
var post = m.post.length
|
|
||||||
? expand(m.post, false)
|
|
||||||
: [''];
|
|
||||||
return post.map(function(p) {
|
|
||||||
return m.pre + n[0] + p;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// at this point, n is the parts, and we know it's not a comma set
|
|
||||||
// with a single entry.
|
|
||||||
|
|
||||||
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
||||||
var pre = m.pre;
|
|
||||||
var post = m.post.length
|
|
||||||
? expand(m.post, false)
|
|
||||||
: [''];
|
|
||||||
|
|
||||||
var N;
|
|
||||||
|
|
||||||
if (isSequence) {
|
|
||||||
var x = numeric(n[0]);
|
|
||||||
var y = numeric(n[1]);
|
|
||||||
var width = Math.max(n[0].length, n[1].length)
|
|
||||||
var incr = n.length == 3
|
|
||||||
? Math.abs(numeric(n[2]))
|
|
||||||
: 1;
|
|
||||||
var test = lte;
|
|
||||||
var reverse = y < x;
|
|
||||||
if (reverse) {
|
|
||||||
incr *= -1;
|
|
||||||
test = gte;
|
|
||||||
}
|
|
||||||
var pad = n.some(isPadded);
|
|
||||||
|
|
||||||
N = [];
|
|
||||||
|
|
||||||
for (var i = x; test(i, y); i += incr) {
|
|
||||||
var c;
|
|
||||||
if (isAlphaSequence) {
|
|
||||||
c = String.fromCharCode(i);
|
|
||||||
if (c === '\\')
|
|
||||||
c = '';
|
|
||||||
} else {
|
|
||||||
c = String(i);
|
|
||||||
if (pad) {
|
|
||||||
var need = width - c.length;
|
|
||||||
if (need > 0) {
|
|
||||||
var z = new Array(need + 1).join('0');
|
|
||||||
if (i < 0)
|
|
||||||
c = '-' + z + c.slice(1);
|
|
||||||
else
|
|
||||||
c = z + c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
N.push(c);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
N = concatMap(n, function(el) { return expand(el, false) });
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var j = 0; j < N.length; j++) {
|
|
||||||
for (var k = 0; k < post.length; k++) {
|
|
||||||
var expansion = pre + N[j] + post[k];
|
|
||||||
if (!isTop || isSequence || expansion)
|
|
||||||
expansions.push(expansion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return expansions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
import utils from './../utils.js';
|
|
||||||
|
|
||||||
class InterceptorManager {
|
|
||||||
constructor() {
|
|
||||||
this.handlers = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new interceptor to the stack
|
|
||||||
*
|
|
||||||
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
||||||
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
||||||
*
|
|
||||||
* @return {Number} An ID used to remove interceptor later
|
|
||||||
*/
|
|
||||||
use(fulfilled, rejected, options) {
|
|
||||||
this.handlers.push({
|
|
||||||
fulfilled,
|
|
||||||
rejected,
|
|
||||||
synchronous: options ? options.synchronous : false,
|
|
||||||
runWhen: options ? options.runWhen : null
|
|
||||||
});
|
|
||||||
return this.handlers.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove an interceptor from the stack
|
|
||||||
*
|
|
||||||
* @param {Number} id The ID that was returned by `use`
|
|
||||||
*
|
|
||||||
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
||||||
*/
|
|
||||||
eject(id) {
|
|
||||||
if (this.handlers[id]) {
|
|
||||||
this.handlers[id] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear all interceptors from the stack
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clear() {
|
|
||||||
if (this.handlers) {
|
|
||||||
this.handlers = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterate over all the registered interceptors
|
|
||||||
*
|
|
||||||
* This method is particularly useful for skipping over any
|
|
||||||
* interceptors that may have become `null` calling `eject`.
|
|
||||||
*
|
|
||||||
* @param {Function} fn The function to call for each interceptor
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
forEach(fn) {
|
|
||||||
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
||||||
if (h !== null) {
|
|
||||||
fn(h);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default InterceptorManager;
|
|
||||||
@@ -1,355 +0,0 @@
|
|||||||
# Form-Data [](https://www.npmjs.com/package/form-data) [](https://gitter.im/form-data/form-data)
|
|
||||||
|
|
||||||
A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
|
|
||||||
|
|
||||||
The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
|
|
||||||
|
|
||||||
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
|
||||||
|
|
||||||
[](https://travis-ci.org/form-data/form-data)
|
|
||||||
[](https://travis-ci.org/form-data/form-data)
|
|
||||||
[](https://travis-ci.org/form-data/form-data)
|
|
||||||
|
|
||||||
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
|
||||||
[](https://david-dm.org/form-data/form-data)
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```
|
|
||||||
npm install --save form-data
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
In this example we are constructing a form with 3 fields that contain a string,
|
|
||||||
a buffer and a file stream.
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var FormData = require('form-data');
|
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
var form = new FormData();
|
|
||||||
form.append('my_field', 'my value');
|
|
||||||
form.append('my_buffer', new Buffer(10));
|
|
||||||
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
|
||||||
```
|
|
||||||
|
|
||||||
Also you can use http-response stream:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var FormData = require('form-data');
|
|
||||||
var http = require('http');
|
|
||||||
|
|
||||||
var form = new FormData();
|
|
||||||
|
|
||||||
http.request('http://nodejs.org/images/logo.png', function (response) {
|
|
||||||
form.append('my_field', 'my value');
|
|
||||||
form.append('my_buffer', new Buffer(10));
|
|
||||||
form.append('my_logo', response);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Or @mikeal's [request](https://github.com/request/request) stream:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var FormData = require('form-data');
|
|
||||||
var request = require('request');
|
|
||||||
|
|
||||||
var form = new FormData();
|
|
||||||
|
|
||||||
form.append('my_field', 'my value');
|
|
||||||
form.append('my_buffer', new Buffer(10));
|
|
||||||
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
|
|
||||||
```
|
|
||||||
|
|
||||||
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
form.submit('http://example.org/', function (err, res) {
|
|
||||||
// res – response object (http.IncomingMessage) //
|
|
||||||
res.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
|
|
||||||
|
|
||||||
### Custom options
|
|
||||||
|
|
||||||
You can provide custom options, such as `maxDataSize`:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var FormData = require('form-data');
|
|
||||||
|
|
||||||
var form = new FormData({ maxDataSize: 20971520 });
|
|
||||||
form.append('my_field', 'my value');
|
|
||||||
form.append('my_buffer', /* something big */);
|
|
||||||
```
|
|
||||||
|
|
||||||
List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15)
|
|
||||||
|
|
||||||
### Alternative submission methods
|
|
||||||
|
|
||||||
You can use node's http client interface:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var http = require('http');
|
|
||||||
|
|
||||||
var request = http.request({
|
|
||||||
method: 'post',
|
|
||||||
host: 'example.org',
|
|
||||||
path: '/upload',
|
|
||||||
headers: form.getHeaders()
|
|
||||||
});
|
|
||||||
|
|
||||||
form.pipe(request);
|
|
||||||
|
|
||||||
request.on('response', function (res) {
|
|
||||||
console.log(res.statusCode);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Or if you would prefer the `'Content-Length'` header to be set for you:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
form.submit('example.org/upload', function (err, res) {
|
|
||||||
console.log(res.statusCode);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
To use custom headers and pre-known length in parts:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var CRLF = '\r\n';
|
|
||||||
var form = new FormData();
|
|
||||||
|
|
||||||
var options = {
|
|
||||||
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
|
|
||||||
knownLength: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
form.append('my_buffer', buffer, options);
|
|
||||||
|
|
||||||
form.submit('http://example.com/', function (err, res) {
|
|
||||||
if (err) throw err;
|
|
||||||
console.log('Done');
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
someModule.stream(function (err, stdout, stderr) {
|
|
||||||
if (err) throw err;
|
|
||||||
|
|
||||||
var form = new FormData();
|
|
||||||
|
|
||||||
form.append('file', stdout, {
|
|
||||||
filename: 'unicycle.jpg', // ... or:
|
|
||||||
filepath: 'photos/toys/unicycle.jpg',
|
|
||||||
contentType: 'image/jpeg',
|
|
||||||
knownLength: 19806
|
|
||||||
});
|
|
||||||
|
|
||||||
form.submit('http://example.com/', function (err, res) {
|
|
||||||
if (err) throw err;
|
|
||||||
console.log('Done');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory).
|
|
||||||
|
|
||||||
For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
form.submit({
|
|
||||||
host: 'example.com',
|
|
||||||
path: '/probably.php?extra=params',
|
|
||||||
auth: 'username:password'
|
|
||||||
}, function (err, res) {
|
|
||||||
console.log(res.statusCode);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`:
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
form.submit({
|
|
||||||
host: 'example.com',
|
|
||||||
path: '/surelynot.php',
|
|
||||||
headers: { 'x-test-header': 'test-header-value' }
|
|
||||||
}, function (err, res) {
|
|
||||||
console.log(res.statusCode);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### Methods
|
|
||||||
|
|
||||||
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
|
|
||||||
- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
|
|
||||||
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
|
|
||||||
- [_Void_ setBoundary()](https://github.com/form-data/form-data#void-setboundary)
|
|
||||||
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
|
|
||||||
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
|
|
||||||
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
|
|
||||||
- [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength)
|
|
||||||
- [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-)
|
|
||||||
- [_String_ toString()](https://github.com/form-data/form-data#string-tostring)
|
|
||||||
|
|
||||||
#### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
|
|
||||||
Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user.
|
|
||||||
```javascript
|
|
||||||
var form = new FormData();
|
|
||||||
form.append('my_string', 'my value');
|
|
||||||
form.append('my_integer', 1);
|
|
||||||
form.append('my_boolean', true);
|
|
||||||
form.append('my_buffer', new Buffer(10));
|
|
||||||
form.append('my_array_as_json', JSON.stringify(['bird', 'cute']));
|
|
||||||
```
|
|
||||||
|
|
||||||
You may provide a string for options, or an object.
|
|
||||||
```javascript
|
|
||||||
// Set filename by providing a string for options
|
|
||||||
form.append('my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg');
|
|
||||||
|
|
||||||
// provide an object.
|
|
||||||
form.append('my_file', fs.createReadStream('/foo/bar.jpg'), { filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806 });
|
|
||||||
```
|
|
||||||
|
|
||||||
#### _Headers_ getHeaders( [**Headers** _userHeaders_] )
|
|
||||||
This method adds the correct `content-type` header to the provided array of `userHeaders`.
|
|
||||||
|
|
||||||
#### _String_ getBoundary()
|
|
||||||
Return the boundary of the formData. By default, the boundary consists of 26 `-` followed by 24 numbers
|
|
||||||
for example:
|
|
||||||
```javascript
|
|
||||||
--------------------------515890814546601021194782
|
|
||||||
```
|
|
||||||
|
|
||||||
#### _Void_ setBoundary(String _boundary_)
|
|
||||||
Set the boundary string, overriding the default behavior described above.
|
|
||||||
|
|
||||||
_Note: The boundary must be unique and may not appear in the data._
|
|
||||||
|
|
||||||
#### _Buffer_ getBuffer()
|
|
||||||
Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.
|
|
||||||
```javascript
|
|
||||||
var form = new FormData();
|
|
||||||
form.append('my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]));
|
|
||||||
form.append('my_file', fs.readFileSync('/foo/bar.jpg'));
|
|
||||||
|
|
||||||
axios.post('https://example.com/path/to/api', form.getBuffer(), form.getHeaders());
|
|
||||||
```
|
|
||||||
**Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error.
|
|
||||||
|
|
||||||
#### _Integer_ getLengthSync()
|
|
||||||
Same as `getLength` but synchronous.
|
|
||||||
|
|
||||||
_Note: getLengthSync __doesn't__ calculate streams length._
|
|
||||||
|
|
||||||
#### _Integer_ getLength(**function** _callback_ )
|
|
||||||
Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
|
|
||||||
```javascript
|
|
||||||
this.getLength(function (err, length) {
|
|
||||||
if (err) {
|
|
||||||
this._error(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add content length
|
|
||||||
request.setHeader('Content-Length', length);
|
|
||||||
|
|
||||||
...
|
|
||||||
}.bind(this));
|
|
||||||
```
|
|
||||||
|
|
||||||
#### _Boolean_ hasKnownLength()
|
|
||||||
Checks if the length of added values is known.
|
|
||||||
|
|
||||||
#### _Request_ submit(_params_, **function** _callback_ )
|
|
||||||
Submit the form to a web application.
|
|
||||||
```javascript
|
|
||||||
var form = new FormData();
|
|
||||||
form.append('my_string', 'Hello World');
|
|
||||||
|
|
||||||
form.submit('http://example.com/', function (err, res) {
|
|
||||||
// res – response object (http.IncomingMessage) //
|
|
||||||
res.resume();
|
|
||||||
} );
|
|
||||||
```
|
|
||||||
|
|
||||||
#### _String_ toString()
|
|
||||||
Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead.
|
|
||||||
|
|
||||||
### Integration with other libraries
|
|
||||||
|
|
||||||
#### Request
|
|
||||||
|
|
||||||
Form submission using [request](https://github.com/request/request):
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var formData = {
|
|
||||||
my_field: 'my_value',
|
|
||||||
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
|
||||||
};
|
|
||||||
|
|
||||||
request.post({url:'http://service.com/upload', formData: formData}, function (err, httpResponse, body) {
|
|
||||||
if (err) {
|
|
||||||
return console.error('upload failed:', err);
|
|
||||||
}
|
|
||||||
console.log('Upload successful! Server responded with:', body);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads).
|
|
||||||
|
|
||||||
#### node-fetch
|
|
||||||
|
|
||||||
You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch):
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var form = new FormData();
|
|
||||||
|
|
||||||
form.append('a', 1);
|
|
||||||
|
|
||||||
fetch('http://example.com', { method: 'POST', body: form })
|
|
||||||
.then(function (res) {
|
|
||||||
return res.json();
|
|
||||||
}).then(function (json) {
|
|
||||||
console.log(json);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
#### axios
|
|
||||||
|
|
||||||
In Node.js you can post a file using [axios](https://github.com/axios/axios):
|
|
||||||
```javascript
|
|
||||||
const form = new FormData();
|
|
||||||
const stream = fs.createReadStream(PATH_TO_FILE);
|
|
||||||
|
|
||||||
form.append('image', stream);
|
|
||||||
|
|
||||||
// In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders`
|
|
||||||
const formHeaders = form.getHeaders();
|
|
||||||
|
|
||||||
axios.post('http://example.com', form, {
|
|
||||||
headers: {
|
|
||||||
...formHeaders,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(response => response)
|
|
||||||
.catch(error => error)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
|
||||||
- ```getLength(cb)``` will send an error as first parameter of callback if stream length cannot be calculated (e.g. send in custom streams w/o using ```knownLength```).
|
|
||||||
- ```submit``` will not add `content-length` if form length is unknown or not calculable.
|
|
||||||
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
|
|
||||||
- Starting version `3.x` FormData has dropped support for `node@4.x`.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Form-Data is released under the [MIT](License) license.
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user