feat: refactoring project
This commit is contained in:
2
node_modules/@babel/generator/lib/buffer.js.map
generated
vendored
2
node_modules/@babel/generator/lib/buffer.js.map
generated
vendored
File diff suppressed because one or more lines are too long
16
node_modules/@babel/generator/lib/generators/base.js
generated
vendored
16
node_modules/@babel/generator/lib/generators/base.js
generated
vendored
@@ -12,9 +12,9 @@ exports.Placeholder = Placeholder;
|
||||
exports.Program = Program;
|
||||
function File(node) {
|
||||
if (node.program) {
|
||||
this.print(node.program.interpreter, node);
|
||||
this.print(node.program.interpreter);
|
||||
}
|
||||
this.print(node.program, node);
|
||||
this.print(node.program);
|
||||
}
|
||||
function Program(node) {
|
||||
var _node$directives;
|
||||
@@ -24,23 +24,24 @@ function Program(node) {
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai;
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, node, {
|
||||
this.printSequence(node.directives, {
|
||||
trailingCommentsLineOffset: newline
|
||||
});
|
||||
if (!((_node$directives$trai = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai.length)) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
this.printSequence(node.body, node);
|
||||
this.printSequence(node.body);
|
||||
}
|
||||
function BlockStatement(node) {
|
||||
var _node$directives2;
|
||||
this.tokenChar(123);
|
||||
const exit = this.enterDelimited();
|
||||
const directivesLen = (_node$directives2 = node.directives) == null ? void 0 : _node$directives2.length;
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai2;
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, node, {
|
||||
this.printSequence(node.directives, {
|
||||
indent: true,
|
||||
trailingCommentsLineOffset: newline
|
||||
});
|
||||
@@ -48,15 +49,14 @@ function BlockStatement(node) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printSequence(node.body, node, {
|
||||
this.printSequence(node.body, {
|
||||
indent: true
|
||||
});
|
||||
exit();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function Directive(node) {
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
this.semicolon();
|
||||
}
|
||||
const unescapedSingleQuoteRE = /(?:^|[^\\])(?:\\\\)*'/;
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/base.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/base.js.map
generated
vendored
File diff suppressed because one or more lines are too long
105
node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
105
node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
@@ -20,7 +20,7 @@ const {
|
||||
function ClassDeclaration(node, parent) {
|
||||
const inExport = isExportDefaultDeclaration(parent) || isExportNamedDeclaration(parent);
|
||||
if (!inExport || !this._shouldPrintDecoratorsBeforeExport(parent)) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
}
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
@@ -33,24 +33,24 @@ function ClassDeclaration(node, parent) {
|
||||
this.word("class");
|
||||
if (node.id) {
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
}
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeParameters);
|
||||
if (node.superClass) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.superClass, node);
|
||||
this.print(node.superTypeParameters, node);
|
||||
this.print(node.superClass);
|
||||
this.print(node.superTypeParameters);
|
||||
}
|
||||
if (node.implements) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements, node);
|
||||
this.printList(node.implements);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ClassBody(node) {
|
||||
this.tokenChar(123);
|
||||
@@ -58,28 +58,63 @@ function ClassBody(node) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printSequence(node.body, node, {
|
||||
indent: true
|
||||
const separator = classBodyEmptySemicolonsPrinter(this, node);
|
||||
separator == null || separator(-1);
|
||||
const exit = this.enterDelimited();
|
||||
this.printJoin(node.body, {
|
||||
statement: true,
|
||||
indent: true,
|
||||
separator,
|
||||
printTrailingSeparator: true
|
||||
});
|
||||
exit();
|
||||
if (!this.endsWith(10)) this.newline();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
}
|
||||
function classBodyEmptySemicolonsPrinter(printer, node) {
|
||||
if (!printer.tokenMap || node.start == null || node.end == null) {
|
||||
return null;
|
||||
}
|
||||
const indexes = printer.tokenMap.getIndexes(node);
|
||||
if (!indexes) return null;
|
||||
let k = 1;
|
||||
let occurrenceCount = 0;
|
||||
let nextLocIndex = 0;
|
||||
const advanceNextLocIndex = () => {
|
||||
while (nextLocIndex < node.body.length && node.body[nextLocIndex].start == null) {
|
||||
nextLocIndex++;
|
||||
}
|
||||
};
|
||||
advanceNextLocIndex();
|
||||
return i => {
|
||||
if (nextLocIndex <= i) {
|
||||
nextLocIndex = i + 1;
|
||||
advanceNextLocIndex();
|
||||
}
|
||||
const end = nextLocIndex === node.body.length ? node.end : node.body[nextLocIndex].start;
|
||||
let tok;
|
||||
while (k < indexes.length && printer.tokenMap.matchesOriginal(tok = printer._tokens[indexes[k]], ";") && tok.start < end) {
|
||||
printer.token(";", undefined, occurrenceCount++);
|
||||
k++;
|
||||
}
|
||||
};
|
||||
}
|
||||
function ClassProperty(node) {
|
||||
var _node$key$loc;
|
||||
this.printJoin(node.decorators, node);
|
||||
const endLine = (_node$key$loc = node.key.loc) == null || (_node$key$loc = _node$key$loc.end) == null ? void 0 : _node$key$loc.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.printJoin(node.decorators);
|
||||
if (!node.static && !this.format.preserveFormat) {
|
||||
var _node$key$loc;
|
||||
const endLine = (_node$key$loc = node.key.loc) == null || (_node$key$loc = _node$key$loc.end) == null ? void 0 : _node$key$loc.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
}
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this._variance(node);
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
@@ -87,18 +122,18 @@ function ClassProperty(node) {
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassAccessorProperty(node) {
|
||||
var _node$key$loc2;
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
const endLine = (_node$key$loc2 = node.key.loc) == null || (_node$key$loc2 = _node$key$loc2.end) == null ? void 0 : _node$key$loc2.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
@@ -106,11 +141,11 @@ function ClassAccessorProperty(node) {
|
||||
this.space();
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this._variance(node);
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
@@ -118,46 +153,48 @@ function ClassAccessorProperty(node) {
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassPrivateProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.key, node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.key);
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ClassPrivateMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function _classMethodHead(node) {
|
||||
var _node$key$loc3;
|
||||
this.printJoin(node.decorators, node);
|
||||
const endLine = (_node$key$loc3 = node.key.loc) == null || (_node$key$loc3 = _node$key$loc3.end) == null ? void 0 : _node$key$loc3.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.printJoin(node.decorators);
|
||||
if (!this.format.preserveFormat) {
|
||||
var _node$key$loc3;
|
||||
const endLine = (_node$key$loc3 = node.key.loc) == null || (_node$key$loc3 = _node$key$loc3.end) == null ? void 0 : _node$key$loc3.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
}
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
this._methodHead(node);
|
||||
}
|
||||
@@ -169,7 +206,7 @@ function StaticBlock(node) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
this.printSequence(node.body, node, {
|
||||
this.printSequence(node.body, {
|
||||
indent: true
|
||||
});
|
||||
this.rightBrace(node);
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/classes.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/classes.js.map
generated
vendored
File diff suppressed because one or more lines are too long
109
node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
109
node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
@@ -36,7 +36,8 @@ const {
|
||||
isCallExpression,
|
||||
isLiteral,
|
||||
isMemberExpression,
|
||||
isNewExpression
|
||||
isNewExpression,
|
||||
isPattern
|
||||
} = _t;
|
||||
function UnaryExpression(node) {
|
||||
const {
|
||||
@@ -48,7 +49,7 @@ function UnaryExpression(node) {
|
||||
} else {
|
||||
this.token(operator);
|
||||
}
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
function DoExpression(node) {
|
||||
if (node.async) {
|
||||
@@ -57,55 +58,62 @@ function DoExpression(node) {
|
||||
}
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ParenthesizedExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression, node);
|
||||
const exit = this.enterDelimited();
|
||||
this.print(node.expression);
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function UpdateExpression(node) {
|
||||
if (node.prefix) {
|
||||
this.token(node.operator);
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
} else {
|
||||
this.printTerminatorless(node.argument, node, true);
|
||||
this.print(node.argument, true);
|
||||
this.token(node.operator);
|
||||
}
|
||||
}
|
||||
function ConditionalExpression(node) {
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.space();
|
||||
this.tokenChar(63);
|
||||
this.space();
|
||||
this.print(node.consequent, node);
|
||||
this.print(node.consequent);
|
||||
this.space();
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.alternate, node);
|
||||
this.print(node.alternate);
|
||||
}
|
||||
function NewExpression(node, parent) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.print(node.callee, node);
|
||||
this.print(node.callee);
|
||||
if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, {
|
||||
callee: node
|
||||
}) && !isMemberExpression(parent) && !isNewExpression(parent)) {
|
||||
return;
|
||||
}
|
||||
this.print(node.typeArguments, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeArguments);
|
||||
this.print(node.typeParameters);
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
if (node.arguments.length === 0 && this.tokenMap && !this.tokenMap.endMatches(node, ")")) {
|
||||
return;
|
||||
}
|
||||
this.tokenChar(40);
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printList(node.arguments, node);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma(")")
|
||||
});
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function SequenceExpression(node) {
|
||||
this.printList(node.expressions, node);
|
||||
this.printList(node.expressions);
|
||||
}
|
||||
function ThisExpression() {
|
||||
this.word("this");
|
||||
@@ -121,7 +129,7 @@ function _shouldPrintDecoratorsBeforeExport(node) {
|
||||
}
|
||||
function Decorator(node) {
|
||||
this.tokenChar(64);
|
||||
this.print(node.expression, node);
|
||||
this.print(node.expression);
|
||||
this.newline();
|
||||
}
|
||||
function OptionalMemberExpression(node) {
|
||||
@@ -132,7 +140,7 @@ function OptionalMemberExpression(node) {
|
||||
optional,
|
||||
property
|
||||
} = node;
|
||||
this.print(node.object, node);
|
||||
this.print(node.object);
|
||||
if (!computed && isMemberExpression(property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
@@ -144,35 +152,37 @@ function OptionalMemberExpression(node) {
|
||||
}
|
||||
if (computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(property, node);
|
||||
this.print(property);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (!optional) {
|
||||
this.tokenChar(46);
|
||||
}
|
||||
this.print(property, node);
|
||||
this.print(property);
|
||||
}
|
||||
}
|
||||
function OptionalCallExpression(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.callee);
|
||||
this.print(node.typeParameters);
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
this.print(node.typeArguments, node);
|
||||
this.print(node.typeArguments);
|
||||
this.tokenChar(40);
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printList(node.arguments, node);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments);
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function CallExpression(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.typeArguments, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.callee);
|
||||
this.print(node.typeArguments);
|
||||
this.print(node.typeParameters);
|
||||
this.tokenChar(40);
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printList(node.arguments, node);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma(")")
|
||||
});
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
@@ -183,7 +193,7 @@ function AwaitExpression(node) {
|
||||
this.word("await");
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
this.printTerminatorless(node.argument);
|
||||
}
|
||||
}
|
||||
function YieldExpression(node) {
|
||||
@@ -192,12 +202,12 @@ function YieldExpression(node) {
|
||||
this.tokenChar(42);
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
} else {
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
this.printTerminatorless(node.argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,38 +216,39 @@ function EmptyStatement() {
|
||||
}
|
||||
function ExpressionStatement(node) {
|
||||
this.tokenContext |= _index.TokenContext.expressionStatement;
|
||||
this.print(node.expression, node);
|
||||
this.print(node.expression);
|
||||
this.semicolon();
|
||||
}
|
||||
function AssignmentPattern(node) {
|
||||
this.print(node.left, node);
|
||||
if (node.left.type === "Identifier") {
|
||||
this.print(node.left);
|
||||
if (node.left.type === "Identifier" || isPattern(node.left)) {
|
||||
if (node.left.optional) this.tokenChar(63);
|
||||
this.print(node.left.typeAnnotation, node);
|
||||
this.print(node.left.typeAnnotation);
|
||||
}
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.print(node.right);
|
||||
}
|
||||
function AssignmentExpression(node) {
|
||||
this.print(node.left, node);
|
||||
this.print(node.left);
|
||||
this.space();
|
||||
if (node.operator === "in" || node.operator === "instanceof") {
|
||||
this.word(node.operator);
|
||||
} else {
|
||||
this.token(node.operator);
|
||||
this._endsWithDiv = node.operator === "/";
|
||||
}
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.print(node.right);
|
||||
}
|
||||
function BindExpression(node) {
|
||||
this.print(node.object, node);
|
||||
this.print(node.object);
|
||||
this.token("::");
|
||||
this.print(node.callee, node);
|
||||
this.print(node.callee);
|
||||
}
|
||||
function MemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
this.print(node.object);
|
||||
if (!node.computed && isMemberExpression(node.property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
@@ -246,24 +257,24 @@ function MemberExpression(node) {
|
||||
computed = true;
|
||||
}
|
||||
if (computed) {
|
||||
const exit = this.enterForStatementInit(false);
|
||||
const exit = this.enterDelimited();
|
||||
this.tokenChar(91);
|
||||
this.print(node.property, node);
|
||||
this.print(node.property);
|
||||
this.tokenChar(93);
|
||||
exit();
|
||||
} else {
|
||||
this.tokenChar(46);
|
||||
this.print(node.property, node);
|
||||
this.print(node.property);
|
||||
}
|
||||
}
|
||||
function MetaProperty(node) {
|
||||
this.print(node.meta, node);
|
||||
this.print(node.meta);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property, node);
|
||||
this.print(node.property);
|
||||
}
|
||||
function PrivateName(node) {
|
||||
this.tokenChar(35);
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
}
|
||||
function V8IntrinsicIdentifier(node) {
|
||||
this.tokenChar(37);
|
||||
@@ -280,7 +291,7 @@ function ModuleExpression(node) {
|
||||
if (body.body.length || body.directives.length) {
|
||||
this.newline();
|
||||
}
|
||||
this.print(body, node);
|
||||
this.print(body);
|
||||
this.dedent();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/expressions.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/expressions.js.map
generated
vendored
File diff suppressed because one or more lines are too long
152
node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
152
node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
@@ -89,7 +89,7 @@ function AnyTypeAnnotation() {
|
||||
this.word("any");
|
||||
}
|
||||
function ArrayTypeAnnotation(node) {
|
||||
this.print(node.elementType, node, true);
|
||||
this.print(node.elementType, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
@@ -118,11 +118,11 @@ function DeclareFunction(node, parent) {
|
||||
}
|
||||
this.word("function");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id.typeAnnotation.typeAnnotation, node);
|
||||
this.print(node.id);
|
||||
this.print(node.id.typeAnnotation.typeAnnotation);
|
||||
if (node.predicate) {
|
||||
this.space();
|
||||
this.print(node.predicate, node);
|
||||
this.print(node.predicate);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ function DeclaredPredicate(node) {
|
||||
this.tokenChar(37);
|
||||
this.word("checks");
|
||||
this.tokenChar(40);
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function DeclareInterface(node) {
|
||||
@@ -147,9 +147,9 @@ function DeclareModule(node) {
|
||||
this.space();
|
||||
this.word("module");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function DeclareModuleExports(node) {
|
||||
this.word("declare");
|
||||
@@ -157,7 +157,7 @@ function DeclareModuleExports(node) {
|
||||
this.word("module");
|
||||
this.tokenChar(46);
|
||||
this.word("exports");
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function DeclareTypeAlias(node) {
|
||||
this.word("declare");
|
||||
@@ -178,8 +178,8 @@ function DeclareVariable(node, parent) {
|
||||
}
|
||||
this.word("var");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
this.print(node.id);
|
||||
this.print(node.id.typeAnnotation);
|
||||
this.semicolon();
|
||||
}
|
||||
function DeclareExportDeclaration(node) {
|
||||
@@ -205,8 +205,8 @@ function EnumDeclaration(node) {
|
||||
} = node;
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(body, node);
|
||||
this.print(id);
|
||||
this.print(body);
|
||||
}
|
||||
function enumExplicitType(context, name, hasExplicitType) {
|
||||
if (hasExplicitType) {
|
||||
@@ -225,7 +225,7 @@ function enumBody(context, node) {
|
||||
context.indent();
|
||||
context.newline();
|
||||
for (const member of members) {
|
||||
context.print(member, node);
|
||||
context.print(member);
|
||||
context.newline();
|
||||
}
|
||||
if (node.hasUnknownMembers) {
|
||||
@@ -264,19 +264,15 @@ function EnumDefaultedMember(node) {
|
||||
const {
|
||||
id
|
||||
} = node;
|
||||
this.print(id, node);
|
||||
this.print(id);
|
||||
this.tokenChar(44);
|
||||
}
|
||||
function enumInitializedMember(context, node) {
|
||||
const {
|
||||
id,
|
||||
init
|
||||
} = node;
|
||||
context.print(id, node);
|
||||
context.print(node.id);
|
||||
context.space();
|
||||
context.token("=");
|
||||
context.space();
|
||||
context.print(init, node);
|
||||
context.print(node.init);
|
||||
context.token(",");
|
||||
}
|
||||
function EnumBooleanMember(node) {
|
||||
@@ -291,13 +287,13 @@ function EnumStringMember(node) {
|
||||
function FlowExportDeclaration(node) {
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
this.tokenChar(123);
|
||||
if (node.specifiers.length) {
|
||||
this.space();
|
||||
this.printList(node.specifiers, node);
|
||||
this.printList(node.specifiers);
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(125);
|
||||
@@ -305,7 +301,7 @@ function FlowExportDeclaration(node) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -314,26 +310,26 @@ function ExistsTypeAnnotation() {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeParameters);
|
||||
this.tokenChar(40);
|
||||
if (node.this) {
|
||||
this.word("this");
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.this.typeAnnotation, node);
|
||||
this.print(node.this.typeAnnotation);
|
||||
if (node.params.length || node.rest) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
this.printList(node.params, node);
|
||||
this.printList(node.params);
|
||||
if (node.rest) {
|
||||
if (node.params.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
this.token("...");
|
||||
this.print(node.rest, node);
|
||||
this.print(node.rest);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
const type = parent == null ? void 0 : parent.type;
|
||||
@@ -344,30 +340,30 @@ function FunctionTypeAnnotation(node, parent) {
|
||||
this.token("=>");
|
||||
}
|
||||
this.space();
|
||||
this.print(node.returnType, node);
|
||||
this.print(node.returnType);
|
||||
}
|
||||
function FunctionTypeParam(node) {
|
||||
this.print(node.name, node);
|
||||
this.print(node.name);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (node.name) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function InterfaceExtends(node) {
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node, true);
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters, true);
|
||||
}
|
||||
function _interfaceish(node) {
|
||||
var _node$extends;
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
if ((_node$extends = node.extends) != null && _node$extends.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends, node);
|
||||
this.printList(node.extends);
|
||||
}
|
||||
if (node.type === "DeclareClass") {
|
||||
var _node$mixins, _node$implements;
|
||||
@@ -375,17 +371,17 @@ function _interfaceish(node) {
|
||||
this.space();
|
||||
this.word("mixins");
|
||||
this.space();
|
||||
this.printList(node.mixins, node);
|
||||
this.printList(node.mixins);
|
||||
}
|
||||
if ((_node$implements = node.implements) != null && _node$implements.length) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements, node);
|
||||
this.printList(node.implements);
|
||||
}
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function _variance(node) {
|
||||
var _node$variance;
|
||||
@@ -403,9 +399,9 @@ function InterfaceDeclaration(node) {
|
||||
this.space();
|
||||
this._interfaceish(node);
|
||||
}
|
||||
function andSeparator() {
|
||||
function andSeparator(occurrenceCount) {
|
||||
this.space();
|
||||
this.tokenChar(38);
|
||||
this.token("&", false, occurrenceCount);
|
||||
this.space();
|
||||
}
|
||||
function InterfaceTypeAnnotation(node) {
|
||||
@@ -415,13 +411,13 @@ function InterfaceTypeAnnotation(node) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends, node);
|
||||
this.printList(node.extends);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function IntersectionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, node, {
|
||||
this.printJoin(node.types, {
|
||||
separator: andSeparator
|
||||
});
|
||||
}
|
||||
@@ -433,7 +429,7 @@ function EmptyTypeAnnotation() {
|
||||
}
|
||||
function NullableTypeAnnotation(node) {
|
||||
this.tokenChar(63);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function NumberTypeAnnotation() {
|
||||
this.word("number");
|
||||
@@ -446,23 +442,23 @@ function ThisTypeAnnotation() {
|
||||
}
|
||||
function TupleTypeAnnotation(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.types, node);
|
||||
this.printList(node.types);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TypeofTypeAnnotation(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
function TypeAlias(node) {
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.print(node.right);
|
||||
this.semicolon();
|
||||
}
|
||||
function TypeAnnotation(node, parent) {
|
||||
@@ -473,24 +469,24 @@ function TypeAnnotation(node, parent) {
|
||||
} else if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TypeParameterInstantiation(node) {
|
||||
this.tokenChar(60);
|
||||
this.printList(node.params, node, {});
|
||||
this.printList(node.params, {});
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function TypeParameter(node) {
|
||||
this._variance(node);
|
||||
this.word(node.name);
|
||||
if (node.bound) {
|
||||
this.print(node.bound, node);
|
||||
this.print(node.bound);
|
||||
}
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
this.print(node.default);
|
||||
}
|
||||
}
|
||||
function OpaqueType(node) {
|
||||
@@ -498,18 +494,18 @@ function OpaqueType(node) {
|
||||
this.space();
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
if (node.supertype) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.supertype, node);
|
||||
this.print(node.supertype);
|
||||
}
|
||||
if (node.impltype) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.impltype, node);
|
||||
this.print(node.impltype);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -523,7 +519,7 @@ function ObjectTypeAnnotation(node) {
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
this.space();
|
||||
this.printJoin(props, node, {
|
||||
this.printJoin(props, {
|
||||
addNewlines(leading) {
|
||||
if (leading && !props[0]) return 1;
|
||||
},
|
||||
@@ -559,7 +555,7 @@ function ObjectTypeInternalSlot(node) {
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(91);
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(93);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
@@ -567,14 +563,14 @@ function ObjectTypeInternalSlot(node) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeCallProperty(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeIndexer(node) {
|
||||
if (node.static) {
|
||||
@@ -584,15 +580,15 @@ function ObjectTypeIndexer(node) {
|
||||
this._variance(node);
|
||||
this.tokenChar(91);
|
||||
if (node.id) {
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeProperty(node) {
|
||||
if (node.proto) {
|
||||
@@ -608,40 +604,40 @@ function ObjectTypeProperty(node) {
|
||||
this.space();
|
||||
}
|
||||
this._variance(node);
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (!node.method) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeSpreadProperty(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
function QualifiedTypeIdentifier(node) {
|
||||
this.print(node.qualification, node);
|
||||
this.print(node.qualification);
|
||||
this.tokenChar(46);
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
}
|
||||
function SymbolTypeAnnotation() {
|
||||
this.word("symbol");
|
||||
}
|
||||
function orSeparator() {
|
||||
function orSeparator(occurrenceCount) {
|
||||
this.space();
|
||||
this.tokenChar(124);
|
||||
this.token("|", false, occurrenceCount);
|
||||
this.space();
|
||||
}
|
||||
function UnionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, node, {
|
||||
this.printJoin(node.types, {
|
||||
separator: orSeparator
|
||||
});
|
||||
}
|
||||
function TypeCastExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.expression);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function Variance(node) {
|
||||
@@ -655,18 +651,18 @@ function VoidTypeAnnotation() {
|
||||
this.word("void");
|
||||
}
|
||||
function IndexedAccessType(node) {
|
||||
this.print(node.objectType, node, true);
|
||||
this.print(node.objectType, true);
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType, node);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function OptionalIndexedAccessType(node) {
|
||||
this.print(node.objectType, node);
|
||||
this.print(node.objectType);
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType, node);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/flow.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/flow.js.map
generated
vendored
File diff suppressed because one or more lines are too long
52
node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
52
node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
@@ -19,41 +19,41 @@ exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
||||
exports.JSXSpreadChild = JSXSpreadChild;
|
||||
exports.JSXText = JSXText;
|
||||
function JSXAttribute(node) {
|
||||
this.print(node.name, node);
|
||||
this.print(node.name);
|
||||
if (node.value) {
|
||||
this.tokenChar(61);
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
}
|
||||
function JSXIdentifier(node) {
|
||||
this.word(node.name);
|
||||
}
|
||||
function JSXNamespacedName(node) {
|
||||
this.print(node.namespace, node);
|
||||
this.print(node.namespace);
|
||||
this.tokenChar(58);
|
||||
this.print(node.name, node);
|
||||
this.print(node.name);
|
||||
}
|
||||
function JSXMemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
this.print(node.object);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property, node);
|
||||
this.print(node.property);
|
||||
}
|
||||
function JSXSpreadAttribute(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
this.tokenChar(125);
|
||||
this.print(node.argument);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXExpressionContainer(node) {
|
||||
this.tokenChar(123);
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(125);
|
||||
this.print(node.expression);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXSpreadChild(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(125);
|
||||
this.print(node.expression);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXText(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
@@ -65,51 +65,51 @@ function JSXText(node) {
|
||||
}
|
||||
function JSXElement(node) {
|
||||
const open = node.openingElement;
|
||||
this.print(open, node);
|
||||
this.print(open);
|
||||
if (open.selfClosing) return;
|
||||
this.indent();
|
||||
for (const child of node.children) {
|
||||
this.print(child, node);
|
||||
this.print(child);
|
||||
}
|
||||
this.dedent();
|
||||
this.print(node.closingElement, node);
|
||||
this.print(node.closingElement);
|
||||
}
|
||||
function spaceSeparator() {
|
||||
this.space();
|
||||
}
|
||||
function JSXOpeningElement(node) {
|
||||
this.tokenChar(60);
|
||||
this.print(node.name, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.name);
|
||||
this.print(node.typeParameters);
|
||||
if (node.attributes.length > 0) {
|
||||
this.space();
|
||||
this.printJoin(node.attributes, node, {
|
||||
this.printJoin(node.attributes, {
|
||||
separator: spaceSeparator
|
||||
});
|
||||
}
|
||||
if (node.selfClosing) {
|
||||
this.space();
|
||||
this.token("/>");
|
||||
} else {
|
||||
this.tokenChar(62);
|
||||
this.tokenChar(47);
|
||||
}
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXClosingElement(node) {
|
||||
this.token("</");
|
||||
this.print(node.name, node);
|
||||
this.tokenChar(60);
|
||||
this.tokenChar(47);
|
||||
this.print(node.name);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXEmptyExpression() {
|
||||
this.printInnerComments();
|
||||
}
|
||||
function JSXFragment(node) {
|
||||
this.print(node.openingFragment, node);
|
||||
this.print(node.openingFragment);
|
||||
this.indent();
|
||||
for (const child of node.children) {
|
||||
this.print(child, node);
|
||||
this.print(child);
|
||||
}
|
||||
this.dedent();
|
||||
this.print(node.closingFragment, node);
|
||||
this.print(node.closingFragment);
|
||||
}
|
||||
function JSXOpeningFragment() {
|
||||
this.tokenChar(60);
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/jsx.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/jsx.js.map
generated
vendored
File diff suppressed because one or more lines are too long
77
node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
77
node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
@@ -11,43 +11,45 @@ exports._param = _param;
|
||||
exports._parameters = _parameters;
|
||||
exports._params = _params;
|
||||
exports._predicate = _predicate;
|
||||
exports._shouldPrintArrowParamsParens = _shouldPrintArrowParamsParens;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isIdentifier
|
||||
} = _t;
|
||||
function _params(node, idNode, parentNode) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeParameters);
|
||||
const nameInfo = _getFuncIdName.call(this, idNode, parentNode);
|
||||
if (nameInfo) {
|
||||
this.sourceIdentifierName(nameInfo.name, nameInfo.pos);
|
||||
}
|
||||
this.tokenChar(40);
|
||||
this._parameters(node.params, node);
|
||||
this.tokenChar(41);
|
||||
this._parameters(node.params, ")");
|
||||
const noLineTerminator = node.type === "ArrowFunctionExpression";
|
||||
this.print(node.returnType, node, noLineTerminator);
|
||||
this.print(node.returnType, noLineTerminator);
|
||||
this._noLineTerminator = noLineTerminator;
|
||||
}
|
||||
function _parameters(parameters, parent) {
|
||||
const exit = this.enterForStatementInit(false);
|
||||
function _parameters(parameters, endToken) {
|
||||
const exit = this.enterDelimited();
|
||||
const trailingComma = this.shouldPrintTrailingComma(endToken);
|
||||
const paramLength = parameters.length;
|
||||
for (let i = 0; i < paramLength; i++) {
|
||||
this._param(parameters[i], parent);
|
||||
if (i < parameters.length - 1) {
|
||||
this.tokenChar(44);
|
||||
this._param(parameters[i]);
|
||||
if (trailingComma || i < paramLength - 1) {
|
||||
this.token(",", null, i);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
this.token(endToken);
|
||||
exit();
|
||||
}
|
||||
function _param(parameter, parent) {
|
||||
this.printJoin(parameter.decorators, parameter);
|
||||
this.print(parameter, parent);
|
||||
function _param(parameter) {
|
||||
this.printJoin(parameter.decorators);
|
||||
this.print(parameter);
|
||||
if (parameter.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this.print(parameter.typeAnnotation, parameter);
|
||||
this.print(parameter.typeAnnotation);
|
||||
}
|
||||
function _methodHead(node) {
|
||||
const kind = node.kind;
|
||||
@@ -67,10 +69,10 @@ function _methodHead(node) {
|
||||
}
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(key, node);
|
||||
this.print(key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this.print(key, node);
|
||||
this.print(key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
@@ -83,23 +85,27 @@ function _predicate(node, noLineTerminatorAfter) {
|
||||
this.tokenChar(58);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.predicate, node, noLineTerminatorAfter);
|
||||
this.print(node.predicate, noLineTerminatorAfter);
|
||||
}
|
||||
}
|
||||
function _functionHead(node, parent) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this._endsWithInnerRaw = false;
|
||||
if (!this.format.preserveFormat) {
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
this.space();
|
||||
}
|
||||
this.word("function");
|
||||
if (node.generator) {
|
||||
this._endsWithInnerRaw = false;
|
||||
if (!this.format.preserveFormat) {
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
this.tokenChar(42);
|
||||
}
|
||||
this.space();
|
||||
if (node.id) {
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
}
|
||||
this._params(node, node.id, parent);
|
||||
if (node.type !== "TSDeclareFunction") {
|
||||
@@ -109,18 +115,17 @@ function _functionHead(node, parent) {
|
||||
function FunctionExpression(node, parent) {
|
||||
this._functionHead(node, parent);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ArrowFunctionExpression(node, parent) {
|
||||
if (node.async) {
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
let firstParam;
|
||||
if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) {
|
||||
this.print(firstParam, node, true);
|
||||
} else {
|
||||
if (this._shouldPrintArrowParamsParens(node)) {
|
||||
this._params(node, undefined, parent);
|
||||
} else {
|
||||
this.print(node.params[0], true);
|
||||
}
|
||||
this._predicate(node, true);
|
||||
this.space();
|
||||
@@ -128,11 +133,27 @@ function ArrowFunctionExpression(node, parent) {
|
||||
this.token("=>");
|
||||
this.space();
|
||||
this.tokenContext |= _index.TokenContext.arrowBody;
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function hasTypesOrComments(node, param) {
|
||||
var _param$leadingComment, _param$trailingCommen;
|
||||
return !!(node.typeParameters || node.returnType || node.predicate || param.typeAnnotation || param.optional || (_param$leadingComment = param.leadingComments) != null && _param$leadingComment.length || (_param$trailingCommen = param.trailingComments) != null && _param$trailingCommen.length);
|
||||
function _shouldPrintArrowParamsParens(node) {
|
||||
var _firstParam$leadingCo, _firstParam$trailingC;
|
||||
if (node.params.length !== 1) return true;
|
||||
if (node.typeParameters || node.returnType || node.predicate) {
|
||||
return true;
|
||||
}
|
||||
const firstParam = node.params[0];
|
||||
if (!isIdentifier(firstParam) || firstParam.typeAnnotation || firstParam.optional || (_firstParam$leadingCo = firstParam.leadingComments) != null && _firstParam$leadingCo.length || (_firstParam$trailingC = firstParam.trailingComments) != null && _firstParam$trailingC.length) {
|
||||
return true;
|
||||
}
|
||||
if (this.tokenMap) {
|
||||
if (node.loc == null) return true;
|
||||
if (this.tokenMap.findMatching(node, "(") !== null) return true;
|
||||
const arrowToken = this.tokenMap.findMatching(node, "=>");
|
||||
if ((arrowToken == null ? void 0 : arrowToken.loc) == null) return true;
|
||||
return arrowToken.loc.start.line !== node.loc.start.line;
|
||||
}
|
||||
if (this.format.retainLines) return true;
|
||||
return false;
|
||||
}
|
||||
function _getFuncIdName(idNode, parent) {
|
||||
let id = idNode;
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/methods.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/methods.js.map
generated
vendored
File diff suppressed because one or more lines are too long
74
node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
74
node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
@@ -31,31 +31,31 @@ function ImportSpecifier(node) {
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.imported, node);
|
||||
this.print(node.imported);
|
||||
if (node.local && node.local.name !== node.imported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local, node);
|
||||
this.print(node.local);
|
||||
}
|
||||
}
|
||||
function ImportDefaultSpecifier(node) {
|
||||
this.print(node.local, node);
|
||||
this.print(node.local);
|
||||
}
|
||||
function ExportDefaultSpecifier(node) {
|
||||
this.print(node.exported, node);
|
||||
this.print(node.exported);
|
||||
}
|
||||
function ExportSpecifier(node) {
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.local, node);
|
||||
this.print(node.local);
|
||||
if (node.exported && node.local.name !== node.exported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported, node);
|
||||
this.print(node.exported);
|
||||
}
|
||||
}
|
||||
function ExportNamespaceSpecifier(node) {
|
||||
@@ -63,10 +63,10 @@ function ExportNamespaceSpecifier(node) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported, node);
|
||||
this.print(node.exported);
|
||||
}
|
||||
let warningShown = false;
|
||||
function _printAttributes(node) {
|
||||
function _printAttributes(node, hasPreviousBrace) {
|
||||
const {
|
||||
importAttributesKeyword
|
||||
} = this.format;
|
||||
@@ -88,14 +88,17 @@ Please specify the "importAttributesKeyword" generator option, whose value can b
|
||||
this.word(useAssertKeyword ? "assert" : "with");
|
||||
this.space();
|
||||
if (!useAssertKeyword && importAttributesKeyword !== "with") {
|
||||
this.printList(attributes || assertions, node);
|
||||
this.printList(attributes || assertions);
|
||||
return;
|
||||
}
|
||||
this.tokenChar(123);
|
||||
const occurrenceCount = hasPreviousBrace ? 1 : 0;
|
||||
this.token("{", null, occurrenceCount);
|
||||
this.space();
|
||||
this.printList(attributes || assertions, node);
|
||||
this.printList(attributes || assertions, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("}")
|
||||
});
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
this.token("}", null, occurrenceCount);
|
||||
}
|
||||
function ExportAllDeclaration(node) {
|
||||
var _node$attributes, _node$assertions;
|
||||
@@ -110,17 +113,17 @@ function ExportAllDeclaration(node) {
|
||||
this.word("from");
|
||||
this.space();
|
||||
if ((_node$attributes = node.attributes) != null && _node$attributes.length || (_node$assertions = node.assertions) != null && _node$assertions.length) {
|
||||
this.print(node.source, node, true);
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
this._printAttributes(node);
|
||||
this._printAttributes(node, false);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function maybePrintDecoratorsBeforeExport(printer, node) {
|
||||
if (isClassDeclaration(node.declaration) && printer._shouldPrintDecoratorsBeforeExport(node)) {
|
||||
printer.printJoin(node.declaration.decorators, node);
|
||||
printer.printJoin(node.declaration.decorators);
|
||||
}
|
||||
}
|
||||
function ExportNamedDeclaration(node) {
|
||||
@@ -129,7 +132,7 @@ function ExportNamedDeclaration(node) {
|
||||
this.space();
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
if (node.exportKind === "type") {
|
||||
@@ -142,7 +145,7 @@ function ExportNamedDeclaration(node) {
|
||||
const first = specifiers[0];
|
||||
if (isExportDefaultSpecifier(first) || isExportNamespaceSpecifier(first)) {
|
||||
hasSpecial = true;
|
||||
this.print(specifiers.shift(), node);
|
||||
this.print(specifiers.shift());
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
@@ -151,11 +154,15 @@ function ExportNamedDeclaration(node) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasBrace = false;
|
||||
if (specifiers.length || !specifiers.length && !hasSpecial) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
if (specifiers.length) {
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.printList(specifiers, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("}")
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(125);
|
||||
@@ -166,11 +173,11 @@ function ExportNamedDeclaration(node) {
|
||||
this.word("from");
|
||||
this.space();
|
||||
if ((_node$attributes2 = node.attributes) != null && _node$attributes2.length || (_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
|
||||
this.print(node.source, node, true);
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
this._printAttributes(node);
|
||||
this._printAttributes(node, hasBrace);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
}
|
||||
}
|
||||
this.semicolon();
|
||||
@@ -185,7 +192,7 @@ function ExportDefaultDeclaration(node) {
|
||||
this.space();
|
||||
this.tokenContext |= _index.TokenContext.exportDefault;
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
}
|
||||
function ImportDeclaration(node) {
|
||||
@@ -211,7 +218,7 @@ function ImportDeclaration(node) {
|
||||
while (hasSpecifiers) {
|
||||
const first = specifiers[0];
|
||||
if (isImportDefaultSpecifier(first) || isImportNamespaceSpecifier(first)) {
|
||||
this.print(specifiers.shift(), node);
|
||||
this.print(specifiers.shift());
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
@@ -220,13 +227,18 @@ function ImportDeclaration(node) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasBrace = false;
|
||||
if (specifiers.length) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.printList(specifiers, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("}")
|
||||
});
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
} else if (isTypeKind && !hasSpecifiers) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
@@ -236,11 +248,11 @@ function ImportDeclaration(node) {
|
||||
this.space();
|
||||
}
|
||||
if ((_node$attributes3 = node.attributes) != null && _node$attributes3.length || (_node$assertions3 = node.assertions) != null && _node$assertions3.length) {
|
||||
this.print(node.source, node, true);
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
this._printAttributes(node);
|
||||
this._printAttributes(node, hasBrace);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -255,7 +267,7 @@ function ImportNamespaceSpecifier(node) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local, node);
|
||||
this.print(node.local);
|
||||
}
|
||||
function ImportExpression(node) {
|
||||
this.word("import");
|
||||
@@ -264,11 +276,11 @@ function ImportExpression(node) {
|
||||
this.word(node.phase);
|
||||
}
|
||||
this.tokenChar(40);
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
if (node.options != null) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
this.print(node.options, node);
|
||||
this.print(node.options);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/modules.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/modules.js.map
generated
vendored
File diff suppressed because one or more lines are too long
80
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
80
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
@@ -33,7 +33,7 @@ function WithStatement(node) {
|
||||
this.word("with");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.object, node);
|
||||
this.print(node.object);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
@@ -50,7 +50,7 @@ function IfStatement(node) {
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
this.printAndIndentOnComments(node.consequent, node);
|
||||
this.printAndIndentOnComments(node.consequent);
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
@@ -60,7 +60,7 @@ function IfStatement(node) {
|
||||
if (this.endsWith(125)) this.space();
|
||||
this.word("else");
|
||||
this.space();
|
||||
this.printAndIndentOnComments(node.alternate, node);
|
||||
this.printAndIndentOnComments(node.alternate);
|
||||
}
|
||||
}
|
||||
function getLastStatement(statement) {
|
||||
@@ -77,20 +77,20 @@ function ForStatement(node) {
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
{
|
||||
const exit = this.enterForStatementInit(true);
|
||||
const exit = this.enterForStatementInit();
|
||||
this.tokenContext |= _index.TokenContext.forHead;
|
||||
this.print(node.init, node);
|
||||
this.print(node.init);
|
||||
exit();
|
||||
}
|
||||
this.tokenChar(59);
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
}
|
||||
this.tokenChar(59);
|
||||
this.token(";", false, 1);
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update, node);
|
||||
this.print(node.update);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
@@ -99,7 +99,7 @@ function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -114,15 +114,15 @@ function ForXStatement(node) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
{
|
||||
const exit = isForOf ? null : this.enterForStatementInit(true);
|
||||
const exit = isForOf ? null : this.enterForStatementInit();
|
||||
this.tokenContext |= isForOf ? _index.TokenContext.forOfHead : _index.TokenContext.forInHead;
|
||||
this.print(node.left, node);
|
||||
this.print(node.left);
|
||||
exit == null || exit();
|
||||
}
|
||||
this.space();
|
||||
this.word(isForOf ? "of" : "in");
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.print(node.right);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -131,59 +131,59 @@ const ForOfStatement = exports.ForOfStatement = ForXStatement;
|
||||
function DoWhileStatement(node) {
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
this.space();
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.semicolon();
|
||||
}
|
||||
function printStatementAfterKeyword(printer, node, parent, isLabel) {
|
||||
function printStatementAfterKeyword(printer, node) {
|
||||
if (node) {
|
||||
printer.space();
|
||||
printer.printTerminatorless(node, parent, isLabel);
|
||||
printer.printTerminatorless(node);
|
||||
}
|
||||
printer.semicolon();
|
||||
}
|
||||
function BreakStatement(node) {
|
||||
this.word("break");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ContinueStatement(node) {
|
||||
this.word("continue");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ReturnStatement(node) {
|
||||
this.word("return");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function ThrowStatement(node) {
|
||||
this.word("throw");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function LabeledStatement(node) {
|
||||
this.print(node.label, node);
|
||||
this.print(node.label);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function TryStatement(node) {
|
||||
this.word("try");
|
||||
this.space();
|
||||
this.print(node.block, node);
|
||||
this.print(node.block);
|
||||
this.space();
|
||||
if (node.handlers) {
|
||||
this.print(node.handlers[0], node);
|
||||
this.print(node.handlers[0]);
|
||||
} else {
|
||||
this.print(node.handler, node);
|
||||
this.print(node.handler);
|
||||
}
|
||||
if (node.finalizer) {
|
||||
this.space();
|
||||
this.word("finally");
|
||||
this.space();
|
||||
this.print(node.finalizer, node);
|
||||
this.print(node.finalizer);
|
||||
}
|
||||
}
|
||||
function CatchClause(node) {
|
||||
@@ -191,22 +191,22 @@ function CatchClause(node) {
|
||||
this.space();
|
||||
if (node.param) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.param, node);
|
||||
this.print(node.param.typeAnnotation, node);
|
||||
this.print(node.param);
|
||||
this.print(node.param.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.discriminant, node);
|
||||
this.print(node.discriminant);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.printSequence(node.cases, node, {
|
||||
this.printSequence(node.cases, {
|
||||
indent: true,
|
||||
addNewlines(leading, cas) {
|
||||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
|
||||
@@ -218,7 +218,7 @@ function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.word("default");
|
||||
@@ -226,7 +226,7 @@ function SwitchCase(node) {
|
||||
}
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, node, {
|
||||
this.printSequence(node.consequent, {
|
||||
indent: true
|
||||
});
|
||||
}
|
||||
@@ -259,9 +259,9 @@ function VariableDeclaration(node, parent) {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.printList(node.declarations, node, {
|
||||
separator: hasInits ? function () {
|
||||
this.tokenChar(44);
|
||||
this.printList(node.declarations, {
|
||||
separator: hasInits ? function (occurrenceCount) {
|
||||
this.token(",", false, occurrenceCount);
|
||||
this.newline();
|
||||
} : undefined,
|
||||
indent: node.declarations.length > 1 ? true : false
|
||||
@@ -276,14 +276,14 @@ function VariableDeclaration(node, parent) {
|
||||
this.semicolon();
|
||||
}
|
||||
function VariableDeclarator(node) {
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
if (node.definite) this.tokenChar(33);
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
this.print(node.id.typeAnnotation);
|
||||
if (node.init) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.init, node);
|
||||
this.print(node.init);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/statements.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/statements.js.map
generated
vendored
File diff suppressed because one or more lines are too long
12
node_modules/@babel/generator/lib/generators/template-literals.js
generated
vendored
12
node_modules/@babel/generator/lib/generators/template-literals.js
generated
vendored
@@ -7,9 +7,9 @@ exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
||||
exports.TemplateElement = TemplateElement;
|
||||
exports.TemplateLiteral = TemplateLiteral;
|
||||
function TaggedTemplateExpression(node) {
|
||||
this.print(node.tag, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.quasi, node);
|
||||
this.print(node.tag);
|
||||
this.print(node.typeParameters);
|
||||
this.print(node.quasi);
|
||||
}
|
||||
function TemplateElement() {
|
||||
throw new Error("TemplateElement printing is handled in TemplateLiteral");
|
||||
@@ -21,8 +21,12 @@ function TemplateLiteral(node) {
|
||||
partRaw += quasis[i].value.raw;
|
||||
if (i + 1 < quasis.length) {
|
||||
this.token(partRaw + "${", true);
|
||||
this.print(node.expressions[i], node);
|
||||
this.print(node.expressions[i]);
|
||||
partRaw = "}";
|
||||
if (this.tokenMap) {
|
||||
const token = this.tokenMap.findMatching(node, "}", i);
|
||||
if (token) this._catchUpTo(token.loc.start);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.token(partRaw + "`", true);
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/template-literals.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/template-literals.js.map
generated
vendored
@@ -1 +1 @@
|
||||
{"version":3,"names":["TaggedTemplateExpression","node","print","tag","typeParameters","quasi","TemplateElement","Error","TemplateLiteral","quasis","partRaw","i","length","value","raw","token","expressions"],"sources":["../../src/generators/template-literals.ts"],"sourcesContent":["import type Printer from \"../printer.ts\";\nimport type * as t from \"@babel/types\";\n\nexport function TaggedTemplateExpression(\n this: Printer,\n node: t.TaggedTemplateExpression,\n) {\n this.print(node.tag, node);\n this.print(node.typeParameters, node); // TS\n this.print(node.quasi, node);\n}\n\nexport function TemplateElement(this: Printer) {\n throw new Error(\"TemplateElement printing is handled in TemplateLiteral\");\n}\n\nexport function TemplateLiteral(this: Printer, node: t.TemplateLiteral) {\n const quasis = node.quasis;\n\n let partRaw = \"`\";\n\n for (let i = 0; i < quasis.length; i++) {\n partRaw += quasis[i].value.raw;\n\n if (i + 1 < quasis.length) {\n this.token(partRaw + \"${\", true);\n this.print(node.expressions[i], node);\n partRaw = \"}\";\n }\n }\n\n this.token(partRaw + \"`\", true);\n}\n"],"mappings":";;;;;;;;AAGO,SAASA,wBAAwBA,CAEtCC,IAAgC,EAChC;EACA,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,GAAG,EAAEF,IAAI,CAAC;EAC1B,IAAI,CAACC,KAAK,CAACD,IAAI,CAACG,cAAc,EAAEH,IAAI,CAAC;EACrC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACI,KAAK,EAAEJ,IAAI,CAAC;AAC9B;AAEO,SAASK,eAAeA,CAAA,EAAgB;EAC7C,MAAM,IAAIC,KAAK,CAAC,wDAAwD,CAAC;AAC3E;AAEO,SAASC,eAAeA,CAAgBP,IAAuB,EAAE;EACtE,MAAMQ,MAAM,GAAGR,IAAI,CAACQ,MAAM;EAE1B,IAAIC,OAAO,GAAG,GAAG;EAEjB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;IACtCD,OAAO,IAAID,MAAM,CAACE,CAAC,CAAC,CAACE,KAAK,CAACC,GAAG;IAE9B,IAAIH,CAAC,GAAG,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAE;MACzB,IAAI,CAACG,KAAK,CAACL,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC;MAChC,IAAI,CAACR,KAAK,CAACD,IAAI,CAACe,WAAW,CAACL,CAAC,CAAC,EAAEV,IAAI,CAAC;MACrCS,OAAO,GAAG,GAAG;IACf;EACF;EAEA,IAAI,CAACK,KAAK,CAACL,OAAO,GAAG,GAAG,EAAE,IAAI,CAAC;AACjC","ignoreList":[]}
|
||||
{"version":3,"names":["TaggedTemplateExpression","node","print","tag","typeParameters","quasi","TemplateElement","Error","TemplateLiteral","quasis","partRaw","i","length","value","raw","token","expressions","tokenMap","findMatching","_catchUpTo","loc","start"],"sources":["../../src/generators/template-literals.ts"],"sourcesContent":["import type Printer from \"../printer.ts\";\nimport type * as t from \"@babel/types\";\n\nexport function TaggedTemplateExpression(\n this: Printer,\n node: t.TaggedTemplateExpression,\n) {\n this.print(node.tag);\n this.print(node.typeParameters); // TS\n this.print(node.quasi);\n}\n\nexport function TemplateElement(this: Printer) {\n throw new Error(\"TemplateElement printing is handled in TemplateLiteral\");\n}\n\nexport function TemplateLiteral(this: Printer, node: t.TemplateLiteral) {\n const quasis = node.quasis;\n\n let partRaw = \"`\";\n\n for (let i = 0; i < quasis.length; i++) {\n partRaw += quasis[i].value.raw;\n\n if (i + 1 < quasis.length) {\n this.token(partRaw + \"${\", true);\n this.print(node.expressions[i]);\n partRaw = \"}\";\n\n // In Babel 7 we have indivirual tokens for ${ and }, so the automatic\n // catchup logic does not work. Manually look for those tokens.\n if (!process.env.BABEL_8_BREAKING && this.tokenMap) {\n const token = this.tokenMap.findMatching(node, \"}\", i);\n if (token) this._catchUpTo(token.loc.start);\n }\n }\n }\n\n this.token(partRaw + \"`\", true);\n}\n"],"mappings":";;;;;;;;AAGO,SAASA,wBAAwBA,CAEtCC,IAAgC,EAChC;EACA,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,GAAG,CAAC;EACpB,IAAI,CAACD,KAAK,CAACD,IAAI,CAACG,cAAc,CAAC;EAC/B,IAAI,CAACF,KAAK,CAACD,IAAI,CAACI,KAAK,CAAC;AACxB;AAEO,SAASC,eAAeA,CAAA,EAAgB;EAC7C,MAAM,IAAIC,KAAK,CAAC,wDAAwD,CAAC;AAC3E;AAEO,SAASC,eAAeA,CAAgBP,IAAuB,EAAE;EACtE,MAAMQ,MAAM,GAAGR,IAAI,CAACQ,MAAM;EAE1B,IAAIC,OAAO,GAAG,GAAG;EAEjB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;IACtCD,OAAO,IAAID,MAAM,CAACE,CAAC,CAAC,CAACE,KAAK,CAACC,GAAG;IAE9B,IAAIH,CAAC,GAAG,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAE;MACzB,IAAI,CAACG,KAAK,CAACL,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC;MAChC,IAAI,CAACR,KAAK,CAACD,IAAI,CAACe,WAAW,CAACL,CAAC,CAAC,CAAC;MAC/BD,OAAO,GAAG,GAAG;MAIb,IAAqC,IAAI,CAACO,QAAQ,EAAE;QAClD,MAAMF,KAAK,GAAG,IAAI,CAACE,QAAQ,CAACC,YAAY,CAACjB,IAAI,EAAE,GAAG,EAAEU,CAAC,CAAC;QACtD,IAAII,KAAK,EAAE,IAAI,CAACI,UAAU,CAACJ,KAAK,CAACK,GAAG,CAACC,KAAK,CAAC;MAC7C;IACF;EACF;EAEA,IAAI,CAACN,KAAK,CAACL,OAAO,GAAG,GAAG,EAAE,IAAI,CAAC;AACjC","ignoreList":[]}
|
||||
66
node_modules/@babel/generator/lib/generators/types.js
generated
vendored
66
node_modules/@babel/generator/lib/generators/types.js
generated
vendored
@@ -23,33 +23,50 @@ exports.SpreadElement = exports.RestElement = RestElement;
|
||||
exports.StringLiteral = StringLiteral;
|
||||
exports.TopicReference = TopicReference;
|
||||
exports.TupleExpression = TupleExpression;
|
||||
exports._getRawIdentifier = _getRawIdentifier;
|
||||
var _t = require("@babel/types");
|
||||
var _jsesc = require("jsesc");
|
||||
const {
|
||||
isAssignmentPattern,
|
||||
isIdentifier
|
||||
} = _t;
|
||||
let lastRawIdentNode = null;
|
||||
let lastRawIdentResult = "";
|
||||
function _getRawIdentifier(node) {
|
||||
if (node === lastRawIdentNode) return lastRawIdentResult;
|
||||
lastRawIdentNode = node;
|
||||
const {
|
||||
name
|
||||
} = node;
|
||||
const token = this.tokenMap.find(node, tok => tok.value === name);
|
||||
if (token) {
|
||||
lastRawIdentResult = this._originalCode.slice(token.start, token.end);
|
||||
return lastRawIdentResult;
|
||||
}
|
||||
return lastRawIdentResult = node.name;
|
||||
}
|
||||
function Identifier(node) {
|
||||
var _node$loc;
|
||||
this.sourceIdentifierName(((_node$loc = node.loc) == null ? void 0 : _node$loc.identifierName) || node.name);
|
||||
this.word(node.name);
|
||||
this.word(this.tokenMap ? this._getRawIdentifier(node) : node.name);
|
||||
}
|
||||
function ArgumentPlaceholder() {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
function RestElement(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
function ObjectExpression(node) {
|
||||
const props = node.properties;
|
||||
this.tokenChar(123);
|
||||
if (props.length) {
|
||||
const exit = this.enterForStatementInit(false);
|
||||
const exit = this.enterDelimited();
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
this.printList(props, {
|
||||
indent: true,
|
||||
statement: true
|
||||
statement: true,
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("}")
|
||||
});
|
||||
this.space();
|
||||
exit();
|
||||
@@ -58,44 +75,46 @@ function ObjectExpression(node) {
|
||||
this.tokenChar(125);
|
||||
}
|
||||
function ObjectMethod(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
this._methodHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ObjectProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (isAssignmentPattern(node.value) && isIdentifier(node.key) && node.key.name === node.value.left.name) {
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
return;
|
||||
}
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
if (node.shorthand && isIdentifier(node.key) && isIdentifier(node.value) && node.key.name === node.value.name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
function ArrayExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
this.tokenChar(91);
|
||||
const exit = this.enterForStatementInit(false);
|
||||
const exit = this.enterDelimited();
|
||||
for (let i = 0; i < elems.length; i++) {
|
||||
const elem = elems[i];
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem, node);
|
||||
if (i < len - 1) this.tokenChar(44);
|
||||
this.print(elem);
|
||||
if (i < len - 1 || this.shouldPrintTrailingComma("]")) {
|
||||
this.token(",", false, i);
|
||||
}
|
||||
} else {
|
||||
this.tokenChar(44);
|
||||
this.token(",", false, i);
|
||||
}
|
||||
}
|
||||
exit();
|
||||
@@ -119,9 +138,10 @@ function RecordExpression(node) {
|
||||
this.token(startToken);
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
this.printList(props, {
|
||||
indent: true,
|
||||
statement: true
|
||||
statement: true,
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma(endToken)
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
@@ -148,8 +168,10 @@ function TupleExpression(node) {
|
||||
const elem = elems[i];
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem, node);
|
||||
if (i < len - 1) this.tokenChar(44);
|
||||
this.print(elem);
|
||||
if (i < len - 1 || this.shouldPrintTrailingComma(endToken)) {
|
||||
this.token(",", false, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.token(endToken);
|
||||
@@ -217,10 +239,10 @@ function TopicReference() {
|
||||
}
|
||||
}
|
||||
function PipelineTopicExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.expression);
|
||||
}
|
||||
function PipelineBareFunction(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.callee);
|
||||
}
|
||||
function PipelinePrimaryTopicReference() {
|
||||
this.tokenChar(35);
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/types.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/types.js.map
generated
vendored
File diff suppressed because one or more lines are too long
302
node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
302
node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
@@ -9,6 +9,7 @@ exports.TSSatisfiesExpression = exports.TSAsExpression = TSTypeExpression;
|
||||
exports.TSBigIntKeyword = TSBigIntKeyword;
|
||||
exports.TSBooleanKeyword = TSBooleanKeyword;
|
||||
exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration;
|
||||
exports.TSInterfaceHeritage = exports.TSExpressionWithTypeArguments = exports.TSClassImplements = TSClassImplements;
|
||||
exports.TSConditionalType = TSConditionalType;
|
||||
exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration;
|
||||
exports.TSConstructorType = TSConstructorType;
|
||||
@@ -17,7 +18,6 @@ exports.TSDeclareMethod = TSDeclareMethod;
|
||||
exports.TSEnumDeclaration = TSEnumDeclaration;
|
||||
exports.TSEnumMember = TSEnumMember;
|
||||
exports.TSExportAssignment = TSExportAssignment;
|
||||
exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments;
|
||||
exports.TSExternalModuleReference = TSExternalModuleReference;
|
||||
exports.TSFunctionType = TSFunctionType;
|
||||
exports.TSImportEqualsDeclaration = TSImportEqualsDeclaration;
|
||||
@@ -70,19 +70,22 @@ exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers;
|
||||
exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType;
|
||||
exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName;
|
||||
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase;
|
||||
exports.tsPrintTypeLiteralOrInterfaceBody = tsPrintTypeLiteralOrInterfaceBody;
|
||||
function TSTypeAnnotation(node) {
|
||||
this.tokenChar(58);
|
||||
function TSTypeAnnotation(node, parent) {
|
||||
this.token((parent.type === "TSFunctionType" || parent.type === "TSConstructorType") && parent.typeAnnotation === node ? "=>" : ":");
|
||||
this.space();
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSTypeParameterInstantiation(node, parent) {
|
||||
this.tokenChar(60);
|
||||
this.printList(node.params, node, {});
|
||||
if (parent.type === "ArrowFunctionExpression" && node.params.length === 1) {
|
||||
this.tokenChar(44);
|
||||
let printTrailingSeparator = parent.type === "ArrowFunctionExpression" && node.params.length === 1;
|
||||
if (this.tokenMap && node.start != null && node.end != null) {
|
||||
printTrailingSeparator && (printTrailingSeparator = !!this.tokenMap.find(node, t => this.tokenMap.matchesOriginal(t, ",")));
|
||||
printTrailingSeparator || (printTrailingSeparator = this.shouldPrintTrailingComma(">"));
|
||||
}
|
||||
this.printList(node.params, {
|
||||
printTrailingSeparator
|
||||
});
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function TSTypeParameter(node) {
|
||||
@@ -99,13 +102,13 @@ function TSTypeParameter(node) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.constraint, node);
|
||||
this.print(node.constraint);
|
||||
}
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
this.print(node.default);
|
||||
}
|
||||
}
|
||||
function TSParameterProperty(node) {
|
||||
@@ -125,26 +128,37 @@ function TSDeclareFunction(node, parent) {
|
||||
this.space();
|
||||
}
|
||||
this._functionHead(node, parent);
|
||||
this.tokenChar(59);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSDeclareMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.tokenChar(59);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSQualifiedName(node) {
|
||||
this.print(node.left, node);
|
||||
this.print(node.left);
|
||||
this.tokenChar(46);
|
||||
this.print(node.right, node);
|
||||
this.print(node.right);
|
||||
}
|
||||
function TSCallSignatureDeclaration(node) {
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.tokenChar(59);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function maybePrintTrailingCommaOrSemicolon(printer, node) {
|
||||
if (!printer.tokenMap || !node.start || !node.end) {
|
||||
printer.semicolon();
|
||||
return;
|
||||
}
|
||||
if (printer.tokenMap.endMatches(node, ",")) {
|
||||
printer.token(",");
|
||||
} else if (printer.tokenMap.endMatches(node, ";")) {
|
||||
printer.semicolon();
|
||||
}
|
||||
}
|
||||
function TSConstructSignatureDeclaration(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.tokenChar(59);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSPropertySignature(node) {
|
||||
const {
|
||||
@@ -155,14 +169,14 @@ function TSPropertySignature(node) {
|
||||
this.space();
|
||||
}
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.tokenChar(59);
|
||||
this.print(node.typeAnnotation);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function tsPrintPropertyOrMethodName(node) {
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
}
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
if (node.computed) {
|
||||
this.tokenChar(93);
|
||||
}
|
||||
@@ -180,7 +194,7 @@ function TSMethodSignature(node) {
|
||||
}
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.tokenChar(59);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSIndexSignature(node) {
|
||||
const {
|
||||
@@ -196,10 +210,9 @@ function TSIndexSignature(node) {
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this._parameters(node.parameters, node);
|
||||
this.tokenChar(93);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.tokenChar(59);
|
||||
this._parameters(node.parameters, "]");
|
||||
this.print(node.typeAnnotation);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSAnyKeyword() {
|
||||
this.word("any");
|
||||
@@ -260,19 +273,16 @@ function tsPrintFunctionOrConstructorType(node) {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.print(typeParameters);
|
||||
this.tokenChar(40);
|
||||
this._parameters(parameters, node);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this._parameters(parameters, ")");
|
||||
this.space();
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType.typeAnnotation, node);
|
||||
this.print(returnType);
|
||||
}
|
||||
function TSTypeReference(node) {
|
||||
this.print(node.typeName, node, true);
|
||||
this.print(node.typeParameters, node, true);
|
||||
this.print(node.typeName, !!node.typeParameters);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
function TSTypePredicate(node) {
|
||||
if (node.asserts) {
|
||||
@@ -292,51 +302,41 @@ function TSTypeQuery(node) {
|
||||
this.space();
|
||||
this.print(node.exprName);
|
||||
if (node.typeParameters) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
}
|
||||
function TSTypeLiteral(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node);
|
||||
}
|
||||
function tsPrintTypeLiteralOrInterfaceBody(members, node) {
|
||||
tsPrintBraced(this, members, node);
|
||||
}
|
||||
function tsPrintBraced(printer, members, node) {
|
||||
printer.token("{");
|
||||
if (members.length) {
|
||||
printer.indent();
|
||||
printer.newline();
|
||||
for (const member of members) {
|
||||
printer.print(member, node);
|
||||
printer.newline();
|
||||
}
|
||||
printer.dedent();
|
||||
}
|
||||
printer.rightBrace(node);
|
||||
printBraced(this, node, () => this.printJoin(node.members, {
|
||||
indent: true,
|
||||
statement: true
|
||||
}));
|
||||
}
|
||||
function TSArrayType(node) {
|
||||
this.print(node.elementType, node, true);
|
||||
this.token("[]");
|
||||
this.print(node.elementType, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSTupleType(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.elementTypes, node);
|
||||
this.printList(node.elementTypes, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("]")
|
||||
});
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSOptionalType(node) {
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(63);
|
||||
}
|
||||
function TSRestType(node) {
|
||||
this.token("...");
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSNamedTupleMember(node) {
|
||||
this.print(node.label, node);
|
||||
this.print(node.label);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.elementType, node);
|
||||
this.print(node.elementType);
|
||||
}
|
||||
function TSUnionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "|");
|
||||
@@ -345,10 +345,16 @@ function TSIntersectionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "&");
|
||||
}
|
||||
function tsPrintUnionOrIntersectionType(printer, node, sep) {
|
||||
printer.printJoin(node.types, node, {
|
||||
separator() {
|
||||
var _printer$tokenMap;
|
||||
let hasLeadingToken = 0;
|
||||
if ((_printer$tokenMap = printer.tokenMap) != null && _printer$tokenMap.startMatches(node, sep)) {
|
||||
hasLeadingToken = 1;
|
||||
printer.token(sep);
|
||||
}
|
||||
printer.printJoin(node.types, {
|
||||
separator(i) {
|
||||
this.space();
|
||||
this.token(sep);
|
||||
this.token(sep, null, i + hasLeadingToken);
|
||||
this.space();
|
||||
}
|
||||
});
|
||||
@@ -369,24 +375,23 @@ function TSConditionalType(node) {
|
||||
this.print(node.falseType);
|
||||
}
|
||||
function TSInferType(node) {
|
||||
this.token("infer");
|
||||
this.space();
|
||||
this.word("infer");
|
||||
this.print(node.typeParameter);
|
||||
}
|
||||
function TSParenthesizedType(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function TSTypeOperator(node) {
|
||||
this.word(node.operator);
|
||||
this.space();
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSIndexedAccessType(node) {
|
||||
this.print(node.objectType, node, true);
|
||||
this.print(node.objectType, true);
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType, node);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSMappedType(node) {
|
||||
@@ -394,10 +399,10 @@ function TSMappedType(node) {
|
||||
nameType,
|
||||
optional,
|
||||
readonly,
|
||||
typeParameter,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.tokenChar(123);
|
||||
const exit = this.enterDelimited();
|
||||
this.space();
|
||||
if (readonly) {
|
||||
tokenIfPlusMinus(this, readonly);
|
||||
@@ -405,16 +410,20 @@ function TSMappedType(node) {
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.word(typeParameter.name);
|
||||
{
|
||||
this.word(node.typeParameter.name);
|
||||
}
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
this.print(typeParameter.constraint, typeParameter);
|
||||
{
|
||||
this.print(node.typeParameter.constraint);
|
||||
}
|
||||
if (nameType) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(nameType, node);
|
||||
this.print(nameType);
|
||||
}
|
||||
this.tokenChar(93);
|
||||
if (optional) {
|
||||
@@ -424,9 +433,10 @@ function TSMappedType(node) {
|
||||
if (typeAnnotation) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
this.print(typeAnnotation);
|
||||
}
|
||||
this.space();
|
||||
exit();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
function tokenIfPlusMinus(self, tok) {
|
||||
@@ -435,11 +445,11 @@ function tokenIfPlusMinus(self, tok) {
|
||||
}
|
||||
}
|
||||
function TSLiteralType(node) {
|
||||
this.print(node.literal, node);
|
||||
this.print(node.literal);
|
||||
}
|
||||
function TSExpressionWithTypeArguments(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeParameters, node);
|
||||
function TSClassImplements(node) {
|
||||
this.print(node.expression);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
function TSInterfaceDeclaration(node) {
|
||||
const {
|
||||
@@ -455,19 +465,22 @@ function TSInterfaceDeclaration(node) {
|
||||
}
|
||||
this.word("interface");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(typeParameters, node);
|
||||
this.print(id);
|
||||
this.print(typeParameters);
|
||||
if (extendz != null && extendz.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(extendz, node);
|
||||
this.printList(extendz);
|
||||
}
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
this.print(body);
|
||||
}
|
||||
function TSInterfaceBody(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node);
|
||||
printBraced(this, node, () => this.printJoin(node.body, {
|
||||
indent: true,
|
||||
statement: true
|
||||
}));
|
||||
}
|
||||
function TSTypeAliasDeclaration(node) {
|
||||
const {
|
||||
@@ -482,27 +495,25 @@ function TSTypeAliasDeclaration(node) {
|
||||
}
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(typeParameters, node);
|
||||
this.print(id);
|
||||
this.print(typeParameters);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
this.tokenChar(59);
|
||||
this.print(typeAnnotation);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSTypeExpression(node) {
|
||||
var _expression$trailingC;
|
||||
const {
|
||||
type,
|
||||
expression,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
const forceParens = !!((_expression$trailingC = expression.trailingComments) != null && _expression$trailingC.length);
|
||||
this.print(expression, node, true, undefined, forceParens);
|
||||
this.print(expression, true);
|
||||
this.space();
|
||||
this.word(type === "TSAsExpression" ? "as" : "satisfies");
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
this.print(typeAnnotation);
|
||||
}
|
||||
function TSTypeAssertion(node) {
|
||||
const {
|
||||
@@ -510,14 +521,14 @@ function TSTypeAssertion(node) {
|
||||
expression
|
||||
} = node;
|
||||
this.tokenChar(60);
|
||||
this.print(typeAnnotation, node);
|
||||
this.print(typeAnnotation);
|
||||
this.tokenChar(62);
|
||||
this.space();
|
||||
this.print(expression, node);
|
||||
this.print(expression);
|
||||
}
|
||||
function TSInstantiationExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.expression);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
function TSEnumDeclaration(node) {
|
||||
const {
|
||||
@@ -536,53 +547,62 @@ function TSEnumDeclaration(node) {
|
||||
}
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(id);
|
||||
this.space();
|
||||
tsPrintBraced(this, members, node);
|
||||
printBraced(this, node, () => {
|
||||
var _this$shouldPrintTrai;
|
||||
return this.printList(members, {
|
||||
indent: true,
|
||||
statement: true,
|
||||
printTrailingSeparator: (_this$shouldPrintTrai = this.shouldPrintTrailingComma("}")) != null ? _this$shouldPrintTrai : true
|
||||
});
|
||||
});
|
||||
}
|
||||
function TSEnumMember(node) {
|
||||
const {
|
||||
id,
|
||||
initializer
|
||||
} = node;
|
||||
this.print(id, node);
|
||||
this.print(id);
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(initializer, node);
|
||||
this.print(initializer);
|
||||
}
|
||||
this.tokenChar(44);
|
||||
}
|
||||
function TSModuleDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id
|
||||
id,
|
||||
kind
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (!node.global) {
|
||||
this.word(id.type === "Identifier" ? "namespace" : "module");
|
||||
this.word(kind != null ? kind : id.type === "Identifier" ? "namespace" : "module");
|
||||
this.space();
|
||||
}
|
||||
this.print(id, node);
|
||||
this.print(id);
|
||||
if (!node.body) {
|
||||
this.tokenChar(59);
|
||||
this.semicolon();
|
||||
return;
|
||||
}
|
||||
let body = node.body;
|
||||
while (body.type === "TSModuleDeclaration") {
|
||||
this.tokenChar(46);
|
||||
this.print(body.id, body);
|
||||
this.print(body.id);
|
||||
body = body.body;
|
||||
}
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
this.print(body);
|
||||
}
|
||||
function TSModuleBlock(node) {
|
||||
tsPrintBraced(this, node.body, node);
|
||||
printBraced(this, node, () => this.printSequence(node.body, {
|
||||
indent: true
|
||||
}));
|
||||
}
|
||||
function TSImportType(node) {
|
||||
const {
|
||||
@@ -592,14 +612,14 @@ function TSImportType(node) {
|
||||
} = node;
|
||||
this.word("import");
|
||||
this.tokenChar(40);
|
||||
this.print(argument, node);
|
||||
this.print(argument);
|
||||
this.tokenChar(41);
|
||||
if (qualifier) {
|
||||
this.tokenChar(46);
|
||||
this.print(qualifier, node);
|
||||
this.print(qualifier);
|
||||
}
|
||||
if (typeParameters) {
|
||||
this.print(typeParameters, node);
|
||||
this.print(typeParameters);
|
||||
}
|
||||
}
|
||||
function TSImportEqualsDeclaration(node) {
|
||||
@@ -614,20 +634,20 @@ function TSImportEqualsDeclaration(node) {
|
||||
}
|
||||
this.word("import");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(id);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(moduleReference, node);
|
||||
this.tokenChar(59);
|
||||
this.print(moduleReference);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSExternalModuleReference(node) {
|
||||
this.token("require(");
|
||||
this.print(node.expression, node);
|
||||
this.print(node.expression);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function TSNonNullExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.expression);
|
||||
this.tokenChar(33);
|
||||
}
|
||||
function TSExportAssignment(node) {
|
||||
@@ -635,8 +655,8 @@ function TSExportAssignment(node) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(59);
|
||||
this.print(node.expression);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSNamespaceExportDeclaration(node) {
|
||||
this.word("export");
|
||||
@@ -645,45 +665,53 @@ function TSNamespaceExportDeclaration(node) {
|
||||
this.space();
|
||||
this.word("namespace");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
this.semicolon();
|
||||
}
|
||||
function tsPrintSignatureDeclarationBase(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.print(typeParameters);
|
||||
this.tokenChar(40);
|
||||
this._parameters(parameters, node);
|
||||
this.tokenChar(41);
|
||||
this._parameters(parameters, ")");
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType, node);
|
||||
this.print(returnType);
|
||||
}
|
||||
function tsPrintClassMemberModifiers(node) {
|
||||
const isField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty";
|
||||
if (isField && node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
printModifiersList(this, node, [isField && node.declare && "declare", node.accessibility]);
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
if (node.override) {
|
||||
this.word("override");
|
||||
this.space();
|
||||
printModifiersList(this, node, [node.override && "override", node.abstract && "abstract", isField && node.readonly && "readonly"]);
|
||||
}
|
||||
function printBraced(printer, node, cb) {
|
||||
printer.token("{");
|
||||
const exit = printer.enterDelimited();
|
||||
cb();
|
||||
exit();
|
||||
printer.rightBrace(node);
|
||||
}
|
||||
function printModifiersList(printer, node, modifiers) {
|
||||
var _printer$tokenMap2;
|
||||
const modifiersSet = new Set();
|
||||
for (const modifier of modifiers) {
|
||||
if (modifier) modifiersSet.add(modifier);
|
||||
}
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
if (isField && node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
(_printer$tokenMap2 = printer.tokenMap) == null || _printer$tokenMap2.find(node, tok => {
|
||||
if (modifiersSet.has(tok.value)) {
|
||||
printer.token(tok.value);
|
||||
printer.space();
|
||||
modifiersSet.delete(tok.value);
|
||||
return modifiersSet.size === 0;
|
||||
}
|
||||
});
|
||||
for (const modifier of modifiersSet) {
|
||||
printer.word(modifier);
|
||||
printer.space();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/typescript.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/typescript.js.map
generated
vendored
File diff suppressed because one or more lines are too long
31
node_modules/@babel/generator/lib/index.js
generated
vendored
31
node_modules/@babel/generator/lib/index.js
generated
vendored
@@ -6,11 +6,32 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.default = generate;
|
||||
var _sourceMap = require("./source-map.js");
|
||||
var _printer = require("./printer.js");
|
||||
function normalizeOptions(code, opts) {
|
||||
function normalizeOptions(code, opts, ast) {
|
||||
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 attatched 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,
|
||||
@@ -47,7 +68,7 @@ function normalizeOptions(code, opts) {
|
||||
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + `${opts.filename} as it exceeds the max of ${"500KB"}.`);
|
||||
}
|
||||
}
|
||||
if (format.compact) {
|
||||
if (format.compact || format.preserveFormat) {
|
||||
format.indent.adjustMultilineComment = false;
|
||||
}
|
||||
const {
|
||||
@@ -70,7 +91,7 @@ function normalizeOptions(code, opts) {
|
||||
this._format = void 0;
|
||||
this._map = void 0;
|
||||
this._ast = ast;
|
||||
this._format = normalizeOptions(code, opts);
|
||||
this._format = normalizeOptions(code, opts, ast);
|
||||
this._map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
}
|
||||
generate() {
|
||||
@@ -80,9 +101,9 @@ function normalizeOptions(code, opts) {
|
||||
};
|
||||
}
|
||||
function generate(ast, opts = {}, code) {
|
||||
const format = normalizeOptions(code, opts);
|
||||
const format = normalizeOptions(code, opts, ast);
|
||||
const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
const printer = new _printer.default(format, map);
|
||||
const printer = new _printer.default(format, map, ast.tokens, typeof code === "string" ? code : null);
|
||||
return printer.generate(ast);
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/@babel/generator/lib/index.js.map
generated
vendored
2
node_modules/@babel/generator/lib/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
26
node_modules/@babel/generator/lib/node/index.js
generated
vendored
26
node_modules/@babel/generator/lib/node/index.js
generated
vendored
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TokenContext = void 0;
|
||||
exports.isLastChild = isLastChild;
|
||||
exports.needsParens = needsParens;
|
||||
exports.needsWhitespace = needsWhitespace;
|
||||
exports.needsWhitespaceAfter = needsWhitespaceAfter;
|
||||
@@ -13,6 +14,7 @@ var parens = require("./parentheses.js");
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
VISITOR_KEYS,
|
||||
isCallExpression,
|
||||
isDecorator,
|
||||
isExpressionStatement,
|
||||
@@ -33,9 +35,9 @@ function expandAliases(obj) {
|
||||
const map = new Map();
|
||||
function add(type, func) {
|
||||
const fn = map.get(type);
|
||||
map.set(type, fn ? function (node, parent, stack, inForInit) {
|
||||
map.set(type, fn ? function (node, parent, stack, inForInit, getRawIdentifier) {
|
||||
var _fn;
|
||||
return (_fn = fn(node, parent, stack, inForInit)) != null ? _fn : func(node, parent, stack, inForInit);
|
||||
return (_fn = fn(node, parent, stack, inForInit, getRawIdentifier)) != null ? _fn : func(node, parent, stack, inForInit, getRawIdentifier);
|
||||
} : func);
|
||||
}
|
||||
for (const type of Object.keys(obj)) {
|
||||
@@ -76,7 +78,7 @@ function needsWhitespaceBefore(node, parent) {
|
||||
function needsWhitespaceAfter(node, parent) {
|
||||
return needsWhitespace(node, parent, 2);
|
||||
}
|
||||
function needsParens(node, parent, tokenContext, inForInit) {
|
||||
function needsParens(node, parent, tokenContext, inForInit, getRawIdentifier) {
|
||||
var _expandedParens$get;
|
||||
if (!parent) return false;
|
||||
if (isNewExpression(parent) && parent.callee === node) {
|
||||
@@ -85,7 +87,7 @@ function needsParens(node, parent, tokenContext, inForInit) {
|
||||
if (isDecorator(parent)) {
|
||||
return !isDecoratorMemberExpression(node) && !(isCallExpression(node) && isDecoratorMemberExpression(node.callee)) && !isParenthesizedExpression(node);
|
||||
}
|
||||
return (_expandedParens$get = expandedParens.get(node.type)) == null ? void 0 : _expandedParens$get(node, parent, tokenContext, inForInit);
|
||||
return (_expandedParens$get = expandedParens.get(node.type)) == null ? void 0 : _expandedParens$get(node, parent, tokenContext, inForInit, getRawIdentifier);
|
||||
}
|
||||
function isDecoratorMemberExpression(node) {
|
||||
switch (node.type) {
|
||||
@@ -97,5 +99,21 @@ function isDecoratorMemberExpression(node) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function isLastChild(parent, child) {
|
||||
const visitorKeys = VISITOR_KEYS[parent.type];
|
||||
for (let i = visitorKeys.length - 1; i >= 0; i--) {
|
||||
const val = parent[visitorKeys[i]];
|
||||
if (val === child) {
|
||||
return true;
|
||||
} else if (Array.isArray(val)) {
|
||||
let j = val.length - 1;
|
||||
while (j >= 0 && val[j] === null) j--;
|
||||
return j >= 0 && val[j] === child;
|
||||
} else if (val) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
2
node_modules/@babel/generator/lib/node/index.js.map
generated
vendored
2
node_modules/@babel/generator/lib/node/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
42
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
42
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
@@ -3,12 +3,11 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
||||
exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.Binary = Binary;
|
||||
exports.BinaryExpression = BinaryExpression;
|
||||
exports.ClassExpression = ClassExpression;
|
||||
exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.ArrowFunctionExpression = exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.DoExpression = DoExpression;
|
||||
exports.FunctionExpression = FunctionExpression;
|
||||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||||
@@ -33,13 +32,13 @@ const {
|
||||
isArrayTypeAnnotation,
|
||||
isBinaryExpression,
|
||||
isCallExpression,
|
||||
isExportDeclaration,
|
||||
isForOfStatement,
|
||||
isIndexedAccessType,
|
||||
isMemberExpression,
|
||||
isObjectPattern,
|
||||
isOptionalMemberExpression,
|
||||
isYieldExpression
|
||||
isYieldExpression,
|
||||
isStatement
|
||||
} = _t;
|
||||
const PRECEDENCE = new Map([["||", 0], ["??", 0], ["|>", 0], ["&&", 1], ["|", 2], ["^", 3], ["&", 4], ["==", 5], ["===", 5], ["!=", 5], ["!==", 5], ["<", 6], [">", 6], ["<=", 6], [">=", 6], ["in", 6], ["instanceof", 6], [">>", 7], ["<<", 7], [">>>", 7], ["+", 8], ["-", 8], ["*", 9], ["/", 9], ["%", 9], ["**", 10]]);
|
||||
function getBinaryPrecedence(node, nodeType) {
|
||||
@@ -66,14 +65,18 @@ function NullableTypeAnnotation(node, parent) {
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent, tokenContext) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "UnionTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "ArrayTypeAnnotation" || Boolean(tokenContext & _index.TokenContext.arrowFlowReturnType);
|
||||
return (parentType === "UnionTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "ArrayTypeAnnotation" || Boolean(tokenContext & _index.TokenContext.arrowFlowReturnType)
|
||||
);
|
||||
}
|
||||
function UpdateExpression(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isClassExtendsClause(node, parent);
|
||||
}
|
||||
function ObjectExpression(node, parent, tokenContext) {
|
||||
function needsParenBeforeExpressionBrace(tokenContext) {
|
||||
return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.arrowBody));
|
||||
}
|
||||
function ObjectExpression(node, parent, tokenContext) {
|
||||
return needsParenBeforeExpressionBrace(tokenContext);
|
||||
}
|
||||
function DoExpression(node, parent, tokenContext) {
|
||||
return !node.async && Boolean(tokenContext & _index.TokenContext.expressionStatement);
|
||||
}
|
||||
@@ -115,7 +118,7 @@ function TSAsExpression(node, parent) {
|
||||
}
|
||||
function TSUnionType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "TSArrayType" || parentType === "TSOptionalType" || parentType === "TSIntersectionType" || parentType === "TSUnionType" || parentType === "TSRestType";
|
||||
return parentType === "TSArrayType" || parentType === "TSOptionalType" || parentType === "TSIntersectionType" || parentType === "TSRestType";
|
||||
}
|
||||
function TSInferType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
@@ -130,10 +133,19 @@ function BinaryExpression(node, parent, tokenContext, inForStatementInit) {
|
||||
}
|
||||
function SequenceExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "ForStatement" || parentType === "ThrowStatement" || parentType === "ReturnStatement" || parentType === "IfStatement" && parent.test === node || parentType === "WhileStatement" && parent.test === node || parentType === "ForInStatement" && parent.right === node || parentType === "SwitchStatement" && parent.discriminant === node || parentType === "ExpressionStatement" && parent.expression === node) {
|
||||
if (parentType === "SequenceExpression" || parentType === "ParenthesizedExpression" || parentType === "MemberExpression" && parent.property === node || parentType === "OptionalMemberExpression" && parent.property === node || parentType === "TemplateLiteral") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (parentType === "ClassDeclaration") {
|
||||
return true;
|
||||
}
|
||||
if (parentType === "ForOfStatement") {
|
||||
return parent.right === node;
|
||||
}
|
||||
if (parentType === "ExportDefaultDeclaration") {
|
||||
return true;
|
||||
}
|
||||
return !isStatement(parent);
|
||||
}
|
||||
function YieldExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
@@ -148,9 +160,6 @@ function UnaryLike(node, parent) {
|
||||
function FunctionExpression(node, parent, tokenContext) {
|
||||
return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault));
|
||||
}
|
||||
function ArrowFunctionExpression(node, parent) {
|
||||
return isExportDeclaration(parent) || ConditionalExpression(node, parent);
|
||||
}
|
||||
function ConditionalExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "UnaryExpression" || parentType === "SpreadElement" || parentType === "BinaryExpression" || parentType === "LogicalExpression" || parentType === "ConditionalExpression" && parent.test === node || parentType === "AwaitExpression" || isTSTypeExpression(parentType)) {
|
||||
@@ -161,8 +170,8 @@ function ConditionalExpression(node, parent) {
|
||||
function OptionalMemberExpression(node, parent) {
|
||||
return isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node;
|
||||
}
|
||||
function AssignmentExpression(node, parent) {
|
||||
if (isObjectPattern(node.left)) {
|
||||
function AssignmentExpression(node, parent, tokenContext) {
|
||||
if (needsParenBeforeExpressionBrace(tokenContext) && isObjectPattern(node.left)) {
|
||||
return true;
|
||||
} else {
|
||||
return ConditionalExpression(node, parent);
|
||||
@@ -181,7 +190,7 @@ function LogicalExpression(node, parent) {
|
||||
return parent.operator !== "??";
|
||||
}
|
||||
}
|
||||
function Identifier(node, parent, tokenContext) {
|
||||
function Identifier(node, parent, tokenContext, _inForInit, getRawIdentifier) {
|
||||
var _node$extra;
|
||||
const parentType = parent.type;
|
||||
if ((_node$extra = node.extra) != null && _node$extra.parenthesized && parentType === "AssignmentExpression" && parent.left === node) {
|
||||
@@ -190,6 +199,9 @@ function Identifier(node, parent, tokenContext) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (getRawIdentifier && getRawIdentifier(node) !== node.name) {
|
||||
return false;
|
||||
}
|
||||
if (node.name === "let") {
|
||||
const isFollowedByBracket = isMemberExpression(parent, {
|
||||
object: node,
|
||||
|
||||
2
node_modules/@babel/generator/lib/node/parentheses.js.map
generated
vendored
2
node_modules/@babel/generator/lib/node/parentheses.js.map
generated
vendored
File diff suppressed because one or more lines are too long
318
node_modules/@babel/generator/lib/printer.js
generated
vendored
318
node_modules/@babel/generator/lib/printer.js
generated
vendored
@@ -7,8 +7,10 @@ exports.default = void 0;
|
||||
var _buffer = require("./buffer.js");
|
||||
var n = require("./node/index.js");
|
||||
var _t = require("@babel/types");
|
||||
var _tokenMap = require("./token-map.js");
|
||||
var generatorFunctions = require("./generators/index.js");
|
||||
const {
|
||||
isExpression,
|
||||
isFunction,
|
||||
isStatement,
|
||||
isClassBody,
|
||||
@@ -19,59 +21,105 @@ const SCIENTIFIC_NOTATION = /e/i;
|
||||
const ZERO_DECIMAL_INTEGER = /\.0+$/;
|
||||
const HAS_NEWLINE = /[\n\r\u2028\u2029]/;
|
||||
const HAS_NEWLINE_OR_BlOCK_COMMENT_END = /[\n\r\u2028\u2029]|\*\//;
|
||||
function commentIsNewline(c) {
|
||||
return c.type === "CommentLine" || HAS_NEWLINE.test(c.value);
|
||||
}
|
||||
const {
|
||||
needsParens
|
||||
} = n;
|
||||
class Printer {
|
||||
constructor(format, map) {
|
||||
constructor(format, map, tokens, originalCode) {
|
||||
this.inForStatementInit = false;
|
||||
this.tokenContext = 0;
|
||||
this._tokens = null;
|
||||
this._originalCode = null;
|
||||
this._currentNode = null;
|
||||
this._indent = 0;
|
||||
this._indentRepeat = 0;
|
||||
this._insideAux = false;
|
||||
this._parenPushNewlineState = null;
|
||||
this._noLineTerminator = false;
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
this._printAuxAfterOnNextUserNode = false;
|
||||
this._printedComments = new Set();
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithWord = false;
|
||||
this._endsWithDiv = false;
|
||||
this._lastCommentLine = 0;
|
||||
this._endsWithInnerRaw = false;
|
||||
this._indentInnerComments = true;
|
||||
this.tokenMap = null;
|
||||
this._boundGetRawIdentifier = this._getRawIdentifier.bind(this);
|
||||
this.format = format;
|
||||
this._tokens = tokens;
|
||||
this._originalCode = originalCode;
|
||||
this._indentRepeat = format.indent.style.length;
|
||||
this._inputMap = map == null ? void 0 : map._inputMap;
|
||||
this._buf = new _buffer.default(map, format.indent.style[0]);
|
||||
}
|
||||
enterForStatementInit(val) {
|
||||
const old = this.inForStatementInit;
|
||||
if (old === val) return () => {};
|
||||
this.inForStatementInit = val;
|
||||
enterForStatementInit() {
|
||||
if (this.inForStatementInit) return () => {};
|
||||
this.inForStatementInit = true;
|
||||
return () => {
|
||||
this.inForStatementInit = old;
|
||||
this.inForStatementInit = false;
|
||||
};
|
||||
}
|
||||
enterDelimited() {
|
||||
const oldInForStatementInit = this.inForStatementInit;
|
||||
const oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
if (oldInForStatementInit === false && oldNoLineTerminatorAfterNode === null) {
|
||||
return () => {};
|
||||
}
|
||||
this.inForStatementInit = false;
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
return () => {
|
||||
this.inForStatementInit = oldInForStatementInit;
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
};
|
||||
}
|
||||
generate(ast) {
|
||||
if (this.format.preserveFormat) {
|
||||
this.tokenMap = new _tokenMap.TokenMap(ast, this._tokens, this._originalCode);
|
||||
}
|
||||
this.print(ast);
|
||||
this._maybeAddAuxComment();
|
||||
return this._buf.get();
|
||||
}
|
||||
indent() {
|
||||
if (this.format.compact || this.format.concise) return;
|
||||
const {
|
||||
format
|
||||
} = this;
|
||||
if (format.preserveFormat || format.compact || format.concise) {
|
||||
return;
|
||||
}
|
||||
this._indent++;
|
||||
}
|
||||
dedent() {
|
||||
if (this.format.compact || this.format.concise) return;
|
||||
const {
|
||||
format
|
||||
} = this;
|
||||
if (format.preserveFormat || format.compact || format.concise) {
|
||||
return;
|
||||
}
|
||||
this._indent--;
|
||||
}
|
||||
semicolon(force = false) {
|
||||
this._maybeAddAuxComment();
|
||||
if (force) {
|
||||
this._appendChar(59);
|
||||
} else {
|
||||
this._queue(59);
|
||||
this._noLineTerminator = false;
|
||||
return;
|
||||
}
|
||||
if (this.tokenMap) {
|
||||
const node = this._currentNode;
|
||||
if (node.start != null && node.end != null) {
|
||||
if (!this.tokenMap.endMatches(node, ";")) {
|
||||
return;
|
||||
}
|
||||
const indexes = this.tokenMap.getIndexes(this._currentNode);
|
||||
this._catchUpTo(this._tokens[indexes[indexes.length - 1]].loc.start);
|
||||
}
|
||||
}
|
||||
this._queue(59);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
rightBrace(node) {
|
||||
@@ -86,7 +134,10 @@ class Printer {
|
||||
this.tokenChar(41);
|
||||
}
|
||||
space(force = false) {
|
||||
if (this.format.compact) return;
|
||||
const {
|
||||
format
|
||||
} = this;
|
||||
if (format.compact || format.preserveFormat) return;
|
||||
if (force) {
|
||||
this._space();
|
||||
} else if (this._buf.hasContent()) {
|
||||
@@ -98,8 +149,8 @@ class Printer {
|
||||
}
|
||||
word(str, noLineTerminatorAfter = false) {
|
||||
this.tokenContext = 0;
|
||||
this._maybePrintInnerComments();
|
||||
if (this._endsWithWord || str.charCodeAt(0) === 47 && this.endsWith(47)) {
|
||||
this._maybePrintInnerComments(str);
|
||||
if (this._endsWithWord || this._endsWithDiv && str.charCodeAt(0) === 47) {
|
||||
this._space();
|
||||
}
|
||||
this._maybeAddAuxComment();
|
||||
@@ -118,21 +169,21 @@ class Printer {
|
||||
this.word(str);
|
||||
this._endsWithInteger = Number.isInteger(number) && !isNonDecimalLiteral(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str.charCodeAt(str.length - 1) !== 46;
|
||||
}
|
||||
token(str, maybeNewline = false) {
|
||||
token(str, maybeNewline = false, occurrenceCount = 0) {
|
||||
this.tokenContext = 0;
|
||||
this._maybePrintInnerComments();
|
||||
this._maybePrintInnerComments(str, occurrenceCount);
|
||||
const lastChar = this.getLastChar();
|
||||
const strFirst = str.charCodeAt(0);
|
||||
if (lastChar === 33 && (str === "--" || strFirst === 61) || strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 || strFirst === 46 && this._endsWithInteger) {
|
||||
this._space();
|
||||
}
|
||||
this._maybeAddAuxComment();
|
||||
this._append(str, maybeNewline);
|
||||
this._append(str, maybeNewline, occurrenceCount);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
tokenChar(char) {
|
||||
this.tokenContext = 0;
|
||||
this._maybePrintInnerComments();
|
||||
this._maybePrintInnerComments(String.fromCharCode(char));
|
||||
const lastChar = this.getLastChar();
|
||||
if (char === 43 && lastChar === 43 || char === 45 && lastChar === 45 || char === 46 && this._endsWithInteger) {
|
||||
this._space();
|
||||
@@ -183,7 +234,7 @@ class Printer {
|
||||
this._buf.source(prop, loc);
|
||||
}
|
||||
sourceWithOffset(prop, loc, columnOffset) {
|
||||
if (!loc) return;
|
||||
if (!loc || this.format.preserveFormat) return;
|
||||
this._catchUp(prop, loc);
|
||||
this._buf.sourceWithOffset(prop, loc, columnOffset);
|
||||
}
|
||||
@@ -199,22 +250,29 @@ class Printer {
|
||||
_newline() {
|
||||
this._queue(10);
|
||||
}
|
||||
_append(str, maybeNewline) {
|
||||
this._maybeAddParen(str);
|
||||
_append(str, maybeNewline, occurrenceCount = 0) {
|
||||
if (this.tokenMap) {
|
||||
const token = this.tokenMap.findMatching(this._currentNode, str, occurrenceCount);
|
||||
if (token) this._catchUpTo(token.loc.start);
|
||||
}
|
||||
this._maybeIndent(str.charCodeAt(0));
|
||||
this._buf.append(str, maybeNewline);
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithDiv = false;
|
||||
}
|
||||
_appendChar(char) {
|
||||
this._maybeAddParenChar(char);
|
||||
if (this.tokenMap) {
|
||||
const token = this.tokenMap.findMatching(this._currentNode, String.fromCharCode(char));
|
||||
if (token) this._catchUpTo(token.loc.start);
|
||||
}
|
||||
this._maybeIndent(char);
|
||||
this._buf.appendChar(char);
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithDiv = false;
|
||||
}
|
||||
_queue(char) {
|
||||
this._maybeAddParenChar(char);
|
||||
this._maybeIndent(char);
|
||||
this._buf.queue(char);
|
||||
this._endsWithWord = false;
|
||||
@@ -230,47 +288,6 @@ class Printer {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_maybeAddParenChar(char) {
|
||||
const parenPushNewlineState = this._parenPushNewlineState;
|
||||
if (!parenPushNewlineState) return;
|
||||
if (char === 32) {
|
||||
return;
|
||||
}
|
||||
if (char !== 10) {
|
||||
this._parenPushNewlineState = null;
|
||||
return;
|
||||
}
|
||||
this.tokenChar(40);
|
||||
this.indent();
|
||||
parenPushNewlineState.printed = true;
|
||||
}
|
||||
_maybeAddParen(str) {
|
||||
const parenPushNewlineState = this._parenPushNewlineState;
|
||||
if (!parenPushNewlineState) return;
|
||||
const len = str.length;
|
||||
let i;
|
||||
for (i = 0; i < len && str.charCodeAt(i) === 32; i++) continue;
|
||||
if (i === len) {
|
||||
return;
|
||||
}
|
||||
const cha = str.charCodeAt(i);
|
||||
if (cha !== 10) {
|
||||
if (cha !== 47 || i + 1 === len) {
|
||||
this._parenPushNewlineState = null;
|
||||
return;
|
||||
}
|
||||
const chaPost = str.charCodeAt(i + 1);
|
||||
if (chaPost === 42) {
|
||||
return;
|
||||
} else if (chaPost !== 47) {
|
||||
this._parenPushNewlineState = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.tokenChar(40);
|
||||
this.indent();
|
||||
parenPushNewlineState.printed = true;
|
||||
}
|
||||
catchUp(line) {
|
||||
if (!this.format.retainLines) return;
|
||||
const count = line - this._buf.getCurrentLine();
|
||||
@@ -279,38 +296,45 @@ class Printer {
|
||||
}
|
||||
}
|
||||
_catchUp(prop, loc) {
|
||||
var _loc$prop;
|
||||
if (!this.format.retainLines) return;
|
||||
const line = loc == null || (_loc$prop = loc[prop]) == null ? void 0 : _loc$prop.line;
|
||||
if (line != null) {
|
||||
const count = line - this._buf.getCurrentLine();
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
const {
|
||||
format
|
||||
} = this;
|
||||
if (!format.preserveFormat) {
|
||||
if (format.retainLines && loc != null && loc[prop]) {
|
||||
this.catchUp(loc[prop].line);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const pos = loc == null ? void 0 : loc[prop];
|
||||
if (pos != null) this._catchUpTo(pos);
|
||||
}
|
||||
_catchUpTo({
|
||||
line,
|
||||
column,
|
||||
index
|
||||
}) {
|
||||
const count = line - this._buf.getCurrentLine();
|
||||
if (count > 0 && this._noLineTerminator) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
}
|
||||
const spacesCount = count > 0 ? column : column - this._buf.getCurrentColumn();
|
||||
if (spacesCount > 0) {
|
||||
const spaces = this._originalCode ? this._originalCode.slice(index - spacesCount, index).replace(/[^\t\x0B\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]/gu, " ") : " ".repeat(spacesCount);
|
||||
this._append(spaces, false);
|
||||
}
|
||||
}
|
||||
_getIndent() {
|
||||
return this._indentRepeat * this._indent;
|
||||
}
|
||||
printTerminatorless(node, parent, isLabel) {
|
||||
if (isLabel) {
|
||||
this._noLineTerminator = true;
|
||||
this.print(node, parent);
|
||||
} else {
|
||||
const terminatorState = {
|
||||
printed: false
|
||||
};
|
||||
this._parenPushNewlineState = terminatorState;
|
||||
this.print(node, parent);
|
||||
if (terminatorState.printed) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.tokenChar(41);
|
||||
}
|
||||
}
|
||||
printTerminatorless(node) {
|
||||
this._noLineTerminator = true;
|
||||
this.print(node);
|
||||
}
|
||||
print(node, parent, noLineTerminatorAfter, trailingCommentsLineOffset, forceParens) {
|
||||
var _node$extra, _node$leadingComments;
|
||||
print(node, noLineTerminatorAfter, trailingCommentsLineOffset) {
|
||||
var _node$extra, _node$leadingComments, _node$leadingComments2;
|
||||
if (!node) return;
|
||||
this._endsWithInnerRaw = false;
|
||||
const nodeType = node.type;
|
||||
@@ -323,13 +347,13 @@ class Printer {
|
||||
if (printMethod === undefined) {
|
||||
throw new ReferenceError(`unknown node of type ${JSON.stringify(nodeType)} with constructor ${JSON.stringify(node.constructor.name)}`);
|
||||
}
|
||||
const oldNode = this._currentNode;
|
||||
const parent = this._currentNode;
|
||||
this._currentNode = node;
|
||||
const oldInAux = this._insideAux;
|
||||
this._insideAux = node.loc == null;
|
||||
this._maybeAddAuxComment(this._insideAux && !oldInAux);
|
||||
const parenthesized = (_node$extra = node.extra) == null ? void 0 : _node$extra.parenthesized;
|
||||
let shouldPrintParens = forceParens || parenthesized && format.retainFunctionParens && nodeType === "FunctionExpression" || needsParens(node, parent, this.tokenContext, this.inForStatementInit);
|
||||
let shouldPrintParens = parenthesized && format.preserveFormat || parenthesized && format.retainFunctionParens && nodeType === "FunctionExpression" || needsParens(node, parent, this.tokenContext, this.inForStatementInit, format.preserveFormat ? this._boundGetRawIdentifier : undefined);
|
||||
if (!shouldPrintParens && parenthesized && (_node$leadingComments = node.leadingComments) != null && _node$leadingComments.length && node.leadingComments[0].type === "CommentBlock") {
|
||||
const parentType = parent == null ? void 0 : parent.type;
|
||||
switch (parentType) {
|
||||
@@ -346,11 +370,35 @@ class Printer {
|
||||
shouldPrintParens = true;
|
||||
}
|
||||
}
|
||||
let exitInForStatementInit;
|
||||
let indentParenthesized = false;
|
||||
if (!shouldPrintParens && this._noLineTerminator && ((_node$leadingComments2 = node.leadingComments) != null && _node$leadingComments2.some(commentIsNewline) || this.format.retainLines && node.loc && node.loc.start.line > this._buf.getCurrentLine())) {
|
||||
shouldPrintParens = true;
|
||||
indentParenthesized = true;
|
||||
}
|
||||
let oldNoLineTerminatorAfterNode;
|
||||
let oldInForStatementInitWasTrue;
|
||||
if (!shouldPrintParens) {
|
||||
noLineTerminatorAfter || (noLineTerminatorAfter = parent && this._noLineTerminatorAfterNode === parent && n.isLastChild(parent, node));
|
||||
if (noLineTerminatorAfter) {
|
||||
var _node$trailingComment;
|
||||
if ((_node$trailingComment = node.trailingComments) != null && _node$trailingComment.some(commentIsNewline)) {
|
||||
if (isExpression(node)) shouldPrintParens = true;
|
||||
} else {
|
||||
oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
this._noLineTerminatorAfterNode = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shouldPrintParens) {
|
||||
this.tokenChar(40);
|
||||
if (indentParenthesized) this.indent();
|
||||
this._endsWithInnerRaw = false;
|
||||
exitInForStatementInit = this.enterForStatementInit(false);
|
||||
if (this.inForStatementInit) {
|
||||
oldInForStatementInitWasTrue = true;
|
||||
this.inForStatementInit = false;
|
||||
}
|
||||
oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
}
|
||||
this._lastCommentLine = 0;
|
||||
this._printLeadingComments(node, parent);
|
||||
@@ -358,18 +406,25 @@ class Printer {
|
||||
this.exactSource(loc, printMethod.bind(this, node, parent));
|
||||
if (shouldPrintParens) {
|
||||
this._printTrailingComments(node, parent);
|
||||
if (indentParenthesized) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this._noLineTerminator = noLineTerminatorAfter;
|
||||
exitInForStatementInit();
|
||||
if (oldInForStatementInitWasTrue) this.inForStatementInit = true;
|
||||
} else if (noLineTerminatorAfter && !this._noLineTerminator) {
|
||||
this._noLineTerminator = true;
|
||||
this._printTrailingComments(node, parent);
|
||||
} else {
|
||||
this._printTrailingComments(node, parent, trailingCommentsLineOffset);
|
||||
}
|
||||
this._currentNode = oldNode;
|
||||
this._currentNode = parent;
|
||||
format.concise = oldConcise;
|
||||
this._insideAux = oldInAux;
|
||||
if (oldNoLineTerminatorAfterNode !== undefined) {
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
}
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
_maybeAddAuxComment(enteredPositionlessNode) {
|
||||
@@ -404,7 +459,7 @@ class Printer {
|
||||
return extra.raw;
|
||||
}
|
||||
}
|
||||
printJoin(nodes, parent, opts = {}) {
|
||||
printJoin(nodes, opts = {}) {
|
||||
if (!(nodes != null && nodes.length)) return;
|
||||
let {
|
||||
indent
|
||||
@@ -427,12 +482,14 @@ class Printer {
|
||||
const node = nodes[i];
|
||||
if (!node) continue;
|
||||
if (opts.statement) this._printNewline(i === 0, newlineOpts);
|
||||
this.print(node, parent, undefined, opts.trailingCommentsLineOffset || 0);
|
||||
this.print(node, undefined, opts.trailingCommentsLineOffset || 0);
|
||||
opts.iterator == null || opts.iterator(node, i);
|
||||
if (i < len - 1) separator == null || separator();
|
||||
if (separator != null) {
|
||||
if (i < len - 1) separator(i, false);else if (opts.printTrailingSeparator) separator(i, true);
|
||||
}
|
||||
if (opts.statement) {
|
||||
var _node$trailingComment;
|
||||
if (!((_node$trailingComment = node.trailingComments) != null && _node$trailingComment.length)) {
|
||||
var _node$trailingComment2;
|
||||
if (!((_node$trailingComment2 = node.trailingComments) != null && _node$trailingComment2.length)) {
|
||||
this._lastCommentLine = 0;
|
||||
}
|
||||
if (i + 1 === len) {
|
||||
@@ -447,10 +504,10 @@ class Printer {
|
||||
}
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
printAndIndentOnComments(node, parent) {
|
||||
printAndIndentOnComments(node) {
|
||||
const indent = node.leadingComments && node.leadingComments.length > 0;
|
||||
if (indent) this.indent();
|
||||
this.print(node, parent);
|
||||
this.print(node);
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
printBlock(parent) {
|
||||
@@ -458,7 +515,7 @@ class Printer {
|
||||
if (node.type !== "EmptyStatement") {
|
||||
this.space();
|
||||
}
|
||||
this.print(node, parent);
|
||||
this.print(node);
|
||||
}
|
||||
_printTrailingComments(node, parent, lineOffset) {
|
||||
const {
|
||||
@@ -477,12 +534,15 @@ class Printer {
|
||||
if (!(comments != null && comments.length)) return;
|
||||
this._printComments(0, comments, node, parent);
|
||||
}
|
||||
_maybePrintInnerComments() {
|
||||
if (this._endsWithInnerRaw) this.printInnerComments();
|
||||
_maybePrintInnerComments(nextTokenStr, nextTokenOccurrenceCount) {
|
||||
if (this._endsWithInnerRaw) {
|
||||
var _this$tokenMap;
|
||||
this.printInnerComments((_this$tokenMap = this.tokenMap) == null ? void 0 : _this$tokenMap.findMatching(this._currentNode, nextTokenStr, nextTokenOccurrenceCount));
|
||||
}
|
||||
this._endsWithInnerRaw = true;
|
||||
this._indentInnerComments = true;
|
||||
}
|
||||
printInnerComments() {
|
||||
printInnerComments(nextToken) {
|
||||
const node = this._currentNode;
|
||||
const comments = node.innerComments;
|
||||
if (!(comments != null && comments.length)) return;
|
||||
@@ -490,7 +550,7 @@ class Printer {
|
||||
const indent = this._indentInnerComments;
|
||||
const printedCommentsCount = this._printedComments.size;
|
||||
if (indent) this.indent();
|
||||
this._printComments(1, comments, node);
|
||||
this._printComments(1, comments, node, undefined, undefined, nextToken);
|
||||
if (hasSpace && printedCommentsCount !== this._printedComments.size) {
|
||||
this.space();
|
||||
}
|
||||
@@ -499,17 +559,23 @@ class Printer {
|
||||
noIndentInnerCommentsHere() {
|
||||
this._indentInnerComments = false;
|
||||
}
|
||||
printSequence(nodes, parent, opts = {}) {
|
||||
printSequence(nodes, opts = {}) {
|
||||
var _opts$indent;
|
||||
opts.statement = true;
|
||||
(_opts$indent = opts.indent) != null ? _opts$indent : opts.indent = false;
|
||||
this.printJoin(nodes, parent, opts);
|
||||
this.printJoin(nodes, opts);
|
||||
}
|
||||
printList(items, parent, opts = {}) {
|
||||
printList(items, opts = {}) {
|
||||
if (opts.separator == null) {
|
||||
opts.separator = commaSeparator;
|
||||
}
|
||||
this.printJoin(items, parent, opts);
|
||||
this.printJoin(items, opts);
|
||||
}
|
||||
shouldPrintTrailingComma(listEnd) {
|
||||
if (!this.tokenMap) return null;
|
||||
const listEndIndex = this.tokenMap.findLastIndex(this._currentNode, token => this.tokenMap.matchesOriginal(token, listEnd));
|
||||
if (listEndIndex <= 0) return null;
|
||||
return this.tokenMap.matchesOriginal(this._tokens[listEndIndex - 1], ",");
|
||||
}
|
||||
_printNewline(newLine, opts) {
|
||||
const format = this.format;
|
||||
@@ -534,12 +600,18 @@ class Printer {
|
||||
this.newline(1);
|
||||
}
|
||||
}
|
||||
_shouldPrintComment(comment) {
|
||||
_shouldPrintComment(comment, nextToken) {
|
||||
if (comment.ignore) return 0;
|
||||
if (this._printedComments.has(comment)) return 0;
|
||||
if (this._noLineTerminator && HAS_NEWLINE_OR_BlOCK_COMMENT_END.test(comment.value)) {
|
||||
return 2;
|
||||
}
|
||||
if (nextToken && this.tokenMap) {
|
||||
const commentTok = this.tokenMap.find(this._currentNode, token => token.value === comment.value);
|
||||
if (commentTok && commentTok.start > nextToken.start) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
this._printedComments.add(comment);
|
||||
if (!this.format.shouldPrintComment(comment.value)) {
|
||||
return 0;
|
||||
@@ -554,19 +626,11 @@ class Printer {
|
||||
this.newline(1);
|
||||
}
|
||||
const lastCharCode = this.getLastChar();
|
||||
if (lastCharCode !== 91 && lastCharCode !== 123) {
|
||||
if (lastCharCode !== 91 && lastCharCode !== 123 && lastCharCode !== 40) {
|
||||
this.space();
|
||||
}
|
||||
let val;
|
||||
if (isBlockComment) {
|
||||
const {
|
||||
_parenPushNewlineState
|
||||
} = this;
|
||||
if ((_parenPushNewlineState == null ? void 0 : _parenPushNewlineState.printed) === false && HAS_NEWLINE.test(comment.value)) {
|
||||
this.tokenChar(40);
|
||||
this.indent();
|
||||
_parenPushNewlineState.printed = true;
|
||||
}
|
||||
val = `/*${comment.value}*/`;
|
||||
if (this.format.indent.adjustMultilineComment) {
|
||||
var _comment$loc;
|
||||
@@ -590,7 +654,7 @@ class Printer {
|
||||
} else {
|
||||
val = `/*${comment.value}*/`;
|
||||
}
|
||||
if (this.endsWith(47)) this._space();
|
||||
if (this._endsWithDiv) this._space();
|
||||
this.source("start", comment.loc);
|
||||
this._append(val, isBlockComment);
|
||||
if (!isBlockComment && !noLineTerminator) {
|
||||
@@ -600,7 +664,7 @@ class Printer {
|
||||
this.newline(1);
|
||||
}
|
||||
}
|
||||
_printComments(type, comments, node, parent, lineOffset = 0) {
|
||||
_printComments(type, comments, node, parent, lineOffset = 0, nextToken) {
|
||||
const nodeLoc = node.loc;
|
||||
const len = comments.length;
|
||||
let hasLoc = !!nodeLoc;
|
||||
@@ -611,7 +675,7 @@ class Printer {
|
||||
const maybeNewline = this._noLineTerminator ? function () {} : this.newline.bind(this);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const comment = comments[i];
|
||||
const shouldPrint = this._shouldPrintComment(comment);
|
||||
const shouldPrint = this._shouldPrintComment(comment, nextToken);
|
||||
if (shouldPrint === 2) {
|
||||
hasLoc = false;
|
||||
break;
|
||||
@@ -684,9 +748,9 @@ Object.assign(Printer.prototype, generatorFunctions);
|
||||
Printer.prototype.Noop = function Noop() {};
|
||||
}
|
||||
var _default = exports.default = Printer;
|
||||
function commaSeparator() {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
function commaSeparator(occurrenceCount, last) {
|
||||
this.token(",", false, occurrenceCount);
|
||||
if (!last) this.space();
|
||||
}
|
||||
|
||||
//# sourceMappingURL=printer.js.map
|
||||
|
||||
2
node_modules/@babel/generator/lib/printer.js.map
generated
vendored
2
node_modules/@babel/generator/lib/printer.js.map
generated
vendored
File diff suppressed because one or more lines are too long
12
node_modules/@babel/generator/package.json
generated
vendored
12
node_modules/@babel/generator/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.25.0",
|
||||
"version": "7.26.2",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"license": "MIT",
|
||||
@@ -19,14 +19,16 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.25.0",
|
||||
"@babel/parser": "^7.26.2",
|
||||
"@babel/types": "^7.26.0",
|
||||
"@jridgewell/gen-mapping": "^0.3.5",
|
||||
"@jridgewell/trace-mapping": "^0.3.25",
|
||||
"jsesc": "^2.5.1"
|
||||
"jsesc": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.24.8",
|
||||
"@babel/parser": "^7.25.0",
|
||||
"@babel/core": "^7.26.0",
|
||||
"@babel/helper-fixtures": "^7.26.0",
|
||||
"@babel/plugin-transform-typescript": "^7.25.9",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.15",
|
||||
"@types/jsesc": "^2.5.0",
|
||||
"charcodes": "^0.2.0"
|
||||
|
||||
Reference in New Issue
Block a user