$
This commit is contained in:
364
node_modules/@babel/generator/lib/buffer.js
generated
vendored
Normal file
364
node_modules/@babel/generator/lib/buffer.js
generated
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function SourcePos() {
|
||||
return {
|
||||
identifierName: undefined,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
filename: undefined
|
||||
};
|
||||
}
|
||||
|
||||
class Buffer {
|
||||
constructor(map) {
|
||||
this._map = null;
|
||||
this._buf = "";
|
||||
this._str = "";
|
||||
this._appendCount = 0;
|
||||
this._last = 0;
|
||||
this._queue = [];
|
||||
this._queueCursor = 0;
|
||||
this._position = {
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
this._sourcePosition = SourcePos();
|
||||
this._disallowedPop = {
|
||||
identifierName: undefined,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
filename: undefined,
|
||||
objectReusable: true
|
||||
};
|
||||
this._map = map;
|
||||
|
||||
this._allocQueue();
|
||||
}
|
||||
|
||||
_allocQueue() {
|
||||
const queue = this._queue;
|
||||
|
||||
for (let i = 0; i < 16; i++) {
|
||||
queue.push({
|
||||
char: 0,
|
||||
repeat: 1,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
identifierName: undefined,
|
||||
filename: ""
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_pushQueue(char, repeat, line, column, identifierName, filename) {
|
||||
const cursor = this._queueCursor;
|
||||
|
||||
if (cursor === this._queue.length) {
|
||||
this._allocQueue();
|
||||
}
|
||||
|
||||
const item = this._queue[cursor];
|
||||
item.char = char;
|
||||
item.repeat = repeat;
|
||||
item.line = line;
|
||||
item.column = column;
|
||||
item.identifierName = identifierName;
|
||||
item.filename = filename;
|
||||
this._queueCursor++;
|
||||
}
|
||||
|
||||
_popQueue() {
|
||||
if (this._queueCursor === 0) {
|
||||
throw new Error("Cannot pop from empty queue");
|
||||
}
|
||||
|
||||
return this._queue[--this._queueCursor];
|
||||
}
|
||||
|
||||
get() {
|
||||
this._flush();
|
||||
|
||||
const map = this._map;
|
||||
const result = {
|
||||
code: (this._buf + this._str).trimRight(),
|
||||
decodedMap: map == null ? void 0 : map.getDecoded(),
|
||||
|
||||
get map() {
|
||||
const resultMap = map ? map.get() : null;
|
||||
result.map = resultMap;
|
||||
return resultMap;
|
||||
},
|
||||
|
||||
set map(value) {
|
||||
Object.defineProperty(result, "map", {
|
||||
value,
|
||||
writable: true
|
||||
});
|
||||
},
|
||||
|
||||
get rawMappings() {
|
||||
const mappings = map == null ? void 0 : map.getRawMappings();
|
||||
result.rawMappings = mappings;
|
||||
return mappings;
|
||||
},
|
||||
|
||||
set rawMappings(value) {
|
||||
Object.defineProperty(result, "rawMappings", {
|
||||
value,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
append(str, maybeNewline) {
|
||||
this._flush();
|
||||
|
||||
this._append(str, this._sourcePosition, maybeNewline);
|
||||
}
|
||||
|
||||
appendChar(char) {
|
||||
this._flush();
|
||||
|
||||
this._appendChar(char, 1, this._sourcePosition);
|
||||
}
|
||||
|
||||
queue(char) {
|
||||
if (char === 10) {
|
||||
while (this._queueCursor !== 0) {
|
||||
const char = this._queue[this._queueCursor - 1].char;
|
||||
|
||||
if (char !== 32 && char !== 9) {
|
||||
break;
|
||||
}
|
||||
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
|
||||
const sourcePosition = this._sourcePosition;
|
||||
|
||||
this._pushQueue(char, 1, sourcePosition.line, sourcePosition.column, sourcePosition.identifierName, sourcePosition.filename);
|
||||
}
|
||||
|
||||
queueIndentation(char, repeat) {
|
||||
this._pushQueue(char, repeat, undefined, undefined, undefined, undefined);
|
||||
}
|
||||
|
||||
_flush() {
|
||||
const queueCursor = this._queueCursor;
|
||||
const queue = this._queue;
|
||||
|
||||
for (let i = 0; i < queueCursor; i++) {
|
||||
const item = queue[i];
|
||||
|
||||
this._appendChar(item.char, item.repeat, item);
|
||||
}
|
||||
|
||||
this._queueCursor = 0;
|
||||
}
|
||||
|
||||
_appendChar(char, repeat, sourcePos) {
|
||||
this._last = char;
|
||||
this._str += repeat > 1 ? String.fromCharCode(char).repeat(repeat) : String.fromCharCode(char);
|
||||
|
||||
if (char !== 10) {
|
||||
this._mark(sourcePos.line, sourcePos.column, sourcePos.identifierName, sourcePos.filename);
|
||||
|
||||
this._position.column += repeat;
|
||||
} else {
|
||||
this._position.line++;
|
||||
this._position.column = 0;
|
||||
}
|
||||
}
|
||||
|
||||
_append(str, sourcePos, maybeNewline) {
|
||||
const len = str.length;
|
||||
this._last = str.charCodeAt(len - 1);
|
||||
|
||||
if (++this._appendCount > 4096) {
|
||||
+this._str;
|
||||
this._buf += this._str;
|
||||
this._str = str;
|
||||
this._appendCount = 0;
|
||||
} else {
|
||||
this._str += str;
|
||||
}
|
||||
|
||||
if (!maybeNewline && !this._map) {
|
||||
this._position.column += len;
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
column,
|
||||
identifierName,
|
||||
filename
|
||||
} = sourcePos;
|
||||
let line = sourcePos.line;
|
||||
let i = str.indexOf("\n");
|
||||
let last = 0;
|
||||
|
||||
if (i !== 0) {
|
||||
this._mark(line, column, identifierName, filename);
|
||||
}
|
||||
|
||||
while (i !== -1) {
|
||||
this._position.line++;
|
||||
this._position.column = 0;
|
||||
last = i + 1;
|
||||
|
||||
if (last < str.length) {
|
||||
this._mark(++line, 0, identifierName, filename);
|
||||
}
|
||||
|
||||
i = str.indexOf("\n", last);
|
||||
}
|
||||
|
||||
this._position.column += str.length - last;
|
||||
}
|
||||
|
||||
_mark(line, column, identifierName, filename) {
|
||||
var _this$_map;
|
||||
|
||||
(_this$_map = this._map) == null ? void 0 : _this$_map.mark(this._position, line, column, identifierName, filename);
|
||||
}
|
||||
|
||||
removeTrailingNewline() {
|
||||
const queueCursor = this._queueCursor;
|
||||
|
||||
if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 10) {
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
|
||||
removeLastSemicolon() {
|
||||
const queueCursor = this._queueCursor;
|
||||
|
||||
if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 59) {
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
|
||||
getLastChar() {
|
||||
const queueCursor = this._queueCursor;
|
||||
return queueCursor !== 0 ? this._queue[queueCursor - 1].char : this._last;
|
||||
}
|
||||
|
||||
endsWithCharAndNewline() {
|
||||
const queue = this._queue;
|
||||
const queueCursor = this._queueCursor;
|
||||
|
||||
if (queueCursor !== 0) {
|
||||
const lastCp = queue[queueCursor - 1].char;
|
||||
if (lastCp !== 10) return;
|
||||
|
||||
if (queueCursor > 1) {
|
||||
return queue[queueCursor - 2].char;
|
||||
} else {
|
||||
return this._last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasContent() {
|
||||
return this._queueCursor !== 0 || !!this._last;
|
||||
}
|
||||
|
||||
exactSource(loc, cb) {
|
||||
if (!this._map) return cb();
|
||||
this.source("start", loc);
|
||||
cb();
|
||||
this.source("end", loc);
|
||||
|
||||
this._disallowPop("start", loc);
|
||||
}
|
||||
|
||||
source(prop, loc) {
|
||||
if (!loc) return;
|
||||
|
||||
this._normalizePosition(prop, loc, this._sourcePosition);
|
||||
}
|
||||
|
||||
withSource(prop, loc, cb) {
|
||||
if (!this._map) return cb();
|
||||
const originalLine = this._sourcePosition.line;
|
||||
const originalColumn = this._sourcePosition.column;
|
||||
const originalFilename = this._sourcePosition.filename;
|
||||
const originalIdentifierName = this._sourcePosition.identifierName;
|
||||
this.source(prop, loc);
|
||||
cb();
|
||||
|
||||
if (this._disallowedPop.objectReusable || this._disallowedPop.line !== originalLine || this._disallowedPop.column !== originalColumn || this._disallowedPop.filename !== originalFilename) {
|
||||
this._sourcePosition.line = originalLine;
|
||||
this._sourcePosition.column = originalColumn;
|
||||
this._sourcePosition.filename = originalFilename;
|
||||
this._sourcePosition.identifierName = originalIdentifierName;
|
||||
this._disallowedPop.objectReusable = true;
|
||||
}
|
||||
}
|
||||
|
||||
_disallowPop(prop, loc) {
|
||||
if (!loc) return;
|
||||
const disallowedPop = this._disallowedPop;
|
||||
|
||||
this._normalizePosition(prop, loc, disallowedPop);
|
||||
|
||||
disallowedPop.objectReusable = false;
|
||||
}
|
||||
|
||||
_normalizePosition(prop, loc, targetObj) {
|
||||
const pos = loc[prop];
|
||||
targetObj.identifierName = prop === "start" && loc.identifierName || undefined;
|
||||
|
||||
if (pos) {
|
||||
targetObj.line = pos.line;
|
||||
targetObj.column = pos.column;
|
||||
targetObj.filename = loc.filename;
|
||||
} else {
|
||||
targetObj.line = null;
|
||||
targetObj.column = null;
|
||||
targetObj.filename = null;
|
||||
}
|
||||
}
|
||||
|
||||
getCurrentColumn() {
|
||||
const queue = this._queue;
|
||||
let lastIndex = -1;
|
||||
let len = 0;
|
||||
|
||||
for (let i = 0; i < this._queueCursor; i++) {
|
||||
const item = queue[i];
|
||||
|
||||
if (item.char === 10) {
|
||||
lastIndex = i;
|
||||
len += item.repeat;
|
||||
}
|
||||
}
|
||||
|
||||
return lastIndex === -1 ? this._position.column + len : len - 1 - lastIndex;
|
||||
}
|
||||
|
||||
getCurrentLine() {
|
||||
let count = 0;
|
||||
const queue = this._queue;
|
||||
|
||||
for (let i = 0; i < this._queueCursor; i++) {
|
||||
if (queue[i].char === 10) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return this._position.line + count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Buffer;
|
96
node_modules/@babel/generator/lib/generators/base.js
generated
vendored
Normal file
96
node_modules/@babel/generator/lib/generators/base.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.BlockStatement = BlockStatement;
|
||||
exports.Directive = Directive;
|
||||
exports.DirectiveLiteral = DirectiveLiteral;
|
||||
exports.File = File;
|
||||
exports.InterpreterDirective = InterpreterDirective;
|
||||
exports.Placeholder = Placeholder;
|
||||
exports.Program = Program;
|
||||
|
||||
function File(node) {
|
||||
if (node.program) {
|
||||
this.print(node.program.interpreter, node);
|
||||
}
|
||||
|
||||
this.print(node.program, node);
|
||||
}
|
||||
|
||||
function Program(node) {
|
||||
this.printInnerComments(node, false);
|
||||
this.printSequence(node.directives, node);
|
||||
if (node.directives && node.directives.length) this.newline();
|
||||
this.printSequence(node.body, node);
|
||||
}
|
||||
|
||||
function BlockStatement(node) {
|
||||
var _node$directives;
|
||||
|
||||
this.tokenChar(123);
|
||||
this.printInnerComments(node);
|
||||
const hasDirectives = (_node$directives = node.directives) == null ? void 0 : _node$directives.length;
|
||||
|
||||
if (node.body.length || hasDirectives) {
|
||||
this.newline();
|
||||
this.printSequence(node.directives, node, {
|
||||
indent: true
|
||||
});
|
||||
if (hasDirectives) this.newline();
|
||||
this.printSequence(node.body, node, {
|
||||
indent: true
|
||||
});
|
||||
this.removeTrailingNewline();
|
||||
this.source("end", node.loc);
|
||||
if (!this.endsWith(10)) this.newline();
|
||||
this.rightBrace();
|
||||
} else {
|
||||
this.source("end", node.loc);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
}
|
||||
|
||||
function Directive(node) {
|
||||
this.print(node.value, node);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
const unescapedSingleQuoteRE = /(?:^|[^\\])(?:\\\\)*'/;
|
||||
const unescapedDoubleQuoteRE = /(?:^|[^\\])(?:\\\\)*"/;
|
||||
|
||||
function DirectiveLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.token(raw);
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
value
|
||||
} = node;
|
||||
|
||||
if (!unescapedDoubleQuoteRE.test(value)) {
|
||||
this.token(`"${value}"`);
|
||||
} else if (!unescapedSingleQuoteRE.test(value)) {
|
||||
this.token(`'${value}'`);
|
||||
} else {
|
||||
throw new Error("Malformed AST: it is not possible to print a directive containing" + " both unescaped single and double quotes.");
|
||||
}
|
||||
}
|
||||
|
||||
function InterpreterDirective(node) {
|
||||
this.token(`#!${node.value}\n`, true);
|
||||
}
|
||||
|
||||
function Placeholder(node) {
|
||||
this.token("%%");
|
||||
this.print(node.name);
|
||||
this.token("%%");
|
||||
|
||||
if (node.expectedNode === "Statement") {
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
215
node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
Normal file
215
node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ClassAccessorProperty = ClassAccessorProperty;
|
||||
exports.ClassBody = ClassBody;
|
||||
exports.ClassExpression = exports.ClassDeclaration = ClassDeclaration;
|
||||
exports.ClassMethod = ClassMethod;
|
||||
exports.ClassPrivateMethod = ClassPrivateMethod;
|
||||
exports.ClassPrivateProperty = ClassPrivateProperty;
|
||||
exports.ClassProperty = ClassProperty;
|
||||
exports.StaticBlock = StaticBlock;
|
||||
exports._classMethodHead = _classMethodHead;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isExportDefaultDeclaration,
|
||||
isExportNamedDeclaration
|
||||
} = _t;
|
||||
|
||||
function ClassDeclaration(node, parent) {
|
||||
{
|
||||
if (!this.format.decoratorsBeforeExport || !isExportDefaultDeclaration(parent) && !isExportNamedDeclaration(parent)) {
|
||||
this.printJoin(node.decorators, node);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("class");
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (node.id) {
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if (node.superClass) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.superClass, node);
|
||||
this.print(node.superTypeParameters, node);
|
||||
}
|
||||
|
||||
if (node.implements) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements, node);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ClassBody(node) {
|
||||
this.tokenChar(123);
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (node.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
this.indent();
|
||||
this.printSequence(node.body, node);
|
||||
this.dedent();
|
||||
if (!this.endsWith(10)) this.newline();
|
||||
this.rightBrace();
|
||||
}
|
||||
}
|
||||
|
||||
function ClassProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.source("end", node.key.loc);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this._variance(node);
|
||||
|
||||
this.print(node.key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ClassAccessorProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.source("end", node.key.loc);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
this.word("accessor");
|
||||
this.printInnerComments(node);
|
||||
this.space();
|
||||
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this._variance(node);
|
||||
|
||||
this.print(node.key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ClassPrivateProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.key, node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ClassMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ClassPrivateMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function _classMethodHead(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.source("end", node.key.loc);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
|
||||
this._methodHead(node);
|
||||
}
|
||||
|
||||
function StaticBlock(node) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
|
||||
if (node.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
this.printSequence(node.body, node, {
|
||||
indent: true
|
||||
});
|
||||
this.rightBrace();
|
||||
}
|
||||
}
|
352
node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
Normal file
352
node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
Normal file
@@ -0,0 +1,352 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.LogicalExpression = exports.BinaryExpression = exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.AssignmentPattern = AssignmentPattern;
|
||||
exports.AwaitExpression = AwaitExpression;
|
||||
exports.BindExpression = BindExpression;
|
||||
exports.CallExpression = CallExpression;
|
||||
exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.Decorator = Decorator;
|
||||
exports.DoExpression = DoExpression;
|
||||
exports.EmptyStatement = EmptyStatement;
|
||||
exports.ExpressionStatement = ExpressionStatement;
|
||||
exports.Import = Import;
|
||||
exports.MemberExpression = MemberExpression;
|
||||
exports.MetaProperty = MetaProperty;
|
||||
exports.ModuleExpression = ModuleExpression;
|
||||
exports.NewExpression = NewExpression;
|
||||
exports.OptionalCallExpression = OptionalCallExpression;
|
||||
exports.OptionalMemberExpression = OptionalMemberExpression;
|
||||
exports.ParenthesizedExpression = ParenthesizedExpression;
|
||||
exports.PrivateName = PrivateName;
|
||||
exports.SequenceExpression = SequenceExpression;
|
||||
exports.Super = Super;
|
||||
exports.ThisExpression = ThisExpression;
|
||||
exports.UnaryExpression = UnaryExpression;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier;
|
||||
exports.YieldExpression = YieldExpression;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var n = require("../node");
|
||||
|
||||
const {
|
||||
isCallExpression,
|
||||
isLiteral,
|
||||
isMemberExpression,
|
||||
isNewExpression
|
||||
} = _t;
|
||||
|
||||
function UnaryExpression(node) {
|
||||
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" || node.operator === "throw") {
|
||||
this.word(node.operator);
|
||||
this.space();
|
||||
} else {
|
||||
this.token(node.operator);
|
||||
}
|
||||
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function DoExpression(node) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ParenthesizedExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function UpdateExpression(node) {
|
||||
if (node.prefix) {
|
||||
this.token(node.operator);
|
||||
this.print(node.argument, node);
|
||||
} else {
|
||||
this.printTerminatorless(node.argument, node, true);
|
||||
this.token(node.operator);
|
||||
}
|
||||
}
|
||||
|
||||
function ConditionalExpression(node) {
|
||||
this.print(node.test, node);
|
||||
this.space();
|
||||
this.tokenChar(63);
|
||||
this.space();
|
||||
this.print(node.consequent, node);
|
||||
this.space();
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.alternate, node);
|
||||
}
|
||||
|
||||
function NewExpression(node, parent) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.print(node.callee, node);
|
||||
|
||||
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);
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
|
||||
this.tokenChar(40);
|
||||
this.printList(node.arguments, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function SequenceExpression(node) {
|
||||
this.printList(node.expressions, node);
|
||||
}
|
||||
|
||||
function ThisExpression() {
|
||||
this.word("this");
|
||||
}
|
||||
|
||||
function Super() {
|
||||
this.word("super");
|
||||
}
|
||||
|
||||
function isDecoratorMemberExpression(node) {
|
||||
switch (node.type) {
|
||||
case "Identifier":
|
||||
return true;
|
||||
|
||||
case "MemberExpression":
|
||||
return !node.computed && node.property.type === "Identifier" && isDecoratorMemberExpression(node.object);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function shouldParenthesizeDecoratorExpression(node) {
|
||||
if (node.type === "CallExpression") {
|
||||
node = node.callee;
|
||||
}
|
||||
|
||||
if (node.type === "ParenthesizedExpression") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !isDecoratorMemberExpression(node);
|
||||
}
|
||||
|
||||
function Decorator(node) {
|
||||
this.tokenChar(64);
|
||||
const {
|
||||
expression
|
||||
} = node;
|
||||
|
||||
if (shouldParenthesizeDecoratorExpression(expression)) {
|
||||
this.tokenChar(40);
|
||||
this.print(expression, node);
|
||||
this.tokenChar(41);
|
||||
} else {
|
||||
this.print(expression, node);
|
||||
}
|
||||
|
||||
this.newline();
|
||||
}
|
||||
|
||||
function OptionalMemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
|
||||
if (!node.computed && isMemberExpression(node.property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
|
||||
let computed = node.computed;
|
||||
|
||||
if (isLiteral(node.property) && typeof node.property.value === "number") {
|
||||
computed = true;
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
|
||||
if (computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.property, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (!node.optional) {
|
||||
this.tokenChar(46);
|
||||
}
|
||||
|
||||
this.print(node.property, node);
|
||||
}
|
||||
}
|
||||
|
||||
function OptionalCallExpression(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.typeArguments, node);
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
|
||||
this.tokenChar(40);
|
||||
this.printList(node.arguments, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function CallExpression(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.typeArguments, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.tokenChar(40);
|
||||
this.printList(node.arguments, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function Import() {
|
||||
this.word("import");
|
||||
}
|
||||
|
||||
function AwaitExpression(node) {
|
||||
this.word("await");
|
||||
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
}
|
||||
}
|
||||
|
||||
function YieldExpression(node) {
|
||||
this.word("yield");
|
||||
|
||||
if (node.delegate) {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
}
|
||||
}
|
||||
|
||||
function EmptyStatement() {
|
||||
this.semicolon(true);
|
||||
}
|
||||
|
||||
function ExpressionStatement(node) {
|
||||
this.print(node.expression, node);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function AssignmentPattern(node) {
|
||||
this.print(node.left, node);
|
||||
if (node.left.optional) this.tokenChar(63);
|
||||
this.print(node.left.typeAnnotation, node);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
}
|
||||
|
||||
function AssignmentExpression(node, parent) {
|
||||
const parens = this.inForStatementInitCounter && node.operator === "in" && !n.needsParens(node, parent);
|
||||
|
||||
if (parens) {
|
||||
this.tokenChar(40);
|
||||
}
|
||||
|
||||
this.print(node.left, node);
|
||||
this.space();
|
||||
|
||||
if (node.operator === "in" || node.operator === "instanceof") {
|
||||
this.word(node.operator);
|
||||
} else {
|
||||
this.token(node.operator);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
|
||||
if (parens) {
|
||||
this.tokenChar(41);
|
||||
}
|
||||
}
|
||||
|
||||
function BindExpression(node) {
|
||||
this.print(node.object, node);
|
||||
this.token("::");
|
||||
this.print(node.callee, node);
|
||||
}
|
||||
|
||||
function MemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
|
||||
if (!node.computed && isMemberExpression(node.property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
|
||||
let computed = node.computed;
|
||||
|
||||
if (isLiteral(node.property) && typeof node.property.value === "number") {
|
||||
computed = true;
|
||||
}
|
||||
|
||||
if (computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.property, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this.tokenChar(46);
|
||||
this.print(node.property, node);
|
||||
}
|
||||
}
|
||||
|
||||
function MetaProperty(node) {
|
||||
this.print(node.meta, node);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property, node);
|
||||
}
|
||||
|
||||
function PrivateName(node) {
|
||||
this.tokenChar(35);
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
function V8IntrinsicIdentifier(node) {
|
||||
this.tokenChar(37);
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
function ModuleExpression(node) {
|
||||
this.word("module");
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
|
||||
if (node.body.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
this.printSequence(node.body.body, node, {
|
||||
indent: true
|
||||
});
|
||||
this.rightBrace();
|
||||
}
|
||||
}
|
795
node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
Normal file
795
node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
148
node_modules/@babel/generator/lib/generators/index.js
generated
vendored
Normal file
148
node_modules/@babel/generator/lib/generators/index.js
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _templateLiterals = require("./template-literals");
|
||||
|
||||
Object.keys(_templateLiterals).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _templateLiterals[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _templateLiterals[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _expressions = require("./expressions");
|
||||
|
||||
Object.keys(_expressions).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _expressions[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _expressions[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _statements = require("./statements");
|
||||
|
||||
Object.keys(_statements).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _statements[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _statements[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _classes = require("./classes");
|
||||
|
||||
Object.keys(_classes).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _classes[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _classes[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _methods = require("./methods");
|
||||
|
||||
Object.keys(_methods).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _methods[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _methods[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _modules = require("./modules");
|
||||
|
||||
Object.keys(_modules).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _modules[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _modules[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
Object.keys(_types).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _types[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _flow = require("./flow");
|
||||
|
||||
Object.keys(_flow).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _flow[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _flow[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _base = require("./base");
|
||||
|
||||
Object.keys(_base).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _base[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _base[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _jsx = require("./jsx");
|
||||
|
||||
Object.keys(_jsx).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _jsx[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _jsx[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _typescript = require("./typescript");
|
||||
|
||||
Object.keys(_typescript).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _typescript[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _typescript[key];
|
||||
}
|
||||
});
|
||||
});
|
145
node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
Normal file
145
node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.JSXAttribute = JSXAttribute;
|
||||
exports.JSXClosingElement = JSXClosingElement;
|
||||
exports.JSXClosingFragment = JSXClosingFragment;
|
||||
exports.JSXElement = JSXElement;
|
||||
exports.JSXEmptyExpression = JSXEmptyExpression;
|
||||
exports.JSXExpressionContainer = JSXExpressionContainer;
|
||||
exports.JSXFragment = JSXFragment;
|
||||
exports.JSXIdentifier = JSXIdentifier;
|
||||
exports.JSXMemberExpression = JSXMemberExpression;
|
||||
exports.JSXNamespacedName = JSXNamespacedName;
|
||||
exports.JSXOpeningElement = JSXOpeningElement;
|
||||
exports.JSXOpeningFragment = JSXOpeningFragment;
|
||||
exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
||||
exports.JSXSpreadChild = JSXSpreadChild;
|
||||
exports.JSXText = JSXText;
|
||||
|
||||
function JSXAttribute(node) {
|
||||
this.print(node.name, node);
|
||||
|
||||
if (node.value) {
|
||||
this.tokenChar(61);
|
||||
this.print(node.value, node);
|
||||
}
|
||||
}
|
||||
|
||||
function JSXIdentifier(node) {
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
function JSXNamespacedName(node) {
|
||||
this.print(node.namespace, node);
|
||||
this.tokenChar(58);
|
||||
this.print(node.name, node);
|
||||
}
|
||||
|
||||
function JSXMemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property, node);
|
||||
}
|
||||
|
||||
function JSXSpreadAttribute(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function JSXExpressionContainer(node) {
|
||||
this.tokenChar(123);
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function JSXSpreadChild(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function JSXText(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (raw !== undefined) {
|
||||
this.token(raw);
|
||||
} else {
|
||||
this.token(node.value);
|
||||
}
|
||||
}
|
||||
|
||||
function JSXElement(node) {
|
||||
const open = node.openingElement;
|
||||
this.print(open, node);
|
||||
if (open.selfClosing) return;
|
||||
this.indent();
|
||||
|
||||
for (const child of node.children) {
|
||||
this.print(child, node);
|
||||
}
|
||||
|
||||
this.dedent();
|
||||
this.print(node.closingElement, node);
|
||||
}
|
||||
|
||||
function spaceSeparator() {
|
||||
this.space();
|
||||
}
|
||||
|
||||
function JSXOpeningElement(node) {
|
||||
this.tokenChar(60);
|
||||
this.print(node.name, node);
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if (node.attributes.length > 0) {
|
||||
this.space();
|
||||
this.printJoin(node.attributes, node, {
|
||||
separator: spaceSeparator
|
||||
});
|
||||
}
|
||||
|
||||
if (node.selfClosing) {
|
||||
this.space();
|
||||
this.token("/>");
|
||||
} else {
|
||||
this.tokenChar(62);
|
||||
}
|
||||
}
|
||||
|
||||
function JSXClosingElement(node) {
|
||||
this.token("</");
|
||||
this.print(node.name, node);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
|
||||
function JSXEmptyExpression(node) {
|
||||
this.printInnerComments(node);
|
||||
}
|
||||
|
||||
function JSXFragment(node) {
|
||||
this.print(node.openingFragment, node);
|
||||
this.indent();
|
||||
|
||||
for (const child of node.children) {
|
||||
this.print(child, node);
|
||||
}
|
||||
|
||||
this.dedent();
|
||||
this.print(node.closingFragment, node);
|
||||
}
|
||||
|
||||
function JSXOpeningFragment() {
|
||||
this.tokenChar(60);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
|
||||
function JSXClosingFragment() {
|
||||
this.token("</");
|
||||
this.tokenChar(62);
|
||||
}
|
156
node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
Normal file
156
node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
||||
exports.FunctionDeclaration = exports.FunctionExpression = FunctionExpression;
|
||||
exports._functionHead = _functionHead;
|
||||
exports._methodHead = _methodHead;
|
||||
exports._param = _param;
|
||||
exports._parameters = _parameters;
|
||||
exports._params = _params;
|
||||
exports._predicate = _predicate;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isIdentifier
|
||||
} = _t;
|
||||
|
||||
function _params(node) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.tokenChar(40);
|
||||
|
||||
this._parameters(node.params, node);
|
||||
|
||||
this.tokenChar(41);
|
||||
this.print(node.returnType, node, node.type === "ArrowFunctionExpression");
|
||||
}
|
||||
|
||||
function _parameters(parameters, parent) {
|
||||
for (let i = 0; i < parameters.length; i++) {
|
||||
this._param(parameters[i], parent);
|
||||
|
||||
if (i < parameters.length - 1) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _param(parameter, parent) {
|
||||
this.printJoin(parameter.decorators, parameter);
|
||||
this.print(parameter, parent);
|
||||
|
||||
if (parameter.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
this.print(parameter.typeAnnotation, parameter);
|
||||
}
|
||||
|
||||
function _methodHead(node) {
|
||||
const kind = node.kind;
|
||||
const key = node.key;
|
||||
|
||||
if (kind === "get" || kind === "set") {
|
||||
this.word(kind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.async) {
|
||||
this._catchUp("start", key.loc);
|
||||
|
||||
this.word("async");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (kind === "method" || kind === "init") {
|
||||
if (node.generator) {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(key, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this.print(key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
this._params(node);
|
||||
}
|
||||
|
||||
function _predicate(node) {
|
||||
if (node.predicate) {
|
||||
if (!node.returnType) {
|
||||
this.tokenChar(58);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.predicate, node);
|
||||
}
|
||||
}
|
||||
|
||||
function _functionHead(node) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("function");
|
||||
if (node.generator) this.tokenChar(42);
|
||||
this.printInnerComments(node);
|
||||
this.space();
|
||||
|
||||
if (node.id) {
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
this._params(node);
|
||||
|
||||
if (node.type !== "TSDeclareFunction") {
|
||||
this._predicate(node);
|
||||
}
|
||||
}
|
||||
|
||||
function FunctionExpression(node) {
|
||||
this._functionHead(node);
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ArrowFunctionExpression(node) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this.space();
|
||||
}
|
||||
|
||||
const firstParam = node.params[0];
|
||||
|
||||
if (!this.format.retainLines && !this.format.auxiliaryCommentBefore && !this.format.auxiliaryCommentAfter && node.params.length === 1 && isIdentifier(firstParam) && !hasTypesOrComments(node, firstParam)) {
|
||||
this.print(firstParam, node);
|
||||
} else {
|
||||
this._params(node);
|
||||
}
|
||||
|
||||
this._predicate(node);
|
||||
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
245
node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
Normal file
245
node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ExportAllDeclaration = ExportAllDeclaration;
|
||||
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
|
||||
exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
|
||||
exports.ExportNamedDeclaration = ExportNamedDeclaration;
|
||||
exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
|
||||
exports.ExportSpecifier = ExportSpecifier;
|
||||
exports.ImportAttribute = ImportAttribute;
|
||||
exports.ImportDeclaration = ImportDeclaration;
|
||||
exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
|
||||
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
|
||||
exports.ImportSpecifier = ImportSpecifier;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isClassDeclaration,
|
||||
isExportDefaultSpecifier,
|
||||
isExportNamespaceSpecifier,
|
||||
isImportDefaultSpecifier,
|
||||
isImportNamespaceSpecifier,
|
||||
isStatement
|
||||
} = _t;
|
||||
|
||||
function ImportSpecifier(node) {
|
||||
if (node.importKind === "type" || node.importKind === "typeof") {
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.imported, node);
|
||||
|
||||
if (node.local && node.local.name !== node.imported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local, node);
|
||||
}
|
||||
}
|
||||
|
||||
function ImportDefaultSpecifier(node) {
|
||||
this.print(node.local, node);
|
||||
}
|
||||
|
||||
function ExportDefaultSpecifier(node) {
|
||||
this.print(node.exported, node);
|
||||
}
|
||||
|
||||
function ExportSpecifier(node) {
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.local, node);
|
||||
|
||||
if (node.exported && node.local.name !== node.exported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported, node);
|
||||
}
|
||||
}
|
||||
|
||||
function ExportNamespaceSpecifier(node) {
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported, node);
|
||||
}
|
||||
|
||||
function ExportAllDeclaration(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
this.printAssertions(node);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ExportNamedDeclaration(node) {
|
||||
{
|
||||
if (this.format.decoratorsBeforeExport && isClassDeclaration(node.declaration)) {
|
||||
this.printJoin(node.declaration.decorators, node);
|
||||
}
|
||||
}
|
||||
this.word("export");
|
||||
this.space();
|
||||
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
|
||||
const specifiers = node.specifiers.slice(0);
|
||||
let hasSpecial = false;
|
||||
|
||||
for (;;) {
|
||||
const first = specifiers[0];
|
||||
|
||||
if (isExportDefaultSpecifier(first) || isExportNamespaceSpecifier(first)) {
|
||||
hasSpecial = true;
|
||||
this.print(specifiers.shift(), node);
|
||||
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (specifiers.length || !specifiers.length && !hasSpecial) {
|
||||
this.tokenChar(123);
|
||||
|
||||
if (specifiers.length) {
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
if (node.source) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
this.printAssertions(node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
|
||||
function ExportDefaultDeclaration(node) {
|
||||
{
|
||||
if (this.format.decoratorsBeforeExport && isClassDeclaration(node.declaration)) {
|
||||
this.printJoin(node.declaration.decorators, node);
|
||||
}
|
||||
}
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.word("default");
|
||||
this.space();
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
}
|
||||
|
||||
function ImportDeclaration(node) {
|
||||
this.word("import");
|
||||
this.space();
|
||||
const isTypeKind = node.importKind === "type" || node.importKind === "typeof";
|
||||
|
||||
if (isTypeKind) {
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
const specifiers = node.specifiers.slice(0);
|
||||
const hasSpecifiers = !!specifiers.length;
|
||||
|
||||
while (hasSpecifiers) {
|
||||
const first = specifiers[0];
|
||||
|
||||
if (isImportDefaultSpecifier(first) || isImportNamespaceSpecifier(first)) {
|
||||
this.print(specifiers.shift(), node);
|
||||
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
} else if (isTypeKind && !hasSpecifiers) {
|
||||
this.tokenChar(123);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
if (hasSpecifiers || isTypeKind) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.source, node);
|
||||
this.printAssertions(node);
|
||||
{
|
||||
var _node$attributes;
|
||||
|
||||
if ((_node$attributes = node.attributes) != null && _node$attributes.length) {
|
||||
this.space();
|
||||
this.word("with");
|
||||
this.space();
|
||||
this.printList(node.attributes, node);
|
||||
}
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ImportAttribute(node) {
|
||||
this.print(node.key);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
|
||||
function ImportNamespaceSpecifier(node) {
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local, node);
|
||||
}
|
340
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
Normal file
340
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
Normal file
@@ -0,0 +1,340 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.BreakStatement = BreakStatement;
|
||||
exports.CatchClause = CatchClause;
|
||||
exports.ContinueStatement = ContinueStatement;
|
||||
exports.DebuggerStatement = DebuggerStatement;
|
||||
exports.DoWhileStatement = DoWhileStatement;
|
||||
exports.ForOfStatement = exports.ForInStatement = void 0;
|
||||
exports.ForStatement = ForStatement;
|
||||
exports.IfStatement = IfStatement;
|
||||
exports.LabeledStatement = LabeledStatement;
|
||||
exports.ReturnStatement = ReturnStatement;
|
||||
exports.SwitchCase = SwitchCase;
|
||||
exports.SwitchStatement = SwitchStatement;
|
||||
exports.ThrowStatement = ThrowStatement;
|
||||
exports.TryStatement = TryStatement;
|
||||
exports.VariableDeclaration = VariableDeclaration;
|
||||
exports.VariableDeclarator = VariableDeclarator;
|
||||
exports.WhileStatement = WhileStatement;
|
||||
exports.WithStatement = WithStatement;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isFor,
|
||||
isForStatement,
|
||||
isIfStatement,
|
||||
isStatement
|
||||
} = _t;
|
||||
|
||||
function WithStatement(node) {
|
||||
this.word("with");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.object, node);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
|
||||
if (needsBlock) {
|
||||
this.tokenChar(123);
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
|
||||
this.printAndIndentOnComments(node.consequent, node);
|
||||
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
if (node.alternate) {
|
||||
if (this.endsWith(125)) this.space();
|
||||
this.word("else");
|
||||
this.space();
|
||||
this.printAndIndentOnComments(node.alternate, node);
|
||||
}
|
||||
}
|
||||
|
||||
function getLastStatement(statement) {
|
||||
const {
|
||||
body
|
||||
} = statement;
|
||||
|
||||
if (isStatement(body) === false) {
|
||||
return statement;
|
||||
}
|
||||
|
||||
return getLastStatement(body);
|
||||
}
|
||||
|
||||
function ForStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.inForStatementInitCounter++;
|
||||
this.print(node.init, node);
|
||||
this.inForStatementInitCounter--;
|
||||
this.tokenChar(59);
|
||||
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
}
|
||||
|
||||
this.tokenChar(59);
|
||||
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update, node);
|
||||
}
|
||||
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
function ForXStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
const isForOf = node.type === "ForOfStatement";
|
||||
|
||||
if (isForOf && node.await) {
|
||||
this.word("await");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(40);
|
||||
this.print(node.left, node);
|
||||
this.space();
|
||||
this.word(isForOf ? "of" : "in");
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
const ForInStatement = ForXStatement;
|
||||
exports.ForInStatement = ForInStatement;
|
||||
const ForOfStatement = ForXStatement;
|
||||
exports.ForOfStatement = ForOfStatement;
|
||||
|
||||
function DoWhileStatement(node) {
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.space();
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.tokenChar(41);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function printStatementAfterKeyword(printer, node, parent, isLabel) {
|
||||
if (node) {
|
||||
printer.space();
|
||||
printer.printTerminatorless(node, parent, isLabel);
|
||||
}
|
||||
|
||||
printer.semicolon();
|
||||
}
|
||||
|
||||
function BreakStatement(node) {
|
||||
this.word("break");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
}
|
||||
|
||||
function ContinueStatement(node) {
|
||||
this.word("continue");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
}
|
||||
|
||||
function ReturnStatement(node) {
|
||||
this.word("return");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
}
|
||||
|
||||
function ThrowStatement(node) {
|
||||
this.word("throw");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
}
|
||||
|
||||
function LabeledStatement(node) {
|
||||
this.print(node.label, node);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function TryStatement(node) {
|
||||
this.word("try");
|
||||
this.space();
|
||||
this.print(node.block, node);
|
||||
this.space();
|
||||
|
||||
if (node.handlers) {
|
||||
this.print(node.handlers[0], node);
|
||||
} else {
|
||||
this.print(node.handler, node);
|
||||
}
|
||||
|
||||
if (node.finalizer) {
|
||||
this.space();
|
||||
this.word("finally");
|
||||
this.space();
|
||||
this.print(node.finalizer, node);
|
||||
}
|
||||
}
|
||||
|
||||
function CatchClause(node) {
|
||||
this.word("catch");
|
||||
this.space();
|
||||
|
||||
if (node.param) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.param, node);
|
||||
this.print(node.param.typeAnnotation, node);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.discriminant, node);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.printSequence(node.cases, node, {
|
||||
indent: true,
|
||||
|
||||
addNewlines(leading, cas) {
|
||||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
|
||||
}
|
||||
|
||||
});
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.word("default");
|
||||
this.tokenChar(58);
|
||||
}
|
||||
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, node, {
|
||||
indent: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function DebuggerStatement() {
|
||||
this.word("debugger");
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function variableDeclarationIndent() {
|
||||
this.tokenChar(44);
|
||||
this.newline();
|
||||
|
||||
if (this.endsWith(10)) {
|
||||
for (let i = 0; i < 4; i++) this.space(true);
|
||||
}
|
||||
}
|
||||
|
||||
function constDeclarationIndent() {
|
||||
this.tokenChar(44);
|
||||
this.newline();
|
||||
|
||||
if (this.endsWith(10)) {
|
||||
for (let i = 0; i < 6; i++) this.space(true);
|
||||
}
|
||||
}
|
||||
|
||||
function VariableDeclaration(node, parent) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word(node.kind);
|
||||
this.space();
|
||||
let hasInits = false;
|
||||
|
||||
if (!isFor(parent)) {
|
||||
for (const declar of node.declarations) {
|
||||
if (declar.init) {
|
||||
hasInits = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let separator;
|
||||
|
||||
if (hasInits) {
|
||||
separator = node.kind === "const" ? constDeclarationIndent : variableDeclarationIndent;
|
||||
}
|
||||
|
||||
this.printList(node.declarations, node, {
|
||||
separator
|
||||
});
|
||||
|
||||
if (isFor(parent)) {
|
||||
if (isForStatement(parent)) {
|
||||
if (parent.init === node) return;
|
||||
} else {
|
||||
if (parent.left === node) return;
|
||||
}
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function VariableDeclarator(node) {
|
||||
this.print(node.id, node);
|
||||
if (node.definite) this.tokenChar(33);
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
|
||||
if (node.init) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.init, node);
|
||||
}
|
||||
}
|
33
node_modules/@babel/generator/lib/generators/template-literals.js
generated
vendored
Normal file
33
node_modules/@babel/generator/lib/generators/template-literals.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
function TemplateElement(node, parent) {
|
||||
const isFirst = parent.quasis[0] === node;
|
||||
const isLast = parent.quasis[parent.quasis.length - 1] === node;
|
||||
const value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${");
|
||||
this.token(value, true);
|
||||
}
|
||||
|
||||
function TemplateLiteral(node) {
|
||||
const quasis = node.quasis;
|
||||
|
||||
for (let i = 0; i < quasis.length; i++) {
|
||||
this.print(quasis[i], node);
|
||||
|
||||
if (i + 1 < quasis.length) {
|
||||
this.print(node.expressions[i], node);
|
||||
}
|
||||
}
|
||||
}
|
276
node_modules/@babel/generator/lib/generators/types.js
generated
vendored
Normal file
276
node_modules/@babel/generator/lib/generators/types.js
generated
vendored
Normal file
@@ -0,0 +1,276 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ArgumentPlaceholder = ArgumentPlaceholder;
|
||||
exports.ArrayPattern = exports.ArrayExpression = ArrayExpression;
|
||||
exports.BigIntLiteral = BigIntLiteral;
|
||||
exports.BooleanLiteral = BooleanLiteral;
|
||||
exports.DecimalLiteral = DecimalLiteral;
|
||||
exports.Identifier = Identifier;
|
||||
exports.NullLiteral = NullLiteral;
|
||||
exports.NumericLiteral = NumericLiteral;
|
||||
exports.ObjectPattern = exports.ObjectExpression = ObjectExpression;
|
||||
exports.ObjectMethod = ObjectMethod;
|
||||
exports.ObjectProperty = ObjectProperty;
|
||||
exports.PipelineBareFunction = PipelineBareFunction;
|
||||
exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference;
|
||||
exports.PipelineTopicExpression = PipelineTopicExpression;
|
||||
exports.RecordExpression = RecordExpression;
|
||||
exports.RegExpLiteral = RegExpLiteral;
|
||||
exports.SpreadElement = exports.RestElement = RestElement;
|
||||
exports.StringLiteral = StringLiteral;
|
||||
exports.TopicReference = TopicReference;
|
||||
exports.TupleExpression = TupleExpression;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _jsesc = require("jsesc");
|
||||
|
||||
const {
|
||||
isAssignmentPattern,
|
||||
isIdentifier
|
||||
} = _t;
|
||||
|
||||
function Identifier(node) {
|
||||
this.exactSource(node.loc, () => {
|
||||
this.word(node.name);
|
||||
});
|
||||
}
|
||||
|
||||
function ArgumentPlaceholder() {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
function RestElement(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function ObjectExpression(node) {
|
||||
const props = node.properties;
|
||||
this.tokenChar(123);
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
indent: true,
|
||||
statement: true
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function ObjectMethod(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
this._methodHead(node);
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ObjectProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (isAssignmentPattern(node.value) && isIdentifier(node.key) && node.key.name === node.value.left.name) {
|
||||
this.print(node.value, node);
|
||||
return;
|
||||
}
|
||||
|
||||
this.print(node.key, node);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function ArrayExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
this.tokenChar(91);
|
||||
this.printInnerComments(node);
|
||||
|
||||
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);
|
||||
} else {
|
||||
this.tokenChar(44);
|
||||
}
|
||||
}
|
||||
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
function RecordExpression(node) {
|
||||
const props = node.properties;
|
||||
let startToken;
|
||||
let endToken;
|
||||
|
||||
if (this.format.recordAndTupleSyntaxType === "bar") {
|
||||
startToken = "{|";
|
||||
endToken = "|}";
|
||||
} else if (this.format.recordAndTupleSyntaxType === "hash") {
|
||||
startToken = "#{";
|
||||
endToken = "}";
|
||||
} else {
|
||||
throw new Error(`The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify(this.format.recordAndTupleSyntaxType)} received).`);
|
||||
}
|
||||
|
||||
this.token(startToken);
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
indent: true,
|
||||
statement: true
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token(endToken);
|
||||
}
|
||||
|
||||
function TupleExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
let startToken;
|
||||
let endToken;
|
||||
|
||||
if (this.format.recordAndTupleSyntaxType === "bar") {
|
||||
startToken = "[|";
|
||||
endToken = "|]";
|
||||
} else if (this.format.recordAndTupleSyntaxType === "hash") {
|
||||
startToken = "#[";
|
||||
endToken = "]";
|
||||
} else {
|
||||
throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`);
|
||||
}
|
||||
|
||||
this.token(startToken);
|
||||
this.printInnerComments(node);
|
||||
|
||||
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.token(endToken);
|
||||
}
|
||||
|
||||
function RegExpLiteral(node) {
|
||||
this.word(`/${node.pattern}/${node.flags}`);
|
||||
}
|
||||
|
||||
function BooleanLiteral(node) {
|
||||
this.word(node.value ? "true" : "false");
|
||||
}
|
||||
|
||||
function NullLiteral() {
|
||||
this.word("null");
|
||||
}
|
||||
|
||||
function NumericLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
const opts = this.format.jsescOption;
|
||||
const value = node.value + "";
|
||||
|
||||
if (opts.numbers) {
|
||||
this.number(_jsesc(node.value, opts));
|
||||
} else if (raw == null) {
|
||||
this.number(value);
|
||||
} else if (this.format.minified) {
|
||||
this.number(raw.length < value.length ? raw : value);
|
||||
} else {
|
||||
this.number(raw);
|
||||
}
|
||||
}
|
||||
|
||||
function StringLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.token(raw);
|
||||
return;
|
||||
}
|
||||
|
||||
const val = _jsesc(node.value, Object.assign(this.format.jsescOption, this.format.jsonCompatibleStrings && {
|
||||
json: true
|
||||
}));
|
||||
|
||||
return this.token(val);
|
||||
}
|
||||
|
||||
function BigIntLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.word(raw);
|
||||
return;
|
||||
}
|
||||
|
||||
this.word(node.value + "n");
|
||||
}
|
||||
|
||||
function DecimalLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.word(raw);
|
||||
return;
|
||||
}
|
||||
|
||||
this.word(node.value + "m");
|
||||
}
|
||||
|
||||
const validTopicTokenSet = new Set(["^^", "@@", "^", "%", "#"]);
|
||||
|
||||
function TopicReference() {
|
||||
const {
|
||||
topicToken
|
||||
} = this.format;
|
||||
|
||||
if (validTopicTokenSet.has(topicToken)) {
|
||||
this.token(topicToken);
|
||||
} else {
|
||||
const givenTopicTokenJSON = JSON.stringify(topicToken);
|
||||
const validTopics = Array.from(validTopicTokenSet, v => JSON.stringify(v));
|
||||
throw new Error(`The "topicToken" generator option must be one of ` + `${validTopics.join(", ")} (${givenTopicTokenJSON} received instead).`);
|
||||
}
|
||||
}
|
||||
|
||||
function PipelineTopicExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
}
|
||||
|
||||
function PipelineBareFunction(node) {
|
||||
this.print(node.callee, node);
|
||||
}
|
||||
|
||||
function PipelinePrimaryTopicReference() {
|
||||
this.tokenChar(35);
|
||||
}
|
833
node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
Normal file
833
node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
97
node_modules/@babel/generator/lib/index.js
generated
vendored
Normal file
97
node_modules/@babel/generator/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.CodeGenerator = void 0;
|
||||
exports.default = generate;
|
||||
|
||||
var _sourceMap = require("./source-map");
|
||||
|
||||
var _printer = require("./printer");
|
||||
|
||||
class Generator extends _printer.default {
|
||||
constructor(ast, opts = {}, code) {
|
||||
const format = normalizeOptions(code, opts);
|
||||
const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
super(format, map);
|
||||
this.ast = void 0;
|
||||
this.ast = ast;
|
||||
}
|
||||
|
||||
generate() {
|
||||
return super.generate(this.ast);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function normalizeOptions(code, opts) {
|
||||
const format = {
|
||||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
|
||||
shouldPrintComment: opts.shouldPrintComment,
|
||||
retainLines: opts.retainLines,
|
||||
retainFunctionParens: opts.retainFunctionParens,
|
||||
comments: opts.comments == null || opts.comments,
|
||||
compact: opts.compact,
|
||||
minified: opts.minified,
|
||||
concise: opts.concise,
|
||||
indent: {
|
||||
adjustMultilineComment: true,
|
||||
style: " ",
|
||||
base: 0
|
||||
},
|
||||
jsescOption: Object.assign({
|
||||
quotes: "double",
|
||||
wrap: true,
|
||||
minimal: false
|
||||
}, opts.jsescOption),
|
||||
recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType,
|
||||
topicToken: opts.topicToken
|
||||
};
|
||||
{
|
||||
format.decoratorsBeforeExport = !!opts.decoratorsBeforeExport;
|
||||
format.jsonCompatibleStrings = opts.jsonCompatibleStrings;
|
||||
}
|
||||
|
||||
if (format.minified) {
|
||||
format.compact = true;
|
||||
|
||||
format.shouldPrintComment = format.shouldPrintComment || (() => format.comments);
|
||||
} else {
|
||||
format.shouldPrintComment = format.shouldPrintComment || (value => format.comments || value.includes("@license") || value.includes("@preserve"));
|
||||
}
|
||||
|
||||
if (format.compact === "auto") {
|
||||
format.compact = code.length > 500000;
|
||||
|
||||
if (format.compact) {
|
||||
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + `${opts.filename} as it exceeds the max of ${"500KB"}.`);
|
||||
}
|
||||
}
|
||||
|
||||
if (format.compact) {
|
||||
format.indent.adjustMultilineComment = false;
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
class CodeGenerator {
|
||||
constructor(ast, opts, code) {
|
||||
this._generator = void 0;
|
||||
this._generator = new Generator(ast, opts, code);
|
||||
}
|
||||
|
||||
generate() {
|
||||
return this._generator.generate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.CodeGenerator = CodeGenerator;
|
||||
|
||||
function generate(ast, opts, code) {
|
||||
const gen = new Generator(ast, opts, code);
|
||||
return gen.generate();
|
||||
}
|
99
node_modules/@babel/generator/lib/node/index.js
generated
vendored
Normal file
99
node_modules/@babel/generator/lib/node/index.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.needsParens = needsParens;
|
||||
exports.needsWhitespace = needsWhitespace;
|
||||
exports.needsWhitespaceAfter = needsWhitespaceAfter;
|
||||
exports.needsWhitespaceBefore = needsWhitespaceBefore;
|
||||
|
||||
var whitespace = require("./whitespace");
|
||||
|
||||
var parens = require("./parentheses");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
isCallExpression,
|
||||
isExpressionStatement,
|
||||
isMemberExpression,
|
||||
isNewExpression
|
||||
} = _t;
|
||||
|
||||
function expandAliases(obj) {
|
||||
const newObj = {};
|
||||
|
||||
function add(type, func) {
|
||||
const fn = newObj[type];
|
||||
newObj[type] = fn ? function (node, parent, stack) {
|
||||
const result = fn(node, parent, stack);
|
||||
return result == null ? func(node, parent, stack) : result;
|
||||
} : func;
|
||||
}
|
||||
|
||||
for (const type of Object.keys(obj)) {
|
||||
const aliases = FLIPPED_ALIAS_KEYS[type];
|
||||
|
||||
if (aliases) {
|
||||
for (const alias of aliases) {
|
||||
add(alias, obj[type]);
|
||||
}
|
||||
} else {
|
||||
add(type, obj[type]);
|
||||
}
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
|
||||
const expandedParens = expandAliases(parens);
|
||||
const expandedWhitespaceNodes = expandAliases(whitespace.nodes);
|
||||
|
||||
function find(obj, node, parent, printStack) {
|
||||
const fn = obj[node.type];
|
||||
return fn ? fn(node, parent, printStack) : null;
|
||||
}
|
||||
|
||||
function isOrHasCallExpression(node) {
|
||||
if (isCallExpression(node)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isMemberExpression(node) && isOrHasCallExpression(node.object);
|
||||
}
|
||||
|
||||
function needsWhitespace(node, parent, type) {
|
||||
if (!node) return false;
|
||||
|
||||
if (isExpressionStatement(node)) {
|
||||
node = node.expression;
|
||||
}
|
||||
|
||||
const flag = find(expandedWhitespaceNodes, node, parent);
|
||||
|
||||
if (typeof flag === "number") {
|
||||
return (flag & type) !== 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function needsWhitespaceBefore(node, parent) {
|
||||
return needsWhitespace(node, parent, 1);
|
||||
}
|
||||
|
||||
function needsWhitespaceAfter(node, parent) {
|
||||
return needsWhitespace(node, parent, 2);
|
||||
}
|
||||
|
||||
function needsParens(node, parent, printStack) {
|
||||
if (!parent) return false;
|
||||
|
||||
if (isNewExpression(parent) && parent.callee === node) {
|
||||
if (isOrHasCallExpression(node)) return true;
|
||||
}
|
||||
|
||||
return find(expandedParens, node, parent, printStack);
|
||||
}
|
346
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
Normal file
346
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
Normal file
@@ -0,0 +1,346 @@
|
||||
"use strict";
|
||||
|
||||
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.DoExpression = DoExpression;
|
||||
exports.FunctionExpression = FunctionExpression;
|
||||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||||
exports.Identifier = Identifier;
|
||||
exports.LogicalExpression = LogicalExpression;
|
||||
exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||||
exports.ObjectExpression = ObjectExpression;
|
||||
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
|
||||
exports.OptionalCallExpression = exports.OptionalMemberExpression = OptionalMemberExpression;
|
||||
exports.SequenceExpression = SequenceExpression;
|
||||
exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSInferType = TSInferType;
|
||||
exports.TSInstantiationExpression = TSInstantiationExpression;
|
||||
exports.TSTypeAssertion = TSTypeAssertion;
|
||||
exports.TSIntersectionType = exports.TSUnionType = TSUnionType;
|
||||
exports.UnaryLike = UnaryLike;
|
||||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.AwaitExpression = exports.YieldExpression = YieldExpression;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isArrayTypeAnnotation,
|
||||
isArrowFunctionExpression,
|
||||
isAssignmentExpression,
|
||||
isAwaitExpression,
|
||||
isBinary,
|
||||
isBinaryExpression,
|
||||
isUpdateExpression,
|
||||
isCallExpression,
|
||||
isClass,
|
||||
isClassExpression,
|
||||
isConditional,
|
||||
isConditionalExpression,
|
||||
isExportDeclaration,
|
||||
isExportDefaultDeclaration,
|
||||
isExpressionStatement,
|
||||
isFor,
|
||||
isForInStatement,
|
||||
isForOfStatement,
|
||||
isForStatement,
|
||||
isFunctionExpression,
|
||||
isIfStatement,
|
||||
isIndexedAccessType,
|
||||
isIntersectionTypeAnnotation,
|
||||
isLogicalExpression,
|
||||
isMemberExpression,
|
||||
isNewExpression,
|
||||
isNullableTypeAnnotation,
|
||||
isObjectPattern,
|
||||
isOptionalCallExpression,
|
||||
isOptionalMemberExpression,
|
||||
isReturnStatement,
|
||||
isSequenceExpression,
|
||||
isSwitchStatement,
|
||||
isTSArrayType,
|
||||
isTSAsExpression,
|
||||
isTSInstantiationExpression,
|
||||
isTSIntersectionType,
|
||||
isTSNonNullExpression,
|
||||
isTSOptionalType,
|
||||
isTSRestType,
|
||||
isTSTypeAssertion,
|
||||
isTSUnionType,
|
||||
isTaggedTemplateExpression,
|
||||
isThrowStatement,
|
||||
isTypeAnnotation,
|
||||
isUnaryLike,
|
||||
isUnionTypeAnnotation,
|
||||
isVariableDeclarator,
|
||||
isWhileStatement,
|
||||
isYieldExpression
|
||||
} = _t;
|
||||
const PRECEDENCE = {
|
||||
"||": 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
|
||||
};
|
||||
|
||||
const isClassExtendsClause = (node, parent) => isClass(parent, {
|
||||
superClass: node
|
||||
});
|
||||
|
||||
const hasPostfixPart = (node, parent) => (isMemberExpression(parent) || isOptionalMemberExpression(parent)) && parent.object === node || (isCallExpression(parent) || isOptionalCallExpression(parent) || isNewExpression(parent)) && parent.callee === node || isTaggedTemplateExpression(parent) && parent.tag === node || isTSNonNullExpression(parent);
|
||||
|
||||
function NullableTypeAnnotation(node, parent) {
|
||||
return isArrayTypeAnnotation(parent);
|
||||
}
|
||||
|
||||
function FunctionTypeAnnotation(node, parent, printStack) {
|
||||
if (printStack.length < 3) return;
|
||||
return isUnionTypeAnnotation(parent) || isIntersectionTypeAnnotation(parent) || isArrayTypeAnnotation(parent) || isTypeAnnotation(parent) && isArrowFunctionExpression(printStack[printStack.length - 3]);
|
||||
}
|
||||
|
||||
function UpdateExpression(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isClassExtendsClause(node, parent);
|
||||
}
|
||||
|
||||
function ObjectExpression(node, parent, printStack) {
|
||||
return isFirstInContext(printStack, 1 | 2);
|
||||
}
|
||||
|
||||
function DoExpression(node, parent, printStack) {
|
||||
return !node.async && isFirstInContext(printStack, 1);
|
||||
}
|
||||
|
||||
function Binary(node, parent) {
|
||||
if (node.operator === "**" && isBinaryExpression(parent, {
|
||||
operator: "**"
|
||||
})) {
|
||||
return parent.left === node;
|
||||
}
|
||||
|
||||
if (isClassExtendsClause(node, parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasPostfixPart(node, parent) || isUnaryLike(parent) || isAwaitExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBinary(parent)) {
|
||||
const parentOp = parent.operator;
|
||||
const parentPos = PRECEDENCE[parentOp];
|
||||
const nodeOp = node.operator;
|
||||
const nodePos = PRECEDENCE[nodeOp];
|
||||
|
||||
if (parentPos === nodePos && parent.right === node && !isLogicalExpression(parent) || parentPos > nodePos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function UnionTypeAnnotation(node, parent) {
|
||||
return isArrayTypeAnnotation(parent) || isNullableTypeAnnotation(parent) || isIntersectionTypeAnnotation(parent) || isUnionTypeAnnotation(parent);
|
||||
}
|
||||
|
||||
function OptionalIndexedAccessType(node, parent) {
|
||||
return isIndexedAccessType(parent, {
|
||||
objectType: node
|
||||
});
|
||||
}
|
||||
|
||||
function TSAsExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function TSTypeAssertion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function TSUnionType(node, parent) {
|
||||
return isTSArrayType(parent) || isTSOptionalType(parent) || isTSIntersectionType(parent) || isTSUnionType(parent) || isTSRestType(parent);
|
||||
}
|
||||
|
||||
function TSInferType(node, parent) {
|
||||
return isTSArrayType(parent) || isTSOptionalType(parent);
|
||||
}
|
||||
|
||||
function TSInstantiationExpression(node, parent) {
|
||||
return (isCallExpression(parent) || isOptionalCallExpression(parent) || isNewExpression(parent) || isTSInstantiationExpression(parent)) && !!parent.typeParameters;
|
||||
}
|
||||
|
||||
function BinaryExpression(node, parent) {
|
||||
return node.operator === "in" && (isVariableDeclarator(parent) || isFor(parent));
|
||||
}
|
||||
|
||||
function SequenceExpression(node, parent) {
|
||||
if (isForStatement(parent) || isThrowStatement(parent) || isReturnStatement(parent) || isIfStatement(parent) && parent.test === node || isWhileStatement(parent) && parent.test === node || isForInStatement(parent) && parent.right === node || isSwitchStatement(parent) && parent.discriminant === node || isExpressionStatement(parent) && parent.expression === node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function YieldExpression(node, parent) {
|
||||
return isBinary(parent) || isUnaryLike(parent) || hasPostfixPart(node, parent) || isAwaitExpression(parent) && isYieldExpression(node) || isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent);
|
||||
}
|
||||
|
||||
function ClassExpression(node, parent, printStack) {
|
||||
return isFirstInContext(printStack, 1 | 4);
|
||||
}
|
||||
|
||||
function UnaryLike(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isBinaryExpression(parent, {
|
||||
operator: "**",
|
||||
left: node
|
||||
}) || isClassExtendsClause(node, parent);
|
||||
}
|
||||
|
||||
function FunctionExpression(node, parent, printStack) {
|
||||
return isFirstInContext(printStack, 1 | 4);
|
||||
}
|
||||
|
||||
function ArrowFunctionExpression(node, parent) {
|
||||
return isExportDeclaration(parent) || ConditionalExpression(node, parent);
|
||||
}
|
||||
|
||||
function ConditionalExpression(node, parent) {
|
||||
if (isUnaryLike(parent) || isBinary(parent) || isConditionalExpression(parent, {
|
||||
test: node
|
||||
}) || isAwaitExpression(parent) || isTSTypeAssertion(parent) || isTSAsExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return UnaryLike(node, parent);
|
||||
}
|
||||
|
||||
function OptionalMemberExpression(node, parent) {
|
||||
return isCallExpression(parent, {
|
||||
callee: node
|
||||
}) || isMemberExpression(parent, {
|
||||
object: node
|
||||
});
|
||||
}
|
||||
|
||||
function AssignmentExpression(node, parent) {
|
||||
if (isObjectPattern(node.left)) {
|
||||
return true;
|
||||
} else {
|
||||
return ConditionalExpression(node, parent);
|
||||
}
|
||||
}
|
||||
|
||||
function LogicalExpression(node, parent) {
|
||||
switch (node.operator) {
|
||||
case "||":
|
||||
if (!isLogicalExpression(parent)) return false;
|
||||
return parent.operator === "??" || parent.operator === "&&";
|
||||
|
||||
case "&&":
|
||||
return isLogicalExpression(parent, {
|
||||
operator: "??"
|
||||
});
|
||||
|
||||
case "??":
|
||||
return isLogicalExpression(parent) && parent.operator !== "??";
|
||||
}
|
||||
}
|
||||
|
||||
function Identifier(node, parent, printStack) {
|
||||
var _node$extra;
|
||||
|
||||
if ((_node$extra = node.extra) != null && _node$extra.parenthesized && isAssignmentExpression(parent, {
|
||||
left: node
|
||||
}) && (isFunctionExpression(parent.right) || isClassExpression(parent.right)) && parent.right.id == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (node.name === "let") {
|
||||
const isFollowedByBracket = isMemberExpression(parent, {
|
||||
object: node,
|
||||
computed: true
|
||||
}) || isOptionalMemberExpression(parent, {
|
||||
object: node,
|
||||
computed: true,
|
||||
optional: false
|
||||
});
|
||||
return isFirstInContext(printStack, isFollowedByBracket ? 1 | 8 | 16 | 32 : 32);
|
||||
}
|
||||
|
||||
return node.name === "async" && isForOfStatement(parent) && node === parent.left;
|
||||
}
|
||||
|
||||
function isFirstInContext(printStack, checkParam) {
|
||||
const expressionStatement = checkParam & 1;
|
||||
const arrowBody = checkParam & 2;
|
||||
const exportDefault = checkParam & 4;
|
||||
const forHead = checkParam & 8;
|
||||
const forInHead = checkParam & 16;
|
||||
const forOfHead = checkParam & 32;
|
||||
let i = printStack.length - 1;
|
||||
if (i <= 0) return;
|
||||
let node = printStack[i];
|
||||
i--;
|
||||
let parent = printStack[i];
|
||||
|
||||
while (i >= 0) {
|
||||
if (expressionStatement && isExpressionStatement(parent, {
|
||||
expression: node
|
||||
}) || exportDefault && isExportDefaultDeclaration(parent, {
|
||||
declaration: node
|
||||
}) || arrowBody && isArrowFunctionExpression(parent, {
|
||||
body: node
|
||||
}) || forHead && isForStatement(parent, {
|
||||
init: node
|
||||
}) || forInHead && isForInStatement(parent, {
|
||||
left: node
|
||||
}) || forOfHead && isForOfStatement(parent, {
|
||||
left: node
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (i > 0 && (hasPostfixPart(node, parent) && !isNewExpression(parent) || isSequenceExpression(parent) && parent.expressions[0] === node || isUpdateExpression(parent) && !parent.prefix || isConditional(parent, {
|
||||
test: node
|
||||
}) || isBinary(parent, {
|
||||
left: node
|
||||
}) || isAssignmentExpression(parent, {
|
||||
left: node
|
||||
}))) {
|
||||
node = parent;
|
||||
i--;
|
||||
parent = printStack[i];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
174
node_modules/@babel/generator/lib/node/whitespace.js
generated
vendored
Normal file
174
node_modules/@babel/generator/lib/node/whitespace.js
generated
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.nodes = void 0;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
isArrayExpression,
|
||||
isAssignmentExpression,
|
||||
isBinary,
|
||||
isBlockStatement,
|
||||
isCallExpression,
|
||||
isFunction,
|
||||
isIdentifier,
|
||||
isLiteral,
|
||||
isMemberExpression,
|
||||
isObjectExpression,
|
||||
isOptionalCallExpression,
|
||||
isOptionalMemberExpression,
|
||||
isStringLiteral
|
||||
} = _t;
|
||||
|
||||
function crawlInternal(node, state) {
|
||||
if (!node) return state;
|
||||
|
||||
if (isMemberExpression(node) || isOptionalMemberExpression(node)) {
|
||||
crawlInternal(node.object, state);
|
||||
if (node.computed) crawlInternal(node.property, state);
|
||||
} else if (isBinary(node) || isAssignmentExpression(node)) {
|
||||
crawlInternal(node.left, state);
|
||||
crawlInternal(node.right, state);
|
||||
} else if (isCallExpression(node) || isOptionalCallExpression(node)) {
|
||||
state.hasCall = true;
|
||||
crawlInternal(node.callee, state);
|
||||
} else if (isFunction(node)) {
|
||||
state.hasFunction = true;
|
||||
} else if (isIdentifier(node)) {
|
||||
state.hasHelper = state.hasHelper || node.callee && isHelper(node.callee);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
function crawl(node) {
|
||||
return crawlInternal(node, {
|
||||
hasCall: false,
|
||||
hasFunction: false,
|
||||
hasHelper: false
|
||||
});
|
||||
}
|
||||
|
||||
function isHelper(node) {
|
||||
if (!node) return false;
|
||||
|
||||
if (isMemberExpression(node)) {
|
||||
return isHelper(node.object) || isHelper(node.property);
|
||||
} else if (isIdentifier(node)) {
|
||||
return node.name === "require" || node.name.charCodeAt(0) === 95;
|
||||
} else if (isCallExpression(node)) {
|
||||
return isHelper(node.callee);
|
||||
} else if (isBinary(node) || isAssignmentExpression(node)) {
|
||||
return isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isType(node) {
|
||||
return isLiteral(node) || isObjectExpression(node) || isArrayExpression(node) || isIdentifier(node) || isMemberExpression(node);
|
||||
}
|
||||
|
||||
const nodes = {
|
||||
AssignmentExpression(node) {
|
||||
const state = crawl(node.right);
|
||||
|
||||
if (state.hasCall && state.hasHelper || state.hasFunction) {
|
||||
return state.hasFunction ? 1 | 2 : 2;
|
||||
}
|
||||
},
|
||||
|
||||
SwitchCase(node, parent) {
|
||||
return (!!node.consequent.length || parent.cases[0] === node ? 1 : 0) | (!node.consequent.length && parent.cases[parent.cases.length - 1] === node ? 2 : 0);
|
||||
},
|
||||
|
||||
LogicalExpression(node) {
|
||||
if (isFunction(node.left) || isFunction(node.right)) {
|
||||
return 2;
|
||||
}
|
||||
},
|
||||
|
||||
Literal(node) {
|
||||
if (isStringLiteral(node) && node.value === "use strict") {
|
||||
return 2;
|
||||
}
|
||||
},
|
||||
|
||||
CallExpression(node) {
|
||||
if (isFunction(node.callee) || isHelper(node)) {
|
||||
return 1 | 2;
|
||||
}
|
||||
},
|
||||
|
||||
OptionalCallExpression(node) {
|
||||
if (isFunction(node.callee)) {
|
||||
return 1 | 2;
|
||||
}
|
||||
},
|
||||
|
||||
VariableDeclaration(node) {
|
||||
for (let i = 0; i < node.declarations.length; i++) {
|
||||
const declar = node.declarations[i];
|
||||
let enabled = isHelper(declar.id) && !isType(declar.init);
|
||||
|
||||
if (!enabled && declar.init) {
|
||||
const state = crawl(declar.init);
|
||||
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
return 1 | 2;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
IfStatement(node) {
|
||||
if (isBlockStatement(node.consequent)) {
|
||||
return 1 | 2;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
exports.nodes = nodes;
|
||||
|
||||
nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) {
|
||||
if (parent.properties[0] === node) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeCallProperty = function (node, parent) {
|
||||
var _parent$properties;
|
||||
|
||||
if (parent.callProperties[0] === node && !((_parent$properties = parent.properties) != null && _parent$properties.length)) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeIndexer = function (node, parent) {
|
||||
var _parent$properties2, _parent$callPropertie;
|
||||
|
||||
if (parent.indexers[0] === node && !((_parent$properties2 = parent.properties) != null && _parent$properties2.length) && !((_parent$callPropertie = parent.callProperties) != null && _parent$callPropertie.length)) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeInternalSlot = function (node, parent) {
|
||||
var _parent$properties3, _parent$callPropertie2, _parent$indexers;
|
||||
|
||||
if (parent.internalSlots[0] === node && !((_parent$properties3 = parent.properties) != null && _parent$properties3.length) && !((_parent$callPropertie2 = parent.callProperties) != null && _parent$callPropertie2.length) && !((_parent$indexers = parent.indexers) != null && _parent$indexers.length)) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function ([type, amounts]) {
|
||||
[type].concat(FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
|
||||
const ret = amounts ? 1 | 2 : 0;
|
||||
|
||||
nodes[type] = () => ret;
|
||||
});
|
||||
});
|
614
node_modules/@babel/generator/lib/printer.js
generated
vendored
Normal file
614
node_modules/@babel/generator/lib/printer.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
62
node_modules/@babel/generator/lib/source-map.js
generated
vendored
Normal file
62
node_modules/@babel/generator/lib/source-map.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _genMapping = require("@jridgewell/gen-mapping");
|
||||
|
||||
class SourceMap {
|
||||
constructor(opts, code) {
|
||||
var _opts$sourceFileName;
|
||||
|
||||
this._map = void 0;
|
||||
this._rawMappings = void 0;
|
||||
this._sourceFileName = void 0;
|
||||
this._lastGenLine = 0;
|
||||
this._lastSourceLine = 0;
|
||||
this._lastSourceColumn = 0;
|
||||
const map = this._map = new _genMapping.GenMapping({
|
||||
sourceRoot: opts.sourceRoot
|
||||
});
|
||||
this._sourceFileName = (_opts$sourceFileName = opts.sourceFileName) == null ? void 0 : _opts$sourceFileName.replace(/\\/g, "/");
|
||||
this._rawMappings = undefined;
|
||||
|
||||
if (typeof code === "string") {
|
||||
(0, _genMapping.setSourceContent)(map, this._sourceFileName, code);
|
||||
} else if (typeof code === "object") {
|
||||
Object.keys(code).forEach(sourceFileName => {
|
||||
(0, _genMapping.setSourceContent)(map, sourceFileName.replace(/\\/g, "/"), code[sourceFileName]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get() {
|
||||
return (0, _genMapping.toEncodedMap)(this._map);
|
||||
}
|
||||
|
||||
getDecoded() {
|
||||
return (0, _genMapping.toDecodedMap)(this._map);
|
||||
}
|
||||
|
||||
getRawMappings() {
|
||||
return this._rawMappings || (this._rawMappings = (0, _genMapping.allMappings)(this._map));
|
||||
}
|
||||
|
||||
mark(generated, line, column, identifierName, filename) {
|
||||
this._rawMappings = undefined;
|
||||
(0, _genMapping.maybeAddMapping)(this._map, {
|
||||
name: identifierName,
|
||||
generated,
|
||||
source: line == null ? undefined : (filename == null ? void 0 : filename.replace(/\\/g, "/")) || this._sourceFileName,
|
||||
original: line == null ? undefined : {
|
||||
line: line,
|
||||
column: column
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = SourceMap;
|
Reference in New Issue
Block a user