first commit
This commit is contained in:
+22
@@ -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
@@ -0,0 +1,19 @@
|
||||
# @babel/generator
|
||||
|
||||
> Turns an AST into code.
|
||||
|
||||
See our website [@babel/generator](https://babeljs.io/docs/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
|
||||
```
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
const spaceIndents = [];
|
||||
for (let i = 0; i < 32; i++) {
|
||||
spaceIndents.push(" ".repeat(i * 2));
|
||||
}
|
||||
class Buffer {
|
||||
constructor(map, indentChar) {
|
||||
this._map = null;
|
||||
this._buf = "";
|
||||
this._str = "";
|
||||
this._appendCount = 0;
|
||||
this._last = 0;
|
||||
this._canMarkIdName = true;
|
||||
this._indentChar = "";
|
||||
this._queuedChar = 0;
|
||||
this._position = {
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
this._sourcePosition = {
|
||||
identifierName: undefined,
|
||||
identifierNamePos: undefined,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
filename: undefined
|
||||
};
|
||||
this._map = map;
|
||||
this._indentChar = indentChar;
|
||||
}
|
||||
get() {
|
||||
const {
|
||||
_map,
|
||||
_last
|
||||
} = this;
|
||||
if (this._queuedChar !== 32) {
|
||||
this._flush();
|
||||
}
|
||||
const code = _last === 10 ? (this._buf + this._str).trimRight() : this._buf + this._str;
|
||||
if (_map === null) {
|
||||
return {
|
||||
code: code,
|
||||
decodedMap: undefined,
|
||||
map: null,
|
||||
rawMappings: undefined
|
||||
};
|
||||
}
|
||||
const result = {
|
||||
code: code,
|
||||
decodedMap: _map.getDecoded(),
|
||||
get __mergedMap() {
|
||||
return this.map;
|
||||
},
|
||||
get map() {
|
||||
const resultMap = _map.get();
|
||||
result.map = resultMap;
|
||||
return resultMap;
|
||||
},
|
||||
set map(value) {
|
||||
Object.defineProperty(result, "map", {
|
||||
value,
|
||||
writable: true
|
||||
});
|
||||
},
|
||||
get rawMappings() {
|
||||
const mappings = _map.getRawMappings();
|
||||
result.rawMappings = mappings;
|
||||
return mappings;
|
||||
},
|
||||
set rawMappings(value) {
|
||||
Object.defineProperty(result, "rawMappings", {
|
||||
value,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
append(str, maybeNewline) {
|
||||
this._flush();
|
||||
this._append(str, maybeNewline);
|
||||
}
|
||||
appendChar(char) {
|
||||
this._flush();
|
||||
this._appendChar(char, 1, true);
|
||||
}
|
||||
queue(char) {
|
||||
this._flush();
|
||||
this._queuedChar = char;
|
||||
}
|
||||
_flush() {
|
||||
const queuedChar = this._queuedChar;
|
||||
if (queuedChar !== 0) {
|
||||
this._appendChar(queuedChar, 1, true);
|
||||
this._queuedChar = 0;
|
||||
}
|
||||
}
|
||||
_appendChar(char, repeat, useSourcePos) {
|
||||
this._last = char;
|
||||
if (char === -1) {
|
||||
const indent = repeat >= 64 ? this._indentChar.repeat(repeat) : spaceIndents[repeat / 2];
|
||||
this._str += indent;
|
||||
} else {
|
||||
this._str += repeat > 1 ? String.fromCharCode(char).repeat(repeat) : String.fromCharCode(char);
|
||||
}
|
||||
const isSpace = char === 32;
|
||||
const position = this._position;
|
||||
if (char !== 10) {
|
||||
if (this._map) {
|
||||
const sourcePos = this._sourcePosition;
|
||||
if (useSourcePos && sourcePos) {
|
||||
this._map.mark(position, sourcePos.line, sourcePos.column, isSpace ? undefined : sourcePos.identifierName, isSpace ? undefined : sourcePos.identifierNamePos, sourcePos.filename);
|
||||
if (!isSpace && this._canMarkIdName) {
|
||||
sourcePos.identifierName = undefined;
|
||||
sourcePos.identifierNamePos = undefined;
|
||||
}
|
||||
} else {
|
||||
this._map.mark(position);
|
||||
}
|
||||
}
|
||||
position.column += repeat;
|
||||
} else {
|
||||
position.line++;
|
||||
position.column = 0;
|
||||
}
|
||||
}
|
||||
_append(str, maybeNewline) {
|
||||
const len = str.length;
|
||||
const position = this._position;
|
||||
const sourcePos = this._sourcePosition;
|
||||
this._last = -1;
|
||||
if (++this._appendCount > 4096) {
|
||||
+this._str;
|
||||
this._buf += this._str;
|
||||
this._str = str;
|
||||
this._appendCount = 0;
|
||||
} else {
|
||||
this._str += str;
|
||||
}
|
||||
const hasMap = this._map !== null;
|
||||
if (!maybeNewline && !hasMap) {
|
||||
position.column += len;
|
||||
return;
|
||||
}
|
||||
const {
|
||||
column,
|
||||
identifierName,
|
||||
identifierNamePos,
|
||||
filename
|
||||
} = sourcePos;
|
||||
let line = sourcePos.line;
|
||||
if ((identifierName != null || identifierNamePos != null) && this._canMarkIdName) {
|
||||
sourcePos.identifierName = undefined;
|
||||
sourcePos.identifierNamePos = undefined;
|
||||
}
|
||||
let i = str.indexOf("\n");
|
||||
let last = 0;
|
||||
if (hasMap && i !== 0) {
|
||||
this._map.mark(position, line, column, identifierName, identifierNamePos, filename);
|
||||
}
|
||||
while (i !== -1) {
|
||||
position.line++;
|
||||
position.column = 0;
|
||||
last = i + 1;
|
||||
if (last < len && line !== undefined) {
|
||||
line++;
|
||||
if (hasMap) {
|
||||
this._map.mark(position, line, 0, undefined, undefined, filename);
|
||||
}
|
||||
}
|
||||
i = str.indexOf("\n", last);
|
||||
}
|
||||
position.column += len - last;
|
||||
}
|
||||
removeLastSemicolon() {
|
||||
if (this._queuedChar === 59) {
|
||||
this._queuedChar = 0;
|
||||
}
|
||||
}
|
||||
getLastChar(checkQueue) {
|
||||
if (!checkQueue) {
|
||||
return this._last;
|
||||
}
|
||||
const queuedChar = this._queuedChar;
|
||||
return queuedChar !== 0 ? queuedChar : this._last;
|
||||
}
|
||||
getNewlineCount() {
|
||||
return this._queuedChar === 0 && this._last === 10 ? 1 : 0;
|
||||
}
|
||||
hasContent() {
|
||||
return this._last !== 0;
|
||||
}
|
||||
exactSource(loc, cb) {
|
||||
if (!this._map) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
this.source("start", loc);
|
||||
const identifierName = loc.identifierName;
|
||||
const sourcePos = this._sourcePosition;
|
||||
if (identifierName != null) {
|
||||
this._canMarkIdName = false;
|
||||
sourcePos.identifierName = identifierName;
|
||||
}
|
||||
cb();
|
||||
if (identifierName != null) {
|
||||
this._canMarkIdName = true;
|
||||
sourcePos.identifierName = undefined;
|
||||
sourcePos.identifierNamePos = undefined;
|
||||
}
|
||||
this.source("end", loc);
|
||||
}
|
||||
source(prop, loc) {
|
||||
if (!this._map) return;
|
||||
this._normalizePosition(prop, loc, 0);
|
||||
}
|
||||
sourceWithOffset(prop, loc, columnOffset) {
|
||||
if (!this._map) return;
|
||||
this._normalizePosition(prop, loc, columnOffset);
|
||||
}
|
||||
_normalizePosition(prop, loc, columnOffset) {
|
||||
this._flush();
|
||||
const pos = loc[prop];
|
||||
const target = this._sourcePosition;
|
||||
if (pos) {
|
||||
target.line = pos.line;
|
||||
target.column = Math.max(pos.column + columnOffset, 0);
|
||||
target.filename = loc.filename;
|
||||
}
|
||||
}
|
||||
getCurrentColumn() {
|
||||
return this._position.column + (this._queuedChar ? 1 : 0);
|
||||
}
|
||||
getCurrentLine() {
|
||||
return this._position.line;
|
||||
}
|
||||
}
|
||||
exports.default = Buffer;
|
||||
|
||||
//# sourceMappingURL=buffer.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+86
@@ -0,0 +1,86 @@
|
||||
"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);
|
||||
}
|
||||
this.print(node.program);
|
||||
}
|
||||
function Program(node) {
|
||||
var _node$directives;
|
||||
this.printInnerComments(false);
|
||||
const directivesLen = (_node$directives = node.directives) == null ? void 0 : _node$directives.length;
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai;
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, undefined, undefined, newline);
|
||||
if (!((_node$directives$trai = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai.length)) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
this.printSequence(node.body);
|
||||
}
|
||||
function BlockStatement(node) {
|
||||
var _node$directives2;
|
||||
this.tokenChar(123);
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
const directivesLen = (_node$directives2 = node.directives) == null ? void 0 : _node$directives2.length;
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai2;
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, true, true, newline);
|
||||
if (!((_node$directives$trai2 = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai2.length)) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
this.printSequence(node.body, true, true);
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function Directive(node) {
|
||||
this.print(node.value);
|
||||
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}`);
|
||||
this._newline();
|
||||
}
|
||||
function Placeholder(node) {
|
||||
this.token("%%");
|
||||
this.print(node.name);
|
||||
this.token("%%");
|
||||
if (node.expectedNode === "Statement") {
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=base.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+215
@@ -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");
|
||||
var _expressions = require("./expressions.js");
|
||||
var _typescript = require("./typescript.js");
|
||||
var _flow = require("./flow.js");
|
||||
var _methods = require("./methods.js");
|
||||
const {
|
||||
isExportDefaultDeclaration,
|
||||
isExportNamedDeclaration
|
||||
} = _t;
|
||||
function ClassDeclaration(node, parent) {
|
||||
const inExport = isExportDefaultDeclaration(parent) || isExportNamedDeclaration(parent);
|
||||
if (!inExport || !_expressions._shouldPrintDecoratorsBeforeExport.call(this, parent)) {
|
||||
this.printJoin(node.decorators);
|
||||
}
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
this.word("class");
|
||||
if (node.id) {
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
}
|
||||
this.print(node.typeParameters);
|
||||
if (node.superClass) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.superClass);
|
||||
this.print(node.superTypeParameters);
|
||||
}
|
||||
if (node.implements) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ClassBody(node) {
|
||||
this.tokenChar(123);
|
||||
if (node.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
const separator = classBodyEmptySemicolonsPrinter(this, node);
|
||||
separator == null || separator(-1);
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
this.printJoin(node.body, true, true, separator, true, true);
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
if (!this.endsWith(10)) this.newline();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
}
|
||||
function classBodyEmptySemicolonsPrinter(printer, node) {
|
||||
if (!printer.tokenMap || node.start == null || node.end == null) {
|
||||
return null;
|
||||
}
|
||||
const indexes = printer.tokenMap.getIndexes(node);
|
||||
if (!indexes) return null;
|
||||
let k = 1;
|
||||
let occurrenceCount = 0;
|
||||
let nextLocIndex = 0;
|
||||
const advanceNextLocIndex = () => {
|
||||
while (nextLocIndex < node.body.length && node.body[nextLocIndex].start == null) {
|
||||
nextLocIndex++;
|
||||
}
|
||||
};
|
||||
advanceNextLocIndex();
|
||||
return i => {
|
||||
if (nextLocIndex <= i) {
|
||||
nextLocIndex = i + 1;
|
||||
advanceNextLocIndex();
|
||||
}
|
||||
const end = nextLocIndex === node.body.length ? node.end : node.body[nextLocIndex].start;
|
||||
let tok;
|
||||
while (k < indexes.length && printer.tokenMap.matchesOriginal(tok = printer._tokens[indexes[k]], ";") && tok.start < end) {
|
||||
printer.tokenChar(59, occurrenceCount++);
|
||||
k++;
|
||||
}
|
||||
};
|
||||
}
|
||||
function ClassProperty(node) {
|
||||
this.printJoin(node.decorators);
|
||||
if (!node.static && !this.format.preserveFormat) {
|
||||
var _node$key$loc;
|
||||
const endLine = (_node$key$loc = node.key.loc) == null || (_node$key$loc = _node$key$loc.end) == null ? void 0 : _node$key$loc.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
}
|
||||
_typescript._tsPrintClassMemberModifiers.call(this, node);
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
_flow._variance.call(this, node);
|
||||
this.print(node.key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassAccessorProperty(node) {
|
||||
var _node$key$loc2;
|
||||
this.printJoin(node.decorators);
|
||||
const endLine = (_node$key$loc2 = node.key.loc) == null || (_node$key$loc2 = _node$key$loc2.end) == null ? void 0 : _node$key$loc2.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
_typescript._tsPrintClassMemberModifiers.call(this, node);
|
||||
this.word("accessor", true);
|
||||
this.space();
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
_flow._variance.call(this, node);
|
||||
this.print(node.key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassPrivateProperty(node) {
|
||||
this.printJoin(node.decorators);
|
||||
_typescript._tsPrintClassMemberModifiers.call(this, node);
|
||||
this.print(node.key);
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassMethod(node) {
|
||||
_classMethodHead.call(this, node);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ClassPrivateMethod(node) {
|
||||
_classMethodHead.call(this, node);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function _classMethodHead(node) {
|
||||
this.printJoin(node.decorators);
|
||||
if (!this.format.preserveFormat) {
|
||||
var _node$key$loc3;
|
||||
const endLine = (_node$key$loc3 = node.key.loc) == null || (_node$key$loc3 = _node$key$loc3.end) == null ? void 0 : _node$key$loc3.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
}
|
||||
_typescript._tsPrintClassMemberModifiers.call(this, node);
|
||||
_methods._methodHead.call(this, node);
|
||||
}
|
||||
function StaticBlock(node) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
if (node.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
this.printSequence(node.body, true);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=classes.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+73
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.DecimalLiteral = DecimalLiteral;
|
||||
exports.Noop = Noop;
|
||||
exports.RecordExpression = RecordExpression;
|
||||
exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments;
|
||||
exports.TupleExpression = TupleExpression;
|
||||
function Noop() {}
|
||||
function TSExpressionWithTypeArguments(node) {
|
||||
this.print(node.expression);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
function DecimalLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.word(raw);
|
||||
return;
|
||||
}
|
||||
this.word(node.value + "m");
|
||||
}
|
||||
function RecordExpression(node) {
|
||||
const props = node.properties;
|
||||
let startToken;
|
||||
let endToken;
|
||||
if (this.format.recordAndTupleSyntaxType === "bar") {
|
||||
startToken = "{|";
|
||||
endToken = "|}";
|
||||
} else if (this.format.recordAndTupleSyntaxType !== "hash" && this.format.recordAndTupleSyntaxType != null) {
|
||||
throw new Error(`The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify(this.format.recordAndTupleSyntaxType)} received).`);
|
||||
} else {
|
||||
startToken = "#{";
|
||||
endToken = "}";
|
||||
}
|
||||
this.token(startToken);
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, this.shouldPrintTrailingComma(endToken), true, 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);
|
||||
for (let i = 0; i < elems.length; i++) {
|
||||
const elem = elems[i];
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem);
|
||||
if (i < len - 1 || this.shouldPrintTrailingComma(endToken)) {
|
||||
this.token(",", false, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.token(endToken);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=deprecated.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+309
@@ -0,0 +1,309 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.LogicalExpression = exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.AssignmentPattern = AssignmentPattern;
|
||||
exports.AwaitExpression = AwaitExpression;
|
||||
exports.BinaryExpression = BinaryExpression;
|
||||
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;
|
||||
exports._shouldPrintDecoratorsBeforeExport = _shouldPrintDecoratorsBeforeExport;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isCallExpression,
|
||||
isLiteral,
|
||||
isMemberExpression,
|
||||
isNewExpression,
|
||||
isPattern
|
||||
} = _t;
|
||||
function UnaryExpression(node) {
|
||||
const {
|
||||
operator
|
||||
} = node;
|
||||
const firstChar = operator.charCodeAt(0);
|
||||
if (firstChar >= 97 && firstChar <= 122) {
|
||||
this.word(operator);
|
||||
this.space();
|
||||
} else {
|
||||
this.tokenChar(firstChar);
|
||||
}
|
||||
this.print(node.argument);
|
||||
}
|
||||
function DoExpression(node) {
|
||||
if (node.async) {
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ParenthesizedExpression(node) {
|
||||
this.tokenChar(40);
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
this.print(node.expression, undefined, true);
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
this.rightParens(node);
|
||||
}
|
||||
function UpdateExpression(node) {
|
||||
if (node.prefix) {
|
||||
this.token(node.operator, false, 0, true);
|
||||
this.print(node.argument);
|
||||
} else {
|
||||
this.print(node.argument, true);
|
||||
this.token(node.operator, false, 0, true);
|
||||
}
|
||||
}
|
||||
function ConditionalExpression(node) {
|
||||
this.print(node.test);
|
||||
this.space();
|
||||
this.tokenChar(63);
|
||||
this.space();
|
||||
this.print(node.consequent);
|
||||
this.space();
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.alternate);
|
||||
}
|
||||
function NewExpression(node, parent) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.print(node.callee);
|
||||
if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, {
|
||||
callee: node
|
||||
}) && !isMemberExpression(parent) && !isNewExpression(parent)) {
|
||||
return;
|
||||
}
|
||||
this.print(node.typeArguments);
|
||||
this.print(node.typeParameters);
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
if (node.arguments.length === 0 && this.tokenMap && !this.tokenMap.endMatches(node, ")")) {
|
||||
return;
|
||||
}
|
||||
this.tokenChar(40);
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
this.printList(node.arguments, this.shouldPrintTrailingComma(")"), undefined, undefined, undefined, true);
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
this.rightParens(node);
|
||||
}
|
||||
function SequenceExpression(node) {
|
||||
this.printList(node.expressions);
|
||||
}
|
||||
function ThisExpression() {
|
||||
this.word("this");
|
||||
}
|
||||
function Super() {
|
||||
this.word("super");
|
||||
}
|
||||
function _shouldPrintDecoratorsBeforeExport(node) {
|
||||
if (typeof this.format.decoratorsBeforeExport === "boolean") {
|
||||
return this.format.decoratorsBeforeExport;
|
||||
}
|
||||
return typeof node.start === "number" && node.start === node.declaration.start;
|
||||
}
|
||||
function Decorator(node) {
|
||||
this.tokenChar(64);
|
||||
const {
|
||||
expression
|
||||
} = node;
|
||||
this.print(expression);
|
||||
this.newline();
|
||||
}
|
||||
function OptionalMemberExpression(node) {
|
||||
let {
|
||||
computed
|
||||
} = node;
|
||||
const {
|
||||
optional,
|
||||
property
|
||||
} = node;
|
||||
this.print(node.object);
|
||||
if (!computed && isMemberExpression(property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
if (isLiteral(property) && typeof property.value === "number") {
|
||||
computed = true;
|
||||
}
|
||||
if (optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
if (computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(property);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (!optional) {
|
||||
this.tokenChar(46);
|
||||
}
|
||||
this.print(property);
|
||||
}
|
||||
}
|
||||
function OptionalCallExpression(node) {
|
||||
this.print(node.callee);
|
||||
this.print(node.typeParameters);
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
this.print(node.typeArguments);
|
||||
this.tokenChar(40);
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
this.printList(node.arguments, undefined, undefined, undefined, undefined, true);
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
this.rightParens(node);
|
||||
}
|
||||
function CallExpression(node) {
|
||||
this.print(node.callee);
|
||||
this.print(node.typeArguments);
|
||||
this.print(node.typeParameters);
|
||||
this.tokenChar(40);
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
this.printList(node.arguments, this.shouldPrintTrailingComma(")"), undefined, undefined, undefined, true);
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
this.rightParens(node);
|
||||
}
|
||||
function Import() {
|
||||
this.word("import");
|
||||
}
|
||||
function AwaitExpression(node) {
|
||||
this.word("await");
|
||||
this.space();
|
||||
this.print(node.argument);
|
||||
}
|
||||
function YieldExpression(node) {
|
||||
if (node.delegate) {
|
||||
this.word("yield", true);
|
||||
this.tokenChar(42);
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.print(node.argument);
|
||||
}
|
||||
} else if (node.argument) {
|
||||
this.word("yield", true);
|
||||
this.space();
|
||||
this.print(node.argument);
|
||||
} else {
|
||||
this.word("yield");
|
||||
}
|
||||
}
|
||||
function EmptyStatement() {
|
||||
this.semicolon(true);
|
||||
}
|
||||
function ExpressionStatement(node) {
|
||||
this.tokenContext |= _index.TokenContext.expressionStatement;
|
||||
this.print(node.expression);
|
||||
this.semicolon();
|
||||
}
|
||||
function AssignmentPattern(node) {
|
||||
this.print(node.left);
|
||||
if (node.left.type === "Identifier" || isPattern(node.left)) {
|
||||
if (node.left.optional) this.tokenChar(63);
|
||||
this.print(node.left.typeAnnotation);
|
||||
}
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
}
|
||||
function AssignmentExpression(node) {
|
||||
this.print(node.left);
|
||||
this.space();
|
||||
this.token(node.operator, false, 0, true);
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
}
|
||||
function BinaryExpression(node) {
|
||||
this.print(node.left);
|
||||
this.space();
|
||||
const {
|
||||
operator
|
||||
} = node;
|
||||
if (operator.charCodeAt(0) === 105) {
|
||||
this.word(operator);
|
||||
} else {
|
||||
this.token(operator, false, 0, true);
|
||||
this.setLastChar(operator.charCodeAt(operator.length - 1));
|
||||
}
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
}
|
||||
function BindExpression(node) {
|
||||
this.print(node.object);
|
||||
this.token("::");
|
||||
this.print(node.callee);
|
||||
}
|
||||
function MemberExpression(node) {
|
||||
this.print(node.object);
|
||||
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) {
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
this.tokenChar(91);
|
||||
this.print(node.property, undefined, true);
|
||||
this.tokenChar(93);
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
} else {
|
||||
this.tokenChar(46);
|
||||
this.print(node.property);
|
||||
}
|
||||
}
|
||||
function MetaProperty(node) {
|
||||
this.print(node.meta);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property);
|
||||
}
|
||||
function PrivateName(node) {
|
||||
this.tokenChar(35);
|
||||
this.print(node.id);
|
||||
}
|
||||
function V8IntrinsicIdentifier(node) {
|
||||
this.tokenChar(37);
|
||||
this.word(node.name);
|
||||
}
|
||||
function ModuleExpression(node) {
|
||||
this.word("module", true);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.indent();
|
||||
const {
|
||||
body
|
||||
} = node;
|
||||
if (body.body.length || body.directives.length) {
|
||||
this.newline();
|
||||
}
|
||||
this.print(body);
|
||||
this.dedent();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=expressions.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+658
@@ -0,0 +1,658 @@
|
||||
"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.js");
|
||||
var _index = require("../node/index.js");
|
||||
var _types2 = require("./types.js");
|
||||
const {
|
||||
isDeclareExportDeclaration,
|
||||
isStatement
|
||||
} = _t;
|
||||
function AnyTypeAnnotation() {
|
||||
this.word("any");
|
||||
}
|
||||
function ArrayTypeAnnotation(node) {
|
||||
this.print(node.elementType, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
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();
|
||||
_interfaceish.call(this, node);
|
||||
}
|
||||
function DeclareFunction(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("function");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.print(node.id.typeAnnotation.typeAnnotation);
|
||||
if (node.predicate) {
|
||||
this.space();
|
||||
this.print(node.predicate);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function InferredPredicate() {
|
||||
this.tokenChar(37);
|
||||
this.word("checks");
|
||||
}
|
||||
function DeclaredPredicate(node) {
|
||||
this.tokenChar(37);
|
||||
this.word("checks");
|
||||
this.tokenChar(40);
|
||||
this.print(node.value);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function DeclareInterface(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
InterfaceDeclaration.call(this, node);
|
||||
}
|
||||
function DeclareModule(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("module");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function DeclareModuleExports(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("module");
|
||||
this.tokenChar(46);
|
||||
this.word("exports");
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function DeclareTypeAlias(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
TypeAlias.call(this, node);
|
||||
}
|
||||
function DeclareOpaqueType(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
OpaqueType.call(this, node);
|
||||
}
|
||||
function DeclareVariable(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("var");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.print(node.id.typeAnnotation);
|
||||
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);
|
||||
this.print(body);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
this.tokenChar(44);
|
||||
}
|
||||
function enumInitializedMember(context, node) {
|
||||
context.print(node.id);
|
||||
context.space();
|
||||
context.token("=");
|
||||
context.space();
|
||||
context.print(node.init);
|
||||
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);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
this.tokenChar(123);
|
||||
if (node.specifiers.length) {
|
||||
this.space();
|
||||
this.printList(node.specifiers);
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(125);
|
||||
if (node.source) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
function ExistsTypeAnnotation() {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent) {
|
||||
this.print(node.typeParameters);
|
||||
this.tokenChar(40);
|
||||
if (node.this) {
|
||||
this.word("this");
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.this.typeAnnotation);
|
||||
if (node.params.length || node.rest) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
this.printList(node.params);
|
||||
if (node.rest) {
|
||||
if (node.params.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
this.token("...");
|
||||
this.print(node.rest);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
const type = parent == null ? void 0 : parent.type;
|
||||
if (type != null && (type === "ObjectTypeCallProperty" || type === "ObjectTypeInternalSlot" || type === "DeclareFunction" || type === "ObjectTypeProperty" && parent.method)) {
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.space();
|
||||
this.token("=>");
|
||||
}
|
||||
this.space();
|
||||
this.print(node.returnType);
|
||||
}
|
||||
function FunctionTypeParam(node) {
|
||||
this.print(node.name);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (node.name) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function InterfaceExtends(node) {
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters, true);
|
||||
}
|
||||
function _interfaceish(node) {
|
||||
var _node$extends;
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
if ((_node$extends = node.extends) != null && _node$extends.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends);
|
||||
}
|
||||
if (node.type === "DeclareClass") {
|
||||
var _node$mixins, _node$implements;
|
||||
if ((_node$mixins = node.mixins) != null && _node$mixins.length) {
|
||||
this.space();
|
||||
this.word("mixins");
|
||||
this.space();
|
||||
this.printList(node.mixins);
|
||||
}
|
||||
if ((_node$implements = node.implements) != null && _node$implements.length) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements);
|
||||
}
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function _variance(node) {
|
||||
var _node$variance;
|
||||
const kind = (_node$variance = node.variance) == null ? void 0 : _node$variance.kind;
|
||||
if (kind != null) {
|
||||
if (kind === "plus") {
|
||||
this.tokenChar(43);
|
||||
} else if (kind === "minus") {
|
||||
this.tokenChar(45);
|
||||
}
|
||||
}
|
||||
}
|
||||
function InterfaceDeclaration(node) {
|
||||
this.word("interface");
|
||||
this.space();
|
||||
_interfaceish.call(this, node);
|
||||
}
|
||||
function andSeparator(occurrenceCount) {
|
||||
this.space();
|
||||
this.token("&", false, occurrenceCount);
|
||||
this.space();
|
||||
}
|
||||
function InterfaceTypeAnnotation(node) {
|
||||
var _node$extends2;
|
||||
this.word("interface");
|
||||
if ((_node$extends2 = node.extends) != null && _node$extends2.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function IntersectionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, undefined, undefined, andSeparator);
|
||||
}
|
||||
function MixedTypeAnnotation() {
|
||||
this.word("mixed");
|
||||
}
|
||||
function EmptyTypeAnnotation() {
|
||||
this.word("empty");
|
||||
}
|
||||
function NullableTypeAnnotation(node) {
|
||||
this.tokenChar(63);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function NumberTypeAnnotation() {
|
||||
this.word("number");
|
||||
}
|
||||
function StringTypeAnnotation() {
|
||||
this.word("string");
|
||||
}
|
||||
function ThisTypeAnnotation() {
|
||||
this.word("this");
|
||||
}
|
||||
function TupleTypeAnnotation(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.types);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TypeofTypeAnnotation(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.argument);
|
||||
}
|
||||
function TypeAlias(node) {
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
this.semicolon();
|
||||
}
|
||||
function TypeAnnotation(node, parent) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
if (parent.type === "ArrowFunctionExpression") {
|
||||
this.tokenContext |= _index.TokenContext.arrowFlowReturnType;
|
||||
} else if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TypeParameterInstantiation(node) {
|
||||
this.tokenChar(60);
|
||||
this.printList(node.params);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function TypeParameter(node) {
|
||||
_variance.call(this, node);
|
||||
this.word(node.name);
|
||||
if (node.bound) {
|
||||
this.print(node.bound);
|
||||
}
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.default);
|
||||
}
|
||||
}
|
||||
function OpaqueType(node) {
|
||||
this.word("opaque");
|
||||
this.space();
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
if (node.supertype) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.supertype);
|
||||
}
|
||||
if (node.impltype) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.impltype);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ObjectTypeAnnotation(node) {
|
||||
if (node.exact) {
|
||||
this.token("{|");
|
||||
} else {
|
||||
this.tokenChar(123);
|
||||
}
|
||||
const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
this.space();
|
||||
this.printJoin(props, true, true, () => {
|
||||
if (props.length !== 1 || node.inexact) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
}, true);
|
||||
this.space();
|
||||
}
|
||||
if (node.inexact) {
|
||||
this.indent();
|
||||
this.token("...");
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
}
|
||||
this.dedent();
|
||||
}
|
||||
if (node.exact) {
|
||||
this.token("|}");
|
||||
} else {
|
||||
this.tokenChar(125);
|
||||
}
|
||||
}
|
||||
function ObjectTypeInternalSlot(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(91);
|
||||
this.print(node.id);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(93);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (!node.method) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeCallProperty(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeIndexer(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
_variance.call(this, node);
|
||||
this.tokenChar(91);
|
||||
if (node.id) {
|
||||
this.print(node.id);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
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();
|
||||
}
|
||||
_variance.call(this, node);
|
||||
this.print(node.key);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (!node.method) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeSpreadProperty(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument);
|
||||
}
|
||||
function QualifiedTypeIdentifier(node) {
|
||||
this.print(node.qualification);
|
||||
this.tokenChar(46);
|
||||
this.print(node.id);
|
||||
}
|
||||
function SymbolTypeAnnotation() {
|
||||
this.word("symbol");
|
||||
}
|
||||
function orSeparator(occurrenceCount) {
|
||||
this.space();
|
||||
this.token("|", false, occurrenceCount);
|
||||
this.space();
|
||||
}
|
||||
function UnionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, undefined, undefined, orSeparator);
|
||||
}
|
||||
function TypeCastExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function Variance(node) {
|
||||
if (node.kind === "plus") {
|
||||
this.tokenChar(43);
|
||||
} else {
|
||||
this.tokenChar(45);
|
||||
}
|
||||
}
|
||||
function VoidTypeAnnotation() {
|
||||
this.word("void");
|
||||
}
|
||||
function IndexedAccessType(node) {
|
||||
this.print(node.objectType, true);
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function OptionalIndexedAccessType(node) {
|
||||
this.print(node.objectType);
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=flow.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+128
@@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _templateLiterals = require("./template-literals.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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.js");
|
||||
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];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_templateLiterals","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_expressions","_statements","_classes","_methods","_modules","_types","_flow","_base","_jsx","_typescript"],"sources":["../../src/generators/index.ts"],"sourcesContent":["export * from \"./template-literals.ts\";\nexport * from \"./expressions.ts\";\nexport * from \"./statements.ts\";\nexport * from \"./classes.ts\";\nexport * from \"./methods.ts\";\nexport * from \"./modules.ts\";\nexport * from \"./types.ts\";\nexport * from \"./flow.ts\";\nexport * from \"./base.ts\";\nexport * from \"./jsx.ts\";\nexport * from \"./typescript.ts\";\n"],"mappings":";;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,iBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,iBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,iBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,YAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,YAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,YAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,YAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,WAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,WAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,WAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,WAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,QAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,QAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,QAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,QAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,QAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,QAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,QAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,QAAA,CAAAR,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,QAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,QAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,QAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,QAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,MAAA,GAAAd,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAY,MAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAU,MAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAM,MAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,KAAA,GAAAf,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAa,KAAA,EAAAZ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAW,KAAA,CAAAX,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAO,KAAA,CAAAX,GAAA;IAAA;EAAA;AAAA;AACA,IAAAY,KAAA,GAAAhB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAc,KAAA,EAAAb,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAY,KAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAQ,KAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA;AACA,IAAAa,IAAA,GAAAjB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAe,IAAA,EAAAd,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAa,IAAA,CAAAb,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAS,IAAA,CAAAb,GAAA;IAAA;EAAA;AAAA;AACA,IAAAc,WAAA,GAAAlB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAgB,WAAA,EAAAf,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAc,WAAA,CAAAd,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAU,WAAA,CAAAd,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
"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);
|
||||
if (node.value) {
|
||||
this.tokenChar(61);
|
||||
this.print(node.value);
|
||||
}
|
||||
}
|
||||
function JSXIdentifier(node) {
|
||||
this.word(node.name);
|
||||
}
|
||||
function JSXNamespacedName(node) {
|
||||
this.print(node.namespace);
|
||||
this.tokenChar(58);
|
||||
this.print(node.name);
|
||||
}
|
||||
function JSXMemberExpression(node) {
|
||||
this.print(node.object);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property);
|
||||
}
|
||||
function JSXSpreadAttribute(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.argument);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXExpressionContainer(node) {
|
||||
this.tokenChar(123);
|
||||
this.print(node.expression);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXSpreadChild(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.expression);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXText(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
if (raw !== undefined) {
|
||||
this.token(raw, true);
|
||||
} else {
|
||||
this.token(node.value, true);
|
||||
}
|
||||
}
|
||||
function JSXElement(node) {
|
||||
const open = node.openingElement;
|
||||
this.print(open);
|
||||
if (open.selfClosing) return;
|
||||
this.indent();
|
||||
for (const child of node.children) {
|
||||
this.print(child);
|
||||
}
|
||||
this.dedent();
|
||||
this.print(node.closingElement);
|
||||
}
|
||||
function spaceSeparator() {
|
||||
this.space();
|
||||
}
|
||||
function JSXOpeningElement(node) {
|
||||
this.tokenChar(60);
|
||||
this.print(node.name);
|
||||
if (node.typeArguments) {
|
||||
this.print(node.typeArguments);
|
||||
}
|
||||
this.print(node.typeParameters);
|
||||
if (node.attributes.length > 0) {
|
||||
this.space();
|
||||
this.printJoin(node.attributes, undefined, undefined, spaceSeparator);
|
||||
}
|
||||
if (node.selfClosing) {
|
||||
this.space();
|
||||
this.tokenChar(47);
|
||||
}
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXClosingElement(node) {
|
||||
this.tokenChar(60);
|
||||
this.tokenChar(47);
|
||||
this.print(node.name);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXEmptyExpression() {
|
||||
this.printInnerComments();
|
||||
}
|
||||
function JSXFragment(node) {
|
||||
this.print(node.openingFragment);
|
||||
this.indent();
|
||||
for (const child of node.children) {
|
||||
this.print(child);
|
||||
}
|
||||
this.dedent();
|
||||
this.print(node.closingFragment);
|
||||
}
|
||||
function JSXOpeningFragment() {
|
||||
this.tokenChar(60);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXClosingFragment() {
|
||||
this.token("</");
|
||||
this.tokenChar(62);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=jsx.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+207
@@ -0,0 +1,207 @@
|
||||
"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;
|
||||
exports._shouldPrintArrowParamsParens = _shouldPrintArrowParamsParens;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isIdentifier
|
||||
} = _t;
|
||||
function _params(node, noLineTerminator, idNode, parentNode) {
|
||||
this.print(node.typeParameters);
|
||||
if (idNode !== undefined || parentNode !== undefined) {
|
||||
const nameInfo = _getFuncIdName.call(this, idNode, parentNode);
|
||||
if (nameInfo) {
|
||||
this.sourceIdentifierName(nameInfo.name, nameInfo.pos);
|
||||
}
|
||||
}
|
||||
this.tokenChar(40);
|
||||
_parameters.call(this, node.params, 41);
|
||||
this.print(node.returnType, noLineTerminator);
|
||||
this._noLineTerminator = noLineTerminator;
|
||||
}
|
||||
function _parameters(parameters, endToken) {
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
const trailingComma = this.shouldPrintTrailingComma(endToken);
|
||||
const paramLength = parameters.length;
|
||||
for (let i = 0; i < paramLength; i++) {
|
||||
_param.call(this, parameters[i]);
|
||||
if (trailingComma || i < paramLength - 1) {
|
||||
this.tokenChar(44, i);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
this.tokenChar(endToken);
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
}
|
||||
function _param(parameter) {
|
||||
this.printJoin(parameter.decorators, undefined, undefined, undefined, undefined, true);
|
||||
this.print(parameter, undefined, true);
|
||||
if (parameter.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this.print(parameter.typeAnnotation, undefined, true);
|
||||
}
|
||||
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.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
if (kind === "method" || kind === "init") {
|
||||
if (node.generator) {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
}
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this.print(key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (this._buf._map) {
|
||||
_params.call(this, node, false, node.computed && node.key.type !== "StringLiteral" ? undefined : node.key);
|
||||
} else {
|
||||
_params.call(this, node, false);
|
||||
}
|
||||
}
|
||||
function _predicate(node, noLineTerminatorAfter) {
|
||||
if (node.predicate) {
|
||||
if (!node.returnType) {
|
||||
this.tokenChar(58);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.predicate, noLineTerminatorAfter);
|
||||
}
|
||||
}
|
||||
function _functionHead(node, parent, hasPredicate) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
if (!this.format.preserveFormat) {
|
||||
this._innerCommentsState = 0;
|
||||
}
|
||||
this.space();
|
||||
}
|
||||
this.word("function");
|
||||
if (node.generator) {
|
||||
if (!this.format.preserveFormat) {
|
||||
this._innerCommentsState = 0;
|
||||
}
|
||||
this.tokenChar(42);
|
||||
}
|
||||
this.space();
|
||||
if (node.id) {
|
||||
this.print(node.id);
|
||||
}
|
||||
if (this._buf._map) {
|
||||
_params.call(this, node, false, node.id, parent);
|
||||
} else {
|
||||
_params.call(this, node, false);
|
||||
}
|
||||
if (hasPredicate) {
|
||||
_predicate.call(this, node);
|
||||
}
|
||||
}
|
||||
function FunctionExpression(node, parent) {
|
||||
_functionHead.call(this, node, parent, true);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ArrowFunctionExpression(node, parent) {
|
||||
if (node.async) {
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
if (_shouldPrintArrowParamsParens.call(this, node)) {
|
||||
_params.call(this, node, true, undefined, this._buf._map ? parent : undefined);
|
||||
} else {
|
||||
this.print(node.params[0], true);
|
||||
}
|
||||
_predicate.call(this, node, true);
|
||||
this.space();
|
||||
this.printInnerComments();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
this.tokenContext |= _index.TokenContext.arrowBody;
|
||||
this.print(node.body);
|
||||
}
|
||||
function _shouldPrintArrowParamsParens(node) {
|
||||
var _firstParam$leadingCo, _firstParam$trailingC;
|
||||
if (node.params.length !== 1) return true;
|
||||
if (node.typeParameters || node.returnType || node.predicate) {
|
||||
return true;
|
||||
}
|
||||
const firstParam = node.params[0];
|
||||
if (!isIdentifier(firstParam) || firstParam.typeAnnotation || firstParam.optional || (_firstParam$leadingCo = firstParam.leadingComments) != null && _firstParam$leadingCo.length || (_firstParam$trailingC = firstParam.trailingComments) != null && _firstParam$trailingC.length) {
|
||||
return true;
|
||||
}
|
||||
if (this.tokenMap) {
|
||||
if (node.loc == null) return true;
|
||||
if (this.tokenMap.findMatching(node, "(") !== null) return true;
|
||||
const arrowToken = this.tokenMap.findMatching(node, "=>");
|
||||
if ((arrowToken == null ? void 0 : arrowToken.loc) == null) return true;
|
||||
return arrowToken.loc.start.line !== node.loc.start.line;
|
||||
}
|
||||
if (this.format.retainLines) return true;
|
||||
return false;
|
||||
}
|
||||
function _getFuncIdName(idNode, parent) {
|
||||
let id = idNode;
|
||||
if (!id && parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "VariableDeclarator") {
|
||||
id = parent.id;
|
||||
} else if (parentType === "AssignmentExpression" || parentType === "AssignmentPattern") {
|
||||
id = parent.left;
|
||||
} else if (parentType === "ObjectProperty" || parentType === "ClassProperty") {
|
||||
if (!parent.computed || parent.key.type === "StringLiteral") {
|
||||
id = parent.key;
|
||||
}
|
||||
} else if (parentType === "ClassPrivateProperty" || parentType === "ClassAccessorProperty") {
|
||||
id = parent.key;
|
||||
}
|
||||
}
|
||||
if (!id) return;
|
||||
let nameInfo;
|
||||
if (id.type === "Identifier") {
|
||||
var _id$loc, _id$loc2;
|
||||
nameInfo = {
|
||||
pos: (_id$loc = id.loc) == null ? void 0 : _id$loc.start,
|
||||
name: ((_id$loc2 = id.loc) == null ? void 0 : _id$loc2.identifierName) || id.name
|
||||
};
|
||||
} else if (id.type === "PrivateName") {
|
||||
var _id$loc3;
|
||||
nameInfo = {
|
||||
pos: (_id$loc3 = id.loc) == null ? void 0 : _id$loc3.start,
|
||||
name: "#" + id.id.name
|
||||
};
|
||||
} else if (id.type === "StringLiteral") {
|
||||
var _id$loc4;
|
||||
nameInfo = {
|
||||
pos: (_id$loc4 = id.loc) == null ? void 0 : _id$loc4.start,
|
||||
name: id.value
|
||||
};
|
||||
}
|
||||
return nameInfo;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=methods.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+290
@@ -0,0 +1,290 @@
|
||||
"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.ImportExpression = ImportExpression;
|
||||
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
|
||||
exports.ImportSpecifier = ImportSpecifier;
|
||||
exports._printAttributes = _printAttributes;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
var _expressions = require("./expressions.js");
|
||||
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);
|
||||
if (node.local && node.local.name !== node.imported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local);
|
||||
}
|
||||
}
|
||||
function ImportDefaultSpecifier(node) {
|
||||
this.print(node.local);
|
||||
}
|
||||
function ExportDefaultSpecifier(node) {
|
||||
this.print(node.exported);
|
||||
}
|
||||
function ExportSpecifier(node) {
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.local);
|
||||
if (node.exported && node.local.name !== node.exported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported);
|
||||
}
|
||||
}
|
||||
function ExportNamespaceSpecifier(node) {
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported);
|
||||
}
|
||||
let warningShown = false;
|
||||
function _printAttributes(node, hasPreviousBrace) {
|
||||
var _node$extra;
|
||||
const {
|
||||
attributes
|
||||
} = node;
|
||||
var {
|
||||
assertions
|
||||
} = node;
|
||||
const {
|
||||
importAttributesKeyword
|
||||
} = this.format;
|
||||
if (attributes && !importAttributesKeyword && node.extra && (node.extra.deprecatedAssertSyntax || node.extra.deprecatedWithLegacySyntax) && !warningShown) {
|
||||
warningShown = true;
|
||||
console.warn(`\
|
||||
You are using import attributes, without specifying the desired output syntax.
|
||||
Please specify the "importAttributesKeyword" generator option, whose value can be one of:
|
||||
- "with" : \`import { a } from "b" with { type: "json" };\`
|
||||
- "assert" : \`import { a } from "b" assert { type: "json" };\`
|
||||
- "with-legacy" : \`import { a } from "b" with type: "json";\`
|
||||
`);
|
||||
}
|
||||
const useAssertKeyword = importAttributesKeyword === "assert" || !importAttributesKeyword && assertions;
|
||||
this.word(useAssertKeyword ? "assert" : "with");
|
||||
this.space();
|
||||
if (!useAssertKeyword && (importAttributesKeyword === "with-legacy" || !importAttributesKeyword && (_node$extra = node.extra) != null && _node$extra.deprecatedWithLegacySyntax)) {
|
||||
this.printList(attributes || assertions);
|
||||
return;
|
||||
}
|
||||
const occurrenceCount = hasPreviousBrace ? 1 : 0;
|
||||
this.token("{", undefined, occurrenceCount);
|
||||
this.space();
|
||||
this.printList(attributes || assertions, this.shouldPrintTrailingComma("}"));
|
||||
this.space();
|
||||
this.token("}", undefined, occurrenceCount);
|
||||
}
|
||||
function ExportAllDeclaration(node) {
|
||||
var _node$attributes, _node$assertions;
|
||||
this.word("export");
|
||||
this.space();
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
if ((_node$attributes = node.attributes) != null && _node$attributes.length || (_node$assertions = node.assertions) != null && _node$assertions.length) {
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
_printAttributes.call(this, node, false);
|
||||
} else {
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function maybePrintDecoratorsBeforeExport(printer, node) {
|
||||
if (isClassDeclaration(node.declaration) && _expressions._shouldPrintDecoratorsBeforeExport.call(printer, node)) {
|
||||
printer.printJoin(node.declaration.decorators);
|
||||
}
|
||||
}
|
||||
function ExportNamedDeclaration(node) {
|
||||
maybePrintDecoratorsBeforeExport(this, node);
|
||||
this.word("export");
|
||||
this.space();
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar);
|
||||
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());
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasBrace = false;
|
||||
if (specifiers.length || !specifiers.length && !hasSpecial) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
if (specifiers.length) {
|
||||
this.space();
|
||||
this.printList(specifiers, this.shouldPrintTrailingComma("}"));
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(125);
|
||||
}
|
||||
if (node.source) {
|
||||
var _node$attributes2, _node$assertions2;
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
if ((_node$attributes2 = node.attributes) != null && _node$attributes2.length || (_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
_printAttributes.call(this, node, hasBrace);
|
||||
} else {
|
||||
this.print(node.source);
|
||||
}
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
function ExportDefaultDeclaration(node) {
|
||||
maybePrintDecoratorsBeforeExport(this, node);
|
||||
this.word("export");
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.space();
|
||||
this.word("default");
|
||||
this.space();
|
||||
this.tokenContext |= _index.TokenContext.exportDefault;
|
||||
const declar = node.declaration;
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
}
|
||||
function ImportDeclaration(node) {
|
||||
var _node$attributes3, _node$assertions3;
|
||||
this.word("import");
|
||||
this.space();
|
||||
const isTypeKind = node.importKind === "type" || node.importKind === "typeof";
|
||||
if (isTypeKind) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
} else if (node.module) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.word("module");
|
||||
this.space();
|
||||
} else if (node.phase) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.word(node.phase);
|
||||
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());
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasBrace = false;
|
||||
if (specifiers.length) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(specifiers, this.shouldPrintTrailingComma("}"));
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
} else if (isTypeKind && !hasSpecifiers) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
if (hasSpecifiers || isTypeKind) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
}
|
||||
if ((_node$attributes3 = node.attributes) != null && _node$attributes3.length || (_node$assertions3 = node.assertions) != null && _node$assertions3.length) {
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
_printAttributes.call(this, node, hasBrace);
|
||||
} else {
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ImportAttribute(node) {
|
||||
this.print(node.key);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
function ImportNamespaceSpecifier(node) {
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local);
|
||||
}
|
||||
function ImportExpression(node) {
|
||||
this.word("import");
|
||||
if (node.phase) {
|
||||
this.tokenChar(46);
|
||||
this.word(node.phase);
|
||||
}
|
||||
this.tokenChar(40);
|
||||
const shouldPrintTrailingComma = this.shouldPrintTrailingComma(")");
|
||||
this.print(node.source);
|
||||
if (node.options != null) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
this.print(node.options);
|
||||
}
|
||||
if (shouldPrintTrailingComma) {
|
||||
this.tokenChar(44);
|
||||
}
|
||||
this.rightParens(node);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=modules.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+297
@@ -0,0 +1,297 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.BreakStatement = BreakStatement;
|
||||
exports.CatchClause = CatchClause;
|
||||
exports.ContinueStatement = ContinueStatement;
|
||||
exports.DebuggerStatement = DebuggerStatement;
|
||||
exports.DoWhileStatement = DoWhileStatement;
|
||||
exports.ForInStatement = ForInStatement;
|
||||
exports.ForOfStatement = ForOfStatement;
|
||||
exports.ForStatement = ForStatement;
|
||||
exports.IfStatement = IfStatement;
|
||||
exports.LabeledStatement = LabeledStatement;
|
||||
exports.ReturnStatement = ReturnStatement;
|
||||
exports.SwitchCase = SwitchCase;
|
||||
exports.SwitchStatement = SwitchStatement;
|
||||
exports.ThrowStatement = ThrowStatement;
|
||||
exports.TryStatement = TryStatement;
|
||||
exports.VariableDeclaration = VariableDeclaration;
|
||||
exports.VariableDeclarator = VariableDeclarator;
|
||||
exports.WhileStatement = WhileStatement;
|
||||
exports.WithStatement = WithStatement;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isFor,
|
||||
isIfStatement,
|
||||
isStatement
|
||||
} = _t;
|
||||
function WithStatement(node) {
|
||||
this.word("with");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.object);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
if (needsBlock) {
|
||||
this.tokenChar(123);
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
this.printAndIndentOnComments(node.consequent);
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
if (node.alternate) {
|
||||
if (this.endsWith(125)) this.space();
|
||||
this.word("else");
|
||||
this.space();
|
||||
this.printAndIndentOnComments(node.alternate);
|
||||
}
|
||||
}
|
||||
function getLastStatement(statement) {
|
||||
const {
|
||||
body
|
||||
} = statement;
|
||||
if (isStatement(body) === false) {
|
||||
return statement;
|
||||
}
|
||||
return getLastStatement(body);
|
||||
}
|
||||
function ForStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.tokenContext |= _index.TokenContext.forInitHead | _index.TokenContext.forInOrInitHeadAccumulate;
|
||||
this.print(node.init);
|
||||
this.tokenContext = _index.TokenContext.normal;
|
||||
this.tokenChar(59);
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test);
|
||||
}
|
||||
this.tokenChar(59, 1);
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function ForInStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
this.tokenContext |= _index.TokenContext.forInHead | _index.TokenContext.forInOrInitHeadAccumulate;
|
||||
this.print(node.left);
|
||||
this.tokenContext = _index.TokenContext.normal;
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function ForOfStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
if (node.await) {
|
||||
this.word("await");
|
||||
this.space();
|
||||
}
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
this.tokenContext |= _index.TokenContext.forOfHead;
|
||||
this.print(node.left);
|
||||
this.space();
|
||||
this.word("of");
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node.body);
|
||||
}
|
||||
function DoWhileStatement(node) {
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
this.space();
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.semicolon();
|
||||
}
|
||||
function printStatementAfterKeyword(printer, node) {
|
||||
if (node) {
|
||||
printer.space();
|
||||
printer.printTerminatorless(node);
|
||||
}
|
||||
printer.semicolon();
|
||||
}
|
||||
function BreakStatement(node) {
|
||||
this.word("break");
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ContinueStatement(node) {
|
||||
this.word("continue");
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ReturnStatement(node) {
|
||||
this.word("return");
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function ThrowStatement(node) {
|
||||
this.word("throw");
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function LabeledStatement(node) {
|
||||
this.print(node.label);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function TryStatement(node) {
|
||||
this.word("try");
|
||||
this.space();
|
||||
this.print(node.block);
|
||||
this.space();
|
||||
if (node.handlers) {
|
||||
this.print(node.handlers[0]);
|
||||
} else {
|
||||
this.print(node.handler);
|
||||
}
|
||||
if (node.finalizer) {
|
||||
this.space();
|
||||
this.word("finally");
|
||||
this.space();
|
||||
this.print(node.finalizer);
|
||||
}
|
||||
}
|
||||
function CatchClause(node) {
|
||||
this.word("catch");
|
||||
this.space();
|
||||
if (node.param) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.param);
|
||||
this.print(node.param.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.body);
|
||||
}
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.discriminant);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.printSequence(node.cases, true);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
this.space();
|
||||
this.print(node.test);
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.word("default");
|
||||
this.tokenChar(58);
|
||||
}
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, true);
|
||||
}
|
||||
}
|
||||
function DebuggerStatement() {
|
||||
this.word("debugger");
|
||||
this.semicolon();
|
||||
}
|
||||
function commaSeparatorWithNewline(occurrenceCount) {
|
||||
this.tokenChar(44, occurrenceCount);
|
||||
this.newline();
|
||||
}
|
||||
function VariableDeclaration(node, parent) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
switch (kind) {
|
||||
case "await using":
|
||||
this.word("await");
|
||||
this.space();
|
||||
case "using":
|
||||
this.word("using", true);
|
||||
break;
|
||||
default:
|
||||
this.word(kind);
|
||||
}
|
||||
this.space();
|
||||
let hasInits = false;
|
||||
if (!isFor(parent)) {
|
||||
for (const declar of node.declarations) {
|
||||
if (declar.init) {
|
||||
hasInits = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.printList(node.declarations, undefined, undefined, node.declarations.length > 1, hasInits ? commaSeparatorWithNewline : undefined);
|
||||
if (parent != null) {
|
||||
switch (parent.type) {
|
||||
case "ForStatement":
|
||||
if (parent.init === node) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "ForInStatement":
|
||||
case "ForOfStatement":
|
||||
if (parent.left === node) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function VariableDeclarator(node) {
|
||||
this.print(node.id);
|
||||
if (node.definite) this.tokenChar(33);
|
||||
this.print(node.id.typeAnnotation);
|
||||
if (node.init) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.init);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=statements.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
||||
exports.TemplateElement = TemplateElement;
|
||||
exports.TemplateLiteral = TemplateLiteral;
|
||||
exports._printTemplate = _printTemplate;
|
||||
function TaggedTemplateExpression(node) {
|
||||
this.print(node.tag);
|
||||
this.print(node.typeParameters);
|
||||
this.print(node.quasi);
|
||||
}
|
||||
function TemplateElement() {
|
||||
throw new Error("TemplateElement printing is handled in TemplateLiteral");
|
||||
}
|
||||
function _printTemplate(node, substitutions) {
|
||||
const quasis = node.quasis;
|
||||
let partRaw = "`";
|
||||
for (let i = 0; i < quasis.length - 1; i++) {
|
||||
partRaw += quasis[i].value.raw;
|
||||
this.token(partRaw + "${", true);
|
||||
this.print(substitutions[i]);
|
||||
partRaw = "}";
|
||||
if (this.tokenMap) {
|
||||
const token = this.tokenMap.findMatching(node, "}", i);
|
||||
if (token) this._catchUpTo(token.loc.start);
|
||||
}
|
||||
}
|
||||
partRaw += quasis[quasis.length - 1].value.raw;
|
||||
this.token(partRaw + "`", true);
|
||||
}
|
||||
function TemplateLiteral(node) {
|
||||
_printTemplate.call(this, node, node.expressions);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=template-literals.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["TaggedTemplateExpression","node","print","tag","typeParameters","quasi","TemplateElement","Error","_printTemplate","substitutions","quasis","partRaw","i","length","value","raw","token","tokenMap","findMatching","_catchUpTo","loc","start","TemplateLiteral","call","expressions"],"sources":["../../src/generators/template-literals.ts"],"sourcesContent":["import type Printer from \"../printer.ts\";\nimport type * as t from \"@babel/types\";\n\nexport function TaggedTemplateExpression(\n this: Printer,\n node: t.TaggedTemplateExpression,\n) {\n this.print(node.tag);\n if (process.env.BABEL_8_BREAKING) {\n // @ts-ignore(Babel 7 vs Babel 8) Babel 8 AST\n this.print(node.typeArguments);\n } else {\n // @ts-ignore(Babel 7 vs Babel 8) Babel 7 AST\n this.print(node.typeParameters);\n }\n this.print(node.quasi);\n}\n\nexport function TemplateElement(this: Printer) {\n throw new Error(\"TemplateElement printing is handled in TemplateLiteral\");\n}\n\nexport type TemplateLiteralBase = t.Node & {\n quasis: t.TemplateElement[];\n};\n\nexport function _printTemplate<T extends t.Node>(\n this: Printer,\n node: TemplateLiteralBase,\n substitutions: T[],\n) {\n const quasis = node.quasis;\n let partRaw = \"`\";\n for (let i = 0; i < quasis.length - 1; i++) {\n partRaw += quasis[i].value.raw;\n this.token(partRaw + \"${\", true);\n this.print(substitutions[i]);\n partRaw = \"}\";\n\n // In Babel 7 we have individual tokens for ${ and }, so the automatic\n // catchup logic does not work. Manually look for those tokens.\n if (!process.env.BABEL_8_BREAKING && this.tokenMap) {\n const token = this.tokenMap.findMatching(node, \"}\", i);\n if (token) this._catchUpTo(token.loc.start);\n }\n }\n partRaw += quasis[quasis.length - 1].value.raw;\n this.token(partRaw + \"`\", true);\n}\n\nexport function TemplateLiteral(this: Printer, node: t.TemplateLiteral) {\n _printTemplate.call(this, node, node.expressions);\n}\n"],"mappings":";;;;;;;;;AAGO,SAASA,wBAAwBA,CAEtCC,IAAgC,EAChC;EACA,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,GAAG,CAAC;EAMlB,IAAI,CAACD,KAAK,CAACD,IAAI,CAACG,cAAc,CAAC;EAEjC,IAAI,CAACF,KAAK,CAACD,IAAI,CAACI,KAAK,CAAC;AACxB;AAEO,SAASC,eAAeA,CAAA,EAAgB;EAC7C,MAAM,IAAIC,KAAK,CAAC,wDAAwD,CAAC;AAC3E;AAMO,SAASC,cAAcA,CAE5BP,IAAyB,EACzBQ,aAAkB,EAClB;EACA,MAAMC,MAAM,GAAGT,IAAI,CAACS,MAAM;EAC1B,IAAIC,OAAO,GAAG,GAAG;EACjB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACG,MAAM,GAAG,CAAC,EAAED,CAAC,EAAE,EAAE;IAC1CD,OAAO,IAAID,MAAM,CAACE,CAAC,CAAC,CAACE,KAAK,CAACC,GAAG;IAC9B,IAAI,CAACC,KAAK,CAACL,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC;IAChC,IAAI,CAACT,KAAK,CAACO,aAAa,CAACG,CAAC,CAAC,CAAC;IAC5BD,OAAO,GAAG,GAAG;IAIb,IAAqC,IAAI,CAACM,QAAQ,EAAE;MAClD,MAAMD,KAAK,GAAG,IAAI,CAACC,QAAQ,CAACC,YAAY,CAACjB,IAAI,EAAE,GAAG,EAAEW,CAAC,CAAC;MACtD,IAAII,KAAK,EAAE,IAAI,CAACG,UAAU,CAACH,KAAK,CAACI,GAAG,CAACC,KAAK,CAAC;IAC7C;EACF;EACAV,OAAO,IAAID,MAAM,CAACA,MAAM,CAACG,MAAM,GAAG,CAAC,CAAC,CAACC,KAAK,CAACC,GAAG;EAC9C,IAAI,CAACC,KAAK,CAACL,OAAO,GAAG,GAAG,EAAE,IAAI,CAAC;AACjC;AAEO,SAASW,eAAeA,CAAgBrB,IAAuB,EAAE;EACtEO,cAAc,CAACe,IAAI,CAAC,IAAI,EAAEtB,IAAI,EAAEA,IAAI,CAACuB,WAAW,CAAC;AACnD","ignoreList":[]}
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ArgumentPlaceholder = ArgumentPlaceholder;
|
||||
exports.ArrayPattern = exports.ArrayExpression = ArrayExpression;
|
||||
exports.BigIntLiteral = BigIntLiteral;
|
||||
exports.BooleanLiteral = BooleanLiteral;
|
||||
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.RegExpLiteral = RegExpLiteral;
|
||||
exports.SpreadElement = exports.RestElement = RestElement;
|
||||
exports.StringLiteral = StringLiteral;
|
||||
exports.TopicReference = TopicReference;
|
||||
exports.VoidPattern = VoidPattern;
|
||||
exports._getRawIdentifier = _getRawIdentifier;
|
||||
var _t = require("@babel/types");
|
||||
var _jsesc = require("jsesc");
|
||||
var _methods = require("./methods.js");
|
||||
const {
|
||||
isAssignmentPattern,
|
||||
isIdentifier
|
||||
} = _t;
|
||||
let lastRawIdentResult = "";
|
||||
function _getRawIdentifier(node) {
|
||||
const {
|
||||
name
|
||||
} = node;
|
||||
const token = this.tokenMap.find(node, tok => tok.value === name);
|
||||
if (token) {
|
||||
lastRawIdentResult = this._originalCode.slice(token.start, token.end);
|
||||
return lastRawIdentResult;
|
||||
}
|
||||
return lastRawIdentResult = node.name;
|
||||
}
|
||||
function Identifier(node) {
|
||||
if (this._buf._map) {
|
||||
var _node$loc;
|
||||
this.sourceIdentifierName(((_node$loc = node.loc) == null ? void 0 : _node$loc.identifierName) || node.name);
|
||||
}
|
||||
this.word(this.tokenMap ? lastRawIdentResult : node.name);
|
||||
}
|
||||
function ArgumentPlaceholder() {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
function RestElement(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument);
|
||||
}
|
||||
function ObjectExpression(node) {
|
||||
const props = node.properties;
|
||||
this.tokenChar(123);
|
||||
if (props.length) {
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
this.space();
|
||||
this.printList(props, this.shouldPrintTrailingComma("}"), true, true, undefined, true);
|
||||
this.space();
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
}
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function ObjectMethod(node) {
|
||||
this.printJoin(node.decorators);
|
||||
_methods._methodHead.call(this, node);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ObjectProperty(node) {
|
||||
this.printJoin(node.decorators);
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (isAssignmentPattern(node.value) && isIdentifier(node.key) && node.key.name === node.value.left.name) {
|
||||
this.print(node.value);
|
||||
return;
|
||||
}
|
||||
this.print(node.key);
|
||||
if (node.shorthand && isIdentifier(node.key) && isIdentifier(node.value) && node.key.name === node.value.name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
function ArrayExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
this.tokenChar(91);
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
for (let i = 0; i < elems.length; i++) {
|
||||
const elem = elems[i];
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem, undefined, true);
|
||||
if (i < len - 1 || this.shouldPrintTrailingComma("]")) {
|
||||
this.tokenChar(44, i);
|
||||
}
|
||||
} else {
|
||||
this.tokenChar(44, i);
|
||||
}
|
||||
}
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function RegExpLiteral(node) {
|
||||
this.word(`/${node.pattern}/${node.flags}`, false);
|
||||
}
|
||||
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;
|
||||
const str = value + "";
|
||||
if (opts.numbers) {
|
||||
this.number(_jsesc(value, opts), value);
|
||||
} else if (raw == null) {
|
||||
this.number(str, value);
|
||||
} else if (this.format.minified) {
|
||||
this.number(raw.length < str.length ? raw : str, value);
|
||||
} else {
|
||||
this.number(raw, value);
|
||||
}
|
||||
}
|
||||
function StringLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.token(raw);
|
||||
return;
|
||||
}
|
||||
const val = _jsesc(node.value, this.format.jsescOption);
|
||||
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");
|
||||
}
|
||||
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);
|
||||
}
|
||||
function PipelineBareFunction(node) {
|
||||
this.print(node.callee);
|
||||
}
|
||||
function PipelinePrimaryTopicReference() {
|
||||
this.tokenChar(35);
|
||||
}
|
||||
function VoidPattern() {
|
||||
this.word("void");
|
||||
}
|
||||
|
||||
//# sourceMappingURL=types.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+726
@@ -0,0 +1,726 @@
|
||||
"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.TSInterfaceHeritage = exports.TSClassImplements = TSClassImplements;
|
||||
exports.TSConditionalType = TSConditionalType;
|
||||
exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration;
|
||||
exports.TSConstructorType = TSConstructorType;
|
||||
exports.TSDeclareFunction = TSDeclareFunction;
|
||||
exports.TSDeclareMethod = TSDeclareMethod;
|
||||
exports.TSEnumBody = TSEnumBody;
|
||||
exports.TSEnumDeclaration = TSEnumDeclaration;
|
||||
exports.TSEnumMember = TSEnumMember;
|
||||
exports.TSExportAssignment = TSExportAssignment;
|
||||
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.TSSatisfiesExpression = TSSatisfiesExpression;
|
||||
exports.TSStringKeyword = TSStringKeyword;
|
||||
exports.TSSymbolKeyword = TSSymbolKeyword;
|
||||
exports.TSTemplateLiteralType = TSTemplateLiteralType;
|
||||
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;
|
||||
var _methods = require("./methods.js");
|
||||
var _classes = require("./classes.js");
|
||||
var _templateLiterals = require("./template-literals.js");
|
||||
function TSTypeAnnotation(node, parent) {
|
||||
this.token((parent.type === "TSFunctionType" || parent.type === "TSConstructorType") && parent.typeAnnotation === node ? "=>" : ":");
|
||||
this.space();
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSTypeParameterInstantiation(node, parent) {
|
||||
this.tokenChar(60);
|
||||
let printTrailingSeparator = parent.type === "ArrowFunctionExpression" && node.params.length === 1;
|
||||
if (this.tokenMap && node.start != null && node.end != null) {
|
||||
printTrailingSeparator && (printTrailingSeparator = !!this.tokenMap.find(node, t => this.tokenMap.matchesOriginal(t, ",")));
|
||||
printTrailingSeparator || (printTrailingSeparator = this.shouldPrintTrailingComma(">"));
|
||||
}
|
||||
this.printList(node.params, printTrailingSeparator);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function TSTypeParameter(node) {
|
||||
if (node.const) {
|
||||
this.word("const");
|
||||
this.space();
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.default);
|
||||
}
|
||||
}
|
||||
function TSParameterProperty(node) {
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
if (node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
_methods._param.call(this, node.parameter);
|
||||
}
|
||||
function TSDeclareFunction(node, parent) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
_methods._functionHead.call(this, node, parent, false);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSDeclareMethod(node) {
|
||||
_classes._classMethodHead.call(this, node);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSQualifiedName(node) {
|
||||
this.print(node.left);
|
||||
this.tokenChar(46);
|
||||
this.print(node.right);
|
||||
}
|
||||
function TSCallSignatureDeclaration(node) {
|
||||
tsPrintSignatureDeclarationBase.call(this, node);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function maybePrintTrailingCommaOrSemicolon(printer, node) {
|
||||
if (!printer.tokenMap || !node.start || !node.end) {
|
||||
printer.semicolon();
|
||||
return;
|
||||
}
|
||||
if (printer.tokenMap.endMatches(node, ",")) {
|
||||
printer.token(",");
|
||||
} else if (printer.tokenMap.endMatches(node, ";")) {
|
||||
printer.semicolon();
|
||||
}
|
||||
}
|
||||
function TSConstructSignatureDeclaration(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
tsPrintSignatureDeclarationBase.call(this, node);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSPropertySignature(node) {
|
||||
const {
|
||||
readonly
|
||||
} = node;
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
tsPrintPropertyOrMethodName.call(this, node);
|
||||
this.print(node.typeAnnotation);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function tsPrintPropertyOrMethodName(node) {
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
}
|
||||
this.print(node.key);
|
||||
if (node.computed) {
|
||||
this.tokenChar(93);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
}
|
||||
function TSMethodSignature(node) {
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
if (kind === "set" || kind === "get") {
|
||||
this.word(kind);
|
||||
this.space();
|
||||
}
|
||||
tsPrintPropertyOrMethodName.call(this, node);
|
||||
tsPrintSignatureDeclarationBase.call(this, node);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSIndexSignature(node) {
|
||||
const {
|
||||
readonly,
|
||||
static: isStatic
|
||||
} = node;
|
||||
if (isStatic) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
_methods._parameters.call(this, node.parameters, 93);
|
||||
this.print(node.typeAnnotation);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
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) {
|
||||
tsPrintFunctionOrConstructorType.call(this, node);
|
||||
}
|
||||
function TSConstructorType(node) {
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
this.word("new");
|
||||
this.space();
|
||||
tsPrintFunctionOrConstructorType.call(this, node);
|
||||
}
|
||||
function tsPrintFunctionOrConstructorType(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters);
|
||||
this.tokenChar(40);
|
||||
_methods._parameters.call(this, parameters, 41);
|
||||
this.space();
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType);
|
||||
}
|
||||
function TSTypeReference(node) {
|
||||
const typeArguments = node.typeParameters;
|
||||
this.print(node.typeName, !!typeArguments);
|
||||
this.print(typeArguments);
|
||||
}
|
||||
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);
|
||||
const typeArguments = node.typeParameters;
|
||||
if (typeArguments) {
|
||||
this.print(typeArguments);
|
||||
}
|
||||
}
|
||||
function TSTypeLiteral(node) {
|
||||
printBraced(this, node, () => this.printJoin(node.members, true, true, undefined, undefined, true));
|
||||
}
|
||||
function TSArrayType(node) {
|
||||
this.print(node.elementType, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSTupleType(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.elementTypes, this.shouldPrintTrailingComma("]"));
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSOptionalType(node) {
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(63);
|
||||
}
|
||||
function TSRestType(node) {
|
||||
this.token("...");
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSNamedTupleMember(node) {
|
||||
this.print(node.label);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.elementType);
|
||||
}
|
||||
function TSUnionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "|");
|
||||
}
|
||||
function TSIntersectionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "&");
|
||||
}
|
||||
function tsPrintUnionOrIntersectionType(printer, node, sep) {
|
||||
var _printer$tokenMap;
|
||||
let hasLeadingToken = 0;
|
||||
if ((_printer$tokenMap = printer.tokenMap) != null && _printer$tokenMap.startMatches(node, sep)) {
|
||||
hasLeadingToken = 1;
|
||||
printer.token(sep);
|
||||
}
|
||||
printer.printJoin(node.types, undefined, undefined, function (i) {
|
||||
this.space();
|
||||
this.token(sep, undefined, i + hasLeadingToken);
|
||||
this.space();
|
||||
});
|
||||
}
|
||||
function TSConditionalType(node) {
|
||||
this.print(node.checkType);
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.extendsType);
|
||||
this.space();
|
||||
this.tokenChar(63);
|
||||
this.space();
|
||||
this.print(node.trueType);
|
||||
this.space();
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.falseType);
|
||||
}
|
||||
function TSInferType(node) {
|
||||
this.word("infer");
|
||||
this.print(node.typeParameter);
|
||||
}
|
||||
function TSParenthesizedType(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function TSTypeOperator(node) {
|
||||
this.word(node.operator);
|
||||
this.space();
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSIndexedAccessType(node) {
|
||||
this.print(node.objectType, true);
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSMappedType(node) {
|
||||
const {
|
||||
nameType,
|
||||
optional,
|
||||
readonly,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.tokenChar(123);
|
||||
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
||||
this.space();
|
||||
if (readonly) {
|
||||
tokenIfPlusMinus(this, readonly);
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.word(node.typeParameter.name);
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
this.print(node.typeParameter.constraint, undefined, true);
|
||||
if (nameType) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(nameType, undefined, true);
|
||||
}
|
||||
this.tokenChar(93);
|
||||
if (optional) {
|
||||
tokenIfPlusMinus(this, optional);
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (typeAnnotation) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(typeAnnotation, undefined, true);
|
||||
}
|
||||
this.space();
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
this.tokenChar(125);
|
||||
}
|
||||
function tokenIfPlusMinus(self, tok) {
|
||||
if (tok !== true) {
|
||||
self.token(tok);
|
||||
}
|
||||
}
|
||||
function TSTemplateLiteralType(node) {
|
||||
_templateLiterals._printTemplate.call(this, node, node.types);
|
||||
}
|
||||
function TSLiteralType(node) {
|
||||
this.print(node.literal);
|
||||
}
|
||||
function TSClassImplements(node) {
|
||||
this.print(node.expression);
|
||||
this.print(node.typeArguments);
|
||||
}
|
||||
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);
|
||||
this.print(typeParameters);
|
||||
if (extendz != null && extendz.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(extendz);
|
||||
}
|
||||
this.space();
|
||||
this.print(body);
|
||||
}
|
||||
function TSInterfaceBody(node) {
|
||||
printBraced(this, node, () => this.printJoin(node.body, true, true, undefined, undefined, true));
|
||||
}
|
||||
function TSTypeAliasDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id,
|
||||
typeParameters,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(id);
|
||||
this.print(typeParameters);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(typeAnnotation);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSAsExpression(node) {
|
||||
const {
|
||||
expression,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.print(expression, true);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(typeAnnotation);
|
||||
}
|
||||
function TSSatisfiesExpression(node) {
|
||||
const {
|
||||
expression,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.print(expression, true);
|
||||
this.space();
|
||||
this.word("satisfies");
|
||||
this.space();
|
||||
this.print(typeAnnotation);
|
||||
}
|
||||
function TSTypeAssertion(node) {
|
||||
const {
|
||||
typeAnnotation,
|
||||
expression
|
||||
} = node;
|
||||
this.tokenChar(60);
|
||||
this.print(typeAnnotation);
|
||||
this.tokenChar(62);
|
||||
this.space();
|
||||
this.print(expression);
|
||||
}
|
||||
function TSInstantiationExpression(node) {
|
||||
this.print(node.expression);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
function TSEnumDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
const: isConst,
|
||||
id
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (isConst) {
|
||||
this.word("const");
|
||||
this.space();
|
||||
}
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id);
|
||||
this.space();
|
||||
TSEnumBody.call(this, node);
|
||||
}
|
||||
function TSEnumBody(node) {
|
||||
printBraced(this, node, () => {
|
||||
var _this$shouldPrintTrai;
|
||||
return this.printList(node.members, (_this$shouldPrintTrai = this.shouldPrintTrailingComma("}")) != null ? _this$shouldPrintTrai : true, true, true, undefined, true);
|
||||
});
|
||||
}
|
||||
function TSEnumMember(node) {
|
||||
const {
|
||||
id,
|
||||
initializer
|
||||
} = node;
|
||||
this.print(id);
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(initializer);
|
||||
}
|
||||
}
|
||||
function TSModuleDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id,
|
||||
kind
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (!node.global) {
|
||||
this.word(kind != null ? kind : id.type === "Identifier" ? "namespace" : "module");
|
||||
this.space();
|
||||
}
|
||||
this.print(id);
|
||||
if (!node.body) {
|
||||
this.semicolon();
|
||||
return;
|
||||
}
|
||||
let body = node.body;
|
||||
while (body.type === "TSModuleDeclaration") {
|
||||
this.tokenChar(46);
|
||||
this.print(body.id);
|
||||
body = body.body;
|
||||
}
|
||||
this.space();
|
||||
this.print(body);
|
||||
}
|
||||
function TSModuleBlock(node) {
|
||||
printBraced(this, node, () => this.printSequence(node.body, true, true));
|
||||
}
|
||||
function TSImportType(node) {
|
||||
const {
|
||||
qualifier,
|
||||
options
|
||||
} = node;
|
||||
this.word("import");
|
||||
this.tokenChar(40);
|
||||
this.print(node.argument);
|
||||
if (options) {
|
||||
this.tokenChar(44);
|
||||
this.print(options);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
if (qualifier) {
|
||||
this.tokenChar(46);
|
||||
this.print(qualifier);
|
||||
}
|
||||
const typeArguments = node.typeParameters;
|
||||
if (typeArguments) {
|
||||
this.print(typeArguments);
|
||||
}
|
||||
}
|
||||
function TSImportEqualsDeclaration(node) {
|
||||
const {
|
||||
id,
|
||||
moduleReference
|
||||
} = node;
|
||||
if (node.isExport) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
}
|
||||
this.word("import");
|
||||
this.space();
|
||||
this.print(id);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(moduleReference);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSExternalModuleReference(node) {
|
||||
this.token("require(");
|
||||
this.print(node.expression);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function TSNonNullExpression(node) {
|
||||
this.print(node.expression);
|
||||
this.tokenChar(33);
|
||||
this.setLastChar(33);
|
||||
}
|
||||
function TSExportAssignment(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.expression);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSNamespaceExportDeclaration(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.word("namespace");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.semicolon();
|
||||
}
|
||||
function tsPrintSignatureDeclarationBase(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters);
|
||||
this.tokenChar(40);
|
||||
_methods._parameters.call(this, parameters, 41);
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType);
|
||||
}
|
||||
function _tsPrintClassMemberModifiers(node) {
|
||||
const isPrivateField = node.type === "ClassPrivateProperty";
|
||||
const isPublicField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty";
|
||||
printModifiersList(this, node, [isPublicField && node.declare && "declare", !isPrivateField && node.accessibility]);
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
printModifiersList(this, node, [!isPrivateField && node.abstract && "abstract", !isPrivateField && node.override && "override", (isPublicField || isPrivateField) && node.readonly && "readonly"]);
|
||||
}
|
||||
function printBraced(printer, node, cb) {
|
||||
printer.token("{");
|
||||
const oldNoLineTerminatorAfterNode = printer.enterDelimited();
|
||||
cb();
|
||||
printer._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
printer.rightBrace(node);
|
||||
}
|
||||
function printModifiersList(printer, node, modifiers) {
|
||||
var _printer$tokenMap2;
|
||||
const modifiersSet = new Set();
|
||||
for (const modifier of modifiers) {
|
||||
if (modifier) modifiersSet.add(modifier);
|
||||
}
|
||||
(_printer$tokenMap2 = printer.tokenMap) == null || _printer$tokenMap2.find(node, tok => {
|
||||
if (modifiersSet.has(tok.value)) {
|
||||
printer.token(tok.value);
|
||||
printer.space();
|
||||
modifiersSet.delete(tok.value);
|
||||
return modifiersSet.size === 0;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
for (const modifier of modifiersSet) {
|
||||
printer.word(modifier);
|
||||
printer.space();
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=typescript.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+108
@@ -0,0 +1,108 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
exports.generate = generate;
|
||||
var _sourceMap = require("./source-map.js");
|
||||
var _printer = require("./printer.js");
|
||||
function normalizeOptions(code, opts, ast) {
|
||||
var _opts$recordAndTupleS;
|
||||
if (opts.experimental_preserveFormat) {
|
||||
if (typeof code !== "string") {
|
||||
throw new Error("`experimental_preserveFormat` requires the original `code` to be passed to @babel/generator as a string");
|
||||
}
|
||||
if (!opts.retainLines) {
|
||||
throw new Error("`experimental_preserveFormat` requires `retainLines` to be set to `true`");
|
||||
}
|
||||
if (opts.compact && opts.compact !== "auto") {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `compact` option");
|
||||
}
|
||||
if (opts.minified) {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `minified` option");
|
||||
}
|
||||
if (opts.jsescOption) {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `jsescOption` option");
|
||||
}
|
||||
if (!Array.isArray(ast.tokens)) {
|
||||
throw new Error("`experimental_preserveFormat` requires the AST to have attached the token of the input code. Make sure to enable the `tokens: true` parser option.");
|
||||
}
|
||||
}
|
||||
const format = {
|
||||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
|
||||
shouldPrintComment: opts.shouldPrintComment,
|
||||
preserveFormat: opts.experimental_preserveFormat,
|
||||
retainLines: opts.retainLines,
|
||||
retainFunctionParens: opts.retainFunctionParens,
|
||||
comments: opts.comments == null || opts.comments,
|
||||
compact: opts.compact,
|
||||
minified: opts.minified,
|
||||
concise: opts.concise,
|
||||
indent: {
|
||||
adjustMultilineComment: true,
|
||||
style: " "
|
||||
},
|
||||
jsescOption: Object.assign({
|
||||
quotes: "double",
|
||||
wrap: true,
|
||||
minimal: false
|
||||
}, opts.jsescOption),
|
||||
topicToken: opts.topicToken
|
||||
};
|
||||
format.decoratorsBeforeExport = opts.decoratorsBeforeExport;
|
||||
format.jsescOption.json = opts.jsonCompatibleStrings;
|
||||
format.recordAndTupleSyntaxType = (_opts$recordAndTupleS = opts.recordAndTupleSyntaxType) != null ? _opts$recordAndTupleS : "hash";
|
||||
format.importAttributesKeyword = opts.importAttributesKeyword;
|
||||
if (format.minified) {
|
||||
format.compact = true;
|
||||
format.shouldPrintComment = format.shouldPrintComment || (() => format.comments);
|
||||
} else {
|
||||
format.shouldPrintComment = format.shouldPrintComment || (value => format.comments || value.includes("@license") || value.includes("@preserve"));
|
||||
}
|
||||
if (format.compact === "auto") {
|
||||
format.compact = typeof code === "string" && code.length > 500000;
|
||||
if (format.compact) {
|
||||
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + `${opts.filename} as it exceeds the max of ${"500KB"}.`);
|
||||
}
|
||||
}
|
||||
if (format.compact || format.preserveFormat) {
|
||||
format.indent.adjustMultilineComment = false;
|
||||
}
|
||||
const {
|
||||
auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter,
|
||||
shouldPrintComment
|
||||
} = format;
|
||||
if (auxiliaryCommentBefore && !shouldPrintComment(auxiliaryCommentBefore)) {
|
||||
format.auxiliaryCommentBefore = undefined;
|
||||
}
|
||||
if (auxiliaryCommentAfter && !shouldPrintComment(auxiliaryCommentAfter)) {
|
||||
format.auxiliaryCommentAfter = undefined;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
exports.CodeGenerator = class CodeGenerator {
|
||||
constructor(ast, opts = {}, code) {
|
||||
this._ast = void 0;
|
||||
this._format = void 0;
|
||||
this._map = void 0;
|
||||
this._ast = ast;
|
||||
this._format = normalizeOptions(code, opts, ast);
|
||||
this._map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
}
|
||||
generate() {
|
||||
const printer = new _printer.default(this._format, this._map);
|
||||
return printer.generate(this._ast);
|
||||
}
|
||||
};
|
||||
function generate(ast, opts = {}, code) {
|
||||
const format = normalizeOptions(code, opts, ast);
|
||||
const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
const printer = new _printer.default(format, map, ast.tokens, typeof code === "string" ? code : null);
|
||||
return printer.generate(ast);
|
||||
}
|
||||
var _default = exports.default = generate;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+81
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TokenContext = void 0;
|
||||
exports.isLastChild = isLastChild;
|
||||
exports.parentNeedsParens = parentNeedsParens;
|
||||
var parens = require("./parentheses.js");
|
||||
var _t = require("@babel/types");
|
||||
var _nodes = require("../nodes.js");
|
||||
const {
|
||||
VISITOR_KEYS
|
||||
} = _t;
|
||||
const TokenContext = exports.TokenContext = {
|
||||
normal: 0,
|
||||
expressionStatement: 1,
|
||||
arrowBody: 2,
|
||||
exportDefault: 4,
|
||||
arrowFlowReturnType: 8,
|
||||
forInitHead: 16,
|
||||
forInHead: 32,
|
||||
forOfHead: 64,
|
||||
forInOrInitHeadAccumulate: 128,
|
||||
forInOrInitHeadAccumulatePassThroughMask: 128
|
||||
};
|
||||
for (const type of Object.keys(parens)) {
|
||||
const func = parens[type];
|
||||
if (_nodes.generatorInfosMap.has(type)) {
|
||||
_nodes.generatorInfosMap.get(type)[2] = func;
|
||||
}
|
||||
}
|
||||
function isOrHasCallExpression(node) {
|
||||
switch (node.type) {
|
||||
case "CallExpression":
|
||||
return true;
|
||||
case "MemberExpression":
|
||||
return isOrHasCallExpression(node.object);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parentNeedsParens(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 112:
|
||||
if (parent.callee === node) {
|
||||
if (isOrHasCallExpression(node)) return true;
|
||||
}
|
||||
break;
|
||||
case 42:
|
||||
return !isDecoratorMemberExpression(node) && !(node.type === "CallExpression" && isDecoratorMemberExpression(node.callee)) && node.type !== "ParenthesizedExpression";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
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 isLastChild(parent, child) {
|
||||
const visitorKeys = VISITOR_KEYS[parent.type];
|
||||
for (let i = visitorKeys.length - 1; i >= 0; i--) {
|
||||
const val = parent[visitorKeys[i]];
|
||||
if (val === child) {
|
||||
return true;
|
||||
} else if (Array.isArray(val)) {
|
||||
let j = val.length - 1;
|
||||
while (j >= 0 && val[j] === null) j--;
|
||||
return j >= 0 && val[j] === child;
|
||||
} else if (val) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+298
@@ -0,0 +1,298 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.BinaryExpression = BinaryExpression;
|
||||
exports.ClassExpression = ClassExpression;
|
||||
exports.ArrowFunctionExpression = exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.DoExpression = DoExpression;
|
||||
exports.FunctionExpression = FunctionExpression;
|
||||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||||
exports.Identifier = Identifier;
|
||||
exports.LogicalExpression = LogicalExpression;
|
||||
exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||||
exports.ObjectExpression = ObjectExpression;
|
||||
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
|
||||
exports.OptionalCallExpression = exports.OptionalMemberExpression = OptionalMemberExpression;
|
||||
exports.SequenceExpression = SequenceExpression;
|
||||
exports.TSSatisfiesExpression = exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSConditionalType = TSConditionalType;
|
||||
exports.TSConstructorType = exports.TSFunctionType = TSFunctionType;
|
||||
exports.TSInferType = TSInferType;
|
||||
exports.TSInstantiationExpression = TSInstantiationExpression;
|
||||
exports.TSIntersectionType = TSIntersectionType;
|
||||
exports.SpreadElement = exports.UnaryExpression = exports.TSTypeAssertion = UnaryLike;
|
||||
exports.TSTypeOperator = TSTypeOperator;
|
||||
exports.TSUnionType = TSUnionType;
|
||||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.AwaitExpression = exports.YieldExpression = YieldExpression;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("./index.js");
|
||||
const {
|
||||
isMemberExpression,
|
||||
isOptionalMemberExpression,
|
||||
isYieldExpression,
|
||||
isStatement
|
||||
} = _t;
|
||||
const PRECEDENCE = new Map([["||", 0], ["??", 1], ["&&", 2], ["|", 3], ["^", 4], ["&", 5], ["==", 6], ["===", 6], ["!=", 6], ["!==", 6], ["<", 7], [">", 7], ["<=", 7], [">=", 7], ["in", 7], ["instanceof", 7], [">>", 8], ["<<", 8], [">>>", 8], ["+", 9], ["-", 9], ["*", 10], ["/", 10], ["%", 10], ["**", 11]]);
|
||||
function isTSTypeExpression(nodeId) {
|
||||
return nodeId === 156 || nodeId === 201 || nodeId === 209;
|
||||
}
|
||||
const isClassExtendsClause = (node, parent, parentId) => {
|
||||
return (parentId === 21 || parentId === 22) && parent.superClass === node;
|
||||
};
|
||||
const hasPostfixPart = (node, parent, parentId) => {
|
||||
switch (parentId) {
|
||||
case 108:
|
||||
case 132:
|
||||
return parent.object === node;
|
||||
case 17:
|
||||
case 130:
|
||||
case 112:
|
||||
return parent.callee === node;
|
||||
case 222:
|
||||
return parent.tag === node;
|
||||
case 191:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
function NullableTypeAnnotation(node, parent, parentId) {
|
||||
return parentId === 4;
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent, parentId, tokenContext) {
|
||||
return (parentId === 239 || parentId === 90 || parentId === 4 || (tokenContext & _index.TokenContext.arrowFlowReturnType) > 0
|
||||
);
|
||||
}
|
||||
function UpdateExpression(node, parent, parentId) {
|
||||
return hasPostfixPart(node, parent, parentId) || isClassExtendsClause(node, parent, parentId);
|
||||
}
|
||||
function needsParenBeforeExpressionBrace(tokenContext) {
|
||||
return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.arrowBody)) > 0;
|
||||
}
|
||||
function ObjectExpression(node, parent, parentId, tokenContext) {
|
||||
return needsParenBeforeExpressionBrace(tokenContext);
|
||||
}
|
||||
function DoExpression(node, parent, parentId, tokenContext) {
|
||||
return (tokenContext & _index.TokenContext.expressionStatement) > 0 && !node.async;
|
||||
}
|
||||
function BinaryLike(node, parent, parentId, nodeType) {
|
||||
if (isClassExtendsClause(node, parent, parentId)) {
|
||||
return true;
|
||||
}
|
||||
if (hasPostfixPart(node, parent, parentId) || parentId === 238 || parentId === 145 || parentId === 8) {
|
||||
return true;
|
||||
}
|
||||
let parentPos;
|
||||
switch (parentId) {
|
||||
case 10:
|
||||
case 107:
|
||||
parentPos = PRECEDENCE.get(parent.operator);
|
||||
break;
|
||||
case 156:
|
||||
case 201:
|
||||
parentPos = 7;
|
||||
}
|
||||
if (parentPos !== undefined) {
|
||||
const nodePos = nodeType === 2 ? 7 : PRECEDENCE.get(node.operator);
|
||||
if (parentPos > nodePos) return true;
|
||||
if (parentPos === nodePos && parentId === 10 && (nodePos === 11 ? parent.left === node : parent.right === node)) {
|
||||
return true;
|
||||
}
|
||||
if (nodeType === 1 && parentId === 107 && (nodePos === 1 && parentPos !== 1 || parentPos === 1 && nodePos !== 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function UnionTypeAnnotation(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 4:
|
||||
case 115:
|
||||
case 90:
|
||||
case 239:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function OptionalIndexedAccessType(node, parent, parentId) {
|
||||
return parentId === 84 && parent.objectType === node;
|
||||
}
|
||||
function TSAsExpression(node, parent, parentId) {
|
||||
if ((parentId === 6 || parentId === 7) && parent.left === node) {
|
||||
return true;
|
||||
}
|
||||
if (parentId === 10 && (parent.operator === "|" || parent.operator === "&") && node === parent.left) {
|
||||
return true;
|
||||
}
|
||||
return BinaryLike(node, parent, parentId, 2);
|
||||
}
|
||||
function TSConditionalType(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 155:
|
||||
case 195:
|
||||
case 211:
|
||||
case 212:
|
||||
return true;
|
||||
case 175:
|
||||
return parent.objectType === node;
|
||||
case 181:
|
||||
case 219:
|
||||
return parent.types[0] === node;
|
||||
case 161:
|
||||
return parent.checkType === node || parent.extendsType === node;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSUnionType(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 181:
|
||||
case 211:
|
||||
case 155:
|
||||
case 195:
|
||||
return true;
|
||||
case 175:
|
||||
return parent.objectType === node;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSIntersectionType(node, parent, parentId) {
|
||||
return parentId === 211 || TSTypeOperator(node, parent, parentId);
|
||||
}
|
||||
function TSInferType(node, parent, parentId) {
|
||||
if (TSTypeOperator(node, parent, parentId)) {
|
||||
return true;
|
||||
}
|
||||
if ((parentId === 181 || parentId === 219) && node.typeParameter.constraint && parent.types[0] === node) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSTypeOperator(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 155:
|
||||
case 195:
|
||||
return true;
|
||||
case 175:
|
||||
if (parent.objectType === node) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSInstantiationExpression(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 17:
|
||||
case 130:
|
||||
case 112:
|
||||
case 177:
|
||||
return (parent.typeParameters
|
||||
) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSFunctionType(node, parent, parentId) {
|
||||
if (TSUnionType(node, parent, parentId)) return true;
|
||||
return parentId === 219 || parentId === 161 && (parent.checkType === node || parent.extendsType === node);
|
||||
}
|
||||
function BinaryExpression(node, parent, parentId, tokenContext) {
|
||||
if (BinaryLike(node, parent, parentId, 0)) return true;
|
||||
return (tokenContext & _index.TokenContext.forInOrInitHeadAccumulate) > 0 && node.operator === "in";
|
||||
}
|
||||
function LogicalExpression(node, parent, parentId) {
|
||||
return BinaryLike(node, parent, parentId, 1);
|
||||
}
|
||||
function SequenceExpression(node, parent, parentId) {
|
||||
if (parentId === 144 || parentId === 133 || parentId === 108 && parent.property === node || parentId === 132 && parent.property === node || parentId === 224) {
|
||||
return false;
|
||||
}
|
||||
if (parentId === 21) {
|
||||
return true;
|
||||
}
|
||||
if (parentId === 68) {
|
||||
return parent.right === node;
|
||||
}
|
||||
if (parentId === 60) {
|
||||
return true;
|
||||
}
|
||||
return !isStatement(parent);
|
||||
}
|
||||
function YieldExpression(node, parent, parentId) {
|
||||
return parentId === 10 || parentId === 107 || parentId === 238 || parentId === 145 || hasPostfixPart(node, parent, parentId) || parentId === 8 && isYieldExpression(node) || parentId === 28 && node === parent.test || isClassExtendsClause(node, parent, parentId) || isTSTypeExpression(parentId);
|
||||
}
|
||||
function ClassExpression(node, parent, parentId, tokenContext) {
|
||||
return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault)) > 0;
|
||||
}
|
||||
function UnaryLike(node, parent, parentId) {
|
||||
return hasPostfixPart(node, parent, parentId) || parentId === 10 && parent.operator === "**" && parent.left === node || isClassExtendsClause(node, parent, parentId);
|
||||
}
|
||||
function FunctionExpression(node, parent, parentId, tokenContext) {
|
||||
return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault)) > 0;
|
||||
}
|
||||
function ConditionalExpression(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 238:
|
||||
case 145:
|
||||
case 10:
|
||||
case 107:
|
||||
case 8:
|
||||
return true;
|
||||
case 28:
|
||||
if (parent.test === node) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (isTSTypeExpression(parentId)) {
|
||||
return true;
|
||||
}
|
||||
return UnaryLike(node, parent, parentId);
|
||||
}
|
||||
function OptionalMemberExpression(node, parent, parentId) {
|
||||
switch (parentId) {
|
||||
case 17:
|
||||
return parent.callee === node;
|
||||
case 108:
|
||||
return parent.object === node;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function AssignmentExpression(node, parent, parentId, tokenContext) {
|
||||
if (needsParenBeforeExpressionBrace(tokenContext) && node.left.type === "ObjectPattern") {
|
||||
return true;
|
||||
}
|
||||
return ConditionalExpression(node, parent, parentId);
|
||||
}
|
||||
function Identifier(node, parent, parentId, tokenContext, getRawIdentifier) {
|
||||
var _node$extra;
|
||||
if (getRawIdentifier && getRawIdentifier(node) !== node.name) {
|
||||
return false;
|
||||
}
|
||||
if (parentId === 6 && (_node$extra = node.extra) != null && _node$extra.parenthesized && parent.left === node) {
|
||||
const rightType = parent.right.type;
|
||||
if ((rightType === "FunctionExpression" || rightType === "ClassExpression") && parent.right.id == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (tokenContext & _index.TokenContext.forOfHead || (parentId === 108 || parentId === 132) && tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.forInitHead | _index.TokenContext.forInHead)) {
|
||||
if (node.name === "let") {
|
||||
const isFollowedByBracket = isMemberExpression(parent, {
|
||||
object: node,
|
||||
computed: true
|
||||
}) || isOptionalMemberExpression(parent, {
|
||||
object: node,
|
||||
computed: true,
|
||||
optional: false
|
||||
});
|
||||
if (isFollowedByBracket && tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.forInitHead | _index.TokenContext.forInHead)) {
|
||||
return true;
|
||||
}
|
||||
return (tokenContext & _index.TokenContext.forOfHead) > 0;
|
||||
}
|
||||
}
|
||||
return parentId === 68 && parent.left === node && node.name === "async" && !parent.await;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parentheses.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+19
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.generatorInfosMap = void 0;
|
||||
var generatorFunctions = require("./generators/index.js");
|
||||
var deprecatedGeneratorFunctions = require("./generators/deprecated.js");
|
||||
const generatorInfosMap = exports.generatorInfosMap = new Map();
|
||||
let index = 0;
|
||||
for (const key of Object.keys(generatorFunctions).sort()) {
|
||||
if (key.startsWith("_")) continue;
|
||||
generatorInfosMap.set(key, [generatorFunctions[key], index++, undefined]);
|
||||
}
|
||||
for (const key of Object.keys(deprecatedGeneratorFunctions)) {
|
||||
generatorInfosMap.set(key, [deprecatedGeneratorFunctions[key], index++, undefined]);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=nodes.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["generatorFunctions","require","deprecatedGeneratorFunctions","generatorInfosMap","exports","Map","index","key","Object","keys","sort","startsWith","set","undefined"],"sources":["../src/nodes.ts"],"sourcesContent":["import type * as t from \"@babel/types\";\n\nimport * as generatorFunctions from \"./generators/index.ts\";\nimport * as deprecatedGeneratorFunctions from \"./generators/deprecated.ts\";\nimport type { NodeHandler } from \"./node/index.ts\";\nimport type Printer from \"./printer.ts\";\n\ndeclare global {\n function __node(type: t.Node[\"type\"]): number;\n}\n\nconst generatorInfosMap = new Map<\n string,\n [\n (this: Printer, node: t.Node, parent?: t.Node | null) => void,\n number,\n NodeHandler<boolean> | undefined,\n ]\n>();\nlet index = 0;\n\nfor (const key of Object.keys(generatorFunctions).sort() as Exclude<\n keyof typeof generatorFunctions,\n `_${string}`\n>[]) {\n if (key.startsWith(\"_\")) continue;\n generatorInfosMap.set(key, [generatorFunctions[key], index++, undefined]);\n}\nif (!process.env.BABEL_8_BREAKING) {\n for (const key of Object.keys(\n deprecatedGeneratorFunctions,\n ) as (keyof typeof deprecatedGeneratorFunctions)[]) {\n generatorInfosMap.set(key, [\n deprecatedGeneratorFunctions[key],\n index++,\n undefined,\n ]);\n }\n}\n\nexport { generatorInfosMap };\n"],"mappings":";;;;;;AAEA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,4BAAA,GAAAD,OAAA;AAQA,MAAME,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAIE,GAAG,CAO/B,CAAC;AACH,IAAIC,KAAK,GAAG,CAAC;AAEb,KAAK,MAAMC,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACT,kBAAkB,CAAC,CAACU,IAAI,CAAC,CAAC,EAGnD;EACH,IAAIH,GAAG,CAACI,UAAU,CAAC,GAAG,CAAC,EAAE;EACzBR,iBAAiB,CAACS,GAAG,CAACL,GAAG,EAAE,CAACP,kBAAkB,CAACO,GAAG,CAAC,EAAED,KAAK,EAAE,EAAEO,SAAS,CAAC,CAAC;AAC3E;AAEE,KAAK,MAAMN,GAAG,IAAIC,MAAM,CAACC,IAAI,CAC3BP,4BACF,CAAC,EAAmD;EAClDC,iBAAiB,CAACS,GAAG,CAACL,GAAG,EAAE,CACzBL,4BAA4B,CAACK,GAAG,CAAC,EACjCD,KAAK,EAAE,EACPO,SAAS,CACV,CAAC;AACJ","ignoreList":[]}
|
||||
+782
@@ -0,0 +1,782 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _buffer = require("./buffer.js");
|
||||
var _index = require("./node/index.js");
|
||||
var _nodes = require("./nodes.js");
|
||||
var _t = require("@babel/types");
|
||||
var _tokenMap = require("./token-map.js");
|
||||
var _types2 = require("./generators/types.js");
|
||||
const {
|
||||
isExpression,
|
||||
isFunction,
|
||||
isStatement,
|
||||
isClassBody,
|
||||
isTSInterfaceBody,
|
||||
isTSEnumMember
|
||||
} = _t;
|
||||
const SCIENTIFIC_NOTATION = /e/i;
|
||||
const ZERO_DECIMAL_INTEGER = /\.0+$/;
|
||||
const HAS_NEWLINE = /[\n\r\u2028\u2029]/;
|
||||
const HAS_NEWLINE_OR_BlOCK_COMMENT_END = /[\n\r\u2028\u2029]|\*\//;
|
||||
function commentIsNewline(c) {
|
||||
return c.type === "CommentLine" || HAS_NEWLINE.test(c.value);
|
||||
}
|
||||
class Printer {
|
||||
constructor(format, map, tokens = null, originalCode = null) {
|
||||
this.tokenContext = _index.TokenContext.normal;
|
||||
this._tokens = null;
|
||||
this._originalCode = null;
|
||||
this._currentNode = null;
|
||||
this._currentTypeId = null;
|
||||
this._indent = 0;
|
||||
this._indentRepeat = 0;
|
||||
this._insideAux = false;
|
||||
this._noLineTerminator = false;
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
this._printAuxAfterOnNextUserNode = false;
|
||||
this._printedComments = new Set();
|
||||
this._lastCommentLine = 0;
|
||||
this._innerCommentsState = 0;
|
||||
this._flags = 0;
|
||||
this.tokenMap = null;
|
||||
this._boundGetRawIdentifier = null;
|
||||
this._printSemicolonBeforeNextNode = -1;
|
||||
this._printSemicolonBeforeNextToken = -1;
|
||||
this.format = format;
|
||||
this._tokens = tokens;
|
||||
this._originalCode = originalCode;
|
||||
this._indentRepeat = format.indent.style.length;
|
||||
this._inputMap = (map == null ? void 0 : map._inputMap) || null;
|
||||
this._buf = new _buffer.default(map, format.indent.style[0]);
|
||||
const {
|
||||
preserveFormat,
|
||||
compact,
|
||||
concise,
|
||||
retainLines,
|
||||
retainFunctionParens
|
||||
} = format;
|
||||
if (preserveFormat) {
|
||||
this._flags |= 1;
|
||||
}
|
||||
if (compact) {
|
||||
this._flags |= 2;
|
||||
}
|
||||
if (concise) {
|
||||
this._flags |= 4;
|
||||
}
|
||||
if (retainLines) {
|
||||
this._flags |= 8;
|
||||
}
|
||||
if (retainFunctionParens) {
|
||||
this._flags |= 16;
|
||||
}
|
||||
if (format.auxiliaryCommentBefore || format.auxiliaryCommentAfter) {
|
||||
this._flags |= 32;
|
||||
}
|
||||
}
|
||||
enterDelimited() {
|
||||
const oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
if (oldNoLineTerminatorAfterNode !== null) {
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
}
|
||||
return oldNoLineTerminatorAfterNode;
|
||||
}
|
||||
generate(ast) {
|
||||
if (this.format.preserveFormat) {
|
||||
this.tokenMap = new _tokenMap.TokenMap(ast, this._tokens, this._originalCode);
|
||||
this._boundGetRawIdentifier = _types2._getRawIdentifier.bind(this);
|
||||
}
|
||||
this.print(ast);
|
||||
this._maybeAddAuxComment();
|
||||
return this._buf.get();
|
||||
}
|
||||
indent(flags = this._flags) {
|
||||
if (flags & (1 | 2 | 4)) {
|
||||
return;
|
||||
}
|
||||
this._indent += this._indentRepeat;
|
||||
}
|
||||
dedent(flags = this._flags) {
|
||||
if (flags & (1 | 2 | 4)) {
|
||||
return;
|
||||
}
|
||||
this._indent -= this._indentRepeat;
|
||||
}
|
||||
semicolon(force = false) {
|
||||
const flags = this._flags;
|
||||
if (flags & 32) {
|
||||
this._maybeAddAuxComment();
|
||||
}
|
||||
if (flags & 1) {
|
||||
const node = this._currentNode;
|
||||
if (node.start != null && node.end != null) {
|
||||
if (!this.tokenMap.endMatches(node, ";")) {
|
||||
this._printSemicolonBeforeNextNode = this._buf.getCurrentLine();
|
||||
return;
|
||||
}
|
||||
const indexes = this.tokenMap.getIndexes(this._currentNode);
|
||||
this._catchUpTo(this._tokens[indexes[indexes.length - 1]].loc.start);
|
||||
}
|
||||
}
|
||||
if (force) {
|
||||
this._appendChar(59);
|
||||
} else {
|
||||
this._queue(59);
|
||||
}
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
rightBrace(node) {
|
||||
if (this.format.minified) {
|
||||
this._buf.removeLastSemicolon();
|
||||
}
|
||||
this.sourceWithOffset("end", node.loc, -1);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
rightParens(node) {
|
||||
this.sourceWithOffset("end", node.loc, -1);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
space(force = false) {
|
||||
if (this._flags & (1 | 2)) {
|
||||
return;
|
||||
}
|
||||
if (force) {
|
||||
this._space();
|
||||
} else {
|
||||
const lastCp = this.getLastChar(true);
|
||||
if (lastCp !== 0 && lastCp !== 32 && lastCp !== 10) {
|
||||
this._space();
|
||||
}
|
||||
}
|
||||
}
|
||||
word(str, noLineTerminatorAfter = false) {
|
||||
this.tokenContext &= _index.TokenContext.forInOrInitHeadAccumulatePassThroughMask;
|
||||
this._maybePrintInnerComments(str);
|
||||
const flags = this._flags;
|
||||
if (flags & 32) {
|
||||
this._maybeAddAuxComment();
|
||||
}
|
||||
if (flags & 1) this._catchUpToCurrentToken(str);
|
||||
const lastChar = this.getLastChar();
|
||||
if (lastChar === -2 || lastChar === -3 || lastChar === 47 && str.charCodeAt(0) === 47) {
|
||||
this._space();
|
||||
}
|
||||
this._append(str, false);
|
||||
this.setLastChar(-3);
|
||||
this._noLineTerminator = noLineTerminatorAfter;
|
||||
}
|
||||
number(str, number) {
|
||||
function isNonDecimalLiteral(str) {
|
||||
if (str.length > 2 && str.charCodeAt(0) === 48) {
|
||||
const secondChar = str.charCodeAt(1);
|
||||
return secondChar === 98 || secondChar === 111 || secondChar === 120;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
this.word(str);
|
||||
if (Number.isInteger(number) && !isNonDecimalLiteral(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str.charCodeAt(str.length - 1) !== 46) {
|
||||
this.setLastChar(-2);
|
||||
}
|
||||
}
|
||||
token(str, maybeNewline = false, occurrenceCount = 0, mayNeedSpace = false) {
|
||||
this.tokenContext &= _index.TokenContext.forInOrInitHeadAccumulatePassThroughMask;
|
||||
this._maybePrintInnerComments(str, occurrenceCount);
|
||||
const flags = this._flags;
|
||||
if (flags & 32) {
|
||||
this._maybeAddAuxComment();
|
||||
}
|
||||
if (flags & 1) {
|
||||
this._catchUpToCurrentToken(str, occurrenceCount);
|
||||
}
|
||||
if (mayNeedSpace) {
|
||||
const strFirst = str.charCodeAt(0);
|
||||
if ((strFirst === 45 && str === "--" || strFirst === 61) && this.getLastChar() === 33 || strFirst === 43 && this.getLastChar() === 43 || strFirst === 45 && this.getLastChar() === 45 || strFirst === 46 && this.getLastChar() === -2) {
|
||||
this._space();
|
||||
}
|
||||
}
|
||||
this._append(str, maybeNewline);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
tokenChar(char, occurrenceCount = 0) {
|
||||
this.tokenContext &= _index.TokenContext.forInOrInitHeadAccumulatePassThroughMask;
|
||||
this._maybePrintInnerComments(char, occurrenceCount);
|
||||
const flags = this._flags;
|
||||
if (flags & 32) {
|
||||
this._maybeAddAuxComment();
|
||||
}
|
||||
if (flags & 1) {
|
||||
this._catchUpToCurrentToken(char, occurrenceCount);
|
||||
}
|
||||
if (char === 43 && this.getLastChar() === 43 || char === 45 && this.getLastChar() === 45 || char === 46 && this.getLastChar() === -2) {
|
||||
this._space();
|
||||
}
|
||||
this._appendChar(char);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
newline(i = 1, flags = this._flags) {
|
||||
if (i <= 0) return;
|
||||
if (flags & (8 | 2)) {
|
||||
return;
|
||||
}
|
||||
if (flags & 4) {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
if (i > 2) i = 2;
|
||||
i -= this._buf.getNewlineCount();
|
||||
for (let j = 0; j < i; j++) {
|
||||
this._newline();
|
||||
}
|
||||
}
|
||||
endsWith(char) {
|
||||
return this.getLastChar(true) === char;
|
||||
}
|
||||
getLastChar(checkQueue) {
|
||||
return this._buf.getLastChar(checkQueue);
|
||||
}
|
||||
setLastChar(char) {
|
||||
this._buf._last = char;
|
||||
}
|
||||
exactSource(loc, cb) {
|
||||
if (!loc) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
this._catchUp("start", loc);
|
||||
this._buf.exactSource(loc, cb);
|
||||
}
|
||||
source(prop, loc) {
|
||||
if (!loc) return;
|
||||
this._catchUp(prop, loc);
|
||||
this._buf.source(prop, loc);
|
||||
}
|
||||
sourceWithOffset(prop, loc, columnOffset) {
|
||||
if (!loc || this.format.preserveFormat) return;
|
||||
this._catchUp(prop, loc);
|
||||
this._buf.sourceWithOffset(prop, loc, columnOffset);
|
||||
}
|
||||
sourceIdentifierName(identifierName, pos) {
|
||||
if (!this._buf._canMarkIdName) return;
|
||||
const sourcePosition = this._buf._sourcePosition;
|
||||
sourcePosition.identifierNamePos = pos;
|
||||
sourcePosition.identifierName = identifierName;
|
||||
}
|
||||
_space() {
|
||||
this._queue(32);
|
||||
}
|
||||
_newline() {
|
||||
if (this._buf._queuedChar === 32) this._buf._queuedChar = 0;
|
||||
this._appendChar(10, true);
|
||||
}
|
||||
_catchUpToCurrentToken(str, occurrenceCount = 0) {
|
||||
const token = this.tokenMap.findMatching(this._currentNode, str, occurrenceCount);
|
||||
if (token) this._catchUpTo(token.loc.start);
|
||||
if (this._printSemicolonBeforeNextToken !== -1 && this._printSemicolonBeforeNextToken === this._buf.getCurrentLine()) {
|
||||
this._appendChar(59, true);
|
||||
}
|
||||
this._printSemicolonBeforeNextToken = -1;
|
||||
this._printSemicolonBeforeNextNode = -1;
|
||||
}
|
||||
_append(str, maybeNewline) {
|
||||
this._maybeIndent();
|
||||
this._buf.append(str, maybeNewline);
|
||||
}
|
||||
_appendChar(char, noIndent) {
|
||||
if (!noIndent) {
|
||||
this._maybeIndent();
|
||||
}
|
||||
this._buf.appendChar(char);
|
||||
}
|
||||
_queue(char) {
|
||||
this._buf.queue(char);
|
||||
this.setLastChar(-1);
|
||||
}
|
||||
_maybeIndent() {
|
||||
const indent = this._shouldIndent();
|
||||
if (indent > 0) {
|
||||
this._buf._appendChar(-1, indent, false);
|
||||
}
|
||||
}
|
||||
_shouldIndent() {
|
||||
return this.endsWith(10) ? this._indent : 0;
|
||||
}
|
||||
catchUp(line) {
|
||||
if (!this.format.retainLines) return;
|
||||
const count = line - this._buf.getCurrentLine();
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
}
|
||||
}
|
||||
_catchUp(prop, loc) {
|
||||
const flags = this._flags;
|
||||
if ((flags & 1) === 0) {
|
||||
if (flags & 8 && loc != null && loc[prop]) {
|
||||
this.catchUp(loc[prop].line);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const pos = loc == null ? void 0 : loc[prop];
|
||||
if (pos != null) this._catchUpTo(pos);
|
||||
}
|
||||
_catchUpTo({
|
||||
line,
|
||||
column,
|
||||
index
|
||||
}) {
|
||||
const count = line - this._buf.getCurrentLine();
|
||||
if (count > 0 && this._noLineTerminator) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
}
|
||||
const spacesCount = count > 0 ? column : column - this._buf.getCurrentColumn();
|
||||
if (spacesCount > 0) {
|
||||
const spaces = this._originalCode ? this._originalCode.slice(index - spacesCount, index).replace(/[^\t\x0B\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]/gu, " ") : " ".repeat(spacesCount);
|
||||
this._append(spaces, false);
|
||||
this.setLastChar(32);
|
||||
}
|
||||
}
|
||||
printTerminatorless(node) {
|
||||
this._noLineTerminator = true;
|
||||
this.print(node);
|
||||
}
|
||||
print(node, noLineTerminatorAfter = false, resetTokenContext = false, trailingCommentsLineOffset) {
|
||||
var _node$leadingComments, _node$leadingComments2;
|
||||
if (!node) return;
|
||||
this._innerCommentsState = 0;
|
||||
const {
|
||||
type,
|
||||
loc,
|
||||
extra
|
||||
} = node;
|
||||
const flags = this._flags;
|
||||
let changedFlags = false;
|
||||
if (node._compact) {
|
||||
this._flags |= 4;
|
||||
changedFlags = true;
|
||||
}
|
||||
const nodeInfo = _nodes.generatorInfosMap.get(type);
|
||||
if (nodeInfo === undefined) {
|
||||
throw new ReferenceError(`unknown node of type ${JSON.stringify(type)} with constructor ${JSON.stringify(node.constructor.name)}`);
|
||||
}
|
||||
const [printMethod, nodeId, needsParens] = nodeInfo;
|
||||
const parent = this._currentNode;
|
||||
const parentId = this._currentTypeId;
|
||||
this._currentNode = node;
|
||||
this._currentTypeId = nodeId;
|
||||
if (flags & 1) {
|
||||
this._printSemicolonBeforeNextToken = this._printSemicolonBeforeNextNode;
|
||||
}
|
||||
let oldInAux;
|
||||
if (flags & 32) {
|
||||
oldInAux = this._insideAux;
|
||||
this._insideAux = loc == null;
|
||||
this._maybeAddAuxComment(this._insideAux && !oldInAux);
|
||||
}
|
||||
let oldTokenContext = 0;
|
||||
if (resetTokenContext) {
|
||||
oldTokenContext = this.tokenContext;
|
||||
if (oldTokenContext & _index.TokenContext.forInOrInitHeadAccumulate) {
|
||||
this.tokenContext = 0;
|
||||
} else {
|
||||
oldTokenContext = 0;
|
||||
}
|
||||
}
|
||||
const parenthesized = extra != null && extra.parenthesized;
|
||||
let shouldPrintParens = parenthesized && flags & 1 || parenthesized && flags & 16 && nodeId === 71 || parent && ((0, _index.parentNeedsParens)(node, parent, parentId) || needsParens != null && needsParens(node, parent, parentId, this.tokenContext, flags & 1 ? this._boundGetRawIdentifier : undefined));
|
||||
if (!shouldPrintParens && parenthesized && (_node$leadingComments = node.leadingComments) != null && _node$leadingComments.length && node.leadingComments[0].type === "CommentBlock") {
|
||||
switch (parentId) {
|
||||
case 65:
|
||||
case 243:
|
||||
case 6:
|
||||
case 143:
|
||||
break;
|
||||
case 17:
|
||||
case 130:
|
||||
case 112:
|
||||
if (parent.callee !== node) break;
|
||||
default:
|
||||
shouldPrintParens = true;
|
||||
}
|
||||
}
|
||||
let indentParenthesized = false;
|
||||
if (!shouldPrintParens && this._noLineTerminator && ((_node$leadingComments2 = node.leadingComments) != null && _node$leadingComments2.some(commentIsNewline) || flags & 8 && loc && loc.start.line > this._buf.getCurrentLine())) {
|
||||
shouldPrintParens = true;
|
||||
indentParenthesized = true;
|
||||
}
|
||||
let oldNoLineTerminatorAfterNode;
|
||||
if (!shouldPrintParens) {
|
||||
noLineTerminatorAfter || (noLineTerminatorAfter = !!parent && this._noLineTerminatorAfterNode === parent && (0, _index.isLastChild)(parent, node));
|
||||
if (noLineTerminatorAfter) {
|
||||
var _node$trailingComment;
|
||||
if ((_node$trailingComment = node.trailingComments) != null && _node$trailingComment.some(commentIsNewline)) {
|
||||
if (isExpression(node)) shouldPrintParens = true;
|
||||
} else {
|
||||
oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
this._noLineTerminatorAfterNode = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shouldPrintParens) {
|
||||
this.tokenChar(40);
|
||||
if (indentParenthesized) this.indent();
|
||||
this._innerCommentsState = 0;
|
||||
if (!resetTokenContext) {
|
||||
oldTokenContext = this.tokenContext;
|
||||
}
|
||||
if (oldTokenContext & _index.TokenContext.forInOrInitHeadAccumulate) {
|
||||
this.tokenContext = 0;
|
||||
}
|
||||
oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
}
|
||||
this._printLeadingComments(node, parent);
|
||||
this.exactSource(nodeId === 139 || nodeId === 66 ? null : loc, printMethod.bind(this, node, parent));
|
||||
if (shouldPrintParens) {
|
||||
this._printTrailingComments(node, parent);
|
||||
if (indentParenthesized) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this._noLineTerminator = noLineTerminatorAfter;
|
||||
} else if (noLineTerminatorAfter && !this._noLineTerminator) {
|
||||
this._noLineTerminator = true;
|
||||
this._printTrailingComments(node, parent);
|
||||
} else {
|
||||
this._printTrailingComments(node, parent, trailingCommentsLineOffset);
|
||||
}
|
||||
if (oldTokenContext) this.tokenContext = oldTokenContext;
|
||||
this._currentNode = parent;
|
||||
this._currentTypeId = parentId;
|
||||
if (changedFlags) {
|
||||
this._flags = flags;
|
||||
}
|
||||
if (flags & 32) {
|
||||
this._insideAux = oldInAux;
|
||||
}
|
||||
if (oldNoLineTerminatorAfterNode != null) {
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
}
|
||||
this._innerCommentsState = 0;
|
||||
}
|
||||
_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
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
_printAuxAfterComment() {
|
||||
if (!this._printAuxAfterOnNextUserNode) return;
|
||||
this._printAuxAfterOnNextUserNode = false;
|
||||
const comment = this.format.auxiliaryCommentAfter;
|
||||
if (comment) {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
value: comment
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
getPossibleRaw(node) {
|
||||
const extra = node.extra;
|
||||
if ((extra == null ? void 0 : extra.raw) != null && extra.rawValue != null && node.value === extra.rawValue) {
|
||||
return extra.raw;
|
||||
}
|
||||
}
|
||||
printJoin(nodes, statement, indent, separator, printTrailingSeparator, resetTokenContext, trailingCommentsLineOffset) {
|
||||
if (!(nodes != null && nodes.length)) return;
|
||||
const flags = this._flags;
|
||||
if (indent == null && flags & 8) {
|
||||
var _nodes$0$loc;
|
||||
const startLine = (_nodes$0$loc = nodes[0].loc) == null ? void 0 : _nodes$0$loc.start.line;
|
||||
if (startLine != null && startLine !== this._buf.getCurrentLine()) {
|
||||
indent = true;
|
||||
}
|
||||
}
|
||||
if (indent) this.indent(flags);
|
||||
const len = nodes.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const node = nodes[i];
|
||||
if (!node) continue;
|
||||
if (statement && i === 0 && this._buf.hasContent()) {
|
||||
this.newline(1, flags);
|
||||
}
|
||||
this.print(node, false, resetTokenContext, trailingCommentsLineOffset || 0);
|
||||
if (separator != null) {
|
||||
if (i < len - 1) separator.call(this, i, false);else if (printTrailingSeparator) separator.call(this, i, true);
|
||||
}
|
||||
if (statement) {
|
||||
if (i + 1 === len) {
|
||||
this.newline(1, flags);
|
||||
} else {
|
||||
const lastCommentLine = this._lastCommentLine;
|
||||
if (lastCommentLine > 0) {
|
||||
var _nodes$loc;
|
||||
const offset = (((_nodes$loc = nodes[i + 1].loc) == null ? void 0 : _nodes$loc.start.line) || 0) - lastCommentLine;
|
||||
if (offset >= 0) {
|
||||
this.newline(offset || 1, flags);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
this.newline(1, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (indent) this.dedent(flags);
|
||||
}
|
||||
printAndIndentOnComments(node) {
|
||||
const indent = node.leadingComments && node.leadingComments.length > 0;
|
||||
if (indent) this.indent();
|
||||
this.print(node);
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
printBlock(body) {
|
||||
if (body.type !== "EmptyStatement") {
|
||||
this.space();
|
||||
}
|
||||
this.print(body);
|
||||
}
|
||||
_printTrailingComments(node, parent, lineOffset) {
|
||||
const {
|
||||
innerComments,
|
||||
trailingComments
|
||||
} = node;
|
||||
if (innerComments != null && innerComments.length) {
|
||||
this._printComments(2, innerComments, node, parent, lineOffset);
|
||||
}
|
||||
if (trailingComments != null && trailingComments.length) {
|
||||
this._printComments(2, trailingComments, node, parent, lineOffset);
|
||||
} else {
|
||||
this._lastCommentLine = 0;
|
||||
}
|
||||
}
|
||||
_printLeadingComments(node, parent) {
|
||||
const comments = node.leadingComments;
|
||||
if (!(comments != null && comments.length)) return;
|
||||
this._printComments(0, comments, node, parent);
|
||||
}
|
||||
_maybePrintInnerComments(nextTokenStr, nextTokenOccurrenceCount) {
|
||||
var _this$tokenMap;
|
||||
const state = this._innerCommentsState;
|
||||
switch (state & 3) {
|
||||
case 0:
|
||||
this._innerCommentsState = 1 | 4;
|
||||
return;
|
||||
case 1:
|
||||
this.printInnerComments((state & 4) > 0, (_this$tokenMap = this.tokenMap) == null ? void 0 : _this$tokenMap.findMatching(this._currentNode, nextTokenStr, nextTokenOccurrenceCount));
|
||||
}
|
||||
}
|
||||
printInnerComments(indent = true, nextToken) {
|
||||
const node = this._currentNode;
|
||||
const comments = node.innerComments;
|
||||
if (!(comments != null && comments.length)) {
|
||||
this._innerCommentsState = 2;
|
||||
return;
|
||||
}
|
||||
const hasSpace = this.endsWith(32);
|
||||
if (indent) this.indent();
|
||||
switch (this._printComments(1, comments, node, undefined, undefined, nextToken)) {
|
||||
case 2:
|
||||
this._innerCommentsState = 2;
|
||||
case 1:
|
||||
if (hasSpace) this.space();
|
||||
}
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
noIndentInnerCommentsHere() {
|
||||
this._innerCommentsState &= ~4;
|
||||
}
|
||||
printSequence(nodes, indent, resetTokenContext, trailingCommentsLineOffset) {
|
||||
this.printJoin(nodes, true, indent != null ? indent : false, undefined, undefined, resetTokenContext, trailingCommentsLineOffset);
|
||||
}
|
||||
printList(items, printTrailingSeparator, statement, indent, separator, resetTokenContext) {
|
||||
this.printJoin(items, statement, indent, separator != null ? separator : commaSeparator, printTrailingSeparator, resetTokenContext);
|
||||
}
|
||||
shouldPrintTrailingComma(listEnd) {
|
||||
if (!this.tokenMap) return null;
|
||||
const listEndIndex = this.tokenMap.findLastIndex(this._currentNode, token => this.tokenMap.matchesOriginal(token, typeof listEnd === "number" ? String.fromCharCode(listEnd) : listEnd));
|
||||
if (listEndIndex <= 0) return null;
|
||||
return this.tokenMap.matchesOriginal(this._tokens[listEndIndex - 1], ",");
|
||||
}
|
||||
_shouldPrintComment(comment, nextToken) {
|
||||
if (comment.ignore) return 0;
|
||||
if (this._printedComments.has(comment)) return 0;
|
||||
if (this._noLineTerminator && HAS_NEWLINE_OR_BlOCK_COMMENT_END.test(comment.value)) {
|
||||
return 2;
|
||||
}
|
||||
if (nextToken && this.tokenMap) {
|
||||
const commentTok = this.tokenMap.find(this._currentNode, token => token.value === comment.value);
|
||||
if (commentTok && commentTok.start > nextToken.start) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
this._printedComments.add(comment);
|
||||
if (!this.format.shouldPrintComment(comment.value)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
_printComment(comment, skipNewLines) {
|
||||
const noLineTerminator = this._noLineTerminator;
|
||||
const isBlockComment = comment.type === "CommentBlock";
|
||||
const printNewLines = isBlockComment && skipNewLines !== 1 && !noLineTerminator;
|
||||
if (printNewLines && this._buf.hasContent() && skipNewLines !== 2) {
|
||||
this.newline(1);
|
||||
}
|
||||
switch (this.getLastChar(true)) {
|
||||
case 47:
|
||||
this._space();
|
||||
case 91:
|
||||
case 123:
|
||||
case 40:
|
||||
break;
|
||||
default:
|
||||
this.space();
|
||||
}
|
||||
let val;
|
||||
if (isBlockComment) {
|
||||
val = `/*${comment.value}*/`;
|
||||
if (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");
|
||||
}
|
||||
if (this._flags & 4) {
|
||||
val = val.replace(/\n(?!$)/g, `\n`);
|
||||
} else {
|
||||
let indentSize = this.format.retainLines ? 0 : this._buf.getCurrentColumn();
|
||||
if (this._shouldIndent() || this.format.retainLines) {
|
||||
indentSize += this._indent;
|
||||
}
|
||||
val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);
|
||||
}
|
||||
}
|
||||
} else if (!noLineTerminator) {
|
||||
val = `//${comment.value}`;
|
||||
} else {
|
||||
val = `/*${comment.value}*/`;
|
||||
}
|
||||
this.source("start", comment.loc);
|
||||
this._append(val, isBlockComment);
|
||||
if (!isBlockComment && !noLineTerminator) {
|
||||
this._newline();
|
||||
}
|
||||
if (printNewLines && skipNewLines !== 3) {
|
||||
this.newline(1);
|
||||
}
|
||||
}
|
||||
_printComments(type, comments, node, parent, lineOffset = 0, nextToken) {
|
||||
const nodeLoc = node.loc;
|
||||
const len = comments.length;
|
||||
let hasLoc = !!nodeLoc;
|
||||
const nodeStartLine = hasLoc ? nodeLoc.start.line : 0;
|
||||
const nodeEndLine = hasLoc ? nodeLoc.end.line : 0;
|
||||
let lastLine = 0;
|
||||
let leadingCommentNewline = 0;
|
||||
const {
|
||||
_noLineTerminator,
|
||||
_flags
|
||||
} = this;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const comment = comments[i];
|
||||
const shouldPrint = this._shouldPrintComment(comment, nextToken);
|
||||
if (shouldPrint === 2) {
|
||||
return i === 0 ? 0 : 1;
|
||||
}
|
||||
if (hasLoc && comment.loc && shouldPrint === 1) {
|
||||
const commentStartLine = comment.loc.start.line;
|
||||
const commentEndLine = comment.loc.end.line;
|
||||
if (type === 0) {
|
||||
let offset = 0;
|
||||
if (i === 0) {
|
||||
if (this._buf.hasContent() && (comment.type === "CommentLine" || commentStartLine !== commentEndLine)) {
|
||||
offset = leadingCommentNewline = 1;
|
||||
}
|
||||
} else {
|
||||
offset = commentStartLine - lastLine;
|
||||
}
|
||||
lastLine = commentEndLine;
|
||||
if (offset > 0 && !_noLineTerminator) {
|
||||
this.newline(offset, _flags);
|
||||
}
|
||||
this._printComment(comment, 1);
|
||||
if (i + 1 === len) {
|
||||
const count = Math.max(nodeStartLine - lastLine, leadingCommentNewline);
|
||||
if (count > 0 && !_noLineTerminator) {
|
||||
this.newline(count, _flags);
|
||||
}
|
||||
lastLine = nodeStartLine;
|
||||
}
|
||||
} else if (type === 1) {
|
||||
const offset = commentStartLine - (i === 0 ? nodeStartLine : lastLine);
|
||||
lastLine = commentEndLine;
|
||||
if (offset > 0 && !_noLineTerminator) {
|
||||
this.newline(offset, _flags);
|
||||
}
|
||||
this._printComment(comment, 1);
|
||||
if (i + 1 === len) {
|
||||
const count = Math.min(1, nodeEndLine - lastLine);
|
||||
if (count > 0 && !_noLineTerminator) {
|
||||
this.newline(count, _flags);
|
||||
}
|
||||
lastLine = nodeEndLine;
|
||||
}
|
||||
} else {
|
||||
const offset = commentStartLine - (i === 0 ? nodeEndLine - lineOffset : lastLine);
|
||||
lastLine = commentEndLine;
|
||||
if (offset > 0 && !_noLineTerminator) {
|
||||
this.newline(offset, _flags);
|
||||
}
|
||||
this._printComment(comment, 1);
|
||||
}
|
||||
} else {
|
||||
hasLoc = false;
|
||||
if (shouldPrint !== 1) {
|
||||
continue;
|
||||
}
|
||||
if (len === 1) {
|
||||
const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !HAS_NEWLINE.test(comment.value);
|
||||
const shouldSkipNewline = singleLine && !isStatement(node) && !isClassBody(parent) && !isTSInterfaceBody(parent) && !isTSEnumMember(node);
|
||||
if (type === 0) {
|
||||
this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent) && parent.body === node ? 1 : 0);
|
||||
} else if (shouldSkipNewline && type === 2) {
|
||||
this._printComment(comment, 1);
|
||||
} else {
|
||||
this._printComment(comment, 0);
|
||||
}
|
||||
} else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") {
|
||||
this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);
|
||||
} else {
|
||||
this._printComment(comment, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type === 2 && hasLoc && lastLine) {
|
||||
this._lastCommentLine = lastLine;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
var _default = exports.default = Printer;
|
||||
function commaSeparator(occurrenceCount, last) {
|
||||
this.tokenChar(44, occurrenceCount);
|
||||
if (!last) this.space();
|
||||
}
|
||||
|
||||
//# sourceMappingURL=printer.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+86
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _genMapping = require("@jridgewell/gen-mapping");
|
||||
var _traceMapping = require("@jridgewell/trace-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;
|
||||
this._inputMap = null;
|
||||
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 (opts.inputSourceMap) {
|
||||
this._inputMap = new _traceMapping.TraceMap(opts.inputSourceMap);
|
||||
const resolvedSources = this._inputMap.resolvedSources;
|
||||
if (resolvedSources.length) {
|
||||
for (let i = 0; i < resolvedSources.length; i++) {
|
||||
var _this$_inputMap$sourc;
|
||||
(0, _genMapping.setSourceContent)(map, resolvedSources[i], (_this$_inputMap$sourc = this._inputMap.sourcesContent) == null ? void 0 : _this$_inputMap$sourc[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof code === "string" && !opts.inputSourceMap) {
|
||||
(0, _genMapping.setSourceContent)(map, this._sourceFileName, code);
|
||||
} else if (typeof code === "object") {
|
||||
for (const sourceFileName of Object.keys(code)) {
|
||||
(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, identifierNamePos, filename) {
|
||||
var _originalMapping;
|
||||
this._rawMappings = undefined;
|
||||
let originalMapping;
|
||||
if (line != null) {
|
||||
if (this._inputMap) {
|
||||
originalMapping = (0, _traceMapping.originalPositionFor)(this._inputMap, {
|
||||
line,
|
||||
column: column
|
||||
});
|
||||
if (!originalMapping.name && identifierNamePos) {
|
||||
const originalIdentifierMapping = (0, _traceMapping.originalPositionFor)(this._inputMap, identifierNamePos);
|
||||
if (originalIdentifierMapping.name) {
|
||||
identifierName = originalIdentifierMapping.name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
originalMapping = {
|
||||
name: null,
|
||||
source: (filename == null ? void 0 : filename.replace(/\\/g, "/")) || this._sourceFileName,
|
||||
line: line,
|
||||
column: column
|
||||
};
|
||||
}
|
||||
}
|
||||
(0, _genMapping.maybeAddMapping)(this._map, {
|
||||
name: identifierName,
|
||||
generated,
|
||||
source: (_originalMapping = originalMapping) == null ? void 0 : _originalMapping.source,
|
||||
original: originalMapping
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = SourceMap;
|
||||
|
||||
//# sourceMappingURL=source-map.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+195
@@ -0,0 +1,195 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TokenMap = void 0;
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
traverseFast,
|
||||
VISITOR_KEYS
|
||||
} = _t;
|
||||
class TokenMap {
|
||||
constructor(ast, tokens, source) {
|
||||
this._tokens = void 0;
|
||||
this._source = void 0;
|
||||
this._nodesToTokenIndexes = new Map();
|
||||
this._nodesOccurrencesCountCache = new Map();
|
||||
this._tokensCache = new Map();
|
||||
this._tokens = tokens;
|
||||
this._source = source;
|
||||
traverseFast(ast, node => {
|
||||
const indexes = this._getTokensIndexesOfNode(node);
|
||||
if (indexes.length > 0) this._nodesToTokenIndexes.set(node, indexes);
|
||||
});
|
||||
this._tokensCache.clear();
|
||||
}
|
||||
has(node) {
|
||||
return this._nodesToTokenIndexes.has(node);
|
||||
}
|
||||
getIndexes(node) {
|
||||
return this._nodesToTokenIndexes.get(node);
|
||||
}
|
||||
find(node, condition) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
for (let k = 0; k < indexes.length; k++) {
|
||||
const index = indexes[k];
|
||||
const tok = this._tokens[index];
|
||||
if (condition(tok, index)) return tok;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
findLastIndex(node, condition) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
for (let k = indexes.length - 1; k >= 0; k--) {
|
||||
const index = indexes[k];
|
||||
const tok = this._tokens[index];
|
||||
if (condition(tok, index)) return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
findMatching(node, test, occurrenceCount = 0) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
if (typeof test === "number") {
|
||||
test = String.fromCharCode(test);
|
||||
}
|
||||
let i = 0;
|
||||
const count = occurrenceCount;
|
||||
if (count > 1) {
|
||||
const cache = this._nodesOccurrencesCountCache.get(node);
|
||||
if ((cache == null ? void 0 : cache.test) === test && cache.count < count) {
|
||||
i = cache.i + 1;
|
||||
occurrenceCount -= cache.count + 1;
|
||||
}
|
||||
}
|
||||
for (; i < indexes.length; i++) {
|
||||
const tok = this._tokens[indexes[i]];
|
||||
if (this.matchesOriginal(tok, test)) {
|
||||
if (occurrenceCount === 0) {
|
||||
if (count > 0) {
|
||||
this._nodesOccurrencesCountCache.set(node, {
|
||||
test,
|
||||
count,
|
||||
i
|
||||
});
|
||||
}
|
||||
return tok;
|
||||
}
|
||||
occurrenceCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
matchesOriginal(token, test) {
|
||||
if (token.end - token.start !== test.length) return false;
|
||||
if (token.value != null) return token.value === test;
|
||||
return this._source.startsWith(test, token.start);
|
||||
}
|
||||
startMatches(node, test) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (!indexes) return false;
|
||||
const tok = this._tokens[indexes[0]];
|
||||
if (tok.start !== node.start) return false;
|
||||
return this.matchesOriginal(tok, test);
|
||||
}
|
||||
endMatches(node, test) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (!indexes) return false;
|
||||
const tok = this._tokens[indexes[indexes.length - 1]];
|
||||
if (tok.end !== node.end) return false;
|
||||
return this.matchesOriginal(tok, test);
|
||||
}
|
||||
_getTokensIndexesOfNode(node) {
|
||||
var _node$declaration;
|
||||
if (node.start == null || node.end == null) return [];
|
||||
const {
|
||||
first,
|
||||
last
|
||||
} = this._findTokensOfNode(node, 0, this._tokens.length - 1);
|
||||
let low = first;
|
||||
const children = childrenIterator(node);
|
||||
if ((node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") && ((_node$declaration = node.declaration) == null ? void 0 : _node$declaration.type) === "ClassDeclaration") {
|
||||
children.next();
|
||||
}
|
||||
const indexes = [];
|
||||
for (const child of children) {
|
||||
if (child == null) continue;
|
||||
if (child.start == null || child.end == null) continue;
|
||||
const childTok = this._findTokensOfNode(child, low, last);
|
||||
const high = childTok.first;
|
||||
for (let k = low; k < high; k++) indexes.push(k);
|
||||
low = childTok.last + 1;
|
||||
}
|
||||
for (let k = low; k <= last; k++) indexes.push(k);
|
||||
return indexes;
|
||||
}
|
||||
_findTokensOfNode(node, low, high) {
|
||||
const cached = this._tokensCache.get(node);
|
||||
if (cached) return cached;
|
||||
const first = this._findFirstTokenOfNode(node.start, low, high);
|
||||
const last = this._findLastTokenOfNode(node.end, first, high);
|
||||
this._tokensCache.set(node, {
|
||||
first,
|
||||
last
|
||||
});
|
||||
return {
|
||||
first,
|
||||
last
|
||||
};
|
||||
}
|
||||
_findFirstTokenOfNode(start, low, high) {
|
||||
while (low <= high) {
|
||||
const mid = high + low >> 1;
|
||||
if (start < this._tokens[mid].start) {
|
||||
high = mid - 1;
|
||||
} else if (start > this._tokens[mid].start) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
return low;
|
||||
}
|
||||
_findLastTokenOfNode(end, low, high) {
|
||||
while (low <= high) {
|
||||
const mid = high + low >> 1;
|
||||
if (end < this._tokens[mid].end) {
|
||||
high = mid - 1;
|
||||
} else if (end > this._tokens[mid].end) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
return high;
|
||||
}
|
||||
}
|
||||
exports.TokenMap = TokenMap;
|
||||
function* childrenIterator(node) {
|
||||
if (node.type === "TemplateLiteral") {
|
||||
yield node.quasis[0];
|
||||
for (let i = 1; i < node.quasis.length; i++) {
|
||||
yield node.expressions[i - 1];
|
||||
yield node.quasis[i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
const keys = VISITOR_KEYS[node.type];
|
||||
for (const key of keys) {
|
||||
const child = node[key];
|
||||
if (!child) continue;
|
||||
if (Array.isArray(child)) {
|
||||
yield* child;
|
||||
} else {
|
||||
yield child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=token-map.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+39
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.29.1",
|
||||
"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/parser": "^7.29.0",
|
||||
"@babel/types": "^7.29.0",
|
||||
"@jridgewell/gen-mapping": "^0.3.12",
|
||||
"@jridgewell/trace-mapping": "^0.3.28",
|
||||
"jsesc": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.29.0",
|
||||
"@babel/helper-fixtures": "^7.28.6",
|
||||
"@babel/plugin-transform-typescript": "^7.28.6",
|
||||
"@jridgewell/sourcemap-codec": "^1.5.3",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"type": "commonjs"
|
||||
}
|
||||
+22
@@ -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
@@ -0,0 +1,19 @@
|
||||
# @babel/helper-string-parser
|
||||
|
||||
> A utility package to parse strings
|
||||
|
||||
See our website [@babel/helper-string-parser](https://babeljs.io/docs/babel-helper-string-parser) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-string-parser
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-string-parser
|
||||
```
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.readCodePoint = readCodePoint;
|
||||
exports.readInt = readInt;
|
||||
exports.readStringContents = readStringContents;
|
||||
var _isDigit = function isDigit(code) {
|
||||
return code >= 48 && code <= 57;
|
||||
};
|
||||
const forbiddenNumericSeparatorSiblings = {
|
||||
decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]),
|
||||
hex: new Set([46, 88, 95, 120])
|
||||
};
|
||||
const isAllowedNumericSeparatorSibling = {
|
||||
bin: ch => ch === 48 || ch === 49,
|
||||
oct: ch => ch >= 48 && ch <= 55,
|
||||
dec: ch => ch >= 48 && ch <= 57,
|
||||
hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
|
||||
};
|
||||
function readStringContents(type, input, pos, lineStart, curLine, errors) {
|
||||
const initialPos = pos;
|
||||
const initialLineStart = lineStart;
|
||||
const initialCurLine = curLine;
|
||||
let out = "";
|
||||
let firstInvalidLoc = null;
|
||||
let chunkStart = pos;
|
||||
const {
|
||||
length
|
||||
} = input;
|
||||
for (;;) {
|
||||
if (pos >= length) {
|
||||
errors.unterminated(initialPos, initialLineStart, initialCurLine);
|
||||
out += input.slice(chunkStart, pos);
|
||||
break;
|
||||
}
|
||||
const ch = input.charCodeAt(pos);
|
||||
if (isStringEnd(type, ch, input, pos)) {
|
||||
out += input.slice(chunkStart, pos);
|
||||
break;
|
||||
}
|
||||
if (ch === 92) {
|
||||
out += input.slice(chunkStart, pos);
|
||||
const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
|
||||
if (res.ch === null && !firstInvalidLoc) {
|
||||
firstInvalidLoc = {
|
||||
pos,
|
||||
lineStart,
|
||||
curLine
|
||||
};
|
||||
} else {
|
||||
out += res.ch;
|
||||
}
|
||||
({
|
||||
pos,
|
||||
lineStart,
|
||||
curLine
|
||||
} = res);
|
||||
chunkStart = pos;
|
||||
} else if (ch === 8232 || ch === 8233) {
|
||||
++pos;
|
||||
++curLine;
|
||||
lineStart = pos;
|
||||
} else if (ch === 10 || ch === 13) {
|
||||
if (type === "template") {
|
||||
out += input.slice(chunkStart, pos) + "\n";
|
||||
++pos;
|
||||
if (ch === 13 && input.charCodeAt(pos) === 10) {
|
||||
++pos;
|
||||
}
|
||||
++curLine;
|
||||
chunkStart = lineStart = pos;
|
||||
} else {
|
||||
errors.unterminated(initialPos, initialLineStart, initialCurLine);
|
||||
}
|
||||
} else {
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
return {
|
||||
pos,
|
||||
str: out,
|
||||
firstInvalidLoc,
|
||||
lineStart,
|
||||
curLine,
|
||||
containsInvalid: !!firstInvalidLoc
|
||||
};
|
||||
}
|
||||
function isStringEnd(type, ch, input, pos) {
|
||||
if (type === "template") {
|
||||
return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123;
|
||||
}
|
||||
return ch === (type === "double" ? 34 : 39);
|
||||
}
|
||||
function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
|
||||
const throwOnInvalid = !inTemplate;
|
||||
pos++;
|
||||
const res = ch => ({
|
||||
pos,
|
||||
ch,
|
||||
lineStart,
|
||||
curLine
|
||||
});
|
||||
const ch = input.charCodeAt(pos++);
|
||||
switch (ch) {
|
||||
case 110:
|
||||
return res("\n");
|
||||
case 114:
|
||||
return res("\r");
|
||||
case 120:
|
||||
{
|
||||
let code;
|
||||
({
|
||||
code,
|
||||
pos
|
||||
} = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
|
||||
return res(code === null ? null : String.fromCharCode(code));
|
||||
}
|
||||
case 117:
|
||||
{
|
||||
let code;
|
||||
({
|
||||
code,
|
||||
pos
|
||||
} = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
|
||||
return res(code === null ? null : String.fromCodePoint(code));
|
||||
}
|
||||
case 116:
|
||||
return res("\t");
|
||||
case 98:
|
||||
return res("\b");
|
||||
case 118:
|
||||
return res("\u000b");
|
||||
case 102:
|
||||
return res("\f");
|
||||
case 13:
|
||||
if (input.charCodeAt(pos) === 10) {
|
||||
++pos;
|
||||
}
|
||||
case 10:
|
||||
lineStart = pos;
|
||||
++curLine;
|
||||
case 8232:
|
||||
case 8233:
|
||||
return res("");
|
||||
case 56:
|
||||
case 57:
|
||||
if (inTemplate) {
|
||||
return res(null);
|
||||
} else {
|
||||
errors.strictNumericEscape(pos - 1, lineStart, curLine);
|
||||
}
|
||||
default:
|
||||
if (ch >= 48 && ch <= 55) {
|
||||
const startPos = pos - 1;
|
||||
const match = /^[0-7]+/.exec(input.slice(startPos, pos + 2));
|
||||
let octalStr = match[0];
|
||||
let octal = parseInt(octalStr, 8);
|
||||
if (octal > 255) {
|
||||
octalStr = octalStr.slice(0, -1);
|
||||
octal = parseInt(octalStr, 8);
|
||||
}
|
||||
pos += octalStr.length - 1;
|
||||
const next = input.charCodeAt(pos);
|
||||
if (octalStr !== "0" || next === 56 || next === 57) {
|
||||
if (inTemplate) {
|
||||
return res(null);
|
||||
} else {
|
||||
errors.strictNumericEscape(startPos, lineStart, curLine);
|
||||
}
|
||||
}
|
||||
return res(String.fromCharCode(octal));
|
||||
}
|
||||
return res(String.fromCharCode(ch));
|
||||
}
|
||||
}
|
||||
function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
|
||||
const initialPos = pos;
|
||||
let n;
|
||||
({
|
||||
n,
|
||||
pos
|
||||
} = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
|
||||
if (n === null) {
|
||||
if (throwOnInvalid) {
|
||||
errors.invalidEscapeSequence(initialPos, lineStart, curLine);
|
||||
} else {
|
||||
pos = initialPos - 1;
|
||||
}
|
||||
}
|
||||
return {
|
||||
code: n,
|
||||
pos
|
||||
};
|
||||
}
|
||||
function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
|
||||
const start = pos;
|
||||
const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
|
||||
const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
|
||||
let invalid = false;
|
||||
let total = 0;
|
||||
for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
|
||||
const code = input.charCodeAt(pos);
|
||||
let val;
|
||||
if (code === 95 && allowNumSeparator !== "bail") {
|
||||
const prev = input.charCodeAt(pos - 1);
|
||||
const next = input.charCodeAt(pos + 1);
|
||||
if (!allowNumSeparator) {
|
||||
if (bailOnError) return {
|
||||
n: null,
|
||||
pos
|
||||
};
|
||||
errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
|
||||
} else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) {
|
||||
if (bailOnError) return {
|
||||
n: null,
|
||||
pos
|
||||
};
|
||||
errors.unexpectedNumericSeparator(pos, lineStart, curLine);
|
||||
}
|
||||
++pos;
|
||||
continue;
|
||||
}
|
||||
if (code >= 97) {
|
||||
val = code - 97 + 10;
|
||||
} else if (code >= 65) {
|
||||
val = code - 65 + 10;
|
||||
} else if (_isDigit(code)) {
|
||||
val = code - 48;
|
||||
} else {
|
||||
val = Infinity;
|
||||
}
|
||||
if (val >= radix) {
|
||||
if (val <= 9 && bailOnError) {
|
||||
return {
|
||||
n: null,
|
||||
pos
|
||||
};
|
||||
} else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
|
||||
val = 0;
|
||||
} else if (forceLen) {
|
||||
val = 0;
|
||||
invalid = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
++pos;
|
||||
total = total * radix + val;
|
||||
}
|
||||
if (pos === start || len != null && pos - start !== len || invalid) {
|
||||
return {
|
||||
n: null,
|
||||
pos
|
||||
};
|
||||
}
|
||||
return {
|
||||
n: total,
|
||||
pos
|
||||
};
|
||||
}
|
||||
function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
|
||||
const ch = input.charCodeAt(pos);
|
||||
let code;
|
||||
if (ch === 123) {
|
||||
++pos;
|
||||
({
|
||||
code,
|
||||
pos
|
||||
} = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
|
||||
++pos;
|
||||
if (code !== null && code > 0x10ffff) {
|
||||
if (throwOnInvalid) {
|
||||
errors.invalidCodePoint(pos, lineStart, curLine);
|
||||
} else {
|
||||
return {
|
||||
code: null,
|
||||
pos
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
({
|
||||
code,
|
||||
pos
|
||||
} = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
|
||||
}
|
||||
return {
|
||||
code,
|
||||
pos
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+31
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@babel/helper-string-parser",
|
||||
"version": "7.27.1",
|
||||
"description": "A utility package to parse strings",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-helper-string-parser"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-helper-string-parser",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"devDependencies": {
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"type": "commonjs"
|
||||
}
|
||||
+22
@@ -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
@@ -0,0 +1,19 @@
|
||||
# @babel/helper-validator-identifier
|
||||
|
||||
> Validate identifier/keywords name
|
||||
|
||||
See our website [@babel/helper-validator-identifier](https://babeljs.io/docs/babel-helper-validator-identifier) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-validator-identifier
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-validator-identifier
|
||||
```
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isIdentifierChar = isIdentifierChar;
|
||||
exports.isIdentifierName = isIdentifierName;
|
||||
exports.isIdentifierStart = isIdentifierStart;
|
||||
let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088f\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5c\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdc-\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c8a\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7dc\ua7f1-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
|
||||
let nonASCIIidentifierChars = "\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0897-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1add\u1ae0-\u1aeb\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
|
||||
const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
||||
const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
||||
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
|
||||
const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 7, 25, 39, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 5, 57, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 24, 43, 261, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 33, 24, 3, 24, 45, 74, 6, 0, 67, 12, 65, 1, 2, 0, 15, 4, 10, 7381, 42, 31, 98, 114, 8702, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 208, 30, 2, 2, 2, 1, 2, 6, 3, 4, 10, 1, 225, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4381, 3, 5773, 3, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 8489];
|
||||
const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 78, 5, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 199, 7, 137, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 55, 9, 266, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 233, 0, 3, 0, 8, 1, 6, 0, 475, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
||||
function isInAstralSet(code, set) {
|
||||
let pos = 0x10000;
|
||||
for (let i = 0, length = set.length; i < length; i += 2) {
|
||||
pos += set[i];
|
||||
if (pos > code) return false;
|
||||
pos += set[i + 1];
|
||||
if (pos >= code) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isIdentifierStart(code) {
|
||||
if (code < 65) return code === 36;
|
||||
if (code <= 90) return true;
|
||||
if (code < 97) return code === 95;
|
||||
if (code <= 122) return true;
|
||||
if (code <= 0xffff) {
|
||||
return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
|
||||
}
|
||||
return isInAstralSet(code, astralIdentifierStartCodes);
|
||||
}
|
||||
function isIdentifierChar(code) {
|
||||
if (code < 48) return code === 36;
|
||||
if (code < 58) return true;
|
||||
if (code < 65) return false;
|
||||
if (code <= 90) return true;
|
||||
if (code < 97) return code === 95;
|
||||
if (code <= 122) return true;
|
||||
if (code <= 0xffff) {
|
||||
return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
|
||||
}
|
||||
return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
|
||||
}
|
||||
function isIdentifierName(name) {
|
||||
let isFirst = true;
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
let cp = name.charCodeAt(i);
|
||||
if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
|
||||
const trail = name.charCodeAt(++i);
|
||||
if ((trail & 0xfc00) === 0xdc00) {
|
||||
cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
|
||||
}
|
||||
}
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
if (!isIdentifierStart(cp)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!isIdentifierChar(cp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !isFirst;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=identifier.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+57
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierChar", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierChar;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierName", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierName;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isIdentifierStart", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _identifier.isIdentifierStart;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isKeyword", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isKeyword;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictBindOnlyReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictBindReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictBindReservedWord;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isStrictReservedWord", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _keyword.isStrictReservedWord;
|
||||
}
|
||||
});
|
||||
var _identifier = require("./identifier.js");
|
||||
var _keyword = require("./keyword.js");
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_identifier","require","_keyword"],"sources":["../src/index.ts"],"sourcesContent":["export {\n isIdentifierName,\n isIdentifierChar,\n isIdentifierStart,\n} from \"./identifier.ts\";\nexport {\n isReservedWord,\n isStrictBindOnlyReservedWord,\n isStrictBindReservedWord,\n isStrictReservedWord,\n isKeyword,\n} from \"./keyword.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isKeyword = isKeyword;
|
||||
exports.isReservedWord = isReservedWord;
|
||||
exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
|
||||
exports.isStrictBindReservedWord = isStrictBindReservedWord;
|
||||
exports.isStrictReservedWord = isStrictReservedWord;
|
||||
const reservedWords = {
|
||||
keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
|
||||
strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
|
||||
strictBind: ["eval", "arguments"]
|
||||
};
|
||||
const keywords = new Set(reservedWords.keyword);
|
||||
const reservedWordsStrictSet = new Set(reservedWords.strict);
|
||||
const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
|
||||
function isReservedWord(word, inModule) {
|
||||
return inModule && word === "await" || word === "enum";
|
||||
}
|
||||
function isStrictReservedWord(word, inModule) {
|
||||
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
|
||||
}
|
||||
function isStrictBindOnlyReservedWord(word) {
|
||||
return reservedWordsStrictBindSet.has(word);
|
||||
}
|
||||
function isStrictBindReservedWord(word, inModule) {
|
||||
return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
|
||||
}
|
||||
function isKeyword(word) {
|
||||
return keywords.has(word);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=keyword.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["reservedWords","keyword","strict","strictBind","keywords","Set","reservedWordsStrictSet","reservedWordsStrictBindSet","isReservedWord","word","inModule","isStrictReservedWord","has","isStrictBindOnlyReservedWord","isStrictBindReservedWord","isKeyword"],"sources":["../src/keyword.ts"],"sourcesContent":["const reservedWords = {\n keyword: [\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"return\",\n \"switch\",\n \"throw\",\n \"try\",\n \"var\",\n \"const\",\n \"while\",\n \"with\",\n \"new\",\n \"this\",\n \"super\",\n \"class\",\n \"extends\",\n \"export\",\n \"import\",\n \"null\",\n \"true\",\n \"false\",\n \"in\",\n \"instanceof\",\n \"typeof\",\n \"void\",\n \"delete\",\n ],\n strict: [\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n ],\n strictBind: [\"eval\", \"arguments\"],\n};\nconst keywords = new Set(reservedWords.keyword);\nconst reservedWordsStrictSet = new Set(reservedWords.strict);\nconst reservedWordsStrictBindSet = new Set(reservedWords.strictBind);\n\n/**\n * Checks if word is a reserved word in non-strict mode\n */\nexport function isReservedWord(word: string, inModule: boolean): boolean {\n return (inModule && word === \"await\") || word === \"enum\";\n}\n\n/**\n * Checks if word is a reserved word in non-binding strict mode\n *\n * Includes non-strict reserved words\n */\nexport function isStrictReservedWord(word: string, inModule: boolean): boolean {\n return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode, but it is allowed as\n * a normal identifier.\n */\nexport function isStrictBindOnlyReservedWord(word: string): boolean {\n return reservedWordsStrictBindSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode\n *\n * Includes non-strict reserved words and non-binding strict reserved words\n */\nexport function isStrictBindReservedWord(\n word: string,\n inModule: boolean,\n): boolean {\n return (\n isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word)\n );\n}\n\nexport function isKeyword(word: string): boolean {\n return keywords.has(word);\n}\n"],"mappings":";;;;;;;;;;AAAA,MAAMA,aAAa,GAAG;EACpBC,OAAO,EAAE,CACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,CACT;EACDC,MAAM,EAAE,CACN,YAAY,EACZ,WAAW,EACX,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,OAAO,CACR;EACDC,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW;AAClC,CAAC;AACD,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAACL,aAAa,CAACC,OAAO,CAAC;AAC/C,MAAMK,sBAAsB,GAAG,IAAID,GAAG,CAACL,aAAa,CAACE,MAAM,CAAC;AAC5D,MAAMK,0BAA0B,GAAG,IAAIF,GAAG,CAACL,aAAa,CAACG,UAAU,CAAC;AAK7D,SAASK,cAAcA,CAACC,IAAY,EAAEC,QAAiB,EAAW;EACvE,OAAQA,QAAQ,IAAID,IAAI,KAAK,OAAO,IAAKA,IAAI,KAAK,MAAM;AAC1D;AAOO,SAASE,oBAAoBA,CAACF,IAAY,EAAEC,QAAiB,EAAW;EAC7E,OAAOF,cAAc,CAACC,IAAI,EAAEC,QAAQ,CAAC,IAAIJ,sBAAsB,CAACM,GAAG,CAACH,IAAI,CAAC;AAC3E;AAMO,SAASI,4BAA4BA,CAACJ,IAAY,EAAW;EAClE,OAAOF,0BAA0B,CAACK,GAAG,CAACH,IAAI,CAAC;AAC7C;AAOO,SAASK,wBAAwBA,CACtCL,IAAY,EACZC,QAAiB,EACR;EACT,OACEC,oBAAoB,CAACF,IAAI,EAAEC,QAAQ,CAAC,IAAIG,4BAA4B,CAACJ,IAAI,CAAC;AAE9E;AAEO,SAASM,SAASA,CAACN,IAAY,EAAW;EAC/C,OAAOL,QAAQ,CAACQ,GAAG,CAACH,IAAI,CAAC;AAC3B","ignoreList":[]}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@babel/helper-validator-identifier",
|
||||
"version": "7.28.5",
|
||||
"description": "Validate identifier/keywords name",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-helper-validator-identifier"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@unicode/unicode-17.0.0": "^1.6.10",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
+1073
File diff suppressed because it is too large
Load Diff
+19
@@ -0,0 +1,19 @@
|
||||
Copyright (C) 2012-2014 by various contributors (see AUTHORS)
|
||||
|
||||
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
@@ -0,0 +1,19 @@
|
||||
# @babel/parser
|
||||
|
||||
> A JavaScript parser
|
||||
|
||||
See our website [@babel/parser](https://babeljs.io/docs/babel-parser) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20parser%22+is%3Aopen) associated with this package.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/parser
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/parser --dev
|
||||
```
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
/* eslint-disable no-var, unicorn/prefer-node-protocol */
|
||||
|
||||
var parser = require("..");
|
||||
var fs = require("fs");
|
||||
|
||||
var filename = process.argv[2];
|
||||
if (!filename) {
|
||||
console.error("no filename specified");
|
||||
} else {
|
||||
var file = fs.readFileSync(filename, "utf8");
|
||||
var ast = parser.parse(file);
|
||||
|
||||
console.log(JSON.stringify(ast, null, " "));
|
||||
}
|
||||
+14599
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+50
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "@babel/parser",
|
||||
"version": "7.29.3",
|
||||
"description": "A JavaScript parser",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-parser",
|
||||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A+parser+%28babylon%29%22+is%3Aopen",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"keywords": [
|
||||
"babel",
|
||||
"javascript",
|
||||
"parser",
|
||||
"tc39",
|
||||
"ecmascript",
|
||||
"@babel/parser"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-parser"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"types": "./typings/babel-parser.d.ts",
|
||||
"files": [
|
||||
"bin",
|
||||
"lib",
|
||||
"typings/babel-parser.d.ts",
|
||||
"index.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"# dependencies": "This package doesn't actually have runtime dependencies. @babel/types is only needed for type definitions.",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.29.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/code-frame": "^7.29.0",
|
||||
"@babel/helper-check-duplicate-nodes": "^7.28.6",
|
||||
"@babel/helper-fixtures": "^7.28.6",
|
||||
"@babel/helper-string-parser": "^7.27.1",
|
||||
"@babel/helper-validator-identifier": "^7.28.5",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"bin": "./bin/babel-parser.js",
|
||||
"type": "commonjs"
|
||||
}
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
// This file is auto-generated! Do not modify it directly.
|
||||
// Run `yarn gulp bundle-dts` to re-generate it.
|
||||
/* eslint-disable @typescript-eslint/consistent-type-imports, @typescript-eslint/no-redundant-type-constituents */
|
||||
import { File, Expression } from '@babel/types';
|
||||
|
||||
declare class Position {
|
||||
line: number;
|
||||
column: number;
|
||||
index: number;
|
||||
constructor(line: number, col: number, index: number);
|
||||
}
|
||||
|
||||
type SyntaxPlugin = "flow" | "typescript" | "jsx" | "pipelineOperator" | "placeholders";
|
||||
type ParseErrorCode = "BABEL_PARSER_SYNTAX_ERROR" | "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
|
||||
interface ParseErrorSpecification<ErrorDetails> {
|
||||
code: ParseErrorCode;
|
||||
reasonCode: string;
|
||||
syntaxPlugin?: SyntaxPlugin;
|
||||
missingPlugin?: string | string[];
|
||||
loc: Position;
|
||||
details: ErrorDetails;
|
||||
pos: number;
|
||||
}
|
||||
type ParseError$1<ErrorDetails> = SyntaxError & ParseErrorSpecification<ErrorDetails>;
|
||||
|
||||
type BABEL_8_BREAKING = false;
|
||||
type IF_BABEL_7<V> = false extends BABEL_8_BREAKING ? V : never;
|
||||
|
||||
type Plugin$1 =
|
||||
| "asyncDoExpressions"
|
||||
| IF_BABEL_7<"asyncGenerators">
|
||||
| IF_BABEL_7<"bigInt">
|
||||
| IF_BABEL_7<"classPrivateMethods">
|
||||
| IF_BABEL_7<"classPrivateProperties">
|
||||
| IF_BABEL_7<"classProperties">
|
||||
| IF_BABEL_7<"classStaticBlock">
|
||||
| IF_BABEL_7<"decimal">
|
||||
| "decorators-legacy"
|
||||
| "deferredImportEvaluation"
|
||||
| "decoratorAutoAccessors"
|
||||
| "destructuringPrivate"
|
||||
| IF_BABEL_7<"deprecatedImportAssert">
|
||||
| "doExpressions"
|
||||
| IF_BABEL_7<"dynamicImport">
|
||||
| IF_BABEL_7<"explicitResourceManagement">
|
||||
| "exportDefaultFrom"
|
||||
| IF_BABEL_7<"exportNamespaceFrom">
|
||||
| "flow"
|
||||
| "flowComments"
|
||||
| "functionBind"
|
||||
| "functionSent"
|
||||
| "importMeta"
|
||||
| "jsx"
|
||||
| IF_BABEL_7<"jsonStrings">
|
||||
| IF_BABEL_7<"logicalAssignment">
|
||||
| IF_BABEL_7<"importAssertions">
|
||||
| IF_BABEL_7<"importReflection">
|
||||
| "moduleBlocks"
|
||||
| IF_BABEL_7<"moduleStringNames">
|
||||
| IF_BABEL_7<"nullishCoalescingOperator">
|
||||
| IF_BABEL_7<"numericSeparator">
|
||||
| IF_BABEL_7<"objectRestSpread">
|
||||
| IF_BABEL_7<"optionalCatchBinding">
|
||||
| IF_BABEL_7<"optionalChaining">
|
||||
| "partialApplication"
|
||||
| "placeholders"
|
||||
| IF_BABEL_7<"privateIn">
|
||||
| IF_BABEL_7<"regexpUnicodeSets">
|
||||
| "sourcePhaseImports"
|
||||
| "throwExpressions"
|
||||
| IF_BABEL_7<"topLevelAwait">
|
||||
| "v8intrinsic"
|
||||
| ParserPluginWithOptions[0];
|
||||
|
||||
type ParserPluginWithOptions =
|
||||
| ["decorators", DecoratorsPluginOptions]
|
||||
| ["discardBinding", { syntaxType: "void" }]
|
||||
| ["estree", { classFeatures?: boolean }]
|
||||
| IF_BABEL_7<["importAttributes", { deprecatedAssertSyntax: boolean }]>
|
||||
| IF_BABEL_7<["moduleAttributes", { version: "may-2020" }]>
|
||||
| ["optionalChainingAssign", { version: "2023-07" }]
|
||||
| ["pipelineOperator", PipelineOperatorPluginOptions]
|
||||
| ["recordAndTuple", RecordAndTuplePluginOptions]
|
||||
| ["flow", FlowPluginOptions]
|
||||
| ["typescript", TypeScriptPluginOptions];
|
||||
|
||||
type PluginConfig = Plugin$1 | ParserPluginWithOptions;
|
||||
|
||||
interface DecoratorsPluginOptions {
|
||||
decoratorsBeforeExport?: boolean;
|
||||
allowCallParenthesized?: boolean;
|
||||
}
|
||||
|
||||
interface PipelineOperatorPluginOptions {
|
||||
proposal: BABEL_8_BREAKING extends false
|
||||
? "minimal" | "fsharp" | "hack" | "smart"
|
||||
: "fsharp" | "hack";
|
||||
topicToken?: "%" | "#" | "@@" | "^^" | "^";
|
||||
}
|
||||
|
||||
interface RecordAndTuplePluginOptions {
|
||||
syntaxType: "bar" | "hash";
|
||||
}
|
||||
|
||||
type FlowPluginOptions = BABEL_8_BREAKING extends true
|
||||
? {
|
||||
all?: boolean;
|
||||
enums?: boolean;
|
||||
}
|
||||
: {
|
||||
all?: boolean;
|
||||
};
|
||||
|
||||
interface TypeScriptPluginOptions {
|
||||
dts?: boolean;
|
||||
disallowAmbiguousJSXLike?: boolean;
|
||||
}
|
||||
|
||||
type Plugin = PluginConfig;
|
||||
|
||||
type SourceType = "script" | "commonjs" | "module" | "unambiguous";
|
||||
interface Options {
|
||||
/**
|
||||
* By default, import and export declarations can only appear at a program's top level.
|
||||
* Setting this option to true allows them anywhere where a statement is allowed.
|
||||
*/
|
||||
allowImportExportEverywhere?: boolean;
|
||||
/**
|
||||
* By default, await use is not allowed outside of an async function.
|
||||
* Set this to true to accept such code.
|
||||
*/
|
||||
allowAwaitOutsideFunction?: boolean;
|
||||
/**
|
||||
* By default, a return statement at the top level raises an error.
|
||||
* Set this to true to accept such code.
|
||||
*/
|
||||
allowReturnOutsideFunction?: boolean;
|
||||
/**
|
||||
* By default, new.target use is not allowed outside of a function or class.
|
||||
* Set this to true to accept such code.
|
||||
*/
|
||||
allowNewTargetOutsideFunction?: boolean;
|
||||
/**
|
||||
* By default, super calls are not allowed outside of a method.
|
||||
* Set this to true to accept such code.
|
||||
*/
|
||||
allowSuperOutsideMethod?: boolean;
|
||||
/**
|
||||
* By default, exported identifiers must refer to a declared variable.
|
||||
* Set this to true to allow export statements to reference undeclared variables.
|
||||
*/
|
||||
allowUndeclaredExports?: boolean;
|
||||
/**
|
||||
* By default, yield use is not allowed outside of a generator function.
|
||||
* Set this to true to accept such code.
|
||||
*/
|
||||
allowYieldOutsideFunction?: boolean;
|
||||
/**
|
||||
* By default, Babel parser JavaScript code according to Annex B syntax.
|
||||
* Set this to `false` to disable such behavior.
|
||||
*/
|
||||
annexB?: boolean;
|
||||
/**
|
||||
* By default, Babel attaches comments to adjacent AST nodes.
|
||||
* When this option is set to false, comments are not attached.
|
||||
* It can provide up to 30% performance improvement when the input code has many comments.
|
||||
* @babel/eslint-parser will set it for you.
|
||||
* It is not recommended to use attachComment: false with Babel transform,
|
||||
* as doing so removes all the comments in output code, and renders annotations such as
|
||||
* /* istanbul ignore next *\/ nonfunctional.
|
||||
*/
|
||||
attachComment?: boolean;
|
||||
/**
|
||||
* By default, Babel always throws an error when it finds some invalid code.
|
||||
* When this option is set to true, it will store the parsing error and
|
||||
* try to continue parsing the invalid input file.
|
||||
*/
|
||||
errorRecovery?: boolean;
|
||||
/**
|
||||
* Indicate the mode the code should be parsed in.
|
||||
* Can be one of "script", "commonjs", "module", or "unambiguous". Defaults to "script".
|
||||
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
|
||||
* of ES6 import or export statements.
|
||||
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
|
||||
*
|
||||
* Use "commonjs" to parse code that is intended to be run in a CommonJS environment such as Node.js.
|
||||
*/
|
||||
sourceType?: SourceType;
|
||||
/**
|
||||
* Correlate output AST nodes with their source filename.
|
||||
* Useful when generating code and source maps from the ASTs of multiple input files.
|
||||
*/
|
||||
sourceFilename?: string;
|
||||
/**
|
||||
* By default, all source indexes start from 0.
|
||||
* You can provide a start index to alternatively start with.
|
||||
* Useful for integration with other source tools.
|
||||
*/
|
||||
startIndex?: number;
|
||||
/**
|
||||
* By default, the first line of code parsed is treated as line 1.
|
||||
* You can provide a line number to alternatively start with.
|
||||
* Useful for integration with other source tools.
|
||||
*/
|
||||
startLine?: number;
|
||||
/**
|
||||
* By default, the parsed code is treated as if it starts from line 1, column 0.
|
||||
* You can provide a column number to alternatively start with.
|
||||
* Useful for integration with other source tools.
|
||||
*/
|
||||
startColumn?: number;
|
||||
/**
|
||||
* Array containing the plugins that you want to enable.
|
||||
*/
|
||||
plugins?: Plugin[];
|
||||
/**
|
||||
* Should the parser work in strict mode.
|
||||
* Defaults to true if sourceType === 'module'. Otherwise, false.
|
||||
*/
|
||||
strictMode?: boolean;
|
||||
/**
|
||||
* Adds a ranges property to each node: [node.start, node.end]
|
||||
*/
|
||||
ranges?: boolean;
|
||||
/**
|
||||
* Adds all parsed tokens to a tokens property on the File node.
|
||||
*/
|
||||
tokens?: boolean;
|
||||
/**
|
||||
* By default, the parser adds information about parentheses by setting
|
||||
* `extra.parenthesized` to `true` as needed.
|
||||
* When this option is `true` the parser creates `ParenthesizedExpression`
|
||||
* AST nodes instead of using the `extra` property.
|
||||
*/
|
||||
createParenthesizedExpressions?: boolean;
|
||||
/**
|
||||
* The default is false in Babel 7 and true in Babel 8
|
||||
* Set this to true to parse it as an `ImportExpression` node.
|
||||
* Otherwise `import(foo)` is parsed as `CallExpression(Import, [Identifier(foo)])`.
|
||||
*/
|
||||
createImportExpressions?: boolean;
|
||||
}
|
||||
|
||||
type ParserOptions = Partial<Options>;
|
||||
type ParseError = ParseError$1<object>;
|
||||
type ParseResult<Result extends File | Expression = File> = Result & {
|
||||
comments: File["comments"];
|
||||
errors: null | ParseError[];
|
||||
tokens?: File["tokens"];
|
||||
};
|
||||
/**
|
||||
* Parse the provided code as an entire ECMAScript program.
|
||||
*/
|
||||
declare function parse(input: string, options?: ParserOptions): ParseResult<File>;
|
||||
declare function parseExpression(input: string, options?: ParserOptions): ParseResult<Expression>;
|
||||
|
||||
declare const tokTypes: {
|
||||
// todo(flow->ts) real token type
|
||||
[name: string]: any;
|
||||
};
|
||||
|
||||
export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult, ParserOptions, PluginConfig as ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes };
|
||||
+22
@@ -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
@@ -0,0 +1,19 @@
|
||||
# @babel/types
|
||||
|
||||
> Babel Types is a Lodash-esque utility library for AST nodes
|
||||
|
||||
See our website [@babel/types](https://babeljs.io/docs/babel-types) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20types%22+is%3Aopen) associated with this package.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/types
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/types --dev
|
||||
```
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = assertNode;
|
||||
var _isNode = require("../validators/isNode.js");
|
||||
function assertNode(node) {
|
||||
if (!(0, _isNode.default)(node)) {
|
||||
var _node$type;
|
||||
const type = (_node$type = node == null ? void 0 : node.type) != null ? _node$type : JSON.stringify(node);
|
||||
throw new TypeError(`Not a valid node of type "${type}"`);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=assertNode.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_isNode","require","assertNode","node","isNode","_node$type","type","JSON","stringify","TypeError"],"sources":["../../src/asserts/assertNode.ts"],"sourcesContent":["import isNode from \"../validators/isNode.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function assertNode(node?: any): asserts node is t.Node {\n if (!isNode(node)) {\n const type = node?.type ?? JSON.stringify(node);\n throw new TypeError(`Not a valid node of type \"${type}\"`);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGe,SAASC,UAAUA,CAACC,IAAU,EAA0B;EACrE,IAAI,CAAC,IAAAC,eAAM,EAACD,IAAI,CAAC,EAAE;IAAA,IAAAE,UAAA;IACjB,MAAMC,IAAI,IAAAD,UAAA,GAAGF,IAAI,oBAAJA,IAAI,CAAEG,IAAI,YAAAD,UAAA,GAAIE,IAAI,CAACC,SAAS,CAACL,IAAI,CAAC;IAC/C,MAAM,IAAIM,SAAS,CAAC,6BAA6BH,IAAI,GAAG,CAAC;EAC3D;AACF","ignoreList":[]}
|
||||
+1251
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+18
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = createFlowUnionType;
|
||||
var _index = require("../generated/index.js");
|
||||
var _removeTypeDuplicates = require("../../modifications/flow/removeTypeDuplicates.js");
|
||||
function createFlowUnionType(types) {
|
||||
const flattened = (0, _removeTypeDuplicates.default)(types);
|
||||
if (flattened.length === 1) {
|
||||
return flattened[0];
|
||||
} else {
|
||||
return (0, _index.unionTypeAnnotation)(flattened);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=createFlowUnionType.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_index","require","_removeTypeDuplicates","createFlowUnionType","types","flattened","removeTypeDuplicates","length","unionTypeAnnotation"],"sources":["../../../src/builders/flow/createFlowUnionType.ts"],"sourcesContent":["import { unionTypeAnnotation } from \"../generated/index.ts\";\nimport removeTypeDuplicates from \"../../modifications/flow/removeTypeDuplicates.ts\";\nimport type * as t from \"../../index.ts\";\n\n/**\n * Takes an array of `types` and flattens them, removing duplicates and\n * returns a `UnionTypeAnnotation` node containing them.\n */\nexport default function createFlowUnionType<T extends t.FlowType>(\n types: [T] | T[],\n): T | t.UnionTypeAnnotation {\n const flattened = removeTypeDuplicates(types);\n\n if (flattened.length === 1) {\n return flattened[0] as T;\n } else {\n return unionTypeAnnotation(flattened);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAOe,SAASE,mBAAmBA,CACzCC,KAAgB,EACW;EAC3B,MAAMC,SAAS,GAAG,IAAAC,6BAAoB,EAACF,KAAK,CAAC;EAE7C,IAAIC,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAOF,SAAS,CAAC,CAAC,CAAC;EACrB,CAAC,MAAM;IACL,OAAO,IAAAG,0BAAmB,EAACH,SAAS,CAAC;EACvC;AACF","ignoreList":[]}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _index = require("../generated/index.js");
|
||||
var _default = exports.default = createTypeAnnotationBasedOnTypeof;
|
||||
function createTypeAnnotationBasedOnTypeof(type) {
|
||||
switch (type) {
|
||||
case "string":
|
||||
return (0, _index.stringTypeAnnotation)();
|
||||
case "number":
|
||||
return (0, _index.numberTypeAnnotation)();
|
||||
case "undefined":
|
||||
return (0, _index.voidTypeAnnotation)();
|
||||
case "boolean":
|
||||
return (0, _index.booleanTypeAnnotation)();
|
||||
case "function":
|
||||
return (0, _index.genericTypeAnnotation)((0, _index.identifier)("Function"));
|
||||
case "object":
|
||||
return (0, _index.genericTypeAnnotation)((0, _index.identifier)("Object"));
|
||||
case "symbol":
|
||||
return (0, _index.genericTypeAnnotation)((0, _index.identifier)("Symbol"));
|
||||
case "bigint":
|
||||
return (0, _index.anyTypeAnnotation)();
|
||||
}
|
||||
throw new Error("Invalid typeof value: " + type);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=createTypeAnnotationBasedOnTypeof.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_index","require","_default","exports","default","createTypeAnnotationBasedOnTypeof","type","stringTypeAnnotation","numberTypeAnnotation","voidTypeAnnotation","booleanTypeAnnotation","genericTypeAnnotation","identifier","anyTypeAnnotation","Error"],"sources":["../../../src/builders/flow/createTypeAnnotationBasedOnTypeof.ts"],"sourcesContent":["import {\n anyTypeAnnotation,\n stringTypeAnnotation,\n numberTypeAnnotation,\n voidTypeAnnotation,\n booleanTypeAnnotation,\n genericTypeAnnotation,\n identifier,\n} from \"../generated/index.ts\";\nimport type * as t from \"../../index.ts\";\n\nexport default createTypeAnnotationBasedOnTypeof as {\n (type: \"string\"): t.StringTypeAnnotation;\n (type: \"number\"): t.NumberTypeAnnotation;\n (type: \"undefined\"): t.VoidTypeAnnotation;\n (type: \"boolean\"): t.BooleanTypeAnnotation;\n (type: \"function\"): t.GenericTypeAnnotation;\n (type: \"object\"): t.GenericTypeAnnotation;\n (type: \"symbol\"): t.GenericTypeAnnotation;\n (type: \"bigint\"): t.AnyTypeAnnotation;\n};\n\n/**\n * Create a type annotation based on typeof expression.\n */\nfunction createTypeAnnotationBasedOnTypeof(type: string): t.FlowType {\n switch (type) {\n case \"string\":\n return stringTypeAnnotation();\n case \"number\":\n return numberTypeAnnotation();\n case \"undefined\":\n return voidTypeAnnotation();\n case \"boolean\":\n return booleanTypeAnnotation();\n case \"function\":\n return genericTypeAnnotation(identifier(\"Function\"));\n case \"object\":\n return genericTypeAnnotation(identifier(\"Object\"));\n case \"symbol\":\n return genericTypeAnnotation(identifier(\"Symbol\"));\n case \"bigint\":\n // todo: use BigInt annotation when Flow supports BigInt\n // https://github.com/facebook/flow/issues/6639\n return anyTypeAnnotation();\n }\n throw new Error(\"Invalid typeof value: \" + type);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQ+B,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGhBC,iCAAiC;AAchD,SAASA,iCAAiCA,CAACC,IAAY,EAAc;EACnE,QAAQA,IAAI;IACV,KAAK,QAAQ;MACX,OAAO,IAAAC,2BAAoB,EAAC,CAAC;IAC/B,KAAK,QAAQ;MACX,OAAO,IAAAC,2BAAoB,EAAC,CAAC;IAC/B,KAAK,WAAW;MACd,OAAO,IAAAC,yBAAkB,EAAC,CAAC;IAC7B,KAAK,SAAS;MACZ,OAAO,IAAAC,4BAAqB,EAAC,CAAC;IAChC,KAAK,UAAU;MACb,OAAO,IAAAC,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,UAAU,CAAC,CAAC;IACtD,KAAK,QAAQ;MACX,OAAO,IAAAD,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,QAAQ;MACX,OAAO,IAAAD,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,QAAQ;MAGX,OAAO,IAAAC,wBAAiB,EAAC,CAAC;EAC9B;EACA,MAAM,IAAIC,KAAK,CAAC,wBAAwB,GAAGR,IAAI,CAAC;AAClD","ignoreList":[]}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _lowercase = require("./lowercase.js");
|
||||
Object.keys(_lowercase).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _lowercase[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _lowercase[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _uppercase = require("./uppercase.js");
|
||||
Object.keys(_uppercase).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _uppercase[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _uppercase[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+2902
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+272
@@ -0,0 +1,272 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.JSXIdentifier = exports.JSXFragment = exports.JSXExpressionContainer = exports.JSXEmptyExpression = exports.JSXElement = exports.JSXClosingFragment = exports.JSXClosingElement = exports.JSXAttribute = exports.IntersectionTypeAnnotation = exports.InterpreterDirective = exports.InterfaceTypeAnnotation = exports.InterfaceExtends = exports.InterfaceDeclaration = exports.InferredPredicate = exports.IndexedAccessType = exports.ImportSpecifier = exports.ImportNamespaceSpecifier = exports.ImportExpression = exports.ImportDefaultSpecifier = exports.ImportDeclaration = exports.ImportAttribute = exports.Import = exports.IfStatement = exports.Identifier = exports.GenericTypeAnnotation = exports.FunctionTypeParam = exports.FunctionTypeAnnotation = exports.FunctionExpression = exports.FunctionDeclaration = exports.ForStatement = exports.ForOfStatement = exports.ForInStatement = exports.File = exports.ExpressionStatement = exports.ExportSpecifier = exports.ExportNamespaceSpecifier = exports.ExportNamedDeclaration = exports.ExportDefaultSpecifier = exports.ExportDefaultDeclaration = exports.ExportAllDeclaration = exports.ExistsTypeAnnotation = exports.EnumSymbolBody = exports.EnumStringMember = exports.EnumStringBody = exports.EnumNumberMember = exports.EnumNumberBody = exports.EnumDefaultedMember = exports.EnumDeclaration = exports.EnumBooleanMember = exports.EnumBooleanBody = exports.EmptyTypeAnnotation = exports.EmptyStatement = exports.DoWhileStatement = exports.DoExpression = exports.DirectiveLiteral = exports.Directive = exports.Decorator = exports.DeclaredPredicate = exports.DeclareVariable = exports.DeclareTypeAlias = exports.DeclareOpaqueType = exports.DeclareModuleExports = exports.DeclareModule = exports.DeclareInterface = exports.DeclareFunction = exports.DeclareExportDeclaration = exports.DeclareExportAllDeclaration = exports.DeclareClass = exports.DecimalLiteral = exports.DebuggerStatement = exports.ContinueStatement = exports.ConditionalExpression = exports.ClassProperty = exports.ClassPrivateProperty = exports.ClassPrivateMethod = exports.ClassMethod = exports.ClassImplements = exports.ClassExpression = exports.ClassDeclaration = exports.ClassBody = exports.ClassAccessorProperty = exports.CatchClause = exports.CallExpression = exports.BreakStatement = exports.BooleanTypeAnnotation = exports.BooleanLiteralTypeAnnotation = exports.BooleanLiteral = exports.BlockStatement = exports.BindExpression = exports.BinaryExpression = exports.BigIntLiteral = exports.AwaitExpression = exports.AssignmentPattern = exports.AssignmentExpression = exports.ArrowFunctionExpression = exports.ArrayTypeAnnotation = exports.ArrayPattern = exports.ArrayExpression = exports.ArgumentPlaceholder = exports.AnyTypeAnnotation = void 0;
|
||||
exports.TSNumberKeyword = exports.TSNullKeyword = exports.TSNonNullExpression = exports.TSNeverKeyword = exports.TSNamespaceExportDeclaration = exports.TSNamedTupleMember = exports.TSModuleDeclaration = exports.TSModuleBlock = exports.TSMethodSignature = exports.TSMappedType = exports.TSLiteralType = exports.TSIntrinsicKeyword = exports.TSIntersectionType = exports.TSInterfaceDeclaration = exports.TSInterfaceBody = exports.TSInstantiationExpression = exports.TSInferType = exports.TSIndexedAccessType = exports.TSIndexSignature = exports.TSImportType = exports.TSImportEqualsDeclaration = exports.TSFunctionType = exports.TSExternalModuleReference = exports.TSExpressionWithTypeArguments = exports.TSExportAssignment = exports.TSEnumMember = exports.TSEnumDeclaration = exports.TSEnumBody = exports.TSDeclareMethod = exports.TSDeclareFunction = exports.TSConstructorType = exports.TSConstructSignatureDeclaration = exports.TSConditionalType = exports.TSCallSignatureDeclaration = exports.TSBooleanKeyword = exports.TSBigIntKeyword = exports.TSAsExpression = exports.TSArrayType = exports.TSAnyKeyword = exports.SymbolTypeAnnotation = exports.SwitchStatement = exports.SwitchCase = exports.Super = exports.StringTypeAnnotation = exports.StringLiteralTypeAnnotation = exports.StringLiteral = exports.StaticBlock = exports.SpreadProperty = exports.SpreadElement = exports.SequenceExpression = exports.ReturnStatement = exports.RestProperty = exports.RestElement = exports.RegexLiteral = exports.RegExpLiteral = exports.RecordExpression = exports.QualifiedTypeIdentifier = exports.Program = exports.PrivateName = exports.Placeholder = exports.PipelineTopicExpression = exports.PipelinePrimaryTopicReference = exports.PipelineBareFunction = exports.ParenthesizedExpression = exports.OptionalMemberExpression = exports.OptionalIndexedAccessType = exports.OptionalCallExpression = exports.OpaqueType = exports.ObjectTypeSpreadProperty = exports.ObjectTypeProperty = exports.ObjectTypeInternalSlot = exports.ObjectTypeIndexer = exports.ObjectTypeCallProperty = exports.ObjectTypeAnnotation = exports.ObjectProperty = exports.ObjectPattern = exports.ObjectMethod = exports.ObjectExpression = exports.NumericLiteral = exports.NumberTypeAnnotation = exports.NumberLiteralTypeAnnotation = exports.NumberLiteral = exports.NullableTypeAnnotation = exports.NullLiteralTypeAnnotation = exports.NullLiteral = exports.Noop = exports.NewExpression = exports.ModuleExpression = exports.MixedTypeAnnotation = exports.MetaProperty = exports.MemberExpression = exports.LogicalExpression = exports.LabeledStatement = exports.JSXText = exports.JSXSpreadChild = exports.JSXSpreadAttribute = exports.JSXOpeningFragment = exports.JSXOpeningElement = exports.JSXNamespacedName = exports.JSXMemberExpression = void 0;
|
||||
exports.YieldExpression = exports.WithStatement = exports.WhileStatement = exports.VoidTypeAnnotation = exports.VoidPattern = exports.Variance = exports.VariableDeclarator = exports.VariableDeclaration = exports.V8IntrinsicIdentifier = exports.UpdateExpression = exports.UnionTypeAnnotation = exports.UnaryExpression = exports.TypeofTypeAnnotation = exports.TypeParameterInstantiation = exports.TypeParameterDeclaration = exports.TypeParameter = exports.TypeCastExpression = exports.TypeAnnotation = exports.TypeAlias = exports.TupleTypeAnnotation = exports.TupleExpression = exports.TryStatement = exports.TopicReference = exports.ThrowStatement = exports.ThisTypeAnnotation = exports.ThisExpression = exports.TemplateLiteral = exports.TemplateElement = exports.TaggedTemplateExpression = exports.TSVoidKeyword = exports.TSUnknownKeyword = exports.TSUnionType = exports.TSUndefinedKeyword = exports.TSTypeReference = exports.TSTypeQuery = exports.TSTypePredicate = exports.TSTypeParameterInstantiation = exports.TSTypeParameterDeclaration = exports.TSTypeParameter = exports.TSTypeOperator = exports.TSTypeLiteral = exports.TSTypeAssertion = exports.TSTypeAnnotation = exports.TSTypeAliasDeclaration = exports.TSTupleType = exports.TSThisType = exports.TSTemplateLiteralType = exports.TSSymbolKeyword = exports.TSStringKeyword = exports.TSSatisfiesExpression = exports.TSRestType = exports.TSQualifiedName = exports.TSPropertySignature = exports.TSParenthesizedType = exports.TSParameterProperty = exports.TSOptionalType = exports.TSObjectKeyword = void 0;
|
||||
var b = require("./lowercase.js");
|
||||
var _deprecationWarning = require("../../utils/deprecationWarning.js");
|
||||
function alias(lowercase) {
|
||||
return b[lowercase];
|
||||
}
|
||||
const ArrayExpression = exports.ArrayExpression = alias("arrayExpression"),
|
||||
AssignmentExpression = exports.AssignmentExpression = alias("assignmentExpression"),
|
||||
BinaryExpression = exports.BinaryExpression = alias("binaryExpression"),
|
||||
InterpreterDirective = exports.InterpreterDirective = alias("interpreterDirective"),
|
||||
Directive = exports.Directive = alias("directive"),
|
||||
DirectiveLiteral = exports.DirectiveLiteral = alias("directiveLiteral"),
|
||||
BlockStatement = exports.BlockStatement = alias("blockStatement"),
|
||||
BreakStatement = exports.BreakStatement = alias("breakStatement"),
|
||||
CallExpression = exports.CallExpression = alias("callExpression"),
|
||||
CatchClause = exports.CatchClause = alias("catchClause"),
|
||||
ConditionalExpression = exports.ConditionalExpression = alias("conditionalExpression"),
|
||||
ContinueStatement = exports.ContinueStatement = alias("continueStatement"),
|
||||
DebuggerStatement = exports.DebuggerStatement = alias("debuggerStatement"),
|
||||
DoWhileStatement = exports.DoWhileStatement = alias("doWhileStatement"),
|
||||
EmptyStatement = exports.EmptyStatement = alias("emptyStatement"),
|
||||
ExpressionStatement = exports.ExpressionStatement = alias("expressionStatement"),
|
||||
File = exports.File = alias("file"),
|
||||
ForInStatement = exports.ForInStatement = alias("forInStatement"),
|
||||
ForStatement = exports.ForStatement = alias("forStatement"),
|
||||
FunctionDeclaration = exports.FunctionDeclaration = alias("functionDeclaration"),
|
||||
FunctionExpression = exports.FunctionExpression = alias("functionExpression"),
|
||||
Identifier = exports.Identifier = alias("identifier"),
|
||||
IfStatement = exports.IfStatement = alias("ifStatement"),
|
||||
LabeledStatement = exports.LabeledStatement = alias("labeledStatement"),
|
||||
StringLiteral = exports.StringLiteral = alias("stringLiteral"),
|
||||
NumericLiteral = exports.NumericLiteral = alias("numericLiteral"),
|
||||
NullLiteral = exports.NullLiteral = alias("nullLiteral"),
|
||||
BooleanLiteral = exports.BooleanLiteral = alias("booleanLiteral"),
|
||||
RegExpLiteral = exports.RegExpLiteral = alias("regExpLiteral"),
|
||||
LogicalExpression = exports.LogicalExpression = alias("logicalExpression"),
|
||||
MemberExpression = exports.MemberExpression = alias("memberExpression"),
|
||||
NewExpression = exports.NewExpression = alias("newExpression"),
|
||||
Program = exports.Program = alias("program"),
|
||||
ObjectExpression = exports.ObjectExpression = alias("objectExpression"),
|
||||
ObjectMethod = exports.ObjectMethod = alias("objectMethod"),
|
||||
ObjectProperty = exports.ObjectProperty = alias("objectProperty"),
|
||||
RestElement = exports.RestElement = alias("restElement"),
|
||||
ReturnStatement = exports.ReturnStatement = alias("returnStatement"),
|
||||
SequenceExpression = exports.SequenceExpression = alias("sequenceExpression"),
|
||||
ParenthesizedExpression = exports.ParenthesizedExpression = alias("parenthesizedExpression"),
|
||||
SwitchCase = exports.SwitchCase = alias("switchCase"),
|
||||
SwitchStatement = exports.SwitchStatement = alias("switchStatement"),
|
||||
ThisExpression = exports.ThisExpression = alias("thisExpression"),
|
||||
ThrowStatement = exports.ThrowStatement = alias("throwStatement"),
|
||||
TryStatement = exports.TryStatement = alias("tryStatement"),
|
||||
UnaryExpression = exports.UnaryExpression = alias("unaryExpression"),
|
||||
UpdateExpression = exports.UpdateExpression = alias("updateExpression"),
|
||||
VariableDeclaration = exports.VariableDeclaration = alias("variableDeclaration"),
|
||||
VariableDeclarator = exports.VariableDeclarator = alias("variableDeclarator"),
|
||||
WhileStatement = exports.WhileStatement = alias("whileStatement"),
|
||||
WithStatement = exports.WithStatement = alias("withStatement"),
|
||||
AssignmentPattern = exports.AssignmentPattern = alias("assignmentPattern"),
|
||||
ArrayPattern = exports.ArrayPattern = alias("arrayPattern"),
|
||||
ArrowFunctionExpression = exports.ArrowFunctionExpression = alias("arrowFunctionExpression"),
|
||||
ClassBody = exports.ClassBody = alias("classBody"),
|
||||
ClassExpression = exports.ClassExpression = alias("classExpression"),
|
||||
ClassDeclaration = exports.ClassDeclaration = alias("classDeclaration"),
|
||||
ExportAllDeclaration = exports.ExportAllDeclaration = alias("exportAllDeclaration"),
|
||||
ExportDefaultDeclaration = exports.ExportDefaultDeclaration = alias("exportDefaultDeclaration"),
|
||||
ExportNamedDeclaration = exports.ExportNamedDeclaration = alias("exportNamedDeclaration"),
|
||||
ExportSpecifier = exports.ExportSpecifier = alias("exportSpecifier"),
|
||||
ForOfStatement = exports.ForOfStatement = alias("forOfStatement"),
|
||||
ImportDeclaration = exports.ImportDeclaration = alias("importDeclaration"),
|
||||
ImportDefaultSpecifier = exports.ImportDefaultSpecifier = alias("importDefaultSpecifier"),
|
||||
ImportNamespaceSpecifier = exports.ImportNamespaceSpecifier = alias("importNamespaceSpecifier"),
|
||||
ImportSpecifier = exports.ImportSpecifier = alias("importSpecifier"),
|
||||
ImportExpression = exports.ImportExpression = alias("importExpression"),
|
||||
MetaProperty = exports.MetaProperty = alias("metaProperty"),
|
||||
ClassMethod = exports.ClassMethod = alias("classMethod"),
|
||||
ObjectPattern = exports.ObjectPattern = alias("objectPattern"),
|
||||
SpreadElement = exports.SpreadElement = alias("spreadElement"),
|
||||
Super = exports.Super = alias("super"),
|
||||
TaggedTemplateExpression = exports.TaggedTemplateExpression = alias("taggedTemplateExpression"),
|
||||
TemplateElement = exports.TemplateElement = alias("templateElement"),
|
||||
TemplateLiteral = exports.TemplateLiteral = alias("templateLiteral"),
|
||||
YieldExpression = exports.YieldExpression = alias("yieldExpression"),
|
||||
AwaitExpression = exports.AwaitExpression = alias("awaitExpression"),
|
||||
Import = exports.Import = alias("import"),
|
||||
BigIntLiteral = exports.BigIntLiteral = alias("bigIntLiteral"),
|
||||
ExportNamespaceSpecifier = exports.ExportNamespaceSpecifier = alias("exportNamespaceSpecifier"),
|
||||
OptionalMemberExpression = exports.OptionalMemberExpression = alias("optionalMemberExpression"),
|
||||
OptionalCallExpression = exports.OptionalCallExpression = alias("optionalCallExpression"),
|
||||
ClassProperty = exports.ClassProperty = alias("classProperty"),
|
||||
ClassAccessorProperty = exports.ClassAccessorProperty = alias("classAccessorProperty"),
|
||||
ClassPrivateProperty = exports.ClassPrivateProperty = alias("classPrivateProperty"),
|
||||
ClassPrivateMethod = exports.ClassPrivateMethod = alias("classPrivateMethod"),
|
||||
PrivateName = exports.PrivateName = alias("privateName"),
|
||||
StaticBlock = exports.StaticBlock = alias("staticBlock"),
|
||||
ImportAttribute = exports.ImportAttribute = alias("importAttribute"),
|
||||
AnyTypeAnnotation = exports.AnyTypeAnnotation = alias("anyTypeAnnotation"),
|
||||
ArrayTypeAnnotation = exports.ArrayTypeAnnotation = alias("arrayTypeAnnotation"),
|
||||
BooleanTypeAnnotation = exports.BooleanTypeAnnotation = alias("booleanTypeAnnotation"),
|
||||
BooleanLiteralTypeAnnotation = exports.BooleanLiteralTypeAnnotation = alias("booleanLiteralTypeAnnotation"),
|
||||
NullLiteralTypeAnnotation = exports.NullLiteralTypeAnnotation = alias("nullLiteralTypeAnnotation"),
|
||||
ClassImplements = exports.ClassImplements = alias("classImplements"),
|
||||
DeclareClass = exports.DeclareClass = alias("declareClass"),
|
||||
DeclareFunction = exports.DeclareFunction = alias("declareFunction"),
|
||||
DeclareInterface = exports.DeclareInterface = alias("declareInterface"),
|
||||
DeclareModule = exports.DeclareModule = alias("declareModule"),
|
||||
DeclareModuleExports = exports.DeclareModuleExports = alias("declareModuleExports"),
|
||||
DeclareTypeAlias = exports.DeclareTypeAlias = alias("declareTypeAlias"),
|
||||
DeclareOpaqueType = exports.DeclareOpaqueType = alias("declareOpaqueType"),
|
||||
DeclareVariable = exports.DeclareVariable = alias("declareVariable"),
|
||||
DeclareExportDeclaration = exports.DeclareExportDeclaration = alias("declareExportDeclaration"),
|
||||
DeclareExportAllDeclaration = exports.DeclareExportAllDeclaration = alias("declareExportAllDeclaration"),
|
||||
DeclaredPredicate = exports.DeclaredPredicate = alias("declaredPredicate"),
|
||||
ExistsTypeAnnotation = exports.ExistsTypeAnnotation = alias("existsTypeAnnotation"),
|
||||
FunctionTypeAnnotation = exports.FunctionTypeAnnotation = alias("functionTypeAnnotation"),
|
||||
FunctionTypeParam = exports.FunctionTypeParam = alias("functionTypeParam"),
|
||||
GenericTypeAnnotation = exports.GenericTypeAnnotation = alias("genericTypeAnnotation"),
|
||||
InferredPredicate = exports.InferredPredicate = alias("inferredPredicate"),
|
||||
InterfaceExtends = exports.InterfaceExtends = alias("interfaceExtends"),
|
||||
InterfaceDeclaration = exports.InterfaceDeclaration = alias("interfaceDeclaration"),
|
||||
InterfaceTypeAnnotation = exports.InterfaceTypeAnnotation = alias("interfaceTypeAnnotation"),
|
||||
IntersectionTypeAnnotation = exports.IntersectionTypeAnnotation = alias("intersectionTypeAnnotation"),
|
||||
MixedTypeAnnotation = exports.MixedTypeAnnotation = alias("mixedTypeAnnotation"),
|
||||
EmptyTypeAnnotation = exports.EmptyTypeAnnotation = alias("emptyTypeAnnotation"),
|
||||
NullableTypeAnnotation = exports.NullableTypeAnnotation = alias("nullableTypeAnnotation"),
|
||||
NumberLiteralTypeAnnotation = exports.NumberLiteralTypeAnnotation = alias("numberLiteralTypeAnnotation"),
|
||||
NumberTypeAnnotation = exports.NumberTypeAnnotation = alias("numberTypeAnnotation"),
|
||||
ObjectTypeAnnotation = exports.ObjectTypeAnnotation = alias("objectTypeAnnotation"),
|
||||
ObjectTypeInternalSlot = exports.ObjectTypeInternalSlot = alias("objectTypeInternalSlot"),
|
||||
ObjectTypeCallProperty = exports.ObjectTypeCallProperty = alias("objectTypeCallProperty"),
|
||||
ObjectTypeIndexer = exports.ObjectTypeIndexer = alias("objectTypeIndexer"),
|
||||
ObjectTypeProperty = exports.ObjectTypeProperty = alias("objectTypeProperty"),
|
||||
ObjectTypeSpreadProperty = exports.ObjectTypeSpreadProperty = alias("objectTypeSpreadProperty"),
|
||||
OpaqueType = exports.OpaqueType = alias("opaqueType"),
|
||||
QualifiedTypeIdentifier = exports.QualifiedTypeIdentifier = alias("qualifiedTypeIdentifier"),
|
||||
StringLiteralTypeAnnotation = exports.StringLiteralTypeAnnotation = alias("stringLiteralTypeAnnotation"),
|
||||
StringTypeAnnotation = exports.StringTypeAnnotation = alias("stringTypeAnnotation"),
|
||||
SymbolTypeAnnotation = exports.SymbolTypeAnnotation = alias("symbolTypeAnnotation"),
|
||||
ThisTypeAnnotation = exports.ThisTypeAnnotation = alias("thisTypeAnnotation"),
|
||||
TupleTypeAnnotation = exports.TupleTypeAnnotation = alias("tupleTypeAnnotation"),
|
||||
TypeofTypeAnnotation = exports.TypeofTypeAnnotation = alias("typeofTypeAnnotation"),
|
||||
TypeAlias = exports.TypeAlias = alias("typeAlias"),
|
||||
TypeAnnotation = exports.TypeAnnotation = alias("typeAnnotation"),
|
||||
TypeCastExpression = exports.TypeCastExpression = alias("typeCastExpression"),
|
||||
TypeParameter = exports.TypeParameter = alias("typeParameter"),
|
||||
TypeParameterDeclaration = exports.TypeParameterDeclaration = alias("typeParameterDeclaration"),
|
||||
TypeParameterInstantiation = exports.TypeParameterInstantiation = alias("typeParameterInstantiation"),
|
||||
UnionTypeAnnotation = exports.UnionTypeAnnotation = alias("unionTypeAnnotation"),
|
||||
Variance = exports.Variance = alias("variance"),
|
||||
VoidTypeAnnotation = exports.VoidTypeAnnotation = alias("voidTypeAnnotation"),
|
||||
EnumDeclaration = exports.EnumDeclaration = alias("enumDeclaration"),
|
||||
EnumBooleanBody = exports.EnumBooleanBody = alias("enumBooleanBody"),
|
||||
EnumNumberBody = exports.EnumNumberBody = alias("enumNumberBody"),
|
||||
EnumStringBody = exports.EnumStringBody = alias("enumStringBody"),
|
||||
EnumSymbolBody = exports.EnumSymbolBody = alias("enumSymbolBody"),
|
||||
EnumBooleanMember = exports.EnumBooleanMember = alias("enumBooleanMember"),
|
||||
EnumNumberMember = exports.EnumNumberMember = alias("enumNumberMember"),
|
||||
EnumStringMember = exports.EnumStringMember = alias("enumStringMember"),
|
||||
EnumDefaultedMember = exports.EnumDefaultedMember = alias("enumDefaultedMember"),
|
||||
IndexedAccessType = exports.IndexedAccessType = alias("indexedAccessType"),
|
||||
OptionalIndexedAccessType = exports.OptionalIndexedAccessType = alias("optionalIndexedAccessType"),
|
||||
JSXAttribute = exports.JSXAttribute = alias("jsxAttribute"),
|
||||
JSXClosingElement = exports.JSXClosingElement = alias("jsxClosingElement"),
|
||||
JSXElement = exports.JSXElement = alias("jsxElement"),
|
||||
JSXEmptyExpression = exports.JSXEmptyExpression = alias("jsxEmptyExpression"),
|
||||
JSXExpressionContainer = exports.JSXExpressionContainer = alias("jsxExpressionContainer"),
|
||||
JSXSpreadChild = exports.JSXSpreadChild = alias("jsxSpreadChild"),
|
||||
JSXIdentifier = exports.JSXIdentifier = alias("jsxIdentifier"),
|
||||
JSXMemberExpression = exports.JSXMemberExpression = alias("jsxMemberExpression"),
|
||||
JSXNamespacedName = exports.JSXNamespacedName = alias("jsxNamespacedName"),
|
||||
JSXOpeningElement = exports.JSXOpeningElement = alias("jsxOpeningElement"),
|
||||
JSXSpreadAttribute = exports.JSXSpreadAttribute = alias("jsxSpreadAttribute"),
|
||||
JSXText = exports.JSXText = alias("jsxText"),
|
||||
JSXFragment = exports.JSXFragment = alias("jsxFragment"),
|
||||
JSXOpeningFragment = exports.JSXOpeningFragment = alias("jsxOpeningFragment"),
|
||||
JSXClosingFragment = exports.JSXClosingFragment = alias("jsxClosingFragment"),
|
||||
Noop = exports.Noop = alias("noop"),
|
||||
Placeholder = exports.Placeholder = alias("placeholder"),
|
||||
V8IntrinsicIdentifier = exports.V8IntrinsicIdentifier = alias("v8IntrinsicIdentifier"),
|
||||
ArgumentPlaceholder = exports.ArgumentPlaceholder = alias("argumentPlaceholder"),
|
||||
BindExpression = exports.BindExpression = alias("bindExpression"),
|
||||
Decorator = exports.Decorator = alias("decorator"),
|
||||
DoExpression = exports.DoExpression = alias("doExpression"),
|
||||
ExportDefaultSpecifier = exports.ExportDefaultSpecifier = alias("exportDefaultSpecifier"),
|
||||
RecordExpression = exports.RecordExpression = alias("recordExpression"),
|
||||
TupleExpression = exports.TupleExpression = alias("tupleExpression"),
|
||||
DecimalLiteral = exports.DecimalLiteral = alias("decimalLiteral"),
|
||||
ModuleExpression = exports.ModuleExpression = alias("moduleExpression"),
|
||||
TopicReference = exports.TopicReference = alias("topicReference"),
|
||||
PipelineTopicExpression = exports.PipelineTopicExpression = alias("pipelineTopicExpression"),
|
||||
PipelineBareFunction = exports.PipelineBareFunction = alias("pipelineBareFunction"),
|
||||
PipelinePrimaryTopicReference = exports.PipelinePrimaryTopicReference = alias("pipelinePrimaryTopicReference"),
|
||||
VoidPattern = exports.VoidPattern = alias("voidPattern"),
|
||||
TSParameterProperty = exports.TSParameterProperty = alias("tsParameterProperty"),
|
||||
TSDeclareFunction = exports.TSDeclareFunction = alias("tsDeclareFunction"),
|
||||
TSDeclareMethod = exports.TSDeclareMethod = alias("tsDeclareMethod"),
|
||||
TSQualifiedName = exports.TSQualifiedName = alias("tsQualifiedName"),
|
||||
TSCallSignatureDeclaration = exports.TSCallSignatureDeclaration = alias("tsCallSignatureDeclaration"),
|
||||
TSConstructSignatureDeclaration = exports.TSConstructSignatureDeclaration = alias("tsConstructSignatureDeclaration"),
|
||||
TSPropertySignature = exports.TSPropertySignature = alias("tsPropertySignature"),
|
||||
TSMethodSignature = exports.TSMethodSignature = alias("tsMethodSignature"),
|
||||
TSIndexSignature = exports.TSIndexSignature = alias("tsIndexSignature"),
|
||||
TSAnyKeyword = exports.TSAnyKeyword = alias("tsAnyKeyword"),
|
||||
TSBooleanKeyword = exports.TSBooleanKeyword = alias("tsBooleanKeyword"),
|
||||
TSBigIntKeyword = exports.TSBigIntKeyword = alias("tsBigIntKeyword"),
|
||||
TSIntrinsicKeyword = exports.TSIntrinsicKeyword = alias("tsIntrinsicKeyword"),
|
||||
TSNeverKeyword = exports.TSNeverKeyword = alias("tsNeverKeyword"),
|
||||
TSNullKeyword = exports.TSNullKeyword = alias("tsNullKeyword"),
|
||||
TSNumberKeyword = exports.TSNumberKeyword = alias("tsNumberKeyword"),
|
||||
TSObjectKeyword = exports.TSObjectKeyword = alias("tsObjectKeyword"),
|
||||
TSStringKeyword = exports.TSStringKeyword = alias("tsStringKeyword"),
|
||||
TSSymbolKeyword = exports.TSSymbolKeyword = alias("tsSymbolKeyword"),
|
||||
TSUndefinedKeyword = exports.TSUndefinedKeyword = alias("tsUndefinedKeyword"),
|
||||
TSUnknownKeyword = exports.TSUnknownKeyword = alias("tsUnknownKeyword"),
|
||||
TSVoidKeyword = exports.TSVoidKeyword = alias("tsVoidKeyword"),
|
||||
TSThisType = exports.TSThisType = alias("tsThisType"),
|
||||
TSFunctionType = exports.TSFunctionType = alias("tsFunctionType"),
|
||||
TSConstructorType = exports.TSConstructorType = alias("tsConstructorType"),
|
||||
TSTypeReference = exports.TSTypeReference = alias("tsTypeReference"),
|
||||
TSTypePredicate = exports.TSTypePredicate = alias("tsTypePredicate"),
|
||||
TSTypeQuery = exports.TSTypeQuery = alias("tsTypeQuery"),
|
||||
TSTypeLiteral = exports.TSTypeLiteral = alias("tsTypeLiteral"),
|
||||
TSArrayType = exports.TSArrayType = alias("tsArrayType"),
|
||||
TSTupleType = exports.TSTupleType = alias("tsTupleType"),
|
||||
TSOptionalType = exports.TSOptionalType = alias("tsOptionalType"),
|
||||
TSRestType = exports.TSRestType = alias("tsRestType"),
|
||||
TSNamedTupleMember = exports.TSNamedTupleMember = alias("tsNamedTupleMember"),
|
||||
TSUnionType = exports.TSUnionType = alias("tsUnionType"),
|
||||
TSIntersectionType = exports.TSIntersectionType = alias("tsIntersectionType"),
|
||||
TSConditionalType = exports.TSConditionalType = alias("tsConditionalType"),
|
||||
TSInferType = exports.TSInferType = alias("tsInferType"),
|
||||
TSParenthesizedType = exports.TSParenthesizedType = alias("tsParenthesizedType"),
|
||||
TSTypeOperator = exports.TSTypeOperator = alias("tsTypeOperator"),
|
||||
TSIndexedAccessType = exports.TSIndexedAccessType = alias("tsIndexedAccessType"),
|
||||
TSMappedType = exports.TSMappedType = alias("tsMappedType"),
|
||||
TSTemplateLiteralType = exports.TSTemplateLiteralType = alias("tsTemplateLiteralType"),
|
||||
TSLiteralType = exports.TSLiteralType = alias("tsLiteralType"),
|
||||
TSExpressionWithTypeArguments = exports.TSExpressionWithTypeArguments = alias("tsExpressionWithTypeArguments"),
|
||||
TSInterfaceDeclaration = exports.TSInterfaceDeclaration = alias("tsInterfaceDeclaration"),
|
||||
TSInterfaceBody = exports.TSInterfaceBody = alias("tsInterfaceBody"),
|
||||
TSTypeAliasDeclaration = exports.TSTypeAliasDeclaration = alias("tsTypeAliasDeclaration"),
|
||||
TSInstantiationExpression = exports.TSInstantiationExpression = alias("tsInstantiationExpression"),
|
||||
TSAsExpression = exports.TSAsExpression = alias("tsAsExpression"),
|
||||
TSSatisfiesExpression = exports.TSSatisfiesExpression = alias("tsSatisfiesExpression"),
|
||||
TSTypeAssertion = exports.TSTypeAssertion = alias("tsTypeAssertion"),
|
||||
TSEnumBody = exports.TSEnumBody = alias("tsEnumBody"),
|
||||
TSEnumDeclaration = exports.TSEnumDeclaration = alias("tsEnumDeclaration"),
|
||||
TSEnumMember = exports.TSEnumMember = alias("tsEnumMember"),
|
||||
TSModuleDeclaration = exports.TSModuleDeclaration = alias("tsModuleDeclaration"),
|
||||
TSModuleBlock = exports.TSModuleBlock = alias("tsModuleBlock"),
|
||||
TSImportType = exports.TSImportType = alias("tsImportType"),
|
||||
TSImportEqualsDeclaration = exports.TSImportEqualsDeclaration = alias("tsImportEqualsDeclaration"),
|
||||
TSExternalModuleReference = exports.TSExternalModuleReference = alias("tsExternalModuleReference"),
|
||||
TSNonNullExpression = exports.TSNonNullExpression = alias("tsNonNullExpression"),
|
||||
TSExportAssignment = exports.TSExportAssignment = alias("tsExportAssignment"),
|
||||
TSNamespaceExportDeclaration = exports.TSNamespaceExportDeclaration = alias("tsNamespaceExportDeclaration"),
|
||||
TSTypeAnnotation = exports.TSTypeAnnotation = alias("tsTypeAnnotation"),
|
||||
TSTypeParameterInstantiation = exports.TSTypeParameterInstantiation = alias("tsTypeParameterInstantiation"),
|
||||
TSTypeParameterDeclaration = exports.TSTypeParameterDeclaration = alias("tsTypeParameterDeclaration"),
|
||||
TSTypeParameter = exports.TSTypeParameter = alias("tsTypeParameter");
|
||||
const NumberLiteral = exports.NumberLiteral = b.numberLiteral,
|
||||
RegexLiteral = exports.RegexLiteral = b.regexLiteral,
|
||||
RestProperty = exports.RestProperty = b.restProperty,
|
||||
SpreadProperty = exports.SpreadProperty = b.spreadProperty;
|
||||
|
||||
//# sourceMappingURL=uppercase.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+12
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildUndefinedNode = buildUndefinedNode;
|
||||
var _index = require("./generated/index.js");
|
||||
function buildUndefinedNode() {
|
||||
return (0, _index.unaryExpression)("void", (0, _index.numericLiteral)(0), true);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=productions.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_index","require","buildUndefinedNode","unaryExpression","numericLiteral"],"sources":["../../src/builders/productions.ts"],"sourcesContent":["import { numericLiteral, unaryExpression } from \"./generated/index.ts\";\n\nexport function buildUndefinedNode() {\n return unaryExpression(\"void\", numericLiteral(0), true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,OAAO,IAAAC,sBAAe,EAAC,MAAM,EAAE,IAAAC,qBAAc,EAAC,CAAC,CAAC,EAAE,IAAI,CAAC;AACzD","ignoreList":[]}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = buildChildren;
|
||||
var _index = require("../../validators/generated/index.js");
|
||||
var _cleanJSXElementLiteralChild = require("../../utils/react/cleanJSXElementLiteralChild.js");
|
||||
function buildChildren(node) {
|
||||
const elements = [];
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
let child = node.children[i];
|
||||
if ((0, _index.isJSXText)(child)) {
|
||||
(0, _cleanJSXElementLiteralChild.default)(child, elements);
|
||||
continue;
|
||||
}
|
||||
if ((0, _index.isJSXExpressionContainer)(child)) child = child.expression;
|
||||
if ((0, _index.isJSXEmptyExpression)(child)) continue;
|
||||
elements.push(child);
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=buildChildren.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_index","require","_cleanJSXElementLiteralChild","buildChildren","node","elements","i","children","length","child","isJSXText","cleanJSXElementLiteralChild","isJSXExpressionContainer","expression","isJSXEmptyExpression","push"],"sources":["../../../src/builders/react/buildChildren.ts"],"sourcesContent":["import {\n isJSXText,\n isJSXExpressionContainer,\n isJSXEmptyExpression,\n} from \"../../validators/generated/index.ts\";\nimport cleanJSXElementLiteralChild from \"../../utils/react/cleanJSXElementLiteralChild.ts\";\nimport type * as t from \"../../index.ts\";\n\ntype ReturnedChild =\n | t.JSXSpreadChild\n | t.JSXElement\n | t.JSXFragment\n | t.Expression;\n\nexport default function buildChildren(\n node: t.JSXElement | t.JSXFragment,\n): ReturnedChild[] {\n const elements = [];\n\n for (let i = 0; i < node.children.length; i++) {\n let child: any = node.children[i];\n\n if (isJSXText(child)) {\n cleanJSXElementLiteralChild(child, elements);\n continue;\n }\n\n if (isJSXExpressionContainer(child)) child = child.expression;\n if (isJSXEmptyExpression(child)) continue;\n\n elements.push(child);\n }\n\n return elements;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,4BAAA,GAAAD,OAAA;AASe,SAASE,aAAaA,CACnCC,IAAkC,EACjB;EACjB,MAAMC,QAAQ,GAAG,EAAE;EAEnB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,IAAI,CAACG,QAAQ,CAACC,MAAM,EAAEF,CAAC,EAAE,EAAE;IAC7C,IAAIG,KAAU,GAAGL,IAAI,CAACG,QAAQ,CAACD,CAAC,CAAC;IAEjC,IAAI,IAAAI,gBAAS,EAACD,KAAK,CAAC,EAAE;MACpB,IAAAE,oCAA2B,EAACF,KAAK,EAAEJ,QAAQ,CAAC;MAC5C;IACF;IAEA,IAAI,IAAAO,+BAAwB,EAACH,KAAK,CAAC,EAAEA,KAAK,GAAGA,KAAK,CAACI,UAAU;IAC7D,IAAI,IAAAC,2BAAoB,EAACL,KAAK,CAAC,EAAE;IAEjCJ,QAAQ,CAACU,IAAI,CAACN,KAAK,CAAC;EACtB;EAEA,OAAOJ,QAAQ;AACjB","ignoreList":[]}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = createTSUnionType;
|
||||
var _index = require("../generated/index.js");
|
||||
var _removeTypeDuplicates = require("../../modifications/typescript/removeTypeDuplicates.js");
|
||||
var _index2 = require("../../validators/generated/index.js");
|
||||
function createTSUnionType(typeAnnotations) {
|
||||
const types = typeAnnotations.map(type => {
|
||||
return (0, _index2.isTSTypeAnnotation)(type) ? type.typeAnnotation : type;
|
||||
});
|
||||
const flattened = (0, _removeTypeDuplicates.default)(types);
|
||||
if (flattened.length === 1) {
|
||||
return flattened[0];
|
||||
} else {
|
||||
return (0, _index.tsUnionType)(flattened);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=createTSUnionType.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_index","require","_removeTypeDuplicates","_index2","createTSUnionType","typeAnnotations","types","map","type","isTSTypeAnnotation","typeAnnotation","flattened","removeTypeDuplicates","length","tsUnionType"],"sources":["../../../src/builders/typescript/createTSUnionType.ts"],"sourcesContent":["import { tsUnionType } from \"../generated/index.ts\";\nimport removeTypeDuplicates from \"../../modifications/typescript/removeTypeDuplicates.ts\";\nimport { isTSTypeAnnotation } from \"../../validators/generated/index.ts\";\nimport type * as t from \"../../index.ts\";\n\n/**\n * Takes an array of `types` and flattens them, removing duplicates and\n * returns a `UnionTypeAnnotation` node containing them.\n */\nexport default function createTSUnionType(\n typeAnnotations: (t.TSTypeAnnotation | t.TSType)[],\n): t.TSType {\n const types = typeAnnotations.map(type => {\n return isTSTypeAnnotation(type) ? type.typeAnnotation : type;\n });\n const flattened = removeTypeDuplicates(types);\n\n if (flattened.length === 1) {\n return flattened[0];\n } else {\n return tsUnionType(flattened);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAOe,SAASG,iBAAiBA,CACvCC,eAAkD,EACxC;EACV,MAAMC,KAAK,GAAGD,eAAe,CAACE,GAAG,CAACC,IAAI,IAAI;IACxC,OAAO,IAAAC,0BAAkB,EAACD,IAAI,CAAC,GAAGA,IAAI,CAACE,cAAc,GAAGF,IAAI;EAC9D,CAAC,CAAC;EACF,MAAMG,SAAS,GAAG,IAAAC,6BAAoB,EAACN,KAAK,CAAC;EAE7C,IAAIK,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAOF,SAAS,CAAC,CAAC,CAAC;EACrB,CAAC,MAAM;IACL,OAAO,IAAAG,kBAAW,EAACH,SAAS,CAAC;EAC/B;AACF","ignoreList":[]}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = validateNode;
|
||||
var _validate = require("../validators/validate.js");
|
||||
var _index = require("../index.js");
|
||||
function validateNode(node) {
|
||||
if (node == null || typeof node !== "object") return;
|
||||
const fields = _index.NODE_FIELDS[node.type];
|
||||
if (!fields) return;
|
||||
const keys = _index.BUILDER_KEYS[node.type];
|
||||
for (const key of keys) {
|
||||
const field = fields[key];
|
||||
if (field != null) (0, _validate.validateInternal)(field, node, key, node[key]);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=validateNode.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_validate","require","_index","validateNode","node","fields","NODE_FIELDS","type","keys","BUILDER_KEYS","key","field","validateInternal"],"sources":["../../src/builders/validateNode.ts"],"sourcesContent":["import { validateInternal } from \"../validators/validate.ts\";\nimport type * as t from \"../index.ts\";\nimport { BUILDER_KEYS, NODE_FIELDS } from \"../index.ts\";\n\nexport default function validateNode<N extends t.Node>(node: N) {\n if (node == null || typeof node !== \"object\") return;\n const fields = NODE_FIELDS[node.type];\n if (!fields) return;\n\n // todo: because keys not in BUILDER_KEYS are not validated - this actually allows invalid nodes in some cases\n const keys = BUILDER_KEYS[node.type] as (keyof N & string)[];\n for (const key of keys) {\n const field = fields[key];\n if (field != null) validateInternal(field, node, key, node[key]);\n }\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEe,SAASE,YAAYA,CAAmBC,IAAO,EAAE;EAC9D,IAAIA,IAAI,IAAI,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;EAC9C,MAAMC,MAAM,GAAGC,kBAAW,CAACF,IAAI,CAACG,IAAI,CAAC;EACrC,IAAI,CAACF,MAAM,EAAE;EAGb,MAAMG,IAAI,GAAGC,mBAAY,CAACL,IAAI,CAACG,IAAI,CAAyB;EAC5D,KAAK,MAAMG,GAAG,IAAIF,IAAI,EAAE;IACtB,MAAMG,KAAK,GAAGN,MAAM,CAACK,GAAG,CAAC;IACzB,IAAIC,KAAK,IAAI,IAAI,EAAE,IAAAC,0BAAgB,EAACD,KAAK,EAAEP,IAAI,EAAEM,GAAG,EAAEN,IAAI,CAACM,GAAG,CAAC,CAAC;EAClE;EACA,OAAON,IAAI;AACb","ignoreList":[]}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = clone;
|
||||
var _cloneNode = require("./cloneNode.js");
|
||||
function clone(node) {
|
||||
return (0, _cloneNode.default)(node, false);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=clone.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_cloneNode","require","clone","node","cloneNode"],"sources":["../../src/clone/clone.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a shallow clone of a `node`, including only\n * properties belonging to the node.\n * @deprecated Use t.cloneNode instead.\n */\nexport default function clone<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ false);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAQe,SAASC,KAAKA,CAAmBC,IAAO,EAAK;EAC1D,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,KAAK,CAAC;AAC1C","ignoreList":[]}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = cloneDeep;
|
||||
var _cloneNode = require("./cloneNode.js");
|
||||
function cloneDeep(node) {
|
||||
return (0, _cloneNode.default)(node);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=cloneDeep.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_cloneNode","require","cloneDeep","node","cloneNode"],"sources":["../../src/clone/cloneDeep.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a deep clone of a `node` and all of it's child nodes\n * including only properties belonging to the node.\n * @deprecated Use t.cloneNode instead.\n */\nexport default function cloneDeep<T extends t.Node>(node: T): T {\n return cloneNode(node);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAQe,SAASC,SAASA,CAAmBC,IAAO,EAAK;EAC9D,OAAO,IAAAC,kBAAS,EAACD,IAAI,CAAC;AACxB","ignoreList":[]}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = cloneDeepWithoutLoc;
|
||||
var _cloneNode = require("./cloneNode.js");
|
||||
function cloneDeepWithoutLoc(node) {
|
||||
return (0, _cloneNode.default)(node, true, true);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=cloneDeepWithoutLoc.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_cloneNode","require","cloneDeepWithoutLoc","node","cloneNode"],"sources":["../../src/clone/cloneDeepWithoutLoc.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n/**\n * Create a deep clone of a `node` and all of it's child nodes\n * including only properties belonging to the node.\n * excluding `_private` and location properties.\n */\nexport default function cloneDeepWithoutLoc<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ true, /* withoutLoc */ true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAOe,SAASC,mBAAmBA,CAAmBC,IAAO,EAAK;EACxE,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,IAAI,EAAmB,IAAI,CAAC;AAChE","ignoreList":[]}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = cloneNode;
|
||||
var _index = require("../definitions/index.js");
|
||||
var _index2 = require("../validators/generated/index.js");
|
||||
const {
|
||||
hasOwn
|
||||
} = {
|
||||
hasOwn: Function.call.bind(Object.prototype.hasOwnProperty)
|
||||
};
|
||||
function cloneIfNode(obj, deep, withoutLoc, commentsCache) {
|
||||
if (obj && typeof obj.type === "string") {
|
||||
return cloneNodeInternal(obj, deep, withoutLoc, commentsCache);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
function cloneIfNodeOrArray(obj, deep, withoutLoc, commentsCache) {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(node => cloneIfNode(node, deep, withoutLoc, commentsCache));
|
||||
}
|
||||
return cloneIfNode(obj, deep, withoutLoc, commentsCache);
|
||||
}
|
||||
function cloneNode(node, deep = true, withoutLoc = false) {
|
||||
return cloneNodeInternal(node, deep, withoutLoc, new Map());
|
||||
}
|
||||
function cloneNodeInternal(node, deep = true, withoutLoc = false, commentsCache) {
|
||||
if (!node) return node;
|
||||
const {
|
||||
type
|
||||
} = node;
|
||||
const newNode = {
|
||||
type: node.type
|
||||
};
|
||||
if ((0, _index2.isIdentifier)(node)) {
|
||||
newNode.name = node.name;
|
||||
if (hasOwn(node, "optional") && typeof node.optional === "boolean") {
|
||||
newNode.optional = node.optional;
|
||||
}
|
||||
if (hasOwn(node, "typeAnnotation")) {
|
||||
newNode.typeAnnotation = deep ? cloneIfNodeOrArray(node.typeAnnotation, true, withoutLoc, commentsCache) : node.typeAnnotation;
|
||||
}
|
||||
if (hasOwn(node, "decorators")) {
|
||||
newNode.decorators = deep ? cloneIfNodeOrArray(node.decorators, true, withoutLoc, commentsCache) : node.decorators;
|
||||
}
|
||||
} else if (!hasOwn(_index.NODE_FIELDS, type)) {
|
||||
throw new Error(`Unknown node type: "${type}"`);
|
||||
} else {
|
||||
for (const field of Object.keys(_index.NODE_FIELDS[type])) {
|
||||
if (hasOwn(node, field)) {
|
||||
if (deep) {
|
||||
newNode[field] = (0, _index2.isFile)(node) && field === "comments" ? maybeCloneComments(node.comments, deep, withoutLoc, commentsCache) : cloneIfNodeOrArray(node[field], true, withoutLoc, commentsCache);
|
||||
} else {
|
||||
newNode[field] = node[field];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasOwn(node, "loc")) {
|
||||
if (withoutLoc) {
|
||||
newNode.loc = null;
|
||||
} else {
|
||||
newNode.loc = node.loc;
|
||||
}
|
||||
}
|
||||
if (hasOwn(node, "leadingComments")) {
|
||||
newNode.leadingComments = maybeCloneComments(node.leadingComments, deep, withoutLoc, commentsCache);
|
||||
}
|
||||
if (hasOwn(node, "innerComments")) {
|
||||
newNode.innerComments = maybeCloneComments(node.innerComments, deep, withoutLoc, commentsCache);
|
||||
}
|
||||
if (hasOwn(node, "trailingComments")) {
|
||||
newNode.trailingComments = maybeCloneComments(node.trailingComments, deep, withoutLoc, commentsCache);
|
||||
}
|
||||
if (hasOwn(node, "extra")) {
|
||||
newNode.extra = Object.assign({}, node.extra);
|
||||
}
|
||||
return newNode;
|
||||
}
|
||||
function maybeCloneComments(comments, deep, withoutLoc, commentsCache) {
|
||||
if (!comments || !deep) {
|
||||
return comments;
|
||||
}
|
||||
return comments.map(comment => {
|
||||
const cache = commentsCache.get(comment);
|
||||
if (cache) return cache;
|
||||
const {
|
||||
type,
|
||||
value,
|
||||
loc
|
||||
} = comment;
|
||||
const ret = {
|
||||
type,
|
||||
value,
|
||||
loc
|
||||
};
|
||||
if (withoutLoc) {
|
||||
ret.loc = null;
|
||||
}
|
||||
commentsCache.set(comment, ret);
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=cloneNode.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user