Add node modules and compiled JavaScript from main
This commit is contained in:
parent
8bccaeaf7c
commit
4181bfdf50
7465 changed files with 1775003 additions and 2 deletions
22
node_modules/@babel/generator/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/generator/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
node_modules/@babel/generator/README.md
generated
vendored
Normal file
19
node_modules/@babel/generator/README.md
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# @babel/generator
|
||||
|
||||
> Turns an AST into code.
|
||||
|
||||
See our website [@babel/generator](https://babeljs.io/docs/en/babel-generator) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20generator%22+is%3Aopen) associated with this package.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/generator
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/generator --dev
|
||||
```
|
258
node_modules/@babel/generator/lib/buffer.js
generated
vendored
Normal file
258
node_modules/@babel/generator/lib/buffer.js
generated
vendored
Normal file
|
@ -0,0 +1,258 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function SourcePos() {
|
||||
return {
|
||||
identifierName: undefined,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
filename: undefined
|
||||
};
|
||||
}
|
||||
|
||||
const SPACES_RE = /^[ \t]+$/;
|
||||
|
||||
class Buffer {
|
||||
constructor(map) {
|
||||
this._map = null;
|
||||
this._buf = "";
|
||||
this._last = 0;
|
||||
this._queue = [];
|
||||
this._position = {
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
this._sourcePosition = SourcePos();
|
||||
this._disallowedPop = null;
|
||||
this._map = map;
|
||||
}
|
||||
|
||||
get() {
|
||||
this._flush();
|
||||
|
||||
const map = this._map;
|
||||
const result = {
|
||||
code: this._buf.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) {
|
||||
this._flush();
|
||||
|
||||
const {
|
||||
line,
|
||||
column,
|
||||
filename,
|
||||
identifierName
|
||||
} = this._sourcePosition;
|
||||
|
||||
this._append(str, line, column, identifierName, filename);
|
||||
}
|
||||
|
||||
queue(str) {
|
||||
if (str === "\n") {
|
||||
while (this._queue.length > 0 && SPACES_RE.test(this._queue[0][0])) {
|
||||
this._queue.shift();
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
line,
|
||||
column,
|
||||
filename,
|
||||
identifierName
|
||||
} = this._sourcePosition;
|
||||
|
||||
this._queue.unshift([str, line, column, identifierName, filename]);
|
||||
}
|
||||
|
||||
queueIndentation(str) {
|
||||
this._queue.unshift([str, undefined, undefined, undefined, undefined]);
|
||||
}
|
||||
|
||||
_flush() {
|
||||
let item;
|
||||
|
||||
while (item = this._queue.pop()) {
|
||||
this._append(...item);
|
||||
}
|
||||
}
|
||||
|
||||
_append(str, line, column, identifierName, filename) {
|
||||
this._buf += str;
|
||||
this._last = str.charCodeAt(str.length - 1);
|
||||
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() {
|
||||
if (this._queue.length > 0 && this._queue[0][0] === "\n") {
|
||||
this._queue.shift();
|
||||
}
|
||||
}
|
||||
|
||||
removeLastSemicolon() {
|
||||
if (this._queue.length > 0 && this._queue[0][0] === ";") {
|
||||
this._queue.shift();
|
||||
}
|
||||
}
|
||||
|
||||
getLastChar() {
|
||||
let last;
|
||||
|
||||
if (this._queue.length > 0) {
|
||||
const str = this._queue[0][0];
|
||||
last = str.charCodeAt(0);
|
||||
} else {
|
||||
last = this._last;
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
endsWithCharAndNewline() {
|
||||
const queue = this._queue;
|
||||
|
||||
if (queue.length > 0) {
|
||||
const last = queue[0][0];
|
||||
const lastCp = last.charCodeAt(0);
|
||||
if (lastCp !== 10) return;
|
||||
|
||||
if (queue.length > 1) {
|
||||
const secondLast = queue[1][0];
|
||||
return secondLast.charCodeAt(0);
|
||||
} else {
|
||||
return this._last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasContent() {
|
||||
return this._queue.length > 0 || !!this._last;
|
||||
}
|
||||
|
||||
exactSource(loc, cb) {
|
||||
this.source("start", loc);
|
||||
cb();
|
||||
this.source("end", loc);
|
||||
|
||||
this._disallowPop("start", loc);
|
||||
}
|
||||
|
||||
source(prop, loc) {
|
||||
if (prop && !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 || 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 = null;
|
||||
}
|
||||
}
|
||||
|
||||
_disallowPop(prop, loc) {
|
||||
if (prop && !loc) return;
|
||||
this._disallowedPop = this._normalizePosition(prop, loc, SourcePos());
|
||||
}
|
||||
|
||||
_normalizePosition(prop, loc, targetObj) {
|
||||
const pos = loc ? loc[prop] : null;
|
||||
targetObj.identifierName = prop === "start" && (loc == null ? void 0 : loc.identifierName) || undefined;
|
||||
targetObj.line = pos == null ? void 0 : pos.line;
|
||||
targetObj.column = pos == null ? void 0 : pos.column;
|
||||
targetObj.filename = loc == null ? void 0 : loc.filename;
|
||||
return targetObj;
|
||||
}
|
||||
|
||||
getCurrentColumn() {
|
||||
const extra = this._queue.reduce((acc, item) => item[0] + acc, "");
|
||||
|
||||
const lastIndex = extra.lastIndexOf("\n");
|
||||
return lastIndex === -1 ? this._position.column + extra.length : extra.length - 1 - lastIndex;
|
||||
}
|
||||
|
||||
getCurrentLine() {
|
||||
const extra = this._queue.reduce((acc, item) => item[0] + acc, "");
|
||||
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < extra.length; i++) {
|
||||
if (extra[i] === "\n") 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.token("{");
|
||||
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.token("}");
|
||||
}
|
||||
}
|
||||
|
||||
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`);
|
||||
}
|
||||
|
||||
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.token("{");
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (node.body.length === 0) {
|
||||
this.token("}");
|
||||
} 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.token("[");
|
||||
this.print(node.key, node);
|
||||
this.token("]");
|
||||
} else {
|
||||
this._variance(node);
|
||||
|
||||
this.print(node.key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
if (node.definite) {
|
||||
this.token("!");
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
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.token("[");
|
||||
this.print(node.key, node);
|
||||
this.token("]");
|
||||
} else {
|
||||
this._variance(node);
|
||||
|
||||
this.print(node.key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
if (node.definite) {
|
||||
this.token("!");
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
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.token("=");
|
||||
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.token("{");
|
||||
|
||||
if (node.body.length === 0) {
|
||||
this.token("}");
|
||||
} 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.token("(");
|
||||
this.print(node.expression, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
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.token("?");
|
||||
this.space();
|
||||
this.print(node.consequent, node);
|
||||
this.space();
|
||||
this.token(":");
|
||||
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.token("(");
|
||||
this.printList(node.arguments, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
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.token("@");
|
||||
const {
|
||||
expression
|
||||
} = node;
|
||||
|
||||
if (shouldParenthesizeDecoratorExpression(expression)) {
|
||||
this.token("(");
|
||||
this.print(expression, node);
|
||||
this.token(")");
|
||||
} 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.token("[");
|
||||
this.print(node.property, node);
|
||||
this.token("]");
|
||||
} else {
|
||||
if (!node.optional) {
|
||||
this.token(".");
|
||||
}
|
||||
|
||||
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.token("(");
|
||||
this.printList(node.arguments, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
function CallExpression(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.typeArguments, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.token("(");
|
||||
this.printList(node.arguments, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
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.token("*");
|
||||
}
|
||||
|
||||
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.token("?");
|
||||
this.print(node.left.typeAnnotation, node);
|
||||
this.space();
|
||||
this.token("=");
|
||||
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.token("(");
|
||||
}
|
||||
|
||||
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.token(")");
|
||||
}
|
||||
}
|
||||
|
||||
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.token("[");
|
||||
this.print(node.property, node);
|
||||
this.token("]");
|
||||
} else {
|
||||
this.token(".");
|
||||
this.print(node.property, node);
|
||||
}
|
||||
}
|
||||
|
||||
function MetaProperty(node) {
|
||||
this.print(node.meta, node);
|
||||
this.token(".");
|
||||
this.print(node.property, node);
|
||||
}
|
||||
|
||||
function PrivateName(node) {
|
||||
this.token("#");
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
function V8IntrinsicIdentifier(node) {
|
||||
this.token("%");
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
function ModuleExpression(node) {
|
||||
this.word("module");
|
||||
this.space();
|
||||
this.token("{");
|
||||
|
||||
if (node.body.body.length === 0) {
|
||||
this.token("}");
|
||||
} 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
|
@ -0,0 +1,795 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.AnyTypeAnnotation = AnyTypeAnnotation;
|
||||
exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
|
||||
exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
|
||||
exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
|
||||
exports.DeclareClass = DeclareClass;
|
||||
exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
|
||||
exports.DeclareExportDeclaration = DeclareExportDeclaration;
|
||||
exports.DeclareFunction = DeclareFunction;
|
||||
exports.DeclareInterface = DeclareInterface;
|
||||
exports.DeclareModule = DeclareModule;
|
||||
exports.DeclareModuleExports = DeclareModuleExports;
|
||||
exports.DeclareOpaqueType = DeclareOpaqueType;
|
||||
exports.DeclareTypeAlias = DeclareTypeAlias;
|
||||
exports.DeclareVariable = DeclareVariable;
|
||||
exports.DeclaredPredicate = DeclaredPredicate;
|
||||
exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
|
||||
exports.EnumBooleanBody = EnumBooleanBody;
|
||||
exports.EnumBooleanMember = EnumBooleanMember;
|
||||
exports.EnumDeclaration = EnumDeclaration;
|
||||
exports.EnumDefaultedMember = EnumDefaultedMember;
|
||||
exports.EnumNumberBody = EnumNumberBody;
|
||||
exports.EnumNumberMember = EnumNumberMember;
|
||||
exports.EnumStringBody = EnumStringBody;
|
||||
exports.EnumStringMember = EnumStringMember;
|
||||
exports.EnumSymbolBody = EnumSymbolBody;
|
||||
exports.ExistsTypeAnnotation = ExistsTypeAnnotation;
|
||||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||||
exports.FunctionTypeParam = FunctionTypeParam;
|
||||
exports.IndexedAccessType = IndexedAccessType;
|
||||
exports.InferredPredicate = InferredPredicate;
|
||||
exports.InterfaceDeclaration = InterfaceDeclaration;
|
||||
exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends;
|
||||
exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation;
|
||||
exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
|
||||
exports.MixedTypeAnnotation = MixedTypeAnnotation;
|
||||
exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
|
||||
exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||||
Object.defineProperty(exports, "NumberLiteralTypeAnnotation", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types2.NumericLiteral;
|
||||
}
|
||||
});
|
||||
exports.NumberTypeAnnotation = NumberTypeAnnotation;
|
||||
exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
|
||||
exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
|
||||
exports.ObjectTypeIndexer = ObjectTypeIndexer;
|
||||
exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot;
|
||||
exports.ObjectTypeProperty = ObjectTypeProperty;
|
||||
exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;
|
||||
exports.OpaqueType = OpaqueType;
|
||||
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
|
||||
exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
|
||||
Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types2.StringLiteral;
|
||||
}
|
||||
});
|
||||
exports.StringTypeAnnotation = StringTypeAnnotation;
|
||||
exports.SymbolTypeAnnotation = SymbolTypeAnnotation;
|
||||
exports.ThisTypeAnnotation = ThisTypeAnnotation;
|
||||
exports.TupleTypeAnnotation = TupleTypeAnnotation;
|
||||
exports.TypeAlias = TypeAlias;
|
||||
exports.TypeAnnotation = TypeAnnotation;
|
||||
exports.TypeCastExpression = TypeCastExpression;
|
||||
exports.TypeParameter = TypeParameter;
|
||||
exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation;
|
||||
exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
|
||||
exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||||
exports.Variance = Variance;
|
||||
exports.VoidTypeAnnotation = VoidTypeAnnotation;
|
||||
exports._interfaceish = _interfaceish;
|
||||
exports._variance = _variance;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _modules = require("./modules");
|
||||
|
||||
var _types2 = require("./types");
|
||||
|
||||
const {
|
||||
isDeclareExportDeclaration,
|
||||
isStatement
|
||||
} = _t;
|
||||
|
||||
function AnyTypeAnnotation() {
|
||||
this.word("any");
|
||||
}
|
||||
|
||||
function ArrayTypeAnnotation(node) {
|
||||
this.print(node.elementType, node);
|
||||
this.token("[");
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
function BooleanTypeAnnotation() {
|
||||
this.word("boolean");
|
||||
}
|
||||
|
||||
function BooleanLiteralTypeAnnotation(node) {
|
||||
this.word(node.value ? "true" : "false");
|
||||
}
|
||||
|
||||
function NullLiteralTypeAnnotation() {
|
||||
this.word("null");
|
||||
}
|
||||
|
||||
function DeclareClass(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("class");
|
||||
this.space();
|
||||
|
||||
this._interfaceish(node);
|
||||
}
|
||||
|
||||
function DeclareFunction(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("function");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id.typeAnnotation.typeAnnotation, node);
|
||||
|
||||
if (node.predicate) {
|
||||
this.space();
|
||||
this.print(node.predicate, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function InferredPredicate() {
|
||||
this.token("%");
|
||||
this.word("checks");
|
||||
}
|
||||
|
||||
function DeclaredPredicate(node) {
|
||||
this.token("%");
|
||||
this.word("checks");
|
||||
this.token("(");
|
||||
this.print(node.value, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
function DeclareInterface(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.InterfaceDeclaration(node);
|
||||
}
|
||||
|
||||
function DeclareModule(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("module");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function DeclareModuleExports(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("module");
|
||||
this.token(".");
|
||||
this.word("exports");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function DeclareTypeAlias(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.TypeAlias(node);
|
||||
}
|
||||
|
||||
function DeclareOpaqueType(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.OpaqueType(node);
|
||||
}
|
||||
|
||||
function DeclareVariable(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("var");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function DeclareExportDeclaration(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("export");
|
||||
this.space();
|
||||
|
||||
if (node.default) {
|
||||
this.word("default");
|
||||
this.space();
|
||||
}
|
||||
|
||||
FlowExportDeclaration.call(this, node);
|
||||
}
|
||||
|
||||
function DeclareExportAllDeclaration(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
|
||||
_modules.ExportAllDeclaration.call(this, node);
|
||||
}
|
||||
|
||||
function EnumDeclaration(node) {
|
||||
const {
|
||||
id,
|
||||
body
|
||||
} = node;
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(body, node);
|
||||
}
|
||||
|
||||
function enumExplicitType(context, name, hasExplicitType) {
|
||||
if (hasExplicitType) {
|
||||
context.space();
|
||||
context.word("of");
|
||||
context.space();
|
||||
context.word(name);
|
||||
}
|
||||
|
||||
context.space();
|
||||
}
|
||||
|
||||
function enumBody(context, node) {
|
||||
const {
|
||||
members
|
||||
} = node;
|
||||
context.token("{");
|
||||
context.indent();
|
||||
context.newline();
|
||||
|
||||
for (const member of members) {
|
||||
context.print(member, node);
|
||||
context.newline();
|
||||
}
|
||||
|
||||
if (node.hasUnknownMembers) {
|
||||
context.token("...");
|
||||
context.newline();
|
||||
}
|
||||
|
||||
context.dedent();
|
||||
context.token("}");
|
||||
}
|
||||
|
||||
function EnumBooleanBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
} = node;
|
||||
enumExplicitType(this, "boolean", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
|
||||
function EnumNumberBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
} = node;
|
||||
enumExplicitType(this, "number", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
|
||||
function EnumStringBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
} = node;
|
||||
enumExplicitType(this, "string", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
|
||||
function EnumSymbolBody(node) {
|
||||
enumExplicitType(this, "symbol", true);
|
||||
enumBody(this, node);
|
||||
}
|
||||
|
||||
function EnumDefaultedMember(node) {
|
||||
const {
|
||||
id
|
||||
} = node;
|
||||
this.print(id, node);
|
||||
this.token(",");
|
||||
}
|
||||
|
||||
function enumInitializedMember(context, node) {
|
||||
const {
|
||||
id,
|
||||
init
|
||||
} = node;
|
||||
context.print(id, node);
|
||||
context.space();
|
||||
context.token("=");
|
||||
context.space();
|
||||
context.print(init, node);
|
||||
context.token(",");
|
||||
}
|
||||
|
||||
function EnumBooleanMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
|
||||
function EnumNumberMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
|
||||
function EnumStringMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
|
||||
function FlowExportDeclaration(node) {
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
this.token("{");
|
||||
|
||||
if (node.specifiers.length) {
|
||||
this.space();
|
||||
this.printList(node.specifiers, node);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("}");
|
||||
|
||||
if (node.source) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
|
||||
function ExistsTypeAnnotation() {
|
||||
this.token("*");
|
||||
}
|
||||
|
||||
function FunctionTypeAnnotation(node, parent) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.token("(");
|
||||
|
||||
if (node.this) {
|
||||
this.word("this");
|
||||
this.token(":");
|
||||
this.space();
|
||||
this.print(node.this.typeAnnotation, node);
|
||||
|
||||
if (node.params.length || node.rest) {
|
||||
this.token(",");
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
|
||||
this.printList(node.params, node);
|
||||
|
||||
if (node.rest) {
|
||||
if (node.params.length) {
|
||||
this.token(",");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("...");
|
||||
this.print(node.rest, node);
|
||||
}
|
||||
|
||||
this.token(")");
|
||||
|
||||
if (parent && (parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction" || parent.type === "ObjectTypeProperty" && parent.method)) {
|
||||
this.token(":");
|
||||
} else {
|
||||
this.space();
|
||||
this.token("=>");
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.returnType, node);
|
||||
}
|
||||
|
||||
function FunctionTypeParam(node) {
|
||||
this.print(node.name, node);
|
||||
if (node.optional) this.token("?");
|
||||
|
||||
if (node.name) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function InterfaceExtends(node) {
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
|
||||
function _interfaceish(node) {
|
||||
var _node$extends;
|
||||
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if ((_node$extends = node.extends) != null && _node$extends.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends, node);
|
||||
}
|
||||
|
||||
if (node.mixins && node.mixins.length) {
|
||||
this.space();
|
||||
this.word("mixins");
|
||||
this.space();
|
||||
this.printList(node.mixins, node);
|
||||
}
|
||||
|
||||
if (node.implements && node.implements.length) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements, node);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function _variance(node) {
|
||||
if (node.variance) {
|
||||
if (node.variance.kind === "plus") {
|
||||
this.token("+");
|
||||
} else if (node.variance.kind === "minus") {
|
||||
this.token("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InterfaceDeclaration(node) {
|
||||
this.word("interface");
|
||||
this.space();
|
||||
|
||||
this._interfaceish(node);
|
||||
}
|
||||
|
||||
function andSeparator() {
|
||||
this.space();
|
||||
this.token("&");
|
||||
this.space();
|
||||
}
|
||||
|
||||
function InterfaceTypeAnnotation(node) {
|
||||
this.word("interface");
|
||||
|
||||
if (node.extends && node.extends.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends, node);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function IntersectionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, node, {
|
||||
separator: andSeparator
|
||||
});
|
||||
}
|
||||
|
||||
function MixedTypeAnnotation() {
|
||||
this.word("mixed");
|
||||
}
|
||||
|
||||
function EmptyTypeAnnotation() {
|
||||
this.word("empty");
|
||||
}
|
||||
|
||||
function NullableTypeAnnotation(node) {
|
||||
this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function NumberTypeAnnotation() {
|
||||
this.word("number");
|
||||
}
|
||||
|
||||
function StringTypeAnnotation() {
|
||||
this.word("string");
|
||||
}
|
||||
|
||||
function ThisTypeAnnotation() {
|
||||
this.word("this");
|
||||
}
|
||||
|
||||
function TupleTypeAnnotation(node) {
|
||||
this.token("[");
|
||||
this.printList(node.types, node);
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
function TypeofTypeAnnotation(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function TypeAlias(node) {
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function TypeAnnotation(node) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
if (node.optional) this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TypeParameterInstantiation(node) {
|
||||
this.token("<");
|
||||
this.printList(node.params, node, {});
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
function TypeParameter(node) {
|
||||
this._variance(node);
|
||||
|
||||
this.word(node.name);
|
||||
|
||||
if (node.bound) {
|
||||
this.print(node.bound, node);
|
||||
}
|
||||
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
}
|
||||
}
|
||||
|
||||
function OpaqueType(node) {
|
||||
this.word("opaque");
|
||||
this.space();
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if (node.supertype) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
this.print(node.supertype, node);
|
||||
}
|
||||
|
||||
if (node.impltype) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.impltype, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ObjectTypeAnnotation(node) {
|
||||
if (node.exact) {
|
||||
this.token("{|");
|
||||
} else {
|
||||
this.token("{");
|
||||
}
|
||||
|
||||
const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
|
||||
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printJoin(props, node, {
|
||||
addNewlines(leading) {
|
||||
if (leading && !props[0]) return 1;
|
||||
},
|
||||
|
||||
indent: true,
|
||||
statement: true,
|
||||
iterator: () => {
|
||||
if (props.length !== 1 || node.inexact) {
|
||||
this.token(",");
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.inexact) {
|
||||
this.indent();
|
||||
this.token("...");
|
||||
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
}
|
||||
|
||||
this.dedent();
|
||||
}
|
||||
|
||||
if (node.exact) {
|
||||
this.token("|}");
|
||||
} else {
|
||||
this.token("}");
|
||||
}
|
||||
}
|
||||
|
||||
function ObjectTypeInternalSlot(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("[");
|
||||
this.token("[");
|
||||
this.print(node.id, node);
|
||||
this.token("]");
|
||||
this.token("]");
|
||||
if (node.optional) this.token("?");
|
||||
|
||||
if (!node.method) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ObjectTypeCallProperty(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ObjectTypeIndexer(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._variance(node);
|
||||
|
||||
this.token("[");
|
||||
|
||||
if (node.id) {
|
||||
this.print(node.id, node);
|
||||
this.token(":");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.key, node);
|
||||
this.token("]");
|
||||
this.token(":");
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ObjectTypeProperty(node) {
|
||||
if (node.proto) {
|
||||
this.word("proto");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.kind === "get" || node.kind === "set") {
|
||||
this.word(node.kind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._variance(node);
|
||||
|
||||
this.print(node.key, node);
|
||||
if (node.optional) this.token("?");
|
||||
|
||||
if (!node.method) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ObjectTypeSpreadProperty(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function QualifiedTypeIdentifier(node) {
|
||||
this.print(node.qualification, node);
|
||||
this.token(".");
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
function SymbolTypeAnnotation() {
|
||||
this.word("symbol");
|
||||
}
|
||||
|
||||
function orSeparator() {
|
||||
this.space();
|
||||
this.token("|");
|
||||
this.space();
|
||||
}
|
||||
|
||||
function UnionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, node, {
|
||||
separator: orSeparator
|
||||
});
|
||||
}
|
||||
|
||||
function TypeCastExpression(node) {
|
||||
this.token("(");
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
function Variance(node) {
|
||||
if (node.kind === "plus") {
|
||||
this.token("+");
|
||||
} else {
|
||||
this.token("-");
|
||||
}
|
||||
}
|
||||
|
||||
function VoidTypeAnnotation() {
|
||||
this.word("void");
|
||||
}
|
||||
|
||||
function IndexedAccessType(node) {
|
||||
this.print(node.objectType, node);
|
||||
this.token("[");
|
||||
this.print(node.indexType, node);
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
function OptionalIndexedAccessType(node) {
|
||||
this.print(node.objectType, node);
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
|
||||
this.token("[");
|
||||
this.print(node.indexType, node);
|
||||
this.token("]");
|
||||
}
|
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.token("=");
|
||||
this.print(node.value, node);
|
||||
}
|
||||
}
|
||||
|
||||
function JSXIdentifier(node) {
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
function JSXNamespacedName(node) {
|
||||
this.print(node.namespace, node);
|
||||
this.token(":");
|
||||
this.print(node.name, node);
|
||||
}
|
||||
|
||||
function JSXMemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
this.token(".");
|
||||
this.print(node.property, node);
|
||||
}
|
||||
|
||||
function JSXSpreadAttribute(node) {
|
||||
this.token("{");
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
function JSXExpressionContainer(node) {
|
||||
this.token("{");
|
||||
this.print(node.expression, node);
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
function JSXSpreadChild(node) {
|
||||
this.token("{");
|
||||
this.token("...");
|
||||
this.print(node.expression, node);
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
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.token("<");
|
||||
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.token(">");
|
||||
}
|
||||
}
|
||||
|
||||
function JSXClosingElement(node) {
|
||||
this.token("</");
|
||||
this.print(node.name, node);
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
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.token("<");
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
function JSXClosingFragment() {
|
||||
this.token("</");
|
||||
this.token(">");
|
||||
}
|
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.token("(");
|
||||
|
||||
this._parameters(node.params, node);
|
||||
|
||||
this.token(")");
|
||||
this.print(node.returnType, node);
|
||||
}
|
||||
|
||||
function _parameters(parameters, parent) {
|
||||
for (let i = 0; i < parameters.length; i++) {
|
||||
this._param(parameters[i], parent);
|
||||
|
||||
if (i < parameters.length - 1) {
|
||||
this.token(",");
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _param(parameter, parent) {
|
||||
this.printJoin(parameter.decorators, parameter);
|
||||
this.print(parameter, parent);
|
||||
|
||||
if (parameter.optional) {
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
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.token("*");
|
||||
}
|
||||
}
|
||||
|
||||
if (node.computed) {
|
||||
this.token("[");
|
||||
this.print(key, node);
|
||||
this.token("]");
|
||||
} else {
|
||||
this.print(key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
this._params(node);
|
||||
}
|
||||
|
||||
function _predicate(node) {
|
||||
if (node.predicate) {
|
||||
if (!node.returnType) {
|
||||
this.token(":");
|
||||
}
|
||||
|
||||
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.token("*");
|
||||
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.token("*");
|
||||
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.token("*");
|
||||
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.token(",");
|
||||
this.space();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (specifiers.length || !specifiers.length && !hasSpecial) {
|
||||
this.token("{");
|
||||
|
||||
if (specifiers.length) {
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
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.token(",");
|
||||
this.space();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (specifiers.length) {
|
||||
this.token("{");
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.space();
|
||||
this.token("}");
|
||||
} else if (isTypeKind && !hasSpecifiers) {
|
||||
this.token("{");
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
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.token(":");
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
|
||||
function ImportNamespaceSpecifier(node) {
|
||||
this.token("*");
|
||||
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.token("(");
|
||||
this.print(node.object, node);
|
||||
this.token(")");
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
this.token("(");
|
||||
this.print(node.test, node);
|
||||
this.token(")");
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
|
||||
if (needsBlock) {
|
||||
this.token("{");
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
|
||||
this.printAndIndentOnComments(node.consequent, node);
|
||||
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
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.token("(");
|
||||
this.inForStatementInitCounter++;
|
||||
this.print(node.init, node);
|
||||
this.inForStatementInitCounter--;
|
||||
this.token(";");
|
||||
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
}
|
||||
|
||||
this.token(";");
|
||||
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update, node);
|
||||
}
|
||||
|
||||
this.token(")");
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.token("(");
|
||||
this.print(node.test, node);
|
||||
this.token(")");
|
||||
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.token("(");
|
||||
this.print(node.left, node);
|
||||
this.space();
|
||||
this.word(isForOf ? "of" : "in");
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.token(")");
|
||||
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.token("(");
|
||||
this.print(node.test, node);
|
||||
this.token(")");
|
||||
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.token(":");
|
||||
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.token("(");
|
||||
this.print(node.param, node);
|
||||
this.print(node.param.typeAnnotation, node);
|
||||
this.token(")");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
this.token("(");
|
||||
this.print(node.discriminant, node);
|
||||
this.token(")");
|
||||
this.space();
|
||||
this.token("{");
|
||||
this.printSequence(node.cases, node, {
|
||||
indent: true,
|
||||
|
||||
addNewlines(leading, cas) {
|
||||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
|
||||
}
|
||||
|
||||
});
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
this.token(":");
|
||||
} else {
|
||||
this.word("default");
|
||||
this.token(":");
|
||||
}
|
||||
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, node, {
|
||||
indent: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function DebuggerStatement() {
|
||||
this.word("debugger");
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function variableDeclarationIndent() {
|
||||
this.token(",");
|
||||
this.newline();
|
||||
|
||||
if (this.endsWith(10)) {
|
||||
for (let i = 0; i < 4; i++) this.space(true);
|
||||
}
|
||||
}
|
||||
|
||||
function constDeclarationIndent() {
|
||||
this.token(",");
|
||||
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.token("!");
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
|
||||
if (node.init) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
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);
|
||||
}
|
||||
|
||||
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.token("?");
|
||||
}
|
||||
|
||||
function RestElement(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function ObjectExpression(node) {
|
||||
const props = node.properties;
|
||||
this.token("{");
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
indent: true,
|
||||
statement: true
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
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.token("[");
|
||||
this.print(node.key, node);
|
||||
this.token("]");
|
||||
} 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.token(":");
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ArrayExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
this.token("[");
|
||||
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.token(",");
|
||||
} else {
|
||||
this.token(",");
|
||||
}
|
||||
}
|
||||
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
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.token(",");
|
||||
}
|
||||
}
|
||||
|
||||
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.token("#");
|
||||
}
|
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
|
@ -0,0 +1,833 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TSAnyKeyword = TSAnyKeyword;
|
||||
exports.TSArrayType = TSArrayType;
|
||||
exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSBigIntKeyword = TSBigIntKeyword;
|
||||
exports.TSBooleanKeyword = TSBooleanKeyword;
|
||||
exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration;
|
||||
exports.TSConditionalType = TSConditionalType;
|
||||
exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration;
|
||||
exports.TSConstructorType = TSConstructorType;
|
||||
exports.TSDeclareFunction = TSDeclareFunction;
|
||||
exports.TSDeclareMethod = TSDeclareMethod;
|
||||
exports.TSEnumDeclaration = TSEnumDeclaration;
|
||||
exports.TSEnumMember = TSEnumMember;
|
||||
exports.TSExportAssignment = TSExportAssignment;
|
||||
exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments;
|
||||
exports.TSExternalModuleReference = TSExternalModuleReference;
|
||||
exports.TSFunctionType = TSFunctionType;
|
||||
exports.TSImportEqualsDeclaration = TSImportEqualsDeclaration;
|
||||
exports.TSImportType = TSImportType;
|
||||
exports.TSIndexSignature = TSIndexSignature;
|
||||
exports.TSIndexedAccessType = TSIndexedAccessType;
|
||||
exports.TSInferType = TSInferType;
|
||||
exports.TSInstantiationExpression = TSInstantiationExpression;
|
||||
exports.TSInterfaceBody = TSInterfaceBody;
|
||||
exports.TSInterfaceDeclaration = TSInterfaceDeclaration;
|
||||
exports.TSIntersectionType = TSIntersectionType;
|
||||
exports.TSIntrinsicKeyword = TSIntrinsicKeyword;
|
||||
exports.TSLiteralType = TSLiteralType;
|
||||
exports.TSMappedType = TSMappedType;
|
||||
exports.TSMethodSignature = TSMethodSignature;
|
||||
exports.TSModuleBlock = TSModuleBlock;
|
||||
exports.TSModuleDeclaration = TSModuleDeclaration;
|
||||
exports.TSNamedTupleMember = TSNamedTupleMember;
|
||||
exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration;
|
||||
exports.TSNeverKeyword = TSNeverKeyword;
|
||||
exports.TSNonNullExpression = TSNonNullExpression;
|
||||
exports.TSNullKeyword = TSNullKeyword;
|
||||
exports.TSNumberKeyword = TSNumberKeyword;
|
||||
exports.TSObjectKeyword = TSObjectKeyword;
|
||||
exports.TSOptionalType = TSOptionalType;
|
||||
exports.TSParameterProperty = TSParameterProperty;
|
||||
exports.TSParenthesizedType = TSParenthesizedType;
|
||||
exports.TSPropertySignature = TSPropertySignature;
|
||||
exports.TSQualifiedName = TSQualifiedName;
|
||||
exports.TSRestType = TSRestType;
|
||||
exports.TSStringKeyword = TSStringKeyword;
|
||||
exports.TSSymbolKeyword = TSSymbolKeyword;
|
||||
exports.TSThisType = TSThisType;
|
||||
exports.TSTupleType = TSTupleType;
|
||||
exports.TSTypeAliasDeclaration = TSTypeAliasDeclaration;
|
||||
exports.TSTypeAnnotation = TSTypeAnnotation;
|
||||
exports.TSTypeAssertion = TSTypeAssertion;
|
||||
exports.TSTypeLiteral = TSTypeLiteral;
|
||||
exports.TSTypeOperator = TSTypeOperator;
|
||||
exports.TSTypeParameter = TSTypeParameter;
|
||||
exports.TSTypeParameterDeclaration = exports.TSTypeParameterInstantiation = TSTypeParameterInstantiation;
|
||||
exports.TSTypePredicate = TSTypePredicate;
|
||||
exports.TSTypeQuery = TSTypeQuery;
|
||||
exports.TSTypeReference = TSTypeReference;
|
||||
exports.TSUndefinedKeyword = TSUndefinedKeyword;
|
||||
exports.TSUnionType = TSUnionType;
|
||||
exports.TSUnknownKeyword = TSUnknownKeyword;
|
||||
exports.TSVoidKeyword = TSVoidKeyword;
|
||||
exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers;
|
||||
exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType;
|
||||
exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName;
|
||||
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase;
|
||||
exports.tsPrintTypeLiteralOrInterfaceBody = tsPrintTypeLiteralOrInterfaceBody;
|
||||
|
||||
function TSTypeAnnotation(node) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
if (node.optional) this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSTypeParameterInstantiation(node, parent) {
|
||||
this.token("<");
|
||||
this.printList(node.params, node, {});
|
||||
|
||||
if (parent.type === "ArrowFunctionExpression" && node.params.length === 1) {
|
||||
this.token(",");
|
||||
}
|
||||
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
function TSTypeParameter(node) {
|
||||
if (node.in) {
|
||||
this.word("in");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.out) {
|
||||
this.word("out");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word(node.name);
|
||||
|
||||
if (node.constraint) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.constraint, node);
|
||||
}
|
||||
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
}
|
||||
}
|
||||
|
||||
function TSParameterProperty(node) {
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._param(node.parameter);
|
||||
}
|
||||
|
||||
function TSDeclareFunction(node) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._functionHead(node);
|
||||
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSDeclareMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSQualifiedName(node) {
|
||||
this.print(node.left, node);
|
||||
this.token(".");
|
||||
this.print(node.right, node);
|
||||
}
|
||||
|
||||
function TSCallSignatureDeclaration(node) {
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSConstructSignatureDeclaration(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSPropertySignature(node) {
|
||||
const {
|
||||
readonly,
|
||||
initializer
|
||||
} = node;
|
||||
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(initializer, node);
|
||||
}
|
||||
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function tsPrintPropertyOrMethodName(node) {
|
||||
if (node.computed) {
|
||||
this.token("[");
|
||||
}
|
||||
|
||||
this.print(node.key, node);
|
||||
|
||||
if (node.computed) {
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?");
|
||||
}
|
||||
}
|
||||
|
||||
function TSMethodSignature(node) {
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
|
||||
if (kind === "set" || kind === "get") {
|
||||
this.word(kind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSIndexSignature(node) {
|
||||
const {
|
||||
readonly,
|
||||
static: isStatic
|
||||
} = node;
|
||||
|
||||
if (isStatic) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("[");
|
||||
|
||||
this._parameters(node.parameters, node);
|
||||
|
||||
this.token("]");
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSAnyKeyword() {
|
||||
this.word("any");
|
||||
}
|
||||
|
||||
function TSBigIntKeyword() {
|
||||
this.word("bigint");
|
||||
}
|
||||
|
||||
function TSUnknownKeyword() {
|
||||
this.word("unknown");
|
||||
}
|
||||
|
||||
function TSNumberKeyword() {
|
||||
this.word("number");
|
||||
}
|
||||
|
||||
function TSObjectKeyword() {
|
||||
this.word("object");
|
||||
}
|
||||
|
||||
function TSBooleanKeyword() {
|
||||
this.word("boolean");
|
||||
}
|
||||
|
||||
function TSStringKeyword() {
|
||||
this.word("string");
|
||||
}
|
||||
|
||||
function TSSymbolKeyword() {
|
||||
this.word("symbol");
|
||||
}
|
||||
|
||||
function TSVoidKeyword() {
|
||||
this.word("void");
|
||||
}
|
||||
|
||||
function TSUndefinedKeyword() {
|
||||
this.word("undefined");
|
||||
}
|
||||
|
||||
function TSNullKeyword() {
|
||||
this.word("null");
|
||||
}
|
||||
|
||||
function TSNeverKeyword() {
|
||||
this.word("never");
|
||||
}
|
||||
|
||||
function TSIntrinsicKeyword() {
|
||||
this.word("intrinsic");
|
||||
}
|
||||
|
||||
function TSThisType() {
|
||||
this.word("this");
|
||||
}
|
||||
|
||||
function TSFunctionType(node) {
|
||||
this.tsPrintFunctionOrConstructorType(node);
|
||||
}
|
||||
|
||||
function TSConstructorType(node) {
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintFunctionOrConstructorType(node);
|
||||
}
|
||||
|
||||
function tsPrintFunctionOrConstructorType(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.token("(");
|
||||
|
||||
this._parameters(parameters, node);
|
||||
|
||||
this.token(")");
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSTypeReference(node) {
|
||||
this.print(node.typeName, node);
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
|
||||
function TSTypePredicate(node) {
|
||||
if (node.asserts) {
|
||||
this.word("asserts");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.parameterName);
|
||||
|
||||
if (node.typeAnnotation) {
|
||||
this.space();
|
||||
this.word("is");
|
||||
this.space();
|
||||
this.print(node.typeAnnotation.typeAnnotation);
|
||||
}
|
||||
}
|
||||
|
||||
function TSTypeQuery(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.exprName);
|
||||
|
||||
if (node.typeParameters) {
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
}
|
||||
|
||||
function TSTypeLiteral(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node);
|
||||
}
|
||||
|
||||
function tsPrintTypeLiteralOrInterfaceBody(members, node) {
|
||||
tsPrintBraced(this, members, node);
|
||||
}
|
||||
|
||||
function tsPrintBraced(printer, members, node) {
|
||||
printer.token("{");
|
||||
|
||||
if (members.length) {
|
||||
printer.indent();
|
||||
printer.newline();
|
||||
|
||||
for (const member of members) {
|
||||
printer.print(member, node);
|
||||
printer.newline();
|
||||
}
|
||||
|
||||
printer.dedent();
|
||||
printer.rightBrace();
|
||||
} else {
|
||||
printer.token("}");
|
||||
}
|
||||
}
|
||||
|
||||
function TSArrayType(node) {
|
||||
this.print(node.elementType, node);
|
||||
this.token("[]");
|
||||
}
|
||||
|
||||
function TSTupleType(node) {
|
||||
this.token("[");
|
||||
this.printList(node.elementTypes, node);
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
function TSOptionalType(node) {
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
function TSRestType(node) {
|
||||
this.token("...");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSNamedTupleMember(node) {
|
||||
this.print(node.label, node);
|
||||
if (node.optional) this.token("?");
|
||||
this.token(":");
|
||||
this.space();
|
||||
this.print(node.elementType, node);
|
||||
}
|
||||
|
||||
function TSUnionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "|");
|
||||
}
|
||||
|
||||
function TSIntersectionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "&");
|
||||
}
|
||||
|
||||
function tsPrintUnionOrIntersectionType(printer, node, sep) {
|
||||
printer.printJoin(node.types, node, {
|
||||
separator() {
|
||||
this.space();
|
||||
this.token(sep);
|
||||
this.space();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function TSConditionalType(node) {
|
||||
this.print(node.checkType);
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.extendsType);
|
||||
this.space();
|
||||
this.token("?");
|
||||
this.space();
|
||||
this.print(node.trueType);
|
||||
this.space();
|
||||
this.token(":");
|
||||
this.space();
|
||||
this.print(node.falseType);
|
||||
}
|
||||
|
||||
function TSInferType(node) {
|
||||
this.token("infer");
|
||||
this.space();
|
||||
this.print(node.typeParameter);
|
||||
}
|
||||
|
||||
function TSParenthesizedType(node) {
|
||||
this.token("(");
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
function TSTypeOperator(node) {
|
||||
this.word(node.operator);
|
||||
this.space();
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSIndexedAccessType(node) {
|
||||
this.print(node.objectType, node);
|
||||
this.token("[");
|
||||
this.print(node.indexType, node);
|
||||
this.token("]");
|
||||
}
|
||||
|
||||
function TSMappedType(node) {
|
||||
const {
|
||||
nameType,
|
||||
optional,
|
||||
readonly,
|
||||
typeParameter
|
||||
} = node;
|
||||
this.token("{");
|
||||
this.space();
|
||||
|
||||
if (readonly) {
|
||||
tokenIfPlusMinus(this, readonly);
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("[");
|
||||
this.word(typeParameter.name);
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
this.print(typeParameter.constraint, typeParameter);
|
||||
|
||||
if (nameType) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(nameType, node);
|
||||
}
|
||||
|
||||
this.token("]");
|
||||
|
||||
if (optional) {
|
||||
tokenIfPlusMinus(this, optional);
|
||||
this.token("?");
|
||||
}
|
||||
|
||||
this.token(":");
|
||||
this.space();
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.space();
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
function tokenIfPlusMinus(self, tok) {
|
||||
if (tok !== true) {
|
||||
self.token(tok);
|
||||
}
|
||||
}
|
||||
|
||||
function TSLiteralType(node) {
|
||||
this.print(node.literal, node);
|
||||
}
|
||||
|
||||
function TSExpressionWithTypeArguments(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
|
||||
function TSInterfaceDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id,
|
||||
typeParameters,
|
||||
extends: extendz,
|
||||
body
|
||||
} = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("interface");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(typeParameters, node);
|
||||
|
||||
if (extendz != null && extendz.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(extendz, node);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
}
|
||||
|
||||
function TSInterfaceBody(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node);
|
||||
}
|
||||
|
||||
function TSTypeAliasDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id,
|
||||
typeParameters,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(typeParameters, node);
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSAsExpression(node) {
|
||||
const {
|
||||
expression,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.print(expression, node);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSTypeAssertion(node) {
|
||||
const {
|
||||
typeAnnotation,
|
||||
expression
|
||||
} = node;
|
||||
this.token("<");
|
||||
this.print(typeAnnotation, node);
|
||||
this.token(">");
|
||||
this.space();
|
||||
this.print(expression, node);
|
||||
}
|
||||
|
||||
function TSInstantiationExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
|
||||
function TSEnumDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
const: isConst,
|
||||
id,
|
||||
members
|
||||
} = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (isConst) {
|
||||
this.word("const");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.space();
|
||||
tsPrintBraced(this, members, node);
|
||||
}
|
||||
|
||||
function TSEnumMember(node) {
|
||||
const {
|
||||
id,
|
||||
initializer
|
||||
} = node;
|
||||
this.print(id, node);
|
||||
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(initializer, node);
|
||||
}
|
||||
|
||||
this.token(",");
|
||||
}
|
||||
|
||||
function TSModuleDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id
|
||||
} = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (!node.global) {
|
||||
this.word(id.type === "Identifier" ? "namespace" : "module");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(id, node);
|
||||
|
||||
if (!node.body) {
|
||||
this.token(";");
|
||||
return;
|
||||
}
|
||||
|
||||
let body = node.body;
|
||||
|
||||
while (body.type === "TSModuleDeclaration") {
|
||||
this.token(".");
|
||||
this.print(body.id, body);
|
||||
body = body.body;
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
}
|
||||
|
||||
function TSModuleBlock(node) {
|
||||
tsPrintBraced(this, node.body, node);
|
||||
}
|
||||
|
||||
function TSImportType(node) {
|
||||
const {
|
||||
argument,
|
||||
qualifier,
|
||||
typeParameters
|
||||
} = node;
|
||||
this.word("import");
|
||||
this.token("(");
|
||||
this.print(argument, node);
|
||||
this.token(")");
|
||||
|
||||
if (qualifier) {
|
||||
this.token(".");
|
||||
this.print(qualifier, node);
|
||||
}
|
||||
|
||||
if (typeParameters) {
|
||||
this.print(typeParameters, node);
|
||||
}
|
||||
}
|
||||
|
||||
function TSImportEqualsDeclaration(node) {
|
||||
const {
|
||||
isExport,
|
||||
id,
|
||||
moduleReference
|
||||
} = node;
|
||||
|
||||
if (isExport) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("import");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(moduleReference, node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSExternalModuleReference(node) {
|
||||
this.token("require(");
|
||||
this.print(node.expression, node);
|
||||
this.token(")");
|
||||
}
|
||||
|
||||
function TSNonNullExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.token("!");
|
||||
}
|
||||
|
||||
function TSExportAssignment(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.expression, node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
function TSNamespaceExportDeclaration(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.word("namespace");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
function tsPrintSignatureDeclarationBase(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.token("(");
|
||||
|
||||
this._parameters(parameters, node);
|
||||
|
||||
this.token(")");
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType, node);
|
||||
}
|
||||
|
||||
function tsPrintClassMemberModifiers(node) {
|
||||
const isField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty";
|
||||
|
||||
if (isField && node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.override) {
|
||||
this.word("override");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (isField && node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
}
|
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.indexOf("@license") >= 0 || value.indexOf("@preserve") >= 0);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
111
node_modules/@babel/generator/lib/node/index.js
generated
vendored
Normal file
111
node_modules/@babel/generator/lib/node/index.js
generated
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
"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);
|
||||
const expandedWhitespaceList = expandAliases(whitespace.list);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
let linesInfo = find(expandedWhitespaceNodes, node, parent);
|
||||
|
||||
if (!linesInfo) {
|
||||
const items = find(expandedWhitespaceList, node, parent);
|
||||
|
||||
if (items) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
linesInfo = needsWhitespace(items[i], node, type);
|
||||
if (linesInfo) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof linesInfo === "object" && linesInfo !== null) {
|
||||
return linesInfo[type] || false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function needsWhitespaceBefore(node, parent) {
|
||||
return needsWhitespace(node, parent, "before");
|
||||
}
|
||||
|
||||
function needsWhitespaceAfter(node, parent) {
|
||||
return needsWhitespace(node, parent, "after");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
361
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
Normal file
361
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
Normal file
|
@ -0,0 +1,361 @@
|
|||
"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) {
|
||||
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, {
|
||||
expressionStatement: true,
|
||||
arrowBody: true
|
||||
});
|
||||
}
|
||||
|
||||
function DoExpression(node, parent, printStack) {
|
||||
return !node.async && isFirstInContext(printStack, {
|
||||
expressionStatement: true
|
||||
});
|
||||
}
|
||||
|
||||
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, {
|
||||
expressionStatement: true,
|
||||
exportDefault: true
|
||||
});
|
||||
}
|
||||
|
||||
function UnaryLike(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isBinaryExpression(parent, {
|
||||
operator: "**",
|
||||
left: node
|
||||
}) || isClassExtendsClause(node, parent);
|
||||
}
|
||||
|
||||
function FunctionExpression(node, parent, printStack) {
|
||||
return isFirstInContext(printStack, {
|
||||
expressionStatement: true,
|
||||
exportDefault: true
|
||||
});
|
||||
}
|
||||
|
||||
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, {
|
||||
expressionStatement: isFollowedByBracket,
|
||||
forHead: isFollowedByBracket,
|
||||
forInHead: isFollowedByBracket,
|
||||
forOfHead: true
|
||||
});
|
||||
}
|
||||
|
||||
return node.name === "async" && isForOfStatement(parent) && node === parent.left;
|
||||
}
|
||||
|
||||
function isFirstInContext(printStack, {
|
||||
expressionStatement = false,
|
||||
arrowBody = false,
|
||||
exportDefault = false,
|
||||
forHead = false,
|
||||
forInHead = false,
|
||||
forOfHead = false
|
||||
}) {
|
||||
let i = printStack.length - 1;
|
||||
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 (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;
|
||||
}
|
210
node_modules/@babel/generator/lib/node/whitespace.js
generated
vendored
Normal file
210
node_modules/@babel/generator/lib/node/whitespace.js
generated
vendored
Normal file
|
@ -0,0 +1,210 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.nodes = exports.list = 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 crawl(node, state = {}) {
|
||||
if (isMemberExpression(node) || isOptionalMemberExpression(node)) {
|
||||
crawl(node.object, state);
|
||||
if (node.computed) crawl(node.property, state);
|
||||
} else if (isBinary(node) || isAssignmentExpression(node)) {
|
||||
crawl(node.left, state);
|
||||
crawl(node.right, state);
|
||||
} else if (isCallExpression(node) || isOptionalCallExpression(node)) {
|
||||
state.hasCall = true;
|
||||
crawl(node.callee, state);
|
||||
} else if (isFunction(node)) {
|
||||
state.hasFunction = true;
|
||||
} else if (isIdentifier(node)) {
|
||||
state.hasHelper = state.hasHelper || isHelper(node.callee);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
function isHelper(node) {
|
||||
if (isMemberExpression(node)) {
|
||||
return isHelper(node.object) || isHelper(node.property);
|
||||
} else if (isIdentifier(node)) {
|
||||
return node.name === "require" || node.name[0] === "_";
|
||||
} 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 {
|
||||
before: state.hasFunction,
|
||||
after: true
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
SwitchCase(node, parent) {
|
||||
return {
|
||||
before: !!node.consequent.length || parent.cases[0] === node,
|
||||
after: !node.consequent.length && parent.cases[parent.cases.length - 1] === node
|
||||
};
|
||||
},
|
||||
|
||||
LogicalExpression(node) {
|
||||
if (isFunction(node.left) || isFunction(node.right)) {
|
||||
return {
|
||||
after: true
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
Literal(node) {
|
||||
if (isStringLiteral(node) && node.value === "use strict") {
|
||||
return {
|
||||
after: true
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
CallExpression(node) {
|
||||
if (isFunction(node.callee) || isHelper(node)) {
|
||||
return {
|
||||
before: true,
|
||||
after: true
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
OptionalCallExpression(node) {
|
||||
if (isFunction(node.callee)) {
|
||||
return {
|
||||
before: true,
|
||||
after: true
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
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) {
|
||||
const state = crawl(declar.init);
|
||||
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
return {
|
||||
before: true,
|
||||
after: true
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
IfStatement(node) {
|
||||
if (isBlockStatement(node.consequent)) {
|
||||
return {
|
||||
before: true,
|
||||
after: true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
exports.nodes = nodes;
|
||||
|
||||
nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) {
|
||||
if (parent.properties[0] === node) {
|
||||
return {
|
||||
before: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeCallProperty = function (node, parent) {
|
||||
var _parent$properties;
|
||||
|
||||
if (parent.callProperties[0] === node && !((_parent$properties = parent.properties) != null && _parent$properties.length)) {
|
||||
return {
|
||||
before: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
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 {
|
||||
before: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
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 {
|
||||
before: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const list = {
|
||||
VariableDeclaration(node) {
|
||||
return node.declarations.map(decl => decl.init);
|
||||
},
|
||||
|
||||
ArrayExpression(node) {
|
||||
return node.elements;
|
||||
},
|
||||
|
||||
ObjectExpression(node) {
|
||||
return node.properties;
|
||||
}
|
||||
|
||||
};
|
||||
exports.list = list;
|
||||
[["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) {
|
||||
nodes[type] = function () {
|
||||
return {
|
||||
after: amounts,
|
||||
before: amounts
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
539
node_modules/@babel/generator/lib/printer.js
generated
vendored
Normal file
539
node_modules/@babel/generator/lib/printer.js
generated
vendored
Normal file
|
@ -0,0 +1,539 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _buffer = require("./buffer");
|
||||
|
||||
var n = require("./node");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var generatorFunctions = require("./generators");
|
||||
|
||||
const {
|
||||
isProgram,
|
||||
isFile,
|
||||
isEmptyStatement
|
||||
} = _t;
|
||||
const SCIENTIFIC_NOTATION = /e/i;
|
||||
const ZERO_DECIMAL_INTEGER = /\.0+$/;
|
||||
const NON_DECIMAL_LITERAL = /^0[box]/;
|
||||
const PURE_ANNOTATION_RE = /^\s*[@#]__PURE__\s*$/;
|
||||
const {
|
||||
needsParens,
|
||||
needsWhitespaceAfter,
|
||||
needsWhitespaceBefore
|
||||
} = n;
|
||||
|
||||
class Printer {
|
||||
constructor(format, map) {
|
||||
this.inForStatementInitCounter = 0;
|
||||
this._printStack = [];
|
||||
this._indent = 0;
|
||||
this._insideAux = false;
|
||||
this._parenPushNewlineState = null;
|
||||
this._noLineTerminator = false;
|
||||
this._printAuxAfterOnNextUserNode = false;
|
||||
this._printedComments = new WeakSet();
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithWord = false;
|
||||
this.format = format;
|
||||
this._buf = new _buffer.default(map);
|
||||
}
|
||||
|
||||
generate(ast) {
|
||||
this.print(ast);
|
||||
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
return this._buf.get();
|
||||
}
|
||||
|
||||
indent() {
|
||||
if (this.format.compact || this.format.concise) return;
|
||||
this._indent++;
|
||||
}
|
||||
|
||||
dedent() {
|
||||
if (this.format.compact || this.format.concise) return;
|
||||
this._indent--;
|
||||
}
|
||||
|
||||
semicolon(force = false) {
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
this._append(";", !force);
|
||||
}
|
||||
|
||||
rightBrace() {
|
||||
if (this.format.minified) {
|
||||
this._buf.removeLastSemicolon();
|
||||
}
|
||||
|
||||
this.token("}");
|
||||
}
|
||||
|
||||
space(force = false) {
|
||||
if (this.format.compact) return;
|
||||
|
||||
if (force) {
|
||||
this._space();
|
||||
} else if (this._buf.hasContent()) {
|
||||
const lastCp = this.getLastChar();
|
||||
|
||||
if (lastCp !== 32 && lastCp !== 10) {
|
||||
this._space();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
word(str) {
|
||||
if (this._endsWithWord || this.endsWith(47) && str.charCodeAt(0) === 47) {
|
||||
this._space();
|
||||
}
|
||||
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
this._append(str);
|
||||
|
||||
this._endsWithWord = true;
|
||||
}
|
||||
|
||||
number(str) {
|
||||
this.word(str);
|
||||
this._endsWithInteger = Number.isInteger(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str.charCodeAt(str.length - 1) !== 46;
|
||||
}
|
||||
|
||||
token(str) {
|
||||
const lastChar = this.getLastChar();
|
||||
const strFirst = str.charCodeAt(0);
|
||||
|
||||
if (str === "--" && lastChar === 33 || strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 || strFirst === 46 && this._endsWithInteger) {
|
||||
this._space();
|
||||
}
|
||||
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
this._append(str);
|
||||
}
|
||||
|
||||
newline(i = 1) {
|
||||
if (this.format.retainLines || this.format.compact) return;
|
||||
|
||||
if (this.format.concise) {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
|
||||
const charBeforeNewline = this.endsWithCharAndNewline();
|
||||
if (charBeforeNewline === 10) return;
|
||||
|
||||
if (charBeforeNewline === 123 || charBeforeNewline === 58) {
|
||||
i--;
|
||||
}
|
||||
|
||||
if (i <= 0) return;
|
||||
|
||||
for (let j = 0; j < i; j++) {
|
||||
this._newline();
|
||||
}
|
||||
}
|
||||
|
||||
endsWith(char) {
|
||||
return this.getLastChar() === char;
|
||||
}
|
||||
|
||||
getLastChar() {
|
||||
return this._buf.getLastChar();
|
||||
}
|
||||
|
||||
endsWithCharAndNewline() {
|
||||
return this._buf.endsWithCharAndNewline();
|
||||
}
|
||||
|
||||
removeTrailingNewline() {
|
||||
this._buf.removeTrailingNewline();
|
||||
}
|
||||
|
||||
exactSource(loc, cb) {
|
||||
this._catchUp("start", loc);
|
||||
|
||||
this._buf.exactSource(loc, cb);
|
||||
}
|
||||
|
||||
source(prop, loc) {
|
||||
this._catchUp(prop, loc);
|
||||
|
||||
this._buf.source(prop, loc);
|
||||
}
|
||||
|
||||
withSource(prop, loc, cb) {
|
||||
this._catchUp(prop, loc);
|
||||
|
||||
this._buf.withSource(prop, loc, cb);
|
||||
}
|
||||
|
||||
_space() {
|
||||
this._append(" ", true);
|
||||
}
|
||||
|
||||
_newline() {
|
||||
this._append("\n", true);
|
||||
}
|
||||
|
||||
_append(str, queue = false) {
|
||||
this._maybeAddParen(str);
|
||||
|
||||
this._maybeIndent(str);
|
||||
|
||||
if (queue) this._buf.queue(str);else this._buf.append(str);
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
}
|
||||
|
||||
_maybeIndent(str) {
|
||||
if (this._indent && this.endsWith(10) && str.charCodeAt(0) !== 10) {
|
||||
this._buf.queueIndentation(this._getIndent());
|
||||
}
|
||||
}
|
||||
|
||||
_maybeAddParen(str) {
|
||||
const parenPushNewlineState = this._parenPushNewlineState;
|
||||
if (!parenPushNewlineState) return;
|
||||
let i;
|
||||
|
||||
for (i = 0; i < str.length && str[i] === " "; i++) continue;
|
||||
|
||||
if (i === str.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cha = str[i];
|
||||
|
||||
if (cha !== "\n") {
|
||||
if (cha !== "/" || i + 1 === str.length) {
|
||||
this._parenPushNewlineState = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const chaPost = str[i + 1];
|
||||
|
||||
if (chaPost === "*") {
|
||||
if (PURE_ANNOTATION_RE.test(str.slice(i + 2, str.length - 2))) {
|
||||
return;
|
||||
}
|
||||
} else if (chaPost !== "/") {
|
||||
this._parenPushNewlineState = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.token("(");
|
||||
this.indent();
|
||||
parenPushNewlineState.printed = true;
|
||||
}
|
||||
|
||||
_catchUp(prop, loc) {
|
||||
if (!this.format.retainLines) return;
|
||||
const pos = loc ? loc[prop] : null;
|
||||
|
||||
if ((pos == null ? void 0 : pos.line) != null) {
|
||||
const count = pos.line - this._buf.getCurrentLine();
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_getIndent() {
|
||||
return this.format.indent.style.repeat(this._indent);
|
||||
}
|
||||
|
||||
printTerminatorless(node, parent, isLabel) {
|
||||
if (isLabel) {
|
||||
this._noLineTerminator = true;
|
||||
this.print(node, parent);
|
||||
this._noLineTerminator = false;
|
||||
} else {
|
||||
const terminatorState = {
|
||||
printed: false
|
||||
};
|
||||
this._parenPushNewlineState = terminatorState;
|
||||
this.print(node, parent);
|
||||
|
||||
if (terminatorState.printed) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.token(")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print(node, parent) {
|
||||
if (!node) return;
|
||||
const oldConcise = this.format.concise;
|
||||
|
||||
if (node._compact) {
|
||||
this.format.concise = true;
|
||||
}
|
||||
|
||||
const printMethod = this[node.type];
|
||||
|
||||
if (!printMethod) {
|
||||
throw new ReferenceError(`unknown node of type ${JSON.stringify(node.type)} with constructor ${JSON.stringify(node == null ? void 0 : node.constructor.name)}`);
|
||||
}
|
||||
|
||||
this._printStack.push(node);
|
||||
|
||||
const oldInAux = this._insideAux;
|
||||
this._insideAux = !node.loc;
|
||||
|
||||
this._maybeAddAuxComment(this._insideAux && !oldInAux);
|
||||
|
||||
let shouldPrintParens = needsParens(node, parent, this._printStack);
|
||||
|
||||
if (this.format.retainFunctionParens && node.type === "FunctionExpression" && node.extra && node.extra.parenthesized) {
|
||||
shouldPrintParens = true;
|
||||
}
|
||||
|
||||
if (shouldPrintParens) this.token("(");
|
||||
|
||||
this._printLeadingComments(node);
|
||||
|
||||
const loc = isProgram(node) || isFile(node) ? null : node.loc;
|
||||
this.withSource("start", loc, () => {
|
||||
printMethod.call(this, node, parent);
|
||||
});
|
||||
|
||||
this._printTrailingComments(node);
|
||||
|
||||
if (shouldPrintParens) this.token(")");
|
||||
|
||||
this._printStack.pop();
|
||||
|
||||
this.format.concise = oldConcise;
|
||||
this._insideAux = oldInAux;
|
||||
}
|
||||
|
||||
_maybeAddAuxComment(enteredPositionlessNode) {
|
||||
if (enteredPositionlessNode) this._printAuxBeforeComment();
|
||||
if (!this._insideAux) this._printAuxAfterComment();
|
||||
}
|
||||
|
||||
_printAuxBeforeComment() {
|
||||
if (this._printAuxAfterOnNextUserNode) return;
|
||||
this._printAuxAfterOnNextUserNode = true;
|
||||
const comment = this.format.auxiliaryCommentBefore;
|
||||
|
||||
if (comment) {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
value: comment
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_printAuxAfterComment() {
|
||||
if (!this._printAuxAfterOnNextUserNode) return;
|
||||
this._printAuxAfterOnNextUserNode = false;
|
||||
const comment = this.format.auxiliaryCommentAfter;
|
||||
|
||||
if (comment) {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
value: comment
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getPossibleRaw(node) {
|
||||
const extra = node.extra;
|
||||
|
||||
if (extra && extra.raw != null && extra.rawValue != null && node.value === extra.rawValue) {
|
||||
return extra.raw;
|
||||
}
|
||||
}
|
||||
|
||||
printJoin(nodes, parent, opts = {}) {
|
||||
if (!(nodes != null && nodes.length)) return;
|
||||
if (opts.indent) this.indent();
|
||||
const newlineOpts = {
|
||||
addNewlines: opts.addNewlines
|
||||
};
|
||||
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const node = nodes[i];
|
||||
if (!node) continue;
|
||||
if (opts.statement) this._printNewline(true, node, parent, newlineOpts);
|
||||
this.print(node, parent);
|
||||
|
||||
if (opts.iterator) {
|
||||
opts.iterator(node, i);
|
||||
}
|
||||
|
||||
if (opts.separator && i < nodes.length - 1) {
|
||||
opts.separator.call(this);
|
||||
}
|
||||
|
||||
if (opts.statement) this._printNewline(false, node, parent, newlineOpts);
|
||||
}
|
||||
|
||||
if (opts.indent) this.dedent();
|
||||
}
|
||||
|
||||
printAndIndentOnComments(node, parent) {
|
||||
const indent = node.leadingComments && node.leadingComments.length > 0;
|
||||
if (indent) this.indent();
|
||||
this.print(node, parent);
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
|
||||
printBlock(parent) {
|
||||
const node = parent.body;
|
||||
|
||||
if (!isEmptyStatement(node)) {
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node, parent);
|
||||
}
|
||||
|
||||
_printTrailingComments(node) {
|
||||
this._printComments(this._getComments(false, node));
|
||||
}
|
||||
|
||||
_printLeadingComments(node) {
|
||||
this._printComments(this._getComments(true, node), true);
|
||||
}
|
||||
|
||||
printInnerComments(node, indent = true) {
|
||||
var _node$innerComments;
|
||||
|
||||
if (!((_node$innerComments = node.innerComments) != null && _node$innerComments.length)) return;
|
||||
if (indent) this.indent();
|
||||
|
||||
this._printComments(node.innerComments);
|
||||
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
|
||||
printSequence(nodes, parent, opts = {}) {
|
||||
opts.statement = true;
|
||||
return this.printJoin(nodes, parent, opts);
|
||||
}
|
||||
|
||||
printList(items, parent, opts = {}) {
|
||||
if (opts.separator == null) {
|
||||
opts.separator = commaSeparator;
|
||||
}
|
||||
|
||||
return this.printJoin(items, parent, opts);
|
||||
}
|
||||
|
||||
_printNewline(leading, node, parent, opts) {
|
||||
if (this.format.retainLines || this.format.compact) return;
|
||||
|
||||
if (this.format.concise) {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
|
||||
let lines = 0;
|
||||
|
||||
if (this._buf.hasContent()) {
|
||||
if (!leading) lines++;
|
||||
if (opts.addNewlines) lines += opts.addNewlines(leading, node) || 0;
|
||||
const needs = leading ? needsWhitespaceBefore : needsWhitespaceAfter;
|
||||
if (needs(node, parent)) lines++;
|
||||
}
|
||||
|
||||
this.newline(Math.min(2, lines));
|
||||
}
|
||||
|
||||
_getComments(leading, node) {
|
||||
return node && (leading ? node.leadingComments : node.trailingComments) || [];
|
||||
}
|
||||
|
||||
_printComment(comment, skipNewLines) {
|
||||
if (!this.format.shouldPrintComment(comment.value)) return;
|
||||
if (comment.ignore) return;
|
||||
if (this._printedComments.has(comment)) return;
|
||||
|
||||
this._printedComments.add(comment);
|
||||
|
||||
const isBlockComment = comment.type === "CommentBlock";
|
||||
const printNewLines = isBlockComment && !skipNewLines && !this._noLineTerminator;
|
||||
if (printNewLines && this._buf.hasContent()) this.newline(1);
|
||||
const lastCharCode = this.getLastChar();
|
||||
|
||||
if (lastCharCode !== 91 && lastCharCode !== 123) {
|
||||
this.space();
|
||||
}
|
||||
|
||||
let val = !isBlockComment && !this._noLineTerminator ? `//${comment.value}\n` : `/*${comment.value}*/`;
|
||||
|
||||
if (isBlockComment && this.format.indent.adjustMultilineComment) {
|
||||
var _comment$loc;
|
||||
|
||||
const offset = (_comment$loc = comment.loc) == null ? void 0 : _comment$loc.start.column;
|
||||
|
||||
if (offset) {
|
||||
const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
|
||||
val = val.replace(newlineRegex, "\n");
|
||||
}
|
||||
|
||||
const indentSize = Math.max(this._getIndent().length, this.format.retainLines ? 0 : this._buf.getCurrentColumn());
|
||||
val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);
|
||||
}
|
||||
|
||||
if (this.endsWith(47)) this._space();
|
||||
this.withSource("start", comment.loc, () => {
|
||||
this._append(val);
|
||||
});
|
||||
if (printNewLines) this.newline(1);
|
||||
}
|
||||
|
||||
_printComments(comments, inlinePureAnnotation) {
|
||||
if (!(comments != null && comments.length)) return;
|
||||
|
||||
if (inlinePureAnnotation && comments.length === 1 && PURE_ANNOTATION_RE.test(comments[0].value)) {
|
||||
this._printComment(comments[0], this._buf.hasContent() && !this.endsWith(10));
|
||||
} else {
|
||||
for (const comment of comments) {
|
||||
this._printComment(comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printAssertions(node) {
|
||||
var _node$assertions;
|
||||
|
||||
if ((_node$assertions = node.assertions) != null && _node$assertions.length) {
|
||||
this.space();
|
||||
this.word("assert");
|
||||
this.space();
|
||||
this.token("{");
|
||||
this.space();
|
||||
this.printList(node.assertions, node);
|
||||
this.space();
|
||||
this.token("}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object.assign(Printer.prototype, generatorFunctions);
|
||||
{
|
||||
Printer.prototype.Noop = function Noop() {};
|
||||
}
|
||||
var _default = Printer;
|
||||
exports.default = _default;
|
||||
|
||||
function commaSeparator() {
|
||||
this.token(",");
|
||||
this.space();
|
||||
}
|
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;
|
19
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/LICENSE
generated
vendored
Normal file
19
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright 2022 Justin Ridgewell <jridgewell@google.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
227
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/README.md
generated
vendored
Normal file
227
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/README.md
generated
vendored
Normal file
|
@ -0,0 +1,227 @@
|
|||
# @jridgewell/gen-mapping
|
||||
|
||||
> Generate source maps
|
||||
|
||||
`gen-mapping` allows you to generate a source map during transpilation or minification.
|
||||
With a source map, you're able to trace the original location in the source file, either in Chrome's
|
||||
DevTools or using a library like [`@jridgewell/trace-mapping`][trace-mapping].
|
||||
|
||||
You may already be familiar with the [`source-map`][source-map] package's `SourceMapGenerator`. This
|
||||
provides the same `addMapping` and `setSourceContent` API.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install @jridgewell/gen-mapping
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```typescript
|
||||
import { GenMapping, addMapping, setSourceContent, toEncodedMap, toDecodedMap } from '@jridgewell/gen-mapping';
|
||||
|
||||
const map = new GenMapping({
|
||||
file: 'output.js',
|
||||
sourceRoot: 'https://example.com/',
|
||||
});
|
||||
|
||||
setSourceContent(map, 'input.js', `function foo() {}`);
|
||||
|
||||
addMapping(map, {
|
||||
// Lines start at line 1, columns at column 0.
|
||||
generated: { line: 1, column: 0 },
|
||||
source: 'input.js',
|
||||
original: { line: 1, column: 0 },
|
||||
});
|
||||
|
||||
addMapping(map, {
|
||||
generated: { line: 1, column: 9 },
|
||||
source: 'input.js',
|
||||
original: { line: 1, column: 9 },
|
||||
name: 'foo',
|
||||
});
|
||||
|
||||
assert.deepEqual(toDecodedMap(map), {
|
||||
version: 3,
|
||||
file: 'output.js',
|
||||
names: ['foo'],
|
||||
sourceRoot: 'https://example.com/',
|
||||
sources: ['input.js'],
|
||||
sourcesContent: ['function foo() {}'],
|
||||
mappings: [
|
||||
[ [0, 0, 0, 0], [9, 0, 0, 9, 0] ]
|
||||
],
|
||||
});
|
||||
|
||||
assert.deepEqual(toEncodedMap(map), {
|
||||
version: 3,
|
||||
file: 'output.js',
|
||||
names: ['foo'],
|
||||
sourceRoot: 'https://example.com/',
|
||||
sources: ['input.js'],
|
||||
sourcesContent: ['function foo() {}'],
|
||||
mappings: 'AAAA,SAASA',
|
||||
});
|
||||
```
|
||||
|
||||
### Smaller Sourcemaps
|
||||
|
||||
Not everything needs to be added to a sourcemap, and needless markings can cause signficantly
|
||||
larger file sizes. `gen-mapping` exposes `maybeAddSegment`/`maybeAddMapping` APIs that will
|
||||
intelligently determine if this marking adds useful information. If not, the marking will be
|
||||
skipped.
|
||||
|
||||
```typescript
|
||||
import { maybeAddMapping } from '@jridgewell/gen-mapping';
|
||||
|
||||
const map = new GenMapping();
|
||||
|
||||
// Adding a sourceless marking at the beginning of a line isn't useful.
|
||||
maybeAddMapping(map, {
|
||||
generated: { line: 1, column: 0 },
|
||||
});
|
||||
|
||||
// Adding a new source marking is useful.
|
||||
maybeAddMapping(map, {
|
||||
generated: { line: 1, column: 0 },
|
||||
source: 'input.js',
|
||||
original: { line: 1, column: 0 },
|
||||
});
|
||||
|
||||
// But adding another marking pointing to the exact same original location isn't, even if the
|
||||
// generated column changed.
|
||||
maybeAddMapping(map, {
|
||||
generated: { line: 1, column: 9 },
|
||||
source: 'input.js',
|
||||
original: { line: 1, column: 0 },
|
||||
});
|
||||
|
||||
assert.deepEqual(toEncodedMap(map), {
|
||||
version: 3,
|
||||
names: [],
|
||||
sources: ['input.js'],
|
||||
sourcesContent: [null],
|
||||
mappings: 'AAAA',
|
||||
});
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
```
|
||||
node v18.0.0
|
||||
|
||||
amp.js.map
|
||||
Memory Usage:
|
||||
gen-mapping: addSegment 5852872 bytes
|
||||
gen-mapping: addMapping 7716042 bytes
|
||||
source-map-js 6143250 bytes
|
||||
source-map-0.6.1 6124102 bytes
|
||||
source-map-0.8.0 6121173 bytes
|
||||
Smallest memory usage is gen-mapping: addSegment
|
||||
|
||||
Adding speed:
|
||||
gen-mapping: addSegment x 441 ops/sec ±2.07% (90 runs sampled)
|
||||
gen-mapping: addMapping x 350 ops/sec ±2.40% (86 runs sampled)
|
||||
source-map-js: addMapping x 169 ops/sec ±2.42% (80 runs sampled)
|
||||
source-map-0.6.1: addMapping x 167 ops/sec ±2.56% (80 runs sampled)
|
||||
source-map-0.8.0: addMapping x 168 ops/sec ±2.52% (80 runs sampled)
|
||||
Fastest is gen-mapping: addSegment
|
||||
|
||||
Generate speed:
|
||||
gen-mapping: decoded output x 150,824,370 ops/sec ±0.07% (102 runs sampled)
|
||||
gen-mapping: encoded output x 663 ops/sec ±0.22% (98 runs sampled)
|
||||
source-map-js: encoded output x 197 ops/sec ±0.45% (84 runs sampled)
|
||||
source-map-0.6.1: encoded output x 198 ops/sec ±0.33% (85 runs sampled)
|
||||
source-map-0.8.0: encoded output x 197 ops/sec ±0.06% (93 runs sampled)
|
||||
Fastest is gen-mapping: decoded output
|
||||
|
||||
|
||||
***
|
||||
|
||||
|
||||
babel.min.js.map
|
||||
Memory Usage:
|
||||
gen-mapping: addSegment 37578063 bytes
|
||||
gen-mapping: addMapping 37212897 bytes
|
||||
source-map-js 47638527 bytes
|
||||
source-map-0.6.1 47690503 bytes
|
||||
source-map-0.8.0 47470188 bytes
|
||||
Smallest memory usage is gen-mapping: addMapping
|
||||
|
||||
Adding speed:
|
||||
gen-mapping: addSegment x 31.05 ops/sec ±8.31% (43 runs sampled)
|
||||
gen-mapping: addMapping x 29.83 ops/sec ±7.36% (51 runs sampled)
|
||||
source-map-js: addMapping x 20.73 ops/sec ±6.22% (38 runs sampled)
|
||||
source-map-0.6.1: addMapping x 20.03 ops/sec ±10.51% (38 runs sampled)
|
||||
source-map-0.8.0: addMapping x 19.30 ops/sec ±8.27% (37 runs sampled)
|
||||
Fastest is gen-mapping: addSegment
|
||||
|
||||
Generate speed:
|
||||
gen-mapping: decoded output x 381,379,234 ops/sec ±0.29% (96 runs sampled)
|
||||
gen-mapping: encoded output x 95.15 ops/sec ±2.98% (72 runs sampled)
|
||||
source-map-js: encoded output x 15.20 ops/sec ±7.41% (33 runs sampled)
|
||||
source-map-0.6.1: encoded output x 16.36 ops/sec ±10.46% (31 runs sampled)
|
||||
source-map-0.8.0: encoded output x 16.06 ops/sec ±6.45% (31 runs sampled)
|
||||
Fastest is gen-mapping: decoded output
|
||||
|
||||
|
||||
***
|
||||
|
||||
|
||||
preact.js.map
|
||||
Memory Usage:
|
||||
gen-mapping: addSegment 416247 bytes
|
||||
gen-mapping: addMapping 419824 bytes
|
||||
source-map-js 1024619 bytes
|
||||
source-map-0.6.1 1146004 bytes
|
||||
source-map-0.8.0 1113250 bytes
|
||||
Smallest memory usage is gen-mapping: addSegment
|
||||
|
||||
Adding speed:
|
||||
gen-mapping: addSegment x 13,755 ops/sec ±0.15% (98 runs sampled)
|
||||
gen-mapping: addMapping x 13,013 ops/sec ±0.11% (101 runs sampled)
|
||||
source-map-js: addMapping x 4,564 ops/sec ±0.21% (98 runs sampled)
|
||||
source-map-0.6.1: addMapping x 4,562 ops/sec ±0.11% (99 runs sampled)
|
||||
source-map-0.8.0: addMapping x 4,593 ops/sec ±0.11% (100 runs sampled)
|
||||
Fastest is gen-mapping: addSegment
|
||||
|
||||
Generate speed:
|
||||
gen-mapping: decoded output x 379,864,020 ops/sec ±0.23% (93 runs sampled)
|
||||
gen-mapping: encoded output x 14,368 ops/sec ±4.07% (82 runs sampled)
|
||||
source-map-js: encoded output x 5,261 ops/sec ±0.21% (99 runs sampled)
|
||||
source-map-0.6.1: encoded output x 5,124 ops/sec ±0.58% (99 runs sampled)
|
||||
source-map-0.8.0: encoded output x 5,434 ops/sec ±0.33% (96 runs sampled)
|
||||
Fastest is gen-mapping: decoded output
|
||||
|
||||
|
||||
***
|
||||
|
||||
|
||||
react.js.map
|
||||
Memory Usage:
|
||||
gen-mapping: addSegment 975096 bytes
|
||||
gen-mapping: addMapping 1102981 bytes
|
||||
source-map-js 2918836 bytes
|
||||
source-map-0.6.1 2885435 bytes
|
||||
source-map-0.8.0 2874336 bytes
|
||||
Smallest memory usage is gen-mapping: addSegment
|
||||
|
||||
Adding speed:
|
||||
gen-mapping: addSegment x 4,772 ops/sec ±0.15% (100 runs sampled)
|
||||
gen-mapping: addMapping x 4,456 ops/sec ±0.13% (97 runs sampled)
|
||||
source-map-js: addMapping x 1,618 ops/sec ±0.24% (97 runs sampled)
|
||||
source-map-0.6.1: addMapping x 1,622 ops/sec ±0.12% (99 runs sampled)
|
||||
source-map-0.8.0: addMapping x 1,631 ops/sec ±0.12% (100 runs sampled)
|
||||
Fastest is gen-mapping: addSegment
|
||||
|
||||
Generate speed:
|
||||
gen-mapping: decoded output x 379,107,695 ops/sec ±0.07% (99 runs sampled)
|
||||
gen-mapping: encoded output x 5,421 ops/sec ±1.60% (89 runs sampled)
|
||||
source-map-js: encoded output x 2,113 ops/sec ±1.81% (98 runs sampled)
|
||||
source-map-0.6.1: encoded output x 2,126 ops/sec ±0.10% (100 runs sampled)
|
||||
source-map-0.8.0: encoded output x 2,176 ops/sec ±0.39% (98 runs sampled)
|
||||
Fastest is gen-mapping: decoded output
|
||||
```
|
||||
|
||||
[source-map]: https://www.npmjs.com/package/source-map
|
||||
[trace-mapping]: https://github.com/jridgewell/trace-mapping
|
230
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
generated
vendored
Normal file
230
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
generated
vendored
Normal file
|
@ -0,0 +1,230 @@
|
|||
import { SetArray, put } from '@jridgewell/set-array';
|
||||
import { encode } from '@jridgewell/sourcemap-codec';
|
||||
import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping';
|
||||
|
||||
const COLUMN = 0;
|
||||
const SOURCES_INDEX = 1;
|
||||
const SOURCE_LINE = 2;
|
||||
const SOURCE_COLUMN = 3;
|
||||
const NAMES_INDEX = 4;
|
||||
|
||||
const NO_NAME = -1;
|
||||
/**
|
||||
* A low-level API to associate a generated position with an original source position. Line and
|
||||
* column here are 0-based, unlike `addMapping`.
|
||||
*/
|
||||
let addSegment;
|
||||
/**
|
||||
* A high-level API to associate a generated position with an original source position. Line is
|
||||
* 1-based, but column is 0-based, due to legacy behavior in `source-map` library.
|
||||
*/
|
||||
let addMapping;
|
||||
/**
|
||||
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
||||
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
||||
* not add a segment with a lower generated line/column than one that came before.
|
||||
*/
|
||||
let maybeAddSegment;
|
||||
/**
|
||||
* Same as `addMapping`, but will only add the mapping if it generates useful information in the
|
||||
* resulting map. This only works correctly if mappings are added **in order**, meaning you should
|
||||
* not add a mapping with a lower generated line/column than one that came before.
|
||||
*/
|
||||
let maybeAddMapping;
|
||||
/**
|
||||
* Adds/removes the content of the source file to the source map.
|
||||
*/
|
||||
let setSourceContent;
|
||||
/**
|
||||
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
let toDecodedMap;
|
||||
/**
|
||||
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
let toEncodedMap;
|
||||
/**
|
||||
* Constructs a new GenMapping, using the already present mappings of the input.
|
||||
*/
|
||||
let fromMap;
|
||||
/**
|
||||
* Returns an array of high-level mapping objects for every recorded segment, which could then be
|
||||
* passed to the `source-map` library.
|
||||
*/
|
||||
let allMappings;
|
||||
// This split declaration is only so that terser can elminiate the static initialization block.
|
||||
let addSegmentInternal;
|
||||
/**
|
||||
* Provides the state to generate a sourcemap.
|
||||
*/
|
||||
class GenMapping {
|
||||
constructor({ file, sourceRoot } = {}) {
|
||||
this._names = new SetArray();
|
||||
this._sources = new SetArray();
|
||||
this._sourcesContent = [];
|
||||
this._mappings = [];
|
||||
this.file = file;
|
||||
this.sourceRoot = sourceRoot;
|
||||
}
|
||||
}
|
||||
(() => {
|
||||
addSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||
return addSegmentInternal(false, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
|
||||
};
|
||||
maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||
return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
|
||||
};
|
||||
addMapping = (map, mapping) => {
|
||||
return addMappingInternal(false, map, mapping);
|
||||
};
|
||||
maybeAddMapping = (map, mapping) => {
|
||||
return addMappingInternal(true, map, mapping);
|
||||
};
|
||||
setSourceContent = (map, source, content) => {
|
||||
const { _sources: sources, _sourcesContent: sourcesContent } = map;
|
||||
sourcesContent[put(sources, source)] = content;
|
||||
};
|
||||
toDecodedMap = (map) => {
|
||||
const { file, sourceRoot, _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map;
|
||||
removeEmptyFinalLines(mappings);
|
||||
return {
|
||||
version: 3,
|
||||
file: file || undefined,
|
||||
names: names.array,
|
||||
sourceRoot: sourceRoot || undefined,
|
||||
sources: sources.array,
|
||||
sourcesContent,
|
||||
mappings,
|
||||
};
|
||||
};
|
||||
toEncodedMap = (map) => {
|
||||
const decoded = toDecodedMap(map);
|
||||
return Object.assign(Object.assign({}, decoded), { mappings: encode(decoded.mappings) });
|
||||
};
|
||||
allMappings = (map) => {
|
||||
const out = [];
|
||||
const { _mappings: mappings, _sources: sources, _names: names } = map;
|
||||
for (let i = 0; i < mappings.length; i++) {
|
||||
const line = mappings[i];
|
||||
for (let j = 0; j < line.length; j++) {
|
||||
const seg = line[j];
|
||||
const generated = { line: i + 1, column: seg[COLUMN] };
|
||||
let source = undefined;
|
||||
let original = undefined;
|
||||
let name = undefined;
|
||||
if (seg.length !== 1) {
|
||||
source = sources.array[seg[SOURCES_INDEX]];
|
||||
original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };
|
||||
if (seg.length === 5)
|
||||
name = names.array[seg[NAMES_INDEX]];
|
||||
}
|
||||
out.push({ generated, source, original, name });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
};
|
||||
fromMap = (input) => {
|
||||
const map = new TraceMap(input);
|
||||
const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });
|
||||
putAll(gen._names, map.names);
|
||||
putAll(gen._sources, map.sources);
|
||||
gen._sourcesContent = map.sourcesContent || map.sources.map(() => null);
|
||||
gen._mappings = decodedMappings(map);
|
||||
return gen;
|
||||
};
|
||||
// Internal helpers
|
||||
addSegmentInternal = (skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map;
|
||||
const line = getLine(mappings, genLine);
|
||||
const index = getColumnIndex(line, genColumn);
|
||||
if (!source) {
|
||||
if (skipable && skipSourceless(line, index))
|
||||
return;
|
||||
return insert(line, index, [genColumn]);
|
||||
}
|
||||
const sourcesIndex = put(sources, source);
|
||||
const namesIndex = name ? put(names, name) : NO_NAME;
|
||||
if (sourcesIndex === sourcesContent.length)
|
||||
sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null;
|
||||
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
||||
return;
|
||||
}
|
||||
return insert(line, index, name
|
||||
? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
|
||||
: [genColumn, sourcesIndex, sourceLine, sourceColumn]);
|
||||
};
|
||||
})();
|
||||
function getLine(mappings, index) {
|
||||
for (let i = mappings.length; i <= index; i++) {
|
||||
mappings[i] = [];
|
||||
}
|
||||
return mappings[index];
|
||||
}
|
||||
function getColumnIndex(line, genColumn) {
|
||||
let index = line.length;
|
||||
for (let i = index - 1; i >= 0; index = i--) {
|
||||
const current = line[i];
|
||||
if (genColumn >= current[COLUMN])
|
||||
break;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
function insert(array, index, value) {
|
||||
for (let i = array.length; i > index; i--) {
|
||||
array[i] = array[i - 1];
|
||||
}
|
||||
array[index] = value;
|
||||
}
|
||||
function removeEmptyFinalLines(mappings) {
|
||||
const { length } = mappings;
|
||||
let len = length;
|
||||
for (let i = len - 1; i >= 0; len = i, i--) {
|
||||
if (mappings[i].length > 0)
|
||||
break;
|
||||
}
|
||||
if (len < length)
|
||||
mappings.length = len;
|
||||
}
|
||||
function putAll(strarr, array) {
|
||||
for (let i = 0; i < array.length; i++)
|
||||
put(strarr, array[i]);
|
||||
}
|
||||
function skipSourceless(line, index) {
|
||||
// The start of a line is already sourceless, so adding a sourceless segment to the beginning
|
||||
// doesn't generate any useful information.
|
||||
if (index === 0)
|
||||
return true;
|
||||
const prev = line[index - 1];
|
||||
// If the previous segment is also sourceless, then adding another sourceless segment doesn't
|
||||
// genrate any new information. Else, this segment will end the source/named segment and point to
|
||||
// a sourceless position, which is useful.
|
||||
return prev.length === 1;
|
||||
}
|
||||
function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) {
|
||||
// A source/named segment at the start of a line gives position at that genColumn
|
||||
if (index === 0)
|
||||
return false;
|
||||
const prev = line[index - 1];
|
||||
// If the previous segment is sourceless, then we're transitioning to a source.
|
||||
if (prev.length === 1)
|
||||
return false;
|
||||
// If the previous segment maps to the exact same source position, then this segment doesn't
|
||||
// provide any new position information.
|
||||
return (sourcesIndex === prev[SOURCES_INDEX] &&
|
||||
sourceLine === prev[SOURCE_LINE] &&
|
||||
sourceColumn === prev[SOURCE_COLUMN] &&
|
||||
namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME));
|
||||
}
|
||||
function addMappingInternal(skipable, map, mapping) {
|
||||
const { generated, source, original, name, content } = mapping;
|
||||
if (!source) {
|
||||
return addSegmentInternal(skipable, map, generated.line - 1, generated.column, null, null, null, null, null);
|
||||
}
|
||||
const s = source;
|
||||
return addSegmentInternal(skipable, map, generated.line - 1, generated.column, s, original.line - 1, original.column, name, content);
|
||||
}
|
||||
|
||||
export { GenMapping, addMapping, addSegment, allMappings, fromMap, maybeAddMapping, maybeAddSegment, setSourceContent, toDecodedMap, toEncodedMap };
|
||||
//# sourceMappingURL=gen-mapping.mjs.map
|
1
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map
generated
vendored
Normal file
1
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
236
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js
generated
vendored
Normal file
236
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js
generated
vendored
Normal file
|
@ -0,0 +1,236 @@
|
|||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/set-array'), require('@jridgewell/sourcemap-codec'), require('@jridgewell/trace-mapping')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/set-array', '@jridgewell/sourcemap-codec', '@jridgewell/trace-mapping'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.genMapping = {}, global.setArray, global.sourcemapCodec, global.traceMapping));
|
||||
})(this, (function (exports, setArray, sourcemapCodec, traceMapping) { 'use strict';
|
||||
|
||||
const COLUMN = 0;
|
||||
const SOURCES_INDEX = 1;
|
||||
const SOURCE_LINE = 2;
|
||||
const SOURCE_COLUMN = 3;
|
||||
const NAMES_INDEX = 4;
|
||||
|
||||
const NO_NAME = -1;
|
||||
/**
|
||||
* A low-level API to associate a generated position with an original source position. Line and
|
||||
* column here are 0-based, unlike `addMapping`.
|
||||
*/
|
||||
exports.addSegment = void 0;
|
||||
/**
|
||||
* A high-level API to associate a generated position with an original source position. Line is
|
||||
* 1-based, but column is 0-based, due to legacy behavior in `source-map` library.
|
||||
*/
|
||||
exports.addMapping = void 0;
|
||||
/**
|
||||
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
||||
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
||||
* not add a segment with a lower generated line/column than one that came before.
|
||||
*/
|
||||
exports.maybeAddSegment = void 0;
|
||||
/**
|
||||
* Same as `addMapping`, but will only add the mapping if it generates useful information in the
|
||||
* resulting map. This only works correctly if mappings are added **in order**, meaning you should
|
||||
* not add a mapping with a lower generated line/column than one that came before.
|
||||
*/
|
||||
exports.maybeAddMapping = void 0;
|
||||
/**
|
||||
* Adds/removes the content of the source file to the source map.
|
||||
*/
|
||||
exports.setSourceContent = void 0;
|
||||
/**
|
||||
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
exports.toDecodedMap = void 0;
|
||||
/**
|
||||
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
exports.toEncodedMap = void 0;
|
||||
/**
|
||||
* Constructs a new GenMapping, using the already present mappings of the input.
|
||||
*/
|
||||
exports.fromMap = void 0;
|
||||
/**
|
||||
* Returns an array of high-level mapping objects for every recorded segment, which could then be
|
||||
* passed to the `source-map` library.
|
||||
*/
|
||||
exports.allMappings = void 0;
|
||||
// This split declaration is only so that terser can elminiate the static initialization block.
|
||||
let addSegmentInternal;
|
||||
/**
|
||||
* Provides the state to generate a sourcemap.
|
||||
*/
|
||||
class GenMapping {
|
||||
constructor({ file, sourceRoot } = {}) {
|
||||
this._names = new setArray.SetArray();
|
||||
this._sources = new setArray.SetArray();
|
||||
this._sourcesContent = [];
|
||||
this._mappings = [];
|
||||
this.file = file;
|
||||
this.sourceRoot = sourceRoot;
|
||||
}
|
||||
}
|
||||
(() => {
|
||||
exports.addSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||
return addSegmentInternal(false, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
|
||||
};
|
||||
exports.maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||
return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
|
||||
};
|
||||
exports.addMapping = (map, mapping) => {
|
||||
return addMappingInternal(false, map, mapping);
|
||||
};
|
||||
exports.maybeAddMapping = (map, mapping) => {
|
||||
return addMappingInternal(true, map, mapping);
|
||||
};
|
||||
exports.setSourceContent = (map, source, content) => {
|
||||
const { _sources: sources, _sourcesContent: sourcesContent } = map;
|
||||
sourcesContent[setArray.put(sources, source)] = content;
|
||||
};
|
||||
exports.toDecodedMap = (map) => {
|
||||
const { file, sourceRoot, _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map;
|
||||
removeEmptyFinalLines(mappings);
|
||||
return {
|
||||
version: 3,
|
||||
file: file || undefined,
|
||||
names: names.array,
|
||||
sourceRoot: sourceRoot || undefined,
|
||||
sources: sources.array,
|
||||
sourcesContent,
|
||||
mappings,
|
||||
};
|
||||
};
|
||||
exports.toEncodedMap = (map) => {
|
||||
const decoded = exports.toDecodedMap(map);
|
||||
return Object.assign(Object.assign({}, decoded), { mappings: sourcemapCodec.encode(decoded.mappings) });
|
||||
};
|
||||
exports.allMappings = (map) => {
|
||||
const out = [];
|
||||
const { _mappings: mappings, _sources: sources, _names: names } = map;
|
||||
for (let i = 0; i < mappings.length; i++) {
|
||||
const line = mappings[i];
|
||||
for (let j = 0; j < line.length; j++) {
|
||||
const seg = line[j];
|
||||
const generated = { line: i + 1, column: seg[COLUMN] };
|
||||
let source = undefined;
|
||||
let original = undefined;
|
||||
let name = undefined;
|
||||
if (seg.length !== 1) {
|
||||
source = sources.array[seg[SOURCES_INDEX]];
|
||||
original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };
|
||||
if (seg.length === 5)
|
||||
name = names.array[seg[NAMES_INDEX]];
|
||||
}
|
||||
out.push({ generated, source, original, name });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
};
|
||||
exports.fromMap = (input) => {
|
||||
const map = new traceMapping.TraceMap(input);
|
||||
const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });
|
||||
putAll(gen._names, map.names);
|
||||
putAll(gen._sources, map.sources);
|
||||
gen._sourcesContent = map.sourcesContent || map.sources.map(() => null);
|
||||
gen._mappings = traceMapping.decodedMappings(map);
|
||||
return gen;
|
||||
};
|
||||
// Internal helpers
|
||||
addSegmentInternal = (skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map;
|
||||
const line = getLine(mappings, genLine);
|
||||
const index = getColumnIndex(line, genColumn);
|
||||
if (!source) {
|
||||
if (skipable && skipSourceless(line, index))
|
||||
return;
|
||||
return insert(line, index, [genColumn]);
|
||||
}
|
||||
const sourcesIndex = setArray.put(sources, source);
|
||||
const namesIndex = name ? setArray.put(names, name) : NO_NAME;
|
||||
if (sourcesIndex === sourcesContent.length)
|
||||
sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null;
|
||||
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
||||
return;
|
||||
}
|
||||
return insert(line, index, name
|
||||
? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
|
||||
: [genColumn, sourcesIndex, sourceLine, sourceColumn]);
|
||||
};
|
||||
})();
|
||||
function getLine(mappings, index) {
|
||||
for (let i = mappings.length; i <= index; i++) {
|
||||
mappings[i] = [];
|
||||
}
|
||||
return mappings[index];
|
||||
}
|
||||
function getColumnIndex(line, genColumn) {
|
||||
let index = line.length;
|
||||
for (let i = index - 1; i >= 0; index = i--) {
|
||||
const current = line[i];
|
||||
if (genColumn >= current[COLUMN])
|
||||
break;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
function insert(array, index, value) {
|
||||
for (let i = array.length; i > index; i--) {
|
||||
array[i] = array[i - 1];
|
||||
}
|
||||
array[index] = value;
|
||||
}
|
||||
function removeEmptyFinalLines(mappings) {
|
||||
const { length } = mappings;
|
||||
let len = length;
|
||||
for (let i = len - 1; i >= 0; len = i, i--) {
|
||||
if (mappings[i].length > 0)
|
||||
break;
|
||||
}
|
||||
if (len < length)
|
||||
mappings.length = len;
|
||||
}
|
||||
function putAll(strarr, array) {
|
||||
for (let i = 0; i < array.length; i++)
|
||||
setArray.put(strarr, array[i]);
|
||||
}
|
||||
function skipSourceless(line, index) {
|
||||
// The start of a line is already sourceless, so adding a sourceless segment to the beginning
|
||||
// doesn't generate any useful information.
|
||||
if (index === 0)
|
||||
return true;
|
||||
const prev = line[index - 1];
|
||||
// If the previous segment is also sourceless, then adding another sourceless segment doesn't
|
||||
// genrate any new information. Else, this segment will end the source/named segment and point to
|
||||
// a sourceless position, which is useful.
|
||||
return prev.length === 1;
|
||||
}
|
||||
function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) {
|
||||
// A source/named segment at the start of a line gives position at that genColumn
|
||||
if (index === 0)
|
||||
return false;
|
||||
const prev = line[index - 1];
|
||||
// If the previous segment is sourceless, then we're transitioning to a source.
|
||||
if (prev.length === 1)
|
||||
return false;
|
||||
// If the previous segment maps to the exact same source position, then this segment doesn't
|
||||
// provide any new position information.
|
||||
return (sourcesIndex === prev[SOURCES_INDEX] &&
|
||||
sourceLine === prev[SOURCE_LINE] &&
|
||||
sourceColumn === prev[SOURCE_COLUMN] &&
|
||||
namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME));
|
||||
}
|
||||
function addMappingInternal(skipable, map, mapping) {
|
||||
const { generated, source, original, name, content } = mapping;
|
||||
if (!source) {
|
||||
return addSegmentInternal(skipable, map, generated.line - 1, generated.column, null, null, null, null, null);
|
||||
}
|
||||
const s = source;
|
||||
return addSegmentInternal(skipable, map, generated.line - 1, generated.column, s, original.line - 1, original.column, name, content);
|
||||
}
|
||||
|
||||
exports.GenMapping = GenMapping;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
}));
|
||||
//# sourceMappingURL=gen-mapping.umd.js.map
|
1
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
90
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts
generated
vendored
Normal file
90
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
import type { SourceMapInput } from '@jridgewell/trace-mapping';
|
||||
import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types';
|
||||
export type { DecodedSourceMap, EncodedSourceMap, Mapping };
|
||||
export declare type Options = {
|
||||
file?: string | null;
|
||||
sourceRoot?: string | null;
|
||||
};
|
||||
/**
|
||||
* A low-level API to associate a generated position with an original source position. Line and
|
||||
* column here are 0-based, unlike `addMapping`.
|
||||
*/
|
||||
export declare let addSegment: {
|
||||
(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void;
|
||||
(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void;
|
||||
(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void;
|
||||
};
|
||||
/**
|
||||
* A high-level API to associate a generated position with an original source position. Line is
|
||||
* 1-based, but column is 0-based, due to legacy behavior in `source-map` library.
|
||||
*/
|
||||
export declare let addMapping: {
|
||||
(map: GenMapping, mapping: {
|
||||
generated: Pos;
|
||||
source?: null;
|
||||
original?: null;
|
||||
name?: null;
|
||||
content?: null;
|
||||
}): void;
|
||||
(map: GenMapping, mapping: {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name?: null;
|
||||
content?: string | null;
|
||||
}): void;
|
||||
(map: GenMapping, mapping: {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name: string;
|
||||
content?: string | null;
|
||||
}): void;
|
||||
};
|
||||
/**
|
||||
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
||||
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
||||
* not add a segment with a lower generated line/column than one that came before.
|
||||
*/
|
||||
export declare let maybeAddSegment: typeof addSegment;
|
||||
/**
|
||||
* Same as `addMapping`, but will only add the mapping if it generates useful information in the
|
||||
* resulting map. This only works correctly if mappings are added **in order**, meaning you should
|
||||
* not add a mapping with a lower generated line/column than one that came before.
|
||||
*/
|
||||
export declare let maybeAddMapping: typeof addMapping;
|
||||
/**
|
||||
* Adds/removes the content of the source file to the source map.
|
||||
*/
|
||||
export declare let setSourceContent: (map: GenMapping, source: string, content: string | null) => void;
|
||||
/**
|
||||
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
export declare let toDecodedMap: (map: GenMapping) => DecodedSourceMap;
|
||||
/**
|
||||
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
export declare let toEncodedMap: (map: GenMapping) => EncodedSourceMap;
|
||||
/**
|
||||
* Constructs a new GenMapping, using the already present mappings of the input.
|
||||
*/
|
||||
export declare let fromMap: (input: SourceMapInput) => GenMapping;
|
||||
/**
|
||||
* Returns an array of high-level mapping objects for every recorded segment, which could then be
|
||||
* passed to the `source-map` library.
|
||||
*/
|
||||
export declare let allMappings: (map: GenMapping) => Mapping[];
|
||||
/**
|
||||
* Provides the state to generate a sourcemap.
|
||||
*/
|
||||
export declare class GenMapping {
|
||||
private _names;
|
||||
private _sources;
|
||||
private _sourcesContent;
|
||||
private _mappings;
|
||||
file: string | null | undefined;
|
||||
sourceRoot: string | null | undefined;
|
||||
constructor({ file, sourceRoot }?: Options);
|
||||
}
|
12
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts
generated
vendored
Normal file
12
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
declare type GeneratedColumn = number;
|
||||
declare type SourcesIndex = number;
|
||||
declare type SourceLine = number;
|
||||
declare type SourceColumn = number;
|
||||
declare type NamesIndex = number;
|
||||
export declare type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
|
||||
export declare const COLUMN = 0;
|
||||
export declare const SOURCES_INDEX = 1;
|
||||
export declare const SOURCE_LINE = 2;
|
||||
export declare const SOURCE_COLUMN = 3;
|
||||
export declare const NAMES_INDEX = 4;
|
||||
export {};
|
35
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts
generated
vendored
Normal file
35
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
import type { SourceMapSegment } from './sourcemap-segment';
|
||||
export interface SourceMapV3 {
|
||||
file?: string | null;
|
||||
names: readonly string[];
|
||||
sourceRoot?: string;
|
||||
sources: readonly (string | null)[];
|
||||
sourcesContent?: readonly (string | null)[];
|
||||
version: 3;
|
||||
}
|
||||
export interface EncodedSourceMap extends SourceMapV3 {
|
||||
mappings: string;
|
||||
}
|
||||
export interface DecodedSourceMap extends SourceMapV3 {
|
||||
mappings: readonly SourceMapSegment[][];
|
||||
}
|
||||
export interface Pos {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
export declare type Mapping = {
|
||||
generated: Pos;
|
||||
source: undefined;
|
||||
original: undefined;
|
||||
name: undefined;
|
||||
} | {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name: string;
|
||||
} | {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name: undefined;
|
||||
};
|
78
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/package.json
generated
vendored
Normal file
78
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/package.json
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"name": "@jridgewell/gen-mapping",
|
||||
"version": "0.3.2",
|
||||
"description": "Generate source maps",
|
||||
"keywords": [
|
||||
"source",
|
||||
"map"
|
||||
],
|
||||
"author": "Justin Ridgewell <justin@ridgewell.name>",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/jridgewell/gen-mapping",
|
||||
"main": "dist/gen-mapping.umd.js",
|
||||
"module": "dist/gen-mapping.mjs",
|
||||
"typings": "dist/types/gen-mapping.d.ts",
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"types": "./dist/types/gen-mapping.d.ts",
|
||||
"browser": "./dist/gen-mapping.umd.js",
|
||||
"require": "./dist/gen-mapping.umd.js",
|
||||
"import": "./dist/gen-mapping.mjs"
|
||||
},
|
||||
"./dist/gen-mapping.umd.js"
|
||||
],
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "run-s build:rollup benchmark:*",
|
||||
"benchmark:install": "cd benchmark && npm install",
|
||||
"benchmark:only": "node benchmark/index.mjs",
|
||||
"prebuild": "rm -rf dist",
|
||||
"build": "run-s -n build:*",
|
||||
"build:rollup": "rollup -c rollup.config.js",
|
||||
"build:ts": "tsc --project tsconfig.build.json",
|
||||
"lint": "run-s -n lint:*",
|
||||
"lint:prettier": "npm run test:lint:prettier -- --write",
|
||||
"lint:ts": "npm run test:lint:ts -- --fix",
|
||||
"pretest": "run-s build:rollup",
|
||||
"test": "run-s -n test:lint test:coverage",
|
||||
"test:debug": "mocha --inspect-brk",
|
||||
"test:lint": "run-s -n test:lint:*",
|
||||
"test:lint:prettier": "prettier --check '{src,test}/**/*.ts'",
|
||||
"test:lint:ts": "eslint '{src,test}/**/*.ts'",
|
||||
"test:only": "mocha",
|
||||
"test:coverage": "c8 mocha",
|
||||
"test:watch": "run-p 'build:rollup -- --watch' 'test:only -- --watch'",
|
||||
"prepublishOnly": "npm run preversion",
|
||||
"preversion": "run-s test build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "8.3.2",
|
||||
"@types/mocha": "9.1.1",
|
||||
"@types/node": "17.0.29",
|
||||
"@typescript-eslint/eslint-plugin": "5.21.0",
|
||||
"@typescript-eslint/parser": "5.21.0",
|
||||
"benchmark": "2.1.4",
|
||||
"c8": "7.11.2",
|
||||
"eslint": "8.14.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"mocha": "9.2.2",
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "2.6.2",
|
||||
"rollup": "2.70.2",
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jridgewell/set-array": "^1.0.1",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10",
|
||||
"@jridgewell/trace-mapping": "^0.3.9"
|
||||
}
|
||||
}
|
458
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/src/gen-mapping.ts
generated
vendored
Normal file
458
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/src/gen-mapping.ts
generated
vendored
Normal file
|
@ -0,0 +1,458 @@
|
|||
import { SetArray, put } from '@jridgewell/set-array';
|
||||
import { encode } from '@jridgewell/sourcemap-codec';
|
||||
import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping';
|
||||
|
||||
import {
|
||||
COLUMN,
|
||||
SOURCES_INDEX,
|
||||
SOURCE_LINE,
|
||||
SOURCE_COLUMN,
|
||||
NAMES_INDEX,
|
||||
} from './sourcemap-segment';
|
||||
|
||||
import type { SourceMapInput } from '@jridgewell/trace-mapping';
|
||||
import type { SourceMapSegment } from './sourcemap-segment';
|
||||
import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types';
|
||||
|
||||
export type { DecodedSourceMap, EncodedSourceMap, Mapping };
|
||||
|
||||
export type Options = {
|
||||
file?: string | null;
|
||||
sourceRoot?: string | null;
|
||||
};
|
||||
|
||||
const NO_NAME = -1;
|
||||
|
||||
/**
|
||||
* A low-level API to associate a generated position with an original source position. Line and
|
||||
* column here are 0-based, unlike `addMapping`.
|
||||
*/
|
||||
export let addSegment: {
|
||||
(
|
||||
map: GenMapping,
|
||||
genLine: number,
|
||||
genColumn: number,
|
||||
source?: null,
|
||||
sourceLine?: null,
|
||||
sourceColumn?: null,
|
||||
name?: null,
|
||||
content?: null,
|
||||
): void;
|
||||
(
|
||||
map: GenMapping,
|
||||
genLine: number,
|
||||
genColumn: number,
|
||||
source: string,
|
||||
sourceLine: number,
|
||||
sourceColumn: number,
|
||||
name?: null,
|
||||
content?: string | null,
|
||||
): void;
|
||||
(
|
||||
map: GenMapping,
|
||||
genLine: number,
|
||||
genColumn: number,
|
||||
source: string,
|
||||
sourceLine: number,
|
||||
sourceColumn: number,
|
||||
name: string,
|
||||
content?: string | null,
|
||||
): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* A high-level API to associate a generated position with an original source position. Line is
|
||||
* 1-based, but column is 0-based, due to legacy behavior in `source-map` library.
|
||||
*/
|
||||
export let addMapping: {
|
||||
(
|
||||
map: GenMapping,
|
||||
mapping: {
|
||||
generated: Pos;
|
||||
source?: null;
|
||||
original?: null;
|
||||
name?: null;
|
||||
content?: null;
|
||||
},
|
||||
): void;
|
||||
(
|
||||
map: GenMapping,
|
||||
mapping: {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name?: null;
|
||||
content?: string | null;
|
||||
},
|
||||
): void;
|
||||
(
|
||||
map: GenMapping,
|
||||
mapping: {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name: string;
|
||||
content?: string | null;
|
||||
},
|
||||
): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
||||
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
||||
* not add a segment with a lower generated line/column than one that came before.
|
||||
*/
|
||||
export let maybeAddSegment: typeof addSegment;
|
||||
|
||||
/**
|
||||
* Same as `addMapping`, but will only add the mapping if it generates useful information in the
|
||||
* resulting map. This only works correctly if mappings are added **in order**, meaning you should
|
||||
* not add a mapping with a lower generated line/column than one that came before.
|
||||
*/
|
||||
export let maybeAddMapping: typeof addMapping;
|
||||
|
||||
/**
|
||||
* Adds/removes the content of the source file to the source map.
|
||||
*/
|
||||
export let setSourceContent: (map: GenMapping, source: string, content: string | null) => void;
|
||||
|
||||
/**
|
||||
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
export let toDecodedMap: (map: GenMapping) => DecodedSourceMap;
|
||||
|
||||
/**
|
||||
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
export let toEncodedMap: (map: GenMapping) => EncodedSourceMap;
|
||||
|
||||
/**
|
||||
* Constructs a new GenMapping, using the already present mappings of the input.
|
||||
*/
|
||||
export let fromMap: (input: SourceMapInput) => GenMapping;
|
||||
|
||||
/**
|
||||
* Returns an array of high-level mapping objects for every recorded segment, which could then be
|
||||
* passed to the `source-map` library.
|
||||
*/
|
||||
export let allMappings: (map: GenMapping) => Mapping[];
|
||||
|
||||
// This split declaration is only so that terser can elminiate the static initialization block.
|
||||
let addSegmentInternal: <S extends string | null | undefined>(
|
||||
skipable: boolean,
|
||||
map: GenMapping,
|
||||
genLine: number,
|
||||
genColumn: number,
|
||||
source: S,
|
||||
sourceLine: S extends string ? number : null | undefined,
|
||||
sourceColumn: S extends string ? number : null | undefined,
|
||||
name: S extends string ? string | null | undefined : null | undefined,
|
||||
content: S extends string ? string | null | undefined : null | undefined,
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Provides the state to generate a sourcemap.
|
||||
*/
|
||||
export class GenMapping {
|
||||
private _names = new SetArray();
|
||||
private _sources = new SetArray();
|
||||
private _sourcesContent: (string | null)[] = [];
|
||||
private _mappings: SourceMapSegment[][] = [];
|
||||
declare file: string | null | undefined;
|
||||
declare sourceRoot: string | null | undefined;
|
||||
|
||||
constructor({ file, sourceRoot }: Options = {}) {
|
||||
this.file = file;
|
||||
this.sourceRoot = sourceRoot;
|
||||
}
|
||||
|
||||
static {
|
||||
addSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||
return addSegmentInternal(
|
||||
false,
|
||||
map,
|
||||
genLine,
|
||||
genColumn,
|
||||
source,
|
||||
sourceLine,
|
||||
sourceColumn,
|
||||
name,
|
||||
content,
|
||||
);
|
||||
};
|
||||
|
||||
maybeAddSegment = (
|
||||
map,
|
||||
genLine,
|
||||
genColumn,
|
||||
source,
|
||||
sourceLine,
|
||||
sourceColumn,
|
||||
name,
|
||||
content,
|
||||
) => {
|
||||
return addSegmentInternal(
|
||||
true,
|
||||
map,
|
||||
genLine,
|
||||
genColumn,
|
||||
source,
|
||||
sourceLine,
|
||||
sourceColumn,
|
||||
name,
|
||||
content,
|
||||
);
|
||||
};
|
||||
|
||||
addMapping = (map, mapping) => {
|
||||
return addMappingInternal(false, map, mapping as Parameters<typeof addMappingInternal>[2]);
|
||||
};
|
||||
|
||||
maybeAddMapping = (map, mapping) => {
|
||||
return addMappingInternal(true, map, mapping as Parameters<typeof addMappingInternal>[2]);
|
||||
};
|
||||
|
||||
setSourceContent = (map, source, content) => {
|
||||
const { _sources: sources, _sourcesContent: sourcesContent } = map;
|
||||
sourcesContent[put(sources, source)] = content;
|
||||
};
|
||||
|
||||
toDecodedMap = (map) => {
|
||||
const {
|
||||
file,
|
||||
sourceRoot,
|
||||
_mappings: mappings,
|
||||
_sources: sources,
|
||||
_sourcesContent: sourcesContent,
|
||||
_names: names,
|
||||
} = map;
|
||||
removeEmptyFinalLines(mappings);
|
||||
|
||||
return {
|
||||
version: 3,
|
||||
file: file || undefined,
|
||||
names: names.array,
|
||||
sourceRoot: sourceRoot || undefined,
|
||||
sources: sources.array,
|
||||
sourcesContent,
|
||||
mappings,
|
||||
};
|
||||
};
|
||||
|
||||
toEncodedMap = (map) => {
|
||||
const decoded = toDecodedMap(map);
|
||||
return {
|
||||
...decoded,
|
||||
mappings: encode(decoded.mappings as SourceMapSegment[][]),
|
||||
};
|
||||
};
|
||||
|
||||
allMappings = (map) => {
|
||||
const out: Mapping[] = [];
|
||||
const { _mappings: mappings, _sources: sources, _names: names } = map;
|
||||
|
||||
for (let i = 0; i < mappings.length; i++) {
|
||||
const line = mappings[i];
|
||||
for (let j = 0; j < line.length; j++) {
|
||||
const seg = line[j];
|
||||
|
||||
const generated = { line: i + 1, column: seg[COLUMN] };
|
||||
let source: string | undefined = undefined;
|
||||
let original: Pos | undefined = undefined;
|
||||
let name: string | undefined = undefined;
|
||||
|
||||
if (seg.length !== 1) {
|
||||
source = sources.array[seg[SOURCES_INDEX]];
|
||||
original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };
|
||||
|
||||
if (seg.length === 5) name = names.array[seg[NAMES_INDEX]];
|
||||
}
|
||||
|
||||
out.push({ generated, source, original, name } as Mapping);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
fromMap = (input) => {
|
||||
const map = new TraceMap(input);
|
||||
const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });
|
||||
|
||||
putAll(gen._names, map.names);
|
||||
putAll(gen._sources, map.sources as string[]);
|
||||
gen._sourcesContent = map.sourcesContent || map.sources.map(() => null);
|
||||
gen._mappings = decodedMappings(map) as GenMapping['_mappings'];
|
||||
|
||||
return gen;
|
||||
};
|
||||
|
||||
// Internal helpers
|
||||
addSegmentInternal = (
|
||||
skipable,
|
||||
map,
|
||||
genLine,
|
||||
genColumn,
|
||||
source,
|
||||
sourceLine,
|
||||
sourceColumn,
|
||||
name,
|
||||
content,
|
||||
) => {
|
||||
const {
|
||||
_mappings: mappings,
|
||||
_sources: sources,
|
||||
_sourcesContent: sourcesContent,
|
||||
_names: names,
|
||||
} = map;
|
||||
const line = getLine(mappings, genLine);
|
||||
const index = getColumnIndex(line, genColumn);
|
||||
|
||||
if (!source) {
|
||||
if (skipable && skipSourceless(line, index)) return;
|
||||
return insert(line, index, [genColumn]);
|
||||
}
|
||||
|
||||
// Sigh, TypeScript can't figure out sourceLine and sourceColumn aren't nullish if source
|
||||
// isn't nullish.
|
||||
assert<number>(sourceLine);
|
||||
assert<number>(sourceColumn);
|
||||
|
||||
const sourcesIndex = put(sources, source);
|
||||
const namesIndex = name ? put(names, name) : NO_NAME;
|
||||
if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content ?? null;
|
||||
|
||||
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return insert(
|
||||
line,
|
||||
index,
|
||||
name
|
||||
? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
|
||||
: [genColumn, sourcesIndex, sourceLine, sourceColumn],
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function assert<T>(_val: unknown): asserts _val is T {
|
||||
// noop.
|
||||
}
|
||||
|
||||
function getLine(mappings: SourceMapSegment[][], index: number): SourceMapSegment[] {
|
||||
for (let i = mappings.length; i <= index; i++) {
|
||||
mappings[i] = [];
|
||||
}
|
||||
return mappings[index];
|
||||
}
|
||||
|
||||
function getColumnIndex(line: SourceMapSegment[], genColumn: number): number {
|
||||
let index = line.length;
|
||||
for (let i = index - 1; i >= 0; index = i--) {
|
||||
const current = line[i];
|
||||
if (genColumn >= current[COLUMN]) break;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
function insert<T>(array: T[], index: number, value: T) {
|
||||
for (let i = array.length; i > index; i--) {
|
||||
array[i] = array[i - 1];
|
||||
}
|
||||
array[index] = value;
|
||||
}
|
||||
|
||||
function removeEmptyFinalLines(mappings: SourceMapSegment[][]) {
|
||||
const { length } = mappings;
|
||||
let len = length;
|
||||
for (let i = len - 1; i >= 0; len = i, i--) {
|
||||
if (mappings[i].length > 0) break;
|
||||
}
|
||||
if (len < length) mappings.length = len;
|
||||
}
|
||||
|
||||
function putAll(strarr: SetArray, array: string[]) {
|
||||
for (let i = 0; i < array.length; i++) put(strarr, array[i]);
|
||||
}
|
||||
|
||||
function skipSourceless(line: SourceMapSegment[], index: number): boolean {
|
||||
// The start of a line is already sourceless, so adding a sourceless segment to the beginning
|
||||
// doesn't generate any useful information.
|
||||
if (index === 0) return true;
|
||||
|
||||
const prev = line[index - 1];
|
||||
// If the previous segment is also sourceless, then adding another sourceless segment doesn't
|
||||
// genrate any new information. Else, this segment will end the source/named segment and point to
|
||||
// a sourceless position, which is useful.
|
||||
return prev.length === 1;
|
||||
}
|
||||
|
||||
function skipSource(
|
||||
line: SourceMapSegment[],
|
||||
index: number,
|
||||
sourcesIndex: number,
|
||||
sourceLine: number,
|
||||
sourceColumn: number,
|
||||
namesIndex: number,
|
||||
): boolean {
|
||||
// A source/named segment at the start of a line gives position at that genColumn
|
||||
if (index === 0) return false;
|
||||
|
||||
const prev = line[index - 1];
|
||||
|
||||
// If the previous segment is sourceless, then we're transitioning to a source.
|
||||
if (prev.length === 1) return false;
|
||||
|
||||
// If the previous segment maps to the exact same source position, then this segment doesn't
|
||||
// provide any new position information.
|
||||
return (
|
||||
sourcesIndex === prev[SOURCES_INDEX] &&
|
||||
sourceLine === prev[SOURCE_LINE] &&
|
||||
sourceColumn === prev[SOURCE_COLUMN] &&
|
||||
namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME)
|
||||
);
|
||||
}
|
||||
|
||||
function addMappingInternal<S extends string | null | undefined>(
|
||||
skipable: boolean,
|
||||
map: GenMapping,
|
||||
mapping: {
|
||||
generated: Pos;
|
||||
source: S;
|
||||
original: S extends string ? Pos : null | undefined;
|
||||
name: S extends string ? string | null | undefined : null | undefined;
|
||||
content: S extends string ? string | null | undefined : null | undefined;
|
||||
},
|
||||
) {
|
||||
const { generated, source, original, name, content } = mapping;
|
||||
if (!source) {
|
||||
return addSegmentInternal(
|
||||
skipable,
|
||||
map,
|
||||
generated.line - 1,
|
||||
generated.column,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
}
|
||||
const s: string = source;
|
||||
assert<Pos>(original);
|
||||
return addSegmentInternal(
|
||||
skipable,
|
||||
map,
|
||||
generated.line - 1,
|
||||
generated.column,
|
||||
s,
|
||||
original.line - 1,
|
||||
original.column,
|
||||
name,
|
||||
content,
|
||||
);
|
||||
}
|
16
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/src/sourcemap-segment.ts
generated
vendored
Normal file
16
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/src/sourcemap-segment.ts
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
type GeneratedColumn = number;
|
||||
type SourcesIndex = number;
|
||||
type SourceLine = number;
|
||||
type SourceColumn = number;
|
||||
type NamesIndex = number;
|
||||
|
||||
export type SourceMapSegment =
|
||||
| [GeneratedColumn]
|
||||
| [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn]
|
||||
| [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
|
||||
|
||||
export const COLUMN = 0;
|
||||
export const SOURCES_INDEX = 1;
|
||||
export const SOURCE_LINE = 2;
|
||||
export const SOURCE_COLUMN = 3;
|
||||
export const NAMES_INDEX = 4;
|
43
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/src/types.ts
generated
vendored
Normal file
43
node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping/src/types.ts
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
import type { SourceMapSegment } from './sourcemap-segment';
|
||||
|
||||
export interface SourceMapV3 {
|
||||
file?: string | null;
|
||||
names: readonly string[];
|
||||
sourceRoot?: string;
|
||||
sources: readonly (string | null)[];
|
||||
sourcesContent?: readonly (string | null)[];
|
||||
version: 3;
|
||||
}
|
||||
|
||||
export interface EncodedSourceMap extends SourceMapV3 {
|
||||
mappings: string;
|
||||
}
|
||||
|
||||
export interface DecodedSourceMap extends SourceMapV3 {
|
||||
mappings: readonly SourceMapSegment[][];
|
||||
}
|
||||
|
||||
export interface Pos {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export type Mapping =
|
||||
| {
|
||||
generated: Pos;
|
||||
source: undefined;
|
||||
original: undefined;
|
||||
name: undefined;
|
||||
}
|
||||
| {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name: string;
|
||||
}
|
||||
| {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name: undefined;
|
||||
};
|
37
node_modules/@babel/generator/package.json
generated
vendored
Normal file
37
node_modules/@babel/generator/package.json
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.18.7",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-generator"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-generator",
|
||||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20generator%22+is%3Aopen",
|
||||
"main": "./lib/index.js",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.18.7",
|
||||
"@jridgewell/gen-mapping": "^0.3.2",
|
||||
"jsesc": "^2.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.18.6",
|
||||
"@babel/parser": "^7.18.6",
|
||||
"@jridgewell/trace-mapping": "^0.3.8",
|
||||
"@types/jsesc": "^2.5.0",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"type": "commonjs"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue