Spaces:
Paused
Paused
Upload folder using huggingface_hub (part 5)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/@babel/template/LICENSE +22 -0
- node_modules/@babel/template/README.md +19 -0
- node_modules/@babel/template/lib/builder.js +69 -0
- node_modules/@babel/template/lib/builder.js.map +1 -0
- node_modules/@babel/template/lib/formatters.js +61 -0
- node_modules/@babel/template/lib/formatters.js.map +1 -0
- node_modules/@babel/template/lib/index.js +23 -0
- node_modules/@babel/template/lib/index.js.map +1 -0
- node_modules/@babel/template/lib/literal.js +69 -0
- node_modules/@babel/template/lib/literal.js.map +1 -0
- node_modules/@babel/template/lib/options.js +73 -0
- node_modules/@babel/template/lib/options.js.map +1 -0
- node_modules/@babel/template/lib/parse.js +163 -0
- node_modules/@babel/template/lib/parse.js.map +1 -0
- node_modules/@babel/template/lib/populate.js +138 -0
- node_modules/@babel/template/lib/populate.js.map +1 -0
- node_modules/@babel/template/lib/string.js +20 -0
- node_modules/@babel/template/lib/string.js.map +1 -0
- node_modules/@babel/template/package.json +27 -0
- node_modules/@babel/traverse/LICENSE +22 -0
- node_modules/@babel/traverse/README.md +19 -0
- node_modules/@babel/traverse/lib/cache.js +37 -0
- node_modules/@babel/traverse/lib/cache.js.map +1 -0
- node_modules/@babel/traverse/lib/context.js +125 -0
- node_modules/@babel/traverse/lib/context.js.map +1 -0
- node_modules/@babel/traverse/lib/hub.js +19 -0
- node_modules/@babel/traverse/lib/hub.js.map +1 -0
- node_modules/@babel/traverse/lib/index.js +87 -0
- node_modules/@babel/traverse/lib/index.js.map +1 -0
- node_modules/@babel/traverse/lib/path/ancestry.js +139 -0
- node_modules/@babel/traverse/lib/path/ancestry.js.map +1 -0
- node_modules/@babel/traverse/lib/path/comments.js +52 -0
- node_modules/@babel/traverse/lib/path/comments.js.map +1 -0
- node_modules/@babel/traverse/lib/path/context.js +254 -0
- node_modules/@babel/traverse/lib/path/context.js.map +1 -0
- node_modules/@babel/traverse/lib/path/conversion.js +608 -0
- node_modules/@babel/traverse/lib/path/conversion.js.map +1 -0
- node_modules/@babel/traverse/lib/path/evaluation.js +373 -0
- node_modules/@babel/traverse/lib/path/evaluation.js.map +1 -0
- node_modules/@babel/traverse/lib/path/family.js +346 -0
- node_modules/@babel/traverse/lib/path/family.js.map +1 -0
- node_modules/@babel/traverse/lib/path/index.js +288 -0
- node_modules/@babel/traverse/lib/path/index.js.map +1 -0
- node_modules/@babel/traverse/lib/path/inference/index.js +149 -0
- node_modules/@babel/traverse/lib/path/inference/index.js.map +1 -0
- node_modules/@babel/traverse/lib/path/inference/inferer-reference.js +151 -0
- node_modules/@babel/traverse/lib/path/inference/inferer-reference.js.map +1 -0
- node_modules/@babel/traverse/lib/path/inference/inferers.js +207 -0
- node_modules/@babel/traverse/lib/path/inference/inferers.js.map +1 -0
- node_modules/@babel/traverse/lib/path/inference/util.js +28 -0
node_modules/@babel/template/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 6 |
+
a copy of this software and associated documentation files (the
|
| 7 |
+
"Software"), to deal in the Software without restriction, including
|
| 8 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 9 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 10 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 11 |
+
the following conditions:
|
| 12 |
+
|
| 13 |
+
The above copyright notice and this permission notice shall be
|
| 14 |
+
included in all copies or substantial portions of the Software.
|
| 15 |
+
|
| 16 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 17 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 18 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 19 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
| 20 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 21 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 22 |
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/@babel/template/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @babel/template
|
| 2 |
+
|
| 3 |
+
> Generate an AST from a string template.
|
| 4 |
+
|
| 5 |
+
See our website [@babel/template](https://babeljs.io/docs/babel-template) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20template%22+is%3Aopen) associated with this package.
|
| 6 |
+
|
| 7 |
+
## Install
|
| 8 |
+
|
| 9 |
+
Using npm:
|
| 10 |
+
|
| 11 |
+
```sh
|
| 12 |
+
npm install --save-dev @babel/template
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
or using yarn:
|
| 16 |
+
|
| 17 |
+
```sh
|
| 18 |
+
yarn add @babel/template --dev
|
| 19 |
+
```
|
node_modules/@babel/template/lib/builder.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = createTemplateBuilder;
|
| 7 |
+
var _options = require("./options.js");
|
| 8 |
+
var _string = require("./string.js");
|
| 9 |
+
var _literal = require("./literal.js");
|
| 10 |
+
const NO_PLACEHOLDER = (0, _options.validate)({
|
| 11 |
+
placeholderPattern: false
|
| 12 |
+
});
|
| 13 |
+
function createTemplateBuilder(formatter, defaultOpts) {
|
| 14 |
+
const templateFnCache = new WeakMap();
|
| 15 |
+
const templateAstCache = new WeakMap();
|
| 16 |
+
const cachedOpts = defaultOpts || (0, _options.validate)(null);
|
| 17 |
+
return Object.assign((tpl, ...args) => {
|
| 18 |
+
if (typeof tpl === "string") {
|
| 19 |
+
if (args.length > 1) throw new Error("Unexpected extra params.");
|
| 20 |
+
return extendedTrace((0, _string.default)(formatter, tpl, (0, _options.merge)(cachedOpts, (0, _options.validate)(args[0]))));
|
| 21 |
+
} else if (Array.isArray(tpl)) {
|
| 22 |
+
let builder = templateFnCache.get(tpl);
|
| 23 |
+
if (!builder) {
|
| 24 |
+
builder = (0, _literal.default)(formatter, tpl, cachedOpts);
|
| 25 |
+
templateFnCache.set(tpl, builder);
|
| 26 |
+
}
|
| 27 |
+
return extendedTrace(builder(args));
|
| 28 |
+
} else if (typeof tpl === "object" && tpl) {
|
| 29 |
+
if (args.length > 0) throw new Error("Unexpected extra params.");
|
| 30 |
+
return createTemplateBuilder(formatter, (0, _options.merge)(cachedOpts, (0, _options.validate)(tpl)));
|
| 31 |
+
}
|
| 32 |
+
throw new Error(`Unexpected template param ${typeof tpl}`);
|
| 33 |
+
}, {
|
| 34 |
+
ast: (tpl, ...args) => {
|
| 35 |
+
if (typeof tpl === "string") {
|
| 36 |
+
if (args.length > 1) throw new Error("Unexpected extra params.");
|
| 37 |
+
return (0, _string.default)(formatter, tpl, (0, _options.merge)((0, _options.merge)(cachedOpts, (0, _options.validate)(args[0])), NO_PLACEHOLDER))();
|
| 38 |
+
} else if (Array.isArray(tpl)) {
|
| 39 |
+
let builder = templateAstCache.get(tpl);
|
| 40 |
+
if (!builder) {
|
| 41 |
+
builder = (0, _literal.default)(formatter, tpl, (0, _options.merge)(cachedOpts, NO_PLACEHOLDER));
|
| 42 |
+
templateAstCache.set(tpl, builder);
|
| 43 |
+
}
|
| 44 |
+
return builder(args)();
|
| 45 |
+
}
|
| 46 |
+
throw new Error(`Unexpected template param ${typeof tpl}`);
|
| 47 |
+
}
|
| 48 |
+
});
|
| 49 |
+
}
|
| 50 |
+
function extendedTrace(fn) {
|
| 51 |
+
let rootStack = "";
|
| 52 |
+
try {
|
| 53 |
+
throw new Error();
|
| 54 |
+
} catch (error) {
|
| 55 |
+
if (error.stack) {
|
| 56 |
+
rootStack = error.stack.split("\n").slice(3).join("\n");
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
return arg => {
|
| 60 |
+
try {
|
| 61 |
+
return fn(arg);
|
| 62 |
+
} catch (err) {
|
| 63 |
+
err.stack += `\n =============\n${rootStack}`;
|
| 64 |
+
throw err;
|
| 65 |
+
}
|
| 66 |
+
};
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
//# sourceMappingURL=builder.js.map
|
node_modules/@babel/template/lib/builder.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_options","require","_string","_literal","NO_PLACEHOLDER","validate","placeholderPattern","createTemplateBuilder","formatter","defaultOpts","templateFnCache","WeakMap","templateAstCache","cachedOpts","Object","assign","tpl","args","length","Error","extendedTrace","stringTemplate","merge","Array","isArray","builder","get","literalTemplate","set","ast","fn","rootStack","error","stack","split","slice","join","arg","err"],"sources":["../src/builder.ts"],"sourcesContent":["import { merge, validate } from \"./options.ts\";\nimport type {\n TemplateOpts,\n PublicOpts,\n PublicReplacements,\n} from \"./options.ts\";\nimport type { Formatter } from \"./formatters.ts\";\n\nimport stringTemplate from \"./string.ts\";\nimport literalTemplate from \"./literal.ts\";\n\nexport type TemplateBuilder<T> = {\n // Build a new builder, merging the given options with the previous ones.\n (opts: PublicOpts): TemplateBuilder<T>;\n\n // Building from a string produces an AST builder function by default.\n (tpl: string, opts?: PublicOpts): (replacements?: PublicReplacements) => T;\n\n // Building from a template literal produces an AST builder function by default.\n (\n tpl: TemplateStringsArray,\n ...args: unknown[]\n ): (replacements?: PublicReplacements) => T;\n\n // Allow users to explicitly create templates that produce ASTs, skipping\n // the need for an intermediate function.\n ast: {\n (tpl: string, opts?: PublicOpts): T;\n (tpl: TemplateStringsArray, ...args: unknown[]): T;\n };\n};\n\n// Prebuild the options that will be used when parsing a `.ast` template.\n// These do not use a pattern because there is no way for users to pass in\n// replacement patterns to begin with, and disabling pattern matching means\n// users have more flexibility in what type of content they have in their\n// template JS.\nconst NO_PLACEHOLDER: TemplateOpts = validate({\n placeholderPattern: false,\n});\n\nexport default function createTemplateBuilder<T>(\n formatter: Formatter<T>,\n defaultOpts?: TemplateOpts,\n): TemplateBuilder<T> {\n const templateFnCache = new WeakMap();\n const templateAstCache = new WeakMap();\n const cachedOpts = defaultOpts || validate(null);\n\n return Object.assign(\n ((tpl, ...args) => {\n if (typeof tpl === \"string\") {\n if (args.length > 1) throw new Error(\"Unexpected extra params.\");\n return extendedTrace(\n stringTemplate(formatter, tpl, merge(cachedOpts, validate(args[0]))),\n );\n } else if (Array.isArray(tpl)) {\n let builder = templateFnCache.get(tpl);\n if (!builder) {\n builder = literalTemplate(formatter, tpl, cachedOpts);\n templateFnCache.set(tpl, builder);\n }\n return extendedTrace(builder(args));\n } else if (typeof tpl === \"object\" && tpl) {\n if (args.length > 0) throw new Error(\"Unexpected extra params.\");\n return createTemplateBuilder(\n formatter,\n merge(cachedOpts, validate(tpl)),\n );\n }\n throw new Error(`Unexpected template param ${typeof tpl}`);\n }) as TemplateBuilder<T>,\n {\n ast: (tpl: string | string[], ...args: unknown[]) => {\n if (typeof tpl === \"string\") {\n if (args.length > 1) throw new Error(\"Unexpected extra params.\");\n return stringTemplate(\n formatter,\n tpl,\n merge(merge(cachedOpts, validate(args[0])), NO_PLACEHOLDER),\n )();\n } else if (Array.isArray(tpl)) {\n let builder = templateAstCache.get(tpl);\n if (!builder) {\n builder = literalTemplate(\n formatter,\n tpl,\n merge(cachedOpts, NO_PLACEHOLDER),\n );\n templateAstCache.set(tpl, builder);\n }\n return builder(args)();\n }\n\n throw new Error(`Unexpected template param ${typeof tpl}`);\n },\n },\n );\n}\n\nfunction extendedTrace<Arg, Result>(\n fn: (_: Arg) => Result,\n): (_: Arg) => Result {\n // Since we lazy parse the template, we get the current stack so we have the\n // original stack to append if it errors when parsing\n let rootStack = \"\";\n try {\n // error stack gets populated in IE only on throw\n // (https://msdn.microsoft.com/en-us/library/hh699850(v=vs.94).aspx)\n throw new Error();\n } catch (error) {\n if (error.stack) {\n // error.stack does not exists in IE <= 9\n // We slice off the top 3 items in the stack to remove the call to\n // 'extendedTrace', and the anonymous builder function, with the final\n // stripped line being the error message itself since we threw it\n // in the first place and it doesn't matter.\n rootStack = error.stack.split(\"\\n\").slice(3).join(\"\\n\");\n }\n }\n\n return (arg: Arg) => {\n try {\n return fn(arg);\n } catch (err) {\n err.stack += `\\n =============\\n${rootStack}`;\n throw err;\n }\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAA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AAI;IAGF,MAAM,IAAIZ,KAAK,CAAC,CAAC;EACnB,CAAC,CAAC,OAAOa,KAAK,EAAE;IACd,IAAIA,KAAK,CAACC,KAAK,EAAE;MAMfF,SAAS,GAAGC,KAAK,CAACC,KAAK,CAACC,KAAK,CAAC,IAAI,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;IACzD;EACF;EAEA,OAAQC,GAAQ,IAAK;IACnB,IAAI;MACF,OAAOP,EAAE,CAACO,GAAG,CAAC;IAChB,CAAC,CAAC,OAAOC,GAAG,EAAE;MACZA,GAAG,CAACL,KAAK,IAAI,wBAAwBF,SAAS,EAAE;MAChD,MAAMO,GAAG;IACX;EACF,CAAC;AACH","ignoreList":[]}
|
node_modules/@babel/template/lib/formatters.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.statements = exports.statement = exports.smart = exports.program = exports.expression = void 0;
|
| 7 |
+
var _t = require("@babel/types");
|
| 8 |
+
const {
|
| 9 |
+
assertExpressionStatement
|
| 10 |
+
} = _t;
|
| 11 |
+
function makeStatementFormatter(fn) {
|
| 12 |
+
return {
|
| 13 |
+
code: str => `/* @babel/template */;\n${str}`,
|
| 14 |
+
validate: () => {},
|
| 15 |
+
unwrap: ast => {
|
| 16 |
+
return fn(ast.program.body.slice(1));
|
| 17 |
+
}
|
| 18 |
+
};
|
| 19 |
+
}
|
| 20 |
+
const smart = exports.smart = makeStatementFormatter(body => {
|
| 21 |
+
if (body.length > 1) {
|
| 22 |
+
return body;
|
| 23 |
+
} else {
|
| 24 |
+
return body[0];
|
| 25 |
+
}
|
| 26 |
+
});
|
| 27 |
+
const statements = exports.statements = makeStatementFormatter(body => body);
|
| 28 |
+
const statement = exports.statement = makeStatementFormatter(body => {
|
| 29 |
+
if (body.length === 0) {
|
| 30 |
+
throw new Error("Found nothing to return.");
|
| 31 |
+
}
|
| 32 |
+
if (body.length > 1) {
|
| 33 |
+
throw new Error("Found multiple statements but wanted one");
|
| 34 |
+
}
|
| 35 |
+
return body[0];
|
| 36 |
+
});
|
| 37 |
+
const expression = exports.expression = {
|
| 38 |
+
code: str => `(\n${str}\n)`,
|
| 39 |
+
validate: ast => {
|
| 40 |
+
if (ast.program.body.length > 1) {
|
| 41 |
+
throw new Error("Found multiple statements but wanted one");
|
| 42 |
+
}
|
| 43 |
+
if (expression.unwrap(ast).start === 0) {
|
| 44 |
+
throw new Error("Parse result included parens.");
|
| 45 |
+
}
|
| 46 |
+
},
|
| 47 |
+
unwrap: ({
|
| 48 |
+
program
|
| 49 |
+
}) => {
|
| 50 |
+
const [stmt] = program.body;
|
| 51 |
+
assertExpressionStatement(stmt);
|
| 52 |
+
return stmt.expression;
|
| 53 |
+
}
|
| 54 |
+
};
|
| 55 |
+
const program = exports.program = {
|
| 56 |
+
code: str => str,
|
| 57 |
+
validate: () => {},
|
| 58 |
+
unwrap: ast => ast.program
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
//# sourceMappingURL=formatters.js.map
|
node_modules/@babel/template/lib/formatters.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_t","require","assertExpressionStatement","makeStatementFormatter","fn","code","str","validate","unwrap","ast","program","body","slice","smart","exports","length","statements","statement","Error","expression","start","stmt"],"sources":["../src/formatters.ts"],"sourcesContent":["import { assertExpressionStatement } from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nexport type Formatter<T> = {\n code: (source: string) => string;\n validate: (ast: t.File) => void;\n unwrap: (ast: t.File) => T;\n};\n\nfunction makeStatementFormatter<T>(\n fn: (statements: t.Statement[]) => T,\n): Formatter<T> {\n return {\n // We need to prepend a \";\" to force statement parsing so that\n // ExpressionStatement strings won't be parsed as directives.\n // Alongside that, we also prepend a comment so that when a syntax error\n // is encountered, the user will be less likely to get confused about\n // where the random semicolon came from.\n code: str => `/* @babel/template */;\\n${str}`,\n validate: () => {},\n unwrap: (ast: t.File): T => {\n return fn(ast.program.body.slice(1));\n },\n };\n}\n\nexport const smart = makeStatementFormatter(body => {\n if (body.length > 1) {\n return body;\n } else {\n return body[0];\n }\n});\n\nexport const statements = makeStatementFormatter(body => body);\n\nexport const statement = makeStatementFormatter(body => {\n // We do this validation when unwrapping since the replacement process\n // could have added or removed statements.\n if (body.length === 0) {\n throw new Error(\"Found nothing to return.\");\n }\n if (body.length > 1) {\n throw new Error(\"Found multiple statements but wanted one\");\n }\n\n return body[0];\n});\n\nexport const expression: Formatter<t.Expression> = {\n code: str => `(\\n${str}\\n)`,\n validate: ast => {\n if (ast.program.body.length > 1) {\n throw new Error(\"Found multiple statements but wanted one\");\n }\n if (expression.unwrap(ast).start === 0) {\n throw new Error(\"Parse result included parens.\");\n }\n },\n unwrap: ({ program }) => {\n const [stmt] = program.body;\n assertExpressionStatement(stmt);\n return stmt.expression;\n },\n};\n\nexport const program: Formatter<t.Program> = {\n code: str => str,\n validate: () => {},\n unwrap: ast => ast.program,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,EAAA,GAAAC,OAAA;AAAyD;EAAhDC;AAAyB,IAAAF,EA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7D;IACA,IAAIC,UAAU,CAACX,MAAM,CAACC,GAAG,CAAC,CAACW,KAAK,KAAK,CAAC,EAAE;MACtC,MAAM,IAAIF,KAAK,CAAC,+BAA+B,CAAC;IAClD;EACF,CAAC;EACDV,MAAM,EAAEA,CAAC;IAAEE;EAAQ,CAAC,KAAK;IACvB,MAAM,CAACW,IAAI,CAAC,GAAGX,OAAO,CAACC,IAAI;IAC3BT,yBAAyB,CAACmB,IAAI,CAAC;IAC/B,OAAOA,IAAI,CAACF,UAAU;EACxB;AACF,CAAC;AAEM,MAAMT,OAA6B,GAAAI,OAAA,CAAAJ,OAAA,GAAG;EAC3CL,IAAI,EAAEC,GAAG,IAAIA,GAAG;EAChBC,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClBC,MAAM,EAAEC,GAAG,IAAIA,GAAG,CAACC;AACrB,CAAC","ignoreList":[]}
|
node_modules/@babel/template/lib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.statements = exports.statement = exports.smart = exports.program = exports.expression = exports.default = void 0;
|
| 7 |
+
var formatters = require("./formatters.js");
|
| 8 |
+
var _builder = require("./builder.js");
|
| 9 |
+
const smart = exports.smart = (0, _builder.default)(formatters.smart);
|
| 10 |
+
const statement = exports.statement = (0, _builder.default)(formatters.statement);
|
| 11 |
+
const statements = exports.statements = (0, _builder.default)(formatters.statements);
|
| 12 |
+
const expression = exports.expression = (0, _builder.default)(formatters.expression);
|
| 13 |
+
const program = exports.program = (0, _builder.default)(formatters.program);
|
| 14 |
+
var _default = exports.default = Object.assign(smart.bind(undefined), {
|
| 15 |
+
smart,
|
| 16 |
+
statement,
|
| 17 |
+
statements,
|
| 18 |
+
expression,
|
| 19 |
+
program,
|
| 20 |
+
ast: smart.ast
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@babel/template/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["formatters","require","_builder","smart","exports","createTemplateBuilder","statement","statements","expression","program","_default","default","Object","assign","bind","undefined","ast"],"sources":["../src/index.ts"],"sourcesContent":["import * as formatters from \"./formatters.ts\";\nimport createTemplateBuilder from \"./builder.ts\";\n\nexport const smart = createTemplateBuilder(formatters.smart);\nexport const statement = createTemplateBuilder(formatters.statement);\nexport const statements = createTemplateBuilder(formatters.statements);\nexport const expression = createTemplateBuilder(formatters.expression);\nexport const program = createTemplateBuilder(formatters.program);\n\ntype DefaultTemplateBuilder = typeof smart & {\n smart: typeof smart;\n statement: typeof statement;\n statements: typeof statements;\n expression: typeof expression;\n program: typeof program;\n};\n\nexport default Object.assign(smart.bind(undefined) as DefaultTemplateBuilder, {\n smart,\n statement,\n statements,\n expression,\n program,\n ast: smart.ast,\n});\n\nexport type {\n PublicOpts as Options,\n PublicReplacements as Replacements,\n} from \"./options.ts\";\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG,IAAAE,gBAAqB,EAACL,UAAU,CAACG,KAAK,CAAC;AACrD,MAAMG,SAAS,GAAAF,OAAA,CAAAE,SAAA,GAAG,IAAAD,gBAAqB,EAACL,UAAU,CAACM,SAAS,CAAC;AAC7D,MAAMC,UAAU,GAAAH,OAAA,CAAAG,UAAA,GAAG,IAAAF,gBAAqB,EAACL,UAAU,CAACO,UAAU,CAAC;AAC/D,MAAMC,UAAU,GAAAJ,OAAA,CAAAI,UAAA,GAAG,IAAAH,gBAAqB,EAACL,UAAU,CAACQ,UAAU,CAAC;AAC/D,MAAMC,OAAO,GAAAL,OAAA,CAAAK,OAAA,GAAG,IAAAJ,gBAAqB,EAACL,UAAU,CAACS,OAAO,CAAC;AAAC,IAAAC,QAAA,GAAAN,OAAA,CAAAO,OAAA,GAUlDC,MAAM,CAACC,MAAM,CAACV,KAAK,CAACW,IAAI,CAACC,SAAS,CAAC,EAA4B;EAC5EZ,KAAK;EACLG,SAAS;EACTC,UAAU;EACVC,UAAU;EACVC,OAAO;EACPO,GAAG,EAAEb,KAAK,CAACa;AACb,CAAC,CAAC","ignoreList":[]}
|
node_modules/@babel/template/lib/literal.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = literalTemplate;
|
| 7 |
+
var _options = require("./options.js");
|
| 8 |
+
var _parse = require("./parse.js");
|
| 9 |
+
var _populate = require("./populate.js");
|
| 10 |
+
function literalTemplate(formatter, tpl, opts) {
|
| 11 |
+
const {
|
| 12 |
+
metadata,
|
| 13 |
+
names
|
| 14 |
+
} = buildLiteralData(formatter, tpl, opts);
|
| 15 |
+
return arg => {
|
| 16 |
+
const defaultReplacements = {};
|
| 17 |
+
arg.forEach((replacement, i) => {
|
| 18 |
+
defaultReplacements[names[i]] = replacement;
|
| 19 |
+
});
|
| 20 |
+
return arg => {
|
| 21 |
+
const replacements = (0, _options.normalizeReplacements)(arg);
|
| 22 |
+
if (replacements) {
|
| 23 |
+
Object.keys(replacements).forEach(key => {
|
| 24 |
+
if (hasOwnProperty.call(defaultReplacements, key)) {
|
| 25 |
+
throw new Error("Unexpected replacement overlap.");
|
| 26 |
+
}
|
| 27 |
+
});
|
| 28 |
+
}
|
| 29 |
+
return formatter.unwrap((0, _populate.default)(metadata, replacements ? Object.assign(replacements, defaultReplacements) : defaultReplacements));
|
| 30 |
+
};
|
| 31 |
+
};
|
| 32 |
+
}
|
| 33 |
+
function buildLiteralData(formatter, tpl, opts) {
|
| 34 |
+
let prefix = "BABEL_TPL$";
|
| 35 |
+
const raw = tpl.join("");
|
| 36 |
+
do {
|
| 37 |
+
prefix = "$$" + prefix;
|
| 38 |
+
} while (raw.includes(prefix));
|
| 39 |
+
const {
|
| 40 |
+
names,
|
| 41 |
+
code
|
| 42 |
+
} = buildTemplateCode(tpl, prefix);
|
| 43 |
+
const metadata = (0, _parse.default)(formatter, formatter.code(code), {
|
| 44 |
+
parser: opts.parser,
|
| 45 |
+
placeholderWhitelist: new Set(names.concat(opts.placeholderWhitelist ? Array.from(opts.placeholderWhitelist) : [])),
|
| 46 |
+
placeholderPattern: opts.placeholderPattern,
|
| 47 |
+
preserveComments: opts.preserveComments,
|
| 48 |
+
syntacticPlaceholders: opts.syntacticPlaceholders
|
| 49 |
+
});
|
| 50 |
+
return {
|
| 51 |
+
metadata,
|
| 52 |
+
names
|
| 53 |
+
};
|
| 54 |
+
}
|
| 55 |
+
function buildTemplateCode(tpl, prefix) {
|
| 56 |
+
const names = [];
|
| 57 |
+
let code = tpl[0];
|
| 58 |
+
for (let i = 1; i < tpl.length; i++) {
|
| 59 |
+
const value = `${prefix}${i - 1}`;
|
| 60 |
+
names.push(value);
|
| 61 |
+
code += value + tpl[i];
|
| 62 |
+
}
|
| 63 |
+
return {
|
| 64 |
+
names,
|
| 65 |
+
code
|
| 66 |
+
};
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
//# sourceMappingURL=literal.js.map
|
node_modules/@babel/template/lib/literal.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_options","require","_parse","_populate","literalTemplate","formatter","tpl","opts","metadata","names","buildLiteralData","arg","defaultReplacements","forEach","replacement","i","replacements","normalizeReplacements","Object","keys","key","hasOwnProperty","call","Error","unwrap","populatePlaceholders","assign","prefix","raw","join","includes","code","buildTemplateCode","parseAndBuildMetadata","parser","placeholderWhitelist","Set","concat","Array","from","placeholderPattern","preserveComments","syntacticPlaceholders","length","value","push"],"sources":["../src/literal.ts"],"sourcesContent":["import type { Formatter } from \"./formatters.ts\";\nimport type { TemplateReplacements, TemplateOpts } from \"./options.ts\";\nimport { normalizeReplacements } from \"./options.ts\";\nimport parseAndBuildMetadata from \"./parse.ts\";\nimport populatePlaceholders from \"./populate.ts\";\n\nexport default function literalTemplate<T>(\n formatter: Formatter<T>,\n tpl: string[],\n opts: TemplateOpts,\n): (_: unknown[]) => (_: unknown) => T {\n const { metadata, names } = buildLiteralData(formatter, tpl, opts);\n\n return arg => {\n const defaultReplacements: TemplateReplacements = {};\n arg.forEach((replacement, i) => {\n defaultReplacements[names[i]] = replacement;\n });\n\n return (arg: unknown) => {\n const replacements = normalizeReplacements(arg);\n\n if (replacements) {\n Object.keys(replacements).forEach(key => {\n if (Object.hasOwn(defaultReplacements, key)) {\n throw new Error(\"Unexpected replacement overlap.\");\n }\n });\n }\n\n return formatter.unwrap(\n populatePlaceholders(\n metadata,\n replacements\n ? Object.assign(replacements, defaultReplacements)\n : defaultReplacements,\n ),\n );\n };\n };\n}\n\nfunction buildLiteralData<T>(\n formatter: Formatter<T>,\n tpl: string[],\n opts: TemplateOpts,\n) {\n let prefix = \"BABEL_TPL$\";\n\n const raw = tpl.join(\"\");\n\n do {\n // If there are cases where the template already contains $$BABEL_TPL$0 or any other\n // matching pattern, we keep adding \"$$\" characters until a unique prefix\n // is found.\n prefix = \"$$\" + prefix;\n } while (raw.includes(prefix));\n\n const { names, code } = buildTemplateCode(tpl, prefix);\n\n const metadata = parseAndBuildMetadata(formatter, formatter.code(code), {\n parser: opts.parser,\n\n // Explicitly include our generated names in the whitelist so users never\n // have to think about whether their placeholder pattern will match.\n placeholderWhitelist: new Set(\n names.concat(\n opts.placeholderWhitelist ? Array.from(opts.placeholderWhitelist) : [],\n ),\n ),\n placeholderPattern: opts.placeholderPattern,\n preserveComments: opts.preserveComments,\n syntacticPlaceholders: opts.syntacticPlaceholders,\n });\n\n return { metadata, names };\n}\n\nfunction buildTemplateCode(\n tpl: string[],\n prefix: string,\n): { names: string[]; code: string } {\n const names = [];\n\n let code = tpl[0];\n\n for (let i = 1; i < tpl.length; i++) {\n const value = `${prefix}${i - 1}`;\n names.push(value);\n\n code += value + tpl[i];\n }\n\n return { names, code };\n}\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEe,SAASG,eAAeA,CACrCC,SAAuB,EACvBC,GAAa,EACbC,IAAkB,EACmB;EACrC,MAAM;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAGC,gBAAgB,CAACL,SAAS,EAAEC,GAAG,EAAEC,IAAI,CAAC;EAElE,OAAOI,GAAG,IAAI;IACZ,MAAMC,mBAAyC,GAAG,CAAC,CAAC;IACpDD,GAAG,CAACE,OAAO,CAAC,CAACC,WAAW,EAAEC,CAAC,KAAK;MAC9BH,mBAAmB,CAACH,KAAK,CAACM,CAAC,CAAC,CAAC,G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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.merge = merge;
|
| 7 |
+
exports.normalizeReplacements = normalizeReplacements;
|
| 8 |
+
exports.validate = validate;
|
| 9 |
+
const _excluded = ["placeholderWhitelist", "placeholderPattern", "preserveComments", "syntacticPlaceholders"];
|
| 10 |
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
| 11 |
+
function merge(a, b) {
|
| 12 |
+
const {
|
| 13 |
+
placeholderWhitelist = a.placeholderWhitelist,
|
| 14 |
+
placeholderPattern = a.placeholderPattern,
|
| 15 |
+
preserveComments = a.preserveComments,
|
| 16 |
+
syntacticPlaceholders = a.syntacticPlaceholders
|
| 17 |
+
} = b;
|
| 18 |
+
return {
|
| 19 |
+
parser: Object.assign({}, a.parser, b.parser),
|
| 20 |
+
placeholderWhitelist,
|
| 21 |
+
placeholderPattern,
|
| 22 |
+
preserveComments,
|
| 23 |
+
syntacticPlaceholders
|
| 24 |
+
};
|
| 25 |
+
}
|
| 26 |
+
function validate(opts) {
|
| 27 |
+
if (opts != null && typeof opts !== "object") {
|
| 28 |
+
throw new Error("Unknown template options.");
|
| 29 |
+
}
|
| 30 |
+
const _ref = opts || {},
|
| 31 |
+
{
|
| 32 |
+
placeholderWhitelist,
|
| 33 |
+
placeholderPattern,
|
| 34 |
+
preserveComments,
|
| 35 |
+
syntacticPlaceholders
|
| 36 |
+
} = _ref,
|
| 37 |
+
parser = _objectWithoutPropertiesLoose(_ref, _excluded);
|
| 38 |
+
if (placeholderWhitelist != null && !(placeholderWhitelist instanceof Set)) {
|
| 39 |
+
throw new Error("'.placeholderWhitelist' must be a Set, null, or undefined");
|
| 40 |
+
}
|
| 41 |
+
if (placeholderPattern != null && !(placeholderPattern instanceof RegExp) && placeholderPattern !== false) {
|
| 42 |
+
throw new Error("'.placeholderPattern' must be a RegExp, false, null, or undefined");
|
| 43 |
+
}
|
| 44 |
+
if (preserveComments != null && typeof preserveComments !== "boolean") {
|
| 45 |
+
throw new Error("'.preserveComments' must be a boolean, null, or undefined");
|
| 46 |
+
}
|
| 47 |
+
if (syntacticPlaceholders != null && typeof syntacticPlaceholders !== "boolean") {
|
| 48 |
+
throw new Error("'.syntacticPlaceholders' must be a boolean, null, or undefined");
|
| 49 |
+
}
|
| 50 |
+
if (syntacticPlaceholders === true && (placeholderWhitelist != null || placeholderPattern != null)) {
|
| 51 |
+
throw new Error("'.placeholderWhitelist' and '.placeholderPattern' aren't compatible" + " with '.syntacticPlaceholders: true'");
|
| 52 |
+
}
|
| 53 |
+
return {
|
| 54 |
+
parser,
|
| 55 |
+
placeholderWhitelist: placeholderWhitelist || undefined,
|
| 56 |
+
placeholderPattern: placeholderPattern == null ? undefined : placeholderPattern,
|
| 57 |
+
preserveComments: preserveComments == null ? undefined : preserveComments,
|
| 58 |
+
syntacticPlaceholders: syntacticPlaceholders == null ? undefined : syntacticPlaceholders
|
| 59 |
+
};
|
| 60 |
+
}
|
| 61 |
+
function normalizeReplacements(replacements) {
|
| 62 |
+
if (Array.isArray(replacements)) {
|
| 63 |
+
return replacements.reduce((acc, replacement, i) => {
|
| 64 |
+
acc["$" + i] = replacement;
|
| 65 |
+
return acc;
|
| 66 |
+
}, {});
|
| 67 |
+
} else if (typeof replacements === "object" || replacements == null) {
|
| 68 |
+
return replacements || undefined;
|
| 69 |
+
}
|
| 70 |
+
throw new Error("Template replacements must be an array, object, null, or undefined");
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
//# sourceMappingURL=options.js.map
|
node_modules/@babel/template/lib/options.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["merge","a","b","placeholderWhitelist","placeholderPattern","preserveComments","syntacticPlaceholders","parser","Object","assign","validate","opts","Error","_ref","_objectWithoutPropertiesLoose","_excluded","Set","RegExp","undefined","normalizeReplacements","replacements","Array","isArray","reduce","acc","replacement","i"],"sources":["../src/options.ts"],"sourcesContent":["import type { ParserOptions as ParserOpts } from \"@babel/parser\";\n\nexport type { ParserOpts };\n\n/**\n * These are the options that 'babel-template' actually accepts and typechecks\n * when called. All other options are passed through to the parser.\n */\nexport type PublicOpts = {\n /**\n * A set of placeholder names to automatically accept, ignoring the given\n * pattern entirely.\n *\n * This option can be used when using %%foo%% style placeholders.\n */\n placeholderWhitelist?: Set<string>;\n /**\n * A pattern to search for when looking for Identifier and StringLiteral\n * nodes that can be replaced.\n *\n * 'false' will disable placeholder searching entirely, leaving only the\n * 'placeholderWhitelist' value to find replacements.\n *\n * Defaults to /^[_$A-Z0-9]+$/.\n *\n * This option can be used when using %%foo%% style placeholders.\n */\n placeholderPattern?: RegExp | false;\n /**\n * 'true' to pass through comments from the template into the resulting AST,\n * or 'false' to automatically discard comments. Defaults to 'false'.\n */\n preserveComments?: boolean;\n /**\n * 'true' to use %%foo%% style placeholders, 'false' to use legacy placeholders\n * described by placeholderPattern or placeholderWhitelist.\n * When it is not set, it behaves as 'true' if there are syntactic placeholders,\n * otherwise as 'false'.\n */\n syntacticPlaceholders?: boolean | null;\n} & ParserOpts;\n\nexport type TemplateOpts = {\n parser: ParserOpts;\n placeholderWhitelist?: Set<string>;\n placeholderPattern?: RegExp | false;\n preserveComments?: boolean;\n syntacticPlaceholders?: boolean;\n};\n\nexport function merge(a: TemplateOpts, b: TemplateOpts): TemplateOpts {\n const {\n placeholderWhitelist = a.placeholderWhitelist,\n placeholderPattern = a.placeholderPattern,\n preserveComments = a.preserveComments,\n syntacticPlaceholders = a.syntacticPlaceholders,\n } = b;\n\n return {\n parser: {\n ...a.parser,\n ...b.parser,\n },\n placeholderWhitelist,\n placeholderPattern,\n preserveComments,\n syntacticPlaceholders,\n };\n}\n\nexport function validate(opts: unknown): TemplateOpts {\n if (opts != null && typeof opts !== \"object\") {\n throw new Error(\"Unknown template options.\");\n }\n\n const {\n placeholderWhitelist,\n placeholderPattern,\n preserveComments,\n syntacticPlaceholders,\n ...parser\n } = opts || ({} as any);\n\n if (placeholderWhitelist != null && !(placeholderWhitelist instanceof Set)) {\n throw new Error(\n \"'.placeholderWhitelist' must be a Set, null, or undefined\",\n );\n }\n\n if (\n placeholderPattern != null &&\n !(placeholderPattern instanceof RegExp) &&\n placeholderPattern !== false\n ) {\n throw new Error(\n \"'.placeholderPattern' must be a RegExp, false, null, or undefined\",\n );\n }\n\n if (preserveComments != null && typeof preserveComments !== \"boolean\") {\n throw new Error(\n \"'.preserveComments' must be a boolean, null, or undefined\",\n );\n }\n\n if (\n syntacticPlaceholders != null &&\n typeof syntacticPlaceholders !== \"boolean\"\n ) {\n throw new Error(\n \"'.syntacticPlaceholders' must be a boolean, null, or undefined\",\n );\n }\n if (\n syntacticPlaceholders === true &&\n (placeholderWhitelist != null || placeholderPattern != null)\n ) {\n throw new Error(\n \"'.placeholderWhitelist' and '.placeholderPattern' aren't compatible\" +\n \" with '.syntacticPlaceholders: true'\",\n );\n }\n\n return {\n parser,\n placeholderWhitelist: placeholderWhitelist || undefined,\n placeholderPattern:\n placeholderPattern == null ? undefined : placeholderPattern,\n preserveComments: preserveComments == null ? undefined : preserveComments,\n syntacticPlaceholders:\n syntacticPlaceholders == null ? undefined : syntacticPlaceholders,\n };\n}\n\nexport type PublicReplacements = Record<string, unknown> | unknown[];\nexport type TemplateReplacements = Record<string, unknown> | void;\n\nexport function normalizeReplacements(\n replacements: unknown,\n): TemplateReplacements {\n if (Array.isArray(replacements)) {\n return replacements.reduce((acc, replacement, i) => {\n acc[\"$\" + i] = replacement;\n return acc;\n }, {});\n } else if (typeof replacements === \"object\" || replacements == null) {\n return (replacements as any) || undefined;\n }\n\n throw new Error(\n \"Template replacements must be an array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var _parser = require("@babel/parser");
|
| 9 |
+
var _codeFrame = require("@babel/code-frame");
|
| 10 |
+
const {
|
| 11 |
+
isCallExpression,
|
| 12 |
+
isExpressionStatement,
|
| 13 |
+
isFunction,
|
| 14 |
+
isIdentifier,
|
| 15 |
+
isJSXIdentifier,
|
| 16 |
+
isNewExpression,
|
| 17 |
+
isPlaceholder,
|
| 18 |
+
isStatement,
|
| 19 |
+
isStringLiteral,
|
| 20 |
+
removePropertiesDeep,
|
| 21 |
+
traverse
|
| 22 |
+
} = _t;
|
| 23 |
+
const PATTERN = /^[_$A-Z0-9]+$/;
|
| 24 |
+
function parseAndBuildMetadata(formatter, code, opts) {
|
| 25 |
+
const {
|
| 26 |
+
placeholderWhitelist,
|
| 27 |
+
placeholderPattern,
|
| 28 |
+
preserveComments,
|
| 29 |
+
syntacticPlaceholders
|
| 30 |
+
} = opts;
|
| 31 |
+
const ast = parseWithCodeFrame(code, opts.parser, syntacticPlaceholders);
|
| 32 |
+
removePropertiesDeep(ast, {
|
| 33 |
+
preserveComments
|
| 34 |
+
});
|
| 35 |
+
formatter.validate(ast);
|
| 36 |
+
const state = {
|
| 37 |
+
syntactic: {
|
| 38 |
+
placeholders: [],
|
| 39 |
+
placeholderNames: new Set()
|
| 40 |
+
},
|
| 41 |
+
legacy: {
|
| 42 |
+
placeholders: [],
|
| 43 |
+
placeholderNames: new Set()
|
| 44 |
+
},
|
| 45 |
+
placeholderWhitelist,
|
| 46 |
+
placeholderPattern,
|
| 47 |
+
syntacticPlaceholders
|
| 48 |
+
};
|
| 49 |
+
traverse(ast, placeholderVisitorHandler, state);
|
| 50 |
+
return Object.assign({
|
| 51 |
+
ast
|
| 52 |
+
}, state.syntactic.placeholders.length ? state.syntactic : state.legacy);
|
| 53 |
+
}
|
| 54 |
+
function placeholderVisitorHandler(node, ancestors, state) {
|
| 55 |
+
var _state$placeholderWhi;
|
| 56 |
+
let name;
|
| 57 |
+
let hasSyntacticPlaceholders = state.syntactic.placeholders.length > 0;
|
| 58 |
+
if (isPlaceholder(node)) {
|
| 59 |
+
if (state.syntacticPlaceholders === false) {
|
| 60 |
+
throw new Error("%%foo%%-style placeholders can't be used when " + "'.syntacticPlaceholders' is false.");
|
| 61 |
+
}
|
| 62 |
+
name = node.name.name;
|
| 63 |
+
hasSyntacticPlaceholders = true;
|
| 64 |
+
} else if (hasSyntacticPlaceholders || state.syntacticPlaceholders) {
|
| 65 |
+
return;
|
| 66 |
+
} else if (isIdentifier(node) || isJSXIdentifier(node)) {
|
| 67 |
+
name = node.name;
|
| 68 |
+
} else if (isStringLiteral(node)) {
|
| 69 |
+
name = node.value;
|
| 70 |
+
} else {
|
| 71 |
+
return;
|
| 72 |
+
}
|
| 73 |
+
if (hasSyntacticPlaceholders && (state.placeholderPattern != null || state.placeholderWhitelist != null)) {
|
| 74 |
+
throw new Error("'.placeholderWhitelist' and '.placeholderPattern' aren't compatible" + " with '.syntacticPlaceholders: true'");
|
| 75 |
+
}
|
| 76 |
+
if (!hasSyntacticPlaceholders && (state.placeholderPattern === false || !(state.placeholderPattern || PATTERN).test(name)) && !((_state$placeholderWhi = state.placeholderWhitelist) != null && _state$placeholderWhi.has(name))) {
|
| 77 |
+
return;
|
| 78 |
+
}
|
| 79 |
+
ancestors = ancestors.slice();
|
| 80 |
+
const {
|
| 81 |
+
node: parent,
|
| 82 |
+
key
|
| 83 |
+
} = ancestors[ancestors.length - 1];
|
| 84 |
+
let type;
|
| 85 |
+
if (isStringLiteral(node) || isPlaceholder(node, {
|
| 86 |
+
expectedNode: "StringLiteral"
|
| 87 |
+
})) {
|
| 88 |
+
type = "string";
|
| 89 |
+
} else if (isNewExpression(parent) && key === "arguments" || isCallExpression(parent) && key === "arguments" || isFunction(parent) && key === "params") {
|
| 90 |
+
type = "param";
|
| 91 |
+
} else if (isExpressionStatement(parent) && !isPlaceholder(node)) {
|
| 92 |
+
type = "statement";
|
| 93 |
+
ancestors = ancestors.slice(0, -1);
|
| 94 |
+
} else if (isStatement(node) && isPlaceholder(node)) {
|
| 95 |
+
type = "statement";
|
| 96 |
+
} else {
|
| 97 |
+
type = "other";
|
| 98 |
+
}
|
| 99 |
+
const {
|
| 100 |
+
placeholders,
|
| 101 |
+
placeholderNames
|
| 102 |
+
} = !hasSyntacticPlaceholders ? state.legacy : state.syntactic;
|
| 103 |
+
placeholders.push({
|
| 104 |
+
name,
|
| 105 |
+
type,
|
| 106 |
+
resolve: ast => resolveAncestors(ast, ancestors),
|
| 107 |
+
isDuplicate: placeholderNames.has(name)
|
| 108 |
+
});
|
| 109 |
+
placeholderNames.add(name);
|
| 110 |
+
}
|
| 111 |
+
function resolveAncestors(ast, ancestors) {
|
| 112 |
+
let parent = ast;
|
| 113 |
+
for (let i = 0; i < ancestors.length - 1; i++) {
|
| 114 |
+
const {
|
| 115 |
+
key,
|
| 116 |
+
index
|
| 117 |
+
} = ancestors[i];
|
| 118 |
+
if (index === undefined) {
|
| 119 |
+
parent = parent[key];
|
| 120 |
+
} else {
|
| 121 |
+
parent = parent[key][index];
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
const {
|
| 125 |
+
key,
|
| 126 |
+
index
|
| 127 |
+
} = ancestors[ancestors.length - 1];
|
| 128 |
+
return {
|
| 129 |
+
parent,
|
| 130 |
+
key,
|
| 131 |
+
index
|
| 132 |
+
};
|
| 133 |
+
}
|
| 134 |
+
function parseWithCodeFrame(code, parserOpts, syntacticPlaceholders) {
|
| 135 |
+
const plugins = (parserOpts.plugins || []).slice();
|
| 136 |
+
if (syntacticPlaceholders !== false) {
|
| 137 |
+
plugins.push("placeholders");
|
| 138 |
+
}
|
| 139 |
+
parserOpts = Object.assign({
|
| 140 |
+
allowAwaitOutsideFunction: true,
|
| 141 |
+
allowReturnOutsideFunction: true,
|
| 142 |
+
allowNewTargetOutsideFunction: true,
|
| 143 |
+
allowSuperOutsideMethod: true,
|
| 144 |
+
allowYieldOutsideFunction: true,
|
| 145 |
+
sourceType: "module"
|
| 146 |
+
}, parserOpts, {
|
| 147 |
+
plugins
|
| 148 |
+
});
|
| 149 |
+
try {
|
| 150 |
+
return (0, _parser.parse)(code, parserOpts);
|
| 151 |
+
} catch (err) {
|
| 152 |
+
const loc = err.loc;
|
| 153 |
+
if (loc) {
|
| 154 |
+
err.message += "\n" + (0, _codeFrame.codeFrameColumns)(code, {
|
| 155 |
+
start: loc
|
| 156 |
+
});
|
| 157 |
+
err.code = "BABEL_TEMPLATE_PARSE_ERROR";
|
| 158 |
+
}
|
| 159 |
+
throw err;
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
//# sourceMappingURL=parse.js.map
|
node_modules/@babel/template/lib/parse.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_t","require","_parser","_codeFrame","isCallExpression","isExpressionStatement","isFunction","isIdentifier","isJSXIdentifier","isNewExpression","isPlaceholder","isStatement","isStringLiteral","removePropertiesDeep","traverse","PATTERN","parseAndBuildMetadata","formatter","code","opts","placeholderWhitelist","placeholderPattern","preserveComments","syntacticPlaceholders","ast","parseWithCodeFrame","parser","validate","state","syntactic","placeholders","placeholderNames","Set","legacy","placeholderVisitorHandler","Object","assign","length","node","ancestors","_state$placeholderWhi","name","hasSyntacticPlaceholders","Error","value","test","has","slice","parent","key","type","expectedNode","push","resolve","resolveAncestors","isDuplicate","add","i","index","undefined","parserOpts","plugins","allowAwaitOutsideFunction","allowReturnOutsideFunction","allowNewTargetOutsideFunction","allowSuperOutsideMethod","allowYieldOutsideFunction","sourceType","parse","err","loc","message","codeFrameColumns","start"],"sources":["../src/parse.ts"],"sourcesContent":["import {\n isCallExpression,\n isExpressionStatement,\n isFunction,\n isIdentifier,\n isJSXIdentifier,\n isNewExpression,\n isPlaceholder,\n isStatement,\n isStringLiteral,\n removePropertiesDeep,\n traverse,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type { TraversalAncestors } from \"@babel/types\";\nimport { parse } from \"@babel/parser\";\nimport { codeFrameColumns } from \"@babel/code-frame\";\nimport type { TemplateOpts, ParserOpts } from \"./options.ts\";\nimport type { Formatter } from \"./formatters.ts\";\n\nexport type Metadata = {\n ast: t.File;\n placeholders: Placeholder[];\n placeholderNames: Set<string>;\n};\n\ntype PlaceholderType = \"string\" | \"param\" | \"statement\" | \"other\";\nexport type Placeholder = {\n name: string;\n resolve: (a: t.File) => { parent: t.Node; key: string; index?: number };\n type: PlaceholderType;\n isDuplicate: boolean;\n};\n\nconst PATTERN = /^[_$A-Z0-9]+$/;\n\nexport default function parseAndBuildMetadata<T>(\n formatter: Formatter<T>,\n code: string,\n opts: TemplateOpts,\n): Metadata {\n const {\n placeholderWhitelist,\n placeholderPattern,\n preserveComments,\n syntacticPlaceholders,\n } = opts;\n\n const ast = parseWithCodeFrame(code, opts.parser, syntacticPlaceholders);\n\n removePropertiesDeep(ast, {\n preserveComments,\n });\n\n formatter.validate(ast);\n\n const state: MetadataState = {\n syntactic: { placeholders: [], placeholderNames: new Set() },\n legacy: { placeholders: [], placeholderNames: new Set() },\n placeholderWhitelist,\n placeholderPattern,\n syntacticPlaceholders,\n };\n\n traverse(ast, placeholderVisitorHandler, state);\n\n return {\n ast,\n ...(state.syntactic.placeholders.length ? state.syntactic : state.legacy),\n };\n}\n\nfunction placeholderVisitorHandler(\n node: t.Node,\n ancestors: TraversalAncestors,\n state: MetadataState,\n) {\n let name: string;\n\n let hasSyntacticPlaceholders = state.syntactic.placeholders.length > 0;\n\n if (isPlaceholder(node)) {\n if (state.syntacticPlaceholders === false) {\n throw new Error(\n \"%%foo%%-style placeholders can't be used when \" +\n \"'.syntacticPlaceholders' is false.\",\n );\n }\n name = node.name.name;\n hasSyntacticPlaceholders = true;\n } else if (hasSyntacticPlaceholders || state.syntacticPlaceholders) {\n return;\n } else if (isIdentifier(node) || isJSXIdentifier(node)) {\n name = node.name;\n } else if (isStringLiteral(node)) {\n name = node.value;\n } else {\n return;\n }\n\n if (\n hasSyntacticPlaceholders &&\n (state.placeholderPattern != null || state.placeholderWhitelist != null)\n ) {\n // This check is also in options.js. We need it there to handle the default\n // .syntacticPlaceholders behavior.\n throw new Error(\n \"'.placeholderWhitelist' and '.placeholderPattern' aren't compatible\" +\n \" with '.syntacticPlaceholders: true'\",\n );\n }\n\n if (\n !hasSyntacticPlaceholders &&\n (state.placeholderPattern === false ||\n !(state.placeholderPattern || PATTERN).test(name)) &&\n !state.placeholderWhitelist?.has(name)\n ) {\n return;\n }\n\n // Keep our own copy of the ancestors so we can use it in .resolve().\n ancestors = ancestors.slice();\n\n const { node: parent, key } = ancestors[ancestors.length - 1];\n\n let type: PlaceholderType;\n if (\n isStringLiteral(node) ||\n isPlaceholder(node, { expectedNode: \"StringLiteral\" })\n ) {\n type = \"string\";\n } else if (\n (isNewExpression(parent) && key === \"arguments\") ||\n (isCallExpression(parent) && key === \"arguments\") ||\n (isFunction(parent) && key === \"params\")\n ) {\n type = \"param\";\n } else if (isExpressionStatement(parent) && !isPlaceholder(node)) {\n type = \"statement\";\n ancestors = ancestors.slice(0, -1);\n } else if (isStatement(node) && isPlaceholder(node)) {\n type = \"statement\";\n } else {\n type = \"other\";\n }\n\n const { placeholders, placeholderNames } = !hasSyntacticPlaceholders\n ? state.legacy\n : state.syntactic;\n\n placeholders.push({\n name,\n type,\n resolve: ast => resolveAncestors(ast, ancestors),\n isDuplicate: placeholderNames.has(name),\n });\n placeholderNames.add(name);\n}\n\nfunction resolveAncestors(ast: t.File, ancestors: TraversalAncestors) {\n let parent: t.Node = ast;\n for (let i = 0; i < ancestors.length - 1; i++) {\n const { key, index } = ancestors[i];\n\n if (index === undefined) {\n parent = (parent as any)[key];\n } else {\n parent = (parent as any)[key][index];\n }\n }\n\n const { key, index } = ancestors[ancestors.length - 1];\n\n return { parent, key, index };\n}\n\ntype MetadataState = {\n syntactic: {\n placeholders: Placeholder[];\n placeholderNames: Set<string>;\n };\n legacy: {\n placeholders: Placeholder[];\n placeholderNames: Set<string>;\n };\n placeholderWhitelist?: Set<string>;\n placeholderPattern?: RegExp | false;\n syntacticPlaceholders?: boolean;\n};\n\nfunction parseWithCodeFrame(\n code: string,\n parserOpts: ParserOpts,\n syntacticPlaceholders?: boolean,\n): t.File {\n const plugins = (parserOpts.plugins || []).slice();\n if (syntacticPlaceholders !== false) {\n plugins.push(\"placeholders\");\n }\n\n parserOpts = {\n allowAwaitOutsideFunction: true,\n allowReturnOutsideFunction: true,\n allowNewTargetOutsideFunction: true,\n allowSuperOutsideMethod: true,\n allowYieldOutsideFunction: true,\n sourceType: \"module\",\n ...parserOpts,\n plugins,\n };\n\n try {\n return parse(code, parserOpts);\n } catch (err) {\n const loc = err.loc;\n if (loc) {\n err.message += \"\\n\" + codeFrameColumns(code, { start: loc });\n err.code = \"BABEL_TEMPLATE_PARSE_ERROR\";\n }\n throw err;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,EAAA,GAAAC,OAAA;AAeA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAAqD;EAfnDG,gBAAgB;EAChBC,qBAAqB;EACrBC,UAAU;EACVC,YAAY;EACZC,eAAe;EACfC,eAAe;EACfC,aAAa;EACbC,WAAW;EACXC,eAAe;EACfC,oBAAoB;EACpBC;AAAQ,IAAAd,EAAA;AAuBV,MAAMe,OAAO,GAAG,eAAe;AAEhB,SAASC,qBAAqBA,CAC3CC,SAAuB,EACvBC,IAAY,EACZC,IAAkB,EACR;EACV,MAAM;IACJC,oBAAoB;IACpBC,kBAAkB;IAClBC,gBAAgB;IAChBC;EACF,CAAC,GAAGJ,IAAI;EAER,MAAMK,GAAG,GAAGC,kBAAkB,CAACP,IAAI,EAAEC,IAAI,CAACO,MAAM,EAAEH,qBAAqB,CAAC;EAExEV,oBAAoB,CAACW,GAAG,EAAE;IACxBF;EACF,CAAC,CAAC;EAEFL,SAAS,CAACU,QAAQ,CAACH,GAAG,CAAC;EAEvB,MAAMI,KAAoB,GAAG;IAC3BC,SAAS,EAAE;MAAEC,Y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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = populatePlaceholders;
|
| 7 |
+
var _t = require("@babel/types");
|
| 8 |
+
const {
|
| 9 |
+
blockStatement,
|
| 10 |
+
cloneNode,
|
| 11 |
+
emptyStatement,
|
| 12 |
+
expressionStatement,
|
| 13 |
+
identifier,
|
| 14 |
+
isStatement,
|
| 15 |
+
isStringLiteral,
|
| 16 |
+
stringLiteral,
|
| 17 |
+
validate
|
| 18 |
+
} = _t;
|
| 19 |
+
function populatePlaceholders(metadata, replacements) {
|
| 20 |
+
const ast = cloneNode(metadata.ast);
|
| 21 |
+
if (replacements) {
|
| 22 |
+
metadata.placeholders.forEach(placeholder => {
|
| 23 |
+
if (!hasOwnProperty.call(replacements, placeholder.name)) {
|
| 24 |
+
const placeholderName = placeholder.name;
|
| 25 |
+
throw new Error(`Error: No substitution given for "${placeholderName}". If this is not meant to be a
|
| 26 |
+
placeholder you may want to consider passing one of the following options to @babel/template:
|
| 27 |
+
- { placeholderPattern: false, placeholderWhitelist: new Set(['${placeholderName}'])}
|
| 28 |
+
- { placeholderPattern: /^${placeholderName}$/ }`);
|
| 29 |
+
}
|
| 30 |
+
});
|
| 31 |
+
Object.keys(replacements).forEach(key => {
|
| 32 |
+
if (!metadata.placeholderNames.has(key)) {
|
| 33 |
+
throw new Error(`Unknown substitution "${key}" given`);
|
| 34 |
+
}
|
| 35 |
+
});
|
| 36 |
+
}
|
| 37 |
+
metadata.placeholders.slice().reverse().forEach(placeholder => {
|
| 38 |
+
try {
|
| 39 |
+
var _ref;
|
| 40 |
+
applyReplacement(placeholder, ast, (_ref = replacements && replacements[placeholder.name]) != null ? _ref : null);
|
| 41 |
+
} catch (e) {
|
| 42 |
+
e.message = `@babel/template placeholder "${placeholder.name}": ${e.message}`;
|
| 43 |
+
throw e;
|
| 44 |
+
}
|
| 45 |
+
});
|
| 46 |
+
return ast;
|
| 47 |
+
}
|
| 48 |
+
function applyReplacement(placeholder, ast, replacement) {
|
| 49 |
+
if (placeholder.isDuplicate) {
|
| 50 |
+
if (Array.isArray(replacement)) {
|
| 51 |
+
replacement = replacement.map(node => cloneNode(node));
|
| 52 |
+
} else if (typeof replacement === "object") {
|
| 53 |
+
replacement = cloneNode(replacement);
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
const {
|
| 57 |
+
parent,
|
| 58 |
+
key,
|
| 59 |
+
index
|
| 60 |
+
} = placeholder.resolve(ast);
|
| 61 |
+
if (placeholder.type === "string") {
|
| 62 |
+
if (typeof replacement === "string") {
|
| 63 |
+
replacement = stringLiteral(replacement);
|
| 64 |
+
}
|
| 65 |
+
if (!replacement || !isStringLiteral(replacement)) {
|
| 66 |
+
throw new Error("Expected string substitution");
|
| 67 |
+
}
|
| 68 |
+
} else if (placeholder.type === "statement") {
|
| 69 |
+
if (index === undefined) {
|
| 70 |
+
if (!replacement) {
|
| 71 |
+
replacement = emptyStatement();
|
| 72 |
+
} else if (Array.isArray(replacement)) {
|
| 73 |
+
replacement = blockStatement(replacement);
|
| 74 |
+
} else if (typeof replacement === "string") {
|
| 75 |
+
replacement = expressionStatement(identifier(replacement));
|
| 76 |
+
} else if (!isStatement(replacement)) {
|
| 77 |
+
replacement = expressionStatement(replacement);
|
| 78 |
+
}
|
| 79 |
+
} else {
|
| 80 |
+
if (replacement && !Array.isArray(replacement)) {
|
| 81 |
+
if (typeof replacement === "string") {
|
| 82 |
+
replacement = identifier(replacement);
|
| 83 |
+
}
|
| 84 |
+
if (!isStatement(replacement)) {
|
| 85 |
+
replacement = expressionStatement(replacement);
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
} else if (placeholder.type === "param") {
|
| 90 |
+
if (typeof replacement === "string") {
|
| 91 |
+
replacement = identifier(replacement);
|
| 92 |
+
}
|
| 93 |
+
if (index === undefined) throw new Error("Assertion failure.");
|
| 94 |
+
} else {
|
| 95 |
+
if (typeof replacement === "string") {
|
| 96 |
+
replacement = identifier(replacement);
|
| 97 |
+
}
|
| 98 |
+
if (Array.isArray(replacement)) {
|
| 99 |
+
throw new Error("Cannot replace single expression with an array.");
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
function set(parent, key, value) {
|
| 103 |
+
const node = parent[key];
|
| 104 |
+
parent[key] = value;
|
| 105 |
+
if (node.type === "Identifier" || node.type === "Placeholder") {
|
| 106 |
+
if (node.typeAnnotation) {
|
| 107 |
+
value.typeAnnotation = node.typeAnnotation;
|
| 108 |
+
}
|
| 109 |
+
if (node.optional) {
|
| 110 |
+
value.optional = node.optional;
|
| 111 |
+
}
|
| 112 |
+
if (node.decorators) {
|
| 113 |
+
value.decorators = node.decorators;
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
if (index === undefined) {
|
| 118 |
+
validate(parent, key, replacement);
|
| 119 |
+
set(parent, key, replacement);
|
| 120 |
+
} else {
|
| 121 |
+
const items = parent[key].slice();
|
| 122 |
+
if (placeholder.type === "statement" || placeholder.type === "param") {
|
| 123 |
+
if (replacement == null) {
|
| 124 |
+
items.splice(index, 1);
|
| 125 |
+
} else if (Array.isArray(replacement)) {
|
| 126 |
+
items.splice(index, 1, ...replacement);
|
| 127 |
+
} else {
|
| 128 |
+
set(items, index, replacement);
|
| 129 |
+
}
|
| 130 |
+
} else {
|
| 131 |
+
set(items, index, replacement);
|
| 132 |
+
}
|
| 133 |
+
validate(parent, key, items);
|
| 134 |
+
parent[key] = items;
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
//# sourceMappingURL=populate.js.map
|
node_modules/@babel/template/lib/populate.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_t","require","blockStatement","cloneNode","emptyStatement","expressionStatement","identifier","isStatement","isStringLiteral","stringLiteral","validate","populatePlaceholders","metadata","replacements","ast","placeholders","forEach","placeholder","hasOwnProperty","call","name","placeholderName","Error","Object","keys","key","placeholderNames","has","slice","reverse","_ref","applyReplacement","e","message","replacement","isDuplicate","Array","isArray","map","node","parent","index","resolve","type","undefined","set","value","typeAnnotation","optional","decorators","items","splice"],"sources":["../src/populate.ts"],"sourcesContent":["import {\n blockStatement,\n cloneNode,\n emptyStatement,\n expressionStatement,\n identifier,\n isStatement,\n isStringLiteral,\n stringLiteral,\n validate,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nimport type { TemplateReplacements } from \"./options.ts\";\nimport type { Metadata, Placeholder } from \"./parse.ts\";\n\nexport default function populatePlaceholders(\n metadata: Metadata,\n replacements: TemplateReplacements,\n): t.File {\n const ast = cloneNode(metadata.ast);\n\n if (replacements) {\n metadata.placeholders.forEach(placeholder => {\n if (!Object.hasOwn(replacements, placeholder.name)) {\n const placeholderName = placeholder.name;\n\n throw new Error(\n `Error: No substitution given for \"${placeholderName}\". If this is not meant to be a\n placeholder you may want to consider passing one of the following options to @babel/template:\n - { placeholderPattern: false, placeholderWhitelist: new Set(['${placeholderName}'])}\n - { placeholderPattern: /^${placeholderName}$/ }`,\n );\n }\n });\n Object.keys(replacements).forEach(key => {\n if (!metadata.placeholderNames.has(key)) {\n throw new Error(`Unknown substitution \"${key}\" given`);\n }\n });\n }\n\n // Process in reverse order so AST mutation doesn't change indices that\n // will be needed for later calls to `placeholder.resolve()`.\n metadata.placeholders\n .slice()\n .reverse()\n .forEach(placeholder => {\n try {\n applyReplacement(\n placeholder,\n ast,\n (replacements && replacements[placeholder.name]) ?? null,\n );\n } catch (e) {\n e.message = `@babel/template placeholder \"${placeholder.name}\": ${e.message}`;\n throw e;\n }\n });\n\n return ast;\n}\n\nfunction applyReplacement(\n placeholder: Placeholder,\n ast: t.File,\n replacement: any,\n) {\n // Track inserted nodes and clone them if they are inserted more than\n // once to avoid injecting the same node multiple times.\n if (placeholder.isDuplicate) {\n if (Array.isArray(replacement)) {\n replacement = replacement.map(node => cloneNode(node));\n } else if (typeof replacement === \"object\") {\n replacement = cloneNode(replacement);\n }\n }\n\n const { parent, key, index } = placeholder.resolve(ast);\n\n if (placeholder.type === \"string\") {\n if (typeof replacement === \"string\") {\n replacement = stringLiteral(replacement);\n }\n if (!replacement || !isStringLiteral(replacement)) {\n throw new Error(\"Expected string substitution\");\n }\n } else if (placeholder.type === \"statement\") {\n if (index === undefined) {\n if (!replacement) {\n replacement = emptyStatement();\n } else if (Array.isArray(replacement)) {\n replacement = blockStatement(replacement);\n } else if (typeof replacement === \"string\") {\n replacement = expressionStatement(identifier(replacement));\n } else if (!isStatement(replacement)) {\n replacement = expressionStatement(replacement);\n }\n } else {\n if (replacement && !Array.isArray(replacement)) {\n if (typeof replacement === \"string\") {\n replacement = identifier(replacement);\n }\n if (!isStatement(replacement)) {\n replacement = expressionStatement(replacement);\n }\n }\n }\n } else if (placeholder.type === \"param\") {\n if (typeof replacement === \"string\") {\n replacement = identifier(replacement);\n }\n\n if (index === undefined) throw new Error(\"Assertion failure.\");\n } else {\n if (typeof replacement === \"string\") {\n replacement = identifier(replacement);\n }\n if (Array.isArray(replacement)) {\n throw new Error(\"Cannot replace single expression with an array.\");\n }\n }\n\n function set(parent: any, key: any, value: any) {\n const node = parent[key] as t.Node;\n parent[key] = value;\n if (node.type === \"Identifier\" || node.type === \"Placeholder\") {\n if (node.typeAnnotation) {\n value.typeAnnotation = node.typeAnnotation;\n }\n if (node.optional) {\n value.optional = node.optional;\n }\n if (node.decorators) {\n value.decorators = node.decorators;\n }\n }\n }\n\n if (index === undefined) {\n validate(parent, key, replacement);\n\n set(parent, key, replacement);\n } else {\n const items: t.Node[] = (parent as any)[key].slice();\n\n if (placeholder.type === \"statement\" || placeholder.type === \"param\") {\n if (replacement == null) {\n items.splice(index, 1);\n } else if (Array.isArray(replacement)) {\n items.splice(index, 1, ...replacement);\n } else {\n set(items, index, replacement);\n }\n } else {\n set(items, index, replacement);\n }\n\n validate(parent, key, items);\n (parent as any)[key] = items;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,EAAA,GAAAC,OAAA;AAUsB;EATpBC,cAAc;EACdC,SAAS;EACTC,cAAc;EACdC,mBAAmB;EACnBC,UAAU;EACVC,WAAW;EACXC,eAAe;EACfC,aAAa;EACbC;AAAQ,IAAAV,EAAA;AAOK,SAASW,oBAAoBA,CAC1CC,QAAkB,EAClBC,YAAkC,EAC1B;EACR,MAAMC,GAAG,GAAGX,SAAS,CAACS,QAAQ,CAACE,GAAG,CAAC;EAEnC,IAAID,YAAY,EAAE;IAChBD,QAAQ,CAACG,YAAY,CAACC,OAAO,CAACC,WAAW,IAAI;MAC3C,IAAI,CAACC,cAAA,CAAAC,IAAA,CAAcN,YAAY,EAAEI,WAAW,CAACG,IAAI,CAAC,EAAE;QAClD,MAAMC,eAAe,GAAGJ,WAAW,CAACG,IAAI;QAExC,MAAM,IAAIE,KAAK,CACb,qCAAqCD,eAAe;AAC9D;AACA,6EAA6EA,eAAe;AAC5F,wCAAwCA,eAAe,MAC/C,CAAC;MACH;IACF,CA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IT,WAAW,IAAI,IAAI,EAAE;QACvBgB,KAAK,CAACC,MAAM,CAACV,KAAK,EAAE,CAAC,CAAC;MACxB,CAAC,MAAM,IAAIL,KAAK,CAACC,OAAO,CAACH,WAAW,CAAC,EAAE;QACrCgB,KAAK,CAACC,MAAM,CAACV,KAAK,EAAE,CAAC,EAAE,GAAGP,WAAW,CAAC;MACxC,CAAC,MAAM;QACLW,GAAG,CAACK,KAAK,EAAET,KAAK,EAAEP,WAAW,CAAC;MAChC;IACF,CAAC,MAAM;MACLW,GAAG,CAACK,KAAK,EAAET,KAAK,EAAEP,WAAW,CAAC;IAChC;IAEAxB,QAAQ,CAAC8B,MAAM,EAAEf,GAAG,EAAEyB,KAAK,CAAC;IAC3BV,MAAM,CAASf,GAAG,CAAC,GAAGyB,KAAK;EAC9B;AACF","ignoreList":[]}
|
node_modules/@babel/template/lib/string.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = stringTemplate;
|
| 7 |
+
var _options = require("./options.js");
|
| 8 |
+
var _parse = require("./parse.js");
|
| 9 |
+
var _populate = require("./populate.js");
|
| 10 |
+
function stringTemplate(formatter, code, opts) {
|
| 11 |
+
code = formatter.code(code);
|
| 12 |
+
let metadata;
|
| 13 |
+
return arg => {
|
| 14 |
+
const replacements = (0, _options.normalizeReplacements)(arg);
|
| 15 |
+
if (!metadata) metadata = (0, _parse.default)(formatter, code, opts);
|
| 16 |
+
return formatter.unwrap((0, _populate.default)(metadata, replacements));
|
| 17 |
+
};
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
//# sourceMappingURL=string.js.map
|
node_modules/@babel/template/lib/string.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_options","require","_parse","_populate","stringTemplate","formatter","code","opts","metadata","arg","replacements","normalizeReplacements","parseAndBuildMetadata","unwrap","populatePlaceholders"],"sources":["../src/string.ts"],"sourcesContent":["import type { Formatter } from \"./formatters.ts\";\nimport type { TemplateOpts } from \"./options.ts\";\nimport type { Metadata } from \"./parse.ts\";\nimport { normalizeReplacements } from \"./options.ts\";\nimport parseAndBuildMetadata from \"./parse.ts\";\nimport populatePlaceholders from \"./populate.ts\";\n\nexport default function stringTemplate<T>(\n formatter: Formatter<T>,\n code: string,\n opts: TemplateOpts,\n): (arg?: unknown) => T {\n code = formatter.code(code);\n\n let metadata: Metadata;\n\n return (arg?: unknown) => {\n const replacements = normalizeReplacements(arg);\n\n if (!metadata) metadata = parseAndBuildMetadata(formatter, code, opts);\n\n return formatter.unwrap(populatePlaceholders(metadata, replacements));\n };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEe,SAASG,cAAcA,CACpCC,SAAuB,EACvBC,IAAY,EACZC,IAAkB,EACI;EACtBD,IAAI,GAAGD,SAAS,CAACC,IAAI,CAACA,IAAI,CAAC;EAE3B,IAAIE,QAAkB;EAEtB,OAAQC,GAAa,IAAK;IACxB,MAAMC,YAAY,GAAG,IAAAC,8BAAqB,EAACF,GAAG,CAAC;IAE/C,IAAI,CAACD,QAAQ,EAAEA,QAAQ,GAAG,IAAAI,cAAqB,EAACP,SAAS,EAAEC,IAAI,EAAEC,IAAI,CAAC;IAEtE,OAAOF,SAAS,CAACQ,MAAM,CAAC,IAAAC,iBAAoB,EAACN,QAAQ,EAAEE,YAAY,CAAC,CAAC;EACvE,CAAC;AACH","ignoreList":[]}
|
node_modules/@babel/template/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@babel/template",
|
| 3 |
+
"version": "7.29.7",
|
| 4 |
+
"description": "Generate an AST from a string template.",
|
| 5 |
+
"author": "The Babel Team (https://babel.dev/team)",
|
| 6 |
+
"homepage": "https://babel.dev/docs/en/next/babel-template",
|
| 7 |
+
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20template%22+is%3Aopen",
|
| 8 |
+
"license": "MIT",
|
| 9 |
+
"publishConfig": {
|
| 10 |
+
"access": "public"
|
| 11 |
+
},
|
| 12 |
+
"repository": {
|
| 13 |
+
"type": "git",
|
| 14 |
+
"url": "https://github.com/babel/babel.git",
|
| 15 |
+
"directory": "packages/babel-template"
|
| 16 |
+
},
|
| 17 |
+
"main": "./lib/index.js",
|
| 18 |
+
"dependencies": {
|
| 19 |
+
"@babel/code-frame": "^7.29.7",
|
| 20 |
+
"@babel/parser": "^7.29.7",
|
| 21 |
+
"@babel/types": "^7.29.7"
|
| 22 |
+
},
|
| 23 |
+
"engines": {
|
| 24 |
+
"node": ">=6.9.0"
|
| 25 |
+
},
|
| 26 |
+
"type": "commonjs"
|
| 27 |
+
}
|
node_modules/@babel/traverse/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 6 |
+
a copy of this software and associated documentation files (the
|
| 7 |
+
"Software"), to deal in the Software without restriction, including
|
| 8 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 9 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 10 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 11 |
+
the following conditions:
|
| 12 |
+
|
| 13 |
+
The above copyright notice and this permission notice shall be
|
| 14 |
+
included in all copies or substantial portions of the Software.
|
| 15 |
+
|
| 16 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 17 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 18 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 19 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
| 20 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 21 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 22 |
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/@babel/traverse/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @babel/traverse
|
| 2 |
+
|
| 3 |
+
> The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
|
| 4 |
+
|
| 5 |
+
See our website [@babel/traverse](https://babeljs.io/docs/babel-traverse) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20traverse%22+is%3Aopen) associated with this package.
|
| 6 |
+
|
| 7 |
+
## Install
|
| 8 |
+
|
| 9 |
+
Using npm:
|
| 10 |
+
|
| 11 |
+
```sh
|
| 12 |
+
npm install --save-dev @babel/traverse
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
or using yarn:
|
| 16 |
+
|
| 17 |
+
```sh
|
| 18 |
+
yarn add @babel/traverse --dev
|
| 19 |
+
```
|
node_modules/@babel/traverse/lib/cache.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.clear = clear;
|
| 7 |
+
exports.clearPath = clearPath;
|
| 8 |
+
exports.clearScope = clearScope;
|
| 9 |
+
exports.getCachedPaths = getCachedPaths;
|
| 10 |
+
exports.getOrCreateCachedPaths = getOrCreateCachedPaths;
|
| 11 |
+
exports.scope = exports.path = void 0;
|
| 12 |
+
let pathsCache = exports.path = new WeakMap();
|
| 13 |
+
let scope = exports.scope = new WeakMap();
|
| 14 |
+
function clear() {
|
| 15 |
+
clearPath();
|
| 16 |
+
clearScope();
|
| 17 |
+
}
|
| 18 |
+
function clearPath() {
|
| 19 |
+
exports.path = pathsCache = new WeakMap();
|
| 20 |
+
}
|
| 21 |
+
function clearScope() {
|
| 22 |
+
exports.scope = scope = new WeakMap();
|
| 23 |
+
}
|
| 24 |
+
function getCachedPaths(path) {
|
| 25 |
+
const {
|
| 26 |
+
parent,
|
| 27 |
+
parentPath
|
| 28 |
+
} = path;
|
| 29 |
+
return pathsCache.get(parent);
|
| 30 |
+
}
|
| 31 |
+
function getOrCreateCachedPaths(node, parentPath) {
|
| 32 |
+
let paths = pathsCache.get(node);
|
| 33 |
+
if (!paths) pathsCache.set(node, paths = new Map());
|
| 34 |
+
return paths;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
//# sourceMappingURL=cache.js.map
|
node_modules/@babel/traverse/lib/cache.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["pathsCache","exports","path","WeakMap","scope","clear","clearPath","clearScope","getCachedPaths","parent","parentPath","get","getOrCreateCachedPaths","node","paths","set","Map"],"sources":["../src/cache.ts"],"sourcesContent":["import type { Node } from \"@babel/types\";\nimport type NodePath from \"./path/index.ts\";\nimport type Scope from \"./scope/index.ts\";\n\nlet pathsCache = new WeakMap<Node, Map<Node, NodePath>>();\nexport { pathsCache as path };\nexport let scope = new WeakMap<Node, Scope>();\n\nexport function clear() {\n clearPath();\n clearScope();\n}\n\nexport function clearPath() {\n pathsCache = new WeakMap();\n}\n\nexport function clearScope() {\n scope = new WeakMap();\n}\n\nexport function getCachedPaths(path: NodePath) {\n const { parent, parentPath } = path;\n return process.env.BABEL_8_BREAKING && parentPath\n ? parentPath._store\n : pathsCache.get(parent);\n}\n\nexport function getOrCreateCachedPaths(\n node: Node,\n parentPath?: NodePath | null,\n) {\n if (process.env.BABEL_8_BREAKING && parentPath) {\n return (parentPath._store ||= new Map());\n }\n\n let paths = pathsCache.get(node);\n if (!paths) pathsCache.set(node, (paths = new Map()));\n\n return paths;\n}\n"],"mappings":";;;;;;;;;;;AAIA,IAAIA,UAAU,GAAAC,OAAA,CAAAC,IAAA,GAAG,IAAIC,OAAO,CAA4B,CAAC;AAElD,IAAIC,KAAK,GAAAH,OAAA,CAAAG,KAAA,GAAG,IAAID,OAAO,CAAc,CAAC;AA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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
var _index = require("./path/index.js");
|
| 8 |
+
var _t = require("@babel/types");
|
| 9 |
+
var _context = require("./path/context.js");
|
| 10 |
+
var _hub = require("./hub.js");
|
| 11 |
+
const {
|
| 12 |
+
VISITOR_KEYS
|
| 13 |
+
} = _t;
|
| 14 |
+
class TraversalContext {
|
| 15 |
+
constructor(scope, opts, state, parentPath) {
|
| 16 |
+
this.queue = null;
|
| 17 |
+
this.priorityQueue = null;
|
| 18 |
+
this.parentPath = parentPath;
|
| 19 |
+
this.scope = scope;
|
| 20 |
+
this.state = state;
|
| 21 |
+
this.opts = opts;
|
| 22 |
+
}
|
| 23 |
+
shouldVisit(node) {
|
| 24 |
+
const opts = this.opts;
|
| 25 |
+
if (opts.enter || opts.exit) return true;
|
| 26 |
+
if (opts[node.type]) return true;
|
| 27 |
+
const keys = VISITOR_KEYS[node.type];
|
| 28 |
+
if (!(keys != null && keys.length)) return false;
|
| 29 |
+
for (const key of keys) {
|
| 30 |
+
if (node[key]) {
|
| 31 |
+
return true;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
return false;
|
| 35 |
+
}
|
| 36 |
+
create(node, container, key, listKey) {
|
| 37 |
+
const {
|
| 38 |
+
parentPath
|
| 39 |
+
} = this;
|
| 40 |
+
const hub = parentPath == null ? node.type === "Program" || node.type === "File" ? new _hub.default() : undefined : parentPath.hub;
|
| 41 |
+
return _index.default.get({
|
| 42 |
+
parentPath,
|
| 43 |
+
parent: node,
|
| 44 |
+
container,
|
| 45 |
+
key: key,
|
| 46 |
+
listKey,
|
| 47 |
+
hub
|
| 48 |
+
});
|
| 49 |
+
}
|
| 50 |
+
maybeQueue(path, notPriority) {
|
| 51 |
+
if (this.queue) {
|
| 52 |
+
if (notPriority) {
|
| 53 |
+
this.queue.push(path);
|
| 54 |
+
} else {
|
| 55 |
+
this.priorityQueue.push(path);
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
visitMultiple(container, parent, listKey) {
|
| 60 |
+
if (container.length === 0) return false;
|
| 61 |
+
const queue = [];
|
| 62 |
+
for (let key = 0; key < container.length; key++) {
|
| 63 |
+
const node = container[key];
|
| 64 |
+
if (node && this.shouldVisit(node)) {
|
| 65 |
+
queue.push(this.create(parent, container, key, listKey));
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
return this.visitQueue(queue);
|
| 69 |
+
}
|
| 70 |
+
visitSingle(node, key) {
|
| 71 |
+
if (this.shouldVisit(node[key])) {
|
| 72 |
+
return this.visitQueue([this.create(node, node, key)]);
|
| 73 |
+
} else {
|
| 74 |
+
return false;
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
visitQueue(queue) {
|
| 78 |
+
this.queue = queue;
|
| 79 |
+
this.priorityQueue = [];
|
| 80 |
+
const visited = new WeakSet();
|
| 81 |
+
let stop = false;
|
| 82 |
+
let visitIndex = 0;
|
| 83 |
+
for (; visitIndex < queue.length;) {
|
| 84 |
+
const path = queue[visitIndex];
|
| 85 |
+
visitIndex++;
|
| 86 |
+
_context.resync.call(path);
|
| 87 |
+
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
|
| 88 |
+
_context.pushContext.call(path, this);
|
| 89 |
+
}
|
| 90 |
+
if (path.key === null) continue;
|
| 91 |
+
const {
|
| 92 |
+
node
|
| 93 |
+
} = path;
|
| 94 |
+
if (visited.has(node)) continue;
|
| 95 |
+
if (node) visited.add(node);
|
| 96 |
+
if (path.visit()) {
|
| 97 |
+
stop = true;
|
| 98 |
+
break;
|
| 99 |
+
}
|
| 100 |
+
if (this.priorityQueue.length) {
|
| 101 |
+
stop = this.visitQueue(this.priorityQueue);
|
| 102 |
+
this.priorityQueue = [];
|
| 103 |
+
this.queue = queue;
|
| 104 |
+
if (stop) break;
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
for (let i = 0; i < visitIndex; i++) {
|
| 108 |
+
_context.popContext.call(queue[i]);
|
| 109 |
+
}
|
| 110 |
+
this.queue = null;
|
| 111 |
+
return stop;
|
| 112 |
+
}
|
| 113 |
+
visit(node, key) {
|
| 114 |
+
const nodes = node[key];
|
| 115 |
+
if (!nodes) return false;
|
| 116 |
+
if (Array.isArray(nodes)) {
|
| 117 |
+
return this.visitMultiple(nodes, node, key);
|
| 118 |
+
} else {
|
| 119 |
+
return this.visitSingle(node, key);
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
exports.default = TraversalContext;
|
| 124 |
+
|
| 125 |
+
//# sourceMappingURL=context.js.map
|
node_modules/@babel/traverse/lib/context.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_index","require","_t","_context","_hub","VISITOR_KEYS","TraversalContext","constructor","scope","opts","state","parentPath","queue","priorityQueue","shouldVisit","node","enter","exit","type","keys","length","key","create","container","listKey","hub","Hub","undefined","NodePath","get","parent","maybeQueue","path","notPriority","push","visitMultiple","visitQueue","visitSingle","visited","WeakSet","stop","visitIndex","resync","call","contexts","pushContext","has","add","visit","i","popContext","nodes","Array","isArray","exports","default"],"sources":["../src/context.ts"],"sourcesContent":["import NodePath from \"./path/index.ts\";\nimport { VISITOR_KEYS } from \"@babel/types\";\nimport type Scope from \"./scope/index.ts\";\nimport type { ExplodedTraverseOptions } from \"./index.ts\";\nimport type * as t from \"@babel/types\";\nimport type { Visitor } from \"./types.ts\";\nimport { popContext, pushContext, resync } from \"./path/context.ts\";\nimport Hub from \"./hub.ts\";\n\nexport default class TraversalContext<S = unknown> {\n constructor(\n scope: Scope | null | undefined,\n opts: ExplodedTraverseOptions<S>,\n state: S,\n parentPath: NodePath | undefined,\n ) {\n this.parentPath = parentPath;\n this.scope = scope;\n this.state = state;\n this.opts = opts;\n }\n\n declare parentPath: NodePath | undefined;\n declare scope: Scope | null | undefined;\n declare state: S;\n declare opts: ExplodedTraverseOptions<S>;\n queue: NodePath[] | null = null;\n priorityQueue: NodePath[] | null = null;\n\n /**\n * This method does a simple check to determine whether or not we really need to attempt\n * visit a node. This will prevent us from constructing a NodePath.\n */\n\n shouldVisit(node: t.Node): boolean {\n const opts = this.opts as Visitor;\n if (opts.enter || opts.exit) return true;\n\n // check if we have a visitor for this node\n if (opts[node.type]) return true;\n\n // check if we're going to traverse into this node\n const keys: string[] | undefined = VISITOR_KEYS[node.type];\n if (!keys?.length) return false;\n\n // we need to traverse into this node so ensure that it has children to traverse into!\n for (const key of keys) {\n if (\n // @ts-expect-error key is from visitor keys\n node[key]\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n create(\n node: t.Node,\n container: t.Node | t.Node[],\n key: string | number,\n listKey?: string,\n ): NodePath {\n const { parentPath } = this;\n const hub =\n parentPath == null\n ? node.type === \"Program\" || node.type === \"File\"\n ? new Hub()\n : undefined\n : parentPath.hub;\n\n // We don't need to `.setContext()` here, since `.visitQueue()` already\n // calls `.pushContext`.\n return NodePath.get({\n parentPath,\n parent: node,\n container,\n key: key,\n listKey,\n hub,\n });\n }\n\n maybeQueue(path: NodePath, notPriority?: boolean) {\n if (this.queue) {\n if (notPriority) {\n this.queue.push(path);\n } else {\n this.priorityQueue!.push(path);\n }\n }\n }\n\n visitMultiple(container: t.Node[], parent: t.Node, listKey: string) {\n // nothing to traverse!\n if (container.length === 0) return false;\n\n const queue = [];\n\n // build up initial queue\n for (let key = 0; key < container.length; key++) {\n const node = container[key];\n if (node && this.shouldVisit(node)) {\n queue.push(this.create(parent, container, key, listKey));\n }\n }\n\n return this.visitQueue(queue);\n }\n\n visitSingle(node: t.Node, key: string): boolean {\n if (\n this.shouldVisit(\n // @ts-expect-error key may not index node\n node[key],\n )\n ) {\n return this.visitQueue([this.create(node, node, key)]);\n } else {\n return false;\n }\n }\n\n visitQueue(queue: NodePath[]): boolean {\n // set queue\n this.queue = queue;\n this.priorityQueue = [];\n\n const visited = new WeakSet();\n let stop = false;\n let visitIndex = 0;\n\n // visit the queue\n for (; visitIndex < queue.length; ) {\n const path = queue[visitIndex];\n visitIndex++;\n resync.call(path);\n\n // this path no longer belongs to the tree\n if (process.env.BABEL_8_BREAKING && path.key === null) continue;\n\n if (\n path.contexts.length === 0 ||\n path.contexts[path.contexts.length - 1] !== this\n ) {\n // The context might already have been pushed when this path was inserted and queued.\n // If we always re-pushed here, we could get duplicates and risk leaving contexts\n // on the stack after the traversal has completed, which could break things.\n pushContext.call(path, this);\n }\n\n // this path no longer belongs to the tree\n if (!process.env.BABEL_8_BREAKING && path.key === null) continue;\n\n // ensure we don't visit the same node twice\n const { node } = path;\n if (visited.has(node)) continue;\n if (node) visited.add(node);\n\n if (path.visit()) {\n stop = true;\n break;\n }\n\n if (this.priorityQueue.length) {\n stop = this.visitQueue(this.priorityQueue);\n this.priorityQueue = [];\n this.queue = queue;\n if (stop) break;\n }\n }\n\n // pop contexts\n for (let i = 0; i < visitIndex; i++) {\n if (process.env.BABEL_8_BREAKING && queue[i].key === null) continue;\n popContext.call(queue[i]);\n }\n\n // clear queue\n this.queue = null;\n\n return stop;\n }\n\n visit(node: t.Node, key: string) {\n // @ts-expect-error key may not index node\n const nodes = node[key] as t.Node | t.Node[] | null;\n if (!nodes) return false;\n\n if (Array.isArray(nodes)) {\n return this.visitMultiple(nodes, node, key);\n } else {\n return this.visitSingle(node, key);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,EAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAA2B;EANlBI;AAAY,IAAAH,EAAA;AAQN,MAAMI,gBAAgB,CAAc;EACjDC,WAAWA,CACTC,KAA+B,EAC/BC,IAAgC,EAChCC,KAAQ,EACRC,UAAgC,EAChC;IAAA,KAWFC,KAAK,GAAsB,IAAI;IAAA,KAC/BC,aAAa,GAAsB,IAAI;IAXrC,IAAI,CAACF,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACH,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACE,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACD,IAAI,GAAGA,IAAI;EAClB;EAcAK,WAAWA,CAACC,IAAY,EAAW;IACjC,MAAMN,IAAI,GAAG,IAAI,CAACA,IAAe;IACjC,IAAIA,IAAI,CAACO,KAAK,IAAIP,IAAI,CAACQ,IAAI,EAAE,OAAO,IAAI;IAGxC,IAAIR,IAAI,CAACM,IAAI,CAACG,IAAI,CAAC,EAAE,OAAO,IAAI;IAGhC,MAAMC,IAA0B,GAAGd,YAAY,CAACU,IAAI,CAACG,IAAI,CAAC;IAC1D,IAAI,EAACC,IAAI,YAAJA,IAAI,CAAEC,MAAM,GAAE,OAAO,KAAK;IAG/B,KAAK,MAAMC,GAAG,IAAIF,IAAI,EAAE;MACtB,IAEEJ,IAAI,CAACM,GAAG,CAAC,EACT;QACA,OAAO,IAAI;MACb;IACF;IAEA,OAAO,KAAK;EACd;EAEAC,MAAMA,CACJP,IAAY,EACZQ,SAA4B,EAC5BF,GAAoB,EACpBG,OAAgB,EACN;IACV,MAAM;MAAEb;IAAW,CAA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AAI,CAACJ,UAAU,CAAC,IAAI,CAACvB,aAAa,CAAC;QAC1C,IAAI,CAACA,aAAa,GAAG,EAAE;QACvB,IAAI,CAACD,KAAK,GAAGA,KAAK;QAClB,IAAI4B,IAAI,EAAE;MACZ;IACF;IAGA,KAAK,IAAIS,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGR,UAAU,EAAEQ,CAAC,EAAE,EAAE;MAEnCC,mBAAU,CAACP,IAAI,CAAC/B,KAAK,CAACqC,CAAC,CAAC,CAAC;IAC3B;IAGA,IAAI,CAACrC,KAAK,GAAG,IAAI;IAEjB,OAAO4B,IAAI;EACb;EAEAQ,KAAKA,CAACjC,IAAY,EAAEM,GAAW,EAAE;IAE/B,MAAM8B,KAAK,GAAGpC,IAAI,CAACM,GAAG,CAA6B;IACnD,IAAI,CAAC8B,KAAK,EAAE,OAAO,KAAK;IAExB,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACxB,OAAO,IAAI,CAAChB,aAAa,CAACgB,KAAK,EAAEpC,IAAI,EAAEM,GAAG,CAAC;IAC7C,CAAC,MAAM;MACL,OAAO,IAAI,CAACgB,WAAW,CAACtB,IAAI,EAAEM,GAAG,CAAC;IACpC;EACF;AACF;AAACiC,OAAA,CAAAC,OAAA,GAAAjD,gBAAA","ignoreList":[]}
|
node_modules/@babel/traverse/lib/hub.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
class Hub {
|
| 8 |
+
getCode() {}
|
| 9 |
+
getScope() {}
|
| 10 |
+
addHelper() {
|
| 11 |
+
throw new Error("Helpers are not supported by the default hub.");
|
| 12 |
+
}
|
| 13 |
+
buildError(node, msg, Error = TypeError) {
|
| 14 |
+
return new Error(msg);
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
exports.default = Hub;
|
| 18 |
+
|
| 19 |
+
//# sourceMappingURL=hub.js.map
|
node_modules/@babel/traverse/lib/hub.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["Hub","getCode","getScope","addHelper","Error","buildError","node","msg","TypeError","exports","default"],"sources":["../src/hub.ts"],"sourcesContent":["import type Scope from \"./scope/index.ts\";\nimport type { Node } from \"@babel/types\";\n\nexport interface HubInterface {\n getCode(): string | void;\n getScope(): Scope | void;\n addHelper(name: string): any;\n buildError(node: Node, msg: string, Error: new (msg: string) => Error): Error;\n}\n\nexport default class Hub implements HubInterface {\n getCode() {}\n\n getScope() {}\n\n addHelper() {\n throw new Error(\"Helpers are not supported by the default hub.\");\n }\n\n buildError(\n node: Node,\n msg: string,\n Error: new (msg: string) => Error = TypeError,\n ): Error {\n return new Error(msg);\n }\n}\n"],"mappings":";;;;;;AAUe,MAAMA,GAAG,CAAyB;EAC/CC,OAAOA,CAAA,EAAG,CAAC;EAEXC,QAAQA,CAAA,EAAG,CAAC;EAEZC,SAASA,CAAA,EAAG;IACV,MAAM,IAAIC,KAAK,CAAC,+CAA+C,CAAC;EAClE;EAEAC,UAAUA,CACRC,IAAU,EACVC,GAAW,EACXH,KAAiC,GAAGI,SAAS,EACtC;IACP,OAAO,IAAIJ,KAAK,CAACG,GAAG,CAAC;EACvB;AACF;AAACE,OAAA,CAAAC,OAAA,GAAAV,GAAA","ignoreList":[]}
|
node_modules/@babel/traverse/lib/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
Object.defineProperty(exports, "Hub", {
|
| 7 |
+
enumerable: true,
|
| 8 |
+
get: function () {
|
| 9 |
+
return _hub.default;
|
| 10 |
+
}
|
| 11 |
+
});
|
| 12 |
+
Object.defineProperty(exports, "NodePath", {
|
| 13 |
+
enumerable: true,
|
| 14 |
+
get: function () {
|
| 15 |
+
return _index.default;
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
Object.defineProperty(exports, "Scope", {
|
| 19 |
+
enumerable: true,
|
| 20 |
+
get: function () {
|
| 21 |
+
return _index2.default;
|
| 22 |
+
}
|
| 23 |
+
});
|
| 24 |
+
exports.visitors = exports.default = void 0;
|
| 25 |
+
require("./path/context.js");
|
| 26 |
+
var visitors = require("./visitors.js");
|
| 27 |
+
exports.visitors = visitors;
|
| 28 |
+
var _t = require("@babel/types");
|
| 29 |
+
var cache = require("./cache.js");
|
| 30 |
+
var _traverseNode = require("./traverse-node.js");
|
| 31 |
+
var _index = require("./path/index.js");
|
| 32 |
+
var _index2 = require("./scope/index.js");
|
| 33 |
+
var _hub = require("./hub.js");
|
| 34 |
+
const {
|
| 35 |
+
VISITOR_KEYS,
|
| 36 |
+
removeProperties,
|
| 37 |
+
traverseFast
|
| 38 |
+
} = _t;
|
| 39 |
+
function traverse(parent, opts = {}, scope, state, parentPath, visitSelf) {
|
| 40 |
+
if (!parent) return;
|
| 41 |
+
if (!opts.noScope && !scope) {
|
| 42 |
+
if (parent.type !== "Program" && parent.type !== "File") {
|
| 43 |
+
throw new Error("You must pass a scope and parentPath unless traversing a Program/File. " + `Instead of that you tried to traverse a ${parent.type} node without ` + "passing scope and parentPath.");
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
if (!parentPath && visitSelf) {
|
| 47 |
+
throw new Error("visitSelf can only be used when providing a NodePath.");
|
| 48 |
+
}
|
| 49 |
+
if (!VISITOR_KEYS[parent.type]) {
|
| 50 |
+
return;
|
| 51 |
+
}
|
| 52 |
+
visitors.explode(opts);
|
| 53 |
+
(0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath, undefined, visitSelf);
|
| 54 |
+
}
|
| 55 |
+
var _default = exports.default = traverse;
|
| 56 |
+
traverse.visitors = visitors;
|
| 57 |
+
traverse.verify = visitors.verify;
|
| 58 |
+
traverse.explode = visitors.explode;
|
| 59 |
+
traverse.cheap = function (node, enter) {
|
| 60 |
+
traverseFast(node, enter);
|
| 61 |
+
return;
|
| 62 |
+
};
|
| 63 |
+
traverse.node = function (node, opts, scope, state, path, skipKeys) {
|
| 64 |
+
(0, _traverseNode.traverseNode)(node, opts, scope, state, path, skipKeys);
|
| 65 |
+
};
|
| 66 |
+
traverse.clearNode = function (node, opts) {
|
| 67 |
+
removeProperties(node, opts);
|
| 68 |
+
};
|
| 69 |
+
traverse.removeProperties = function (tree, opts) {
|
| 70 |
+
traverseFast(tree, traverse.clearNode, opts);
|
| 71 |
+
return tree;
|
| 72 |
+
};
|
| 73 |
+
traverse.hasType = function (tree, type, denylistTypes) {
|
| 74 |
+
if (denylistTypes != null && denylistTypes.includes(tree.type)) return false;
|
| 75 |
+
if (tree.type === type) return true;
|
| 76 |
+
return traverseFast(tree, function (node) {
|
| 77 |
+
if (denylistTypes != null && denylistTypes.includes(node.type)) {
|
| 78 |
+
return traverseFast.skip;
|
| 79 |
+
}
|
| 80 |
+
if (node.type === type) {
|
| 81 |
+
return traverseFast.stop;
|
| 82 |
+
}
|
| 83 |
+
});
|
| 84 |
+
};
|
| 85 |
+
traverse.cache = cache;
|
| 86 |
+
|
| 87 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@babel/traverse/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["require","visitors","exports","_t","cache","_traverseNode","_index","_index2","_hub","VISITOR_KEYS","removeProperties","traverseFast","traverse","parent","opts","scope","state","parentPath","visitSelf","noScope","type","Error","explode","traverseNode","undefined","_default","default","verify","cheap","node","enter","path","skipKeys","clearNode","tree","hasType","denylistTypes","includes","skip","stop"],"sources":["../src/index.ts"],"sourcesContent":["import \"./path/context.ts\"; // We have some cycles, this ensures correct order to avoid TDZ\nimport * as visitors from \"./visitors.ts\";\nimport {\n VISITOR_KEYS,\n removeProperties,\n type RemovePropertiesOptions,\n traverseFast,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport * as cache from \"./cache.ts\";\nimport type NodePath from \"./path/index.ts\";\nimport type { default as Scope, Binding } from \"./scope/index.ts\";\nimport type { ExplodedVisitor, Visitor, VisitorBase } from \"./types.ts\";\nimport { traverseNode } from \"./traverse-node.ts\";\n\nexport type { ExplodedVisitor, Visitor, VisitorBase, Binding };\nexport { default as NodePath } from \"./path/index.ts\";\nexport { default as Scope, type BindingKind } from \"./scope/index.ts\";\nexport { default as Hub } from \"./hub.ts\";\nexport type { HubInterface } from \"./hub.ts\";\nexport type { VisitWrapper } from \"./visitors.ts\";\n\nexport { visitors };\n\nexport type TraverseOptions<S = t.Node> = {\n scope?: Scope;\n noScope?: boolean;\n denylist?: string[];\n shouldSkip?: (node: NodePath) => boolean;\n} & Visitor<S>;\n\nexport type ExplodedTraverseOptions<S = t.Node> = TraverseOptions<S> &\n ExplodedVisitor<S>;\n\nfunction traverse<S>(\n parent: t.Node,\n opts: TraverseOptions<S>,\n scope: Scope | null | undefined,\n state: S,\n parentPath?: NodePath,\n visitSelf?: boolean,\n): void;\n\nfunction traverse(\n parent: t.Node,\n opts: TraverseOptions,\n scope?: Scope | null,\n state?: any,\n parentPath?: NodePath,\n visitSelf?: boolean,\n): void;\n\nfunction traverse<Options extends TraverseOptions>(\n parent: t.Node,\n // @ts-expect-error provide {} as default value for Options\n opts: Options = {},\n scope?: Scope | null,\n state?: any,\n parentPath?: NodePath,\n visitSelf?: boolean,\n) {\n if (!parent) return;\n\n if (!opts.noScope && !scope) {\n if (parent.type !== \"Program\" && parent.type !== \"File\") {\n throw new Error(\n \"You must pass a scope and parentPath unless traversing a Program/File. \" +\n `Instead of that you tried to traverse a ${parent.type} node without ` +\n \"passing scope and parentPath.\",\n );\n }\n }\n\n if (!parentPath && visitSelf) {\n throw new Error(\"visitSelf can only be used when providing a NodePath.\");\n }\n\n if (!VISITOR_KEYS[parent.type]) {\n return;\n }\n\n visitors.explode(opts as Visitor);\n\n traverseNode(\n parent,\n opts as ExplodedVisitor,\n scope,\n state,\n parentPath,\n /* skipKeys */ undefined,\n visitSelf,\n );\n}\n\nexport default traverse;\n\ntraverse.visitors = visitors;\ntraverse.verify = visitors.verify;\ntraverse.explode = visitors.explode;\n\ntraverse.cheap = function (node: t.Node, enter: (node: t.Node) => void) {\n traverseFast(node, enter);\n return;\n};\n\ntraverse.node = function (\n node: t.Node,\n opts: ExplodedTraverseOptions,\n scope?: Scope,\n state?: any,\n path?: NodePath,\n skipKeys?: Record<string, boolean>,\n) {\n traverseNode(node, opts, scope, state, path, skipKeys);\n // traverse.node always returns undefined\n};\n\ntraverse.clearNode = function (node: t.Node, opts?: RemovePropertiesOptions) {\n removeProperties(node, opts);\n};\n\ntraverse.removeProperties = function (\n tree: t.Node,\n opts?: RemovePropertiesOptions,\n) {\n traverseFast(tree, traverse.clearNode, opts);\n return tree;\n};\n\ntraverse.hasType = function (\n tree: t.Node,\n type: t.Node[\"type\"],\n denylistTypes?: string[],\n): boolean {\n // the node we're searching in is denylisted\n if (denylistTypes?.includes(tree.type)) return false;\n\n // the type we're looking for is the same as the passed node\n if (tree.type === type) return true;\n\n return traverseFast(tree, function (node) {\n if (denylistTypes?.includes(node.type)) {\n return traverseFast.skip;\n }\n if (node.type === type) {\n return traverseFast.stop;\n }\n });\n};\n\ntraverse.cache = cache;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAA0CE,OAAA,CAAAD,QAAA,GAAAA,QAAA;AAC1C,IAAAE,EAAA,GAAAH,OAAA;AAOA,IAAAI,KAAA,GAAAJ,OAAA;AAIA,IAAAK,aAAA,GAAAL,OAAA;AAGA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,IAAA,GAAAR,OAAA;AAA0C;EAfxCS,YAAY;EACZC,gBAAgB;EAEhBC;AAAY,IAAAR,EAAA;AA8Cd,SAASS,QAAQA,CACfC,MAAc,EAEdC,IAAa,GAAG,CAAC,CAAC,EAClBC,KAAoB,EACpBC,KAAW,EACXC,UAAqB,EACrBC,SAAmB,EACnB;EACA,IAAI,CAACL,MAAM,EAAE;EAEb,IAAI,CAACC,IAAI,CAACK,OAAO,IAAI,CAACJ,KAAK,EAAE;IAC3B,IAAIF,MAAM,CAACO,IAAI,KAAK,SAAS,IAAIP,MAAM,CAACO,IAAI,KAAK,MAAM,EAAE;MACvD,MAAM,IAAIC,KAAK,CACb,yEAAyE,GACvE,2CAA2CR,MAAM,CAACO,IAAI,gBAAgB,GACtE,+BACJ,CAAC;IACH;EACF;EAEA,IAAI,CAACH,UAAU,IAAIC,SAA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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.find = find;
|
| 7 |
+
exports.findParent = findParent;
|
| 8 |
+
exports.getAncestry = getAncestry;
|
| 9 |
+
exports.getDeepestCommonAncestorFrom = getDeepestCommonAncestorFrom;
|
| 10 |
+
exports.getEarliestCommonAncestorFrom = getEarliestCommonAncestorFrom;
|
| 11 |
+
exports.getFunctionParent = getFunctionParent;
|
| 12 |
+
exports.getStatementParent = getStatementParent;
|
| 13 |
+
exports.inType = inType;
|
| 14 |
+
exports.isAncestor = isAncestor;
|
| 15 |
+
exports.isDescendant = isDescendant;
|
| 16 |
+
var _t = require("@babel/types");
|
| 17 |
+
const {
|
| 18 |
+
VISITOR_KEYS
|
| 19 |
+
} = _t;
|
| 20 |
+
function findParent(callback) {
|
| 21 |
+
let path = this;
|
| 22 |
+
while (path = path.parentPath) {
|
| 23 |
+
if (callback(path)) return path;
|
| 24 |
+
}
|
| 25 |
+
return null;
|
| 26 |
+
}
|
| 27 |
+
function find(callback) {
|
| 28 |
+
let path = this;
|
| 29 |
+
do {
|
| 30 |
+
if (callback(path)) return path;
|
| 31 |
+
} while (path = path.parentPath);
|
| 32 |
+
return null;
|
| 33 |
+
}
|
| 34 |
+
function getFunctionParent() {
|
| 35 |
+
return this.findParent(p => p.isFunction());
|
| 36 |
+
}
|
| 37 |
+
function getStatementParent() {
|
| 38 |
+
let path = this;
|
| 39 |
+
do {
|
| 40 |
+
if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
|
| 41 |
+
break;
|
| 42 |
+
} else {
|
| 43 |
+
path = path.parentPath;
|
| 44 |
+
}
|
| 45 |
+
} while (path);
|
| 46 |
+
if (path && (path.isProgram() || path.isFile())) {
|
| 47 |
+
throw new Error("File/Program node, we can't possibly find a statement parent to this");
|
| 48 |
+
}
|
| 49 |
+
return path;
|
| 50 |
+
}
|
| 51 |
+
function getEarliestCommonAncestorFrom(paths) {
|
| 52 |
+
return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
|
| 53 |
+
let earliest;
|
| 54 |
+
const keys = VISITOR_KEYS[deepest.type];
|
| 55 |
+
for (const ancestry of ancestries) {
|
| 56 |
+
const path = ancestry[i + 1];
|
| 57 |
+
if (!earliest) {
|
| 58 |
+
earliest = path;
|
| 59 |
+
continue;
|
| 60 |
+
}
|
| 61 |
+
if (path.listKey && earliest.listKey === path.listKey) {
|
| 62 |
+
if (path.key < earliest.key) {
|
| 63 |
+
earliest = path;
|
| 64 |
+
continue;
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
const earliestKeyIndex = keys.indexOf(earliest.parentKey);
|
| 68 |
+
const currentKeyIndex = keys.indexOf(path.parentKey);
|
| 69 |
+
if (earliestKeyIndex > currentKeyIndex) {
|
| 70 |
+
earliest = path;
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
return earliest;
|
| 74 |
+
});
|
| 75 |
+
}
|
| 76 |
+
function getDeepestCommonAncestorFrom(paths, filter) {
|
| 77 |
+
if (!paths.length) {
|
| 78 |
+
return this;
|
| 79 |
+
}
|
| 80 |
+
if (paths.length === 1) {
|
| 81 |
+
return paths[0];
|
| 82 |
+
}
|
| 83 |
+
let minDepth = Infinity;
|
| 84 |
+
let lastCommonIndex, lastCommon;
|
| 85 |
+
const ancestries = paths.map(path => {
|
| 86 |
+
const ancestry = [];
|
| 87 |
+
do {
|
| 88 |
+
ancestry.unshift(path);
|
| 89 |
+
} while ((path = path.parentPath) && path !== this);
|
| 90 |
+
if (ancestry.length < minDepth) {
|
| 91 |
+
minDepth = ancestry.length;
|
| 92 |
+
}
|
| 93 |
+
return ancestry;
|
| 94 |
+
});
|
| 95 |
+
const first = ancestries[0];
|
| 96 |
+
depthLoop: for (let i = 0; i < minDepth; i++) {
|
| 97 |
+
const shouldMatch = first[i];
|
| 98 |
+
for (const ancestry of ancestries) {
|
| 99 |
+
if (ancestry[i] !== shouldMatch) {
|
| 100 |
+
break depthLoop;
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
lastCommonIndex = i;
|
| 104 |
+
lastCommon = shouldMatch;
|
| 105 |
+
}
|
| 106 |
+
if (lastCommon) {
|
| 107 |
+
if (filter) {
|
| 108 |
+
return filter(lastCommon, lastCommonIndex, ancestries);
|
| 109 |
+
} else {
|
| 110 |
+
return lastCommon;
|
| 111 |
+
}
|
| 112 |
+
} else {
|
| 113 |
+
throw new Error("Couldn't find intersection");
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
function getAncestry() {
|
| 117 |
+
let path = this;
|
| 118 |
+
const paths = [];
|
| 119 |
+
do {
|
| 120 |
+
paths.push(path);
|
| 121 |
+
} while (path = path.parentPath);
|
| 122 |
+
return paths;
|
| 123 |
+
}
|
| 124 |
+
function isAncestor(maybeDescendant) {
|
| 125 |
+
return maybeDescendant.isDescendant(this);
|
| 126 |
+
}
|
| 127 |
+
function isDescendant(maybeAncestor) {
|
| 128 |
+
return !!this.findParent(parent => parent === maybeAncestor);
|
| 129 |
+
}
|
| 130 |
+
function inType(...candidateTypes) {
|
| 131 |
+
let path = this;
|
| 132 |
+
while (path) {
|
| 133 |
+
if (candidateTypes.includes(path.node.type)) return true;
|
| 134 |
+
path = path.parentPath;
|
| 135 |
+
}
|
| 136 |
+
return false;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
//# sourceMappingURL=ancestry.js.map
|
node_modules/@babel/traverse/lib/path/ancestry.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_t","require","VISITOR_KEYS","findParent","callback","path","parentPath","find","getFunctionParent","p","isFunction","getStatementParent","Array","isArray","container","isStatement","isProgram","isFile","Error","getEarliestCommonAncestorFrom","paths","getDeepestCommonAncestorFrom","deepest","i","ancestries","earliest","keys","type","ancestry","listKey","key","earliestKeyIndex","indexOf","parentKey","currentKeyIndex","filter","length","minDepth","Infinity","lastCommonIndex","lastCommon","map","unshift","first","depthLoop","shouldMatch","getAncestry","push","isAncestor","maybeDescendant","isDescendant","maybeAncestor","parent","inType","candidateTypes","includes","node"],"sources":["../../src/path/ancestry.ts"],"sourcesContent":["// This file contains that retrieve or validate anything related to the current paths ancestry.\n\nimport { VISITOR_KEYS } from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type NodePath from \"./index.ts\";\n\n/**\n * Starting at the parent path of the current `NodePath` and going up the\n * tree, return the first `NodePath` that causes the provided `callback`\n * to return a truthy value, or `null` if the `callback` never returns a\n * truthy value.\n */\n\nexport function findParent(\n this: NodePath,\n callback: (path: NodePath) => boolean,\n): NodePath | null {\n let path = this;\n while ((path = path.parentPath)) {\n if (callback(path)) return path;\n }\n return null;\n}\n\n/**\n * Starting at current `NodePath` and going up the tree, return the first\n * `NodePath` that causes the provided `callback` to return a truthy value,\n * or `null` if the `callback` never returns a truthy value.\n */\n\nexport function find(\n this: NodePath,\n callback: (path: NodePath) => boolean,\n): NodePath | null {\n let path = this;\n do {\n if (callback(path)) return path;\n } while ((path = path.parentPath));\n return null;\n}\n\n/**\n * Get the parent function of the current path.\n */\n\nexport function getFunctionParent(this: NodePath): NodePath<t.Function> | null {\n return this.findParent(p => p.isFunction()) as NodePath<t.Function> | null;\n}\n\n/**\n * Walk up the tree until we hit a parent node path in a list.\n */\n\nexport function getStatementParent(this: NodePath): NodePath<t.Statement> {\n let path = this;\n\n do {\n if (\n !path.parentPath ||\n (Array.isArray(path.container) && path.isStatement())\n ) {\n break;\n } else {\n path = path.parentPath;\n }\n } while (path);\n\n if (path && (path.isProgram() || path.isFile())) {\n throw new Error(\n \"File/Program node, we can't possibly find a statement parent to this\",\n );\n }\n\n return path as NodePath<t.Statement>;\n}\n\n/**\n * Get the deepest common ancestor and then from it, get the earliest relationship path\n * to that ancestor.\n *\n * Earliest is defined as being \"before\" all the other nodes in terms of list container\n * position and visiting key.\n */\n\nexport function getEarliestCommonAncestorFrom(\n this: NodePath,\n paths: NodePath[],\n): NodePath {\n return this.getDeepestCommonAncestorFrom(\n paths,\n function (deepest, i, ancestries) {\n let earliest;\n const keys = VISITOR_KEYS[deepest.type];\n\n for (const ancestry of ancestries) {\n const path = ancestry[i + 1];\n\n // first path\n if (!earliest) {\n earliest = path;\n continue;\n }\n\n // handle containers\n if (path.listKey && earliest.listKey === path.listKey) {\n // we're in the same container so check if we're earlier\n if (path.key! < earliest.key!) {\n earliest = path;\n continue;\n }\n }\n\n // handle keys\n const earliestKeyIndex = keys.indexOf(earliest.parentKey);\n const currentKeyIndex = keys.indexOf(path.parentKey);\n if (earliestKeyIndex > currentKeyIndex) {\n // key appears before so it's earlier\n earliest = path;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return earliest!;\n },\n );\n}\n\n/**\n * Get the earliest path in the tree where the provided `paths` intersect.\n *\n * TODO: Possible optimisation target.\n */\n\nexport function getDeepestCommonAncestorFrom(\n this: NodePath,\n paths: NodePath[],\n filter?: (deepest: NodePath, i: number, ancestries: NodePath[][]) => NodePath,\n): NodePath {\n if (!paths.length) {\n return this;\n }\n\n if (paths.length === 1) {\n return paths[0];\n }\n\n // minimum depth of the tree so we know the highest node\n let minDepth = Infinity;\n\n // last common ancestor\n let lastCommonIndex, lastCommon;\n\n // get the ancestors of the path, breaking when the parent exceeds ourselves\n const ancestries = paths.map(path => {\n const ancestry: NodePath[] = [];\n\n do {\n ancestry.unshift(path);\n } while ((path = path.parentPath) && path !== this);\n\n // save min depth to avoid going too far in\n if (ancestry.length < minDepth) {\n minDepth = ancestry.length;\n }\n\n return ancestry;\n });\n\n // get the first ancestry so we have a seed to assess all other ancestries with\n const first = ancestries[0];\n\n // check ancestor equality\n depthLoop: for (let i = 0; i < minDepth; i++) {\n const shouldMatch = first[i];\n\n for (const ancestry of ancestries) {\n if (ancestry[i] !== shouldMatch) {\n // we've hit a snag\n break depthLoop;\n }\n }\n\n // next iteration may break so store these so they can be returned\n lastCommonIndex = i;\n lastCommon = shouldMatch;\n }\n\n if (lastCommon) {\n if (filter) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return filter(lastCommon, lastCommonIndex!, ancestries);\n } else {\n return lastCommon;\n }\n } else {\n throw new Error(\"Couldn't find intersection\");\n }\n}\n\n/**\n * Build an array of node paths containing the entire ancestry of the current node path.\n *\n * NOTE: The current node path is included in this.\n */\n\nexport function getAncestry(this: NodePath): NodePath[] {\n let path = this;\n const paths = [];\n do {\n paths.push(path);\n } while ((path = path.parentPath));\n return paths;\n}\n\n/**\n * A helper to find if `this` path is an ancestor of @param maybeDescendant\n */\nexport function isAncestor(this: NodePath, maybeDescendant: NodePath): boolean {\n return maybeDescendant.isDescendant(this);\n}\n\n/**\n * A helper to find if `this` path is a descendant of @param maybeAncestor\n */\nexport function isDescendant(this: NodePath, maybeAncestor: NodePath): boolean {\n return !!this.findParent(parent => parent === maybeAncestor);\n}\n\nexport function inType(this: NodePath, ...candidateTypes: string[]): boolean {\n let path = this;\n while (path) {\n if (candidateTypes.includes(path.node.type)) return true;\n path = path.parentPath;\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA,IAAAA,EAAA,GAAAC,OAAA;AAA4C;EAAnCC;AAAY,IAAAF,EAAA;AAWd,SAASG,UAAUA,CAExBC,QAAqC,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B,GAAGC,cAAwB,EAAW;EAC3E,IAAIjD,IAAI,GAAG,IAAI;EACf,OAAOA,IAAI,EAAE;IACX,IAAIiD,cAAc,CAACC,QAAQ,CAAClD,IAAI,CAACmD,IAAI,CAAC7B,IAAI,CAAC,EAAE,OAAO,IAAI;IACxDtB,IAAI,GAAGA,IAAI,CAACC,UAAU;EACxB;EAEA,OAAO,KAAK;AACd","ignoreList":[]}
|
node_modules/@babel/traverse/lib/path/comments.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.addComment = addComment;
|
| 7 |
+
exports.addComments = addComments;
|
| 8 |
+
exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
|
| 9 |
+
var _t = require("@babel/types");
|
| 10 |
+
const {
|
| 11 |
+
addComment: _addComment,
|
| 12 |
+
addComments: _addComments
|
| 13 |
+
} = _t;
|
| 14 |
+
function shareCommentsWithSiblings() {
|
| 15 |
+
if (typeof this.key === "string") return;
|
| 16 |
+
const node = this.node;
|
| 17 |
+
if (!node) return;
|
| 18 |
+
const trailing = node.trailingComments;
|
| 19 |
+
const leading = node.leadingComments;
|
| 20 |
+
if (!trailing && !leading) return;
|
| 21 |
+
const prev = this.getSibling(this.key - 1);
|
| 22 |
+
const next = this.getSibling(this.key + 1);
|
| 23 |
+
const hasPrev = Boolean(prev.node);
|
| 24 |
+
const hasNext = Boolean(next.node);
|
| 25 |
+
if (hasPrev) {
|
| 26 |
+
if (leading) {
|
| 27 |
+
prev.addComments("trailing", removeIfExisting(leading, prev.node.trailingComments));
|
| 28 |
+
}
|
| 29 |
+
if (trailing && !hasNext) prev.addComments("trailing", trailing);
|
| 30 |
+
}
|
| 31 |
+
if (hasNext) {
|
| 32 |
+
if (trailing) {
|
| 33 |
+
next.addComments("leading", removeIfExisting(trailing, next.node.leadingComments));
|
| 34 |
+
}
|
| 35 |
+
if (leading && !hasPrev) next.addComments("leading", leading);
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
function removeIfExisting(list, toRemove) {
|
| 39 |
+
if (!(toRemove != null && toRemove.length)) return list;
|
| 40 |
+
const set = new Set(toRemove);
|
| 41 |
+
return list.filter(el => {
|
| 42 |
+
return !set.has(el);
|
| 43 |
+
});
|
| 44 |
+
}
|
| 45 |
+
function addComment(type, content, line) {
|
| 46 |
+
_addComment(this.node, type, content, line);
|
| 47 |
+
}
|
| 48 |
+
function addComments(type, comments) {
|
| 49 |
+
_addComments(this.node, type, comments);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
//# sourceMappingURL=comments.js.map
|
node_modules/@babel/traverse/lib/path/comments.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_t","require","addComment","_addComment","addComments","_addComments","shareCommentsWithSiblings","key","node","trailing","trailingComments","leading","leadingComments","prev","getSibling","next","hasPrev","Boolean","hasNext","removeIfExisting","list","toRemove","length","set","Set","filter","el","has","type","content","line","comments"],"sources":["../../src/path/comments.ts"],"sourcesContent":["// This file contains methods responsible for dealing with comments.\nimport type * as t from \"@babel/types\";\nimport type NodePath from \"./index.ts\";\nimport {\n addComment as _addComment,\n addComments as _addComments,\n} from \"@babel/types\";\n\n/**\n * Share comments amongst siblings.\n */\n\nexport function shareCommentsWithSiblings(this: NodePath) {\n // NOTE: this assumes numbered keys\n if (typeof this.key === \"string\") return;\n\n const node = this.node;\n if (!node) return;\n\n const trailing = node.trailingComments;\n const leading = node.leadingComments;\n if (!trailing && !leading) return;\n\n const prev = this.getSibling(this.key! - 1);\n const next = this.getSibling(this.key! + 1);\n const hasPrev = Boolean(prev.node);\n const hasNext = Boolean(next.node);\n\n if (hasPrev) {\n if (leading) {\n prev.addComments(\n \"trailing\",\n removeIfExisting(leading, prev.node.trailingComments),\n );\n }\n if (trailing && !hasNext) prev.addComments(\"trailing\", trailing);\n }\n if (hasNext) {\n if (trailing) {\n next.addComments(\n \"leading\",\n removeIfExisting(trailing, next.node.leadingComments),\n );\n }\n if (leading && !hasPrev) next.addComments(\"leading\", leading);\n }\n}\n\nfunction removeIfExisting<T>(list: T[], toRemove?: T[] | null): T[] {\n if (!toRemove?.length) return list;\n const set = new Set(toRemove);\n return list.filter(el => {\n return !set.has(el);\n });\n}\n\nexport function addComment(\n this: NodePath,\n type: t.CommentTypeShorthand,\n content: string,\n line?: boolean,\n) {\n _addComment(this.node, type, content, line);\n}\n\n/**\n * Give node `comments` of the specified `type`.\n */\n\nexport function addComments(\n this: NodePath,\n type: t.CommentTypeShorthand,\n comments: t.Comment[],\n) {\n _addComments(this.node, type, comments);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,EAAA,GAAAC,OAAA;AAGsB;EAFpBC,UAAU,EAAIC,WAAW;EACzBC,WAAW,EAAIC;AAAY,IAAAL,EAAA;AAOtB,SAASM,yBAAyBA,CAAA,EAAiB;EAExD,IAAI,OAAO,IAAI,CAACC,GAAG,KAAK,QAAQ,EAAE;EAElC,MAAMC,IAAI,GAAG,IAAI,CAACA,IAAI;EACtB,IAAI,CAACA,IAAI,EAAE;EAEX,MAAMC,QAAQ,GAAGD,IAAI,CAACE,gBAAgB;EACtC,MAAMC,OAAO,GAAGH,IAAI,CAACI,eAAe;EACpC,IAAI,CAACH,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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports._call = _call;
|
| 7 |
+
exports._forceSetScope = _forceSetScope;
|
| 8 |
+
exports._getQueueContexts = _getQueueContexts;
|
| 9 |
+
exports._resyncKey = _resyncKey;
|
| 10 |
+
exports._resyncList = _resyncList;
|
| 11 |
+
exports._resyncParent = _resyncParent;
|
| 12 |
+
exports._resyncRemoved = _resyncRemoved;
|
| 13 |
+
exports.call = call;
|
| 14 |
+
exports.isDenylisted = isDenylisted;
|
| 15 |
+
exports.popContext = popContext;
|
| 16 |
+
exports.pushContext = pushContext;
|
| 17 |
+
exports.requeue = requeue;
|
| 18 |
+
exports.requeueComputedKeyAndDecorators = requeueComputedKeyAndDecorators;
|
| 19 |
+
exports.resync = resync;
|
| 20 |
+
exports.setContext = setContext;
|
| 21 |
+
exports.setKey = setKey;
|
| 22 |
+
exports.setScope = setScope;
|
| 23 |
+
exports.setup = setup;
|
| 24 |
+
exports.skip = skip;
|
| 25 |
+
exports.skipKey = skipKey;
|
| 26 |
+
exports.stop = stop;
|
| 27 |
+
exports.visit = visit;
|
| 28 |
+
var _traverseNode = require("../traverse-node.js");
|
| 29 |
+
var _index = require("./index.js");
|
| 30 |
+
var _removal = require("./removal.js");
|
| 31 |
+
var t = require("@babel/types");
|
| 32 |
+
function call(key) {
|
| 33 |
+
const opts = this.opts;
|
| 34 |
+
this.debug(key);
|
| 35 |
+
if (this.node) {
|
| 36 |
+
if (_call.call(this, opts[key])) return true;
|
| 37 |
+
}
|
| 38 |
+
if (this.node) {
|
| 39 |
+
var _opts$this$node$type;
|
| 40 |
+
return _call.call(this, (_opts$this$node$type = opts[this.node.type]) == null ? void 0 : _opts$this$node$type[key]);
|
| 41 |
+
}
|
| 42 |
+
return false;
|
| 43 |
+
}
|
| 44 |
+
function _call(fns) {
|
| 45 |
+
if (!fns) return false;
|
| 46 |
+
for (const fn of fns) {
|
| 47 |
+
if (!fn) continue;
|
| 48 |
+
const node = this.node;
|
| 49 |
+
if (!node) return true;
|
| 50 |
+
const ret = fn.call(this.state, this, this.state);
|
| 51 |
+
if (ret && typeof ret === "object" && typeof ret.then === "function") {
|
| 52 |
+
throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
|
| 53 |
+
}
|
| 54 |
+
if (ret) {
|
| 55 |
+
throw new Error(`Unexpected return value from visitor method ${fn}`);
|
| 56 |
+
}
|
| 57 |
+
if (this.node !== node) return true;
|
| 58 |
+
if (this._traverseFlags > 0) return true;
|
| 59 |
+
}
|
| 60 |
+
return false;
|
| 61 |
+
}
|
| 62 |
+
function isDenylisted() {
|
| 63 |
+
var _this$opts$denylist;
|
| 64 |
+
const denylist = (_this$opts$denylist = this.opts.denylist) != null ? _this$opts$denylist : this.opts.blacklist;
|
| 65 |
+
return denylist == null ? void 0 : denylist.includes(this.node.type);
|
| 66 |
+
}
|
| 67 |
+
exports.isBlacklisted = isDenylisted;
|
| 68 |
+
function restoreContext(path, context) {
|
| 69 |
+
if (path.context !== context) {
|
| 70 |
+
path.context = context;
|
| 71 |
+
path.state = context.state;
|
| 72 |
+
path.opts = context.opts;
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
function visit() {
|
| 76 |
+
var _this$opts$shouldSkip, _this$opts;
|
| 77 |
+
if (!this.node) {
|
| 78 |
+
return false;
|
| 79 |
+
}
|
| 80 |
+
if (this.isDenylisted()) {
|
| 81 |
+
return false;
|
| 82 |
+
}
|
| 83 |
+
if ((_this$opts$shouldSkip = (_this$opts = this.opts).shouldSkip) != null && _this$opts$shouldSkip.call(_this$opts, this)) {
|
| 84 |
+
return false;
|
| 85 |
+
}
|
| 86 |
+
const currentContext = this.context;
|
| 87 |
+
if (this.shouldSkip || call.call(this, "enter")) {
|
| 88 |
+
this.debug("Skip...");
|
| 89 |
+
return this.shouldStop;
|
| 90 |
+
}
|
| 91 |
+
restoreContext(this, currentContext);
|
| 92 |
+
this.debug("Recursing into...");
|
| 93 |
+
this.shouldStop = (0, _traverseNode.traverseNode)(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
|
| 94 |
+
restoreContext(this, currentContext);
|
| 95 |
+
call.call(this, "exit");
|
| 96 |
+
return this.shouldStop;
|
| 97 |
+
}
|
| 98 |
+
function skip() {
|
| 99 |
+
this.shouldSkip = true;
|
| 100 |
+
}
|
| 101 |
+
function skipKey(key) {
|
| 102 |
+
if (this.skipKeys == null) {
|
| 103 |
+
this.skipKeys = {};
|
| 104 |
+
}
|
| 105 |
+
this.skipKeys[key] = true;
|
| 106 |
+
}
|
| 107 |
+
function stop() {
|
| 108 |
+
this._traverseFlags |= _index.SHOULD_SKIP | _index.SHOULD_STOP;
|
| 109 |
+
}
|
| 110 |
+
function _forceSetScope() {
|
| 111 |
+
var _this$scope;
|
| 112 |
+
let path = this.parentPath;
|
| 113 |
+
if ((this.key === "key" || this.listKey === "decorators") && path.isMethod() || this.key === "discriminant" && path.isSwitchStatement()) {
|
| 114 |
+
path = path.parentPath;
|
| 115 |
+
}
|
| 116 |
+
let target;
|
| 117 |
+
while (path && !target) {
|
| 118 |
+
target = path.scope;
|
| 119 |
+
path = path.parentPath;
|
| 120 |
+
}
|
| 121 |
+
this.scope = this.getScope(target);
|
| 122 |
+
(_this$scope = this.scope) == null || _this$scope.init();
|
| 123 |
+
}
|
| 124 |
+
function setScope() {
|
| 125 |
+
var _this$opts2, _this$scope2;
|
| 126 |
+
if ((_this$opts2 = this.opts) != null && _this$opts2.noScope) return;
|
| 127 |
+
let path = this.parentPath;
|
| 128 |
+
if ((this.key === "key" || this.listKey === "decorators") && path.isMethod() || this.key === "discriminant" && path.isSwitchStatement()) {
|
| 129 |
+
path = path.parentPath;
|
| 130 |
+
}
|
| 131 |
+
let target;
|
| 132 |
+
while (path && !target) {
|
| 133 |
+
var _path$opts;
|
| 134 |
+
if ((_path$opts = path.opts) != null && _path$opts.noScope) return;
|
| 135 |
+
target = path.scope;
|
| 136 |
+
path = path.parentPath;
|
| 137 |
+
}
|
| 138 |
+
this.scope = this.getScope(target);
|
| 139 |
+
(_this$scope2 = this.scope) == null || _this$scope2.init();
|
| 140 |
+
}
|
| 141 |
+
function setContext(context) {
|
| 142 |
+
if (this.skipKeys != null) {
|
| 143 |
+
this.skipKeys = {};
|
| 144 |
+
}
|
| 145 |
+
this._traverseFlags = 0;
|
| 146 |
+
if (context) {
|
| 147 |
+
this.context = context;
|
| 148 |
+
this.state = context.state;
|
| 149 |
+
this.opts = context.opts;
|
| 150 |
+
}
|
| 151 |
+
setScope.call(this);
|
| 152 |
+
return this;
|
| 153 |
+
}
|
| 154 |
+
function resync() {
|
| 155 |
+
if (this.removed) return;
|
| 156 |
+
_resyncParent.call(this);
|
| 157 |
+
_resyncList.call(this);
|
| 158 |
+
_resyncKey.call(this);
|
| 159 |
+
}
|
| 160 |
+
function _resyncParent() {
|
| 161 |
+
if (this.parentPath) {
|
| 162 |
+
this.parent = this.parentPath.node;
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
function _resyncKey() {
|
| 166 |
+
if (!this.container) return;
|
| 167 |
+
if (this.node === this.container[this.key]) {
|
| 168 |
+
return;
|
| 169 |
+
}
|
| 170 |
+
if (Array.isArray(this.container)) {
|
| 171 |
+
for (let i = 0; i < this.container.length; i++) {
|
| 172 |
+
if (this.container[i] === this.node) {
|
| 173 |
+
setKey.call(this, i);
|
| 174 |
+
return;
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
} else {
|
| 178 |
+
for (const key of Object.keys(this.container)) {
|
| 179 |
+
if (this.container[key] === this.node) {
|
| 180 |
+
setKey.call(this, key);
|
| 181 |
+
return;
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
this.key = null;
|
| 186 |
+
}
|
| 187 |
+
function _resyncList() {
|
| 188 |
+
if (!this.parent || !this.inList) return;
|
| 189 |
+
const newContainer = this.parent[this.listKey];
|
| 190 |
+
if (this.container === newContainer) return;
|
| 191 |
+
this.container = newContainer || null;
|
| 192 |
+
}
|
| 193 |
+
function _resyncRemoved() {
|
| 194 |
+
if (this.key == null || !this.container || this.container[this.key] !== this.node) {
|
| 195 |
+
_removal._markRemoved.call(this);
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
function popContext() {
|
| 199 |
+
this.contexts.pop();
|
| 200 |
+
if (this.contexts.length > 0) {
|
| 201 |
+
this.setContext(this.contexts[this.contexts.length - 1]);
|
| 202 |
+
} else {
|
| 203 |
+
this.setContext(undefined);
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
function pushContext(context) {
|
| 207 |
+
this.contexts.push(context);
|
| 208 |
+
this.setContext(context);
|
| 209 |
+
}
|
| 210 |
+
function setup(parentPath, container, listKey, key) {
|
| 211 |
+
this.listKey = listKey;
|
| 212 |
+
this.container = container;
|
| 213 |
+
this.parentPath = parentPath || this.parentPath;
|
| 214 |
+
setKey.call(this, key);
|
| 215 |
+
}
|
| 216 |
+
function setKey(key) {
|
| 217 |
+
var _this$node;
|
| 218 |
+
this.key = key;
|
| 219 |
+
this.node = this.container[this.key];
|
| 220 |
+
this.type = (_this$node = this.node) == null ? void 0 : _this$node.type;
|
| 221 |
+
}
|
| 222 |
+
function requeue(pathToQueue = this) {
|
| 223 |
+
if (pathToQueue.removed) return;
|
| 224 |
+
const contexts = this.contexts;
|
| 225 |
+
for (const context of contexts) {
|
| 226 |
+
context.maybeQueue(pathToQueue);
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
function requeueComputedKeyAndDecorators() {
|
| 230 |
+
const {
|
| 231 |
+
context,
|
| 232 |
+
node
|
| 233 |
+
} = this;
|
| 234 |
+
if (!t.isPrivate(node) && node.computed) {
|
| 235 |
+
context.maybeQueue(this.get("key"));
|
| 236 |
+
}
|
| 237 |
+
if (node.decorators) {
|
| 238 |
+
for (const decorator of this.get("decorators")) {
|
| 239 |
+
context.maybeQueue(decorator);
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
function _getQueueContexts() {
|
| 244 |
+
let path = this;
|
| 245 |
+
let contexts = this.contexts;
|
| 246 |
+
while (!contexts.length) {
|
| 247 |
+
path = path.parentPath;
|
| 248 |
+
if (!path) break;
|
| 249 |
+
contexts = path.contexts;
|
| 250 |
+
}
|
| 251 |
+
return contexts;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
//# sourceMappingURL=context.js.map
|
node_modules/@babel/traverse/lib/path/context.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_traverseNode","require","_index","_removal","t","call","key","opts","debug","node","_call","_opts$this$node$type","type","fns","fn","ret","state","then","Error","_traverseFlags","isDenylisted","_this$opts$denylist","denylist","blacklist","includes","exports","isBlacklisted","restoreContext","path","context","visit","_this$opts$shouldSkip","_this$opts","shouldSkip","currentContext","shouldStop","traverseNode","scope","skipKeys","skip","skipKey","stop","SHOULD_SKIP","SHOULD_STOP","_forceSetScope","_this$scope","parentPath","listKey","isMethod","isSwitchStatement","target","getScope","init","setScope","_this$opts2","_this$scope2","noScope","_path$opts","setContext","resync","removed","_resyncParent","_resyncList","_resyncKey","parent","container","Array","isArray","i","length","setKey","Object","keys","inList","newContainer","_resyncRemoved","_markRemoved","popContext","contexts","pop","undefined","pushContext","push","setup","_this$node","requeue","pathToQueue","maybeQueue","requeueComputedKeyAndDecorators","isPrivate","computed","get","decorators","decorator","_getQueueContexts"],"sources":["../../src/path/context.ts"],"sourcesContent":["// This file contains methods responsible for maintaining a TraversalContext.\n\nimport { traverseNode } from \"../traverse-node.ts\";\nimport { SHOULD_SKIP, SHOULD_STOP } from \"./index.ts\";\nimport { _markRemoved } from \"./removal.ts\";\nimport type TraversalContext from \"../context.ts\";\nimport type { VisitPhase } from \"../types.ts\";\nimport type NodePath from \"./index.ts\";\nimport * as t from \"@babel/types\";\n\nexport function call(this: NodePath, key: VisitPhase): boolean {\n const opts = this.opts;\n\n this.debug(key);\n\n if (this.node) {\n if (_call.call(this, opts[key])) return true;\n }\n\n if (this.node) {\n return _call.call(this, opts[this.node.type]?.[key]);\n }\n\n return false;\n}\n\nexport function _call(this: NodePath, fns?: Function[]): boolean {\n if (!fns) return false;\n\n for (const fn of fns) {\n if (!fn) continue;\n\n const node = this.node;\n if (!node) return true;\n\n const ret = fn.call(this.state, this, this.state);\n if (ret && typeof ret === \"object\" && typeof ret.then === \"function\") {\n throw new Error(\n `You appear to be using a plugin with an async traversal visitor, ` +\n `which your current version of Babel does not support. ` +\n `If you're using a published plugin, you may need to upgrade ` +\n `your @babel/core version.`,\n );\n }\n if (ret) {\n throw new Error(`Unexpected return value from visitor method ${fn}`);\n }\n\n // node has been replaced, it will have been requeued\n if (this.node !== node) return true;\n\n // this.shouldSkip || this.shouldStop || this.removed\n if (this._traverseFlags > 0) return true;\n }\n\n return false;\n}\n\nexport function isDenylisted(this: NodePath): boolean {\n // @ts-expect-error TODO(Babel 8): Remove blacklist\n const denylist = this.opts.denylist ?? this.opts.blacklist;\n return denylist?.includes(this.node.type);\n}\n\nif (!process.env.BABEL_8_BREAKING && !USE_ESM) {\n // eslint-disable-next-line no-restricted-globals\n exports.isBlacklisted = isDenylisted;\n}\n\nfunction restoreContext(path: NodePath, context: TraversalContext) {\n if (path.context !== context) {\n path.context = context;\n path.state = context.state;\n path.opts = context.opts;\n }\n}\n\nexport function visit(this: NodePath): boolean {\n if (!this.node) {\n return false;\n }\n\n if (this.isDenylisted()) {\n return false;\n }\n\n if (this.opts.shouldSkip?.(this)) {\n return false;\n }\n\n const currentContext = this.context;\n // Note: We need to check \"this.shouldSkip\" first because\n // another visitor can set it to true. Usually .shouldSkip is false\n // before calling the enter visitor, but it can be true in case of\n // a requeued node (e.g. by .replaceWith()) that is then marked\n // with .skip().\n if (this.shouldSkip || call.call(this, \"enter\")) {\n this.debug(\"Skip...\");\n return this.shouldStop;\n }\n restoreContext(this, currentContext);\n\n this.debug(\"Recursing into...\");\n this.shouldStop = traverseNode(\n this.node,\n this.opts,\n this.scope,\n this.state,\n this,\n this.skipKeys,\n );\n\n restoreContext(this, currentContext);\n\n call.call(this, \"exit\");\n\n return this.shouldStop;\n}\n\nexport function skip(this: NodePath) {\n this.shouldSkip = true;\n}\n\nexport function skipKey(this: NodePath, key: string) {\n if (this.skipKeys == null) {\n this.skipKeys = {};\n }\n this.skipKeys[key] = true;\n}\n\nexport function stop(this: NodePath) {\n // this.shouldSkip = true; this.shouldStop = true;\n this._traverseFlags |= SHOULD_SKIP | SHOULD_STOP;\n}\n\nexport function _forceSetScope(this: NodePath) {\n let path = this.parentPath;\n\n if (\n // Skip method scope if is computed method key or decorator expression\n ((this.key === \"key\" || this.listKey === \"decorators\") &&\n path.isMethod()) ||\n // Skip switch scope if for discriminant (`x` in `switch (x) {}`).\n (this.key === \"discriminant\" && path.isSwitchStatement())\n ) {\n path = path.parentPath;\n }\n\n let target;\n while (path && !target) {\n target = path.scope;\n path = path.parentPath;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n this.scope = this.getScope(target!);\n this.scope?.init();\n}\n\nexport function setScope(this: NodePath) {\n if (this.opts?.noScope) return;\n\n let path = this.parentPath;\n\n if (\n // Skip method scope if is computed method key or decorator expression\n ((this.key === \"key\" || this.listKey === \"decorators\") &&\n path.isMethod()) ||\n // Skip switch scope if for discriminant (`x` in `switch (x) {}`).\n (this.key === \"discriminant\" && path.isSwitchStatement())\n ) {\n path = path.parentPath;\n }\n\n let target;\n while (path && !target) {\n if (path.opts?.noScope) return;\n\n target = path.scope;\n path = path.parentPath;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n this.scope = this.getScope(target!);\n this.scope?.init();\n}\n\nexport function setContext<S = unknown>(\n this: NodePath,\n context?: TraversalContext<S>,\n) {\n if (this.skipKeys != null) {\n this.skipKeys = {};\n }\n // this.shouldSkip = false; this.shouldStop = false; this.removed = false;\n this._traverseFlags = 0;\n\n if (context) {\n this.context = context;\n this.state = context.state;\n // Discard the S type parameter from context.opts\n this.opts = context.opts as typeof this.opts;\n }\n\n setScope.call(this);\n\n return this;\n}\n\n/**\n * Here we resync the node paths `key` and `container`. If they've changed according\n * to what we have stored internally then we attempt to resync by crawling and looking\n * for the new values.\n */\n\nexport function resync(this: NodePath) {\n if (this.removed) return;\n\n _resyncParent.call(this);\n _resyncList.call(this);\n _resyncKey.call(this);\n //this._resyncRemoved();\n}\n\nexport function _resyncParent(this: NodePath) {\n if (this.parentPath) {\n this.parent = this.parentPath.node;\n }\n}\n\nexport function _resyncKey(this: NodePath) {\n if (!this.container) return;\n\n if (\n this.node ===\n // @ts-expect-error this.key should present in this.container\n this.container[this.key]\n ) {\n return;\n }\n\n // grrr, path key is out of sync. this is likely due to a modification to the AST\n // not done through our path APIs\n\n if (Array.isArray(this.container)) {\n for (let i = 0; i < this.container.length; i++) {\n if (this.container[i] === this.node) {\n setKey.call(this, i);\n return;\n }\n }\n } else {\n for (const key of Object.keys(this.container)) {\n // @ts-expect-error this.key should present in this.container\n if (this.container[key] === this.node) {\n setKey.call(this, key);\n return;\n }\n }\n }\n\n // ¯\\_(ツ)_/¯ who knows where it's gone lol\n this.key = null;\n}\n\nexport function _resyncList(this: NodePath) {\n if (!this.parent || !this.inList) return;\n\n const newContainer =\n // @ts-expect-error this.listKey should present in this.parent\n this.parent[this.listKey];\n if (this.container === newContainer) return;\n\n // container is out of sync. this is likely the result of it being reassigned\n this.container = newContainer || null;\n}\n\nexport function _resyncRemoved(this: NodePath) {\n if (\n this.key == null ||\n !this.container ||\n // @ts-expect-error this.key should present in this.container\n this.container[this.key] !== this.node\n ) {\n _markRemoved.call(this);\n }\n}\n\nexport function popContext(this: NodePath) {\n this.contexts.pop();\n if (this.contexts.length > 0) {\n this.setContext(this.contexts[this.contexts.length - 1]);\n } else {\n this.setContext(undefined);\n }\n}\n\nexport function pushContext(this: NodePath, context: TraversalContext) {\n this.contexts.push(context);\n this.setContext(context);\n}\n\nexport function setup(\n this: NodePath,\n parentPath: NodePath | undefined,\n container: t.Node | t.Node[],\n listKey: string | undefined,\n key: string | number,\n) {\n this.listKey = listKey;\n this.container = container;\n\n this.parentPath = parentPath || this.parentPath;\n setKey.call(this, key);\n}\n\nexport function setKey(this: NodePath, key: string | number) {\n this.key = key;\n this.node =\n // @ts-expect-error this.key must present in this.container\n this.container[this.key];\n this.type = this.node?.type;\n}\n\nexport function requeue(this: NodePath, pathToQueue = this) {\n if (pathToQueue.removed) return;\n\n // If a path is skipped, and then replaced with a\n // new one, the new one shouldn't probably be skipped.\n if (process.env.BABEL_8_BREAKING) {\n pathToQueue.shouldSkip = false;\n }\n\n // TODO(loganfsmyth): This should be switched back to queue in parent contexts\n // automatically once #2892 and #4135 have been resolved. See #4140.\n // let contexts = this._getQueueContexts();\n const contexts = this.contexts;\n\n for (const context of contexts) {\n context.maybeQueue(pathToQueue);\n }\n}\n\nexport function requeueComputedKeyAndDecorators(\n this: NodePath<t.Method | t.Property>,\n) {\n const { context, node } = this;\n if (!t.isPrivate(node) && node.computed) {\n context.maybeQueue(this.get(\"key\"));\n }\n if (node.decorators) {\n for (const decorator of this.get(\"decorators\")) {\n context.maybeQueue(decorator);\n }\n }\n}\n\nexport function _getQueueContexts(this: NodePath) {\n let path = this;\n let contexts = this.contexts;\n while (!contexts.length) {\n path = path.parentPath;\n if (!path) break;\n contexts = path.contexts;\n }\n return contexts;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAIA,IAAAG,CAAA,GAAAH,OAAA;AAEO,SAASI,IAAIA,CAAiBC,GAAe,EAAW;EAC7D,MAAMC,IAAI,GAAG,IAAI,CAACA,IAAI;EAEtB,IAAI,CAACC,KAAK,CAACF,GAAG,CAAC;EAEf,IAAI,IAAI,CAACG,IAAI,EAAE;IACb,IAAIC,KAAK,CAACL,IAAI,CAAC,IAAI,EAAEE,IAAI,CAACD,GAAG,CAAC,CAAC,EAAE,OAAO,IAAI;EAC9C;EAEA,IAAI,IAAI,CAACG,IAAI,EAAE;IAAA,IAAAE,oBAAA;IACb,OAAOD,KAAK,CAACL,IAAI,CAAC,IAAI,GAAAM,oBAAA,GAAEJ,IAAI,CAAC,IAAI,CAACE,IAAI,CAACG,IA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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.arrowFunctionToExpression = arrowFunctionToExpression;
|
| 7 |
+
exports.ensureBlock = ensureBlock;
|
| 8 |
+
exports.ensureFunctionName = ensureFunctionName;
|
| 9 |
+
exports.splitExportDeclaration = splitExportDeclaration;
|
| 10 |
+
exports.toComputedKey = toComputedKey;
|
| 11 |
+
exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
|
| 12 |
+
var _t = require("@babel/types");
|
| 13 |
+
var _template = require("@babel/template");
|
| 14 |
+
var _visitors = require("../visitors.js");
|
| 15 |
+
var _context = require("./context.js");
|
| 16 |
+
const {
|
| 17 |
+
arrowFunctionExpression,
|
| 18 |
+
assignmentExpression,
|
| 19 |
+
binaryExpression,
|
| 20 |
+
blockStatement,
|
| 21 |
+
callExpression,
|
| 22 |
+
conditionalExpression,
|
| 23 |
+
expressionStatement,
|
| 24 |
+
identifier,
|
| 25 |
+
isIdentifier,
|
| 26 |
+
jsxIdentifier,
|
| 27 |
+
logicalExpression,
|
| 28 |
+
LOGICAL_OPERATORS,
|
| 29 |
+
memberExpression,
|
| 30 |
+
metaProperty,
|
| 31 |
+
numericLiteral,
|
| 32 |
+
objectExpression,
|
| 33 |
+
restElement,
|
| 34 |
+
returnStatement,
|
| 35 |
+
sequenceExpression,
|
| 36 |
+
spreadElement,
|
| 37 |
+
stringLiteral,
|
| 38 |
+
super: _super,
|
| 39 |
+
thisExpression,
|
| 40 |
+
toExpression,
|
| 41 |
+
unaryExpression,
|
| 42 |
+
toBindingIdentifierName,
|
| 43 |
+
isFunction,
|
| 44 |
+
isAssignmentPattern,
|
| 45 |
+
isRestElement,
|
| 46 |
+
getFunctionName,
|
| 47 |
+
cloneNode,
|
| 48 |
+
variableDeclaration,
|
| 49 |
+
variableDeclarator,
|
| 50 |
+
exportNamedDeclaration,
|
| 51 |
+
exportSpecifier,
|
| 52 |
+
inherits
|
| 53 |
+
} = _t;
|
| 54 |
+
function toComputedKey() {
|
| 55 |
+
let key;
|
| 56 |
+
if (this.isMemberExpression()) {
|
| 57 |
+
key = this.node.property;
|
| 58 |
+
} else if (this.isProperty() || this.isMethod()) {
|
| 59 |
+
key = this.node.key;
|
| 60 |
+
} else {
|
| 61 |
+
throw new ReferenceError("todo");
|
| 62 |
+
}
|
| 63 |
+
if (!this.node.computed) {
|
| 64 |
+
if (isIdentifier(key)) key = stringLiteral(key.name);
|
| 65 |
+
}
|
| 66 |
+
return key;
|
| 67 |
+
}
|
| 68 |
+
function ensureBlock() {
|
| 69 |
+
const body = this.get("body");
|
| 70 |
+
const bodyNode = body.node;
|
| 71 |
+
if (Array.isArray(body)) {
|
| 72 |
+
throw new Error("Can't convert array path to a block statement");
|
| 73 |
+
}
|
| 74 |
+
if (!bodyNode) {
|
| 75 |
+
throw new Error("Can't convert node without a body");
|
| 76 |
+
}
|
| 77 |
+
if (body.isBlockStatement()) {
|
| 78 |
+
return bodyNode;
|
| 79 |
+
}
|
| 80 |
+
const statements = [];
|
| 81 |
+
let stringPath = "body";
|
| 82 |
+
let key;
|
| 83 |
+
let listKey;
|
| 84 |
+
if (body.isStatement()) {
|
| 85 |
+
listKey = "body";
|
| 86 |
+
key = 0;
|
| 87 |
+
statements.push(body.node);
|
| 88 |
+
} else {
|
| 89 |
+
stringPath += ".body.0";
|
| 90 |
+
if (this.isFunction()) {
|
| 91 |
+
key = "argument";
|
| 92 |
+
statements.push(returnStatement(body.node));
|
| 93 |
+
} else {
|
| 94 |
+
key = "expression";
|
| 95 |
+
statements.push(expressionStatement(body.node));
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
this.node.body = blockStatement(statements);
|
| 99 |
+
const parentPath = this.get(stringPath);
|
| 100 |
+
_context.setup.call(body, parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
|
| 101 |
+
return this.node;
|
| 102 |
+
}
|
| 103 |
+
exports.arrowFunctionToShadowed = function () {
|
| 104 |
+
if (!this.isArrowFunctionExpression()) return;
|
| 105 |
+
this.arrowFunctionToExpression();
|
| 106 |
+
};
|
| 107 |
+
function unwrapFunctionEnvironment() {
|
| 108 |
+
if (!this.isArrowFunctionExpression() && !this.isFunctionExpression() && !this.isFunctionDeclaration()) {
|
| 109 |
+
throw this.buildCodeFrameError("Can only unwrap the environment of a function.");
|
| 110 |
+
}
|
| 111 |
+
hoistFunctionEnvironment(this);
|
| 112 |
+
}
|
| 113 |
+
function setType(path, type) {
|
| 114 |
+
path.node.type = type;
|
| 115 |
+
}
|
| 116 |
+
function arrowFunctionToExpression({
|
| 117 |
+
allowInsertArrow = true,
|
| 118 |
+
allowInsertArrowWithRest = allowInsertArrow,
|
| 119 |
+
noNewArrows = !(_arguments$ => (_arguments$ = arguments[0]) == null ? void 0 : _arguments$.specCompliant)()
|
| 120 |
+
} = {}) {
|
| 121 |
+
if (!this.isArrowFunctionExpression()) {
|
| 122 |
+
throw this.buildCodeFrameError("Cannot convert non-arrow function to a function expression.");
|
| 123 |
+
}
|
| 124 |
+
let self = this;
|
| 125 |
+
if (!noNewArrows) {
|
| 126 |
+
var _self$ensureFunctionN;
|
| 127 |
+
self = (_self$ensureFunctionN = self.ensureFunctionName(false)) != null ? _self$ensureFunctionN : self;
|
| 128 |
+
}
|
| 129 |
+
const {
|
| 130 |
+
thisBinding,
|
| 131 |
+
fnPath: fn
|
| 132 |
+
} = hoistFunctionEnvironment(self, noNewArrows, allowInsertArrow, allowInsertArrowWithRest);
|
| 133 |
+
fn.ensureBlock();
|
| 134 |
+
setType(fn, "FunctionExpression");
|
| 135 |
+
if (!noNewArrows) {
|
| 136 |
+
const checkBinding = thisBinding ? null : fn.scope.generateUidIdentifier("arrowCheckId");
|
| 137 |
+
if (checkBinding) {
|
| 138 |
+
fn.parentPath.scope.push({
|
| 139 |
+
id: checkBinding,
|
| 140 |
+
init: objectExpression([])
|
| 141 |
+
});
|
| 142 |
+
}
|
| 143 |
+
fn.get("body").unshiftContainer("body", expressionStatement(callExpression(this.hub.addHelper("newArrowCheck"), [thisExpression(), checkBinding ? identifier(checkBinding.name) : identifier(thisBinding)])));
|
| 144 |
+
fn.replaceWith(callExpression(memberExpression(fn.node, identifier("bind")), [checkBinding ? identifier(checkBinding.name) : thisExpression()]));
|
| 145 |
+
return fn.get("callee.object");
|
| 146 |
+
}
|
| 147 |
+
return fn;
|
| 148 |
+
}
|
| 149 |
+
const getSuperCallsVisitor = (0, _visitors.environmentVisitor)({
|
| 150 |
+
CallExpression(child, {
|
| 151 |
+
allSuperCalls
|
| 152 |
+
}) {
|
| 153 |
+
if (!child.get("callee").isSuper()) return;
|
| 154 |
+
allSuperCalls.push(child);
|
| 155 |
+
}
|
| 156 |
+
});
|
| 157 |
+
function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow = true, allowInsertArrowWithRest = true) {
|
| 158 |
+
let arrowParent;
|
| 159 |
+
let thisEnvFn = fnPath.findParent(p => {
|
| 160 |
+
if (p.isArrowFunctionExpression()) {
|
| 161 |
+
arrowParent != null ? arrowParent : arrowParent = p;
|
| 162 |
+
return false;
|
| 163 |
+
}
|
| 164 |
+
return p.isFunction() || p.isProgram() || p.isClassProperty({
|
| 165 |
+
static: false
|
| 166 |
+
}) || p.isClassPrivateProperty({
|
| 167 |
+
static: false
|
| 168 |
+
});
|
| 169 |
+
});
|
| 170 |
+
const inConstructor = thisEnvFn.isClassMethod({
|
| 171 |
+
kind: "constructor"
|
| 172 |
+
});
|
| 173 |
+
if (thisEnvFn.isClassProperty() || thisEnvFn.isClassPrivateProperty()) {
|
| 174 |
+
if (arrowParent) {
|
| 175 |
+
thisEnvFn = arrowParent;
|
| 176 |
+
} else if (allowInsertArrow) {
|
| 177 |
+
fnPath.replaceWith(callExpression(arrowFunctionExpression([], toExpression(fnPath.node)), []));
|
| 178 |
+
thisEnvFn = fnPath.get("callee");
|
| 179 |
+
fnPath = thisEnvFn.get("body");
|
| 180 |
+
} else {
|
| 181 |
+
throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property");
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
const {
|
| 185 |
+
thisPaths,
|
| 186 |
+
argumentsPaths,
|
| 187 |
+
newTargetPaths,
|
| 188 |
+
superProps,
|
| 189 |
+
superCalls
|
| 190 |
+
} = getScopeInformation(fnPath);
|
| 191 |
+
if (inConstructor && superCalls.length > 0) {
|
| 192 |
+
if (!allowInsertArrow) {
|
| 193 |
+
throw superCalls[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', " + "it's not possible to compile `super()` in an arrow function without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration.");
|
| 194 |
+
}
|
| 195 |
+
if (!allowInsertArrowWithRest) {
|
| 196 |
+
throw superCalls[0].buildCodeFrameError("When using '@babel/plugin-transform-parameters', " + "it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration.");
|
| 197 |
+
}
|
| 198 |
+
const allSuperCalls = [];
|
| 199 |
+
thisEnvFn.traverse(getSuperCallsVisitor, {
|
| 200 |
+
allSuperCalls
|
| 201 |
+
});
|
| 202 |
+
const superBinding = getSuperBinding(thisEnvFn);
|
| 203 |
+
allSuperCalls.forEach(superCall => {
|
| 204 |
+
const callee = identifier(superBinding);
|
| 205 |
+
callee.loc = superCall.node.callee.loc;
|
| 206 |
+
superCall.get("callee").replaceWith(callee);
|
| 207 |
+
});
|
| 208 |
+
}
|
| 209 |
+
if (argumentsPaths.length > 0) {
|
| 210 |
+
const argumentsBinding = getBinding(thisEnvFn, "arguments", () => {
|
| 211 |
+
const args = () => identifier("arguments");
|
| 212 |
+
if (thisEnvFn.scope.path.isProgram()) {
|
| 213 |
+
return conditionalExpression(binaryExpression("===", unaryExpression("typeof", args()), stringLiteral("undefined")), thisEnvFn.scope.buildUndefinedNode(), args());
|
| 214 |
+
} else {
|
| 215 |
+
return args();
|
| 216 |
+
}
|
| 217 |
+
});
|
| 218 |
+
argumentsPaths.forEach(argumentsChild => {
|
| 219 |
+
const argsRef = identifier(argumentsBinding);
|
| 220 |
+
argsRef.loc = argumentsChild.node.loc;
|
| 221 |
+
argumentsChild.replaceWith(argsRef);
|
| 222 |
+
});
|
| 223 |
+
}
|
| 224 |
+
if (newTargetPaths.length > 0) {
|
| 225 |
+
const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => metaProperty(identifier("new"), identifier("target")));
|
| 226 |
+
newTargetPaths.forEach(targetChild => {
|
| 227 |
+
const targetRef = identifier(newTargetBinding);
|
| 228 |
+
targetRef.loc = targetChild.node.loc;
|
| 229 |
+
targetChild.replaceWith(targetRef);
|
| 230 |
+
});
|
| 231 |
+
}
|
| 232 |
+
if (superProps.length > 0) {
|
| 233 |
+
if (!allowInsertArrow) {
|
| 234 |
+
throw superProps[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', " + "it's not possible to compile `super.prop` in an arrow function without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration.");
|
| 235 |
+
}
|
| 236 |
+
const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []);
|
| 237 |
+
flatSuperProps.forEach(superProp => {
|
| 238 |
+
const key = superProp.node.computed ? "" : superProp.get("property").node.name;
|
| 239 |
+
const superParentPath = superProp.parentPath;
|
| 240 |
+
const isAssignment = superParentPath.isAssignmentExpression({
|
| 241 |
+
left: superProp.node
|
| 242 |
+
});
|
| 243 |
+
const isCall = superParentPath.isCallExpression({
|
| 244 |
+
callee: superProp.node
|
| 245 |
+
});
|
| 246 |
+
const isTaggedTemplate = superParentPath.isTaggedTemplateExpression({
|
| 247 |
+
tag: superProp.node
|
| 248 |
+
});
|
| 249 |
+
const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
|
| 250 |
+
const args = [];
|
| 251 |
+
if (superProp.node.computed) {
|
| 252 |
+
args.push(superProp.get("property").node);
|
| 253 |
+
}
|
| 254 |
+
if (isAssignment) {
|
| 255 |
+
const value = superParentPath.node.right;
|
| 256 |
+
args.push(value);
|
| 257 |
+
}
|
| 258 |
+
const call = callExpression(identifier(superBinding), args);
|
| 259 |
+
if (isCall) {
|
| 260 |
+
superParentPath.unshiftContainer("arguments", thisExpression());
|
| 261 |
+
superProp.replaceWith(memberExpression(call, identifier("call")));
|
| 262 |
+
thisPaths.push(superParentPath.get("arguments.0"));
|
| 263 |
+
} else if (isAssignment) {
|
| 264 |
+
superParentPath.replaceWith(call);
|
| 265 |
+
} else if (isTaggedTemplate) {
|
| 266 |
+
superProp.replaceWith(callExpression(memberExpression(call, identifier("bind"), false), [thisExpression()]));
|
| 267 |
+
thisPaths.push(superProp.get("arguments.0"));
|
| 268 |
+
} else {
|
| 269 |
+
superProp.replaceWith(call);
|
| 270 |
+
}
|
| 271 |
+
});
|
| 272 |
+
}
|
| 273 |
+
let thisBinding;
|
| 274 |
+
if (thisPaths.length > 0 || !noNewArrows) {
|
| 275 |
+
thisBinding = getThisBinding(thisEnvFn, inConstructor);
|
| 276 |
+
if (noNewArrows || inConstructor && hasSuperClass(thisEnvFn)) {
|
| 277 |
+
thisPaths.forEach(thisChild => {
|
| 278 |
+
const thisRef = thisChild.isJSX() ? jsxIdentifier(thisBinding) : identifier(thisBinding);
|
| 279 |
+
thisRef.loc = thisChild.node.loc;
|
| 280 |
+
thisChild.replaceWith(thisRef);
|
| 281 |
+
});
|
| 282 |
+
if (!noNewArrows) thisBinding = null;
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
return {
|
| 286 |
+
thisBinding: thisBinding,
|
| 287 |
+
fnPath
|
| 288 |
+
};
|
| 289 |
+
}
|
| 290 |
+
function isLogicalOp(op) {
|
| 291 |
+
return LOGICAL_OPERATORS.includes(op);
|
| 292 |
+
}
|
| 293 |
+
function standardizeSuperProperty(superProp) {
|
| 294 |
+
if (superProp.parentPath.isAssignmentExpression() && superProp.parentPath.node.operator !== "=") {
|
| 295 |
+
const assignmentPath = superProp.parentPath;
|
| 296 |
+
const op = assignmentPath.node.operator.slice(0, -1);
|
| 297 |
+
const value = assignmentPath.node.right;
|
| 298 |
+
const isLogicalAssignment = isLogicalOp(op);
|
| 299 |
+
if (superProp.node.computed) {
|
| 300 |
+
const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
|
| 301 |
+
const {
|
| 302 |
+
object,
|
| 303 |
+
property
|
| 304 |
+
} = superProp.node;
|
| 305 |
+
assignmentPath.get("left").replaceWith(memberExpression(object, assignmentExpression("=", tmp, property), true));
|
| 306 |
+
assignmentPath.get("right").replaceWith(rightExpression(isLogicalAssignment ? "=" : op, memberExpression(object, identifier(tmp.name), true), value));
|
| 307 |
+
} else {
|
| 308 |
+
const object = superProp.node.object;
|
| 309 |
+
const property = superProp.node.property;
|
| 310 |
+
assignmentPath.get("left").replaceWith(memberExpression(object, property));
|
| 311 |
+
assignmentPath.get("right").replaceWith(rightExpression(isLogicalAssignment ? "=" : op, memberExpression(object, identifier(property.name)), value));
|
| 312 |
+
}
|
| 313 |
+
if (isLogicalAssignment) {
|
| 314 |
+
assignmentPath.replaceWith(logicalExpression(op, assignmentPath.node.left, assignmentPath.node.right));
|
| 315 |
+
} else {
|
| 316 |
+
assignmentPath.node.operator = "=";
|
| 317 |
+
}
|
| 318 |
+
return [assignmentPath.get("left"), assignmentPath.get("right").get("left")];
|
| 319 |
+
} else if (superProp.parentPath.isUpdateExpression()) {
|
| 320 |
+
const updateExpr = superProp.parentPath;
|
| 321 |
+
const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
|
| 322 |
+
const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
|
| 323 |
+
const parts = [assignmentExpression("=", tmp, memberExpression(superProp.node.object, computedKey ? assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), assignmentExpression("=", memberExpression(superProp.node.object, computedKey ? identifier(computedKey.name) : superProp.node.property, superProp.node.computed), binaryExpression(superProp.parentPath.node.operator[0], identifier(tmp.name), numericLiteral(1)))];
|
| 324 |
+
if (!superProp.parentPath.node.prefix) {
|
| 325 |
+
parts.push(identifier(tmp.name));
|
| 326 |
+
}
|
| 327 |
+
updateExpr.replaceWith(sequenceExpression(parts));
|
| 328 |
+
const left = updateExpr.get("expressions.0.right");
|
| 329 |
+
const right = updateExpr.get("expressions.1.left");
|
| 330 |
+
return [left, right];
|
| 331 |
+
}
|
| 332 |
+
return [superProp];
|
| 333 |
+
function rightExpression(op, left, right) {
|
| 334 |
+
if (op === "=") {
|
| 335 |
+
return assignmentExpression("=", left, right);
|
| 336 |
+
} else {
|
| 337 |
+
return binaryExpression(op, left, right);
|
| 338 |
+
}
|
| 339 |
+
}
|
| 340 |
+
}
|
| 341 |
+
function hasSuperClass(thisEnvFn) {
|
| 342 |
+
return thisEnvFn.isClassMethod() && !!thisEnvFn.parentPath.parentPath.node.superClass;
|
| 343 |
+
}
|
| 344 |
+
const assignSuperThisVisitor = (0, _visitors.environmentVisitor)({
|
| 345 |
+
CallExpression(child, {
|
| 346 |
+
supers,
|
| 347 |
+
thisBinding
|
| 348 |
+
}) {
|
| 349 |
+
if (!child.get("callee").isSuper()) return;
|
| 350 |
+
if (supers.has(child.node)) return;
|
| 351 |
+
supers.add(child.node);
|
| 352 |
+
child.replaceWithMultiple([child.node, assignmentExpression("=", identifier(thisBinding), identifier("this"))]);
|
| 353 |
+
}
|
| 354 |
+
});
|
| 355 |
+
function getThisBinding(thisEnvFn, inConstructor) {
|
| 356 |
+
return getBinding(thisEnvFn, "this", thisBinding => {
|
| 357 |
+
if (!inConstructor || !hasSuperClass(thisEnvFn)) return thisExpression();
|
| 358 |
+
thisEnvFn.traverse(assignSuperThisVisitor, {
|
| 359 |
+
supers: new WeakSet(),
|
| 360 |
+
thisBinding
|
| 361 |
+
});
|
| 362 |
+
});
|
| 363 |
+
}
|
| 364 |
+
function getSuperBinding(thisEnvFn) {
|
| 365 |
+
return getBinding(thisEnvFn, "supercall", () => {
|
| 366 |
+
const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
|
| 367 |
+
return arrowFunctionExpression([restElement(argsBinding)], callExpression(_super(), [spreadElement(identifier(argsBinding.name))]));
|
| 368 |
+
});
|
| 369 |
+
}
|
| 370 |
+
function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
|
| 371 |
+
const op = isAssignment ? "set" : "get";
|
| 372 |
+
return getBinding(thisEnvFn, `superprop_${op}:${propName || ""}`, () => {
|
| 373 |
+
const argsList = [];
|
| 374 |
+
let fnBody;
|
| 375 |
+
if (propName) {
|
| 376 |
+
fnBody = memberExpression(_super(), identifier(propName));
|
| 377 |
+
} else {
|
| 378 |
+
const method = thisEnvFn.scope.generateUidIdentifier("prop");
|
| 379 |
+
argsList.unshift(method);
|
| 380 |
+
fnBody = memberExpression(_super(), identifier(method.name), true);
|
| 381 |
+
}
|
| 382 |
+
if (isAssignment) {
|
| 383 |
+
const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
|
| 384 |
+
argsList.push(valueIdent);
|
| 385 |
+
fnBody = assignmentExpression("=", fnBody, identifier(valueIdent.name));
|
| 386 |
+
}
|
| 387 |
+
return arrowFunctionExpression(argsList, fnBody);
|
| 388 |
+
});
|
| 389 |
+
}
|
| 390 |
+
function getBinding(thisEnvFn, key, init) {
|
| 391 |
+
const cacheKey = "binding:" + key;
|
| 392 |
+
let data = thisEnvFn.getData(cacheKey);
|
| 393 |
+
if (!data) {
|
| 394 |
+
const id = thisEnvFn.scope.generateUidIdentifier(key);
|
| 395 |
+
data = id.name;
|
| 396 |
+
thisEnvFn.setData(cacheKey, data);
|
| 397 |
+
thisEnvFn.scope.push({
|
| 398 |
+
id: id,
|
| 399 |
+
init: init(data)
|
| 400 |
+
});
|
| 401 |
+
}
|
| 402 |
+
return data;
|
| 403 |
+
}
|
| 404 |
+
const getScopeInformationVisitor = (0, _visitors.environmentVisitor)({
|
| 405 |
+
ThisExpression(child, {
|
| 406 |
+
thisPaths
|
| 407 |
+
}) {
|
| 408 |
+
thisPaths.push(child);
|
| 409 |
+
},
|
| 410 |
+
JSXIdentifier(child, {
|
| 411 |
+
thisPaths
|
| 412 |
+
}) {
|
| 413 |
+
if (child.node.name !== "this") return;
|
| 414 |
+
if (!child.parentPath.isJSXMemberExpression({
|
| 415 |
+
object: child.node
|
| 416 |
+
}) && !child.parentPath.isJSXOpeningElement({
|
| 417 |
+
name: child.node
|
| 418 |
+
})) {
|
| 419 |
+
return;
|
| 420 |
+
}
|
| 421 |
+
thisPaths.push(child);
|
| 422 |
+
},
|
| 423 |
+
CallExpression(child, {
|
| 424 |
+
superCalls
|
| 425 |
+
}) {
|
| 426 |
+
if (child.get("callee").isSuper()) superCalls.push(child);
|
| 427 |
+
},
|
| 428 |
+
MemberExpression(child, {
|
| 429 |
+
superProps
|
| 430 |
+
}) {
|
| 431 |
+
if (child.get("object").isSuper()) superProps.push(child);
|
| 432 |
+
},
|
| 433 |
+
Identifier(child, {
|
| 434 |
+
argumentsPaths
|
| 435 |
+
}) {
|
| 436 |
+
if (!child.isReferencedIdentifier({
|
| 437 |
+
name: "arguments"
|
| 438 |
+
})) return;
|
| 439 |
+
let curr = child.scope;
|
| 440 |
+
do {
|
| 441 |
+
if (curr.hasOwnBinding("arguments")) {
|
| 442 |
+
curr.rename("arguments");
|
| 443 |
+
return;
|
| 444 |
+
}
|
| 445 |
+
if (curr.path.isFunction() && !curr.path.isArrowFunctionExpression()) {
|
| 446 |
+
break;
|
| 447 |
+
}
|
| 448 |
+
} while (curr = curr.parent);
|
| 449 |
+
argumentsPaths.push(child);
|
| 450 |
+
},
|
| 451 |
+
MetaProperty(child, {
|
| 452 |
+
newTargetPaths
|
| 453 |
+
}) {
|
| 454 |
+
if (!child.get("meta").isIdentifier({
|
| 455 |
+
name: "new"
|
| 456 |
+
})) return;
|
| 457 |
+
if (!child.get("property").isIdentifier({
|
| 458 |
+
name: "target"
|
| 459 |
+
})) return;
|
| 460 |
+
newTargetPaths.push(child);
|
| 461 |
+
}
|
| 462 |
+
});
|
| 463 |
+
function getScopeInformation(fnPath) {
|
| 464 |
+
const thisPaths = [];
|
| 465 |
+
const argumentsPaths = [];
|
| 466 |
+
const newTargetPaths = [];
|
| 467 |
+
const superProps = [];
|
| 468 |
+
const superCalls = [];
|
| 469 |
+
fnPath.traverse(getScopeInformationVisitor, {
|
| 470 |
+
thisPaths,
|
| 471 |
+
argumentsPaths,
|
| 472 |
+
newTargetPaths,
|
| 473 |
+
superProps,
|
| 474 |
+
superCalls
|
| 475 |
+
});
|
| 476 |
+
return {
|
| 477 |
+
thisPaths,
|
| 478 |
+
argumentsPaths,
|
| 479 |
+
newTargetPaths,
|
| 480 |
+
superProps,
|
| 481 |
+
superCalls
|
| 482 |
+
};
|
| 483 |
+
}
|
| 484 |
+
function splitExportDeclaration() {
|
| 485 |
+
if (!this.isExportDeclaration() || this.isExportAllDeclaration()) {
|
| 486 |
+
throw new Error("Only default and named export declarations can be split.");
|
| 487 |
+
}
|
| 488 |
+
if (this.isExportNamedDeclaration() && this.get("specifiers").length > 0) {
|
| 489 |
+
throw new Error("It doesn't make sense to split exported specifiers.");
|
| 490 |
+
}
|
| 491 |
+
const declaration = this.get("declaration");
|
| 492 |
+
if (this.isExportDefaultDeclaration()) {
|
| 493 |
+
const standaloneDeclaration = declaration.isFunctionDeclaration() || declaration.isClassDeclaration();
|
| 494 |
+
const exportExpr = declaration.isFunctionExpression() || declaration.isClassExpression();
|
| 495 |
+
const scope = declaration.isScope() ? declaration.scope.parent : declaration.scope;
|
| 496 |
+
let id = declaration.node.id;
|
| 497 |
+
let needBindingRegistration = false;
|
| 498 |
+
if (!id) {
|
| 499 |
+
needBindingRegistration = true;
|
| 500 |
+
id = scope.generateUidIdentifier("default");
|
| 501 |
+
if (standaloneDeclaration || exportExpr) {
|
| 502 |
+
declaration.node.id = cloneNode(id);
|
| 503 |
+
}
|
| 504 |
+
} else if (exportExpr && scope.hasBinding(id.name)) {
|
| 505 |
+
needBindingRegistration = true;
|
| 506 |
+
id = scope.generateUidIdentifier(id.name);
|
| 507 |
+
}
|
| 508 |
+
const updatedDeclaration = standaloneDeclaration ? declaration.node : variableDeclaration("var", [variableDeclarator(cloneNode(id), declaration.node)]);
|
| 509 |
+
const updatedExportDeclaration = exportNamedDeclaration(null, [exportSpecifier(cloneNode(id), identifier("default"))]);
|
| 510 |
+
this.insertAfter(updatedExportDeclaration);
|
| 511 |
+
this.replaceWith(updatedDeclaration);
|
| 512 |
+
if (needBindingRegistration) {
|
| 513 |
+
scope.registerDeclaration(this);
|
| 514 |
+
}
|
| 515 |
+
return this;
|
| 516 |
+
} else if (this.get("specifiers").length > 0) {
|
| 517 |
+
throw new Error("It doesn't make sense to split exported specifiers.");
|
| 518 |
+
}
|
| 519 |
+
const bindingIdentifiers = declaration.getOuterBindingIdentifiers();
|
| 520 |
+
const specifiers = Object.keys(bindingIdentifiers).map(name => {
|
| 521 |
+
return exportSpecifier(identifier(name), identifier(name));
|
| 522 |
+
});
|
| 523 |
+
const aliasDeclar = exportNamedDeclaration(null, specifiers);
|
| 524 |
+
this.insertAfter(aliasDeclar);
|
| 525 |
+
this.replaceWith(declaration.node);
|
| 526 |
+
return this;
|
| 527 |
+
}
|
| 528 |
+
const refersOuterBindingVisitor = {
|
| 529 |
+
"ReferencedIdentifier|BindingIdentifier"(path, state) {
|
| 530 |
+
if (path.node.name !== state.name) return;
|
| 531 |
+
state.needsRename = true;
|
| 532 |
+
path.stop();
|
| 533 |
+
},
|
| 534 |
+
Scope(path, state) {
|
| 535 |
+
if (path.scope.hasOwnBinding(state.name)) {
|
| 536 |
+
path.skip();
|
| 537 |
+
}
|
| 538 |
+
}
|
| 539 |
+
};
|
| 540 |
+
function ensureFunctionName(supportUnicodeId) {
|
| 541 |
+
if (this.node.id) return this;
|
| 542 |
+
const res = getFunctionName(this.node, this.parent);
|
| 543 |
+
if (res == null) return this;
|
| 544 |
+
let {
|
| 545 |
+
name
|
| 546 |
+
} = res;
|
| 547 |
+
if (!supportUnicodeId && /[\uD800-\uDFFF]/.test(name)) {
|
| 548 |
+
return null;
|
| 549 |
+
}
|
| 550 |
+
if (name.startsWith("get ") || name.startsWith("set ")) {
|
| 551 |
+
return null;
|
| 552 |
+
}
|
| 553 |
+
name = toBindingIdentifierName(name.replace(/[/ ]/g, "_"));
|
| 554 |
+
const id = identifier(name);
|
| 555 |
+
inherits(id, res.originalNode);
|
| 556 |
+
const state = {
|
| 557 |
+
needsRename: false,
|
| 558 |
+
name
|
| 559 |
+
};
|
| 560 |
+
const {
|
| 561 |
+
scope
|
| 562 |
+
} = this;
|
| 563 |
+
const binding = scope.getOwnBinding(name);
|
| 564 |
+
if (binding) {
|
| 565 |
+
if (binding.kind === "param") {
|
| 566 |
+
state.needsRename = true;
|
| 567 |
+
} else {}
|
| 568 |
+
} else if (scope.parent.hasBinding(name) || scope.hasGlobal(name)) {
|
| 569 |
+
this.traverse(refersOuterBindingVisitor, state);
|
| 570 |
+
}
|
| 571 |
+
if (!state.needsRename) {
|
| 572 |
+
this.node.id = id;
|
| 573 |
+
scope.getProgramParent().references[id.name] = true;
|
| 574 |
+
return this;
|
| 575 |
+
}
|
| 576 |
+
if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) {
|
| 577 |
+
scope.rename(id.name);
|
| 578 |
+
this.node.id = id;
|
| 579 |
+
scope.getProgramParent().references[id.name] = true;
|
| 580 |
+
return this;
|
| 581 |
+
}
|
| 582 |
+
if (!isFunction(this.node)) return null;
|
| 583 |
+
const key = scope.generateUidIdentifier(id.name);
|
| 584 |
+
const params = [];
|
| 585 |
+
for (let i = 0, len = getFunctionArity(this.node); i < len; i++) {
|
| 586 |
+
params.push(scope.generateUidIdentifier("x"));
|
| 587 |
+
}
|
| 588 |
+
const call = _template.default.expression.ast`
|
| 589 |
+
(function (${key}) {
|
| 590 |
+
function ${id}(${params}) {
|
| 591 |
+
return ${cloneNode(key)}.apply(this, arguments);
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
${cloneNode(id)}.toString = function () {
|
| 595 |
+
return ${cloneNode(key)}.toString();
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
return ${cloneNode(id)};
|
| 599 |
+
})(${toExpression(this.node)})
|
| 600 |
+
`;
|
| 601 |
+
return this.replaceWith(call)[0].get("arguments.0");
|
| 602 |
+
}
|
| 603 |
+
function getFunctionArity(node) {
|
| 604 |
+
const count = node.params.findIndex(param => isAssignmentPattern(param) || isRestElement(param));
|
| 605 |
+
return count === -1 ? node.params.length : count;
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
//# sourceMappingURL=conversion.js.map
|
node_modules/@babel/traverse/lib/path/conversion.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_t","require","_template","_visitors","_context","arrowFunctionExpression","assignmentExpression","binaryExpression","blockStatement","callExpression","conditionalExpression","expressionStatement","identifier","isIdentifier","jsxIdentifier","logicalExpression","LOGICAL_OPERATORS","memberExpression","metaProperty","numericLiteral","objectExpression","restElement","returnStatement","sequenceExpression","spreadElement","stringLiteral","super","_super","thisExpression","toExpression","unaryExpression","toBindingIdentifierName","isFunction","isAssignmentPattern","isRestElement","getFunctionName","cloneNode","variableDeclaration","variableDeclarator","exportNamedDeclaration","exportSpecifier","inherits","toComputedKey","key","isMemberExpression","node","property","isProperty","isMethod","ReferenceError","computed","name","ensureBlock","body","get","bodyNode","Array","isArray","Error","isBlockStatement","statements","stringPath","listKey","isStatement","push","parentPath","setup","call","exports","arrowFunctionToShadowed","isArrowFunctionExpression","arrowFunctionToExpression","unwrapFunctionEnvironment","isFunctionExpression","isFunctionDeclaration","buildCodeFrameError","hoistFunctionEnvironment","setType","path","type","allowInsertArrow","allowInsertArrowWithRest","noNewArrows","_arguments$","arguments","specCompliant","self","_self$ensureFunctionN","ensureFunctionName","thisBinding","fnPath","fn","checkBinding","scope","generateUidIdentifier","id","init","unshiftContainer","hub","addHelper","replaceWith","getSuperCallsVisitor","environmentVisitor","CallExpression","child","allSuperCalls","isSuper","arrowParent","thisEnvFn","findParent","p","isProgram","isClassProperty","static","isClassPrivateProperty","inConstructor","isClassMethod","kind","thisPaths","argumentsPaths","newTargetPaths","superProps","superCalls","getScopeInformation","length","traverse","superBinding","getSuperBinding","forEach","superCall","callee","loc","argumentsBinding","getBinding","args","buildUndefinedNode","argumentsChild","argsRef","newTargetBinding","targetChild","targetRef","flatSuperProps","reduce","acc","superProp","concat","standardizeSuperProperty","superParentPath","isAssignment","isAssignmentExpression","left","isCall","isCallExpression","isTaggedTemplate","isTaggedTemplateExpression","tag","getSuperPropBinding","value","right","getThisBinding","hasSuperClass","thisChild","thisRef","isJSX","isLogicalOp","op","includes","operator","assignmentPath","slice","isLogicalAssignment","tmp","generateDeclaredUidIdentifier","object","rightExpression","isUpdateExpression","updateExpr","computedKey","parts","prefix","superClass","assignSuperThisVisitor","supers","has","add","replaceWithMultiple","WeakSet","argsBinding","propName","argsList","fnBody","method","unshift","valueIdent","cacheKey","data","getData","setData","getScopeInformationVisitor","ThisExpression","JSXIdentifier","isJSXMemberExpression","isJSXOpeningElement","MemberExpression","Identifier","isReferencedIdentifier","curr","hasOwnBinding","rename","parent","MetaProperty","splitExportDeclaration","isExportDeclaration","isExportAllDeclaration","isExportNamedDeclaration","declaration","isExportDefaultDeclaration","standaloneDeclaration","isClassDeclaration","exportExpr","isClassExpression","isScope","needBindingRegistration","hasBinding","updatedDeclaration","updatedExportDeclaration","insertAfter","registerDeclaration","bindingIdentifiers","getOuterBindingIdentifiers","specifiers","Object","keys","map","aliasDeclar","refersOuterBindingVisitor","ReferencedIdentifier|BindingIdentifier","state","needsRename","stop","Scope","skip","supportUnicodeId","res","test","startsWith","replace","originalNode","binding","getOwnBinding","hasGlobal","getProgramParent","references","params","i","len","getFunctionArity","template","expression","ast","count","findIndex","param"],"sources":["../../src/path/conversion.ts"],"sourcesContent":["// This file contains methods that convert the path node into another node or some other type of data.\n\nimport {\n arrowFunctionExpression,\n assignmentExpression,\n binaryExpression,\n blockStatement,\n callExpression,\n conditionalExpression,\n expressionStatement,\n identifier,\n isIdentifier,\n jsxIdentifier,\n logicalExpression,\n LOGICAL_OPERATORS,\n memberExpression,\n metaProperty,\n numericLiteral,\n objectExpression,\n restElement,\n returnStatement,\n sequenceExpression,\n spreadElement,\n stringLiteral,\n super as _super,\n thisExpression,\n toExpression,\n unaryExpression,\n toBindingIdentifierName,\n isFunction,\n isAssignmentPattern,\n isRestElement,\n getFunctionName,\n cloneNode,\n variableDeclaration,\n variableDeclarator,\n exportNamedDeclaration,\n exportSpecifier,\n inherits,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport template from \"@babel/template\";\nimport { environmentVisitor } from \"../visitors.ts\";\nimport type NodePath from \"./index.ts\";\nimport type { Visitor } from \"../types.ts\";\nimport { setup } from \"./context.ts\";\nimport type Scope from \"../scope/index.ts\";\n\nexport function toComputedKey(this: NodePath) {\n let key;\n if (this.isMemberExpression()) {\n key = this.node.property;\n } else if (this.isProperty() || this.isMethod()) {\n key = this.node.key;\n } else {\n throw new ReferenceError(\"todo\");\n }\n\n // @ts-expect-error todo(flow->ts) computed does not exist in ClassPrivateProperty\n if (!this.node.computed) {\n if (isIdentifier(key)) key = stringLiteral(key.name);\n }\n\n return key;\n}\n\nexport function ensureBlock(\n this: NodePath<\n t.Loop | t.WithStatement | t.Function | t.LabeledStatement | t.CatchClause\n >,\n): void {\n const body = this.get(\"body\");\n const bodyNode = body.node;\n\n if (Array.isArray(body)) {\n throw new Error(\"Can't convert array path to a block statement\");\n }\n if (!bodyNode) {\n throw new Error(\"Can't convert node without a body\");\n }\n\n if (body.isBlockStatement()) {\n // @ts-expect-error TS throws because ensureBlock returns the body node path\n // however, we don't use the return value and treat it as a transform and\n // assertion utilities. For better type inference we annotate it as an\n // assertion method\n // TODO: Unify the implementation with the type definition\n return bodyNode;\n }\n\n const statements: t.Statement[] = [];\n\n let stringPath = \"body\";\n let key;\n let listKey;\n if (body.isStatement()) {\n listKey = \"body\";\n key = 0;\n statements.push(body.node);\n } else {\n stringPath += \".body.0\";\n if (this.isFunction()) {\n key = \"argument\";\n statements.push(returnStatement(body.node as t.Expression));\n } else {\n key = \"expression\";\n statements.push(expressionStatement(body.node as t.Expression));\n }\n }\n\n this.node.body = blockStatement(statements);\n const parentPath = this.get(stringPath) as NodePath;\n setup.call(\n body,\n parentPath,\n listKey\n ? // @ts-expect-error listKey must present in parent path\n parentPath.node[listKey]\n : parentPath.node,\n listKey,\n key,\n );\n\n // @ts-expect-error TS throws because ensureBlock returns the body node path\n // however, we don't use the return value and treat it as a transform and\n // assertion utilities. For better type inference we annotate it as an\n // assertion method\n // TODO: Unify the implementation with the type definition\n return this.node;\n}\n\nif (!process.env.BABEL_8_BREAKING && !USE_ESM) {\n /**\n * Keeping this for backward-compatibility. You should use arrowFunctionToExpression() for >=7.x.\n */\n // eslint-disable-next-line no-restricted-globals\n exports.arrowFunctionToShadowed = function (this: NodePath) {\n if (!this.isArrowFunctionExpression()) return;\n\n this.arrowFunctionToExpression();\n };\n}\n\n/**\n * Given an arbitrary function, process its content as if it were an arrow function, moving references\n * to \"this\", \"arguments\", \"super\", and such into the function's parent scope. This method is useful if\n * you have wrapped some set of items in an IIFE or other function, but want \"this\", \"arguments\", and super\"\n * to continue behaving as expected.\n */\nexport function unwrapFunctionEnvironment(this: NodePath) {\n if (\n !this.isArrowFunctionExpression() &&\n !this.isFunctionExpression() &&\n !this.isFunctionDeclaration()\n ) {\n throw this.buildCodeFrameError(\n \"Can only unwrap the environment of a function.\",\n );\n }\n\n hoistFunctionEnvironment(this);\n}\n\nfunction setType<N extends t.Node, T extends N[\"type\"]>(\n path: NodePath<N>,\n type: T,\n): asserts path is NodePath<Extract<N, { type: T }>> {\n path.node.type = type;\n}\n\n/**\n * Convert a given arrow function into a normal ES5 function expression.\n */\nexport function arrowFunctionToExpression(\n this: NodePath<t.ArrowFunctionExpression>,\n {\n allowInsertArrow = true,\n allowInsertArrowWithRest = allowInsertArrow,\n noNewArrows = process.env.BABEL_8_BREAKING\n ? // TODO(Babel 8): Consider defaulting to `false` for spec compliance\n true\n : !arguments[0]?.specCompliant,\n }: {\n allowInsertArrow?: boolean | void;\n allowInsertArrowWithRest?: boolean | void;\n noNewArrows?: boolean;\n } = {},\n): NodePath<\n Exclude<t.Function, t.Method | t.ArrowFunctionExpression> | t.CallExpression\n> {\n if (!this.isArrowFunctionExpression()) {\n throw (this as NodePath).buildCodeFrameError(\n \"Cannot convert non-arrow function to a function expression.\",\n );\n }\n\n let self = this;\n if (!noNewArrows) {\n // @ts-expect-error This is technicallynot valid on arrow functions\n // because it adds an .id property, but we are going to convert it\n // to a function expression anyway\n self = self.ensureFunctionName(false) ?? self;\n }\n\n const { thisBinding, fnPath: fn } = hoistFunctionEnvironment(\n self,\n noNewArrows,\n allowInsertArrow,\n allowInsertArrowWithRest,\n );\n\n fn.ensureBlock();\n setType(fn, \"FunctionExpression\");\n\n if (!noNewArrows) {\n const checkBinding = thisBinding\n ? null\n : fn.scope.generateUidIdentifier(\"arrowCheckId\");\n if (checkBinding) {\n fn.parentPath.scope.push({\n id: checkBinding,\n init: objectExpression([]),\n });\n }\n\n fn.get(\"body\").unshiftContainer(\n \"body\",\n expressionStatement(\n callExpression(this.hub.addHelper(\"newArrowCheck\"), [\n thisExpression(),\n checkBinding\n ? identifier(checkBinding.name)\n : identifier(thisBinding),\n ]),\n ),\n );\n\n fn.replaceWith(\n callExpression(memberExpression(fn.node, identifier(\"bind\")), [\n checkBinding ? identifier(checkBinding.name) : thisExpression(),\n ]),\n );\n\n return fn.get(\"callee.object\");\n }\n\n return fn;\n}\n\nconst getSuperCallsVisitor = environmentVisitor<{\n allSuperCalls: NodePath<t.CallExpression>[];\n}>({\n CallExpression(child, { allSuperCalls }) {\n if (!child.get(\"callee\").isSuper()) return;\n allSuperCalls.push(child);\n },\n});\n\n/**\n * Given a function, traverse its contents, and if there are references to \"this\", \"arguments\", \"super\",\n * or \"new.target\", ensure that these references reference the parent environment around this function.\n *\n * @returns `thisBinding`: the name of the injected reference to `this`; for example \"_this\"\n * @returns `fnPath`: the new path to the function node. This is different from the fnPath\n * parameter when the function node is wrapped in another node.\n */\nfunction hoistFunctionEnvironment(\n fnPath: NodePath<t.Function>,\n // TODO(Babel 8): Consider defaulting to `false` for spec compliance\n noNewArrows: boolean | void = true,\n allowInsertArrow: boolean | void = true,\n allowInsertArrowWithRest: boolean | void = true,\n): { thisBinding: string; fnPath: NodePath<t.Function> } {\n let arrowParent;\n let thisEnvFn: NodePath<t.Function> = fnPath.findParent(p => {\n if (p.isArrowFunctionExpression()) {\n arrowParent ??= p;\n return false;\n }\n return (\n p.isFunction() ||\n p.isProgram() ||\n p.isClassProperty({ static: false }) ||\n p.isClassPrivateProperty({ static: false })\n );\n }) as NodePath<t.Function>;\n const inConstructor = thisEnvFn.isClassMethod({ kind: \"constructor\" });\n\n if (thisEnvFn.isClassProperty() || thisEnvFn.isClassPrivateProperty()) {\n if (arrowParent) {\n thisEnvFn = arrowParent;\n } else if (allowInsertArrow) {\n // It's safe to wrap this function in another and not hoist to the\n // top level because the 'this' binding is constant in class\n // properties (since 'super()' has already been called), so we don't\n // need to capture/reassign it at the top level.\n fnPath.replaceWith(\n callExpression(\n arrowFunctionExpression([], toExpression(fnPath.node)),\n [],\n ),\n );\n thisEnvFn = fnPath.get(\"callee\") as NodePath<t.ArrowFunctionExpression>;\n fnPath = thisEnvFn.get(\"body\") as NodePath<t.FunctionExpression>;\n } else {\n throw fnPath.buildCodeFrameError(\n \"Unable to transform arrow inside class property\",\n );\n }\n }\n\n const { thisPaths, argumentsPaths, newTargetPaths, superProps, superCalls } =\n getScopeInformation(fnPath);\n\n // Convert all super() calls in the constructor, if super is used in an arrow.\n if (inConstructor && superCalls.length > 0) {\n if (!allowInsertArrow) {\n throw superCalls[0].buildCodeFrameError(\n \"When using '@babel/plugin-transform-arrow-functions', \" +\n \"it's not possible to compile `super()` in an arrow function without compiling classes.\\n\" +\n \"Please add '@babel/plugin-transform-classes' to your Babel configuration.\",\n );\n }\n if (!allowInsertArrowWithRest) {\n // preset-env with target `since 2017` enables `transform-parameters` without `transform-classes`.\n throw superCalls[0].buildCodeFrameError(\n \"When using '@babel/plugin-transform-parameters', \" +\n \"it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\\n\" +\n \"Please add '@babel/plugin-transform-classes' to your Babel configuration.\",\n );\n }\n const allSuperCalls: NodePath<t.CallExpression>[] = [];\n thisEnvFn.traverse(getSuperCallsVisitor, { allSuperCalls });\n const superBinding = getSuperBinding(thisEnvFn);\n allSuperCalls.forEach(superCall => {\n const callee = identifier(superBinding);\n callee.loc = superCall.node.callee.loc;\n\n superCall.get(\"callee\").replaceWith(callee);\n });\n }\n\n // Convert all \"arguments\" references in the arrow to point at the alias.\n if (argumentsPaths.length > 0) {\n const argumentsBinding = getBinding(thisEnvFn, \"arguments\", () => {\n const args = () => identifier(\"arguments\");\n if (thisEnvFn.scope.path.isProgram()) {\n return conditionalExpression(\n binaryExpression(\n \"===\",\n unaryExpression(\"typeof\", args()),\n stringLiteral(\"undefined\"),\n ),\n thisEnvFn.scope.buildUndefinedNode(),\n args(),\n );\n } else {\n return args();\n }\n });\n\n argumentsPaths.forEach(argumentsChild => {\n const argsRef = identifier(argumentsBinding);\n argsRef.loc = argumentsChild.node.loc;\n\n argumentsChild.replaceWith(argsRef);\n });\n }\n\n // Convert all \"new.target\" references in the arrow to point at the alias.\n if (newTargetPaths.length > 0) {\n const newTargetBinding = getBinding(thisEnvFn, \"newtarget\", () =>\n metaProperty(identifier(\"new\"), identifier(\"target\")),\n );\n\n newTargetPaths.forEach(targetChild => {\n const targetRef = identifier(newTargetBinding);\n targetRef.loc = targetChild.node.loc;\n\n targetChild.replaceWith(targetRef);\n });\n }\n\n // Convert all \"super.prop\" references to point at aliases.\n if (superProps.length > 0) {\n if (!allowInsertArrow) {\n throw superProps[0].buildCodeFrameError(\n \"When using '@babel/plugin-transform-arrow-functions', \" +\n \"it's not possible to compile `super.prop` in an arrow function without compiling classes.\\n\" +\n \"Please add '@babel/plugin-transform-classes' to your Babel configuration.\",\n );\n }\n\n const flatSuperProps = superProps.reduce(\n (acc, superProp) => acc.concat(standardizeSuperProperty(superProp)),\n [] as NodePath<t.MemberExpression>[],\n );\n\n flatSuperProps.forEach(superProp => {\n const key = superProp.node.computed\n ? \"\"\n : // @ts-expect-error super property must not contain private name\n superProp.get(\"property\").node.name;\n\n const superParentPath = superProp.parentPath;\n\n const isAssignment = superParentPath.isAssignmentExpression({\n left: superProp.node,\n });\n const isCall = superParentPath.isCallExpression({\n callee: superProp.node,\n });\n const isTaggedTemplate = superParentPath.isTaggedTemplateExpression({\n tag: superProp.node,\n });\n const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);\n\n const args: t.Expression[] = [];\n if (superProp.node.computed) {\n // SuperProperty must not be a private name\n args.push(superProp.get(\"property\").node as t.Expression);\n }\n\n if (isAssignment) {\n const value = superParentPath.node.right;\n args.push(value);\n }\n\n const call = callExpression(identifier(superBinding), args);\n\n if (isCall) {\n superParentPath.unshiftContainer(\"arguments\", thisExpression());\n superProp.replaceWith(memberExpression(call, identifier(\"call\")));\n\n thisPaths.push(\n superParentPath.get(\"arguments.0\") as NodePath<t.ThisExpression>,\n );\n } else if (isAssignment) {\n // Replace not only the super.prop, but the whole assignment\n superParentPath.replaceWith(call);\n } else if (isTaggedTemplate) {\n superProp.replaceWith(\n callExpression(memberExpression(call, identifier(\"bind\"), false), [\n thisExpression(),\n ]),\n );\n\n thisPaths.push(\n superProp.get(\"arguments.0\") as NodePath<t.ThisExpression>,\n );\n } else {\n superProp.replaceWith(call);\n }\n });\n }\n\n // Convert all \"this\" references in the arrow to point at the alias.\n let thisBinding: string | null;\n if (thisPaths.length > 0 || !noNewArrows) {\n thisBinding = getThisBinding(thisEnvFn, inConstructor);\n\n if (\n noNewArrows ||\n // In subclass constructors, still need to rewrite because \"this\" can't be bound in spec mode\n // because it might not have been initialized yet.\n (inConstructor && hasSuperClass(thisEnvFn))\n ) {\n thisPaths.forEach(thisChild => {\n const thisRef = thisChild.isJSX()\n ? jsxIdentifier(thisBinding!)\n : identifier(thisBinding!);\n\n thisRef.loc = thisChild.node.loc;\n thisChild.replaceWith(thisRef);\n });\n\n if (!noNewArrows) thisBinding = null;\n }\n }\n\n return { thisBinding: thisBinding!, fnPath };\n}\n\ntype LogicalOp = Parameters<typeof logicalExpression>[0];\ntype BinaryOp = Parameters<typeof binaryExpression>[0];\n\nfunction isLogicalOp(op: string): op is LogicalOp {\n return LOGICAL_OPERATORS.includes(op);\n}\n\nfunction standardizeSuperProperty(\n superProp: NodePath<t.MemberExpression>,\n):\n | [NodePath<t.MemberExpression>]\n | [NodePath<t.MemberExpression>, NodePath<t.MemberExpression>] {\n if (\n superProp.parentPath.isAssignmentExpression() &&\n superProp.parentPath.node.operator !== \"=\"\n ) {\n const assignmentPath = superProp.parentPath;\n\n const op = assignmentPath.node.operator.slice(0, -1) as\n | LogicalOp\n | BinaryOp;\n\n const value = assignmentPath.node.right;\n\n const isLogicalAssignment = isLogicalOp(op);\n\n if (superProp.node.computed) {\n // from: super[foo] **= 4;\n // to: super[tmp = foo] = super[tmp] ** 4;\n\n // from: super[foo] ??= 4;\n // to: super[tmp = foo] ?? super[tmp] = 4;\n\n const tmp = superProp.scope.generateDeclaredUidIdentifier(\"tmp\");\n\n const { object, property } = superProp.node;\n\n assignmentPath.get(\"left\").replaceWith(\n memberExpression(\n object,\n // @ts-ignore(Babel 7 vs Babel 8) Babel 8 has better type definitions\n assignmentExpression(\"=\", tmp, property),\n true /* computed */,\n ),\n );\n\n assignmentPath\n .get(\"right\")\n .replaceWith(\n rightExpression(\n isLogicalAssignment ? \"=\" : op,\n memberExpression(object, identifier(tmp.name), true /* computed */),\n value,\n ),\n );\n } else {\n // from: super.foo **= 4;\n // to: super.foo = super.foo ** 4;\n\n // from: super.foo ??= 4;\n // to: super.foo ?? super.foo = 4;\n\n const object = superProp.node.object;\n const property = superProp.node.property as t.Identifier;\n\n assignmentPath\n .get(\"left\")\n .replaceWith(memberExpression(object, property));\n\n assignmentPath\n .get(\"right\")\n .replaceWith(\n rightExpression(\n isLogicalAssignment ? \"=\" : op,\n memberExpression(object, identifier(property.name)),\n value,\n ),\n );\n }\n\n if (isLogicalAssignment) {\n assignmentPath.replaceWith(\n logicalExpression(\n op,\n assignmentPath.node.left as t.MemberExpression,\n assignmentPath.node.right,\n ),\n );\n } else {\n assignmentPath.node.operator = \"=\";\n }\n\n return [\n assignmentPath.get(\"left\") as NodePath<t.MemberExpression>,\n assignmentPath.get(\"right\").get(\"left\") as NodePath<t.MemberExpression>,\n ];\n } else if (superProp.parentPath.isUpdateExpression()) {\n const updateExpr = superProp.parentPath;\n\n const tmp = superProp.scope.generateDeclaredUidIdentifier(\"tmp\");\n const computedKey = superProp.node.computed\n ? superProp.scope.generateDeclaredUidIdentifier(\"prop\")\n : null;\n\n const parts: t.Expression[] = [\n assignmentExpression(\n \"=\",\n tmp,\n memberExpression(\n superProp.node.object,\n computedKey\n ? assignmentExpression(\n \"=\",\n computedKey,\n superProp.node.property as t.Expression,\n )\n : superProp.node.property,\n superProp.node.computed,\n ),\n ),\n assignmentExpression(\n \"=\",\n memberExpression(\n superProp.node.object,\n computedKey ? identifier(computedKey.name) : superProp.node.property,\n superProp.node.computed,\n ),\n binaryExpression(\n // map `++` to `+`, and `--` to `-`\n superProp.parentPath.node.operator[0] as \"+\" | \"-\",\n identifier(tmp.name),\n numericLiteral(1),\n ),\n ),\n ];\n\n if (!superProp.parentPath.node.prefix) {\n parts.push(identifier(tmp.name));\n }\n\n updateExpr.replaceWith(sequenceExpression(parts));\n\n const left = updateExpr.get(\n \"expressions.0.right\",\n ) as NodePath<t.MemberExpression>;\n const right = updateExpr.get(\n \"expressions.1.left\",\n ) as NodePath<t.MemberExpression>;\n return [left, right];\n }\n\n return [superProp];\n\n function rightExpression(\n op: BinaryOp | \"=\",\n left: t.MemberExpression,\n right: t.Expression,\n ) {\n if (op === \"=\") {\n return assignmentExpression(\"=\", left, right);\n } else {\n return binaryExpression(op, left, right);\n }\n }\n}\n\nfunction hasSuperClass(thisEnvFn: NodePath<t.Function>) {\n return (\n thisEnvFn.isClassMethod() &&\n !!(thisEnvFn.parentPath.parentPath.node as t.Class).superClass\n );\n}\n\nconst assignSuperThisVisitor = environmentVisitor<{\n supers: WeakSet<t.CallExpression>;\n thisBinding: string;\n}>({\n CallExpression(child, { supers, thisBinding }) {\n if (!child.get(\"callee\").isSuper()) return;\n if (supers.has(child.node)) return;\n supers.add(child.node);\n\n child.replaceWithMultiple([\n child.node,\n assignmentExpression(\"=\", identifier(thisBinding), identifier(\"this\")),\n ]);\n },\n});\n\n// Create a binding that evaluates to the \"this\" of the given function.\nfunction getThisBinding(\n thisEnvFn: NodePath<t.Function>,\n inConstructor: boolean,\n) {\n return getBinding(thisEnvFn, \"this\", thisBinding => {\n if (!inConstructor || !hasSuperClass(thisEnvFn)) return thisExpression();\n\n thisEnvFn.traverse(assignSuperThisVisitor, {\n supers: new WeakSet(),\n thisBinding,\n });\n });\n}\n\n// Create a binding for a function that will call \"super()\" with arguments passed through.\nfunction getSuperBinding(thisEnvFn: NodePath<t.Function>) {\n return getBinding(thisEnvFn, \"supercall\", () => {\n const argsBinding = thisEnvFn.scope.generateUidIdentifier(\"args\");\n return arrowFunctionExpression(\n [restElement(argsBinding)],\n callExpression(_super(), [spreadElement(identifier(argsBinding.name))]),\n );\n });\n}\n\n// Create a binding for a function that will call \"super.foo\" or \"super[foo]\".\nfunction getSuperPropBinding(\n thisEnvFn: NodePath<t.Function>,\n isAssignment: boolean,\n propName: string,\n) {\n const op = isAssignment ? \"set\" : \"get\";\n\n return getBinding(thisEnvFn, `superprop_${op}:${propName || \"\"}`, () => {\n const argsList = [];\n\n let fnBody;\n if (propName) {\n // () => super.foo\n fnBody = memberExpression(_super(), identifier(propName));\n } else {\n const method = thisEnvFn.scope.generateUidIdentifier(\"prop\");\n // (method) => super[method]\n argsList.unshift(method);\n fnBody = memberExpression(\n _super(),\n identifier(method.name),\n true /* computed */,\n );\n }\n\n if (isAssignment) {\n const valueIdent = thisEnvFn.scope.generateUidIdentifier(\"value\");\n argsList.push(valueIdent);\n\n fnBody = assignmentExpression(\"=\", fnBody, identifier(valueIdent.name));\n }\n\n return arrowFunctionExpression(argsList, fnBody);\n });\n}\n\nfunction getBinding(\n thisEnvFn: NodePath,\n key: string,\n init: (name: string) => t.Expression | undefined,\n) {\n const cacheKey = \"binding:\" + key;\n let data: string | undefined = thisEnvFn.getData(cacheKey);\n if (!data) {\n const id = thisEnvFn.scope.generateUidIdentifier(key);\n data = id.name;\n thisEnvFn.setData(cacheKey, data);\n\n thisEnvFn.scope.push({\n id: id,\n init: init(data),\n });\n }\n\n return data;\n}\n\ntype ScopeInfo = {\n thisPaths: NodePath<t.ThisExpression | t.JSXIdentifier>[];\n superCalls: NodePath<t.CallExpression>[];\n superProps: NodePath<t.MemberExpression>[];\n argumentsPaths: NodePath<t.Identifier | t.JSXIdentifier>[];\n newTargetPaths: NodePath<t.MetaProperty>[];\n};\n\nconst getScopeInformationVisitor = environmentVisitor<ScopeInfo>({\n ThisExpression(child, { thisPaths }) {\n thisPaths.push(child);\n },\n JSXIdentifier(child, { thisPaths }) {\n if (child.node.name !== \"this\") return;\n if (\n !child.parentPath.isJSXMemberExpression({ object: child.node }) &&\n !child.parentPath.isJSXOpeningElement({ name: child.node })\n ) {\n return;\n }\n\n thisPaths.push(child);\n },\n CallExpression(child, { superCalls }) {\n if (child.get(\"callee\").isSuper()) superCalls.push(child);\n },\n MemberExpression(child, { superProps }) {\n if (child.get(\"object\").isSuper()) superProps.push(child);\n },\n Identifier(child, { argumentsPaths }) {\n if (!child.isReferencedIdentifier({ name: \"arguments\" })) return;\n\n let curr: Scope | undefined = child.scope;\n do {\n if (curr.hasOwnBinding(\"arguments\")) {\n curr.rename(\"arguments\");\n return;\n }\n if (curr.path.isFunction() && !curr.path.isArrowFunctionExpression()) {\n break;\n }\n } while ((curr = curr.parent));\n\n argumentsPaths.push(child);\n },\n MetaProperty(child, { newTargetPaths }) {\n if (!child.get(\"meta\").isIdentifier({ name: \"new\" })) return;\n if (!child.get(\"property\").isIdentifier({ name: \"target\" })) return;\n\n newTargetPaths.push(child);\n },\n});\n\nfunction getScopeInformation(fnPath: NodePath) {\n const thisPaths: ScopeInfo[\"thisPaths\"] = [];\n const argumentsPaths: ScopeInfo[\"argumentsPaths\"] = [];\n const newTargetPaths: ScopeInfo[\"newTargetPaths\"] = [];\n const superProps: ScopeInfo[\"superProps\"] = [];\n const superCalls: ScopeInfo[\"superCalls\"] = [];\n\n fnPath.traverse(getScopeInformationVisitor, {\n thisPaths,\n argumentsPaths,\n newTargetPaths,\n superProps,\n superCalls,\n });\n\n return {\n thisPaths,\n argumentsPaths,\n newTargetPaths,\n superProps,\n superCalls,\n };\n}\n\nexport function splitExportDeclaration(\n this: NodePath<t.ExportDefaultDeclaration | t.ExportNamedDeclaration>,\n): NodePath<t.Declaration> {\n if (!this.isExportDeclaration() || this.isExportAllDeclaration()) {\n throw new Error(\"Only default and named export declarations can be split.\");\n }\n if (this.isExportNamedDeclaration() && this.get(\"specifiers\").length > 0) {\n throw new Error(\"It doesn't make sense to split exported specifiers.\");\n }\n\n const declaration = this.get(\"declaration\");\n\n if (this.isExportDefaultDeclaration()) {\n const standaloneDeclaration =\n declaration.isFunctionDeclaration() || declaration.isClassDeclaration();\n const exportExpr =\n declaration.isFunctionExpression() || declaration.isClassExpression();\n\n const scope = declaration.isScope()\n ? declaration.scope.parent!\n : declaration.scope;\n\n // @ts-expect-error id is not defined in expressions other than function/class\n let id = declaration.node.id;\n let needBindingRegistration = false;\n\n if (!id) {\n needBindingRegistration = true;\n\n id = scope.generateUidIdentifier(\"default\");\n\n if (standaloneDeclaration || exportExpr) {\n declaration.node.id = cloneNode(id);\n }\n } else if (exportExpr && scope.hasBinding(id.name)) {\n needBindingRegistration = true;\n\n id = scope.generateUidIdentifier(id.name);\n }\n\n const updatedDeclaration = standaloneDeclaration\n ? declaration.node\n : variableDeclaration(\"var\", [\n variableDeclarator(\n cloneNode(id),\n // @ts-expect-error When `standaloneDeclaration` is false, declaration must not be a Function/ClassDeclaration\n declaration.node,\n ),\n ]);\n\n const updatedExportDeclaration = exportNamedDeclaration(null, [\n exportSpecifier(cloneNode(id), identifier(\"default\")),\n ]);\n\n this.insertAfter(updatedExportDeclaration);\n this.replaceWith(updatedDeclaration);\n\n if (needBindingRegistration) {\n scope.registerDeclaration(this);\n }\n\n return this;\n } else if (this.get(\"specifiers\").length > 0) {\n throw new Error(\"It doesn't make sense to split exported specifiers.\");\n }\n\n const bindingIdentifiers = declaration.getOuterBindingIdentifiers();\n\n const specifiers = Object.keys(bindingIdentifiers).map(name => {\n return exportSpecifier(identifier(name), identifier(name));\n });\n\n const aliasDeclar = exportNamedDeclaration(null, specifiers);\n\n this.insertAfter(aliasDeclar);\n this.replaceWith(declaration.node!);\n return this;\n}\n\nconst refersOuterBindingVisitor: Visitor<{\n needsRename: boolean;\n name: string;\n}> = {\n \"ReferencedIdentifier|BindingIdentifier\"(\n path: NodePath<t.Identifier>,\n state,\n ) {\n // check if this node matches our function id\n if (path.node.name !== state.name) return;\n state.needsRename = true;\n path.stop();\n },\n Scope(path, state) {\n if (path.scope.hasOwnBinding(state.name)) {\n path.skip();\n }\n },\n};\n\nexport function ensureFunctionName<\n N extends t.FunctionExpression | t.ClassExpression,\n>(this: NodePath<N>, supportUnicodeId: boolean): null | NodePath<N> {\n if (this.node.id) return this;\n\n const res = getFunctionName(this.node, this.parent);\n if (res == null) return this;\n let { name } = res;\n\n if (!supportUnicodeId && /[\\uD800-\\uDFFF]/.test(name)) {\n return null;\n }\n\n if (name.startsWith(\"get \") || name.startsWith(\"set \")) {\n // TODO: Remove this to support naming getters and setters\n return null;\n }\n\n name = toBindingIdentifierName(name.replace(/[/ ]/g, \"_\"));\n const id = identifier(name);\n inherits(id, res.originalNode);\n\n const state = { needsRename: false, name };\n\n // check to see if we have a local binding of the id we're setting inside of\n // the function, this is important as there are caveats associated\n\n const { scope } = this;\n const binding = scope.getOwnBinding(name);\n if (binding) {\n if (binding.kind === \"param\") {\n // safari will blow up in strict mode with code like:\n //\n // let t = function t(t) {};\n //\n // with the error:\n //\n // Cannot declare a parameter named 't' as it shadows the name of a\n // strict mode function.\n //\n // this isn't to the spec and they've invented this behaviour which is\n // **extremely** annoying so we avoid setting the name if it has a param\n // with the same id\n state.needsRename = true;\n } else {\n // otherwise it's defined somewhere in scope like:\n //\n // let t = function () {\n // let t = 2;\n // };\n //\n // so we can safely just set the id and move along as it shadows the\n // bound function id\n }\n } else if (scope.parent!.hasBinding(name) || scope.hasGlobal(name)) {\n this.traverse(refersOuterBindingVisitor, state);\n }\n\n if (!state.needsRename) {\n this.node.id = id;\n if (process.env.BABEL_8_BREAKING) {\n scope.getProgramParent().referencesSet.add(id.name);\n } else {\n // @ts-expect-error Babel 7\n scope.getProgramParent().references[id.name] = true;\n }\n return this;\n }\n\n if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) {\n // we can just munge the local binding\n scope.rename(id.name);\n this.node.id = id;\n if (process.env.BABEL_8_BREAKING) {\n scope.getProgramParent().referencesSet.add(id.name);\n } else {\n // @ts-expect-error Babel 7\n scope.getProgramParent().references[id.name] = true;\n }\n return this;\n }\n\n // TODO: we don't currently support wrapping class expressions\n if (!isFunction(this.node)) return null;\n\n // need to add a wrapper since we can't change the references\n\n const key = scope.generateUidIdentifier(id.name);\n // shim in dummy params to retain function arity, if you try to read the\n // source then you'll get the original since it's proxied so it's all good\n const params = [];\n for (let i = 0, len = getFunctionArity(this.node); i < len; i++) {\n params.push(scope.generateUidIdentifier(\"x\"));\n }\n const call = template.expression.ast`\n (function (${key}) {\n function ${id}(${params}) {\n return ${cloneNode(key)}.apply(this, arguments);\n }\n\n ${cloneNode(id)}.toString = function () {\n return ${cloneNode(key)}.toString();\n }\n\n return ${cloneNode(id)};\n })(${toExpression(this.node)})\n ` as t.CallExpression;\n\n return this.replaceWith(call)[0].get(\"arguments.0\") as NodePath<N>;\n}\n\nfunction getFunctionArity(node: t.Function): number {\n const count = node.params.findIndex(\n param => isAssignmentPattern(param) || isRestElement(param),\n );\n return count === -1 ? node.params.length : count;\n}\n"],"mappings":";;;;;;;;;;;AAEA,IAAAA,EAAA,GAAAC,OAAA;AAuCA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,QAAA,GAAAH,OAAA;AAAqC;EA1CnCI,uBAAuB;EACvBC,oBAAoB;EACpBC,gBAAgB;EAChBC,cAAc;EACdC,cAAc;EACdC,qBAAqB;EACrBC,mBAAmB;EACnBC,UAAU;EACVC,YAAY;EACZC,aAAa;EACbC,iBAAiB;EACjBC,iBAAiB;EACjBC,gBAAgB;EAChBC,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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.evaluate = evaluate;
|
| 7 |
+
exports.evaluateTruthy = evaluateTruthy;
|
| 8 |
+
const VALID_OBJECT_CALLEES = ["Number", "String", "Math"];
|
| 9 |
+
const VALID_IDENTIFIER_CALLEES = ["isFinite", "isNaN", "parseFloat", "parseInt", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", null, null];
|
| 10 |
+
const INVALID_METHODS = ["random"];
|
| 11 |
+
function isValidObjectCallee(val) {
|
| 12 |
+
return VALID_OBJECT_CALLEES.includes(val);
|
| 13 |
+
}
|
| 14 |
+
function isValidIdentifierCallee(val) {
|
| 15 |
+
return VALID_IDENTIFIER_CALLEES.includes(val);
|
| 16 |
+
}
|
| 17 |
+
function isInvalidMethod(val) {
|
| 18 |
+
return INVALID_METHODS.includes(val);
|
| 19 |
+
}
|
| 20 |
+
function evaluateTruthy() {
|
| 21 |
+
const res = this.evaluate();
|
| 22 |
+
if (res.confident) return !!res.value;
|
| 23 |
+
}
|
| 24 |
+
function deopt(path, state) {
|
| 25 |
+
if (!state.confident) return;
|
| 26 |
+
state.deoptPath = path;
|
| 27 |
+
state.confident = false;
|
| 28 |
+
}
|
| 29 |
+
const Globals = new Map([["undefined", undefined], ["Infinity", Infinity], ["NaN", NaN]]);
|
| 30 |
+
function evaluateCached(path, state) {
|
| 31 |
+
const {
|
| 32 |
+
node
|
| 33 |
+
} = path;
|
| 34 |
+
const {
|
| 35 |
+
seen
|
| 36 |
+
} = state;
|
| 37 |
+
if (seen.has(node)) {
|
| 38 |
+
const existing = seen.get(node);
|
| 39 |
+
if (existing.resolved) {
|
| 40 |
+
return existing.value;
|
| 41 |
+
} else {
|
| 42 |
+
deopt(path, state);
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
+
} else {
|
| 46 |
+
const item = {
|
| 47 |
+
resolved: false
|
| 48 |
+
};
|
| 49 |
+
seen.set(node, item);
|
| 50 |
+
const val = _evaluate(path, state);
|
| 51 |
+
if (state.confident) {
|
| 52 |
+
item.resolved = true;
|
| 53 |
+
item.value = val;
|
| 54 |
+
}
|
| 55 |
+
return val;
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
function _evaluate(path, state) {
|
| 59 |
+
if (!state.confident) return;
|
| 60 |
+
if (path.isSequenceExpression()) {
|
| 61 |
+
const exprs = path.get("expressions");
|
| 62 |
+
return evaluateCached(exprs[exprs.length - 1], state);
|
| 63 |
+
}
|
| 64 |
+
if (path.isStringLiteral() || path.isNumericLiteral() || path.isBooleanLiteral()) {
|
| 65 |
+
return path.node.value;
|
| 66 |
+
}
|
| 67 |
+
if (path.isNullLiteral()) {
|
| 68 |
+
return null;
|
| 69 |
+
}
|
| 70 |
+
if (path.isTemplateLiteral()) {
|
| 71 |
+
return evaluateQuasis(path, path.node.quasis, state);
|
| 72 |
+
}
|
| 73 |
+
if (path.isTaggedTemplateExpression() && path.get("tag").isMemberExpression()) {
|
| 74 |
+
const object = path.get("tag.object");
|
| 75 |
+
const {
|
| 76 |
+
node: {
|
| 77 |
+
name
|
| 78 |
+
}
|
| 79 |
+
} = object;
|
| 80 |
+
const property = path.get("tag.property");
|
| 81 |
+
if (object.isIdentifier() && name === "String" && !path.scope.getBinding(name) && property.isIdentifier() && property.node.name === "raw") {
|
| 82 |
+
return evaluateQuasis(path, path.node.quasi.quasis, state, true);
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
if (path.isConditionalExpression()) {
|
| 86 |
+
const testResult = evaluateCached(path.get("test"), state);
|
| 87 |
+
if (!state.confident) return;
|
| 88 |
+
if (testResult) {
|
| 89 |
+
return evaluateCached(path.get("consequent"), state);
|
| 90 |
+
} else {
|
| 91 |
+
return evaluateCached(path.get("alternate"), state);
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
if (path.isExpressionWrapper()) {
|
| 95 |
+
return evaluateCached(path.get("expression"), state);
|
| 96 |
+
}
|
| 97 |
+
if (path.isMemberExpression() && !path.parentPath.isCallExpression({
|
| 98 |
+
callee: path.node
|
| 99 |
+
})) {
|
| 100 |
+
const property = path.get("property");
|
| 101 |
+
const object = path.get("object");
|
| 102 |
+
if (object.isLiteral()) {
|
| 103 |
+
const value = object.node.value;
|
| 104 |
+
const type = typeof value;
|
| 105 |
+
let key = null;
|
| 106 |
+
if (path.node.computed) {
|
| 107 |
+
key = evaluateCached(property, state);
|
| 108 |
+
if (!state.confident) return;
|
| 109 |
+
} else if (property.isIdentifier()) {
|
| 110 |
+
key = property.node.name;
|
| 111 |
+
}
|
| 112 |
+
if ((type === "number" || type === "string") && key != null && (typeof key === "number" || typeof key === "string")) {
|
| 113 |
+
return value[key];
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
if (path.isReferencedIdentifier()) {
|
| 118 |
+
const binding = path.scope.getBinding(path.node.name);
|
| 119 |
+
if (binding) {
|
| 120 |
+
if (binding.constantViolations.length > 0 || path.node.start < binding.path.node.end) {
|
| 121 |
+
deopt(binding.path, state);
|
| 122 |
+
return;
|
| 123 |
+
}
|
| 124 |
+
const bindingPathScope = binding.path.scope;
|
| 125 |
+
if (binding.kind === "var" && bindingPathScope !== binding.scope) {
|
| 126 |
+
let hasUnsafeBlock = !bindingPathScope.path.parentPath.isBlockStatement();
|
| 127 |
+
for (let scope = bindingPathScope.parent; scope; scope = scope.parent) {
|
| 128 |
+
var _scope$path$parentPat;
|
| 129 |
+
if (scope === path.scope) {
|
| 130 |
+
if (hasUnsafeBlock) {
|
| 131 |
+
deopt(binding.path, state);
|
| 132 |
+
return;
|
| 133 |
+
}
|
| 134 |
+
break;
|
| 135 |
+
}
|
| 136 |
+
if ((_scope$path$parentPat = scope.path.parentPath) != null && _scope$path$parentPat.isBlockStatement()) {
|
| 137 |
+
hasUnsafeBlock = true;
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
if (binding.hasValue) {
|
| 142 |
+
return binding.value;
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
const name = path.node.name;
|
| 146 |
+
if (Globals.has(name)) {
|
| 147 |
+
if (!binding) {
|
| 148 |
+
return Globals.get(name);
|
| 149 |
+
}
|
| 150 |
+
deopt(binding.path, state);
|
| 151 |
+
return;
|
| 152 |
+
}
|
| 153 |
+
if (!binding) {
|
| 154 |
+
deopt(path, state);
|
| 155 |
+
return;
|
| 156 |
+
}
|
| 157 |
+
const bindingPath = binding.path;
|
| 158 |
+
if (!bindingPath.isVariableDeclarator()) {
|
| 159 |
+
deopt(bindingPath, state);
|
| 160 |
+
return;
|
| 161 |
+
}
|
| 162 |
+
const initPath = bindingPath.get("init");
|
| 163 |
+
const value = evaluateCached(initPath, state);
|
| 164 |
+
if (typeof value === "object" && value !== null && binding.references > 1) {
|
| 165 |
+
deopt(initPath, state);
|
| 166 |
+
return;
|
| 167 |
+
}
|
| 168 |
+
return value;
|
| 169 |
+
}
|
| 170 |
+
if (path.isUnaryExpression({
|
| 171 |
+
prefix: true
|
| 172 |
+
})) {
|
| 173 |
+
if (path.node.operator === "void") {
|
| 174 |
+
return undefined;
|
| 175 |
+
}
|
| 176 |
+
const argument = path.get("argument");
|
| 177 |
+
if (path.node.operator === "typeof" && (argument.isFunction() || argument.isClass())) {
|
| 178 |
+
return "function";
|
| 179 |
+
}
|
| 180 |
+
const arg = evaluateCached(argument, state);
|
| 181 |
+
if (!state.confident) return;
|
| 182 |
+
switch (path.node.operator) {
|
| 183 |
+
case "!":
|
| 184 |
+
return !arg;
|
| 185 |
+
case "+":
|
| 186 |
+
return +arg;
|
| 187 |
+
case "-":
|
| 188 |
+
return -arg;
|
| 189 |
+
case "~":
|
| 190 |
+
return ~arg;
|
| 191 |
+
case "typeof":
|
| 192 |
+
return typeof arg;
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
if (path.isArrayExpression()) {
|
| 196 |
+
const arr = [];
|
| 197 |
+
const elems = path.get("elements");
|
| 198 |
+
for (const elem of elems) {
|
| 199 |
+
const elemValue = elem.evaluate();
|
| 200 |
+
if (elemValue.confident) {
|
| 201 |
+
arr.push(elemValue.value);
|
| 202 |
+
} else {
|
| 203 |
+
deopt(elemValue.deopt, state);
|
| 204 |
+
return;
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
return arr;
|
| 208 |
+
}
|
| 209 |
+
if (path.isObjectExpression()) {
|
| 210 |
+
const obj = {};
|
| 211 |
+
const props = path.get("properties");
|
| 212 |
+
for (const prop of props) {
|
| 213 |
+
if (prop.isObjectMethod() || prop.isSpreadElement()) {
|
| 214 |
+
deopt(prop, state);
|
| 215 |
+
return;
|
| 216 |
+
}
|
| 217 |
+
const keyPath = prop.get("key");
|
| 218 |
+
let key;
|
| 219 |
+
if (prop.node.computed) {
|
| 220 |
+
key = keyPath.evaluate();
|
| 221 |
+
if (!key.confident) {
|
| 222 |
+
deopt(key.deopt, state);
|
| 223 |
+
return;
|
| 224 |
+
}
|
| 225 |
+
key = key.value;
|
| 226 |
+
} else if (keyPath.isIdentifier()) {
|
| 227 |
+
key = keyPath.node.name;
|
| 228 |
+
} else {
|
| 229 |
+
key = keyPath.node.value;
|
| 230 |
+
}
|
| 231 |
+
const valuePath = prop.get("value");
|
| 232 |
+
let value = valuePath.evaluate();
|
| 233 |
+
if (!value.confident) {
|
| 234 |
+
deopt(value.deopt, state);
|
| 235 |
+
return;
|
| 236 |
+
}
|
| 237 |
+
value = value.value;
|
| 238 |
+
obj[key] = value;
|
| 239 |
+
}
|
| 240 |
+
return obj;
|
| 241 |
+
}
|
| 242 |
+
if (path.isLogicalExpression()) {
|
| 243 |
+
const wasConfident = state.confident;
|
| 244 |
+
const left = evaluateCached(path.get("left"), state);
|
| 245 |
+
const leftConfident = state.confident;
|
| 246 |
+
state.confident = wasConfident;
|
| 247 |
+
const right = evaluateCached(path.get("right"), state);
|
| 248 |
+
const rightConfident = state.confident;
|
| 249 |
+
switch (path.node.operator) {
|
| 250 |
+
case "||":
|
| 251 |
+
state.confident = leftConfident && (!!left || rightConfident);
|
| 252 |
+
if (!state.confident) return;
|
| 253 |
+
return left || right;
|
| 254 |
+
case "&&":
|
| 255 |
+
state.confident = leftConfident && (!left || rightConfident);
|
| 256 |
+
if (!state.confident) return;
|
| 257 |
+
return left && right;
|
| 258 |
+
case "??":
|
| 259 |
+
state.confident = leftConfident && (left != null || rightConfident);
|
| 260 |
+
if (!state.confident) return;
|
| 261 |
+
return left != null ? left : right;
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
if (path.isBinaryExpression()) {
|
| 265 |
+
const left = evaluateCached(path.get("left"), state);
|
| 266 |
+
if (!state.confident) return;
|
| 267 |
+
const right = evaluateCached(path.get("right"), state);
|
| 268 |
+
if (!state.confident) return;
|
| 269 |
+
switch (path.node.operator) {
|
| 270 |
+
case "-":
|
| 271 |
+
return left - right;
|
| 272 |
+
case "+":
|
| 273 |
+
return left + right;
|
| 274 |
+
case "/":
|
| 275 |
+
return left / right;
|
| 276 |
+
case "*":
|
| 277 |
+
return left * right;
|
| 278 |
+
case "%":
|
| 279 |
+
return left % right;
|
| 280 |
+
case "**":
|
| 281 |
+
return Math.pow(left, right);
|
| 282 |
+
case "<":
|
| 283 |
+
return left < right;
|
| 284 |
+
case ">":
|
| 285 |
+
return left > right;
|
| 286 |
+
case "<=":
|
| 287 |
+
return left <= right;
|
| 288 |
+
case ">=":
|
| 289 |
+
return left >= right;
|
| 290 |
+
case "==":
|
| 291 |
+
return left == right;
|
| 292 |
+
case "!=":
|
| 293 |
+
return left != right;
|
| 294 |
+
case "===":
|
| 295 |
+
return left === right;
|
| 296 |
+
case "!==":
|
| 297 |
+
return left !== right;
|
| 298 |
+
case "|":
|
| 299 |
+
return left | right;
|
| 300 |
+
case "&":
|
| 301 |
+
return left & right;
|
| 302 |
+
case "^":
|
| 303 |
+
return left ^ right;
|
| 304 |
+
case "<<":
|
| 305 |
+
return left << right;
|
| 306 |
+
case ">>":
|
| 307 |
+
return left >> right;
|
| 308 |
+
case ">>>":
|
| 309 |
+
return left >>> right;
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
if (path.isCallExpression()) {
|
| 313 |
+
const callee = path.get("callee");
|
| 314 |
+
let context;
|
| 315 |
+
let func;
|
| 316 |
+
if (callee.isIdentifier() && !path.scope.getBinding(callee.node.name) && (isValidObjectCallee(callee.node.name) || isValidIdentifierCallee(callee.node.name))) {
|
| 317 |
+
func = global[callee.node.name];
|
| 318 |
+
}
|
| 319 |
+
if (callee.isMemberExpression()) {
|
| 320 |
+
const object = callee.get("object");
|
| 321 |
+
const property = callee.get("property");
|
| 322 |
+
if (object.isIdentifier() && property.isIdentifier() && isValidObjectCallee(object.node.name) && !isInvalidMethod(property.node.name)) {
|
| 323 |
+
context = global[object.node.name];
|
| 324 |
+
const key = property.node.name;
|
| 325 |
+
if (hasOwnProperty.call(context, key)) {
|
| 326 |
+
func = context[key];
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
if (object.isLiteral() && property.isIdentifier()) {
|
| 330 |
+
const type = typeof object.node.value;
|
| 331 |
+
if (type === "string" || type === "number") {
|
| 332 |
+
context = object.node.value;
|
| 333 |
+
func = context[property.node.name];
|
| 334 |
+
}
|
| 335 |
+
}
|
| 336 |
+
}
|
| 337 |
+
if (func) {
|
| 338 |
+
const args = path.get("arguments").map(arg => evaluateCached(arg, state));
|
| 339 |
+
if (!state.confident) return;
|
| 340 |
+
return func.apply(context, args);
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
deopt(path, state);
|
| 344 |
+
}
|
| 345 |
+
function evaluateQuasis(path, quasis, state, raw = false) {
|
| 346 |
+
let str = "";
|
| 347 |
+
let i = 0;
|
| 348 |
+
const exprs = path.isTemplateLiteral() ? path.get("expressions") : path.get("quasi.expressions");
|
| 349 |
+
for (const elem of quasis) {
|
| 350 |
+
if (!state.confident) break;
|
| 351 |
+
str += raw ? elem.value.raw : elem.value.cooked;
|
| 352 |
+
const expr = exprs[i++];
|
| 353 |
+
if (expr) str += String(evaluateCached(expr, state));
|
| 354 |
+
}
|
| 355 |
+
if (!state.confident) return;
|
| 356 |
+
return str;
|
| 357 |
+
}
|
| 358 |
+
function evaluate() {
|
| 359 |
+
const state = {
|
| 360 |
+
confident: true,
|
| 361 |
+
deoptPath: null,
|
| 362 |
+
seen: new Map()
|
| 363 |
+
};
|
| 364 |
+
let value = evaluateCached(this, state);
|
| 365 |
+
if (!state.confident) value = undefined;
|
| 366 |
+
return {
|
| 367 |
+
confident: state.confident,
|
| 368 |
+
deopt: state.deoptPath,
|
| 369 |
+
value: value
|
| 370 |
+
};
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
//# sourceMappingURL=evaluation.js.map
|
node_modules/@babel/traverse/lib/path/evaluation.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["VALID_OBJECT_CALLEES","VALID_IDENTIFIER_CALLEES","INVALID_METHODS","isValidObjectCallee","val","includes","isValidIdentifierCallee","isInvalidMethod","evaluateTruthy","res","evaluate","confident","value","deopt","path","state","deoptPath","Globals","Map","undefined","Infinity","NaN","evaluateCached","node","seen","has","existing","get","resolved","item","set","_evaluate","isSequenceExpression","exprs","length","isStringLiteral","isNumericLiteral","isBooleanLiteral","isNullLiteral","isTemplateLiteral","evaluateQuasis","quasis","isTaggedTemplateExpression","isMemberExpression","object","name","property","isIdentifier","scope","getBinding","quasi","isConditionalExpression","testResult","isExpressionWrapper","parentPath","isCallExpression","callee","isLiteral","type","key","computed","isReferencedIdentifier","binding","constantViolations","start","end","bindingPathScope","kind","hasUnsafeBlock","isBlockStatement","parent","_scope$path$parentPat","hasValue","bindingPath","isVariableDeclarator","initPath","references","isUnaryExpression","prefix","operator","argument","isFunction","isClass","arg","isArrayExpression","arr","elems","elem","elemValue","push","isObjectExpression","obj","props","prop","isObjectMethod","isSpreadElement","keyPath","valuePath","isLogicalExpression","wasConfident","left","leftConfident","right","rightConfident","isBinaryExpression","Math","pow","context","func","global","hasOwnProperty","call","args","map","apply","raw","str","i","cooked","expr","String"],"sources":["../../src/path/evaluation.ts"],"sourcesContent":["import type NodePath from \"./index.ts\";\nimport type * as t from \"@babel/types\";\n\n// This file contains Babels metainterpreter that can evaluate static code.\n\nconst VALID_OBJECT_CALLEES = [\"Number\", \"String\", \"Math\"] as const;\nconst VALID_IDENTIFIER_CALLEES = [\n \"isFinite\",\n \"isNaN\",\n \"parseFloat\",\n \"parseInt\",\n \"decodeURI\",\n \"decodeURIComponent\",\n \"encodeURI\",\n \"encodeURIComponent\",\n process.env.BABEL_8_BREAKING ? \"btoa\" : null,\n process.env.BABEL_8_BREAKING ? \"atob\" : null,\n] as const;\n\nconst INVALID_METHODS = [\"random\"] as const;\n\nfunction isValidObjectCallee(\n val: string,\n): val is (typeof VALID_OBJECT_CALLEES)[number] {\n return VALID_OBJECT_CALLEES.includes(\n // @ts-expect-error val is a string\n val,\n );\n}\n\nfunction isValidIdentifierCallee(\n val: string,\n): val is NonNullable<(typeof VALID_IDENTIFIER_CALLEES)[number]> {\n return VALID_IDENTIFIER_CALLEES.includes(\n // @ts-expect-error val is a string\n val,\n );\n}\n\nfunction isInvalidMethod(val: string): val is (typeof INVALID_METHODS)[number] {\n return INVALID_METHODS.includes(\n // @ts-expect-error val is a string\n val,\n );\n}\n\n/**\n * Walk the input `node` and statically evaluate if it's truthy.\n *\n * Returning `true` when we're sure that the expression will evaluate to a\n * truthy value, `false` if we're sure that it will evaluate to a falsy\n * value and `undefined` if we aren't sure. Because of this please do not\n * rely on coercion when using this method and check with === if it's false.\n *\n * For example do:\n *\n * if (t.evaluateTruthy(node) === false) falsyLogic();\n *\n * **AND NOT**\n *\n * if (!t.evaluateTruthy(node)) falsyLogic();\n *\n */\n\nexport function evaluateTruthy(this: NodePath): boolean | undefined {\n const res = this.evaluate();\n if (res.confident) return !!res.value;\n}\n\ntype State = {\n confident: boolean;\n deoptPath: NodePath | null;\n seen: Map<t.Node, Result>;\n};\n\ntype Result = {\n resolved: boolean;\n value?: any;\n};\n/**\n * Deopts the evaluation\n */\nfunction deopt(path: NodePath | null, state: State) {\n if (!state.confident) return;\n state.deoptPath = path;\n state.confident = false;\n}\n\nconst Globals = new Map([\n [\"undefined\", undefined],\n [\"Infinity\", Infinity],\n [\"NaN\", NaN],\n]);\n\n/**\n * We wrap the _evaluate method so we can track `seen` nodes, we push an item\n * to the map before we actually evaluate it so we can deopt on self recursive\n * nodes such as:\n *\n * var g = a ? 1 : 2,\n * a = g * this.foo\n */\nfunction evaluateCached(path: NodePath, state: State): any {\n const { node } = path;\n const { seen } = state;\n\n if (seen.has(node)) {\n const existing = seen.get(node)!;\n if (existing.resolved) {\n return existing.value;\n } else {\n deopt(path, state);\n return;\n }\n } else {\n const item: Result = { resolved: false };\n seen.set(node, item);\n\n const val = _evaluate(path, state);\n if (state.confident) {\n item.resolved = true;\n item.value = val;\n }\n return val;\n }\n}\n\nfunction _evaluate(path: NodePath, state: State): any {\n if (!state.confident) return;\n\n if (path.isSequenceExpression()) {\n const exprs = path.get(\"expressions\");\n return evaluateCached(exprs[exprs.length - 1], state);\n }\n\n if (\n path.isStringLiteral() ||\n path.isNumericLiteral() ||\n path.isBooleanLiteral()\n ) {\n return path.node.value;\n }\n\n if (path.isNullLiteral()) {\n return null;\n }\n\n if (path.isTemplateLiteral()) {\n return evaluateQuasis(path, path.node.quasis, state);\n }\n\n if (\n path.isTaggedTemplateExpression() &&\n path.get(\"tag\").isMemberExpression()\n ) {\n const object = path.get(\"tag.object\") as NodePath;\n const {\n // @ts-expect-error todo(flow->ts): possible bug, object is can be any expression and so name might be undefined\n node: { name },\n } = object;\n const property = path.get(\"tag.property\") as NodePath;\n\n if (\n object.isIdentifier() &&\n name === \"String\" &&\n // todo(flow->ts): was changed from getBinding(name, true)\n // should this be hasBinding(name, true) as the binding is never used later?\n !path.scope.getBinding(name) &&\n property.isIdentifier() &&\n property.node.name === \"raw\"\n ) {\n return evaluateQuasis(path, path.node.quasi.quasis, state, true);\n }\n }\n\n if (path.isConditionalExpression()) {\n const testResult = evaluateCached(path.get(\"test\"), state);\n if (!state.confident) return;\n if (testResult) {\n return evaluateCached(path.get(\"consequent\"), state);\n } else {\n return evaluateCached(path.get(\"alternate\"), state);\n }\n }\n\n if (path.isExpressionWrapper()) {\n // TypeCastExpression, ExpressionStatement etc\n return evaluateCached(path.get(\"expression\"), state);\n }\n\n // \"foo\".length, \"foo\"[0]\n if (\n path.isMemberExpression() &&\n !path.parentPath.isCallExpression({ callee: path.node })\n ) {\n const property = path.get(\"property\");\n const object = path.get(\"object\");\n\n if (object.isLiteral()) {\n // @ts-expect-error todo(flow->ts): instead of typeof - would it be better to check type of ast node?\n const value = object.node.value;\n const type = typeof value;\n\n let key = null;\n if (path.node.computed) {\n key = evaluateCached(property, state);\n if (!state.confident) return;\n } else if (property.isIdentifier()) {\n key = property.node.name;\n }\n if (\n (type === \"number\" || type === \"string\") &&\n key != null &&\n (typeof key === \"number\" || typeof key === \"string\")\n ) {\n return value[key];\n }\n }\n }\n\n if (path.isReferencedIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (binding) {\n if (\n binding.constantViolations.length > 0 ||\n // @ts-expect-error comparing undefined and number\n path.node.start < binding.path.node.end\n ) {\n deopt(binding.path, state);\n return;\n }\n const bindingPathScope = binding.path.scope;\n if (binding.kind === \"var\" && bindingPathScope !== binding.scope) {\n let hasUnsafeBlock =\n !bindingPathScope.path.parentPath.isBlockStatement();\n for (let scope = bindingPathScope.parent; scope; scope = scope.parent) {\n if (scope === path.scope) {\n if (hasUnsafeBlock) {\n deopt(binding.path, state);\n return;\n }\n break;\n }\n if (scope.path.parentPath?.isBlockStatement()) {\n hasUnsafeBlock = true;\n }\n }\n }\n if (binding.hasValue) {\n return binding.value;\n }\n }\n\n const name = path.node.name;\n if (Globals.has(name)) {\n if (!binding) {\n return Globals.get(name);\n }\n deopt(binding.path, state);\n return;\n }\n\n if (!binding) {\n deopt(path, state);\n return;\n }\n\n const bindingPath = binding.path;\n if (!bindingPath.isVariableDeclarator()) {\n deopt(bindingPath, state);\n return;\n }\n const initPath = bindingPath.get(\"init\");\n // @ts-expect-error FIXME: evaluateCached does not accept NodePath<null>\n const value = evaluateCached(initPath, state);\n if (typeof value === \"object\" && value !== null && binding.references > 1) {\n // @ts-expect-error FIXME: deopt does not accept NodePath<null>\n deopt(initPath, state);\n return;\n }\n return value;\n }\n\n if (path.isUnaryExpression({ prefix: true })) {\n if (path.node.operator === \"void\") {\n // we don't need to evaluate the argument to know what this will return\n return undefined;\n }\n\n const argument = path.get(\"argument\");\n if (\n path.node.operator === \"typeof\" &&\n (argument.isFunction() || argument.isClass())\n ) {\n return \"function\";\n }\n\n const arg = evaluateCached(argument, state);\n if (!state.confident) return;\n switch (path.node.operator) {\n case \"!\":\n return !arg;\n case \"+\":\n return +arg;\n case \"-\":\n return -arg;\n case \"~\":\n return ~arg;\n case \"typeof\":\n return typeof arg;\n }\n }\n\n if (path.isArrayExpression()) {\n const arr = [];\n const elems = path.get(\"elements\");\n for (const elem of elems) {\n // @ts-expect-error FIXME: better types\n const elemValue = elem.evaluate();\n\n if (elemValue.confident) {\n arr.push(elemValue.value);\n } else {\n deopt(elemValue.deopt, state);\n return;\n }\n }\n return arr;\n }\n\n if (path.isObjectExpression()) {\n const obj = {};\n const props = path.get(\"properties\");\n for (const prop of props) {\n if (prop.isObjectMethod() || prop.isSpreadElement()) {\n deopt(prop, state);\n return;\n }\n const keyPath = prop.get(\"key\");\n let key;\n if (prop.node.computed) {\n key = keyPath.evaluate();\n if (!key.confident) {\n deopt(key.deopt, state);\n return;\n }\n key = key.value;\n } else if (keyPath.isIdentifier()) {\n key = keyPath.node.name;\n } else {\n key = (\n keyPath.node as t.StringLiteral | t.NumericLiteral | t.BigIntLiteral\n ).value;\n }\n const valuePath = prop.get(\"value\");\n let value = valuePath.evaluate();\n if (!value.confident) {\n deopt(value.deopt, state);\n return;\n }\n value = value.value;\n // @ts-expect-error key is any type\n obj[key] = value;\n }\n return obj;\n }\n\n if (path.isLogicalExpression()) {\n // If we are confident that the left side of an && is false, or the left\n // side of an || is true, we can be confident about the entire expression\n const wasConfident = state.confident;\n const left = evaluateCached(path.get(\"left\"), state);\n const leftConfident = state.confident;\n state.confident = wasConfident;\n const right = evaluateCached(path.get(\"right\"), state);\n const rightConfident = state.confident;\n\n switch (path.node.operator) {\n case \"||\":\n // TODO consider having a \"truthy type\" that doesn't bail on\n // left uncertainty but can still evaluate to truthy.\n state.confident = leftConfident && (!!left || rightConfident);\n if (!state.confident) return;\n\n return left || right;\n case \"&&\":\n state.confident = leftConfident && (!left || rightConfident);\n if (!state.confident) return;\n\n return left && right;\n case \"??\":\n state.confident = leftConfident && (left != null || rightConfident);\n if (!state.confident) return;\n\n return left ?? right;\n }\n }\n\n if (path.isBinaryExpression()) {\n const left = evaluateCached(path.get(\"left\"), state);\n if (!state.confident) return;\n const right = evaluateCached(path.get(\"right\"), state);\n if (!state.confident) return;\n\n switch (path.node.operator) {\n case \"-\":\n return left - right;\n case \"+\":\n return left + right;\n case \"/\":\n return left / right;\n case \"*\":\n return left * right;\n case \"%\":\n return left % right;\n case \"**\":\n return left ** right;\n case \"<\":\n return left < right;\n case \">\":\n return left > right;\n case \"<=\":\n return left <= right;\n case \">=\":\n return left >= right;\n case \"==\":\n return left == right; // eslint-disable-line eqeqeq\n case \"!=\":\n return left != right; // eslint-disable-line eqeqeq\n case \"===\":\n return left === right;\n case \"!==\":\n return left !== right;\n case \"|\":\n return left | right;\n case \"&\":\n return left & right;\n case \"^\":\n return left ^ right;\n case \"<<\":\n return left << right;\n case \">>\":\n return left >> right;\n case \">>>\":\n return left >>> right;\n }\n }\n\n if (path.isCallExpression()) {\n const callee = path.get(\"callee\");\n let context;\n let func;\n\n // Number(1);\n if (\n callee.isIdentifier() &&\n !path.scope.getBinding(callee.node.name) &&\n (isValidObjectCallee(callee.node.name) ||\n isValidIdentifierCallee(callee.node.name))\n ) {\n func = global[callee.node.name];\n }\n\n if (callee.isMemberExpression()) {\n const object = callee.get(\"object\");\n const property = callee.get(\"property\");\n\n // Math.min(1, 2)\n if (\n object.isIdentifier() &&\n property.isIdentifier() &&\n isValidObjectCallee(object.node.name) &&\n !isInvalidMethod(property.node.name)\n ) {\n context = global[object.node.name];\n const key = property.node.name;\n if (Object.hasOwn(context, key)) {\n func = context[key as keyof typeof context];\n }\n }\n\n // \"abc\".charCodeAt(4)\n if (object.isLiteral() && property.isIdentifier()) {\n // @ts-expect-error todo(flow->ts): consider checking ast node type instead of value type (StringLiteral and NumberLiteral)\n const type = typeof object.node.value;\n if (type === \"string\" || type === \"number\") {\n // @ts-expect-error todo(flow->ts): consider checking ast node type instead of value type\n context = object.node.value;\n func = context[property.node.name];\n }\n }\n }\n\n if (func) {\n const args = path.get(\"arguments\").map(arg => evaluateCached(arg, state));\n if (!state.confident) return;\n\n return func.apply(context, args);\n }\n }\n\n deopt(path, state);\n}\n\nfunction evaluateQuasis(\n path: NodePath<t.TaggedTemplateExpression | t.TemplateLiteral>,\n quasis: any[],\n state: State,\n raw = false,\n) {\n let str = \"\";\n\n let i = 0;\n const exprs = (\n path.isTemplateLiteral()\n ? path.get(\"expressions\")\n : path.get(\"quasi.expressions\")\n ) as NodePath<t.Expression>[];\n\n for (const elem of quasis) {\n // not confident, evaluated an expression we don't like\n if (!state.confident) break;\n\n // add on element\n str += raw ? elem.value.raw : elem.value.cooked;\n\n // add on interpolated expression if it's present\n const expr = exprs[i++];\n if (expr) str += String(evaluateCached(expr, state));\n }\n\n if (!state.confident) return;\n return str;\n}\n\n/**\n * Walk the input `node` and statically evaluate it.\n *\n * Returns an object in the form `{ confident, value, deopt }`. `confident`\n * indicates whether or not we had to drop out of evaluating the expression\n * because of hitting an unknown node that we couldn't confidently find the\n * value of, in which case `deopt` is the path of said node.\n *\n * Example:\n *\n * t.evaluate(parse(\"5 + 5\")) // { confident: true, value: 10 }\n * t.evaluate(parse(\"!true\")) // { confident: true, value: false }\n * t.evaluate(parse(\"foo + foo\")) // { confident: false, value: undefined, deopt: NodePath }\n *\n */\n\nexport function evaluate(this: NodePath): {\n confident: boolean;\n value: any;\n deopt: NodePath | null;\n} {\n const state: State = {\n confident: true,\n deoptPath: null,\n seen: new Map(),\n };\n let value = evaluateCached(this, state);\n if (!state.confident) value = undefined;\n\n return {\n confident: state.confident,\n deopt: state.deoptPath,\n value: value,\n };\n}\n"],"mappings":";;;;;;;AAKA,MAAMA,oBAAoB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAU;AAClE,MAAMC,wBAAwB,GAAG,CAC/B,UAAU,EACV,OAAO,EACP,YAAY,EACZ,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,oB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
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports._getKey = _getKey;
|
| 7 |
+
exports._getPattern = _getPattern;
|
| 8 |
+
exports.get = get;
|
| 9 |
+
exports.getAllNextSiblings = getAllNextSiblings;
|
| 10 |
+
exports.getAllPrevSiblings = getAllPrevSiblings;
|
| 11 |
+
exports.getAssignmentIdentifiers = getAssignmentIdentifiers;
|
| 12 |
+
exports.getBindingIdentifierPaths = getBindingIdentifierPaths;
|
| 13 |
+
exports.getBindingIdentifiers = getBindingIdentifiers;
|
| 14 |
+
exports.getCompletionRecords = getCompletionRecords;
|
| 15 |
+
exports.getNextSibling = getNextSibling;
|
| 16 |
+
exports.getOpposite = getOpposite;
|
| 17 |
+
exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths;
|
| 18 |
+
exports.getOuterBindingIdentifiers = getOuterBindingIdentifiers;
|
| 19 |
+
exports.getPrevSibling = getPrevSibling;
|
| 20 |
+
exports.getSibling = getSibling;
|
| 21 |
+
var _index = require("./index.js");
|
| 22 |
+
var _t = require("@babel/types");
|
| 23 |
+
const {
|
| 24 |
+
getAssignmentIdentifiers: _getAssignmentIdentifiers,
|
| 25 |
+
getBindingIdentifiers: _getBindingIdentifiers,
|
| 26 |
+
getOuterBindingIdentifiers: _getOuterBindingIdentifiers,
|
| 27 |
+
numericLiteral,
|
| 28 |
+
unaryExpression
|
| 29 |
+
} = _t;
|
| 30 |
+
const NORMAL_COMPLETION = 0;
|
| 31 |
+
const BREAK_COMPLETION = 1;
|
| 32 |
+
function NormalCompletion(path) {
|
| 33 |
+
return {
|
| 34 |
+
type: NORMAL_COMPLETION,
|
| 35 |
+
path
|
| 36 |
+
};
|
| 37 |
+
}
|
| 38 |
+
function BreakCompletion(path) {
|
| 39 |
+
return {
|
| 40 |
+
type: BREAK_COMPLETION,
|
| 41 |
+
path
|
| 42 |
+
};
|
| 43 |
+
}
|
| 44 |
+
function getOpposite() {
|
| 45 |
+
if (this.key === "left") {
|
| 46 |
+
return this.getSibling("right");
|
| 47 |
+
} else if (this.key === "right") {
|
| 48 |
+
return this.getSibling("left");
|
| 49 |
+
}
|
| 50 |
+
return null;
|
| 51 |
+
}
|
| 52 |
+
function addCompletionRecords(path, records, context) {
|
| 53 |
+
if (path) {
|
| 54 |
+
records.push(..._getCompletionRecords(path, context));
|
| 55 |
+
}
|
| 56 |
+
return records;
|
| 57 |
+
}
|
| 58 |
+
function completionRecordForSwitch(cases, records, context) {
|
| 59 |
+
let lastNormalCompletions = [];
|
| 60 |
+
for (let i = 0; i < cases.length; i++) {
|
| 61 |
+
const casePath = cases[i];
|
| 62 |
+
const caseCompletions = _getCompletionRecords(casePath, context);
|
| 63 |
+
const normalCompletions = [];
|
| 64 |
+
const breakCompletions = [];
|
| 65 |
+
for (const c of caseCompletions) {
|
| 66 |
+
if (c.type === NORMAL_COMPLETION) {
|
| 67 |
+
normalCompletions.push(c);
|
| 68 |
+
}
|
| 69 |
+
if (c.type === BREAK_COMPLETION) {
|
| 70 |
+
breakCompletions.push(c);
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
if (normalCompletions.length) {
|
| 74 |
+
lastNormalCompletions = normalCompletions;
|
| 75 |
+
}
|
| 76 |
+
records.push(...breakCompletions);
|
| 77 |
+
}
|
| 78 |
+
records.push(...lastNormalCompletions);
|
| 79 |
+
return records;
|
| 80 |
+
}
|
| 81 |
+
function normalCompletionToBreak(completions) {
|
| 82 |
+
completions.forEach(c => {
|
| 83 |
+
c.type = BREAK_COMPLETION;
|
| 84 |
+
});
|
| 85 |
+
}
|
| 86 |
+
function replaceBreakStatementInBreakCompletion(completions, reachable) {
|
| 87 |
+
completions.forEach(c => {
|
| 88 |
+
if (c.path.isBreakStatement({
|
| 89 |
+
label: null
|
| 90 |
+
})) {
|
| 91 |
+
if (reachable) {
|
| 92 |
+
c.path.replaceWith(unaryExpression("void", numericLiteral(0)));
|
| 93 |
+
} else {
|
| 94 |
+
c.path.remove();
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
});
|
| 98 |
+
}
|
| 99 |
+
function getStatementListCompletion(paths, context) {
|
| 100 |
+
const completions = [];
|
| 101 |
+
if (context.canHaveBreak) {
|
| 102 |
+
let lastNormalCompletions = [];
|
| 103 |
+
for (let i = 0; i < paths.length; i++) {
|
| 104 |
+
const path = paths[i];
|
| 105 |
+
const newContext = Object.assign({}, context, {
|
| 106 |
+
inCaseClause: false
|
| 107 |
+
});
|
| 108 |
+
if (path.isBlockStatement() && (context.inCaseClause || context.shouldPopulateBreak)) {
|
| 109 |
+
newContext.shouldPopulateBreak = true;
|
| 110 |
+
} else {
|
| 111 |
+
newContext.shouldPopulateBreak = false;
|
| 112 |
+
}
|
| 113 |
+
const statementCompletions = _getCompletionRecords(path, newContext);
|
| 114 |
+
if (statementCompletions.length > 0 && statementCompletions.every(c => c.type === BREAK_COMPLETION)) {
|
| 115 |
+
if (lastNormalCompletions.length > 0 && statementCompletions.every(c => c.path.isBreakStatement({
|
| 116 |
+
label: null
|
| 117 |
+
}))) {
|
| 118 |
+
normalCompletionToBreak(lastNormalCompletions);
|
| 119 |
+
completions.push(...lastNormalCompletions);
|
| 120 |
+
if (lastNormalCompletions.some(c => c.path.isDeclaration())) {
|
| 121 |
+
completions.push(...statementCompletions);
|
| 122 |
+
if (!context.shouldPreserveBreak) {
|
| 123 |
+
replaceBreakStatementInBreakCompletion(statementCompletions, true);
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
if (!context.shouldPreserveBreak) {
|
| 127 |
+
replaceBreakStatementInBreakCompletion(statementCompletions, false);
|
| 128 |
+
}
|
| 129 |
+
} else {
|
| 130 |
+
completions.push(...statementCompletions);
|
| 131 |
+
if (!context.shouldPopulateBreak && !context.shouldPreserveBreak) {
|
| 132 |
+
replaceBreakStatementInBreakCompletion(statementCompletions, true);
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
break;
|
| 136 |
+
}
|
| 137 |
+
if (i === paths.length - 1) {
|
| 138 |
+
completions.push(...statementCompletions);
|
| 139 |
+
} else {
|
| 140 |
+
lastNormalCompletions = [];
|
| 141 |
+
for (let i = 0; i < statementCompletions.length; i++) {
|
| 142 |
+
const c = statementCompletions[i];
|
| 143 |
+
if (c.type === BREAK_COMPLETION) {
|
| 144 |
+
completions.push(c);
|
| 145 |
+
}
|
| 146 |
+
if (c.type === NORMAL_COMPLETION) {
|
| 147 |
+
lastNormalCompletions.push(c);
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
} else if (paths.length) {
|
| 153 |
+
for (let i = paths.length - 1; i >= 0; i--) {
|
| 154 |
+
const pathCompletions = _getCompletionRecords(paths[i], context);
|
| 155 |
+
if (pathCompletions.length > 1 || pathCompletions.length === 1 && !pathCompletions[0].path.isVariableDeclaration() && !pathCompletions[0].path.isEmptyStatement()) {
|
| 156 |
+
completions.push(...pathCompletions);
|
| 157 |
+
break;
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
return completions;
|
| 162 |
+
}
|
| 163 |
+
function _getCompletionRecords(path, context) {
|
| 164 |
+
let records = [];
|
| 165 |
+
if (path.isIfStatement()) {
|
| 166 |
+
records = addCompletionRecords(path.get("consequent"), records, context);
|
| 167 |
+
records = addCompletionRecords(path.get("alternate"), records, context);
|
| 168 |
+
} else if (path.isDoExpression() || path.isFor() || path.isWhile() || path.isLabeledStatement()) {
|
| 169 |
+
return addCompletionRecords(path.get("body"), records, context);
|
| 170 |
+
} else if (path.isProgram() || path.isBlockStatement()) {
|
| 171 |
+
return getStatementListCompletion(path.get("body"), context);
|
| 172 |
+
} else if (path.isFunction()) {
|
| 173 |
+
return _getCompletionRecords(path.get("body"), context);
|
| 174 |
+
} else if (path.isTryStatement()) {
|
| 175 |
+
records = addCompletionRecords(path.get("block"), records, context);
|
| 176 |
+
records = addCompletionRecords(path.get("handler"), records, context);
|
| 177 |
+
} else if (path.isCatchClause()) {
|
| 178 |
+
return addCompletionRecords(path.get("body"), records, context);
|
| 179 |
+
} else if (path.isSwitchStatement()) {
|
| 180 |
+
return completionRecordForSwitch(path.get("cases"), records, context);
|
| 181 |
+
} else if (path.isSwitchCase()) {
|
| 182 |
+
return getStatementListCompletion(path.get("consequent"), {
|
| 183 |
+
canHaveBreak: true,
|
| 184 |
+
shouldPopulateBreak: false,
|
| 185 |
+
inCaseClause: true,
|
| 186 |
+
shouldPreserveBreak: context.shouldPreserveBreak
|
| 187 |
+
});
|
| 188 |
+
} else if (path.isBreakStatement()) {
|
| 189 |
+
records.push(BreakCompletion(path));
|
| 190 |
+
} else {
|
| 191 |
+
records.push(NormalCompletion(path));
|
| 192 |
+
}
|
| 193 |
+
return records;
|
| 194 |
+
}
|
| 195 |
+
function getCompletionRecords(shouldPreserveBreak = false) {
|
| 196 |
+
const records = _getCompletionRecords(this, {
|
| 197 |
+
canHaveBreak: false,
|
| 198 |
+
shouldPopulateBreak: false,
|
| 199 |
+
inCaseClause: false,
|
| 200 |
+
shouldPreserveBreak
|
| 201 |
+
});
|
| 202 |
+
return records.map(r => r.path);
|
| 203 |
+
}
|
| 204 |
+
function getSibling(key) {
|
| 205 |
+
return _index.default.get({
|
| 206 |
+
parentPath: this.parentPath,
|
| 207 |
+
parent: this.parent,
|
| 208 |
+
container: this.container,
|
| 209 |
+
listKey: this.listKey,
|
| 210 |
+
key: key
|
| 211 |
+
}).setContext(this.context);
|
| 212 |
+
}
|
| 213 |
+
function getPrevSibling() {
|
| 214 |
+
return this.getSibling(this.key - 1);
|
| 215 |
+
}
|
| 216 |
+
function getNextSibling() {
|
| 217 |
+
return this.getSibling(this.key + 1);
|
| 218 |
+
}
|
| 219 |
+
function getAllNextSiblings() {
|
| 220 |
+
let _key = this.key;
|
| 221 |
+
let sibling = this.getSibling(++_key);
|
| 222 |
+
const siblings = [];
|
| 223 |
+
while (sibling.node) {
|
| 224 |
+
siblings.push(sibling);
|
| 225 |
+
sibling = this.getSibling(++_key);
|
| 226 |
+
}
|
| 227 |
+
return siblings;
|
| 228 |
+
}
|
| 229 |
+
function getAllPrevSiblings() {
|
| 230 |
+
let _key = this.key;
|
| 231 |
+
let sibling = this.getSibling(--_key);
|
| 232 |
+
const siblings = [];
|
| 233 |
+
while (sibling.node) {
|
| 234 |
+
siblings.push(sibling);
|
| 235 |
+
sibling = this.getSibling(--_key);
|
| 236 |
+
}
|
| 237 |
+
return siblings;
|
| 238 |
+
}
|
| 239 |
+
function get(key, context = true) {
|
| 240 |
+
if (context === true) context = this.context;
|
| 241 |
+
const parts = key.split(".");
|
| 242 |
+
if (parts.length === 1) {
|
| 243 |
+
return _getKey.call(this, key, context);
|
| 244 |
+
} else {
|
| 245 |
+
return _getPattern.call(this, parts, context);
|
| 246 |
+
}
|
| 247 |
+
}
|
| 248 |
+
function _getKey(key, context) {
|
| 249 |
+
const node = this.node;
|
| 250 |
+
const container = node[key];
|
| 251 |
+
if (Array.isArray(container)) {
|
| 252 |
+
return container.map((_, i) => {
|
| 253 |
+
return _index.default.get({
|
| 254 |
+
listKey: key,
|
| 255 |
+
parentPath: this,
|
| 256 |
+
parent: node,
|
| 257 |
+
container: container,
|
| 258 |
+
key: i
|
| 259 |
+
}).setContext(context);
|
| 260 |
+
});
|
| 261 |
+
} else {
|
| 262 |
+
return _index.default.get({
|
| 263 |
+
parentPath: this,
|
| 264 |
+
parent: node,
|
| 265 |
+
container: node,
|
| 266 |
+
key: key
|
| 267 |
+
}).setContext(context);
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
function _getPattern(parts, context) {
|
| 271 |
+
let path = this;
|
| 272 |
+
for (const part of parts) {
|
| 273 |
+
if (part === ".") {
|
| 274 |
+
path = path.parentPath;
|
| 275 |
+
} else {
|
| 276 |
+
if (Array.isArray(path)) {
|
| 277 |
+
path = path[part];
|
| 278 |
+
} else {
|
| 279 |
+
path = path.get(part, context);
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
}
|
| 283 |
+
return path;
|
| 284 |
+
}
|
| 285 |
+
function getAssignmentIdentifiers() {
|
| 286 |
+
return _getAssignmentIdentifiers(this.node);
|
| 287 |
+
}
|
| 288 |
+
function getBindingIdentifiers(duplicates) {
|
| 289 |
+
return _getBindingIdentifiers(this.node, duplicates);
|
| 290 |
+
}
|
| 291 |
+
function getOuterBindingIdentifiers(duplicates) {
|
| 292 |
+
return _getOuterBindingIdentifiers(this.node, duplicates);
|
| 293 |
+
}
|
| 294 |
+
function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
|
| 295 |
+
const path = this;
|
| 296 |
+
const search = [path];
|
| 297 |
+
const ids = Object.create(null);
|
| 298 |
+
while (search.length) {
|
| 299 |
+
const id = search.shift();
|
| 300 |
+
if (!id) continue;
|
| 301 |
+
if (!id.node) continue;
|
| 302 |
+
const keys = _getBindingIdentifiers.keys[id.node.type];
|
| 303 |
+
if (id.isIdentifier()) {
|
| 304 |
+
if (duplicates) {
|
| 305 |
+
const _ids = ids[id.node.name] = ids[id.node.name] || [];
|
| 306 |
+
_ids.push(id);
|
| 307 |
+
} else {
|
| 308 |
+
ids[id.node.name] = id;
|
| 309 |
+
}
|
| 310 |
+
continue;
|
| 311 |
+
}
|
| 312 |
+
if (id.isExportDeclaration()) {
|
| 313 |
+
const declaration = id.get("declaration");
|
| 314 |
+
if (declaration.isDeclaration()) {
|
| 315 |
+
search.push(declaration);
|
| 316 |
+
}
|
| 317 |
+
continue;
|
| 318 |
+
}
|
| 319 |
+
if (outerOnly) {
|
| 320 |
+
if (id.isFunctionDeclaration()) {
|
| 321 |
+
search.push(id.get("id"));
|
| 322 |
+
continue;
|
| 323 |
+
}
|
| 324 |
+
if (id.isFunctionExpression()) {
|
| 325 |
+
continue;
|
| 326 |
+
}
|
| 327 |
+
}
|
| 328 |
+
if (keys) {
|
| 329 |
+
for (let i = 0; i < keys.length; i++) {
|
| 330 |
+
const key = keys[i];
|
| 331 |
+
const child = id.get(key);
|
| 332 |
+
if (Array.isArray(child)) {
|
| 333 |
+
search.push(...child);
|
| 334 |
+
} else if (child.node) {
|
| 335 |
+
search.push(child);
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
}
|
| 340 |
+
return ids;
|
| 341 |
+
}
|
| 342 |
+
function getOuterBindingIdentifierPaths(duplicates = false) {
|
| 343 |
+
return this.getBindingIdentifierPaths(duplicates, true);
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
//# sourceMappingURL=family.js.map
|
node_modules/@babel/traverse/lib/path/family.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_index","require","_t","getAssignmentIdentifiers","_getAssignmentIdentifiers","getBindingIdentifiers","_getBindingIdentifiers","getOuterBindingIdentifiers","_getOuterBindingIdentifiers","numericLiteral","unaryExpression","NORMAL_COMPLETION","BREAK_COMPLETION","NormalCompletion","path","type","BreakCompletion","getOpposite","key","getSibling","addCompletionRecords","records","context","push","_getCompletionRecords","completionRecordForSwitch","cases","lastNormalCompletions","i","length","casePath","caseCompletions","normalCompletions","breakCompletions","c","normalCompletionToBreak","completions","forEach","replaceBreakStatementInBreakCompletion","reachable","isBreakStatement","label","replaceWith","remove","getStatementListCompletion","paths","canHaveBreak","newContext","Object","assign","inCaseClause","isBlockStatement","shouldPopulateBreak","statementCompletions","every","some","isDeclaration","shouldPreserveBreak","pathCompletions","isVariableDeclaration","isEmptyStatement","isIfStatement","get","isDoExpression","isFor","isWhile","isLabeledStatement","isProgram","isFunction","isTryStatement","isCatchClause","isSwitchStatement","isSwitchCase","getCompletionRecords","map","r","NodePath","parentPath","parent","container","listKey","setContext","getPrevSibling","getNextSibling","getAllNextSiblings","_key","sibling","siblings","node","getAllPrevSiblings","parts","split","_getKey","call","_getPattern","Array","isArray","_","part","duplicates","getBindingIdentifierPaths","outerOnly","search","ids","create","id","shift","keys","isIdentifier","_ids","name","isExportDeclaration","declaration","isFunctionDeclaration","isFunctionExpression","child","getOuterBindingIdentifierPaths"],"sources":["../../src/path/family.ts"],"sourcesContent":["// This file contains methods responsible for dealing with/retrieving children or siblings.\n\nimport type TraversalContext from \"../context.ts\";\nimport NodePath from \"./index.ts\";\nimport {\n getAssignmentIdentifiers as _getAssignmentIdentifiers,\n getBindingIdentifiers as _getBindingIdentifiers,\n getOuterBindingIdentifiers as _getOuterBindingIdentifiers,\n numericLiteral,\n unaryExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nconst NORMAL_COMPLETION = 0;\nconst BREAK_COMPLETION = 1;\n\ntype Completion = {\n path: NodePath;\n type: 0 | 1;\n};\n\ntype CompletionContext = {\n // whether the current context allows `break` statement. When it allows, we have\n // to search all the statements for potential `break`\n canHaveBreak: boolean;\n // whether the statement is an immediate descendant of a switch case clause\n inCaseClause: boolean;\n // whether the `break` statement record should be populated to upper level\n // when a `break` statement is an immediate descendant of a block statement, e.g.\n // `{ break }`, it can influence the control flow in the upper levels.\n shouldPopulateBreak: boolean;\n // Whether the `break` statement should be preserved.\n shouldPreserveBreak: boolean;\n};\n\nfunction NormalCompletion(path: NodePath): Completion {\n return { type: NORMAL_COMPLETION, path };\n}\n\nfunction BreakCompletion(path: NodePath): Completion {\n return { type: BREAK_COMPLETION, path };\n}\n\nexport function getOpposite(this: NodePath): NodePath | null {\n if (this.key === \"left\") {\n return this.getSibling(\"right\");\n } else if (this.key === \"right\") {\n return this.getSibling(\"left\");\n }\n return null;\n}\n\nfunction addCompletionRecords(\n path: NodePath<t.Node | null> | null | undefined,\n records: Completion[],\n context: CompletionContext,\n): Completion[] {\n if (path) {\n // @ts-expect-error FIXME: NodePath<null>\n records.push(..._getCompletionRecords(path, context));\n }\n return records;\n}\n\nfunction completionRecordForSwitch(\n cases: NodePath<t.SwitchCase>[],\n records: Completion[],\n context: CompletionContext,\n): Completion[] {\n // https://tc39.es/ecma262/#sec-runtime-semantics-caseblockevaluation\n let lastNormalCompletions: Completion[] = [];\n for (let i = 0; i < cases.length; i++) {\n const casePath = cases[i];\n const caseCompletions = _getCompletionRecords(casePath, context);\n const normalCompletions = [];\n const breakCompletions = [];\n for (const c of caseCompletions) {\n if (c.type === NORMAL_COMPLETION) {\n normalCompletions.push(c);\n }\n if (c.type === BREAK_COMPLETION) {\n breakCompletions.push(c);\n }\n }\n if (normalCompletions.length) {\n lastNormalCompletions = normalCompletions;\n }\n records.push(...breakCompletions);\n }\n records.push(...lastNormalCompletions);\n return records;\n}\n\nfunction normalCompletionToBreak(completions: Completion[]) {\n completions.forEach(c => {\n c.type = BREAK_COMPLETION;\n });\n}\n\n/**\n * Determine how we should handle the break statement for break completions\n *\n * @param {Completion[]} completions\n * @param {boolean} reachable Whether the break statement is reachable after\n we mark the normal completions _before_ the given break completions as the final\n completions. For example,\n `{ 0 }; break;` is transformed to `{ return 0 }; break;`, the `break` here is unreachable\n and thus can be removed without consequences. We may in the future reserve them instead since\n we do not consistently remove unreachable statements _after_ break\n `{ var x = 0 }; break;` is transformed to `{ var x = 0 }; return void 0;`, the `break` is reachable\n because we can not wrap variable declaration under a return statement\n */\nfunction replaceBreakStatementInBreakCompletion(\n completions: Completion[],\n reachable: boolean,\n) {\n completions.forEach(c => {\n if (c.path.isBreakStatement({ label: null })) {\n if (reachable) {\n c.path.replaceWith(unaryExpression(\"void\", numericLiteral(0)));\n } else {\n c.path.remove();\n }\n }\n });\n}\n\nfunction getStatementListCompletion(\n paths: NodePath[],\n context: CompletionContext,\n): Completion[] {\n const completions = [];\n if (context.canHaveBreak) {\n let lastNormalCompletions = [];\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i];\n const newContext = { ...context, inCaseClause: false };\n if (\n path.isBlockStatement() &&\n (context.inCaseClause || // case test: { break }\n context.shouldPopulateBreak) // case test: { { break } }\n ) {\n newContext.shouldPopulateBreak = true;\n } else {\n newContext.shouldPopulateBreak = false;\n }\n const statementCompletions = _getCompletionRecords(path, newContext);\n if (\n statementCompletions.length > 0 &&\n // we can stop search `paths` when we have seen a `path` that is\n // effectively a `break` statement. Examples are\n // - `break`\n // - `if (true) { 1; break } else { 2; break }`\n // - `{ break }```\n // In other words, the paths after this `path` are unreachable\n statementCompletions.every(c => c.type === BREAK_COMPLETION)\n ) {\n if (\n lastNormalCompletions.length > 0 &&\n statementCompletions.every(c =>\n c.path.isBreakStatement({ label: null }),\n )\n ) {\n // when a break completion has a path as BreakStatement, it must be `{ break }`\n // whose completion value we can not determine, otherwise it would have been\n // replaced by `replaceBreakStatementInBreakCompletion`\n // When we have seen normal completions from the last statement\n // it is safe to stop populating break and mark normal completions as break\n normalCompletionToBreak(lastNormalCompletions);\n completions.push(...lastNormalCompletions);\n // Declarations have empty completion record, however they can not be nested\n // directly in return statement, i.e. `return (var a = 1)` is invalid.\n if (lastNormalCompletions.some(c => c.path.isDeclaration())) {\n completions.push(...statementCompletions);\n if (!context.shouldPreserveBreak) {\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ true,\n );\n }\n }\n if (!context.shouldPreserveBreak) {\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ false,\n );\n }\n } else {\n completions.push(...statementCompletions);\n if (!context.shouldPopulateBreak && !context.shouldPreserveBreak) {\n replaceBreakStatementInBreakCompletion(\n statementCompletions,\n /* reachable */ true,\n );\n }\n }\n break;\n }\n if (i === paths.length - 1) {\n completions.push(...statementCompletions);\n } else {\n lastNormalCompletions = [];\n for (let i = 0; i < statementCompletions.length; i++) {\n const c = statementCompletions[i];\n if (c.type === BREAK_COMPLETION) {\n completions.push(c);\n }\n if (c.type === NORMAL_COMPLETION) {\n lastNormalCompletions.push(c);\n }\n }\n }\n }\n } else if (paths.length) {\n // When we are in a context where `break` must not exist, we can skip linear\n // search on statement lists and assume that the last\n // non-variable-declaration statement determines the completion.\n for (let i = paths.length - 1; i >= 0; i--) {\n const pathCompletions = _getCompletionRecords(paths[i], context);\n if (\n pathCompletions.length > 1 ||\n (pathCompletions.length === 1 &&\n !pathCompletions[0].path.isVariableDeclaration() &&\n !pathCompletions[0].path.isEmptyStatement())\n ) {\n completions.push(...pathCompletions);\n break;\n }\n }\n }\n return completions;\n}\n\nfunction _getCompletionRecords(\n path: NodePath,\n context: CompletionContext,\n): Completion[] {\n let records: Completion[] = [];\n if (path.isIfStatement()) {\n records = addCompletionRecords(path.get(\"consequent\"), records, context);\n records = addCompletionRecords(path.get(\"alternate\"), records, context);\n } else if (\n path.isDoExpression() ||\n path.isFor() ||\n path.isWhile() ||\n path.isLabeledStatement()\n ) {\n return addCompletionRecords(path.get(\"body\"), records, context);\n } else if (path.isProgram() || path.isBlockStatement()) {\n return getStatementListCompletion(path.get(\"body\"), context);\n } else if (path.isFunction()) {\n return _getCompletionRecords(path.get(\"body\"), context);\n } else if (path.isTryStatement()) {\n records = addCompletionRecords(path.get(\"block\"), records, context);\n records = addCompletionRecords(path.get(\"handler\"), records, context);\n } else if (path.isCatchClause()) {\n return addCompletionRecords(path.get(\"body\"), records, context);\n } else if (path.isSwitchStatement()) {\n return completionRecordForSwitch(path.get(\"cases\"), records, context);\n } else if (path.isSwitchCase()) {\n return getStatementListCompletion(path.get(\"consequent\"), {\n canHaveBreak: true,\n shouldPopulateBreak: false,\n inCaseClause: true,\n shouldPreserveBreak: context.shouldPreserveBreak,\n });\n } else if (path.isBreakStatement()) {\n records.push(BreakCompletion(path));\n } else {\n records.push(NormalCompletion(path));\n }\n\n return records;\n}\n\n/**\n * Retrieve the completion records of a given path.\n * Note: to ensure proper support on `break` statement, this method\n * will manipulate the AST around the break statement. Do not call the method\n * twice for the same path.\n *\n * @export\n * @param {NodePath} this\n * @param {boolean} [shouldPreserveBreak=false] Whether the `break` statement should be preserved.\n * @returns {NodePath[]} Completion records\n */\nexport function getCompletionRecords(\n this: NodePath,\n shouldPreserveBreak = false,\n): NodePath[] {\n const records = _getCompletionRecords(this, {\n canHaveBreak: false,\n shouldPopulateBreak: false,\n inCaseClause: false,\n shouldPreserveBreak,\n });\n return records.map(r => r.path);\n}\n\nexport function getSibling(this: NodePath, key: string | number): NodePath {\n return NodePath.get({\n parentPath: this.parentPath,\n parent: this.parent,\n container: this.container!,\n listKey: this.listKey!,\n key: key,\n }).setContext(this.context);\n}\n\nexport function getPrevSibling(this: NodePath): NodePath {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n return this.getSibling(this.key - 1);\n}\n\nexport function getNextSibling(this: NodePath): NodePath {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n return this.getSibling(this.key + 1);\n}\n\nexport function getAllNextSiblings(this: NodePath): NodePath[] {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n let _key: number = this.key;\n let sibling = this.getSibling(++_key);\n const siblings = [];\n while (sibling.node) {\n siblings.push(sibling);\n sibling = this.getSibling(++_key);\n }\n return siblings;\n}\n\nexport function getAllPrevSiblings(this: NodePath): NodePath[] {\n // @ts-expect-error todo(flow->ts) this.key could be a string\n let _key: number = this.key;\n let sibling = this.getSibling(--_key);\n const siblings = [];\n while (sibling.node) {\n siblings.push(sibling);\n sibling = this.getSibling(--_key);\n }\n return siblings;\n}\n\n// convert \"1\" to 1 (string index to number index)\ntype MaybeToIndex<T extends string> = T extends `${bigint}` ? number : T;\n\ntype Pattern<Obj extends string, Prop extends string> = `${Obj}.${Prop}`;\n\n// split \"body.body.1\" to [\"body\", \"body\", 1]\ntype Split<P extends string> =\n P extends Pattern<infer O, infer U>\n ? [MaybeToIndex<O>, ...Split<U>]\n : [MaybeToIndex<P>];\n\n// traverse the Node with tuple path [\"body\", \"body\", 1]\n// Path should be created with Split\ntype Trav<\n Node extends t.Node | t.Node[],\n Path extends unknown[],\n> = Path extends [infer K, ...infer R]\n ? K extends keyof Node\n ? R extends []\n ? Node[K]\n : Node[K] extends t.Node | t.Node[] | null | undefined\n ? TravD<Node[K] & {}, R> | null\n : never\n : never\n : never;\n\ntype TravD<\n Node extends t.Node | t.Node[],\n Path extends unknown[],\n> = Node extends any ? Trav<Node, Path> : never;\n\ntype ToNodePath<T> = T extends undefined | null\n ? NodePath<null>\n : T extends (infer U extends t.Node | null)[]\n ? NodePath<U>[]\n : T extends t.Node | null | undefined\n ? NodePath<T & {}>\n : never;\n\nfunction get<T extends NodePath, K extends keyof T[\"node\"]>(\n this: T,\n key: K,\n context?: true | TraversalContext,\n): T extends any\n ? T[\"node\"][K] extends (infer U extends t.Node | null)[] | null | undefined\n ? NodePath<U>[]\n : T[\"node\"][K] extends (infer U extends t.Node | null) | undefined\n ? NodePath<U>\n : never\n : never;\n\nfunction get<T extends NodePath<t.Node>, K extends string>(\n this: T,\n key: K,\n context?: true | TraversalContext,\n): T extends any ? ToNodePath<Trav<T[\"node\"], Split<K>>> : never;\n\nfunction get(\n this: NodePath,\n key: string,\n context?: true | TraversalContext,\n): NodePath<t.Node | null> | NodePath<t.Node | null>[];\n\nfunction get(\n this: NodePath,\n key: string,\n context: true | TraversalContext = true,\n): NodePath | NodePath[] {\n if (context === true) context = this.context;\n const parts = key.split(\".\");\n if (parts.length === 1) {\n // \"foo\"\n // @ts-expect-error key may not index T\n return _getKey.call(this, key, context);\n } else {\n // \"foo.bar\"\n return _getPattern.call(this, parts, context);\n }\n}\n\nexport { get };\n\nexport function _getKey<T extends t.Node>(\n this: NodePath<T>,\n key: keyof T & string,\n context?: TraversalContext,\n): NodePath | NodePath[] {\n const node = this.node as T;\n const container = node[key];\n\n if (Array.isArray(container)) {\n // requested a container so give them all the paths\n return container.map((_, i) => {\n return NodePath.get({\n listKey: key,\n parentPath: this,\n parent: node,\n container: container,\n key: i,\n }).setContext(context);\n });\n } else {\n return NodePath.get({\n parentPath: this,\n parent: node,\n container: node,\n key: key,\n }).setContext(context);\n }\n}\n\nexport function _getPattern(\n this: NodePath,\n parts: string[],\n context?: TraversalContext,\n): NodePath | NodePath[] {\n let path: NodePath | NodePath[] = this;\n for (const part of parts) {\n if (part === \".\") {\n // @ts-expect-error todo(flow-ts): Can path be an array here?\n path = path.parentPath;\n } else {\n if (Array.isArray(path)) {\n // @ts-expect-error part may not index path\n path = path[part];\n } else {\n path = path.get(part, context);\n }\n }\n }\n return path;\n}\n\nexport function getAssignmentIdentifiers(this: NodePath) {\n return _getAssignmentIdentifiers(this.node);\n}\n\nfunction getBindingIdentifiers(\n duplicates: true,\n): Record<string, t.Identifier[]>;\nfunction getBindingIdentifiers(\n duplicates?: false,\n): Record<string, t.Identifier>;\nfunction getBindingIdentifiers(\n duplicates: boolean,\n): Record<string, t.Identifier[] | t.Identifier>;\n\nfunction getBindingIdentifiers(\n this: NodePath,\n duplicates?: boolean,\n): Record<string, t.Identifier[] | t.Identifier> {\n return _getBindingIdentifiers(this.node, duplicates);\n}\n\nexport { getBindingIdentifiers };\n\nfunction getOuterBindingIdentifiers(\n duplicates: true,\n): Record<string, t.Identifier[]>;\nfunction getOuterBindingIdentifiers(\n duplicates?: false,\n): Record<string, t.Identifier>;\nfunction getOuterBindingIdentifiers(\n duplicates: boolean,\n): Record<string, t.Identifier[] | t.Identifier>;\n\nfunction getOuterBindingIdentifiers(\n this: NodePath,\n duplicates?: boolean,\n): Record<string, t.Identifier[] | t.Identifier> {\n return _getOuterBindingIdentifiers(this.node, duplicates);\n}\n\nexport { getOuterBindingIdentifiers };\n\nfunction getBindingIdentifierPaths(\n duplicates: true,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier>[]>;\nfunction getBindingIdentifierPaths(\n duplicates: false,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier>>;\nfunction getBindingIdentifierPaths(\n duplicates?: boolean,\n outerOnly?: boolean,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]>;\n\n// original source - https://github.com/babel/babel/blob/main/packages/babel-types/src/retrievers/getBindingIdentifiers.js\n// path.getBindingIdentifiers returns nodes where the following re-implementation returns paths\nfunction getBindingIdentifierPaths(\n this: NodePath,\n duplicates: boolean = false,\n outerOnly: boolean = false,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]> {\n const path = this;\n const search = [path];\n const ids = Object.create(null);\n\n while (search.length) {\n const id = search.shift();\n if (!id) continue;\n if (!id.node) continue;\n\n const keys = _getBindingIdentifiers.keys[id.node.type];\n\n if (id.isIdentifier()) {\n if (duplicates) {\n const _ids = (ids[id.node.name] = ids[id.node.name] || []);\n _ids.push(id);\n } else {\n ids[id.node.name] = id;\n }\n continue;\n }\n\n if (id.isExportDeclaration()) {\n const declaration = id.get(\"declaration\");\n if (declaration.isDeclaration()) {\n search.push(declaration);\n }\n continue;\n }\n\n if (outerOnly) {\n if (id.isFunctionDeclaration()) {\n // @ts-expect-error FIXME: NodePath<null>\n search.push(id.get(\"id\"));\n continue;\n }\n if (id.isFunctionExpression()) {\n continue;\n }\n }\n\n if (keys) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const child = id.get(key);\n if (Array.isArray(child)) {\n // @ts-expect-error FIXME: NodePath<null>\n search.push(...child);\n } else if (child.node) {\n search.push(child);\n }\n }\n }\n }\n\n return ids;\n}\n\nexport { getBindingIdentifierPaths };\n\nfunction getOuterBindingIdentifierPaths(\n duplicates: true,\n): Record<string, NodePath<t.Identifier>[]>;\nfunction getOuterBindingIdentifierPaths(\n duplicates?: false,\n): Record<string, NodePath<t.Identifier>>;\nfunction getOuterBindingIdentifierPaths(\n duplicates?: boolean,\n): Record<string, NodePath<t.Identifier> | NodePath<t.Identifier>[]>;\n\nfunction getOuterBindingIdentifierPaths(\n this: NodePath,\n duplicates: boolean = false,\n) {\n return this.getBindingIdentifierPaths(duplicates, true);\n}\n\nexport { getOuterBindingIdentifierPaths };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,EAAA,GAAAD,OAAA;AAMsB;EALpBE,wBAAwB,EAAIC,yBAAyB;EACrDC,qBAAqB,EAAIC,sBAAsB;EAC/CC,0BAA0B,EAAIC,2BAA2B;EACzDC,cAAc;EACdC;AAAe,IAAAR,EAAA;AAIjB,MAAMS,iBAAiB,GAAG,CAAC;AA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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = exports.SHOULD_STOP = exports.SHOULD_SKIP = exports.REMOVED = void 0;
|
| 7 |
+
var virtualTypes = require("./lib/virtual-types.js");
|
| 8 |
+
var _debug = require("debug");
|
| 9 |
+
var _index = require("../index.js");
|
| 10 |
+
var _index2 = require("../scope/index.js");
|
| 11 |
+
var _t = require("@babel/types");
|
| 12 |
+
var t = _t;
|
| 13 |
+
var cache = require("../cache.js");
|
| 14 |
+
var _generator = require("@babel/generator");
|
| 15 |
+
var NodePath_ancestry = require("./ancestry.js");
|
| 16 |
+
var NodePath_inference = require("./inference/index.js");
|
| 17 |
+
var NodePath_replacement = require("./replacement.js");
|
| 18 |
+
var NodePath_evaluation = require("./evaluation.js");
|
| 19 |
+
var NodePath_conversion = require("./conversion.js");
|
| 20 |
+
var NodePath_introspection = require("./introspection.js");
|
| 21 |
+
var _context = require("./context.js");
|
| 22 |
+
var NodePath_context = _context;
|
| 23 |
+
var NodePath_removal = require("./removal.js");
|
| 24 |
+
var NodePath_modification = require("./modification.js");
|
| 25 |
+
var NodePath_family = require("./family.js");
|
| 26 |
+
var NodePath_comments = require("./comments.js");
|
| 27 |
+
var NodePath_virtual_types_validator = require("./lib/virtual-types-validator.js");
|
| 28 |
+
const {
|
| 29 |
+
validate
|
| 30 |
+
} = _t;
|
| 31 |
+
const debug = _debug("babel");
|
| 32 |
+
const REMOVED = exports.REMOVED = 1 << 0;
|
| 33 |
+
const SHOULD_STOP = exports.SHOULD_STOP = 1 << 1;
|
| 34 |
+
const SHOULD_SKIP = exports.SHOULD_SKIP = 1 << 2;
|
| 35 |
+
const NodePath_Final = exports.default = class NodePath {
|
| 36 |
+
constructor(hub, parent) {
|
| 37 |
+
this.contexts = [];
|
| 38 |
+
this.state = null;
|
| 39 |
+
this._traverseFlags = 0;
|
| 40 |
+
this.skipKeys = null;
|
| 41 |
+
this.parentPath = null;
|
| 42 |
+
this.container = null;
|
| 43 |
+
this.listKey = null;
|
| 44 |
+
this.key = null;
|
| 45 |
+
this.node = null;
|
| 46 |
+
this.type = null;
|
| 47 |
+
this._store = null;
|
| 48 |
+
this.parent = parent;
|
| 49 |
+
this.hub = hub;
|
| 50 |
+
this.data = null;
|
| 51 |
+
this.context = null;
|
| 52 |
+
this.scope = null;
|
| 53 |
+
}
|
| 54 |
+
get removed() {
|
| 55 |
+
return (this._traverseFlags & 1) > 0;
|
| 56 |
+
}
|
| 57 |
+
set removed(v) {
|
| 58 |
+
if (v) this._traverseFlags |= 1;else this._traverseFlags &= -2;
|
| 59 |
+
}
|
| 60 |
+
get shouldStop() {
|
| 61 |
+
return (this._traverseFlags & 2) > 0;
|
| 62 |
+
}
|
| 63 |
+
set shouldStop(v) {
|
| 64 |
+
if (v) this._traverseFlags |= 2;else this._traverseFlags &= -3;
|
| 65 |
+
}
|
| 66 |
+
get shouldSkip() {
|
| 67 |
+
return (this._traverseFlags & 4) > 0;
|
| 68 |
+
}
|
| 69 |
+
set shouldSkip(v) {
|
| 70 |
+
if (v) this._traverseFlags |= 4;else this._traverseFlags &= -5;
|
| 71 |
+
}
|
| 72 |
+
static get({
|
| 73 |
+
hub,
|
| 74 |
+
parentPath,
|
| 75 |
+
parent,
|
| 76 |
+
container,
|
| 77 |
+
listKey,
|
| 78 |
+
key
|
| 79 |
+
}) {
|
| 80 |
+
if (!hub && parentPath) {
|
| 81 |
+
hub = parentPath.hub;
|
| 82 |
+
}
|
| 83 |
+
if (!parent) {
|
| 84 |
+
throw new Error("To get a node path the parent needs to exist");
|
| 85 |
+
}
|
| 86 |
+
const targetNode = container[key];
|
| 87 |
+
const paths = cache.getOrCreateCachedPaths(parent, parentPath);
|
| 88 |
+
let path = paths.get(targetNode);
|
| 89 |
+
if (!path) {
|
| 90 |
+
path = new NodePath(hub, parent);
|
| 91 |
+
if (targetNode) paths.set(targetNode, path);
|
| 92 |
+
}
|
| 93 |
+
_context.setup.call(path, parentPath, container, listKey, key);
|
| 94 |
+
return path;
|
| 95 |
+
}
|
| 96 |
+
getScope(scope) {
|
| 97 |
+
return this.isScope() ? new _index2.default(this) : scope;
|
| 98 |
+
}
|
| 99 |
+
setData(key, val) {
|
| 100 |
+
if (this.data == null) {
|
| 101 |
+
this.data = Object.create(null);
|
| 102 |
+
}
|
| 103 |
+
return this.data[key] = val;
|
| 104 |
+
}
|
| 105 |
+
getData(key, def) {
|
| 106 |
+
if (this.data == null) {
|
| 107 |
+
this.data = Object.create(null);
|
| 108 |
+
}
|
| 109 |
+
let val = this.data[key];
|
| 110 |
+
if (val === undefined && def !== undefined) val = this.data[key] = def;
|
| 111 |
+
return val;
|
| 112 |
+
}
|
| 113 |
+
hasNode() {
|
| 114 |
+
return this.node != null;
|
| 115 |
+
}
|
| 116 |
+
buildCodeFrameError(msg, Error = SyntaxError) {
|
| 117 |
+
return this.hub.buildError(this.node, msg, Error);
|
| 118 |
+
}
|
| 119 |
+
traverse(visitor, state) {
|
| 120 |
+
(0, _index.default)(this.node, visitor, this.scope, state, this);
|
| 121 |
+
}
|
| 122 |
+
set(key, node) {
|
| 123 |
+
validate(this.node, key, node);
|
| 124 |
+
this.node[key] = node;
|
| 125 |
+
}
|
| 126 |
+
getPathLocation() {
|
| 127 |
+
const parts = [];
|
| 128 |
+
let path = this;
|
| 129 |
+
do {
|
| 130 |
+
let key = path.key;
|
| 131 |
+
if (path.inList) key = `${path.listKey}[${key}]`;
|
| 132 |
+
parts.unshift(key);
|
| 133 |
+
} while (path = path.parentPath);
|
| 134 |
+
return parts.join(".");
|
| 135 |
+
}
|
| 136 |
+
debug(message) {
|
| 137 |
+
if (!debug.enabled) return;
|
| 138 |
+
debug(`${this.getPathLocation()} ${this.type}: ${message}`);
|
| 139 |
+
}
|
| 140 |
+
toString() {
|
| 141 |
+
return (0, _generator.default)(this.node).code;
|
| 142 |
+
}
|
| 143 |
+
get inList() {
|
| 144 |
+
return !!this.listKey;
|
| 145 |
+
}
|
| 146 |
+
set inList(inList) {
|
| 147 |
+
if (!inList) {
|
| 148 |
+
this.listKey = null;
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
get parentKey() {
|
| 152 |
+
return this.listKey || this.key;
|
| 153 |
+
}
|
| 154 |
+
};
|
| 155 |
+
const methods = {
|
| 156 |
+
findParent: NodePath_ancestry.findParent,
|
| 157 |
+
find: NodePath_ancestry.find,
|
| 158 |
+
getFunctionParent: NodePath_ancestry.getFunctionParent,
|
| 159 |
+
getStatementParent: NodePath_ancestry.getStatementParent,
|
| 160 |
+
getEarliestCommonAncestorFrom: NodePath_ancestry.getEarliestCommonAncestorFrom,
|
| 161 |
+
getDeepestCommonAncestorFrom: NodePath_ancestry.getDeepestCommonAncestorFrom,
|
| 162 |
+
getAncestry: NodePath_ancestry.getAncestry,
|
| 163 |
+
isAncestor: NodePath_ancestry.isAncestor,
|
| 164 |
+
isDescendant: NodePath_ancestry.isDescendant,
|
| 165 |
+
inType: NodePath_ancestry.inType,
|
| 166 |
+
getTypeAnnotation: NodePath_inference.getTypeAnnotation,
|
| 167 |
+
isBaseType: NodePath_inference.isBaseType,
|
| 168 |
+
couldBeBaseType: NodePath_inference.couldBeBaseType,
|
| 169 |
+
baseTypeStrictlyMatches: NodePath_inference.baseTypeStrictlyMatches,
|
| 170 |
+
isGenericType: NodePath_inference.isGenericType,
|
| 171 |
+
replaceWithMultiple: NodePath_replacement.replaceWithMultiple,
|
| 172 |
+
replaceWithSourceString: NodePath_replacement.replaceWithSourceString,
|
| 173 |
+
replaceWith: NodePath_replacement.replaceWith,
|
| 174 |
+
replaceExpressionWithStatements: NodePath_replacement.replaceExpressionWithStatements,
|
| 175 |
+
replaceInline: NodePath_replacement.replaceInline,
|
| 176 |
+
evaluateTruthy: NodePath_evaluation.evaluateTruthy,
|
| 177 |
+
evaluate: NodePath_evaluation.evaluate,
|
| 178 |
+
toComputedKey: NodePath_conversion.toComputedKey,
|
| 179 |
+
ensureBlock: NodePath_conversion.ensureBlock,
|
| 180 |
+
unwrapFunctionEnvironment: NodePath_conversion.unwrapFunctionEnvironment,
|
| 181 |
+
arrowFunctionToExpression: NodePath_conversion.arrowFunctionToExpression,
|
| 182 |
+
splitExportDeclaration: NodePath_conversion.splitExportDeclaration,
|
| 183 |
+
ensureFunctionName: NodePath_conversion.ensureFunctionName,
|
| 184 |
+
matchesPattern: NodePath_introspection.matchesPattern,
|
| 185 |
+
isStatic: NodePath_introspection.isStatic,
|
| 186 |
+
isNodeType: NodePath_introspection.isNodeType,
|
| 187 |
+
canHaveVariableDeclarationOrExpression: NodePath_introspection.canHaveVariableDeclarationOrExpression,
|
| 188 |
+
canSwapBetweenExpressionAndStatement: NodePath_introspection.canSwapBetweenExpressionAndStatement,
|
| 189 |
+
isCompletionRecord: NodePath_introspection.isCompletionRecord,
|
| 190 |
+
isStatementOrBlock: NodePath_introspection.isStatementOrBlock,
|
| 191 |
+
referencesImport: NodePath_introspection.referencesImport,
|
| 192 |
+
getSource: NodePath_introspection.getSource,
|
| 193 |
+
willIMaybeExecuteBefore: NodePath_introspection.willIMaybeExecuteBefore,
|
| 194 |
+
_guessExecutionStatusRelativeTo: NodePath_introspection._guessExecutionStatusRelativeTo,
|
| 195 |
+
resolve: NodePath_introspection.resolve,
|
| 196 |
+
isConstantExpression: NodePath_introspection.isConstantExpression,
|
| 197 |
+
isInStrictMode: NodePath_introspection.isInStrictMode,
|
| 198 |
+
isDenylisted: NodePath_context.isDenylisted,
|
| 199 |
+
visit: NodePath_context.visit,
|
| 200 |
+
skip: NodePath_context.skip,
|
| 201 |
+
skipKey: NodePath_context.skipKey,
|
| 202 |
+
stop: NodePath_context.stop,
|
| 203 |
+
setContext: NodePath_context.setContext,
|
| 204 |
+
requeue: NodePath_context.requeue,
|
| 205 |
+
requeueComputedKeyAndDecorators: NodePath_context.requeueComputedKeyAndDecorators,
|
| 206 |
+
remove: NodePath_removal.remove,
|
| 207 |
+
insertBefore: NodePath_modification.insertBefore,
|
| 208 |
+
insertAfter: NodePath_modification.insertAfter,
|
| 209 |
+
unshiftContainer: NodePath_modification.unshiftContainer,
|
| 210 |
+
pushContainer: NodePath_modification.pushContainer,
|
| 211 |
+
getOpposite: NodePath_family.getOpposite,
|
| 212 |
+
getCompletionRecords: NodePath_family.getCompletionRecords,
|
| 213 |
+
getSibling: NodePath_family.getSibling,
|
| 214 |
+
getPrevSibling: NodePath_family.getPrevSibling,
|
| 215 |
+
getNextSibling: NodePath_family.getNextSibling,
|
| 216 |
+
getAllNextSiblings: NodePath_family.getAllNextSiblings,
|
| 217 |
+
getAllPrevSiblings: NodePath_family.getAllPrevSiblings,
|
| 218 |
+
get: NodePath_family.get,
|
| 219 |
+
getAssignmentIdentifiers: NodePath_family.getAssignmentIdentifiers,
|
| 220 |
+
getBindingIdentifiers: NodePath_family.getBindingIdentifiers,
|
| 221 |
+
getOuterBindingIdentifiers: NodePath_family.getOuterBindingIdentifiers,
|
| 222 |
+
getBindingIdentifierPaths: NodePath_family.getBindingIdentifierPaths,
|
| 223 |
+
getOuterBindingIdentifierPaths: NodePath_family.getOuterBindingIdentifierPaths,
|
| 224 |
+
shareCommentsWithSiblings: NodePath_comments.shareCommentsWithSiblings,
|
| 225 |
+
addComment: NodePath_comments.addComment,
|
| 226 |
+
addComments: NodePath_comments.addComments
|
| 227 |
+
};
|
| 228 |
+
Object.assign(NodePath_Final.prototype, methods);
|
| 229 |
+
NodePath_Final.prototype.arrowFunctionToShadowed = NodePath_conversion[String("arrowFunctionToShadowed")];
|
| 230 |
+
Object.assign(NodePath_Final.prototype, {
|
| 231 |
+
has: NodePath_introspection[String("has")],
|
| 232 |
+
is: NodePath_introspection[String("is")],
|
| 233 |
+
isnt: NodePath_introspection[String("isnt")],
|
| 234 |
+
equals: NodePath_introspection[String("equals")],
|
| 235 |
+
hoist: NodePath_modification[String("hoist")],
|
| 236 |
+
updateSiblingKeys: NodePath_modification.updateSiblingKeys,
|
| 237 |
+
call: NodePath_context.call,
|
| 238 |
+
isBlacklisted: NodePath_context[String("isBlacklisted")],
|
| 239 |
+
setScope: NodePath_context.setScope,
|
| 240 |
+
resync: NodePath_context.resync,
|
| 241 |
+
popContext: NodePath_context.popContext,
|
| 242 |
+
pushContext: NodePath_context.pushContext,
|
| 243 |
+
setup: NodePath_context.setup,
|
| 244 |
+
setKey: NodePath_context.setKey
|
| 245 |
+
});
|
| 246 |
+
NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo;
|
| 247 |
+
NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo;
|
| 248 |
+
Object.assign(NodePath_Final.prototype, {
|
| 249 |
+
_getTypeAnnotation: NodePath_inference._getTypeAnnotation,
|
| 250 |
+
_replaceWith: NodePath_replacement._replaceWith,
|
| 251 |
+
_resolve: NodePath_introspection._resolve,
|
| 252 |
+
_call: NodePath_context._call,
|
| 253 |
+
_resyncParent: NodePath_context._resyncParent,
|
| 254 |
+
_resyncKey: NodePath_context._resyncKey,
|
| 255 |
+
_resyncList: NodePath_context._resyncList,
|
| 256 |
+
_resyncRemoved: NodePath_context._resyncRemoved,
|
| 257 |
+
_getQueueContexts: NodePath_context._getQueueContexts,
|
| 258 |
+
_removeFromScope: NodePath_removal._removeFromScope,
|
| 259 |
+
_callRemovalHooks: NodePath_removal._callRemovalHooks,
|
| 260 |
+
_remove: NodePath_removal._remove,
|
| 261 |
+
_markRemoved: NodePath_removal._markRemoved,
|
| 262 |
+
_assertUnremoved: NodePath_removal._assertUnremoved,
|
| 263 |
+
_containerInsert: NodePath_modification._containerInsert,
|
| 264 |
+
_containerInsertBefore: NodePath_modification._containerInsertBefore,
|
| 265 |
+
_containerInsertAfter: NodePath_modification._containerInsertAfter,
|
| 266 |
+
_verifyNodeList: NodePath_modification._verifyNodeList,
|
| 267 |
+
_getKey: NodePath_family._getKey,
|
| 268 |
+
_getPattern: NodePath_family._getPattern
|
| 269 |
+
});
|
| 270 |
+
for (const type of t.TYPES) {
|
| 271 |
+
const typeKey = `is${type}`;
|
| 272 |
+
const fn = t[typeKey];
|
| 273 |
+
NodePath_Final.prototype[typeKey] = function (opts) {
|
| 274 |
+
return fn(this.node, opts);
|
| 275 |
+
};
|
| 276 |
+
NodePath_Final.prototype[`assert${type}`] = function (opts) {
|
| 277 |
+
if (!fn(this.node, opts)) {
|
| 278 |
+
throw new TypeError(`Expected node path of type ${type}`);
|
| 279 |
+
}
|
| 280 |
+
};
|
| 281 |
+
}
|
| 282 |
+
Object.assign(NodePath_Final.prototype, NodePath_virtual_types_validator);
|
| 283 |
+
for (const type of Object.keys(virtualTypes)) {
|
| 284 |
+
if (type.startsWith("_")) continue;
|
| 285 |
+
if (!t.TYPES.includes(type)) t.TYPES.push(type);
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@babel/traverse/lib/path/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["virtualTypes","require","_debug","_index","_index2","_t","t","cache","_generator","NodePath_ancestry","NodePath_inference","NodePath_replacement","NodePath_evaluation","NodePath_conversion","NodePath_introspection","_context","NodePath_context","NodePath_removal","NodePath_modification","NodePath_family","NodePath_comments","NodePath_virtual_types_validator","validate","debug","buildDebug","REMOVED","exports","SHOULD_STOP","SHOULD_SKIP","NodePath_Final","default","NodePath","constructor","hub","parent","contexts","state","_traverseFlags","skipKeys","parentPath","container","listKey","key","node","type","_store","data","context","scope","removed","v","shouldStop","shouldSkip","get","Error","targetNode","paths","getOrCreateCachedPaths","path","set","setup","call","getScope","isScope","Scope","setData","val","Object","create","getData","def","undefined","hasNode","buildCodeFrameError","msg","SyntaxError","buildError","traverse","visitor","getPathLocation","parts","inList","unshift","join","message","enabled","toString","generator","code","parentKey","methods","findParent","find","getFunctionParent","getStatementParent","getEarliestCommonAncestorFrom","getDeepestCommonAncestorFrom","getAncestry","isAncestor","isDescendant","inType","getTypeAnnotation","isBaseType","couldBeBaseType","baseTypeStrictlyMatches","isGenericType","replaceWithMultiple","replaceWithSourceString","replaceWith","replaceExpressionWithStatements","replaceInline","evaluateTruthy","evaluate","toComputedKey","ensureBlock","unwrapFunctionEnvironment","arrowFunctionToExpression","splitExportDeclaration","ensureFunctionName","matchesPattern","isStatic","isNodeType","canHaveVariableDeclarationOrExpression","canSwapBetweenExpressionAndStatement","isCompletionRecord","isStatementOrBlock","referencesImport","getSource","willIMaybeExecuteBefore","_guessExecutionStatusRelativeTo","resolve","isConstantExpression","isInStrictMode","isDenylisted","visit","skip","skipKey","stop","setContext","requeue","requeueComputedKeyAndDecorators","remove","insertBefore","insertAfter","unshiftContainer","pushContainer","getOpposite","getCompletionRecords","getSibling","getPrevSibling","getNextSibling","getAllNextSiblings","getAllPrevSiblings","getAssignmentIdentifiers","getBindingIdentifiers","getOuterBindingIdentifiers","getBindingIdentifierPaths","getOuterBindingIdentifierPaths","shareCommentsWithSiblings","addComment","addComments","assign","prototype","arrowFunctionToShadowed","String","has","is","isnt","equals","hoist","updateSiblingKeys","isBlacklisted","setScope","resync","popContext","pushContext","setKey","_guessExecutionStatusRelativeToDifferentFunctions","_getTypeAnnotation","_replaceWith","_resolve","_call","_resyncParent","_resyncKey","_resyncList","_resyncRemoved","_getQueueContexts","_removeFromScope","_callRemovalHooks","_remove","_markRemoved","_assertUnremoved","_containerInsert","_containerInsertBefore","_containerInsertAfter","_verifyNodeList","_getKey","_getPattern","TYPES","typeKey","fn","opts","TypeError","keys","startsWith","includes","push"],"sources":["../../src/path/index.ts"],"sourcesContent":["import type { HubInterface } from \"../hub.ts\";\nimport type TraversalContext from \"../context.ts\";\nimport type { ExplodedTraverseOptions } from \"../index.ts\";\nimport * as virtualTypes from \"./lib/virtual-types.ts\";\nimport buildDebug from \"debug\";\nimport traverse from \"../index.ts\";\nimport type { Visitor } from \"../types.ts\";\nimport Scope from \"../scope/index.ts\";\nimport { validate } from \"@babel/types\";\nimport * as t from \"@babel/types\";\nimport * as cache from \"../cache.ts\";\nimport generator from \"@babel/generator\";\n\n// NodePath is split across many files.\nimport * as NodePath_ancestry from \"./ancestry.ts\";\nimport * as NodePath_inference from \"./inference/index.ts\";\nimport * as NodePath_replacement from \"./replacement.ts\";\nimport * as NodePath_evaluation from \"./evaluation.ts\";\nimport * as NodePath_conversion from \"./conversion.ts\";\nimport * as NodePath_introspection from \"./introspection.ts\";\nimport * as NodePath_context from \"./context.ts\";\nimport * as NodePath_removal from \"./removal.ts\";\nimport * as NodePath_modification from \"./modification.ts\";\nimport * as NodePath_family from \"./family.ts\";\nimport * as NodePath_comments from \"./comments.ts\";\nimport * as NodePath_virtual_types_validator from \"./lib/virtual-types-validator.ts\";\nimport type { NodePathAssertions } from \"./generated/asserts.ts\";\nimport type { NodePathValidators } from \"./generated/validators.ts\";\nimport { setup } from \"./context.ts\";\n\nconst debug = buildDebug(\"babel\");\n\nexport const REMOVED = 1 << 0;\nexport const SHOULD_STOP = 1 << 1;\nexport const SHOULD_SKIP = 1 << 2;\n\ndeclare const bit: import(\"../../../../scripts/babel-plugin-bit-decorator/types.d.ts\").BitDecorator<\n NodePath_Final<t.Node>\n>;\n\nexport type NodePaths<T extends t.Node | t.Node[]> = T extends t.Node[]\n ? { [K in keyof T]: NodePath_Final<Extract<T[K], t.Node>> }\n : T extends t.Node\n ? [NodePath_Final<T>]\n : never;\n\nexport type NodeListType<N, K extends keyof N> = N[K] extends (infer P extends\n t.Node)[]\n ? P\n : never;\n\nexport type NodeOrNodeList<T extends t.Node> = T | NodeList<T>;\n\nexport type NodeList<T extends t.Node> = T[] | [T, ...T[]];\n\nconst NodePath_Final = class NodePath {\n constructor(hub: HubInterface | undefined, parent: t.Node) {\n this.parent = parent;\n this.hub = hub!;\n this.data = null;\n\n // @ts-expect-error Set it in setContext\n this.context = null;\n // @ts-expect-error Set it in setContext\n this.scope = null;\n }\n\n declare parent: t.Node;\n declare hub: HubInterface;\n declare data: Record<string | symbol, unknown> | null;\n // TraversalContext is configured by setContext\n declare context: TraversalContext;\n declare scope: Scope;\n\n contexts: TraversalContext[] = [];\n state: any = null;\n declare opts: ExplodedTraverseOptions;\n\n @bit.storage _traverseFlags: number = 0;\n @bit(REMOVED) accessor removed = false;\n @bit(SHOULD_STOP) accessor shouldStop = false;\n @bit(SHOULD_SKIP) accessor shouldSkip = false;\n\n skipKeys: Record<string, boolean> | null = null;\n parentPath: NodePath_Final | null = null;\n container: t.Node | t.Node[] | null = null;\n listKey: string | null | undefined = null;\n key: string | number | null = null;\n node: t.Node | null = null;\n type: t.Node[\"type\"] | null = null;\n _store: Map<t.Node, NodePath_Final> | null = null;\n\n static get({\n hub,\n parentPath,\n parent,\n container,\n listKey,\n key,\n }: {\n hub?: HubInterface;\n parentPath: NodePath_Final | null | undefined;\n parent: t.Node;\n container: t.Node | t.Node[];\n listKey?: string | null;\n key: string | number;\n }): NodePath_Final {\n if (!hub && parentPath) {\n hub = parentPath.hub;\n }\n\n if (!parent) {\n throw new Error(\"To get a node path the parent needs to exist\");\n }\n\n const targetNode =\n // @ts-expect-error key must present in container\n container[key];\n\n const paths = cache.getOrCreateCachedPaths(parent, parentPath);\n\n let path = paths.get(targetNode);\n if (!path) {\n path = new NodePath(hub, parent) as NodePath_Final;\n if (targetNode) paths.set(targetNode, path);\n }\n\n setup.call(path, parentPath, container, listKey, key);\n\n return path;\n }\n\n getScope(this: NodePath_Final, scope: Scope): Scope {\n return this.isScope() ? new Scope(this) : scope;\n }\n\n setData<T>(key: string | symbol, val: T): T {\n if (this.data == null) {\n this.data = Object.create(null);\n }\n return (this.data![key] = val);\n }\n\n getData(key: string | symbol, def?: any): any {\n if (this.data == null) {\n this.data = Object.create(null);\n }\n let val = this.data![key];\n if (val === undefined && def !== undefined) val = this.data![key] = def;\n return val;\n }\n\n hasNode(): boolean {\n return this.node != null;\n }\n\n buildCodeFrameError(\n msg: string,\n Error: new () => Error = SyntaxError,\n ): Error {\n return this.hub.buildError(this.node!, msg, Error);\n }\n\n traverse<T>(this: NodePath_Final, visitor: Visitor<T>, state: T): void;\n traverse(this: NodePath_Final, visitor: Visitor): void;\n traverse(this: NodePath_Final, visitor: any, state?: any) {\n traverse(this.node, visitor, this.scope, state, this);\n }\n\n set(key: string, node: any) {\n validate(this.node, key, node);\n // @ts-expect-error key must present in this.node\n this.node[key] = node;\n }\n\n getPathLocation(this: NodePath_Final): string {\n const parts = [];\n let path: NodePath_Final = this;\n do {\n let key = path.key;\n if (path.inList) key = `${path.listKey}[${key}]`;\n parts.unshift(key);\n } while ((path = path.parentPath));\n return parts.join(\".\");\n }\n\n debug(this: NodePath_Final, message: string) {\n if (!debug.enabled) return;\n debug(`${this.getPathLocation()} ${this.type}: ${message}`);\n }\n\n toString() {\n return generator(this.node!).code;\n }\n\n get inList() {\n return !!this.listKey;\n }\n\n set inList(inList) {\n if (!inList) {\n this.listKey = null;\n }\n // ignore inList = true as it should depend on `listKey`\n }\n\n get parentKey(): string {\n return (this.listKey || this.key) as string;\n }\n};\n\nconst methods = {\n // NodePath_ancestry\n findParent: NodePath_ancestry.findParent,\n find: NodePath_ancestry.find,\n getFunctionParent: NodePath_ancestry.getFunctionParent,\n getStatementParent: NodePath_ancestry.getStatementParent,\n getEarliestCommonAncestorFrom:\n NodePath_ancestry.getEarliestCommonAncestorFrom,\n getDeepestCommonAncestorFrom: NodePath_ancestry.getDeepestCommonAncestorFrom,\n getAncestry: NodePath_ancestry.getAncestry,\n isAncestor: NodePath_ancestry.isAncestor,\n isDescendant: NodePath_ancestry.isDescendant,\n inType: NodePath_ancestry.inType,\n\n // NodePath_inference\n getTypeAnnotation: NodePath_inference.getTypeAnnotation,\n isBaseType: NodePath_inference.isBaseType,\n couldBeBaseType: NodePath_inference.couldBeBaseType,\n baseTypeStrictlyMatches: NodePath_inference.baseTypeStrictlyMatches,\n isGenericType: NodePath_inference.isGenericType,\n\n // NodePath_replacement\n replaceWithMultiple: NodePath_replacement.replaceWithMultiple,\n replaceWithSourceString: NodePath_replacement.replaceWithSourceString,\n replaceWith: NodePath_replacement.replaceWith,\n replaceExpressionWithStatements:\n NodePath_replacement.replaceExpressionWithStatements,\n replaceInline: NodePath_replacement.replaceInline,\n\n // NodePath_evaluation\n evaluateTruthy: NodePath_evaluation.evaluateTruthy,\n evaluate: NodePath_evaluation.evaluate,\n\n // NodePath_conversion\n toComputedKey: NodePath_conversion.toComputedKey,\n ensureBlock: NodePath_conversion.ensureBlock,\n unwrapFunctionEnvironment: NodePath_conversion.unwrapFunctionEnvironment,\n arrowFunctionToExpression: NodePath_conversion.arrowFunctionToExpression,\n splitExportDeclaration: NodePath_conversion.splitExportDeclaration,\n ensureFunctionName: NodePath_conversion.ensureFunctionName,\n\n // NodePath_introspection\n matchesPattern: NodePath_introspection.matchesPattern,\n isStatic: NodePath_introspection.isStatic,\n isNodeType: NodePath_introspection.isNodeType,\n canHaveVariableDeclarationOrExpression:\n NodePath_introspection.canHaveVariableDeclarationOrExpression,\n canSwapBetweenExpressionAndStatement:\n NodePath_introspection.canSwapBetweenExpressionAndStatement,\n isCompletionRecord: NodePath_introspection.isCompletionRecord,\n isStatementOrBlock: NodePath_introspection.isStatementOrBlock,\n referencesImport: NodePath_introspection.referencesImport,\n getSource: NodePath_introspection.getSource,\n willIMaybeExecuteBefore: NodePath_introspection.willIMaybeExecuteBefore,\n _guessExecutionStatusRelativeTo:\n NodePath_introspection._guessExecutionStatusRelativeTo,\n resolve: NodePath_introspection.resolve,\n isConstantExpression: NodePath_introspection.isConstantExpression,\n isInStrictMode: NodePath_introspection.isInStrictMode,\n\n // NodePath_context\n isDenylisted: NodePath_context.isDenylisted,\n visit: NodePath_context.visit,\n skip: NodePath_context.skip,\n skipKey: NodePath_context.skipKey,\n stop: NodePath_context.stop,\n setContext: NodePath_context.setContext,\n requeue: NodePath_context.requeue,\n requeueComputedKeyAndDecorators:\n NodePath_context.requeueComputedKeyAndDecorators,\n\n // NodePath_removal\n remove: NodePath_removal.remove,\n\n // NodePath_modification\n insertBefore: NodePath_modification.insertBefore,\n insertAfter: NodePath_modification.insertAfter,\n unshiftContainer: NodePath_modification.unshiftContainer,\n pushContainer: NodePath_modification.pushContainer,\n\n // NodePath_family\n getOpposite: NodePath_family.getOpposite,\n getCompletionRecords: NodePath_family.getCompletionRecords,\n getSibling: NodePath_family.getSibling,\n getPrevSibling: NodePath_family.getPrevSibling,\n getNextSibling: NodePath_family.getNextSibling,\n getAllNextSiblings: NodePath_family.getAllNextSiblings,\n getAllPrevSiblings: NodePath_family.getAllPrevSiblings,\n get: NodePath_family.get,\n getAssignmentIdentifiers: NodePath_family.getAssignmentIdentifiers,\n getBindingIdentifiers: NodePath_family.getBindingIdentifiers,\n getOuterBindingIdentifiers: NodePath_family.getOuterBindingIdentifiers,\n getBindingIdentifierPaths: NodePath_family.getBindingIdentifierPaths,\n getOuterBindingIdentifierPaths:\n NodePath_family.getOuterBindingIdentifierPaths,\n\n // NodePath_comments\n shareCommentsWithSiblings: NodePath_comments.shareCommentsWithSiblings,\n addComment: NodePath_comments.addComment,\n addComments: NodePath_comments.addComments,\n};\n\nObject.assign(NodePath_Final.prototype, methods);\n\nif (!process.env.BABEL_8_BREAKING && !USE_ESM) {\n // String(x) is workaround for rollup\n\n // @ts-expect-error babel 7 only\n NodePath_Final.prototype.arrowFunctionToShadowed =\n // @ts-expect-error babel 7 only\n NodePath_conversion[String(\"arrowFunctionToShadowed\")];\n\n Object.assign(NodePath_Final.prototype, {\n // @ts-expect-error Babel 7 only\n has: NodePath_introspection[String(\"has\")],\n // @ts-expect-error Babel 7 only\n is: NodePath_introspection[String(\"is\")],\n // @ts-expect-error Babel 7 only\n isnt: NodePath_introspection[String(\"isnt\")],\n // @ts-expect-error Babel 7 only\n equals: NodePath_introspection[String(\"equals\")],\n // @ts-expect-error Babel 7 only\n hoist: NodePath_modification[String(\"hoist\")],\n updateSiblingKeys: NodePath_modification.updateSiblingKeys,\n call: NodePath_context.call,\n // @ts-expect-error Babel 7 only\n isBlacklisted: NodePath_context[String(\"isBlacklisted\")],\n setScope: NodePath_context.setScope,\n resync: NodePath_context.resync,\n popContext: NodePath_context.popContext,\n pushContext: NodePath_context.pushContext,\n setup: NodePath_context.setup,\n setKey: NodePath_context.setKey,\n });\n}\n\nif (!process.env.BABEL_8_BREAKING) {\n // @ts-expect-error The original _guessExecutionStatusRelativeToDifferentFunctions only worked for paths in\n // different functions, but _guessExecutionStatusRelativeTo works as a replacement in those cases.\n NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions =\n NodePath_introspection._guessExecutionStatusRelativeTo;\n\n // @ts-expect-error The original _guessExecutionStatusRelativeToDifferentFunctions only worked for paths in\n // different functions, but _guessExecutionStatusRelativeTo works as a replacement in those cases.\n NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions =\n NodePath_introspection._guessExecutionStatusRelativeTo;\n\n Object.assign(NodePath_Final.prototype, {\n // NodePath_inference\n _getTypeAnnotation: NodePath_inference._getTypeAnnotation,\n\n // NodePath_replacement\n _replaceWith: NodePath_replacement._replaceWith,\n\n // NodePath_introspection\n _resolve: NodePath_introspection._resolve,\n\n // NodePath_context\n _call: NodePath_context._call,\n _resyncParent: NodePath_context._resyncParent,\n _resyncKey: NodePath_context._resyncKey,\n _resyncList: NodePath_context._resyncList,\n _resyncRemoved: NodePath_context._resyncRemoved,\n _getQueueContexts: NodePath_context._getQueueContexts,\n\n // NodePath_removal\n _removeFromScope: NodePath_removal._removeFromScope,\n _callRemovalHooks: NodePath_removal._callRemovalHooks,\n _remove: NodePath_removal._remove,\n _markRemoved: NodePath_removal._markRemoved,\n _assertUnremoved: NodePath_removal._assertUnremoved,\n\n // NodePath_modification\n _containerInsert: NodePath_modification._containerInsert,\n _containerInsertBefore: NodePath_modification._containerInsertBefore,\n _containerInsertAfter: NodePath_modification._containerInsertAfter,\n _verifyNodeList: NodePath_modification._verifyNodeList,\n\n // NodePath_family\n _getKey: NodePath_family._getKey,\n _getPattern: NodePath_family._getPattern,\n });\n}\n\n// we can not use `import { TYPES } from \"@babel/types\"` here\n// because the transformNamedBabelTypesImportToDestructuring plugin in babel.config.js\n// does not offer live bindings for `TYPES`\n// we can change to `import { TYPES }` when we are publishing ES modules only\nfor (const type of t.TYPES) {\n const typeKey = `is${type}`;\n // @ts-expect-error typeKey must present in t\n const fn = t[typeKey];\n // @ts-expect-error augmenting NodePath prototype\n NodePath_Final.prototype[typeKey] = function (opts: any) {\n return fn(this.node, opts);\n };\n\n // @ts-expect-error augmenting NodePath prototype\n NodePath_Final.prototype[`assert${type}`] = function (opts: any) {\n if (!fn(this.node, opts)) {\n throw new TypeError(`Expected node path of type ${type}`);\n }\n };\n}\n\n// Register virtual types validators after base types validators\nObject.assign(NodePath_Final.prototype, NodePath_virtual_types_validator);\n\nfor (const type of Object.keys(virtualTypes) as (keyof typeof virtualTypes)[]) {\n if (type.startsWith(\"_\")) continue;\n if (!t.TYPES.includes(type)) t.TYPES.push(type);\n}\n\ninterface NodePathOverwrites {\n // We need to re-define these predicate and assertion\n // methods here, because we cannot refine `this` in\n // a function declaration.\n // See https://github.com/microsoft/TypeScript/issues/38150\n\n /**\n * NOTE: This assertion doesn't narrow the type on unions of\n * NodePaths, due to https://github.com/microsoft/TypeScript/issues/44212\n *\n * @see ./conversion.ts for implementation.\n */\n ensureBlock(\n this: NodePath_Final,\n ): asserts this is NodePath_Final<\n (\n | t.Loop\n | t.WithStatement\n | t.Function\n | t.LabeledStatement\n | t.CatchClause\n ) & { body: t.BlockStatement }\n >;\n /**\n * @see ./introspection.ts for implementation.\n */\n isStatementOrBlock(\n this: NodePath_Final,\n ): this is NodePath_Final<t.Statement | t.Block>;\n}\n\ntype NodePathMixins = Omit<typeof methods, keyof NodePathOverwrites>;\n\ninterface NodePath<\n N extends t.Node | null,\n T extends t.Node[\"type\"] | null = N extends null\n ? null\n : NonNullable<N>[\"type\"],\n P extends t.Node = NonNullable<t.ParentMaps[NonNullable<T>]>,\n> extends InstanceType<typeof NodePath_Final>,\n NodePathAssertions,\n NodePathValidators,\n NodePathMixins,\n NodePathOverwrites {\n type: T;\n node: N;\n // .parent is only null for File nodes, which are not traversed by @babel/traverse\n // You can technically create a path that contains one, but it's so rare that\n // we can ignore it to avoid having non-null assertions everywhere.\n parent: P;\n parentPath: NodePath_Final<P>;\n}\n\n// This trick is necessary so that\n// NodePath_Final<A | B> is the same as NodePath_Final<A> | NodePath_Final<B>\ntype NodePath_Final<T extends t.Node | null = t.Node> = T extends any\n ? NodePath<T>\n : never;\n\nexport { NodePath_Final as default, type NodePath as NodePath_Internal };\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,EAAA,GAAAJ,OAAA;AAAwC,IAAAK,CAAA,GAAAD,EAAA;AAExC,IAAAE,KAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAGA,IAAAQ,iBAAA,GAAAR,OAAA;AACA,IAAAS,kBAAA,GAAAT,OAAA;AACA,IAAAU,oBAAA,GAAAV,OAAA;AACA,IAAAW,mBAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAZ,OAAA;AACA,IAAAa,sBAAA,GAAAb,OAAA;AACA,IAAAc,QAAA,GAAAd,OAAA;AAAiD,IAAAe,gBAAA,GAAAD,QAAA;AACjD,IAAAE,gBAAA,GAAAhB,OAAA;AACA,IAAAiB,qBAAA,GAAAjB,OAAA;AACA,IAAAkB,eAAA,GAAAlB,OAAA;AACA,IAAAmB,iBAAA,GAAAnB,OAAA;AACA,IAAAoB,gCAAA,GAAApB,OAAA;AAAqF;EAjB5EqB;AAAQ,IAAAjB,EAAA;AAsBjB,MAAMkB,KAAK,GA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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports._getTypeAnnotation = _getTypeAnnotation;
|
| 7 |
+
exports.baseTypeStrictlyMatches = baseTypeStrictlyMatches;
|
| 8 |
+
exports.couldBeBaseType = couldBeBaseType;
|
| 9 |
+
exports.getTypeAnnotation = getTypeAnnotation;
|
| 10 |
+
exports.isBaseType = isBaseType;
|
| 11 |
+
exports.isGenericType = isGenericType;
|
| 12 |
+
var inferers = require("./inferers.js");
|
| 13 |
+
var _t = require("@babel/types");
|
| 14 |
+
const {
|
| 15 |
+
anyTypeAnnotation,
|
| 16 |
+
isAnyTypeAnnotation,
|
| 17 |
+
isArrayTypeAnnotation,
|
| 18 |
+
isBooleanTypeAnnotation,
|
| 19 |
+
isEmptyTypeAnnotation,
|
| 20 |
+
isFlowBaseAnnotation,
|
| 21 |
+
isGenericTypeAnnotation,
|
| 22 |
+
isIdentifier,
|
| 23 |
+
isMixedTypeAnnotation,
|
| 24 |
+
isNumberTypeAnnotation,
|
| 25 |
+
isStringTypeAnnotation,
|
| 26 |
+
isTSArrayType,
|
| 27 |
+
isTSTypeAnnotation,
|
| 28 |
+
isTSTypeReference,
|
| 29 |
+
isTupleTypeAnnotation,
|
| 30 |
+
isTypeAnnotation,
|
| 31 |
+
isUnionTypeAnnotation,
|
| 32 |
+
isVoidTypeAnnotation,
|
| 33 |
+
stringTypeAnnotation,
|
| 34 |
+
voidTypeAnnotation
|
| 35 |
+
} = _t;
|
| 36 |
+
function getTypeAnnotation() {
|
| 37 |
+
let type = this.getData("typeAnnotation");
|
| 38 |
+
if (type != null) {
|
| 39 |
+
return type;
|
| 40 |
+
}
|
| 41 |
+
type = _getTypeAnnotation.call(this) || anyTypeAnnotation();
|
| 42 |
+
if (isTypeAnnotation(type) || isTSTypeAnnotation(type)) {
|
| 43 |
+
type = type.typeAnnotation;
|
| 44 |
+
}
|
| 45 |
+
this.setData("typeAnnotation", type);
|
| 46 |
+
return type;
|
| 47 |
+
}
|
| 48 |
+
const typeAnnotationInferringNodes = new WeakSet();
|
| 49 |
+
function _getTypeAnnotation() {
|
| 50 |
+
const node = this.node;
|
| 51 |
+
if (!node) {
|
| 52 |
+
if (this.key === "init" && this.parentPath.isVariableDeclarator()) {
|
| 53 |
+
const declar = this.parentPath.parentPath;
|
| 54 |
+
const declarParent = declar.parentPath;
|
| 55 |
+
if (declar.key === "left" && declarParent.isForInStatement()) {
|
| 56 |
+
return stringTypeAnnotation();
|
| 57 |
+
}
|
| 58 |
+
if (declar.key === "left" && declarParent.isForOfStatement()) {
|
| 59 |
+
return anyTypeAnnotation();
|
| 60 |
+
}
|
| 61 |
+
return voidTypeAnnotation();
|
| 62 |
+
} else {
|
| 63 |
+
return;
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
if (node.typeAnnotation) {
|
| 67 |
+
return node.typeAnnotation;
|
| 68 |
+
}
|
| 69 |
+
if (typeAnnotationInferringNodes.has(node)) {
|
| 70 |
+
return;
|
| 71 |
+
}
|
| 72 |
+
typeAnnotationInferringNodes.add(node);
|
| 73 |
+
try {
|
| 74 |
+
var _inferer;
|
| 75 |
+
let inferer = inferers[node.type];
|
| 76 |
+
if (inferer) {
|
| 77 |
+
return inferer.call(this, node);
|
| 78 |
+
}
|
| 79 |
+
inferer = inferers[this.parentPath.type];
|
| 80 |
+
if ((_inferer = inferer) != null && _inferer.validParent) {
|
| 81 |
+
return this.parentPath.getTypeAnnotation();
|
| 82 |
+
}
|
| 83 |
+
} finally {
|
| 84 |
+
typeAnnotationInferringNodes.delete(node);
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
function isBaseType(baseName, soft) {
|
| 88 |
+
return _isBaseType(baseName, this.getTypeAnnotation(), soft);
|
| 89 |
+
}
|
| 90 |
+
function _isBaseType(baseName, type, soft) {
|
| 91 |
+
if (baseName === "string") {
|
| 92 |
+
return isStringTypeAnnotation(type);
|
| 93 |
+
} else if (baseName === "number") {
|
| 94 |
+
return isNumberTypeAnnotation(type);
|
| 95 |
+
} else if (baseName === "boolean") {
|
| 96 |
+
return isBooleanTypeAnnotation(type);
|
| 97 |
+
} else if (baseName === "any") {
|
| 98 |
+
return isAnyTypeAnnotation(type);
|
| 99 |
+
} else if (baseName === "mixed") {
|
| 100 |
+
return isMixedTypeAnnotation(type);
|
| 101 |
+
} else if (baseName === "empty") {
|
| 102 |
+
return isEmptyTypeAnnotation(type);
|
| 103 |
+
} else if (baseName === "void") {
|
| 104 |
+
return isVoidTypeAnnotation(type);
|
| 105 |
+
} else {
|
| 106 |
+
if (soft) {
|
| 107 |
+
return false;
|
| 108 |
+
} else {
|
| 109 |
+
throw new Error(`Unknown base type ${baseName}`);
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
function couldBeBaseType(name) {
|
| 114 |
+
const type = this.getTypeAnnotation();
|
| 115 |
+
if (isAnyTypeAnnotation(type)) return true;
|
| 116 |
+
if (isUnionTypeAnnotation(type)) {
|
| 117 |
+
for (const type2 of type.types) {
|
| 118 |
+
if (isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {
|
| 119 |
+
return true;
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
return false;
|
| 123 |
+
} else {
|
| 124 |
+
return _isBaseType(name, type, true);
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
function baseTypeStrictlyMatches(rightArg) {
|
| 128 |
+
const left = this.getTypeAnnotation();
|
| 129 |
+
const right = rightArg.getTypeAnnotation();
|
| 130 |
+
if (!isAnyTypeAnnotation(left) && isFlowBaseAnnotation(left)) {
|
| 131 |
+
return right.type === left.type;
|
| 132 |
+
}
|
| 133 |
+
return false;
|
| 134 |
+
}
|
| 135 |
+
function isGenericType(genericName) {
|
| 136 |
+
const type = this.getTypeAnnotation();
|
| 137 |
+
if (genericName === "Array") {
|
| 138 |
+
if (isTSArrayType(type) || isArrayTypeAnnotation(type) || isTupleTypeAnnotation(type)) {
|
| 139 |
+
return true;
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
return isGenericTypeAnnotation(type) && isIdentifier(type.id, {
|
| 143 |
+
name: genericName
|
| 144 |
+
}) || isTSTypeReference(type) && isIdentifier(type.typeName, {
|
| 145 |
+
name: genericName
|
| 146 |
+
});
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@babel/traverse/lib/path/inference/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["inferers","require","_t","anyTypeAnnotation","isAnyTypeAnnotation","isArrayTypeAnnotation","isBooleanTypeAnnotation","isEmptyTypeAnnotation","isFlowBaseAnnotation","isGenericTypeAnnotation","isIdentifier","isMixedTypeAnnotation","isNumberTypeAnnotation","isStringTypeAnnotation","isTSArrayType","isTSTypeAnnotation","isTSTypeReference","isTupleTypeAnnotation","isTypeAnnotation","isUnionTypeAnnotation","isVoidTypeAnnotation","stringTypeAnnotation","voidTypeAnnotation","getTypeAnnotation","type","getData","_getTypeAnnotation","call","typeAnnotation","setData","typeAnnotationInferringNodes","WeakSet","node","key","parentPath","isVariableDeclarator","declar","declarParent","isForInStatement","isForOfStatement","has","add","_inferer","inferer","validParent","delete","isBaseType","baseName","soft","_isBaseType","Error","couldBeBaseType","name","type2","types","baseTypeStrictlyMatches","rightArg","left","right","isGenericType","genericName","id","typeName"],"sources":["../../../src/path/inference/index.ts"],"sourcesContent":["import type NodePath from \"../index.ts\";\nimport * as inferers from \"./inferers.ts\";\nimport {\n anyTypeAnnotation,\n isAnyTypeAnnotation,\n isArrayTypeAnnotation,\n isBooleanTypeAnnotation,\n isEmptyTypeAnnotation,\n isFlowBaseAnnotation,\n isGenericTypeAnnotation,\n isIdentifier,\n isMixedTypeAnnotation,\n isNumberTypeAnnotation,\n isStringTypeAnnotation,\n isTSArrayType,\n isTSTypeAnnotation,\n isTSTypeReference,\n isTupleTypeAnnotation,\n isTypeAnnotation,\n isUnionTypeAnnotation,\n isVoidTypeAnnotation,\n stringTypeAnnotation,\n voidTypeAnnotation,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\n/**\n * Infer the type of the current `NodePath`.\n */\n\nexport function getTypeAnnotation(\n this: NodePath<t.Node | null>,\n): t.FlowType | t.TSType {\n let type = this.getData(\"typeAnnotation\");\n if (type != null) {\n return type;\n }\n type = _getTypeAnnotation.call(this) || anyTypeAnnotation();\n if (isTypeAnnotation(type) || isTSTypeAnnotation(type)) {\n type = type.typeAnnotation;\n }\n this.setData(\"typeAnnotation\", type);\n return type;\n}\n\n// Used to avoid infinite recursion in cases like\n// var b, c; if (0) { c = 1; b = c; } c = b;\n// It also works with indirect recursion.\nconst typeAnnotationInferringNodes = new WeakSet();\n\n/**\n * todo: split up this method\n */\n\nexport function _getTypeAnnotation(this: NodePath): any {\n const node = this.node;\n\n if (!node) {\n // handle initializerless variables, add in checks for loop initializers too\n if (this.key === \"init\" && this.parentPath.isVariableDeclarator()) {\n const declar = this.parentPath.parentPath;\n const declarParent = declar.parentPath;\n\n // for (let NODE in bar) {}\n if (declar.key === \"left\" && declarParent.isForInStatement()) {\n return stringTypeAnnotation();\n }\n\n // for (let NODE of bar) {}\n if (declar.key === \"left\" && declarParent.isForOfStatement()) {\n return anyTypeAnnotation();\n }\n\n return voidTypeAnnotation();\n } else {\n return;\n }\n }\n\n // @ts-expect-error typeAnnotation may not index node\n if (node.typeAnnotation) {\n // @ts-expect-error typeAnnotation may not index node\n return node.typeAnnotation;\n }\n\n if (typeAnnotationInferringNodes.has(node)) {\n // Bail out from type inference to avoid infinite loops\n return;\n }\n typeAnnotationInferringNodes.add(node);\n\n try {\n let inferer =\n // @ts-expect-error inferers do not cover all AST types\n inferers[node.type];\n if (inferer) {\n return inferer.call(this, node);\n }\n\n // @ts-expect-error inferers do not cover all AST types\n inferer = inferers[this.parentPath.type];\n if (inferer?.validParent) {\n return this.parentPath.getTypeAnnotation();\n }\n } finally {\n typeAnnotationInferringNodes.delete(node);\n }\n}\n\nexport function isBaseType(\n this: NodePath,\n baseName: string,\n soft?: boolean,\n): boolean {\n return _isBaseType(baseName, this.getTypeAnnotation(), soft);\n}\n\nfunction _isBaseType(\n baseName: string,\n type?: t.FlowType | t.TSType,\n soft?: boolean,\n): boolean {\n if (baseName === \"string\") {\n return isStringTypeAnnotation(type);\n } else if (baseName === \"number\") {\n return isNumberTypeAnnotation(type);\n } else if (baseName === \"boolean\") {\n return isBooleanTypeAnnotation(type);\n } else if (baseName === \"any\") {\n return isAnyTypeAnnotation(type);\n } else if (baseName === \"mixed\") {\n return isMixedTypeAnnotation(type);\n } else if (baseName === \"empty\") {\n return isEmptyTypeAnnotation(type);\n } else if (baseName === \"void\") {\n return isVoidTypeAnnotation(type);\n } else {\n if (soft) {\n return false;\n } else {\n throw new Error(`Unknown base type ${baseName}`);\n }\n }\n}\n\nexport function couldBeBaseType(this: NodePath, name: string): boolean {\n const type = this.getTypeAnnotation();\n if (isAnyTypeAnnotation(type)) return true;\n\n if (isUnionTypeAnnotation(type)) {\n for (const type2 of type.types) {\n if (isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {\n return true;\n }\n }\n return false;\n } else {\n return _isBaseType(name, type, true);\n }\n}\n\nexport function baseTypeStrictlyMatches(\n this: NodePath,\n rightArg: NodePath,\n): boolean {\n const left = this.getTypeAnnotation();\n const right = rightArg.getTypeAnnotation();\n\n if (!isAnyTypeAnnotation(left) && isFlowBaseAnnotation(left)) {\n return right.type === left.type;\n }\n return false;\n}\n\nexport function isGenericType(this: NodePath, genericName: string): boolean {\n const type = this.getTypeAnnotation();\n if (genericName === \"Array\") {\n // T[]\n if (\n isTSArrayType(type) ||\n isArrayTypeAnnotation(type) ||\n isTupleTypeAnnotation(type)\n ) {\n return true;\n }\n }\n return (\n (isGenericTypeAnnotation(type) &&\n isIdentifier(type.id, {\n name: genericName,\n })) ||\n (isTSTypeReference(type) &&\n isIdentifier(type.typeName, {\n name: genericName,\n }))\n );\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,EAAA,GAAAD,OAAA;AAqBsB;EApBpBE,iBAAiB;EACjBC,mBAAmB;EACnBC,qBAAqB;EACrBC,uBAAuB;EACvBC,q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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = _default;
|
| 7 |
+
var _t = require("@babel/types");
|
| 8 |
+
var _util = require("./util.js");
|
| 9 |
+
const {
|
| 10 |
+
BOOLEAN_NUMBER_BINARY_OPERATORS,
|
| 11 |
+
createTypeAnnotationBasedOnTypeof,
|
| 12 |
+
numberTypeAnnotation,
|
| 13 |
+
voidTypeAnnotation
|
| 14 |
+
} = _t;
|
| 15 |
+
function _default(node) {
|
| 16 |
+
if (!this.isReferenced()) return;
|
| 17 |
+
const binding = this.scope.getBinding(node.name);
|
| 18 |
+
if (binding) {
|
| 19 |
+
if (binding.identifier.typeAnnotation) {
|
| 20 |
+
return binding.identifier.typeAnnotation;
|
| 21 |
+
} else {
|
| 22 |
+
return getTypeAnnotationBindingConstantViolations(binding, this, node.name);
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
if (node.name === "undefined") {
|
| 26 |
+
return voidTypeAnnotation();
|
| 27 |
+
} else if (node.name === "NaN" || node.name === "Infinity") {
|
| 28 |
+
return numberTypeAnnotation();
|
| 29 |
+
} else if (node.name === "arguments") {}
|
| 30 |
+
}
|
| 31 |
+
function getTypeAnnotationBindingConstantViolations(binding, path, name) {
|
| 32 |
+
const types = [];
|
| 33 |
+
const functionConstantViolations = [];
|
| 34 |
+
let constantViolations = getConstantViolationsBefore(binding, path, functionConstantViolations);
|
| 35 |
+
const testType = getConditionalAnnotation(binding, path, name);
|
| 36 |
+
if (testType) {
|
| 37 |
+
const testConstantViolations = getConstantViolationsBefore(binding, testType.ifStatement);
|
| 38 |
+
constantViolations = constantViolations.filter(path => !testConstantViolations.includes(path));
|
| 39 |
+
types.push(testType.typeAnnotation);
|
| 40 |
+
}
|
| 41 |
+
if (constantViolations.length) {
|
| 42 |
+
constantViolations.push(...functionConstantViolations);
|
| 43 |
+
for (const violation of constantViolations) {
|
| 44 |
+
types.push(violation.getTypeAnnotation());
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
if (!types.length) {
|
| 48 |
+
return;
|
| 49 |
+
}
|
| 50 |
+
return (0, _util.createUnionType)(types);
|
| 51 |
+
}
|
| 52 |
+
function getConstantViolationsBefore(binding, path, functions) {
|
| 53 |
+
const violations = binding.constantViolations.slice();
|
| 54 |
+
violations.unshift(binding.path);
|
| 55 |
+
return violations.filter(violation => {
|
| 56 |
+
violation = violation.resolve();
|
| 57 |
+
const status = violation._guessExecutionStatusRelativeTo(path);
|
| 58 |
+
if (functions && status === "unknown") functions.push(violation);
|
| 59 |
+
return status === "before";
|
| 60 |
+
});
|
| 61 |
+
}
|
| 62 |
+
function inferAnnotationFromBinaryExpression(name, path) {
|
| 63 |
+
const operator = path.node.operator;
|
| 64 |
+
const right = path.get("right").resolve();
|
| 65 |
+
const left = path.get("left").resolve();
|
| 66 |
+
let target;
|
| 67 |
+
if (left.isIdentifier({
|
| 68 |
+
name
|
| 69 |
+
})) {
|
| 70 |
+
target = right;
|
| 71 |
+
} else if (right.isIdentifier({
|
| 72 |
+
name
|
| 73 |
+
})) {
|
| 74 |
+
target = left;
|
| 75 |
+
}
|
| 76 |
+
if (target) {
|
| 77 |
+
if (operator === "===") {
|
| 78 |
+
return target.getTypeAnnotation();
|
| 79 |
+
}
|
| 80 |
+
if (BOOLEAN_NUMBER_BINARY_OPERATORS.includes(operator)) {
|
| 81 |
+
return numberTypeAnnotation();
|
| 82 |
+
}
|
| 83 |
+
return;
|
| 84 |
+
}
|
| 85 |
+
if (operator !== "===" && operator !== "==") return;
|
| 86 |
+
let typeofPath;
|
| 87 |
+
let typePath;
|
| 88 |
+
if (left.isUnaryExpression({
|
| 89 |
+
operator: "typeof"
|
| 90 |
+
})) {
|
| 91 |
+
typeofPath = left;
|
| 92 |
+
typePath = right;
|
| 93 |
+
} else if (right.isUnaryExpression({
|
| 94 |
+
operator: "typeof"
|
| 95 |
+
})) {
|
| 96 |
+
typeofPath = right;
|
| 97 |
+
typePath = left;
|
| 98 |
+
}
|
| 99 |
+
if (!typeofPath) return;
|
| 100 |
+
if (!typeofPath.get("argument").isIdentifier({
|
| 101 |
+
name
|
| 102 |
+
})) return;
|
| 103 |
+
typePath = typePath.resolve();
|
| 104 |
+
if (!typePath.isLiteral()) return;
|
| 105 |
+
const typeValue = typePath.node.value;
|
| 106 |
+
if (typeof typeValue !== "string") return;
|
| 107 |
+
return createTypeAnnotationBasedOnTypeof(typeValue);
|
| 108 |
+
}
|
| 109 |
+
function getParentConditionalPath(binding, path, name) {
|
| 110 |
+
let parentPath;
|
| 111 |
+
while (parentPath = path.parentPath) {
|
| 112 |
+
if (parentPath.isIfStatement() || parentPath.isConditionalExpression()) {
|
| 113 |
+
if (path.key === "test") {
|
| 114 |
+
return;
|
| 115 |
+
}
|
| 116 |
+
return parentPath;
|
| 117 |
+
}
|
| 118 |
+
if (parentPath.isFunction()) {
|
| 119 |
+
if (name == null || parentPath.parentPath.scope.getBinding(name) !== binding) return;
|
| 120 |
+
}
|
| 121 |
+
path = parentPath;
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
function getConditionalAnnotation(binding, path, name) {
|
| 125 |
+
const ifStatement = getParentConditionalPath(binding, path, name);
|
| 126 |
+
if (!ifStatement) return;
|
| 127 |
+
const test = ifStatement.get("test");
|
| 128 |
+
const paths = [test];
|
| 129 |
+
const types = [];
|
| 130 |
+
for (let i = 0; i < paths.length; i++) {
|
| 131 |
+
const path = paths[i];
|
| 132 |
+
if (path.isLogicalExpression()) {
|
| 133 |
+
if (path.node.operator === "&&") {
|
| 134 |
+
paths.push(path.get("left"));
|
| 135 |
+
paths.push(path.get("right"));
|
| 136 |
+
}
|
| 137 |
+
} else if (path.isBinaryExpression()) {
|
| 138 |
+
const type = inferAnnotationFromBinaryExpression(name, path);
|
| 139 |
+
if (type) types.push(type);
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
if (types.length) {
|
| 143 |
+
return {
|
| 144 |
+
typeAnnotation: (0, _util.createUnionType)(types),
|
| 145 |
+
ifStatement
|
| 146 |
+
};
|
| 147 |
+
}
|
| 148 |
+
return getConditionalAnnotation(binding, ifStatement, name);
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
//# sourceMappingURL=inferer-reference.js.map
|
node_modules/@babel/traverse/lib/path/inference/inferer-reference.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_t","require","_util","BOOLEAN_NUMBER_BINARY_OPERATORS","createTypeAnnotationBasedOnTypeof","numberTypeAnnotation","voidTypeAnnotation","_default","node","isReferenced","binding","scope","getBinding","name","identifier","typeAnnotation","getTypeAnnotationBindingConstantViolations","path","types","functionConstantViolations","constantViolations","getConstantViolationsBefore","testType","getConditionalAnnotation","testConstantViolations","ifStatement","filter","includes","push","length","violation","getTypeAnnotation","createUnionType","functions","violations","slice","unshift","resolve","status","_guessExecutionStatusRelativeTo","inferAnnotationFromBinaryExpression","operator","right","get","left","target","isIdentifier","typeofPath","typePath","isUnaryExpression","isLiteral","typeValue","value","getParentConditionalPath","parentPath","isIfStatement","isConditionalExpression","key","isFunction","test","paths","i","isLogicalExpression","isBinaryExpression","type"],"sources":["../../../src/path/inference/inferer-reference.ts"],"sourcesContent":["import type NodePath from \"../index.ts\";\nimport {\n BOOLEAN_NUMBER_BINARY_OPERATORS,\n createTypeAnnotationBasedOnTypeof,\n numberTypeAnnotation,\n voidTypeAnnotation,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type Binding from \"../../scope/binding.ts\";\n\nimport { createUnionType } from \"./util.ts\";\n\nexport default function (this: NodePath<t.Identifier>, node: t.Identifier) {\n if (!this.isReferenced()) return;\n\n // check if a binding exists of this value and if so then return a union type of all\n // possible types that the binding could be\n const binding = this.scope.getBinding(node.name);\n if (binding) {\n if (binding.identifier.typeAnnotation) {\n return binding.identifier.typeAnnotation;\n } else {\n return getTypeAnnotationBindingConstantViolations(\n binding,\n this,\n node.name,\n );\n }\n }\n\n // built-in values\n if (node.name === \"undefined\") {\n return voidTypeAnnotation();\n } else if (node.name === \"NaN\" || node.name === \"Infinity\") {\n return numberTypeAnnotation();\n } else if (node.name === \"arguments\") {\n // todo\n }\n}\n\nfunction getTypeAnnotationBindingConstantViolations(\n binding: Binding,\n path: NodePath<t.Identifier>,\n name: string,\n) {\n const types = [];\n\n const functionConstantViolations: NodePath[] = [];\n let constantViolations = getConstantViolationsBefore(\n binding,\n path,\n functionConstantViolations,\n );\n\n const testType = getConditionalAnnotation(binding, path, name);\n if (testType) {\n const testConstantViolations = getConstantViolationsBefore(\n binding,\n testType.ifStatement,\n );\n\n // remove constant violations observed before the IfStatement\n constantViolations = constantViolations.filter(\n path => !testConstantViolations.includes(path),\n );\n\n // clear current types and add in observed test type\n types.push(testType.typeAnnotation);\n }\n\n if (constantViolations.length) {\n // pick one constant from each scope which will represent the last possible\n // control flow path that it could've taken/been\n /* This code is broken for the following problems:\n * It thinks that assignments can only happen in scopes.\n * What about conditionals, if statements without block,\n * or guarded assignments.\n * It also checks to see if one of the assignments is in the\n * same scope and uses that as the only \"violation\". However,\n * the binding is returned by `getConstantViolationsBefore` so we for\n * sure always going to return that as the only \"violation\".\n let rawConstantViolations = constantViolations.reverse();\n let visitedScopes = [];\n constantViolations = [];\n for (let violation of (rawConstantViolations: Array<NodePath>)) {\n let violationScope = violation.scope;\n if (visitedScopes.indexOf(violationScope) >= 0) continue;\n\n visitedScopes.push(violationScope);\n constantViolations.push(violation);\n\n if (violationScope === path.scope) {\n constantViolations = [violation];\n break;\n }\n }*/\n\n // add back on function constant violations since we can't track calls\n constantViolations.push(...functionConstantViolations);\n\n // push on inferred types of violated paths\n for (const violation of constantViolations) {\n types.push(violation.getTypeAnnotation());\n }\n }\n\n if (!types.length) {\n return;\n }\n\n return createUnionType(types);\n}\n\nfunction getConstantViolationsBefore(\n binding: Binding,\n path: NodePath,\n functions?: NodePath[],\n) {\n const violations = binding.constantViolations.slice();\n violations.unshift(binding.path);\n return violations.filter(violation => {\n violation = violation.resolve();\n const status = violation._guessExecutionStatusRelativeTo(path);\n if (functions && status === \"unknown\") functions.push(violation);\n return status === \"before\";\n });\n}\n\nfunction inferAnnotationFromBinaryExpression(\n name: string | undefined,\n path: NodePath<t.BinaryExpression>,\n) {\n const operator = path.node.operator;\n\n const right = path.get(\"right\").resolve();\n const left = path.get(\"left\").resolve();\n\n let target;\n if (left.isIdentifier({ name })) {\n target = right;\n } else if (right.isIdentifier({ name })) {\n target = left;\n }\n\n if (target) {\n if (operator === \"===\") {\n return target.getTypeAnnotation();\n }\n if (BOOLEAN_NUMBER_BINARY_OPERATORS.includes(operator)) {\n return numberTypeAnnotation();\n }\n\n return;\n }\n\n if (operator !== \"===\" && operator !== \"==\") return;\n\n let typeofPath: NodePath<t.UnaryExpression>;\n let typePath: NodePath<t.Expression>;\n if (left.isUnaryExpression({ operator: \"typeof\" })) {\n typeofPath = left;\n typePath = right as NodePath<t.Expression>;\n } else if (right.isUnaryExpression({ operator: \"typeof\" })) {\n typeofPath = right;\n typePath = left as NodePath<t.Expression>;\n }\n\n if (!typeofPath!) return;\n // and that the argument of the typeof path references us!\n if (!typeofPath.get(\"argument\").isIdentifier({ name })) return;\n\n // ensure that the type path is a Literal\n typePath = typePath!.resolve() as NodePath<t.Expression>;\n if (!typePath.isLiteral()) return;\n\n // and that it's a string so we can infer it\n // @ts-expect-error todo(flow->ts): value is not defined for NullLiteral and some other\n const typeValue = typePath.node.value;\n if (typeof typeValue !== \"string\") return;\n\n // turn type value into a type annotation\n // @ts-expect-error todo(flow->ts): move validation from helper or relax type constraint to just a string\n return createTypeAnnotationBasedOnTypeof(typeValue);\n}\n\nfunction getParentConditionalPath(\n binding: Binding,\n path: NodePath,\n name: string,\n) {\n let parentPath;\n while ((parentPath = path.parentPath)) {\n if (parentPath.isIfStatement() || parentPath.isConditionalExpression()) {\n if (path.key === \"test\") {\n return;\n }\n\n return parentPath as NodePath<t.IfStatement | t.ConditionalExpression>;\n }\n if (parentPath.isFunction()) {\n if (\n name == null ||\n parentPath.parentPath.scope.getBinding(name) !== binding\n )\n return;\n }\n\n path = parentPath;\n }\n}\n\nfunction getConditionalAnnotation<T extends t.Node>(\n binding: Binding,\n path: NodePath<T>,\n name: string,\n):\n | {\n typeAnnotation: t.FlowType | t.TSType;\n ifStatement: NodePath<t.IfStatement | t.ConditionalExpression>;\n }\n | undefined {\n const ifStatement = getParentConditionalPath(binding, path, name);\n if (!ifStatement) return;\n\n const test = ifStatement.get(\"test\");\n const paths = [test];\n const types = [];\n\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i];\n\n if (path.isLogicalExpression()) {\n if (path.node.operator === \"&&\") {\n paths.push(path.get(\"left\"));\n paths.push(path.get(\"right\"));\n }\n } else if (path.isBinaryExpression()) {\n const type = inferAnnotationFromBinaryExpression(name, path);\n if (type) types.push(type);\n }\n }\n\n if (types.length) {\n return {\n typeAnnotation: createUnionType(types)!,\n ifStatement,\n };\n }\n\n return getConditionalAnnotation(binding, ifStatement, name);\n}\n"],"mappings":";;;;;;AACA,IAAAA,EAAA,GAAAC,OAAA;AASA,IAAAC,KAAA,GAAAD,OAAA;AAA4C;EAR1CE,+BAA+B;EAC/BC,iCAAiC;EACjCC,oBAAoB;EACpBC;AAAkB,IAAAN,EAAA;AAOL,SAAAO,SAAwCC,IAAkB,EAAE;EACzE,IAAI,CAAC,IAAI,CAACC,YAAY,CAAC,CAAC,EAAE;EAI1B,MAAMC,OAAO,GAAG,IAAI,CAACC,KAAK,CAACC,UAAU,CAACJ,IAAI,CAACK,IAAI,CAAC;EAChD,IAAIH,OAAO,EAAE;IACX,IAAIA,OAAO,CAACI,UAAU,CAACC,cAAc,EAAE;MACrC,OAAOL,OAAO,CAACI,UAAU,CAACC,cAAc;IAC1C,CAAC,MAAM;MACL,OAAOC,0CAA0C,CAC/CN,OAAO,EACP,IAAI,EACJF,IAAI,CAACK,IACP,CAAC;IACH;EACF;EAGA,IAAIL,IAAI,CAACK,IAAI,KAAK,WAAW,EAAE;IAC7B,OAAOP,kBAAkB,CAAC,CAAC;EAC7B,CAAC,MAAM,IAAIE,IAAI,CAACK,IAAI,KAAK,KAAK,IAAIL,IAAI,CAACK,IAAI,KAAK,UAAU,EAAE;IAC1D,OAAOR,oBAAoB,CAAC,CAAC;EAC/B,CAAC,MAAM,IAAIG,IAAI,CAACK,IAAI,KAAK,WAAW,EAAE,CAEtC;AACF;AAEA,SAASG,0CAA0CA,CACjDN,OAAgB,EAChBO,IAA4B,EAC5BJ,IAAY,EACZ;EACA,MAAMK,KAAK,GAAG,EAAE;EAEhB,MAAMC,0BAAsC,GAAG,EAAE;EACjD,IAAIC,kBAAkB,GAAGC,2BAA2B,CAClDX,OAAO,EACPO,IAAI,EACJE,0BACF,CAAC;EAED,MAAMG,QAAQ,GAAGC,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
| 5 |
+
});
|
| 6 |
+
exports.ArrayExpression = ArrayExpression;
|
| 7 |
+
exports.AssignmentExpression = AssignmentExpression;
|
| 8 |
+
exports.BinaryExpression = BinaryExpression;
|
| 9 |
+
exports.BooleanLiteral = BooleanLiteral;
|
| 10 |
+
exports.CallExpression = CallExpression;
|
| 11 |
+
exports.ConditionalExpression = ConditionalExpression;
|
| 12 |
+
exports.ClassDeclaration = exports.ClassExpression = exports.FunctionDeclaration = exports.ArrowFunctionExpression = exports.FunctionExpression = Func;
|
| 13 |
+
Object.defineProperty(exports, "Identifier", {
|
| 14 |
+
enumerable: true,
|
| 15 |
+
get: function () {
|
| 16 |
+
return _infererReference.default;
|
| 17 |
+
}
|
| 18 |
+
});
|
| 19 |
+
exports.LogicalExpression = LogicalExpression;
|
| 20 |
+
exports.NewExpression = NewExpression;
|
| 21 |
+
exports.NullLiteral = NullLiteral;
|
| 22 |
+
exports.NumericLiteral = NumericLiteral;
|
| 23 |
+
exports.ObjectExpression = ObjectExpression;
|
| 24 |
+
exports.ParenthesizedExpression = ParenthesizedExpression;
|
| 25 |
+
exports.RegExpLiteral = RegExpLiteral;
|
| 26 |
+
exports.RestElement = RestElement;
|
| 27 |
+
exports.SequenceExpression = SequenceExpression;
|
| 28 |
+
exports.StringLiteral = StringLiteral;
|
| 29 |
+
exports.TSAsExpression = TSAsExpression;
|
| 30 |
+
exports.TSNonNullExpression = TSNonNullExpression;
|
| 31 |
+
exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
| 32 |
+
exports.TemplateLiteral = TemplateLiteral;
|
| 33 |
+
exports.TypeCastExpression = TypeCastExpression;
|
| 34 |
+
exports.UnaryExpression = UnaryExpression;
|
| 35 |
+
exports.UpdateExpression = UpdateExpression;
|
| 36 |
+
exports.VariableDeclarator = VariableDeclarator;
|
| 37 |
+
var _t = require("@babel/types");
|
| 38 |
+
var _infererReference = require("./inferer-reference.js");
|
| 39 |
+
var _util = require("./util.js");
|
| 40 |
+
const {
|
| 41 |
+
BOOLEAN_BINARY_OPERATORS,
|
| 42 |
+
BOOLEAN_UNARY_OPERATORS,
|
| 43 |
+
NUMBER_BINARY_OPERATORS,
|
| 44 |
+
NUMBER_UNARY_OPERATORS,
|
| 45 |
+
STRING_UNARY_OPERATORS,
|
| 46 |
+
anyTypeAnnotation,
|
| 47 |
+
arrayTypeAnnotation,
|
| 48 |
+
booleanTypeAnnotation,
|
| 49 |
+
buildMatchMemberExpression,
|
| 50 |
+
genericTypeAnnotation,
|
| 51 |
+
identifier,
|
| 52 |
+
nullLiteralTypeAnnotation,
|
| 53 |
+
numberTypeAnnotation,
|
| 54 |
+
stringTypeAnnotation,
|
| 55 |
+
tupleTypeAnnotation,
|
| 56 |
+
unionTypeAnnotation,
|
| 57 |
+
voidTypeAnnotation,
|
| 58 |
+
isIdentifier
|
| 59 |
+
} = _t;
|
| 60 |
+
function VariableDeclarator() {
|
| 61 |
+
if (!this.get("id").isIdentifier()) return;
|
| 62 |
+
return this.get("init").getTypeAnnotation();
|
| 63 |
+
}
|
| 64 |
+
function TypeCastExpression(node) {
|
| 65 |
+
return node.typeAnnotation;
|
| 66 |
+
}
|
| 67 |
+
TypeCastExpression.validParent = true;
|
| 68 |
+
function TSAsExpression(node) {
|
| 69 |
+
return node.typeAnnotation;
|
| 70 |
+
}
|
| 71 |
+
TSAsExpression.validParent = true;
|
| 72 |
+
function TSNonNullExpression() {
|
| 73 |
+
return this.get("expression").getTypeAnnotation();
|
| 74 |
+
}
|
| 75 |
+
function NewExpression(node) {
|
| 76 |
+
if (node.callee.type === "Identifier") {
|
| 77 |
+
return genericTypeAnnotation(node.callee);
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
function TemplateLiteral() {
|
| 81 |
+
return stringTypeAnnotation();
|
| 82 |
+
}
|
| 83 |
+
function UnaryExpression(node) {
|
| 84 |
+
const operator = node.operator;
|
| 85 |
+
if (operator === "void") {
|
| 86 |
+
return voidTypeAnnotation();
|
| 87 |
+
} else if (NUMBER_UNARY_OPERATORS.includes(operator)) {
|
| 88 |
+
return numberTypeAnnotation();
|
| 89 |
+
} else if (STRING_UNARY_OPERATORS.includes(operator)) {
|
| 90 |
+
return stringTypeAnnotation();
|
| 91 |
+
} else if (BOOLEAN_UNARY_OPERATORS.includes(operator)) {
|
| 92 |
+
return booleanTypeAnnotation();
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
function BinaryExpression(node) {
|
| 96 |
+
const operator = node.operator;
|
| 97 |
+
if (NUMBER_BINARY_OPERATORS.includes(operator)) {
|
| 98 |
+
return numberTypeAnnotation();
|
| 99 |
+
} else if (BOOLEAN_BINARY_OPERATORS.includes(operator)) {
|
| 100 |
+
return booleanTypeAnnotation();
|
| 101 |
+
} else if (operator === "+") {
|
| 102 |
+
const right = this.get("right");
|
| 103 |
+
const left = this.get("left");
|
| 104 |
+
if (left.isBaseType("number") && right.isBaseType("number")) {
|
| 105 |
+
return numberTypeAnnotation();
|
| 106 |
+
} else if (left.isBaseType("string") || right.isBaseType("string")) {
|
| 107 |
+
return stringTypeAnnotation();
|
| 108 |
+
}
|
| 109 |
+
return unionTypeAnnotation([stringTypeAnnotation(), numberTypeAnnotation()]);
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
function LogicalExpression() {
|
| 113 |
+
const argumentTypes = [this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()];
|
| 114 |
+
return (0, _util.createUnionType)(argumentTypes);
|
| 115 |
+
}
|
| 116 |
+
function ConditionalExpression() {
|
| 117 |
+
const argumentTypes = [this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()];
|
| 118 |
+
return (0, _util.createUnionType)(argumentTypes);
|
| 119 |
+
}
|
| 120 |
+
function SequenceExpression() {
|
| 121 |
+
return this.get("expressions").pop().getTypeAnnotation();
|
| 122 |
+
}
|
| 123 |
+
function ParenthesizedExpression() {
|
| 124 |
+
return this.get("expression").getTypeAnnotation();
|
| 125 |
+
}
|
| 126 |
+
function AssignmentExpression() {
|
| 127 |
+
return this.get("right").getTypeAnnotation();
|
| 128 |
+
}
|
| 129 |
+
function UpdateExpression(node) {
|
| 130 |
+
const operator = node.operator;
|
| 131 |
+
if (operator === "++" || operator === "--") {
|
| 132 |
+
return numberTypeAnnotation();
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
function StringLiteral() {
|
| 136 |
+
return stringTypeAnnotation();
|
| 137 |
+
}
|
| 138 |
+
function NumericLiteral() {
|
| 139 |
+
return numberTypeAnnotation();
|
| 140 |
+
}
|
| 141 |
+
function BooleanLiteral() {
|
| 142 |
+
return booleanTypeAnnotation();
|
| 143 |
+
}
|
| 144 |
+
function NullLiteral() {
|
| 145 |
+
return nullLiteralTypeAnnotation();
|
| 146 |
+
}
|
| 147 |
+
function RegExpLiteral() {
|
| 148 |
+
return genericTypeAnnotation(identifier("RegExp"));
|
| 149 |
+
}
|
| 150 |
+
function ObjectExpression() {
|
| 151 |
+
return genericTypeAnnotation(identifier("Object"));
|
| 152 |
+
}
|
| 153 |
+
function ArrayExpression() {
|
| 154 |
+
return genericTypeAnnotation(identifier("Array"));
|
| 155 |
+
}
|
| 156 |
+
function RestElement() {
|
| 157 |
+
return ArrayExpression();
|
| 158 |
+
}
|
| 159 |
+
RestElement.validParent = true;
|
| 160 |
+
function Func() {
|
| 161 |
+
return genericTypeAnnotation(identifier("Function"));
|
| 162 |
+
}
|
| 163 |
+
const isArrayFrom = buildMatchMemberExpression("Array.from");
|
| 164 |
+
const isObjectKeys = buildMatchMemberExpression("Object.keys");
|
| 165 |
+
const isObjectValues = buildMatchMemberExpression("Object.values");
|
| 166 |
+
const isObjectEntries = buildMatchMemberExpression("Object.entries");
|
| 167 |
+
function CallExpression() {
|
| 168 |
+
const {
|
| 169 |
+
callee
|
| 170 |
+
} = this.node;
|
| 171 |
+
if (isObjectKeys(callee)) {
|
| 172 |
+
return arrayTypeAnnotation(stringTypeAnnotation());
|
| 173 |
+
} else if (isArrayFrom(callee) || isObjectValues(callee) || isIdentifier(callee, {
|
| 174 |
+
name: "Array"
|
| 175 |
+
})) {
|
| 176 |
+
return arrayTypeAnnotation(anyTypeAnnotation());
|
| 177 |
+
} else if (isObjectEntries(callee)) {
|
| 178 |
+
return arrayTypeAnnotation(tupleTypeAnnotation([stringTypeAnnotation(), anyTypeAnnotation()]));
|
| 179 |
+
}
|
| 180 |
+
return resolveCall(this.get("callee"));
|
| 181 |
+
}
|
| 182 |
+
function TaggedTemplateExpression() {
|
| 183 |
+
return resolveCall(this.get("tag"));
|
| 184 |
+
}
|
| 185 |
+
function resolveCall(callee) {
|
| 186 |
+
callee = callee.resolve();
|
| 187 |
+
if (callee.isFunction()) {
|
| 188 |
+
const {
|
| 189 |
+
node
|
| 190 |
+
} = callee;
|
| 191 |
+
if (node.async) {
|
| 192 |
+
if (node.generator) {
|
| 193 |
+
return genericTypeAnnotation(identifier("AsyncIterator"));
|
| 194 |
+
} else {
|
| 195 |
+
return genericTypeAnnotation(identifier("Promise"));
|
| 196 |
+
}
|
| 197 |
+
} else {
|
| 198 |
+
if (node.generator) {
|
| 199 |
+
return genericTypeAnnotation(identifier("Iterator"));
|
| 200 |
+
} else if (callee.node.returnType) {
|
| 201 |
+
return callee.node.returnType;
|
| 202 |
+
} else {}
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
//# sourceMappingURL=inferers.js.map
|
node_modules/@babel/traverse/lib/path/inference/inferers.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_t","require","_infererReference","_util","BOOLEAN_BINARY_OPERATORS","BOOLEAN_UNARY_OPERATORS","NUMBER_BINARY_OPERATORS","NUMBER_UNARY_OPERATORS","STRING_UNARY_OPERATORS","anyTypeAnnotation","arrayTypeAnnotation","booleanTypeAnnotation","buildMatchMemberExpression","genericTypeAnnotation","identifier","nullLiteralTypeAnnotation","numberTypeAnnotation","stringTypeAnnotation","tupleTypeAnnotation","unionTypeAnnotation","voidTypeAnnotation","isIdentifier","VariableDeclarator","get","getTypeAnnotation","TypeCastExpression","node","typeAnnotation","validParent","TSAsExpression","TSNonNullExpression","NewExpression","callee","type","TemplateLiteral","UnaryExpression","operator","includes","BinaryExpression","right","left","isBaseType","LogicalExpression","argumentTypes","createUnionType","ConditionalExpression","SequenceExpression","pop","ParenthesizedExpression","AssignmentExpression","UpdateExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","RegExpLiteral","ObjectExpression","ArrayExpression","RestElement","Func","isArrayFrom","isObjectKeys","isObjectValues","isObjectEntries","CallExpression","name","resolveCall","TaggedTemplateExpression","resolve","isFunction","async","generator","returnType"],"sources":["../../../src/path/inference/inferers.ts"],"sourcesContent":["import {\n BOOLEAN_BINARY_OPERATORS,\n BOOLEAN_UNARY_OPERATORS,\n NUMBER_BINARY_OPERATORS,\n NUMBER_UNARY_OPERATORS,\n STRING_UNARY_OPERATORS,\n anyTypeAnnotation,\n arrayTypeAnnotation,\n booleanTypeAnnotation,\n buildMatchMemberExpression,\n genericTypeAnnotation,\n identifier,\n nullLiteralTypeAnnotation,\n numberTypeAnnotation,\n stringTypeAnnotation,\n tupleTypeAnnotation,\n unionTypeAnnotation,\n voidTypeAnnotation,\n isIdentifier,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nexport { default as Identifier } from \"./inferer-reference.ts\";\n\nimport { createUnionType } from \"./util.ts\";\nimport type NodePath from \"../index.ts\";\n\nexport function VariableDeclarator(this: NodePath<t.VariableDeclarator>) {\n if (!this.get(\"id\").isIdentifier()) return;\n return this.get(\"init\").getTypeAnnotation();\n}\n\nexport function TypeCastExpression(node: t.TypeCastExpression) {\n return node.typeAnnotation;\n}\n\nTypeCastExpression.validParent = true;\n\nexport function TSAsExpression(node: t.TSAsExpression) {\n return node.typeAnnotation;\n}\n\nTSAsExpression.validParent = true;\n\nexport function TSNonNullExpression(this: NodePath<t.TSNonNullExpression>) {\n return this.get(\"expression\").getTypeAnnotation();\n}\n\nexport function NewExpression(\n this: NodePath<t.NewExpression>,\n node: t.NewExpression,\n) {\n if (node.callee.type === \"Identifier\") {\n // only resolve identifier callee\n return genericTypeAnnotation(node.callee);\n }\n}\n\nexport function TemplateLiteral() {\n return stringTypeAnnotation();\n}\n\nexport function UnaryExpression(node: t.UnaryExpression) {\n const operator = node.operator;\n\n if (operator === \"void\") {\n return voidTypeAnnotation();\n } else if (NUMBER_UNARY_OPERATORS.includes(operator)) {\n return numberTypeAnnotation();\n } else if (STRING_UNARY_OPERATORS.includes(operator)) {\n return stringTypeAnnotation();\n } else if (BOOLEAN_UNARY_OPERATORS.includes(operator)) {\n return booleanTypeAnnotation();\n }\n}\n\nexport function BinaryExpression(\n this: NodePath<t.BinaryExpression>,\n node: t.BinaryExpression,\n) {\n const operator = node.operator;\n\n if (NUMBER_BINARY_OPERATORS.includes(operator)) {\n return numberTypeAnnotation();\n } else if (BOOLEAN_BINARY_OPERATORS.includes(operator)) {\n return booleanTypeAnnotation();\n } else if (operator === \"+\") {\n const right = this.get(\"right\");\n const left = this.get(\"left\");\n\n if (left.isBaseType(\"number\") && right.isBaseType(\"number\")) {\n // both numbers so this will be a number\n return numberTypeAnnotation();\n } else if (left.isBaseType(\"string\") || right.isBaseType(\"string\")) {\n // one is a string so the result will be a string\n return stringTypeAnnotation();\n }\n\n // unsure if left and right are strings or numbers so stay on the safe side\n return unionTypeAnnotation([\n stringTypeAnnotation(),\n numberTypeAnnotation(),\n ]);\n }\n}\n\nexport function LogicalExpression(this: NodePath<t.LogicalExpression>) {\n const argumentTypes = [\n this.get(\"left\").getTypeAnnotation(),\n this.get(\"right\").getTypeAnnotation(),\n ];\n\n return createUnionType(argumentTypes);\n}\n\nexport function ConditionalExpression(this: NodePath<t.ConditionalExpression>) {\n const argumentTypes = [\n this.get(\"consequent\").getTypeAnnotation(),\n this.get(\"alternate\").getTypeAnnotation(),\n ];\n\n return createUnionType(argumentTypes);\n}\n\nexport function SequenceExpression(this: NodePath<t.SequenceExpression>) {\n return this.get(\"expressions\").pop()!.getTypeAnnotation();\n}\n\nexport function ParenthesizedExpression(\n this: NodePath<t.ParenthesizedExpression>,\n) {\n return this.get(\"expression\").getTypeAnnotation();\n}\n\nexport function AssignmentExpression(this: NodePath<t.AssignmentExpression>) {\n return this.get(\"right\").getTypeAnnotation();\n}\n\nexport function UpdateExpression(\n this: NodePath<t.UpdateExpression>,\n node: t.UpdateExpression,\n) {\n const operator = node.operator;\n if (operator === \"++\" || operator === \"--\") {\n return numberTypeAnnotation();\n }\n}\n\nexport function StringLiteral() {\n return stringTypeAnnotation();\n}\n\nexport function NumericLiteral() {\n return numberTypeAnnotation();\n}\n\nexport function BooleanLiteral() {\n return booleanTypeAnnotation();\n}\n\nexport function NullLiteral() {\n return nullLiteralTypeAnnotation();\n}\n\nexport function RegExpLiteral() {\n return genericTypeAnnotation(identifier(\"RegExp\"));\n}\n\nexport function ObjectExpression() {\n return genericTypeAnnotation(identifier(\"Object\"));\n}\n\nexport function ArrayExpression() {\n return genericTypeAnnotation(identifier(\"Array\"));\n}\n\nexport function RestElement() {\n return ArrayExpression();\n}\n\nRestElement.validParent = true;\n\nfunction Func() {\n return genericTypeAnnotation(identifier(\"Function\"));\n}\n\nexport {\n Func as FunctionExpression,\n Func as ArrowFunctionExpression,\n Func as FunctionDeclaration,\n Func as ClassExpression,\n Func as ClassDeclaration,\n};\n\nconst isArrayFrom = buildMatchMemberExpression(\"Array.from\");\nconst isObjectKeys = buildMatchMemberExpression(\"Object.keys\");\nconst isObjectValues = buildMatchMemberExpression(\"Object.values\");\nconst isObjectEntries = buildMatchMemberExpression(\"Object.entries\");\nexport function CallExpression(this: NodePath<t.CallExpression>) {\n const { callee } = this.node;\n if (isObjectKeys(callee)) {\n return arrayTypeAnnotation(stringTypeAnnotation());\n } else if (\n isArrayFrom(callee) ||\n isObjectValues(callee) ||\n // Detect \"var foo = Array()\" calls so we can optimize for arrays vs iterables.\n isIdentifier(callee, { name: \"Array\" })\n ) {\n return arrayTypeAnnotation(anyTypeAnnotation());\n } else if (isObjectEntries(callee)) {\n return arrayTypeAnnotation(\n tupleTypeAnnotation([stringTypeAnnotation(), anyTypeAnnotation()]),\n );\n }\n\n return resolveCall(this.get(\"callee\"));\n}\n\nexport function TaggedTemplateExpression(\n this: NodePath<t.TaggedTemplateExpression>,\n) {\n return resolveCall(this.get(\"tag\"));\n}\n\nfunction resolveCall(callee: NodePath) {\n callee = callee.resolve();\n\n if (callee.isFunction()) {\n const { node } = callee;\n if (node.async) {\n if (node.generator) {\n return genericTypeAnnotation(identifier(\"AsyncIterator\"));\n } else {\n return genericTypeAnnotation(identifier(\"Promise\"));\n }\n } else {\n if (node.generator) {\n return genericTypeAnnotation(identifier(\"Iterator\"));\n } else if (callee.node.returnType) {\n return callee.node.returnType;\n } else {\n // todo: get union type of all return arguments\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,EAAA,GAAAC,OAAA;AAsBA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAA4C;EAvB1CG,wBAAwB;EACxBC,uBAAuB;EACvBC,uBAAuB;EACvBC,sBAAsB;EACtBC,sBAAsB;EACtBC,iBAAiB;EACjBC,mBAAmB;EACnBC,qBAAqB;EACrBC,0BAA0B;EAC1BC,qBAAqB;EACrBC,UAAU;EACVC,yBAAyB;EACzBC,oBAAoB;EACpBC,oBAAoB;EACpBC,mBAAmB;EACnBC,mBAAmB;EACnBC,kBAAkB;EAClBC;AAAY,IAAArB,EAAA;AASP,SAASsB,kBAAkBA,CAAA,EAAuC;EACvE,IAAI,CAAC,IAAI,CAACC,GAAG,CAAC,IAAI,CAAC,CAACF,YAAY,CAAC,CAAC,EAAE;EACpC,OAAO,IAAI,CAACE,GAAG,CAAC,MAAM,CAAC,CAACC,iBAAiB,CAAC,CAAC;AAC7C;AAEO,SAASC,kBAAkBA,CAACC,IAA0B,EAAE;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,GAAGA,MAAM,CAACoC,OAAO,CAAC,CAAC;EAEzB,IAAIpC,MAAM,CAACqC,UAAU,CAAC,CAAC,EAAE;IACvB,MAAM;MAAE3C;IAAK,CAAC,GAAGM,MAAM;IACvB,IAAIN,IAAI,CAAC4C,KAAK,EAAE;MACd,IAAI5C,IAAI,CAAC6C,SAAS,EAAE;QAClB,OAAO1D,qBAAqB,CAACC,UAAU,CAAC,eAAe,CAAC,CAAC;MAC3D,CAAC,MAAM;QACL,OAAOD,qBAAqB,CAACC,UAAU,CAAC,SAAS,CAAC,CAAC;MACrD;IACF,CAAC,MAAM;MACL,IAAIY,IAAI,CAAC6C,SAAS,EAAE;QAClB,OAAO1D,qBAAqB,CAACC,UAAU,CAAC,UAAU,CAAC,CAAC;MACtD,CAAC,MAAM,IAAIkB,MAAM,CAACN,IAAI,CAAC8C,UAAU,EAAE;QACjC,OAAOxC,MAAM,CAACN,IAAI,CAAC8C,UAAU;MAC/B,CAAC,MAAM,CAEP;IACF;EACF;AACF","ignoreList":[]}
|
node_modules/@babel/traverse/lib/path/inference/util.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.createUnionType = createUnionType;
|
| 7 |
+
var _t = require("@babel/types");
|
| 8 |
+
const {
|
| 9 |
+
createFlowUnionType,
|
| 10 |
+
createTSUnionType,
|
| 11 |
+
createUnionTypeAnnotation,
|
| 12 |
+
isFlowType,
|
| 13 |
+
isTSType
|
| 14 |
+
} = _t;
|
| 15 |
+
function createUnionType(types) {
|
| 16 |
+
if (types.every(v => isFlowType(v))) {
|
| 17 |
+
if (createFlowUnionType) {
|
| 18 |
+
return createFlowUnionType(types);
|
| 19 |
+
}
|
| 20 |
+
return createUnionTypeAnnotation(types);
|
| 21 |
+
} else if (types.every(v => isTSType(v))) {
|
| 22 |
+
if (createTSUnionType) {
|
| 23 |
+
return createTSUnionType(types);
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
//# sourceMappingURL=util.js.map
|