feat: init
This commit is contained in:
21
node_modules/strip-literal/LICENSE
generated
vendored
Normal file
21
node_modules/strip-literal/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Anthony Fu <https://github.com/antfu>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
29
node_modules/strip-literal/README.md
generated
vendored
Normal file
29
node_modules/strip-literal/README.md
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# strip-literal
|
||||
|
||||
[](https://www.npmjs.com/package/strip-literal)
|
||||
|
||||
Strip comments and string literals from JavaScript code. Powered by [`js-tokens`](https://github.com/lydell/js-tokens).
|
||||
|
||||
## Usage
|
||||
|
||||
<!-- eslint-disable no-template-curly-in-string -->
|
||||
|
||||
```ts
|
||||
import { stripLiteral } from 'strip-literal'
|
||||
|
||||
stripLiteral('const foo = `//foo ${bar}`') // 'const foo = ` ${bar}`'
|
||||
```
|
||||
|
||||
Comments, string literals will be replaced by spaces with the same length to keep the source map untouched.
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2022 [Anthony Fu](https://github.com/antfu)
|
||||
88
node_modules/strip-literal/dist/index.cjs
generated
vendored
Normal file
88
node_modules/strip-literal/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
'use strict';
|
||||
|
||||
const jsTokens = require('js-tokens');
|
||||
|
||||
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
||||
|
||||
const jsTokens__default = /*#__PURE__*/_interopDefaultCompat(jsTokens);
|
||||
|
||||
const FILL_COMMENT = " ";
|
||||
function stripLiteralFromToken(token, fillChar, filter) {
|
||||
if (token.type === "SingleLineComment") {
|
||||
return FILL_COMMENT.repeat(token.value.length);
|
||||
}
|
||||
if (token.type === "MultiLineComment") {
|
||||
return token.value.replace(/[^\n]/g, FILL_COMMENT);
|
||||
}
|
||||
if (token.type === "StringLiteral") {
|
||||
if (!token.closed) {
|
||||
return token.value;
|
||||
}
|
||||
const body = token.value.slice(1, -1);
|
||||
if (filter(body)) {
|
||||
return token.value[0] + fillChar.repeat(body.length) + token.value[token.value.length - 1];
|
||||
}
|
||||
}
|
||||
if (token.type === "NoSubstitutionTemplate") {
|
||||
const body = token.value.slice(1, -1);
|
||||
if (filter(body)) {
|
||||
return `\`${body.replace(/[^\n]/g, fillChar)}\``;
|
||||
}
|
||||
}
|
||||
if (token.type === "RegularExpressionLiteral") {
|
||||
const body = token.value;
|
||||
if (filter(body)) {
|
||||
return body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${fillChar.repeat($1.length)}/${$2}`);
|
||||
}
|
||||
}
|
||||
if (token.type === "TemplateHead") {
|
||||
const body = token.value.slice(1, -2);
|
||||
if (filter(body)) {
|
||||
return `\`${body.replace(/[^\n]/g, fillChar)}\${`;
|
||||
}
|
||||
}
|
||||
if (token.type === "TemplateTail") {
|
||||
const body = token.value.slice(0, -2);
|
||||
if (filter(body)) {
|
||||
return `}${body.replace(/[^\n]/g, fillChar)}\``;
|
||||
}
|
||||
}
|
||||
if (token.type === "TemplateMiddle") {
|
||||
const body = token.value.slice(1, -2);
|
||||
if (filter(body)) {
|
||||
return `}${body.replace(/[^\n]/g, fillChar)}\${`;
|
||||
}
|
||||
}
|
||||
return token.value;
|
||||
}
|
||||
function optionsWithDefaults(options) {
|
||||
return {
|
||||
fillChar: options?.fillChar ?? " ",
|
||||
filter: options?.filter ?? (() => true)
|
||||
};
|
||||
}
|
||||
function stripLiteral(code, options) {
|
||||
let result = "";
|
||||
const _options = optionsWithDefaults(options);
|
||||
for (const token of jsTokens__default(code, { jsx: false })) {
|
||||
result += stripLiteralFromToken(token, _options.fillChar, _options.filter);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function stripLiteralDetailed(code, options) {
|
||||
let result = "";
|
||||
const tokens = [];
|
||||
const _options = optionsWithDefaults(options);
|
||||
for (const token of jsTokens__default(code, { jsx: false })) {
|
||||
tokens.push(token);
|
||||
result += stripLiteralFromToken(token, _options.fillChar, _options.filter);
|
||||
}
|
||||
return {
|
||||
result,
|
||||
tokens
|
||||
};
|
||||
}
|
||||
|
||||
exports.stripLiteral = stripLiteral;
|
||||
exports.stripLiteralDetailed = stripLiteralDetailed;
|
||||
exports.stripLiteralJsTokens = stripLiteralDetailed;
|
||||
30
node_modules/strip-literal/dist/index.d.cts
generated
vendored
Normal file
30
node_modules/strip-literal/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Token } from 'js-tokens';
|
||||
|
||||
interface StripLiteralOptions {
|
||||
/**
|
||||
* Will be called for each string literal. Return false to skip stripping.
|
||||
*/
|
||||
filter?: (s: string) => boolean;
|
||||
/**
|
||||
* Fill the stripped literal with this character.
|
||||
* It must be a single character.
|
||||
*
|
||||
* @default ' '
|
||||
*/
|
||||
fillChar?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip literal from code.
|
||||
*/
|
||||
declare function stripLiteral(code: string, options?: StripLiteralOptions): string;
|
||||
/**
|
||||
* Strip literal from code, return more detailed information.
|
||||
*/
|
||||
declare function stripLiteralDetailed(code: string, options?: StripLiteralOptions): {
|
||||
result: string;
|
||||
tokens: Token[];
|
||||
};
|
||||
|
||||
export { stripLiteral, stripLiteralDetailed, stripLiteralDetailed as stripLiteralJsTokens };
|
||||
export type { StripLiteralOptions };
|
||||
30
node_modules/strip-literal/dist/index.d.mts
generated
vendored
Normal file
30
node_modules/strip-literal/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Token } from 'js-tokens';
|
||||
|
||||
interface StripLiteralOptions {
|
||||
/**
|
||||
* Will be called for each string literal. Return false to skip stripping.
|
||||
*/
|
||||
filter?: (s: string) => boolean;
|
||||
/**
|
||||
* Fill the stripped literal with this character.
|
||||
* It must be a single character.
|
||||
*
|
||||
* @default ' '
|
||||
*/
|
||||
fillChar?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip literal from code.
|
||||
*/
|
||||
declare function stripLiteral(code: string, options?: StripLiteralOptions): string;
|
||||
/**
|
||||
* Strip literal from code, return more detailed information.
|
||||
*/
|
||||
declare function stripLiteralDetailed(code: string, options?: StripLiteralOptions): {
|
||||
result: string;
|
||||
tokens: Token[];
|
||||
};
|
||||
|
||||
export { stripLiteral, stripLiteralDetailed, stripLiteralDetailed as stripLiteralJsTokens };
|
||||
export type { StripLiteralOptions };
|
||||
30
node_modules/strip-literal/dist/index.d.ts
generated
vendored
Normal file
30
node_modules/strip-literal/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Token } from 'js-tokens';
|
||||
|
||||
interface StripLiteralOptions {
|
||||
/**
|
||||
* Will be called for each string literal. Return false to skip stripping.
|
||||
*/
|
||||
filter?: (s: string) => boolean;
|
||||
/**
|
||||
* Fill the stripped literal with this character.
|
||||
* It must be a single character.
|
||||
*
|
||||
* @default ' '
|
||||
*/
|
||||
fillChar?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip literal from code.
|
||||
*/
|
||||
declare function stripLiteral(code: string, options?: StripLiteralOptions): string;
|
||||
/**
|
||||
* Strip literal from code, return more detailed information.
|
||||
*/
|
||||
declare function stripLiteralDetailed(code: string, options?: StripLiteralOptions): {
|
||||
result: string;
|
||||
tokens: Token[];
|
||||
};
|
||||
|
||||
export { stripLiteral, stripLiteralDetailed, stripLiteralDetailed as stripLiteralJsTokens };
|
||||
export type { StripLiteralOptions };
|
||||
80
node_modules/strip-literal/dist/index.mjs
generated
vendored
Normal file
80
node_modules/strip-literal/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import jsTokens from 'js-tokens';
|
||||
|
||||
const FILL_COMMENT = " ";
|
||||
function stripLiteralFromToken(token, fillChar, filter) {
|
||||
if (token.type === "SingleLineComment") {
|
||||
return FILL_COMMENT.repeat(token.value.length);
|
||||
}
|
||||
if (token.type === "MultiLineComment") {
|
||||
return token.value.replace(/[^\n]/g, FILL_COMMENT);
|
||||
}
|
||||
if (token.type === "StringLiteral") {
|
||||
if (!token.closed) {
|
||||
return token.value;
|
||||
}
|
||||
const body = token.value.slice(1, -1);
|
||||
if (filter(body)) {
|
||||
return token.value[0] + fillChar.repeat(body.length) + token.value[token.value.length - 1];
|
||||
}
|
||||
}
|
||||
if (token.type === "NoSubstitutionTemplate") {
|
||||
const body = token.value.slice(1, -1);
|
||||
if (filter(body)) {
|
||||
return `\`${body.replace(/[^\n]/g, fillChar)}\``;
|
||||
}
|
||||
}
|
||||
if (token.type === "RegularExpressionLiteral") {
|
||||
const body = token.value;
|
||||
if (filter(body)) {
|
||||
return body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${fillChar.repeat($1.length)}/${$2}`);
|
||||
}
|
||||
}
|
||||
if (token.type === "TemplateHead") {
|
||||
const body = token.value.slice(1, -2);
|
||||
if (filter(body)) {
|
||||
return `\`${body.replace(/[^\n]/g, fillChar)}\${`;
|
||||
}
|
||||
}
|
||||
if (token.type === "TemplateTail") {
|
||||
const body = token.value.slice(0, -2);
|
||||
if (filter(body)) {
|
||||
return `}${body.replace(/[^\n]/g, fillChar)}\``;
|
||||
}
|
||||
}
|
||||
if (token.type === "TemplateMiddle") {
|
||||
const body = token.value.slice(1, -2);
|
||||
if (filter(body)) {
|
||||
return `}${body.replace(/[^\n]/g, fillChar)}\${`;
|
||||
}
|
||||
}
|
||||
return token.value;
|
||||
}
|
||||
function optionsWithDefaults(options) {
|
||||
return {
|
||||
fillChar: options?.fillChar ?? " ",
|
||||
filter: options?.filter ?? (() => true)
|
||||
};
|
||||
}
|
||||
function stripLiteral(code, options) {
|
||||
let result = "";
|
||||
const _options = optionsWithDefaults(options);
|
||||
for (const token of jsTokens(code, { jsx: false })) {
|
||||
result += stripLiteralFromToken(token, _options.fillChar, _options.filter);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function stripLiteralDetailed(code, options) {
|
||||
let result = "";
|
||||
const tokens = [];
|
||||
const _options = optionsWithDefaults(options);
|
||||
for (const token of jsTokens(code, { jsx: false })) {
|
||||
tokens.push(token);
|
||||
result += stripLiteralFromToken(token, _options.fillChar, _options.filter);
|
||||
}
|
||||
return {
|
||||
result,
|
||||
tokens
|
||||
};
|
||||
}
|
||||
|
||||
export { stripLiteral, stripLiteralDetailed, stripLiteralDetailed as stripLiteralJsTokens };
|
||||
21
node_modules/strip-literal/node_modules/js-tokens/LICENSE
generated
vendored
Normal file
21
node_modules/strip-literal/node_modules/js-tokens/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Simon Lydell
|
||||
|
||||
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.
|
||||
14
node_modules/strip-literal/node_modules/js-tokens/README.md
generated
vendored
Normal file
14
node_modules/strip-literal/node_modules/js-tokens/README.md
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# js-tokens
|
||||
|
||||
The tiny, regex powered, lenient, _almost_ spec-compliant JavaScript tokenizer that never fails.
|
||||
|
||||
```js
|
||||
const jsTokens = require("js-tokens");
|
||||
|
||||
const jsString = 'JSON.stringify({k:3.14**2}, null /*replacer*/, "\\t")';
|
||||
|
||||
Array.from(jsTokens(jsString), (token) => token.value).join("|");
|
||||
// JSON|.|stringify|(|{|k|:|3.14|**|2|}|,| |null| |/*replacer*/|,| |"\t"|)
|
||||
```
|
||||
|
||||
**[➡️ Full readme](https://github.com/lydell/js-tokens/)**
|
||||
37
node_modules/strip-literal/node_modules/js-tokens/index.d.ts
generated
vendored
Normal file
37
node_modules/strip-literal/node_modules/js-tokens/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
export declare type Token =
|
||||
| { type: "StringLiteral"; value: string; closed: boolean }
|
||||
| { type: "NoSubstitutionTemplate"; value: string; closed: boolean }
|
||||
| { type: "TemplateHead"; value: string }
|
||||
| { type: "TemplateMiddle"; value: string }
|
||||
| { type: "TemplateTail"; value: string; closed: boolean }
|
||||
| { type: "RegularExpressionLiteral"; value: string; closed: boolean }
|
||||
| { type: "MultiLineComment"; value: string; closed: boolean }
|
||||
| { type: "SingleLineComment"; value: string }
|
||||
| { type: "HashbangComment"; value: string }
|
||||
| { type: "IdentifierName"; value: string }
|
||||
| { type: "PrivateIdentifier"; value: string }
|
||||
| { type: "NumericLiteral"; value: string }
|
||||
| { type: "Punctuator"; value: string }
|
||||
| { type: "WhiteSpace"; value: string }
|
||||
| { type: "LineTerminatorSequence"; value: string }
|
||||
| { type: "Invalid"; value: string };
|
||||
|
||||
export declare type JSXToken =
|
||||
| { type: "JSXString"; value: string; closed: boolean }
|
||||
| { type: "JSXText"; value: string }
|
||||
| { type: "JSXIdentifier"; value: string }
|
||||
| { type: "JSXPunctuator"; value: string }
|
||||
| { type: "JSXInvalid"; value: string };
|
||||
|
||||
declare function jsTokens(
|
||||
input: string,
|
||||
options: { jsx: true },
|
||||
): Iterable<Token | JSXToken>;
|
||||
|
||||
declare function jsTokens(
|
||||
input: string,
|
||||
options?: { jsx?: boolean },
|
||||
): Iterable<Token>;
|
||||
|
||||
// @ts-expect-error TypeScript complains about _both_ exporting types _and_ using `export =` but it seems to work fine in practice.
|
||||
export = jsTokens;
|
||||
396
node_modules/strip-literal/node_modules/js-tokens/index.js
generated
vendored
Normal file
396
node_modules/strip-literal/node_modules/js-tokens/index.js
generated
vendored
Normal file
@@ -0,0 +1,396 @@
|
||||
// Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
|
||||
// License: MIT.
|
||||
var HashbangComment, Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace, jsTokens;
|
||||
RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]?|[^\/[\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
|
||||
Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
|
||||
Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
|
||||
StringLiteral = /(['"])(?:[^'"\\\n\r]+|(?!\1)['"]|\\(?:\r\n|[^]))*(\1)?/y;
|
||||
NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
|
||||
Template = /[`}](?:[^`\\$]+|\\[^]|\$(?!\{))*(`|\$\{)?/y;
|
||||
WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
|
||||
LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
|
||||
MultiLineComment = /\/\*(?:[^*]+|\*(?!\/))*(\*\/)?/y;
|
||||
SingleLineComment = /\/\/.*/y;
|
||||
HashbangComment = /^#!.*/;
|
||||
JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
|
||||
JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
|
||||
JSXString = /(['"])(?:[^'"]+|(?!\1)['"])*(\1)?/y;
|
||||
JSXText = /[^<>{}]+/y;
|
||||
TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
|
||||
TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
|
||||
KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
|
||||
KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
|
||||
Newline = RegExp(LineTerminatorSequence.source);
|
||||
module.exports = jsTokens = function*(input, {jsx = false} = {}) {
|
||||
var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
|
||||
({length} = input);
|
||||
lastIndex = 0;
|
||||
lastSignificantToken = "";
|
||||
stack = [
|
||||
{tag: "JS"}
|
||||
];
|
||||
braces = [];
|
||||
parenNesting = 0;
|
||||
postfixIncDec = false;
|
||||
if (match = HashbangComment.exec(input)) {
|
||||
yield ({
|
||||
type: "HashbangComment",
|
||||
value: match[0]
|
||||
});
|
||||
lastIndex = match[0].length;
|
||||
}
|
||||
while (lastIndex < length) {
|
||||
mode = stack[stack.length - 1];
|
||||
switch (mode.tag) {
|
||||
case "JS":
|
||||
case "JSNonExpressionParen":
|
||||
case "InterpolationInTemplate":
|
||||
case "InterpolationInJSX":
|
||||
if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
||||
RegularExpressionLiteral.lastIndex = lastIndex;
|
||||
if (match = RegularExpressionLiteral.exec(input)) {
|
||||
lastIndex = RegularExpressionLiteral.lastIndex;
|
||||
lastSignificantToken = match[0];
|
||||
postfixIncDec = true;
|
||||
yield ({
|
||||
type: "RegularExpressionLiteral",
|
||||
value: match[0],
|
||||
closed: match[1] !== void 0 && match[1] !== "\\"
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Punctuator.lastIndex = lastIndex;
|
||||
if (match = Punctuator.exec(input)) {
|
||||
punctuator = match[0];
|
||||
nextLastIndex = Punctuator.lastIndex;
|
||||
nextLastSignificantToken = punctuator;
|
||||
switch (punctuator) {
|
||||
case "(":
|
||||
if (lastSignificantToken === "?NonExpressionParenKeyword") {
|
||||
stack.push({
|
||||
tag: "JSNonExpressionParen",
|
||||
nesting: parenNesting
|
||||
});
|
||||
}
|
||||
parenNesting++;
|
||||
postfixIncDec = false;
|
||||
break;
|
||||
case ")":
|
||||
parenNesting--;
|
||||
postfixIncDec = true;
|
||||
if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
|
||||
stack.pop();
|
||||
nextLastSignificantToken = "?NonExpressionParenEnd";
|
||||
postfixIncDec = false;
|
||||
}
|
||||
break;
|
||||
case "{":
|
||||
Punctuator.lastIndex = 0;
|
||||
isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
|
||||
braces.push(isExpression);
|
||||
postfixIncDec = false;
|
||||
break;
|
||||
case "}":
|
||||
switch (mode.tag) {
|
||||
case "InterpolationInTemplate":
|
||||
if (braces.length === mode.nesting) {
|
||||
Template.lastIndex = lastIndex;
|
||||
match = Template.exec(input);
|
||||
lastIndex = Template.lastIndex;
|
||||
lastSignificantToken = match[0];
|
||||
if (match[1] === "${") {
|
||||
lastSignificantToken = "?InterpolationInTemplate";
|
||||
postfixIncDec = false;
|
||||
yield ({
|
||||
type: "TemplateMiddle",
|
||||
value: match[0]
|
||||
});
|
||||
} else {
|
||||
stack.pop();
|
||||
postfixIncDec = true;
|
||||
yield ({
|
||||
type: "TemplateTail",
|
||||
value: match[0],
|
||||
closed: match[1] === "`"
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case "InterpolationInJSX":
|
||||
if (braces.length === mode.nesting) {
|
||||
stack.pop();
|
||||
lastIndex += 1;
|
||||
lastSignificantToken = "}";
|
||||
yield ({
|
||||
type: "JSXPunctuator",
|
||||
value: "}"
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
postfixIncDec = braces.pop();
|
||||
nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
|
||||
break;
|
||||
case "]":
|
||||
postfixIncDec = true;
|
||||
break;
|
||||
case "++":
|
||||
case "--":
|
||||
nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
|
||||
break;
|
||||
case "<":
|
||||
if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
||||
stack.push({tag: "JSXTag"});
|
||||
lastIndex += 1;
|
||||
lastSignificantToken = "<";
|
||||
yield ({
|
||||
type: "JSXPunctuator",
|
||||
value: punctuator
|
||||
});
|
||||
continue;
|
||||
}
|
||||
postfixIncDec = false;
|
||||
break;
|
||||
default:
|
||||
postfixIncDec = false;
|
||||
}
|
||||
lastIndex = nextLastIndex;
|
||||
lastSignificantToken = nextLastSignificantToken;
|
||||
yield ({
|
||||
type: "Punctuator",
|
||||
value: punctuator
|
||||
});
|
||||
continue;
|
||||
}
|
||||
Identifier.lastIndex = lastIndex;
|
||||
if (match = Identifier.exec(input)) {
|
||||
lastIndex = Identifier.lastIndex;
|
||||
nextLastSignificantToken = match[0];
|
||||
switch (match[0]) {
|
||||
case "for":
|
||||
case "if":
|
||||
case "while":
|
||||
case "with":
|
||||
if (lastSignificantToken !== "." && lastSignificantToken !== "?.") {
|
||||
nextLastSignificantToken = "?NonExpressionParenKeyword";
|
||||
}
|
||||
}
|
||||
lastSignificantToken = nextLastSignificantToken;
|
||||
postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
|
||||
yield ({
|
||||
type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
|
||||
value: match[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
StringLiteral.lastIndex = lastIndex;
|
||||
if (match = StringLiteral.exec(input)) {
|
||||
lastIndex = StringLiteral.lastIndex;
|
||||
lastSignificantToken = match[0];
|
||||
postfixIncDec = true;
|
||||
yield ({
|
||||
type: "StringLiteral",
|
||||
value: match[0],
|
||||
closed: match[2] !== void 0
|
||||
});
|
||||
continue;
|
||||
}
|
||||
NumericLiteral.lastIndex = lastIndex;
|
||||
if (match = NumericLiteral.exec(input)) {
|
||||
lastIndex = NumericLiteral.lastIndex;
|
||||
lastSignificantToken = match[0];
|
||||
postfixIncDec = true;
|
||||
yield ({
|
||||
type: "NumericLiteral",
|
||||
value: match[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
Template.lastIndex = lastIndex;
|
||||
if (match = Template.exec(input)) {
|
||||
lastIndex = Template.lastIndex;
|
||||
lastSignificantToken = match[0];
|
||||
if (match[1] === "${") {
|
||||
lastSignificantToken = "?InterpolationInTemplate";
|
||||
stack.push({
|
||||
tag: "InterpolationInTemplate",
|
||||
nesting: braces.length
|
||||
});
|
||||
postfixIncDec = false;
|
||||
yield ({
|
||||
type: "TemplateHead",
|
||||
value: match[0]
|
||||
});
|
||||
} else {
|
||||
postfixIncDec = true;
|
||||
yield ({
|
||||
type: "NoSubstitutionTemplate",
|
||||
value: match[0],
|
||||
closed: match[1] === "`"
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case "JSXTag":
|
||||
case "JSXTagEnd":
|
||||
JSXPunctuator.lastIndex = lastIndex;
|
||||
if (match = JSXPunctuator.exec(input)) {
|
||||
lastIndex = JSXPunctuator.lastIndex;
|
||||
nextLastSignificantToken = match[0];
|
||||
switch (match[0]) {
|
||||
case "<":
|
||||
stack.push({tag: "JSXTag"});
|
||||
break;
|
||||
case ">":
|
||||
stack.pop();
|
||||
if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
|
||||
nextLastSignificantToken = "?JSX";
|
||||
postfixIncDec = true;
|
||||
} else {
|
||||
stack.push({tag: "JSXChildren"});
|
||||
}
|
||||
break;
|
||||
case "{":
|
||||
stack.push({
|
||||
tag: "InterpolationInJSX",
|
||||
nesting: braces.length
|
||||
});
|
||||
nextLastSignificantToken = "?InterpolationInJSX";
|
||||
postfixIncDec = false;
|
||||
break;
|
||||
case "/":
|
||||
if (lastSignificantToken === "<") {
|
||||
stack.pop();
|
||||
if (stack[stack.length - 1].tag === "JSXChildren") {
|
||||
stack.pop();
|
||||
}
|
||||
stack.push({tag: "JSXTagEnd"});
|
||||
}
|
||||
}
|
||||
lastSignificantToken = nextLastSignificantToken;
|
||||
yield ({
|
||||
type: "JSXPunctuator",
|
||||
value: match[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
JSXIdentifier.lastIndex = lastIndex;
|
||||
if (match = JSXIdentifier.exec(input)) {
|
||||
lastIndex = JSXIdentifier.lastIndex;
|
||||
lastSignificantToken = match[0];
|
||||
yield ({
|
||||
type: "JSXIdentifier",
|
||||
value: match[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
JSXString.lastIndex = lastIndex;
|
||||
if (match = JSXString.exec(input)) {
|
||||
lastIndex = JSXString.lastIndex;
|
||||
lastSignificantToken = match[0];
|
||||
yield ({
|
||||
type: "JSXString",
|
||||
value: match[0],
|
||||
closed: match[2] !== void 0
|
||||
});
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case "JSXChildren":
|
||||
JSXText.lastIndex = lastIndex;
|
||||
if (match = JSXText.exec(input)) {
|
||||
lastIndex = JSXText.lastIndex;
|
||||
lastSignificantToken = match[0];
|
||||
yield ({
|
||||
type: "JSXText",
|
||||
value: match[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
switch (input[lastIndex]) {
|
||||
case "<":
|
||||
stack.push({tag: "JSXTag"});
|
||||
lastIndex++;
|
||||
lastSignificantToken = "<";
|
||||
yield ({
|
||||
type: "JSXPunctuator",
|
||||
value: "<"
|
||||
});
|
||||
continue;
|
||||
case "{":
|
||||
stack.push({
|
||||
tag: "InterpolationInJSX",
|
||||
nesting: braces.length
|
||||
});
|
||||
lastIndex++;
|
||||
lastSignificantToken = "?InterpolationInJSX";
|
||||
postfixIncDec = false;
|
||||
yield ({
|
||||
type: "JSXPunctuator",
|
||||
value: "{"
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
WhiteSpace.lastIndex = lastIndex;
|
||||
if (match = WhiteSpace.exec(input)) {
|
||||
lastIndex = WhiteSpace.lastIndex;
|
||||
yield ({
|
||||
type: "WhiteSpace",
|
||||
value: match[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
LineTerminatorSequence.lastIndex = lastIndex;
|
||||
if (match = LineTerminatorSequence.exec(input)) {
|
||||
lastIndex = LineTerminatorSequence.lastIndex;
|
||||
postfixIncDec = false;
|
||||
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
||||
lastSignificantToken = "?NoLineTerminatorHere";
|
||||
}
|
||||
yield ({
|
||||
type: "LineTerminatorSequence",
|
||||
value: match[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
MultiLineComment.lastIndex = lastIndex;
|
||||
if (match = MultiLineComment.exec(input)) {
|
||||
lastIndex = MultiLineComment.lastIndex;
|
||||
if (Newline.test(match[0])) {
|
||||
postfixIncDec = false;
|
||||
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
||||
lastSignificantToken = "?NoLineTerminatorHere";
|
||||
}
|
||||
}
|
||||
yield ({
|
||||
type: "MultiLineComment",
|
||||
value: match[0],
|
||||
closed: match[1] !== void 0
|
||||
});
|
||||
continue;
|
||||
}
|
||||
SingleLineComment.lastIndex = lastIndex;
|
||||
if (match = SingleLineComment.exec(input)) {
|
||||
lastIndex = SingleLineComment.lastIndex;
|
||||
postfixIncDec = false;
|
||||
yield ({
|
||||
type: "SingleLineComment",
|
||||
value: match[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
|
||||
lastIndex += firstCodePoint.length;
|
||||
lastSignificantToken = firstCodePoint;
|
||||
postfixIncDec = false;
|
||||
yield ({
|
||||
type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
|
||||
value: firstCodePoint
|
||||
});
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
22
node_modules/strip-literal/node_modules/js-tokens/package.json
generated
vendored
Normal file
22
node_modules/strip-literal/node_modules/js-tokens/package.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "js-tokens",
|
||||
"version": "9.0.1",
|
||||
"author": "Simon Lydell",
|
||||
"license": "MIT",
|
||||
"description": "Tiny JavaScript tokenizer.",
|
||||
"repository": "lydell/js-tokens",
|
||||
"type": "commonjs",
|
||||
"exports": "./index.js",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
"js",
|
||||
"ECMAScript",
|
||||
"es",
|
||||
"token",
|
||||
"tokens",
|
||||
"tokenize",
|
||||
"tokenizer",
|
||||
"regex",
|
||||
"regexp"
|
||||
]
|
||||
}
|
||||
60
node_modules/strip-literal/package.json
generated
vendored
Normal file
60
node_modules/strip-literal/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "strip-literal",
|
||||
"type": "module",
|
||||
"version": "3.1.0",
|
||||
"description": "Strip comments and string literals from JavaScript code",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/antfu",
|
||||
"homepage": "https://github.com/antfu/strip-literal#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/antfu/strip-literal.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/antfu/strip-literal/issues"
|
||||
},
|
||||
"keywords": [],
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.mjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.mts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"js-tokens": "^9.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^5.4.1",
|
||||
"@antfu/ni": "^26.0.1",
|
||||
"@types/node": "^24.5.2",
|
||||
"bumpp": "^10.2.3",
|
||||
"eslint": "^9.36.0",
|
||||
"pnpm": "^10.17.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"three": "^0.180.0",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.2",
|
||||
"unbuild": "^3.6.1",
|
||||
"vite": "^7.1.7",
|
||||
"vitest": "^3.2.4",
|
||||
"vue": "^3.5.22"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "unbuild --stub",
|
||||
"lint": "eslint .",
|
||||
"release": "bumpp",
|
||||
"start": "tsx src/index.ts",
|
||||
"test": "vitest",
|
||||
"bench": "vitest bench",
|
||||
"typecheck": "tsc --noEmit"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user