init 3
This commit is contained in:
1
node_modules/@babel/generator/lib/generators/expressions.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/expressions.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
297
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
Normal file
297
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.BreakStatement = BreakStatement;
|
||||
exports.CatchClause = CatchClause;
|
||||
exports.ContinueStatement = ContinueStatement;
|
||||
exports.DebuggerStatement = DebuggerStatement;
|
||||
exports.DoWhileStatement = DoWhileStatement;
|
||||
exports.ForInStatement = ForInStatement;
|
||||
exports.ForOfStatement = ForOfStatement;
|
||||
exports.ForStatement = ForStatement;
|
||||
exports.IfStatement = IfStatement;
|
||||
exports.LabeledStatement = LabeledStatement;
|
||||
exports.ReturnStatement = ReturnStatement;
|
||||
exports.SwitchCase = SwitchCase;
|
||||
exports.SwitchStatement = SwitchStatement;
|
||||
exports.ThrowStatement = ThrowStatement;
|
||||
exports.TryStatement = TryStatement;
|
||||
exports.VariableDeclaration = VariableDeclaration;
|
||||
exports.VariableDeclarator = VariableDeclarator;
|
||||
exports.WhileStatement = WhileStatement;
|
||||
exports.WithStatement = WithStatement;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isFor,
|
||||
isIfStatement,
|
||||
isStatement
|
||||
} = _t;
|
||||
function WithStatement(node) {
|
||||
this.word("with");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.object);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
if (needsBlock) {
|
||||
this.tokenChar(123);
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
this.printAndIndentOnComments(node.consequent);
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
if (node.alternate) {
|
||||
if (this.endsWith(125)) this.space();
|
||||
this.word("else");
|
||||
this.space();
|
||||
this.printAndIndentOnComments(node.alternate);
|
||||
}
|
||||
}
|
||||
function getLastStatement(statement) {
|
||||
const {
|
||||
body
|
||||
} = statement;
|
||||
if (isStatement(body) === false) {
|
||||
return statement;
|
||||
}
|
||||
return getLastStatement(body);
|
||||
}
|
||||
function ForStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.tokenContext |= _index.TokenContext.forInitHead | _index.TokenContext.forInOrInitHeadAccumulate;
|
||||
this.print(node.init);
|
||||
this.tokenContext = _index.TokenContext.normal;
|
||||
this.tokenChar(59);
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test);
|
||||
}
|
||||
this.tokenChar(59, 1);
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function ForInStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
this.tokenContext |= _index.TokenContext.forInHead | _index.TokenContext.forInOrInitHeadAccumulate;
|
||||
this.print(node.left);
|
||||
this.tokenContext = _index.TokenContext.normal;
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function ForOfStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
if (node.await) {
|
||||
this.word("await");
|
||||
this.space();
|
||||
}
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
this.tokenContext |= _index.TokenContext.forOfHead;
|
||||
this.print(node.left);
|
||||
this.space();
|
||||
this.word("of");
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function DoWhileStatement(node) {
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
this.space();
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.semicolon();
|
||||
}
|
||||
function printStatementAfterKeyword(printer, node) {
|
||||
if (node) {
|
||||
printer.space();
|
||||
printer.printTerminatorless(node);
|
||||
}
|
||||
printer.semicolon();
|
||||
}
|
||||
function BreakStatement(node) {
|
||||
this.word("break");
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ContinueStatement(node) {
|
||||
this.word("continue");
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ReturnStatement(node) {
|
||||
this.word("return");
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function ThrowStatement(node) {
|
||||
this.word("throw");
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function LabeledStatement(node) {
|
||||
this.print(node.label);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function TryStatement(node) {
|
||||
this.word("try");
|
||||
this.space();
|
||||
this.print(node.block);
|
||||
this.space();
|
||||
if (node.handlers) {
|
||||
this.print(node.handlers[0]);
|
||||
} else {
|
||||
this.print(node.handler);
|
||||
}
|
||||
if (node.finalizer) {
|
||||
this.space();
|
||||
this.word("finally");
|
||||
this.space();
|
||||
this.print(node.finalizer);
|
||||
}
|
||||
}
|
||||
function CatchClause(node) {
|
||||
this.word("catch");
|
||||
this.space();
|
||||
if (node.param) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.param);
|
||||
this.print(node.param.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.body);
|
||||
}
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.discriminant);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.printSequence(node.cases, true);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
this.space();
|
||||
this.print(node.test);
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.word("default");
|
||||
this.tokenChar(58);
|
||||
}
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, true);
|
||||
}
|
||||
}
|
||||
function DebuggerStatement() {
|
||||
this.word("debugger");
|
||||
this.semicolon();
|
||||
}
|
||||
function commaSeparatorWithNewline(occurrenceCount) {
|
||||
this.tokenChar(44, occurrenceCount);
|
||||
this.newline();
|
||||
}
|
||||
function VariableDeclaration(node, parent) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
switch (kind) {
|
||||
case "await using":
|
||||
this.word("await");
|
||||
this.space();
|
||||
case "using":
|
||||
this.word("using", true);
|
||||
break;
|
||||
default:
|
||||
this.word(kind);
|
||||
}
|
||||
this.space();
|
||||
let hasInits = false;
|
||||
if (!isFor(parent)) {
|
||||
for (const declar of node.declarations) {
|
||||
if (declar.init) {
|
||||
hasInits = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.printList(node.declarations, undefined, undefined, node.declarations.length > 1, hasInits ? commaSeparatorWithNewline : undefined);
|
||||
if (parent != null) {
|
||||
switch (parent.type) {
|
||||
case "ForStatement":
|
||||
if (parent.init === node) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "ForInStatement":
|
||||
case "ForOfStatement":
|
||||
if (parent.left === node) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function VariableDeclarator(node) {
|
||||
this.print(node.id);
|
||||
if (node.definite) this.tokenChar(33);
|
||||
this.print(node.id.typeAnnotation);
|
||||
if (node.init) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.init);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=statements.js.map
|
||||
108
node_modules/@babel/generator/lib/index.js
generated
vendored
Normal file
108
node_modules/@babel/generator/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
exports.generate = generate;
|
||||
var _sourceMap = require("./source-map.js");
|
||||
var _printer = require("./printer.js");
|
||||
function normalizeOptions(code, opts, ast) {
|
||||
var _opts$recordAndTupleS;
|
||||
if (opts.experimental_preserveFormat) {
|
||||
if (typeof code !== "string") {
|
||||
throw new Error("`experimental_preserveFormat` requires the original `code` to be passed to @babel/generator as a string");
|
||||
}
|
||||
if (!opts.retainLines) {
|
||||
throw new Error("`experimental_preserveFormat` requires `retainLines` to be set to `true`");
|
||||
}
|
||||
if (opts.compact && opts.compact !== "auto") {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `compact` option");
|
||||
}
|
||||
if (opts.minified) {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `minified` option");
|
||||
}
|
||||
if (opts.jsescOption) {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `jsescOption` option");
|
||||
}
|
||||
if (!Array.isArray(ast.tokens)) {
|
||||
throw new Error("`experimental_preserveFormat` requires the AST to have attached the token of the input code. Make sure to enable the `tokens: true` parser option.");
|
||||
}
|
||||
}
|
||||
const format = {
|
||||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
|
||||
shouldPrintComment: opts.shouldPrintComment,
|
||||
preserveFormat: opts.experimental_preserveFormat,
|
||||
retainLines: opts.retainLines,
|
||||
retainFunctionParens: opts.retainFunctionParens,
|
||||
comments: opts.comments == null || opts.comments,
|
||||
compact: opts.compact,
|
||||
minified: opts.minified,
|
||||
concise: opts.concise,
|
||||
indent: {
|
||||
adjustMultilineComment: true,
|
||||
style: " "
|
||||
},
|
||||
jsescOption: Object.assign({
|
||||
quotes: "double",
|
||||
wrap: true,
|
||||
minimal: false
|
||||
}, opts.jsescOption),
|
||||
topicToken: opts.topicToken
|
||||
};
|
||||
format.decoratorsBeforeExport = opts.decoratorsBeforeExport;
|
||||
format.jsescOption.json = opts.jsonCompatibleStrings;
|
||||
format.recordAndTupleSyntaxType = (_opts$recordAndTupleS = opts.recordAndTupleSyntaxType) != null ? _opts$recordAndTupleS : "hash";
|
||||
format.importAttributesKeyword = opts.importAttributesKeyword;
|
||||
if (format.minified) {
|
||||
format.compact = true;
|
||||
format.shouldPrintComment = format.shouldPrintComment || (() => format.comments);
|
||||
} else {
|
||||
format.shouldPrintComment = format.shouldPrintComment || (value => format.comments || value.includes("@license") || value.includes("@preserve"));
|
||||
}
|
||||
if (format.compact === "auto") {
|
||||
format.compact = typeof code === "string" && code.length > 500000;
|
||||
if (format.compact) {
|
||||
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + `${opts.filename} as it exceeds the max of ${"500KB"}.`);
|
||||
}
|
||||
}
|
||||
if (format.compact || format.preserveFormat) {
|
||||
format.indent.adjustMultilineComment = false;
|
||||
}
|
||||
const {
|
||||
auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter,
|
||||
shouldPrintComment
|
||||
} = format;
|
||||
if (auxiliaryCommentBefore && !shouldPrintComment(auxiliaryCommentBefore)) {
|
||||
format.auxiliaryCommentBefore = undefined;
|
||||
}
|
||||
if (auxiliaryCommentAfter && !shouldPrintComment(auxiliaryCommentAfter)) {
|
||||
format.auxiliaryCommentAfter = undefined;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
exports.CodeGenerator = class CodeGenerator {
|
||||
constructor(ast, opts = {}, code) {
|
||||
this._ast = void 0;
|
||||
this._format = void 0;
|
||||
this._map = void 0;
|
||||
this._ast = ast;
|
||||
this._format = normalizeOptions(code, opts, ast);
|
||||
this._map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
}
|
||||
generate() {
|
||||
const printer = new _printer.default(this._format, this._map);
|
||||
return printer.generate(this._ast);
|
||||
}
|
||||
};
|
||||
function generate(ast, opts = {}, code) {
|
||||
const format = normalizeOptions(code, opts, ast);
|
||||
const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
const printer = new _printer.default(format, map, ast.tokens, typeof code === "string" ? code : null);
|
||||
return printer.generate(ast);
|
||||
}
|
||||
var _default = exports.default = generate;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
298
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
Normal file
298
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
Normal file
@@ -0,0 +1,298 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.BinaryExpression = BinaryExpression;
|
||||
exports.ClassExpression = ClassExpression;
|
||||
exports.ArrowFunctionExpression = exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.DoExpression = DoExpression;
|
||||
exports.FunctionExpression = FunctionExpression;
|
||||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||||
exports.Identifier = Identifier;
|
||||
exports.LogicalExpression = LogicalExpression;
|
||||
exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||||
exports.ObjectExpression = ObjectExpression;
|
||||
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
|
||||
exports.OptionalCallExpression = exports.OptionalMemberExpression = OptionalMemberExpression;
|
||||
exports.SequenceExpression = SequenceExpression;
|
||||
exports.TSSatisfiesExpression = exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSConditionalType = TSConditionalType;
|
||||
exports.TSConstructorType = exports.TSFunctionType = TSFunctionType;
|
||||
exports.TSInferType = TSInferType;
|
||||
exports.TSInstantiationExpression = TSInstantiationExpression;
|
||||
exports.TSIntersectionType = TSIntersectionType;
|
||||
exports.SpreadElement = exports.UnaryExpression = exports.TSTypeAssertion = UnaryLike;
|
||||
exports.TSTypeOperator = TSTypeOperator;
|
||||
exports.TSUnionType = TSUnionType;
|
||||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.AwaitExpression = exports.YieldExpression = YieldExpression;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("./index.js");
|
||||
const {
|
||||
isMemberExpression,
|
||||
isOptionalMemberExpression,
|
||||
isYieldExpression,
|
||||
isStatement
|
||||
} = _t;
|
||||
const PRECEDENCE = new Map([["||", 0], ["??", 1], ["&&", 2], ["|", 3], ["^", 4], ["&", 5], ["==", 6], ["===", 6], ["!=", 6], ["!==", 6], ["<", 7], [">", 7], ["<=", 7], [">=", 7], ["in", 7], ["instanceof", 7], [">>", 8], ["<<", 8], [">>>", 8], ["+", 9], ["-", 9], ["*", 10], ["/", 10], ["%", 10], ["**", 11]]);
|
||||
function isTSTypeExpression(nodeId) {
|
||||
return nodeId === 156 || nodeId === 201 || nodeId === 209;
|
||||
}
|
||||
const isClassExtendsClause = (node, parent, parentId) => {
|
||||
return (parentId === 21 || parentId === 22) && parent.superClass === node;
|
||||
};
|
||||
const hasPostfixPart = (node, parent, parentId) => {
|
||||
switch (parentId) {
|
||||
case 108:
|
||||
case 132:
|
||||
return parent.object === node;
|
||||
case 17:
|
||||
case 130:
|
||||
case 112:
|
||||
return parent.callee === node;
|
||||
case 222:
|
||||
return parent.tag === node;
|
||||
case 191:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
function NullableTypeAnnotation(node, parent, parentId) {
|
||||
return parentId === 4;
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent, parentId, tokenContext) {
|
||||
return (parentId === 239 || parentId === 90 || parentId === 4 || (tokenContext & _index.TokenContext.arrowFlowReturnType) > 0
|
||||
);
|
||||
}
|
||||
function UpdateExpression(node, parent, parentId) {
|
||||
return hasPostfixPart(node, parent, parentId) || isClassExtendsClause(node, parent, parentId);
|
||||
}
|
||||
function needsParenBeforeExpressionBrace(tokenContext) {
|
||||
return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.arrowBody)) > 0;
|
||||
}
|
||||
function ObjectExpression(node, parent, parentId, tokenContext) {
|
||||
return needsParenBeforeExpressionBrace(tokenContext);
|
||||
}
|
||||
function DoExpression(node, parent, parentId, tokenContext) {
|
||||
return (tokenContext & _index.TokenContext.expressionStatement) > 0 && !node.async;
|
||||
}
|
||||
function BinaryLike(node, parent, parentId, nodeType) {
|
||||
if (isClassExtendsClause(node, parent, parentId)) {
|
||||
return true;
|
||||
}
|
||||
if (hasPostfixPart(node, parent, parentId) || parentId === 238 || parentId === 145 || parentId === 8) {
|
||||
return true;
|
||||
}
|
||||
let parentPos;
|
||||
switch (parentId) {
|
||||
case 10:
|
||||
case 107:
|
||||
parentPos = PRECEDENCE.get(parent.operator);
|
||||
break;
|
||||
case 156:
|
||||
case 201:
|
||||
parentPos = 7;
|
||||
}
|
||||
if (parentPos !== undefined) {
|
||||
const nodePos = nodeType === 2 ? 7 : PRECEDENCE.get(node.operator);
|
||||
if (parentPos > nodePos) return true;
|
||||
if (parentPos === nodePos && parentId === 10 && (nodePos === 11 ? parent.left === node : parent.right === node)) {
|
||||
return true;
|
||||
}
|
||||
if (nodeType === 1 && parentId === 107 && (nodePos === 1 && parentPos !== 1 || parentPos === 1 && nodePos !== 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function UnionTypeAnnotation(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 4:
|
||||
case 115:
|
||||
case 90:
|
||||
case 239:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function OptionalIndexedAccessType(node, parent, parentId) {
|
||||
return parentId === 84 && parent.objectType === node;
|
||||
}
|
||||
function TSAsExpression(node, parent, parentId) {
|
||||
if ((parentId === 6 || parentId === 7) && parent.left === node) {
|
||||
return true;
|
||||
}
|
||||
if (parentId === 10 && (parent.operator === "|" || parent.operator === "&") && node === parent.left) {
|
||||
return true;
|
||||
}
|
||||
return BinaryLike(node, parent, parentId, 2);
|
||||
}
|
||||
function TSConditionalType(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 155:
|
||||
case 195:
|
||||
case 211:
|
||||
case 212:
|
||||
return true;
|
||||
case 175:
|
||||
return parent.objectType === node;
|
||||
case 181:
|
||||
case 219:
|
||||
return parent.types[0] === node;
|
||||
case 161:
|
||||
return parent.checkType === node || parent.extendsType === node;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSUnionType(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 181:
|
||||
case 211:
|
||||
case 155:
|
||||
case 195:
|
||||
return true;
|
||||
case 175:
|
||||
return parent.objectType === node;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSIntersectionType(node, parent, parentId) {
|
||||
return parentId === 211 || TSTypeOperator(node, parent, parentId);
|
||||
}
|
||||
function TSInferType(node, parent, parentId) {
|
||||
if (TSTypeOperator(node, parent, parentId)) {
|
||||
return true;
|
||||
}
|
||||
if ((parentId === 181 || parentId === 219) && node.typeParameter.constraint && parent.types[0] === node) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSTypeOperator(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 155:
|
||||
case 195:
|
||||
return true;
|
||||
case 175:
|
||||
if (parent.objectType === node) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSInstantiationExpression(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 17:
|
||||
case 130:
|
||||
case 112:
|
||||
case 177:
|
||||
return (parent.typeParameters
|
||||
) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSFunctionType(node, parent, parentId) {
|
||||
if (TSUnionType(node, parent, parentId)) return true;
|
||||
return parentId === 219 || parentId === 161 && (parent.checkType === node || parent.extendsType === node);
|
||||
}
|
||||
function BinaryExpression(node, parent, parentId, tokenContext) {
|
||||
if (BinaryLike(node, parent, parentId, 0)) return true;
|
||||
return (tokenContext & _index.TokenContext.forInOrInitHeadAccumulate) > 0 && node.operator === "in";
|
||||
}
|
||||
function LogicalExpression(node, parent, parentId) {
|
||||
return BinaryLike(node, parent, parentId, 1);
|
||||
}
|
||||
function SequenceExpression(node, parent, parentId) {
|
||||
if (parentId === 144 || parentId === 133 || parentId === 108 && parent.property === node || parentId === 132 && parent.property === node || parentId === 224) {
|
||||
return false;
|
||||
}
|
||||
if (parentId === 21) {
|
||||
return true;
|
||||
}
|
||||
if (parentId === 68) {
|
||||
return parent.right === node;
|
||||
}
|
||||
if (parentId === 60) {
|
||||
return true;
|
||||
}
|
||||
return !isStatement(parent);
|
||||
}
|
||||
function YieldExpression(node, parent, parentId) {
|
||||
return parentId === 10 || parentId === 107 || parentId === 238 || parentId === 145 || hasPostfixPart(node, parent, parentId) || parentId === 8 && isYieldExpression(node) || parentId === 28 && node === parent.test || isClassExtendsClause(node, parent, parentId) || isTSTypeExpression(parentId);
|
||||
}
|
||||
function ClassExpression(node, parent, parentId, tokenContext) {
|
||||
return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault)) > 0;
|
||||
}
|
||||
function UnaryLike(node, parent, parentId) {
|
||||
return hasPostfixPart(node, parent, parentId) || parentId === 10 && parent.operator === "**" && parent.left === node || isClassExtendsClause(node, parent, parentId);
|
||||
}
|
||||
function FunctionExpression(node, parent, parentId, tokenContext) {
|
||||
return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault)) > 0;
|
||||
}
|
||||
function ConditionalExpression(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 238:
|
||||
case 145:
|
||||
case 10:
|
||||
case 107:
|
||||
case 8:
|
||||
return true;
|
||||
case 28:
|
||||
if (parent.test === node) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (isTSTypeExpression(parentId)) {
|
||||
return true;
|
||||
}
|
||||
return UnaryLike(node, parent, parentId);
|
||||
}
|
||||
function OptionalMemberExpression(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 17:
|
||||
return parent.callee === node;
|
||||
case 108:
|
||||
return parent.object === node;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function AssignmentExpression(node, parent, parentId, tokenContext) {
|
||||
if (needsParenBeforeExpressionBrace(tokenContext) && node.left.type === "ObjectPattern") {
|
||||
return true;
|
||||
}
|
||||
return ConditionalExpression(node, parent, parentId);
|
||||
}
|
||||
function Identifier(node, parent, parentId, tokenContext, getRawIdentifier) {
|
||||
var _node$extra;
|
||||
if (getRawIdentifier && getRawIdentifier(node) !== node.name) {
|
||||
return false;
|
||||
}
|
||||
if (parentId === 6 && (_node$extra = node.extra) != null && _node$extra.parenthesized && parent.left === node) {
|
||||
const rightType = parent.right.type;
|
||||
if ((rightType === "FunctionExpression" || rightType === "ClassExpression") && parent.right.id == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (tokenContext & _index.TokenContext.forOfHead || (parentId === 108 || parentId === 132) && tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.forInitHead | _index.TokenContext.forInHead)) {
|
||||
if (node.name === "let") {
|
||||
const isFollowedByBracket = isMemberExpression(parent, {
|
||||
object: node,
|
||||
computed: true
|
||||
}) || isOptionalMemberExpression(parent, {
|
||||
object: node,
|
||||
computed: true,
|
||||
optional: false
|
||||
});
|
||||
if (isFollowedByBracket && tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.forInitHead | _index.TokenContext.forInHead)) {
|
||||
return true;
|
||||
}
|
||||
return (tokenContext & _index.TokenContext.forOfHead) > 0;
|
||||
}
|
||||
}
|
||||
return parentId === 68 && parent.left === node && node.name === "async" && !parent.await;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parentheses.js.map
|
||||
1
node_modules/@babel/generator/lib/source-map.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/source-map.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
195
node_modules/@babel/generator/lib/token-map.js
generated
vendored
Normal file
195
node_modules/@babel/generator/lib/token-map.js
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TokenMap = void 0;
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
traverseFast,
|
||||
VISITOR_KEYS
|
||||
} = _t;
|
||||
class TokenMap {
|
||||
constructor(ast, tokens, source) {
|
||||
this._tokens = void 0;
|
||||
this._source = void 0;
|
||||
this._nodesToTokenIndexes = new Map();
|
||||
this._nodesOccurrencesCountCache = new Map();
|
||||
this._tokensCache = new Map();
|
||||
this._tokens = tokens;
|
||||
this._source = source;
|
||||
traverseFast(ast, node => {
|
||||
const indexes = this._getTokensIndexesOfNode(node);
|
||||
if (indexes.length > 0) this._nodesToTokenIndexes.set(node, indexes);
|
||||
});
|
||||
this._tokensCache.clear();
|
||||
}
|
||||
has(node) {
|
||||
return this._nodesToTokenIndexes.has(node);
|
||||
}
|
||||
getIndexes(node) {
|
||||
return this._nodesToTokenIndexes.get(node);
|
||||
}
|
||||
find(node, condition) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
for (let k = 0; k < indexes.length; k++) {
|
||||
const index = indexes[k];
|
||||
const tok = this._tokens[index];
|
||||
if (condition(tok, index)) return tok;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
findLastIndex(node, condition) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
for (let k = indexes.length - 1; k >= 0; k--) {
|
||||
const index = indexes[k];
|
||||
const tok = this._tokens[index];
|
||||
if (condition(tok, index)) return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
findMatching(node, test, occurrenceCount = 0) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
if (typeof test === "number") {
|
||||
test = String.fromCharCode(test);
|
||||
}
|
||||
let i = 0;
|
||||
const count = occurrenceCount;
|
||||
if (count > 1) {
|
||||
const cache = this._nodesOccurrencesCountCache.get(node);
|
||||
if ((cache == null ? void 0 : cache.test) === test && cache.count < count) {
|
||||
i = cache.i + 1;
|
||||
occurrenceCount -= cache.count + 1;
|
||||
}
|
||||
}
|
||||
for (; i < indexes.length; i++) {
|
||||
const tok = this._tokens[indexes[i]];
|
||||
if (this.matchesOriginal(tok, test)) {
|
||||
if (occurrenceCount === 0) {
|
||||
if (count > 0) {
|
||||
this._nodesOccurrencesCountCache.set(node, {
|
||||
test,
|
||||
count,
|
||||
i
|
||||
});
|
||||
}
|
||||
return tok;
|
||||
}
|
||||
occurrenceCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
matchesOriginal(token, test) {
|
||||
if (token.end - token.start !== test.length) return false;
|
||||
if (token.value != null) return token.value === test;
|
||||
return this._source.startsWith(test, token.start);
|
||||
}
|
||||
startMatches(node, test) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (!indexes) return false;
|
||||
const tok = this._tokens[indexes[0]];
|
||||
if (tok.start !== node.start) return false;
|
||||
return this.matchesOriginal(tok, test);
|
||||
}
|
||||
endMatches(node, test) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (!indexes) return false;
|
||||
const tok = this._tokens[indexes[indexes.length - 1]];
|
||||
if (tok.end !== node.end) return false;
|
||||
return this.matchesOriginal(tok, test);
|
||||
}
|
||||
_getTokensIndexesOfNode(node) {
|
||||
var _node$declaration;
|
||||
if (node.start == null || node.end == null) return [];
|
||||
const {
|
||||
first,
|
||||
last
|
||||
} = this._findTokensOfNode(node, 0, this._tokens.length - 1);
|
||||
let low = first;
|
||||
const children = childrenIterator(node);
|
||||
if ((node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") && ((_node$declaration = node.declaration) == null ? void 0 : _node$declaration.type) === "ClassDeclaration") {
|
||||
children.next();
|
||||
}
|
||||
const indexes = [];
|
||||
for (const child of children) {
|
||||
if (child == null) continue;
|
||||
if (child.start == null || child.end == null) continue;
|
||||
const childTok = this._findTokensOfNode(child, low, last);
|
||||
const high = childTok.first;
|
||||
for (let k = low; k < high; k++) indexes.push(k);
|
||||
low = childTok.last + 1;
|
||||
}
|
||||
for (let k = low; k <= last; k++) indexes.push(k);
|
||||
return indexes;
|
||||
}
|
||||
_findTokensOfNode(node, low, high) {
|
||||
const cached = this._tokensCache.get(node);
|
||||
if (cached) return cached;
|
||||
const first = this._findFirstTokenOfNode(node.start, low, high);
|
||||
const last = this._findLastTokenOfNode(node.end, first, high);
|
||||
this._tokensCache.set(node, {
|
||||
first,
|
||||
last
|
||||
});
|
||||
return {
|
||||
first,
|
||||
last
|
||||
};
|
||||
}
|
||||
_findFirstTokenOfNode(start, low, high) {
|
||||
while (low <= high) {
|
||||
const mid = high + low >> 1;
|
||||
if (start < this._tokens[mid].start) {
|
||||
high = mid - 1;
|
||||
} else if (start > this._tokens[mid].start) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
return low;
|
||||
}
|
||||
_findLastTokenOfNode(end, low, high) {
|
||||
while (low <= high) {
|
||||
const mid = high + low >> 1;
|
||||
if (end < this._tokens[mid].end) {
|
||||
high = mid - 1;
|
||||
} else if (end > this._tokens[mid].end) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
return high;
|
||||
}
|
||||
}
|
||||
exports.TokenMap = TokenMap;
|
||||
function* childrenIterator(node) {
|
||||
if (node.type === "TemplateLiteral") {
|
||||
yield node.quasis[0];
|
||||
for (let i = 1; i < node.quasis.length; i++) {
|
||||
yield node.expressions[i - 1];
|
||||
yield node.quasis[i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
const keys = VISITOR_KEYS[node.type];
|
||||
for (const key of keys) {
|
||||
const child = node[key];
|
||||
if (!child) continue;
|
||||
if (Array.isArray(child)) {
|
||||
yield* child;
|
||||
} else {
|
||||
yield child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=token-map.js.map
|
||||
Reference in New Issue
Block a user