@babel/generator
Advanced tools
+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 |
| {"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":[]} |
+78
-151
@@ -7,2 +7,6 @@ "use strict"; | ||
| exports.default = void 0; | ||
| const spaceIndents = []; | ||
| for (let i = 0; i < 32; i++) { | ||
| spaceIndents.push(" ".repeat(i * 2)); | ||
| } | ||
| class Buffer { | ||
@@ -15,7 +19,5 @@ constructor(map, indentChar) { | ||
| this._last = 0; | ||
| this._queue = []; | ||
| this._queueCursor = 0; | ||
| this._canMarkIdName = true; | ||
| this._indentChar = ""; | ||
| this._fastIndentations = []; | ||
| this._queuedChar = 0; | ||
| this._position = { | ||
@@ -34,46 +36,23 @@ line: 1, | ||
| this._indentChar = indentChar; | ||
| for (let i = 0; i < 64; i++) { | ||
| this._fastIndentations.push(indentChar.repeat(i)); | ||
| } | ||
| this._allocQueue(); | ||
| } | ||
| _allocQueue() { | ||
| const queue = this._queue; | ||
| for (let i = 0; i < 16; i++) { | ||
| queue.push({ | ||
| char: 0, | ||
| repeat: 1, | ||
| line: undefined, | ||
| column: undefined, | ||
| identifierName: undefined, | ||
| identifierNamePos: undefined, | ||
| filename: "" | ||
| }); | ||
| get() { | ||
| const { | ||
| _map, | ||
| _last | ||
| } = this; | ||
| if (this._queuedChar !== 32) { | ||
| this._flush(); | ||
| } | ||
| } | ||
| _pushQueue(char, repeat, line, column, filename) { | ||
| const cursor = this._queueCursor; | ||
| if (cursor === this._queue.length) { | ||
| this._allocQueue(); | ||
| 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 item = this._queue[cursor]; | ||
| item.char = char; | ||
| item.repeat = repeat; | ||
| item.line = line; | ||
| item.column = column; | ||
| item.filename = filename; | ||
| this._queueCursor++; | ||
| } | ||
| _popQueue() { | ||
| if (this._queueCursor === 0) { | ||
| throw new Error("Cannot pop from empty queue"); | ||
| } | ||
| return this._queue[--this._queueCursor]; | ||
| } | ||
| get() { | ||
| this._flush(); | ||
| const map = this._map; | ||
| const result = { | ||
| code: (this._buf + this._str).trimRight(), | ||
| decodedMap: map == null ? void 0 : map.getDecoded(), | ||
| code: code, | ||
| decodedMap: _map.getDecoded(), | ||
| get __mergedMap() { | ||
@@ -83,3 +62,3 @@ return this.map; | ||
| get map() { | ||
| const resultMap = map ? map.get() : null; | ||
| const resultMap = _map.get(); | ||
| result.map = resultMap; | ||
@@ -95,3 +74,3 @@ return resultMap; | ||
| get rawMappings() { | ||
| const mappings = map == null ? void 0 : map.getRawMappings(); | ||
| const mappings = _map.getRawMappings(); | ||
| result.rawMappings = mappings; | ||
@@ -111,62 +90,53 @@ return mappings; | ||
| this._flush(); | ||
| this._append(str, this._sourcePosition, maybeNewline); | ||
| this._append(str, maybeNewline); | ||
| } | ||
| appendChar(char) { | ||
| this._flush(); | ||
| this._appendChar(char, 1, this._sourcePosition); | ||
| this._appendChar(char, 1, true); | ||
| } | ||
| queue(char) { | ||
| if (char === 10) { | ||
| while (this._queueCursor !== 0) { | ||
| const char = this._queue[this._queueCursor - 1].char; | ||
| if (char !== 32 && char !== 9) { | ||
| break; | ||
| } | ||
| this._queueCursor--; | ||
| } | ||
| } | ||
| const sourcePosition = this._sourcePosition; | ||
| this._pushQueue(char, 1, sourcePosition.line, sourcePosition.column, sourcePosition.filename); | ||
| this._flush(); | ||
| this._queuedChar = char; | ||
| } | ||
| queueIndentation(repeat) { | ||
| if (repeat === 0) return; | ||
| this._pushQueue(-1, repeat, undefined, undefined, undefined); | ||
| } | ||
| _flush() { | ||
| const queueCursor = this._queueCursor; | ||
| const queue = this._queue; | ||
| for (let i = 0; i < queueCursor; i++) { | ||
| const item = queue[i]; | ||
| this._appendChar(item.char, item.repeat, item); | ||
| const queuedChar = this._queuedChar; | ||
| if (queuedChar !== 0) { | ||
| this._appendChar(queuedChar, 1, true); | ||
| this._queuedChar = 0; | ||
| } | ||
| this._queueCursor = 0; | ||
| } | ||
| _appendChar(char, repeat, sourcePos) { | ||
| _appendChar(char, repeat, useSourcePos) { | ||
| this._last = char; | ||
| if (char === -1) { | ||
| const fastIndentation = this._fastIndentations[repeat]; | ||
| if (fastIndentation !== undefined) { | ||
| this._str += fastIndentation; | ||
| } else { | ||
| this._str += repeat > 1 ? this._indentChar.repeat(repeat) : this._indentChar; | ||
| } | ||
| 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) { | ||
| this._mark(sourcePos.line, sourcePos.column, sourcePos.identifierName, sourcePos.identifierNamePos, sourcePos.filename); | ||
| this._position.column += repeat; | ||
| 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 { | ||
| this._position.line++; | ||
| this._position.column = 0; | ||
| position.line++; | ||
| position.column = 0; | ||
| } | ||
| if (this._canMarkIdName) { | ||
| sourcePos.identifierName = undefined; | ||
| sourcePos.identifierNamePos = undefined; | ||
| } | ||
| } | ||
| _append(str, sourcePos, maybeNewline) { | ||
| _append(str, maybeNewline) { | ||
| const len = str.length; | ||
| const position = this._position; | ||
| this._last = str.charCodeAt(len - 1); | ||
| const sourcePos = this._sourcePosition; | ||
| this._last = -1; | ||
| if (++this._appendCount > 4096) { | ||
@@ -180,3 +150,4 @@ +this._str; | ||
| } | ||
| if (!maybeNewline && !this._map) { | ||
| const hasMap = this._map !== null; | ||
| if (!maybeNewline && !hasMap) { | ||
| position.column += len; | ||
@@ -198,4 +169,4 @@ return; | ||
| let last = 0; | ||
| if (i !== 0) { | ||
| this._mark(line, column, identifierName, identifierNamePos, filename); | ||
| if (hasMap && i !== 0) { | ||
| this._map.mark(position, line, column, identifierName, identifierNamePos, filename); | ||
| } | ||
@@ -207,3 +178,6 @@ while (i !== -1) { | ||
| if (last < len && line !== undefined) { | ||
| this._mark(++line, 0, undefined, undefined, filename); | ||
| line++; | ||
| if (hasMap) { | ||
| this._map.mark(position, line, 0, undefined, undefined, filename); | ||
| } | ||
| } | ||
@@ -214,49 +188,19 @@ i = str.indexOf("\n", last); | ||
| } | ||
| _mark(line, column, identifierName, identifierNamePos, filename) { | ||
| var _this$_map; | ||
| (_this$_map = this._map) == null || _this$_map.mark(this._position, line, column, identifierName, identifierNamePos, filename); | ||
| } | ||
| removeTrailingNewline() { | ||
| const queueCursor = this._queueCursor; | ||
| if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 10) { | ||
| this._queueCursor--; | ||
| removeLastSemicolon() { | ||
| if (this._queuedChar === 59) { | ||
| this._queuedChar = 0; | ||
| } | ||
| } | ||
| removeLastSemicolon() { | ||
| const queueCursor = this._queueCursor; | ||
| if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 59) { | ||
| this._queueCursor--; | ||
| getLastChar(checkQueue) { | ||
| if (!checkQueue) { | ||
| return this._last; | ||
| } | ||
| const queuedChar = this._queuedChar; | ||
| return queuedChar !== 0 ? queuedChar : this._last; | ||
| } | ||
| getLastChar() { | ||
| const queueCursor = this._queueCursor; | ||
| return queueCursor !== 0 ? this._queue[queueCursor - 1].char : this._last; | ||
| } | ||
| getNewlineCount() { | ||
| const queueCursor = this._queueCursor; | ||
| let count = 0; | ||
| if (queueCursor === 0) return this._last === 10 ? 1 : 0; | ||
| for (let i = queueCursor - 1; i >= 0; i--) { | ||
| if (this._queue[i].char !== 10) { | ||
| break; | ||
| } | ||
| count++; | ||
| } | ||
| return count === queueCursor && this._last === 10 ? count + 1 : count; | ||
| return this._queuedChar === 0 && this._last === 10 ? 1 : 0; | ||
| } | ||
| endsWithCharAndNewline() { | ||
| const queue = this._queue; | ||
| const queueCursor = this._queueCursor; | ||
| if (queueCursor !== 0) { | ||
| const lastCp = queue[queueCursor - 1].char; | ||
| if (lastCp !== 10) return; | ||
| if (queueCursor > 1) { | ||
| return queue[queueCursor - 2].char; | ||
| } else { | ||
| return this._last; | ||
| } | ||
| } | ||
| } | ||
| hasContent() { | ||
| return this._queueCursor !== 0 || !!this._last; | ||
| return this._last !== 0; | ||
| } | ||
@@ -271,3 +215,3 @@ exactSource(loc, cb) { | ||
| const sourcePos = this._sourcePosition; | ||
| if (identifierName) { | ||
| if (identifierName != null) { | ||
| this._canMarkIdName = false; | ||
@@ -277,3 +221,3 @@ sourcePos.identifierName = identifierName; | ||
| cb(); | ||
| if (identifierName) { | ||
| if (identifierName != null) { | ||
| this._canMarkIdName = true; | ||
@@ -294,2 +238,3 @@ sourcePos.identifierName = undefined; | ||
| _normalizePosition(prop, loc, columnOffset) { | ||
| this._flush(); | ||
| const pos = loc[prop]; | ||
@@ -304,24 +249,6 @@ const target = this._sourcePosition; | ||
| getCurrentColumn() { | ||
| const queue = this._queue; | ||
| const queueCursor = this._queueCursor; | ||
| let lastIndex = -1; | ||
| let len = 0; | ||
| for (let i = 0; i < queueCursor; i++) { | ||
| const item = queue[i]; | ||
| if (item.char === 10) { | ||
| lastIndex = len; | ||
| } | ||
| len += item.repeat; | ||
| } | ||
| return lastIndex === -1 ? this._position.column + len : len - 1 - lastIndex; | ||
| return this._position.column + (this._queuedChar ? 1 : 0); | ||
| } | ||
| getCurrentLine() { | ||
| let count = 0; | ||
| const queue = this._queue; | ||
| for (let i = 0; i < this._queueCursor; i++) { | ||
| if (queue[i].char === 10) { | ||
| count++; | ||
| } | ||
| } | ||
| return this._position.line + count; | ||
| return this._position.line; | ||
| } | ||
@@ -328,0 +255,0 @@ } |
@@ -21,4 +21,3 @@ "use strict"; | ||
| var _node$directives; | ||
| this.noIndentInnerCommentsHere(); | ||
| this.printInnerComments(); | ||
| this.printInnerComments(false); | ||
| const directivesLen = (_node$directives = node.directives) == null ? void 0 : _node$directives.length; | ||
@@ -28,3 +27,3 @@ if (directivesLen) { | ||
| const newline = node.body.length ? 2 : 1; | ||
| this.printSequence(node.directives, undefined, newline); | ||
| this.printSequence(node.directives, undefined, undefined, newline); | ||
| if (!((_node$directives$trai = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai.length)) { | ||
@@ -39,3 +38,3 @@ this.newline(newline); | ||
| this.tokenChar(123); | ||
| const exit = this.enterDelimited(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| const directivesLen = (_node$directives2 = node.directives) == null ? void 0 : _node$directives2.length; | ||
@@ -45,3 +44,3 @@ if (directivesLen) { | ||
| const newline = node.body.length ? 2 : 1; | ||
| this.printSequence(node.directives, true, newline); | ||
| this.printSequence(node.directives, true, true, newline); | ||
| if (!((_node$directives$trai2 = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai2.length)) { | ||
@@ -51,4 +50,4 @@ this.newline(newline); | ||
| } | ||
| this.printSequence(node.body, true); | ||
| exit(); | ||
| this.printSequence(node.body, true, true); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| this.rightBrace(node); | ||
@@ -81,3 +80,3 @@ } | ||
| this.token(`#!${node.value}`); | ||
| this.newline(1, true); | ||
| this._newline(); | ||
| } | ||
@@ -84,0 +83,0 @@ function Placeholder(node) { |
@@ -16,2 +16,6 @@ "use strict"; | ||
| 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 { | ||
@@ -23,3 +27,3 @@ isExportDefaultDeclaration, | ||
| const inExport = isExportDefaultDeclaration(parent) || isExportNamedDeclaration(parent); | ||
| if (!inExport || !this._shouldPrintDecoratorsBeforeExport(parent)) { | ||
| if (!inExport || !_expressions._shouldPrintDecoratorsBeforeExport.call(this, parent)) { | ||
| this.printJoin(node.decorators); | ||
@@ -62,8 +66,7 @@ } | ||
| } else { | ||
| this.newline(); | ||
| const separator = classBodyEmptySemicolonsPrinter(this, node); | ||
| separator == null || separator(-1); | ||
| const exit = this.enterDelimited(); | ||
| this.printJoin(node.body, true, true, separator, true); | ||
| exit(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| this.printJoin(node.body, true, true, separator, true, true); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| if (!this.endsWith(10)) this.newline(); | ||
@@ -96,3 +99,3 @@ this.rightBrace(node); | ||
| while (k < indexes.length && printer.tokenMap.matchesOriginal(tok = printer._tokens[indexes[k]], ";") && tok.start < end) { | ||
| printer.token(";", undefined, occurrenceCount++); | ||
| printer.tokenChar(59, occurrenceCount++); | ||
| k++; | ||
@@ -109,3 +112,3 @@ } | ||
| } | ||
| this.tsPrintClassMemberModifiers(node); | ||
| _typescript._tsPrintClassMemberModifiers.call(this, node); | ||
| if (node.computed) { | ||
@@ -116,3 +119,3 @@ this.tokenChar(91); | ||
| } else { | ||
| this._variance(node); | ||
| _flow._variance.call(this, node); | ||
| this.print(node.key); | ||
@@ -140,3 +143,3 @@ } | ||
| if (endLine) this.catchUp(endLine); | ||
| this.tsPrintClassMemberModifiers(node); | ||
| _typescript._tsPrintClassMemberModifiers.call(this, node); | ||
| this.word("accessor", true); | ||
@@ -149,3 +152,3 @@ this.space(); | ||
| } else { | ||
| this._variance(node); | ||
| _flow._variance.call(this, node); | ||
| this.print(node.key); | ||
@@ -170,3 +173,3 @@ } | ||
| this.printJoin(node.decorators); | ||
| this.tsPrintClassMemberModifiers(node); | ||
| _typescript._tsPrintClassMemberModifiers.call(this, node); | ||
| this.print(node.key); | ||
@@ -189,3 +192,3 @@ if (node.optional) { | ||
| function ClassMethod(node) { | ||
| this._classMethodHead(node); | ||
| _classMethodHead.call(this, node); | ||
| this.space(); | ||
@@ -195,3 +198,3 @@ this.print(node.body); | ||
| function ClassPrivateMethod(node) { | ||
| this._classMethodHead(node); | ||
| _classMethodHead.call(this, node); | ||
| this.space(); | ||
@@ -207,4 +210,4 @@ this.print(node.body); | ||
| } | ||
| this.tsPrintClassMemberModifiers(node); | ||
| this._methodHead(node); | ||
| _typescript._tsPrintClassMemberModifiers.call(this, node); | ||
| _methods._methodHead.call(this, node); | ||
| } | ||
@@ -211,0 +214,0 @@ function StaticBlock(node) { |
@@ -6,70 +6,69 @@ "use strict"; | ||
| }); | ||
| exports.addDeprecatedGenerators = addDeprecatedGenerators; | ||
| function addDeprecatedGenerators(PrinterClass) { | ||
| const deprecatedBabel7Generators = { | ||
| Noop() {}, | ||
| TSExpressionWithTypeArguments(node) { | ||
| this.print(node.expression); | ||
| this.print(node.typeParameters); | ||
| }, | ||
| DecimalLiteral(node) { | ||
| const raw = this.getPossibleRaw(node); | ||
| if (!this.format.minified && raw !== undefined) { | ||
| this.word(raw); | ||
| return; | ||
| 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.word(node.value + "m"); | ||
| }, | ||
| 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); | ||
| }, | ||
| 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); | ||
| } | ||
| }; | ||
| Object.assign(PrinterClass.prototype, deprecatedBabel7Generators); | ||
| } | ||
| this.token(endToken); | ||
| } | ||
| //# sourceMappingURL=deprecated.js.map |
@@ -6,5 +6,6 @@ "use strict"; | ||
| }); | ||
| exports.LogicalExpression = exports.BinaryExpression = exports.AssignmentExpression = AssignmentExpression; | ||
| exports.LogicalExpression = exports.AssignmentExpression = AssignmentExpression; | ||
| exports.AssignmentPattern = AssignmentPattern; | ||
| exports.AwaitExpression = AwaitExpression; | ||
| exports.BinaryExpression = BinaryExpression; | ||
| exports.BindExpression = BindExpression; | ||
@@ -47,7 +48,8 @@ exports.CallExpression = CallExpression; | ||
| } = node; | ||
| if (operator === "void" || operator === "delete" || operator === "typeof" || operator === "throw") { | ||
| const firstChar = operator.charCodeAt(0); | ||
| if (firstChar >= 97 && firstChar <= 122) { | ||
| this.word(operator); | ||
| this.space(); | ||
| } else { | ||
| this.token(operator); | ||
| this.tokenChar(firstChar); | ||
| } | ||
@@ -67,5 +69,5 @@ this.print(node.argument); | ||
| this.tokenChar(40); | ||
| const exit = this.enterDelimited(); | ||
| this.print(node.expression); | ||
| exit(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| this.print(node.expression, undefined, true); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| this.rightParens(node); | ||
@@ -75,7 +77,7 @@ } | ||
| if (node.prefix) { | ||
| this.token(node.operator); | ||
| this.token(node.operator, false, 0, true); | ||
| this.print(node.argument); | ||
| } else { | ||
| this.print(node.argument, true); | ||
| this.token(node.operator); | ||
| this.token(node.operator, false, 0, true); | ||
| } | ||
@@ -112,5 +114,5 @@ } | ||
| this.tokenChar(40); | ||
| const exit = this.enterDelimited(); | ||
| this.printList(node.arguments, this.shouldPrintTrailingComma(")")); | ||
| exit(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| this.printList(node.arguments, this.shouldPrintTrailingComma(")"), undefined, undefined, undefined, true); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| this.rightParens(node); | ||
@@ -135,3 +137,6 @@ } | ||
| this.tokenChar(64); | ||
| this.print(node.expression); | ||
| const { | ||
| expression | ||
| } = node; | ||
| this.print(expression); | ||
| this.newline(); | ||
@@ -176,5 +181,5 @@ } | ||
| this.tokenChar(40); | ||
| const exit = this.enterDelimited(); | ||
| this.printList(node.arguments); | ||
| exit(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| this.printList(node.arguments, undefined, undefined, undefined, undefined, true); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| this.rightParens(node); | ||
@@ -187,5 +192,5 @@ } | ||
| this.tokenChar(40); | ||
| const exit = this.enterDelimited(); | ||
| this.printList(node.arguments, this.shouldPrintTrailingComma(")")); | ||
| exit(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| this.printList(node.arguments, this.shouldPrintTrailingComma(")"), undefined, undefined, undefined, true); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| this.rightParens(node); | ||
@@ -239,7 +244,17 @@ } | ||
| this.space(); | ||
| if (node.operator === "in" || node.operator === "instanceof") { | ||
| this.word(node.operator); | ||
| 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(node.operator); | ||
| this._endsWithDiv = node.operator === "/"; | ||
| this.token(operator, false, 0, true); | ||
| this.setLastChar(operator.charCodeAt(operator.length - 1)); | ||
| } | ||
@@ -264,7 +279,7 @@ this.space(); | ||
| if (computed) { | ||
| const exit = this.enterDelimited(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| this.tokenChar(91); | ||
| this.print(node.property); | ||
| this.print(node.property, undefined, true); | ||
| this.tokenChar(93); | ||
| exit(); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| } else { | ||
@@ -271,0 +286,0 @@ this.tokenChar(46); |
+10
-10
@@ -112,3 +112,3 @@ "use strict"; | ||
| this.space(); | ||
| this._interfaceish(node); | ||
| _interfaceish.call(this, node); | ||
| } | ||
@@ -144,3 +144,3 @@ function DeclareFunction(node, parent) { | ||
| this.space(); | ||
| this.InterfaceDeclaration(node); | ||
| InterfaceDeclaration.call(this, node); | ||
| } | ||
@@ -167,3 +167,3 @@ function DeclareModule(node) { | ||
| this.space(); | ||
| this.TypeAlias(node); | ||
| TypeAlias.call(this, node); | ||
| } | ||
@@ -175,3 +175,3 @@ function DeclareOpaqueType(node, parent) { | ||
| } | ||
| this.OpaqueType(node); | ||
| OpaqueType.call(this, node); | ||
| } | ||
@@ -404,3 +404,3 @@ function DeclareVariable(node, parent) { | ||
| this.space(); | ||
| this._interfaceish(node); | ||
| _interfaceish.call(this, node); | ||
| } | ||
@@ -483,3 +483,3 @@ function andSeparator(occurrenceCount) { | ||
| function TypeParameter(node) { | ||
| this._variance(node); | ||
| _variance.call(this, node); | ||
| this.word(node.name); | ||
@@ -526,3 +526,3 @@ if (node.bound) { | ||
| this.space(); | ||
| this.printJoin(props, true, true, undefined, undefined, () => { | ||
| this.printJoin(props, true, true, () => { | ||
| if (props.length !== 1 || node.inexact) { | ||
@@ -532,3 +532,3 @@ this.tokenChar(44); | ||
| } | ||
| }); | ||
| }, true); | ||
| this.space(); | ||
@@ -579,3 +579,3 @@ } | ||
| } | ||
| this._variance(node); | ||
| _variance.call(this, node); | ||
| this.tokenChar(91); | ||
@@ -606,3 +606,3 @@ if (node.id) { | ||
| } | ||
| this._variance(node); | ||
| _variance.call(this, node); | ||
| this.print(node.key); | ||
@@ -609,0 +609,0 @@ if (node.optional) this.tokenChar(63); |
@@ -20,11 +20,12 @@ "use strict"; | ||
| } = _t; | ||
| function _params(node, idNode, parentNode) { | ||
| function _params(node, noLineTerminator, idNode, parentNode) { | ||
| this.print(node.typeParameters); | ||
| const nameInfo = _getFuncIdName.call(this, idNode, parentNode); | ||
| if (nameInfo) { | ||
| this.sourceIdentifierName(nameInfo.name, nameInfo.pos); | ||
| if (idNode !== undefined || parentNode !== undefined) { | ||
| const nameInfo = _getFuncIdName.call(this, idNode, parentNode); | ||
| if (nameInfo) { | ||
| this.sourceIdentifierName(nameInfo.name, nameInfo.pos); | ||
| } | ||
| } | ||
| this.tokenChar(40); | ||
| this._parameters(node.params, ")"); | ||
| const noLineTerminator = node.type === "ArrowFunctionExpression"; | ||
| _parameters.call(this, node.params, 41); | ||
| this.print(node.returnType, noLineTerminator); | ||
@@ -34,22 +35,22 @@ this._noLineTerminator = noLineTerminator; | ||
| function _parameters(parameters, endToken) { | ||
| const exit = this.enterDelimited(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| const trailingComma = this.shouldPrintTrailingComma(endToken); | ||
| const paramLength = parameters.length; | ||
| for (let i = 0; i < paramLength; i++) { | ||
| this._param(parameters[i]); | ||
| _param.call(this, parameters[i]); | ||
| if (trailingComma || i < paramLength - 1) { | ||
| this.token(",", undefined, i); | ||
| this.tokenChar(44, i); | ||
| this.space(); | ||
| } | ||
| } | ||
| this.token(endToken); | ||
| exit(); | ||
| this.tokenChar(endToken); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| } | ||
| function _param(parameter) { | ||
| this.printJoin(parameter.decorators); | ||
| this.print(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); | ||
| this.print(parameter.typeAnnotation, undefined, true); | ||
| } | ||
@@ -82,3 +83,7 @@ function _methodHead(node) { | ||
| } | ||
| this._params(node, node.computed && node.key.type !== "StringLiteral" ? undefined : node.key); | ||
| if (this._buf._map) { | ||
| _params.call(this, node, false, node.computed && node.key.type !== "StringLiteral" ? undefined : node.key); | ||
| } else { | ||
| _params.call(this, node, false); | ||
| } | ||
| } | ||
@@ -94,7 +99,7 @@ function _predicate(node, noLineTerminatorAfter) { | ||
| } | ||
| function _functionHead(node, parent) { | ||
| function _functionHead(node, parent, hasPredicate) { | ||
| if (node.async) { | ||
| this.word("async"); | ||
| if (!this.format.preserveFormat) { | ||
| this._endsWithInnerRaw = false; | ||
| this._innerCommentsState = 0; | ||
| } | ||
@@ -106,3 +111,3 @@ this.space(); | ||
| if (!this.format.preserveFormat) { | ||
| this._endsWithInnerRaw = false; | ||
| this._innerCommentsState = 0; | ||
| } | ||
@@ -115,9 +120,13 @@ this.tokenChar(42); | ||
| } | ||
| this._params(node, node.id, parent); | ||
| if (node.type !== "TSDeclareFunction") { | ||
| this._predicate(node); | ||
| 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) { | ||
| this._functionHead(node, parent); | ||
| _functionHead.call(this, node, parent, true); | ||
| this.space(); | ||
@@ -131,8 +140,8 @@ this.print(node.body); | ||
| } | ||
| if (this._shouldPrintArrowParamsParens(node)) { | ||
| this._params(node, undefined, parent); | ||
| if (_shouldPrintArrowParamsParens.call(this, node)) { | ||
| _params.call(this, node, true, undefined, this._buf._map ? parent : undefined); | ||
| } else { | ||
| this.print(node.params[0], true); | ||
| } | ||
| this._predicate(node, true); | ||
| _predicate.call(this, node, true); | ||
| this.space(); | ||
@@ -139,0 +148,0 @@ this.printInnerComments(); |
@@ -21,2 +21,3 @@ "use strict"; | ||
| var _index = require("../node/index.js"); | ||
| var _expressions = require("./expressions.js"); | ||
| const { | ||
@@ -120,3 +121,3 @@ isClassDeclaration, | ||
| this.space(); | ||
| this._printAttributes(node, false); | ||
| _printAttributes.call(this, node, false); | ||
| } else { | ||
@@ -128,3 +129,3 @@ this.print(node.source); | ||
| function maybePrintDecoratorsBeforeExport(printer, node) { | ||
| if (isClassDeclaration(node.declaration) && printer._shouldPrintDecoratorsBeforeExport(node)) { | ||
| if (isClassDeclaration(node.declaration) && _expressions._shouldPrintDecoratorsBeforeExport.call(printer, node)) { | ||
| printer.printJoin(node.declaration.decorators); | ||
@@ -180,3 +181,3 @@ } | ||
| this.space(); | ||
| this._printAttributes(node, hasBrace); | ||
| _printAttributes.call(this, node, hasBrace); | ||
| } else { | ||
@@ -254,3 +255,3 @@ this.print(node.source); | ||
| this.space(); | ||
| this._printAttributes(node, hasBrace); | ||
| _printAttributes.call(this, node, hasBrace); | ||
| } else { | ||
@@ -257,0 +258,0 @@ this.print(node.source); |
@@ -11,3 +11,4 @@ "use strict"; | ||
| exports.DoWhileStatement = DoWhileStatement; | ||
| exports.ForOfStatement = exports.ForInStatement = void 0; | ||
| exports.ForInStatement = ForInStatement; | ||
| exports.ForOfStatement = ForOfStatement; | ||
| exports.ForStatement = ForStatement; | ||
@@ -26,5 +27,5 @@ exports.IfStatement = IfStatement; | ||
| var _t = require("@babel/types"); | ||
| var _index = require("../node/index.js"); | ||
| const { | ||
| isFor, | ||
| isForStatement, | ||
| isIfStatement, | ||
@@ -39,3 +40,3 @@ isStatement | ||
| this.tokenChar(41); | ||
| this.printBlock(node); | ||
| this.printBlock(node.body); | ||
| } | ||
@@ -81,7 +82,5 @@ function IfStatement(node) { | ||
| this.tokenChar(40); | ||
| { | ||
| const exit = this.enterForStatementInit(); | ||
| this.print(node.init); | ||
| exit(); | ||
| } | ||
| this.tokenContext |= _index.TokenContext.forInitHead | _index.TokenContext.forInOrInitHeadAccumulate; | ||
| this.print(node.init); | ||
| this.tokenContext = _index.TokenContext.normal; | ||
| this.tokenChar(59); | ||
@@ -92,3 +91,3 @@ if (node.test) { | ||
| } | ||
| this.token(";", false, 1); | ||
| this.tokenChar(59, 1); | ||
| if (node.update) { | ||
@@ -99,3 +98,3 @@ this.space(); | ||
| this.tokenChar(41); | ||
| this.printBlock(node); | ||
| this.printBlock(node.body); | ||
| } | ||
@@ -108,9 +107,23 @@ function WhileStatement(node) { | ||
| this.tokenChar(41); | ||
| this.printBlock(node); | ||
| this.printBlock(node.body); | ||
| } | ||
| function ForXStatement(node) { | ||
| function ForInStatement(node) { | ||
| this.word("for"); | ||
| this.space(); | ||
| const isForOf = node.type === "ForOfStatement"; | ||
| if (isForOf && node.await) { | ||
| 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"); | ||
@@ -121,16 +134,11 @@ this.space(); | ||
| this.tokenChar(40); | ||
| { | ||
| const exit = this.enterForXStatementInit(isForOf); | ||
| this.print(node.left); | ||
| exit == null || exit(); | ||
| } | ||
| this.tokenContext |= _index.TokenContext.forOfHead; | ||
| this.print(node.left); | ||
| this.space(); | ||
| this.word(isForOf ? "of" : "in"); | ||
| this.word("of"); | ||
| this.space(); | ||
| this.print(node.right); | ||
| this.tokenChar(41); | ||
| this.printBlock(node); | ||
| this.printBlock(node.body); | ||
| } | ||
| const ForInStatement = exports.ForInStatement = ForXStatement; | ||
| const ForOfStatement = exports.ForOfStatement = ForXStatement; | ||
| function DoWhileStatement(node) { | ||
@@ -236,2 +244,6 @@ this.word("do"); | ||
| } | ||
| function commaSeparatorWithNewline(occurrenceCount) { | ||
| this.tokenChar(44, occurrenceCount); | ||
| this.newline(); | ||
| } | ||
| function VariableDeclaration(node, parent) { | ||
@@ -245,8 +257,11 @@ if (node.declare) { | ||
| } = node; | ||
| if (kind === "await using") { | ||
| this.word("await"); | ||
| this.space(); | ||
| this.word("using", true); | ||
| } else { | ||
| this.word(kind, kind === "using"); | ||
| switch (kind) { | ||
| case "await using": | ||
| this.word("await"); | ||
| this.space(); | ||
| case "using": | ||
| this.word("using", true); | ||
| break; | ||
| default: | ||
| this.word(kind); | ||
| } | ||
@@ -259,14 +274,19 @@ this.space(); | ||
| hasInits = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| this.printList(node.declarations, undefined, undefined, node.declarations.length > 1, hasInits ? function (occurrenceCount) { | ||
| this.token(",", false, occurrenceCount); | ||
| this.newline(); | ||
| } : undefined); | ||
| if (isFor(parent)) { | ||
| if (isForStatement(parent)) { | ||
| if (parent.init === node) return; | ||
| } else { | ||
| if (parent.left === node) return; | ||
| 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; | ||
| } | ||
| } | ||
@@ -273,0 +293,0 @@ } |
@@ -35,5 +35,5 @@ "use strict"; | ||
| function TemplateLiteral(node) { | ||
| this._printTemplate(node, node.expressions); | ||
| _printTemplate.call(this, node, node.expressions); | ||
| } | ||
| //# sourceMappingURL=template-literals.js.map |
+17
-18
@@ -27,2 +27,3 @@ "use strict"; | ||
| var _jsesc = require("jsesc"); | ||
| var _methods = require("./methods.js"); | ||
| const { | ||
@@ -32,7 +33,4 @@ isAssignmentPattern, | ||
| } = _t; | ||
| let lastRawIdentNode = null; | ||
| let lastRawIdentResult = ""; | ||
| function _getRawIdentifier(node) { | ||
| if (node === lastRawIdentNode) return lastRawIdentResult; | ||
| lastRawIdentNode = node; | ||
| const { | ||
@@ -49,5 +47,7 @@ name | ||
| function Identifier(node) { | ||
| var _node$loc; | ||
| this.sourceIdentifierName(((_node$loc = node.loc) == null ? void 0 : _node$loc.identifierName) || node.name); | ||
| this.word(this.tokenMap ? this._getRawIdentifier(node) : node.name); | ||
| 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); | ||
| } | ||
@@ -65,14 +65,13 @@ function ArgumentPlaceholder() { | ||
| if (props.length) { | ||
| const exit = this.enterDelimited(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| this.space(); | ||
| this.printList(props, this.shouldPrintTrailingComma("}"), true, true); | ||
| this.printList(props, this.shouldPrintTrailingComma("}"), true, true, undefined, true); | ||
| this.space(); | ||
| exit(); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| } | ||
| this.sourceWithOffset("end", node.loc, -1); | ||
| this.tokenChar(125); | ||
| this.rightBrace(node); | ||
| } | ||
| function ObjectMethod(node) { | ||
| this.printJoin(node.decorators); | ||
| this._methodHead(node); | ||
| _methods._methodHead.call(this, node); | ||
| this.space(); | ||
@@ -105,3 +104,3 @@ this.print(node.body); | ||
| this.tokenChar(91); | ||
| const exit = this.enterDelimited(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| for (let i = 0; i < elems.length; i++) { | ||
@@ -111,15 +110,15 @@ const elem = elems[i]; | ||
| if (i > 0) this.space(); | ||
| this.print(elem); | ||
| this.print(elem, undefined, true); | ||
| if (i < len - 1 || this.shouldPrintTrailingComma("]")) { | ||
| this.token(",", false, i); | ||
| this.tokenChar(44, i); | ||
| } | ||
| } else { | ||
| this.token(",", false, i); | ||
| this.tokenChar(44, i); | ||
| } | ||
| } | ||
| exit(); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| this.tokenChar(93); | ||
| } | ||
| function RegExpLiteral(node) { | ||
| this.word(`/${node.pattern}/${node.flags}`); | ||
| this.word(`/${node.pattern}/${node.flags}`, false); | ||
| } | ||
@@ -126,0 +125,0 @@ function BooleanLiteral(node) { |
@@ -8,3 +8,3 @@ "use strict"; | ||
| exports.TSArrayType = TSArrayType; | ||
| exports.TSSatisfiesExpression = exports.TSAsExpression = TSTypeExpression; | ||
| exports.TSAsExpression = TSAsExpression; | ||
| exports.TSBigIntKeyword = TSBigIntKeyword; | ||
@@ -53,2 +53,3 @@ exports.TSBooleanKeyword = TSBooleanKeyword; | ||
| exports.TSRestType = TSRestType; | ||
| exports.TSSatisfiesExpression = TSSatisfiesExpression; | ||
| exports.TSStringKeyword = TSStringKeyword; | ||
@@ -73,6 +74,6 @@ exports.TSSymbolKeyword = TSSymbolKeyword; | ||
| exports.TSVoidKeyword = TSVoidKeyword; | ||
| exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers; | ||
| exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType; | ||
| exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName; | ||
| exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase; | ||
| exports._tsPrintClassMemberModifiers = _tsPrintClassMemberModifiers; | ||
| var _methods = require("./methods.js"); | ||
| var _classes = require("./classes.js"); | ||
| var _templateLiterals = require("./template-literals.js"); | ||
| function TSTypeAnnotation(node, parent) { | ||
@@ -130,3 +131,3 @@ this.token((parent.type === "TSFunctionType" || parent.type === "TSConstructorType") && parent.typeAnnotation === node ? "=>" : ":"); | ||
| } | ||
| this._param(node.parameter); | ||
| _methods._param.call(this, node.parameter); | ||
| } | ||
@@ -138,7 +139,7 @@ function TSDeclareFunction(node, parent) { | ||
| } | ||
| this._functionHead(node, parent); | ||
| _methods._functionHead.call(this, node, parent, false); | ||
| this.semicolon(); | ||
| } | ||
| function TSDeclareMethod(node) { | ||
| this._classMethodHead(node); | ||
| _classes._classMethodHead.call(this, node); | ||
| this.semicolon(); | ||
@@ -152,3 +153,3 @@ } | ||
| function TSCallSignatureDeclaration(node) { | ||
| this.tsPrintSignatureDeclarationBase(node); | ||
| tsPrintSignatureDeclarationBase.call(this, node); | ||
| maybePrintTrailingCommaOrSemicolon(this, node); | ||
@@ -170,3 +171,3 @@ } | ||
| this.space(); | ||
| this.tsPrintSignatureDeclarationBase(node); | ||
| tsPrintSignatureDeclarationBase.call(this, node); | ||
| maybePrintTrailingCommaOrSemicolon(this, node); | ||
@@ -182,3 +183,3 @@ } | ||
| } | ||
| this.tsPrintPropertyOrMethodName(node); | ||
| tsPrintPropertyOrMethodName.call(this, node); | ||
| this.print(node.typeAnnotation); | ||
@@ -207,4 +208,4 @@ maybePrintTrailingCommaOrSemicolon(this, node); | ||
| } | ||
| this.tsPrintPropertyOrMethodName(node); | ||
| this.tsPrintSignatureDeclarationBase(node); | ||
| tsPrintPropertyOrMethodName.call(this, node); | ||
| tsPrintSignatureDeclarationBase.call(this, node); | ||
| maybePrintTrailingCommaOrSemicolon(this, node); | ||
@@ -226,3 +227,3 @@ } | ||
| this.tokenChar(91); | ||
| this._parameters(node.parameters, "]"); | ||
| _methods._parameters.call(this, node.parameters, 93); | ||
| this.print(node.typeAnnotation); | ||
@@ -274,3 +275,3 @@ maybePrintTrailingCommaOrSemicolon(this, node); | ||
| function TSFunctionType(node) { | ||
| this.tsPrintFunctionOrConstructorType(node); | ||
| tsPrintFunctionOrConstructorType.call(this, node); | ||
| } | ||
@@ -284,3 +285,3 @@ function TSConstructorType(node) { | ||
| this.space(); | ||
| this.tsPrintFunctionOrConstructorType(node); | ||
| tsPrintFunctionOrConstructorType.call(this, node); | ||
| } | ||
@@ -294,3 +295,3 @@ function tsPrintFunctionOrConstructorType(node) { | ||
| this.tokenChar(40); | ||
| this._parameters(parameters, ")"); | ||
| _methods._parameters.call(this, parameters, 41); | ||
| this.space(); | ||
@@ -328,3 +329,3 @@ const returnType = node.typeAnnotation; | ||
| function TSTypeLiteral(node) { | ||
| printBraced(this, node, () => this.printJoin(node.members, true, true)); | ||
| printBraced(this, node, () => this.printJoin(node.members, true, true, undefined, undefined, true)); | ||
| } | ||
@@ -418,3 +419,3 @@ function TSArrayType(node) { | ||
| this.tokenChar(123); | ||
| const exit = this.enterDelimited(); | ||
| const oldNoLineTerminatorAfterNode = this.enterDelimited(); | ||
| this.space(); | ||
@@ -431,3 +432,3 @@ if (readonly) { | ||
| this.space(); | ||
| this.print(node.typeParameter.constraint); | ||
| this.print(node.typeParameter.constraint, undefined, true); | ||
| if (nameType) { | ||
@@ -437,3 +438,3 @@ this.space(); | ||
| this.space(); | ||
| this.print(nameType); | ||
| this.print(nameType, undefined, true); | ||
| } | ||
@@ -448,6 +449,6 @@ this.tokenChar(93); | ||
| this.space(); | ||
| this.print(typeAnnotation); | ||
| this.print(typeAnnotation, undefined, true); | ||
| } | ||
| this.space(); | ||
| exit(); | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| this.tokenChar(125); | ||
@@ -461,3 +462,3 @@ } | ||
| function TSTemplateLiteralType(node) { | ||
| this._printTemplate(node, node.types); | ||
| _templateLiterals._printTemplate.call(this, node, node.types); | ||
| } | ||
@@ -497,3 +498,3 @@ function TSLiteralType(node) { | ||
| function TSInterfaceBody(node) { | ||
| printBraced(this, node, () => this.printJoin(node.body, true, true)); | ||
| printBraced(this, node, () => this.printJoin(node.body, true, true, undefined, undefined, true)); | ||
| } | ||
@@ -521,5 +522,4 @@ function TSTypeAliasDeclaration(node) { | ||
| } | ||
| function TSTypeExpression(node) { | ||
| function TSAsExpression(node) { | ||
| const { | ||
| type, | ||
| expression, | ||
@@ -530,6 +530,17 @@ typeAnnotation | ||
| this.space(); | ||
| this.word(type === "TSAsExpression" ? "as" : "satisfies"); | ||
| 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) { | ||
@@ -573,3 +584,3 @@ const { | ||
| var _this$shouldPrintTrai; | ||
| return this.printList(node.members, (_this$shouldPrintTrai = this.shouldPrintTrailingComma("}")) != null ? _this$shouldPrintTrai : true, true, true); | ||
| return this.printList(node.members, (_this$shouldPrintTrai = this.shouldPrintTrailingComma("}")) != null ? _this$shouldPrintTrai : true, true, true, undefined, true); | ||
| }); | ||
@@ -619,3 +630,3 @@ } | ||
| function TSModuleBlock(node) { | ||
| printBraced(this, node, () => this.printSequence(node.body, true)); | ||
| printBraced(this, node, () => this.printSequence(node.body, true, true)); | ||
| } | ||
@@ -670,2 +681,3 @@ function TSImportType(node) { | ||
| this.tokenChar(33); | ||
| this.setLastChar(33); | ||
| } | ||
@@ -697,7 +709,7 @@ function TSExportAssignment(node) { | ||
| this.tokenChar(40); | ||
| this._parameters(parameters, ")"); | ||
| _methods._parameters.call(this, parameters, 41); | ||
| const returnType = node.typeAnnotation; | ||
| this.print(returnType); | ||
| } | ||
| function tsPrintClassMemberModifiers(node) { | ||
| function _tsPrintClassMemberModifiers(node) { | ||
| const isPrivateField = node.type === "ClassPrivateProperty"; | ||
@@ -714,5 +726,5 @@ const isPublicField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty"; | ||
| printer.token("{"); | ||
| const exit = printer.enterDelimited(); | ||
| const oldNoLineTerminatorAfterNode = printer.enterDelimited(); | ||
| cb(); | ||
| exit(); | ||
| printer._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| printer.rightBrace(node); | ||
@@ -719,0 +731,0 @@ } |
+22
-63
@@ -8,18 +8,8 @@ "use strict"; | ||
| exports.isLastChild = isLastChild; | ||
| exports.needsParens = needsParens; | ||
| exports.needsWhitespace = needsWhitespace; | ||
| exports.needsWhitespaceAfter = needsWhitespaceAfter; | ||
| exports.needsWhitespaceBefore = needsWhitespaceBefore; | ||
| var whitespace = require("./whitespace.js"); | ||
| exports.parentNeedsParens = parentNeedsParens; | ||
| var parens = require("./parentheses.js"); | ||
| var _t = require("@babel/types"); | ||
| var _nodes = require("../nodes.js"); | ||
| const { | ||
| FLIPPED_ALIAS_KEYS, | ||
| VISITOR_KEYS, | ||
| isCallExpression, | ||
| isDecorator, | ||
| isExpressionStatement, | ||
| isMemberExpression, | ||
| isNewExpression, | ||
| isParenthesizedExpression | ||
| VISITOR_KEYS | ||
| } = _t; | ||
@@ -38,60 +28,29 @@ const TokenContext = exports.TokenContext = { | ||
| }; | ||
| function expandAliases(obj) { | ||
| const map = new Map(); | ||
| function add(type, func) { | ||
| const fn = map.get(type); | ||
| map.set(type, fn ? function (node, parent, stack, getRawIdentifier) { | ||
| var _fn; | ||
| return (_fn = fn(node, parent, stack, getRawIdentifier)) != null ? _fn : func(node, parent, stack, getRawIdentifier); | ||
| } : func); | ||
| for (const type of Object.keys(parens)) { | ||
| const func = parens[type]; | ||
| if (_nodes.generatorInfosMap.has(type)) { | ||
| _nodes.generatorInfosMap.get(type)[2] = func; | ||
| } | ||
| for (const type of Object.keys(obj)) { | ||
| const aliases = FLIPPED_ALIAS_KEYS[type]; | ||
| if (aliases) { | ||
| for (const alias of aliases) { | ||
| add(alias, obj[type]); | ||
| } | ||
| } else { | ||
| add(type, obj[type]); | ||
| } | ||
| } | ||
| return map; | ||
| } | ||
| const expandedParens = expandAliases(parens); | ||
| const expandedWhitespaceNodes = expandAliases(whitespace.nodes); | ||
| function isOrHasCallExpression(node) { | ||
| if (isCallExpression(node)) { | ||
| return true; | ||
| switch (node.type) { | ||
| case "CallExpression": | ||
| return true; | ||
| case "MemberExpression": | ||
| return isOrHasCallExpression(node.object); | ||
| } | ||
| return isMemberExpression(node) && isOrHasCallExpression(node.object); | ||
| return false; | ||
| } | ||
| function needsWhitespace(node, parent, type) { | ||
| var _expandedWhitespaceNo; | ||
| if (!node) return false; | ||
| if (isExpressionStatement(node)) { | ||
| node = node.expression; | ||
| 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"; | ||
| } | ||
| const flag = (_expandedWhitespaceNo = expandedWhitespaceNodes.get(node.type)) == null ? void 0 : _expandedWhitespaceNo(node, parent); | ||
| if (typeof flag === "number") { | ||
| return (flag & type) !== 0; | ||
| } | ||
| return false; | ||
| } | ||
| function needsWhitespaceBefore(node, parent) { | ||
| return needsWhitespace(node, parent, 1); | ||
| } | ||
| function needsWhitespaceAfter(node, parent) { | ||
| return needsWhitespace(node, parent, 2); | ||
| } | ||
| function needsParens(node, parent, tokenContext, getRawIdentifier) { | ||
| var _expandedParens$get; | ||
| if (!parent) return false; | ||
| if (isNewExpression(parent) && parent.callee === node) { | ||
| if (isOrHasCallExpression(node)) return true; | ||
| } | ||
| if (isDecorator(parent)) { | ||
| return !isDecoratorMemberExpression(node) && !(isCallExpression(node) && isDecoratorMemberExpression(node.callee)) && !isParenthesizedExpression(node); | ||
| } | ||
| return ((_expandedParens$get = expandedParens.get(node.type)) == null ? void 0 : _expandedParens$get(node, parent, tokenContext, getRawIdentifier)) || false; | ||
| } | ||
| function isDecoratorMemberExpression(node) { | ||
@@ -98,0 +57,0 @@ switch (node.type) { |
+186
-149
@@ -7,3 +7,2 @@ "use strict"; | ||
| exports.AssignmentExpression = AssignmentExpression; | ||
| exports.Binary = Binary; | ||
| exports.BinaryExpression = BinaryExpression; | ||
@@ -28,3 +27,3 @@ exports.ClassExpression = ClassExpression; | ||
| exports.TSIntersectionType = TSIntersectionType; | ||
| exports.UnaryLike = exports.TSTypeAssertion = UnaryLike; | ||
| exports.SpreadElement = exports.UnaryExpression = exports.TSTypeAssertion = UnaryLike; | ||
| exports.TSTypeOperator = TSTypeOperator; | ||
@@ -38,9 +37,3 @@ exports.TSUnionType = TSUnionType; | ||
| const { | ||
| isArrayTypeAnnotation, | ||
| isBinaryExpression, | ||
| isCallExpression, | ||
| isForOfStatement, | ||
| isIndexedAccessType, | ||
| isMemberExpression, | ||
| isObjectPattern, | ||
| isOptionalMemberExpression, | ||
@@ -50,86 +43,132 @@ isYieldExpression, | ||
| } = _t; | ||
| const PRECEDENCE = new Map([["||", 0], ["??", 0], ["|>", 0], ["&&", 1], ["|", 2], ["^", 3], ["&", 4], ["==", 5], ["===", 5], ["!=", 5], ["!==", 5], ["<", 6], [">", 6], ["<=", 6], [">=", 6], ["in", 6], ["instanceof", 6], [">>", 7], ["<<", 7], [">>>", 7], ["+", 8], ["-", 8], ["*", 9], ["/", 9], ["%", 9], ["**", 10]]); | ||
| function getBinaryPrecedence(node, nodeType) { | ||
| if (nodeType === "BinaryExpression" || nodeType === "LogicalExpression") { | ||
| return PRECEDENCE.get(node.operator); | ||
| } | ||
| if (nodeType === "TSAsExpression" || nodeType === "TSSatisfiesExpression") { | ||
| return PRECEDENCE.get("in"); | ||
| } | ||
| 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; | ||
| } | ||
| function isTSTypeExpression(nodeType) { | ||
| return nodeType === "TSAsExpression" || nodeType === "TSSatisfiesExpression" || nodeType === "TSTypeAssertion"; | ||
| } | ||
| const isClassExtendsClause = (node, parent) => { | ||
| const parentType = parent.type; | ||
| return (parentType === "ClassDeclaration" || parentType === "ClassExpression") && parent.superClass === node; | ||
| const isClassExtendsClause = (node, parent, parentId) => { | ||
| return (parentId === 21 || parentId === 22) && parent.superClass === node; | ||
| }; | ||
| const hasPostfixPart = (node, parent) => { | ||
| const parentType = parent.type; | ||
| return (parentType === "MemberExpression" || parentType === "OptionalMemberExpression") && parent.object === node || (parentType === "CallExpression" || parentType === "OptionalCallExpression" || parentType === "NewExpression") && parent.callee === node || parentType === "TaggedTemplateExpression" && parent.tag === node || parentType === "TSNonNullExpression"; | ||
| 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) { | ||
| return isArrayTypeAnnotation(parent); | ||
| function NullableTypeAnnotation(node, parent, parentId) { | ||
| return parentId === 4; | ||
| } | ||
| function FunctionTypeAnnotation(node, parent, tokenContext) { | ||
| const parentType = parent.type; | ||
| return (parentType === "UnionTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "ArrayTypeAnnotation" || Boolean(tokenContext & _index.TokenContext.arrowFlowReturnType) | ||
| function FunctionTypeAnnotation(node, parent, parentId, tokenContext) { | ||
| return (parentId === 239 || parentId === 90 || parentId === 4 || (tokenContext & _index.TokenContext.arrowFlowReturnType) > 0 | ||
| ); | ||
| } | ||
| function UpdateExpression(node, parent) { | ||
| return hasPostfixPart(node, parent) || isClassExtendsClause(node, parent); | ||
| function UpdateExpression(node, parent, parentId) { | ||
| return hasPostfixPart(node, parent, parentId) || isClassExtendsClause(node, parent, parentId); | ||
| } | ||
| function needsParenBeforeExpressionBrace(tokenContext) { | ||
| return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.arrowBody)); | ||
| return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.arrowBody)) > 0; | ||
| } | ||
| function ObjectExpression(node, parent, tokenContext) { | ||
| function ObjectExpression(node, parent, parentId, tokenContext) { | ||
| return needsParenBeforeExpressionBrace(tokenContext); | ||
| } | ||
| function DoExpression(node, parent, tokenContext) { | ||
| return !node.async && Boolean(tokenContext & _index.TokenContext.expressionStatement); | ||
| function DoExpression(node, parent, parentId, tokenContext) { | ||
| return (tokenContext & _index.TokenContext.expressionStatement) > 0 && !node.async; | ||
| } | ||
| function Binary(node, parent) { | ||
| const parentType = parent.type; | ||
| if (node.type === "BinaryExpression" && node.operator === "**" && parentType === "BinaryExpression" && parent.operator === "**") { | ||
| return parent.left === node; | ||
| } | ||
| if (isClassExtendsClause(node, parent)) { | ||
| function BinaryLike(node, parent, parentId, nodeType) { | ||
| if (isClassExtendsClause(node, parent, parentId)) { | ||
| return true; | ||
| } | ||
| if (hasPostfixPart(node, parent) || parentType === "UnaryExpression" || parentType === "SpreadElement" || parentType === "AwaitExpression") { | ||
| if (hasPostfixPart(node, parent, parentId) || parentId === 238 || parentId === 145 || parentId === 8) { | ||
| return true; | ||
| } | ||
| const parentPos = getBinaryPrecedence(parent, parentType); | ||
| if (parentPos != null) { | ||
| const nodePos = getBinaryPrecedence(node, node.type); | ||
| if (parentPos === nodePos && parentType === "BinaryExpression" && parent.right === node || parentPos > nodePos) { | ||
| 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) { | ||
| const parentType = parent.type; | ||
| return parentType === "ArrayTypeAnnotation" || parentType === "NullableTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "UnionTypeAnnotation"; | ||
| function UnionTypeAnnotation(node, parent, parentId) { | ||
| switch (parentId) { | ||
| case 4: | ||
| case 115: | ||
| case 90: | ||
| case 239: | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| function OptionalIndexedAccessType(node, parent) { | ||
| return isIndexedAccessType(parent) && parent.objectType === node; | ||
| function OptionalIndexedAccessType(node, parent, parentId) { | ||
| return parentId === 84 && parent.objectType === node; | ||
| } | ||
| function TSAsExpression(node, parent) { | ||
| if ((parent.type === "AssignmentExpression" || parent.type === "AssignmentPattern") && parent.left === node) { | ||
| function TSAsExpression(node, parent, parentId) { | ||
| if ((parentId === 6 || parentId === 7) && parent.left === node) { | ||
| return true; | ||
| } | ||
| if (parent.type === "BinaryExpression" && (parent.operator === "|" || parent.operator === "&") && node === parent.left) { | ||
| if (parentId === 10 && (parent.operator === "|" || parent.operator === "&") && node === parent.left) { | ||
| return true; | ||
| } | ||
| return Binary(node, parent); | ||
| return BinaryLike(node, parent, parentId, 2); | ||
| } | ||
| function TSConditionalType(node, parent) { | ||
| const parentType = parent.type; | ||
| if (parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType" || parentType === "TSTypeOperator" || parentType === "TSTypeParameter") { | ||
| return true; | ||
| 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; | ||
| } | ||
| if ((parentType === "TSIntersectionType" || parentType === "TSUnionType") && parent.types[0] === 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 (parentType === "TSConditionalType" && (parent.checkType === node || parent.extendsType === node)) { | ||
| if ((parentId === 181 || parentId === 219) && node.typeParameter.constraint && parent.types[0] === node) { | ||
| return true; | ||
@@ -139,49 +178,47 @@ } | ||
| } | ||
| function TSUnionType(node, parent) { | ||
| const parentType = parent.type; | ||
| return parentType === "TSIntersectionType" || parentType === "TSTypeOperator" || parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType"; | ||
| } | ||
| function TSIntersectionType(node, parent) { | ||
| const parentType = parent.type; | ||
| return parentType === "TSTypeOperator" || parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType"; | ||
| } | ||
| function TSInferType(node, parent) { | ||
| const parentType = parent.type; | ||
| if (parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType") { | ||
| return true; | ||
| } | ||
| if (node.typeParameter.constraint) { | ||
| if ((parentType === "TSIntersectionType" || parentType === "TSUnionType") && parent.types[0] === node) { | ||
| function TSTypeOperator(node, parent, parentId) { | ||
| switch (parentId) { | ||
| case 155: | ||
| case 195: | ||
| return true; | ||
| } | ||
| case 175: | ||
| if (parent.objectType === node) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| function TSTypeOperator(node, parent) { | ||
| const parentType = parent.type; | ||
| return parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType"; | ||
| function TSInstantiationExpression(node, parent, parentId) { | ||
| switch (parentId) { | ||
| case 17: | ||
| case 130: | ||
| case 112: | ||
| case 177: | ||
| return (parent.typeParameters | ||
| ) != null; | ||
| } | ||
| return false; | ||
| } | ||
| function TSInstantiationExpression(node, parent) { | ||
| const parentType = parent.type; | ||
| return (parentType === "CallExpression" || parentType === "OptionalCallExpression" || parentType === "NewExpression" || parentType === "TSInstantiationExpression") && !!parent.typeParameters; | ||
| function TSFunctionType(node, parent, parentId) { | ||
| if (TSUnionType(node, parent, parentId)) return true; | ||
| return parentId === 219 || parentId === 161 && (parent.checkType === node || parent.extendsType === node); | ||
| } | ||
| function TSFunctionType(node, parent) { | ||
| const parentType = parent.type; | ||
| return parentType === "TSIntersectionType" || parentType === "TSUnionType" || parentType === "TSTypeOperator" || parentType === "TSOptionalType" || parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSConditionalType" && (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 BinaryExpression(node, parent, tokenContext) { | ||
| return node.operator === "in" && Boolean(tokenContext & _index.TokenContext.forInOrInitHeadAccumulate); | ||
| function LogicalExpression(node, parent, parentId) { | ||
| return BinaryLike(node, parent, parentId, 1); | ||
| } | ||
| function SequenceExpression(node, parent) { | ||
| const parentType = parent.type; | ||
| if (parentType === "SequenceExpression" || parentType === "ParenthesizedExpression" || parentType === "MemberExpression" && parent.property === node || parentType === "OptionalMemberExpression" && parent.property === node || parentType === "TemplateLiteral") { | ||
| 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 (parentType === "ClassDeclaration") { | ||
| if (parentId === 21) { | ||
| return true; | ||
| } | ||
| if (parentType === "ForOfStatement") { | ||
| if (parentId === 68) { | ||
| return parent.right === node; | ||
| } | ||
| if (parentType === "ExportDefaultDeclaration") { | ||
| if (parentId === 60) { | ||
| return true; | ||
@@ -191,49 +228,53 @@ } | ||
| } | ||
| function YieldExpression(node, parent) { | ||
| const parentType = parent.type; | ||
| return parentType === "BinaryExpression" || parentType === "LogicalExpression" || parentType === "UnaryExpression" || parentType === "SpreadElement" || hasPostfixPart(node, parent) || parentType === "AwaitExpression" && isYieldExpression(node) || parentType === "ConditionalExpression" && node === parent.test || isClassExtendsClause(node, parent) || isTSTypeExpression(parentType); | ||
| 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, tokenContext) { | ||
| return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault)); | ||
| function ClassExpression(node, parent, parentId, tokenContext) { | ||
| return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault)) > 0; | ||
| } | ||
| function UnaryLike(node, parent) { | ||
| return hasPostfixPart(node, parent) || isBinaryExpression(parent) && parent.operator === "**" && parent.left === node || isClassExtendsClause(node, parent); | ||
| 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, tokenContext) { | ||
| return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault)); | ||
| function FunctionExpression(node, parent, parentId, tokenContext) { | ||
| return (tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault)) > 0; | ||
| } | ||
| function ConditionalExpression(node, parent) { | ||
| const parentType = parent.type; | ||
| if (parentType === "UnaryExpression" || parentType === "SpreadElement" || parentType === "BinaryExpression" || parentType === "LogicalExpression" || parentType === "ConditionalExpression" && parent.test === node || parentType === "AwaitExpression" || isTSTypeExpression(parentType)) { | ||
| 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); | ||
| return UnaryLike(node, parent, parentId); | ||
| } | ||
| function OptionalMemberExpression(node, parent) { | ||
| return isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node; | ||
| 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, tokenContext) { | ||
| if (needsParenBeforeExpressionBrace(tokenContext) && isObjectPattern(node.left)) { | ||
| function AssignmentExpression(node, parent, parentId, tokenContext) { | ||
| if (needsParenBeforeExpressionBrace(tokenContext) && node.left.type === "ObjectPattern") { | ||
| return true; | ||
| } else { | ||
| return ConditionalExpression(node, parent); | ||
| } | ||
| return ConditionalExpression(node, parent, parentId); | ||
| } | ||
| function LogicalExpression(node, parent) { | ||
| const parentType = parent.type; | ||
| if (isTSTypeExpression(parentType)) return true; | ||
| if (parentType !== "LogicalExpression") return false; | ||
| switch (node.operator) { | ||
| case "||": | ||
| return parent.operator === "??" || parent.operator === "&&"; | ||
| case "&&": | ||
| return parent.operator === "??"; | ||
| case "??": | ||
| return parent.operator !== "??"; | ||
| function Identifier(node, parent, parentId, tokenContext, getRawIdentifier) { | ||
| var _node$extra; | ||
| if (getRawIdentifier && getRawIdentifier(node) !== node.name) { | ||
| return false; | ||
| } | ||
| } | ||
| function Identifier(node, parent, tokenContext, getRawIdentifier) { | ||
| var _node$extra; | ||
| const parentType = parent.type; | ||
| if ((_node$extra = node.extra) != null && _node$extra.parenthesized && parentType === "AssignmentExpression" && parent.left === node) { | ||
| if (parentId === 6 && (_node$extra = node.extra) != null && _node$extra.parenthesized && parent.left === node) { | ||
| const rightType = parent.right.type; | ||
@@ -244,25 +285,21 @@ if ((rightType === "FunctionExpression" || rightType === "ClassExpression") && parent.right.id == null) { | ||
| } | ||
| if (getRawIdentifier && getRawIdentifier(node) !== node.name) { | ||
| return false; | ||
| } | ||
| 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; | ||
| 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 Boolean(tokenContext & _index.TokenContext.forOfHead); | ||
| } | ||
| return node.name === "async" && isForOfStatement(parent, { | ||
| left: node, | ||
| await: false | ||
| }); | ||
| return parentId === 68 && parent.left === node && node.name === "async" && !parent.await; | ||
| } | ||
| //# sourceMappingURL=parentheses.js.map |
+274
-270
@@ -9,7 +9,6 @@ "use strict"; | ||
| var _index = require("./node/index.js"); | ||
| var n = _index; | ||
| var _nodes = require("./nodes.js"); | ||
| var _t = require("@babel/types"); | ||
| var _tokenMap = require("./token-map.js"); | ||
| var generatorFunctions = require("./generators/index.js"); | ||
| var _deprecated = require("./generators/deprecated.js"); | ||
| var _types2 = require("./generators/types.js"); | ||
| const { | ||
@@ -30,5 +29,2 @@ isExpression, | ||
| } | ||
| const { | ||
| needsParens | ||
| } = n; | ||
| class Printer { | ||
@@ -40,2 +36,3 @@ constructor(format, map, tokens = null, originalCode = null) { | ||
| this._currentNode = null; | ||
| this._currentTypeId = null; | ||
| this._indent = 0; | ||
@@ -48,10 +45,7 @@ this._indentRepeat = 0; | ||
| this._printedComments = new Set(); | ||
| this._endsWithInteger = false; | ||
| this._endsWithWord = false; | ||
| this._endsWithDiv = false; | ||
| this._lastCommentLine = 0; | ||
| this._endsWithInnerRaw = false; | ||
| this._indentInnerComments = true; | ||
| this._innerCommentsState = 0; | ||
| this._flags = 0; | ||
| this.tokenMap = null; | ||
| this._boundGetRawIdentifier = this._getRawIdentifier.bind(this); | ||
| this._boundGetRawIdentifier = null; | ||
| this._printSemicolonBeforeNextNode = -1; | ||
@@ -65,28 +59,34 @@ this._printSemicolonBeforeNextToken = -1; | ||
| this._buf = new _buffer.default(map, format.indent.style[0]); | ||
| } | ||
| enterForStatementInit() { | ||
| this.tokenContext |= _index.TokenContext.forInitHead | _index.TokenContext.forInOrInitHeadAccumulate; | ||
| return () => this.tokenContext = _index.TokenContext.normal; | ||
| } | ||
| enterForXStatementInit(isForOf) { | ||
| if (isForOf) { | ||
| this.tokenContext |= _index.TokenContext.forOfHead; | ||
| return null; | ||
| } else { | ||
| this.tokenContext |= _index.TokenContext.forInHead | _index.TokenContext.forInOrInitHeadAccumulate; | ||
| return () => this.tokenContext = _index.TokenContext.normal; | ||
| 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 oldTokenContext = this.tokenContext; | ||
| const oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode; | ||
| if (!(oldTokenContext & _index.TokenContext.forInOrInitHeadAccumulate) && oldNoLineTerminatorAfterNode === null) { | ||
| return () => {}; | ||
| if (oldNoLineTerminatorAfterNode !== null) { | ||
| this._noLineTerminatorAfterNode = null; | ||
| } | ||
| this._noLineTerminatorAfterNode = null; | ||
| this.tokenContext = _index.TokenContext.normal; | ||
| return () => { | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| this.tokenContext = oldTokenContext; | ||
| }; | ||
| return oldNoLineTerminatorAfterNode; | ||
| } | ||
@@ -96,2 +96,3 @@ generate(ast) { | ||
| this.tokenMap = new _tokenMap.TokenMap(ast, this._tokens, this._originalCode); | ||
| this._boundGetRawIdentifier = _types2._getRawIdentifier.bind(this); | ||
| } | ||
@@ -102,28 +103,20 @@ this.print(ast); | ||
| } | ||
| indent() { | ||
| const { | ||
| format | ||
| } = this; | ||
| if (format.preserveFormat || format.compact || format.concise) { | ||
| indent(flags = this._flags) { | ||
| if (flags & (1 | 2 | 4)) { | ||
| return; | ||
| } | ||
| this._indent++; | ||
| this._indent += this._indentRepeat; | ||
| } | ||
| dedent() { | ||
| const { | ||
| format | ||
| } = this; | ||
| if (format.preserveFormat || format.compact || format.concise) { | ||
| dedent(flags = this._flags) { | ||
| if (flags & (1 | 2 | 4)) { | ||
| return; | ||
| } | ||
| this._indent--; | ||
| this._indent -= this._indentRepeat; | ||
| } | ||
| semicolon(force = false) { | ||
| this._maybeAddAuxComment(); | ||
| if (force) { | ||
| this._appendChar(59); | ||
| this._noLineTerminator = false; | ||
| return; | ||
| const flags = this._flags; | ||
| if (flags & 32) { | ||
| this._maybeAddAuxComment(); | ||
| } | ||
| if (this.tokenMap) { | ||
| if (flags & 1) { | ||
| const node = this._currentNode; | ||
@@ -139,3 +132,7 @@ if (node.start != null && node.end != null) { | ||
| } | ||
| this._queue(59); | ||
| if (force) { | ||
| this._appendChar(59); | ||
| } else { | ||
| this._queue(59); | ||
| } | ||
| this._noLineTerminator = false; | ||
@@ -155,11 +152,10 @@ } | ||
| space(force = false) { | ||
| const { | ||
| format | ||
| } = this; | ||
| if (format.compact || format.preserveFormat) return; | ||
| if (this._flags & (1 | 2)) { | ||
| return; | ||
| } | ||
| if (force) { | ||
| this._space(); | ||
| } else if (this._buf.hasContent()) { | ||
| const lastCp = this.getLastChar(); | ||
| if (lastCp !== 32 && lastCp !== 10) { | ||
| } else { | ||
| const lastCp = this.getLastChar(true); | ||
| if (lastCp !== 0 && lastCp !== 32 && lastCp !== 10) { | ||
| this._space(); | ||
@@ -172,9 +168,13 @@ } | ||
| this._maybePrintInnerComments(str); | ||
| this._maybeAddAuxComment(); | ||
| if (this.tokenMap) this._catchUpToCurrentToken(str); | ||
| if (this._endsWithWord || this._endsWithDiv && str.charCodeAt(0) === 47) { | ||
| 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._endsWithWord = true; | ||
| this.setLastChar(-3); | ||
| this._noLineTerminator = noLineTerminatorAfter; | ||
@@ -191,25 +191,36 @@ } | ||
| this.word(str); | ||
| this._endsWithInteger = Number.isInteger(number) && !isNonDecimalLiteral(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str.charCodeAt(str.length - 1) !== 46; | ||
| 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) { | ||
| token(str, maybeNewline = false, occurrenceCount = 0, mayNeedSpace = false) { | ||
| this.tokenContext &= _index.TokenContext.forInOrInitHeadAccumulatePassThroughMask; | ||
| this._maybePrintInnerComments(str, occurrenceCount); | ||
| this._maybeAddAuxComment(); | ||
| if (this.tokenMap) this._catchUpToCurrentToken(str, occurrenceCount); | ||
| const lastChar = this.getLastChar(); | ||
| const strFirst = str.charCodeAt(0); | ||
| if (lastChar === 33 && (str === "--" || strFirst === 61) || strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 || strFirst === 46 && this._endsWithInteger) { | ||
| this._space(); | ||
| 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) { | ||
| tokenChar(char, occurrenceCount = 0) { | ||
| this.tokenContext &= _index.TokenContext.forInOrInitHeadAccumulatePassThroughMask; | ||
| const str = String.fromCharCode(char); | ||
| this._maybePrintInnerComments(str); | ||
| this._maybeAddAuxComment(); | ||
| if (this.tokenMap) this._catchUpToCurrentToken(str); | ||
| const lastChar = this.getLastChar(); | ||
| if (char === 43 && lastChar === 43 || char === 45 && lastChar === 45 || char === 46 && this._endsWithInteger) { | ||
| 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(); | ||
@@ -220,11 +231,11 @@ } | ||
| } | ||
| newline(i = 1, force) { | ||
| newline(i = 1, flags = this._flags) { | ||
| if (i <= 0) return; | ||
| if (!force) { | ||
| if (this.format.retainLines || this.format.compact) return; | ||
| if (this.format.concise) { | ||
| this.space(); | ||
| return; | ||
| } | ||
| if (flags & (8 | 2)) { | ||
| return; | ||
| } | ||
| if (flags & 4) { | ||
| this.space(); | ||
| return; | ||
| } | ||
| if (i > 2) i = 2; | ||
@@ -235,16 +246,12 @@ i -= this._buf.getNewlineCount(); | ||
| } | ||
| return; | ||
| } | ||
| endsWith(char) { | ||
| return this.getLastChar() === char; | ||
| return this.getLastChar(true) === char; | ||
| } | ||
| getLastChar() { | ||
| return this._buf.getLastChar(); | ||
| getLastChar(checkQueue) { | ||
| return this._buf.getLastChar(checkQueue); | ||
| } | ||
| endsWithCharAndNewline() { | ||
| return this._buf.endsWithCharAndNewline(); | ||
| setLastChar(char) { | ||
| this._buf._last = char; | ||
| } | ||
| removeTrailingNewline() { | ||
| this._buf.removeTrailingNewline(); | ||
| } | ||
| exactSource(loc, cb) { | ||
@@ -278,3 +285,4 @@ if (!loc) { | ||
| _newline() { | ||
| this._queue(10); | ||
| if (this._buf._queuedChar === 32) this._buf._queuedChar = 0; | ||
| this._appendChar(10, true); | ||
| } | ||
@@ -285,6 +293,3 @@ _catchUpToCurrentToken(str, occurrenceCount = 0) { | ||
| if (this._printSemicolonBeforeNextToken !== -1 && this._printSemicolonBeforeNextToken === this._buf.getCurrentLine()) { | ||
| this._buf.appendChar(59); | ||
| this._endsWithWord = false; | ||
| this._endsWithInteger = false; | ||
| this._endsWithDiv = false; | ||
| this._appendChar(59, true); | ||
| } | ||
@@ -295,30 +300,23 @@ this._printSemicolonBeforeNextToken = -1; | ||
| _append(str, maybeNewline) { | ||
| this._maybeIndent(str.charCodeAt(0)); | ||
| this._maybeIndent(); | ||
| this._buf.append(str, maybeNewline); | ||
| this._endsWithWord = false; | ||
| this._endsWithInteger = false; | ||
| this._endsWithDiv = false; | ||
| } | ||
| _appendChar(char) { | ||
| this._maybeIndent(char); | ||
| _appendChar(char, noIndent) { | ||
| if (!noIndent) { | ||
| this._maybeIndent(); | ||
| } | ||
| this._buf.appendChar(char); | ||
| this._endsWithWord = false; | ||
| this._endsWithInteger = false; | ||
| this._endsWithDiv = false; | ||
| } | ||
| _queue(char) { | ||
| this._maybeIndent(char); | ||
| this._buf.queue(char); | ||
| this._endsWithWord = false; | ||
| this._endsWithInteger = false; | ||
| this.setLastChar(-1); | ||
| } | ||
| _maybeIndent(firstChar) { | ||
| if (this._indent && firstChar !== 10 && this.endsWith(10)) { | ||
| this._buf.queueIndentation(this._getIndent()); | ||
| _maybeIndent() { | ||
| const indent = this._shouldIndent(); | ||
| if (indent > 0) { | ||
| this._buf._appendChar(-1, indent, false); | ||
| } | ||
| } | ||
| _shouldIndent(firstChar) { | ||
| if (this._indent && firstChar !== 10 && this.endsWith(10)) { | ||
| return true; | ||
| } | ||
| _shouldIndent() { | ||
| return this.endsWith(10) ? this._indent : 0; | ||
| } | ||
@@ -333,7 +331,5 @@ catchUp(line) { | ||
| _catchUp(prop, loc) { | ||
| const { | ||
| format | ||
| } = this; | ||
| if (!format.preserveFormat) { | ||
| if (format.retainLines && loc != null && loc[prop]) { | ||
| const flags = this._flags; | ||
| if ((flags & 1) === 0) { | ||
| if (flags & 8 && loc != null && loc[prop]) { | ||
| this.catchUp(loc[prop].line); | ||
@@ -362,7 +358,5 @@ } | ||
| this._append(spaces, false); | ||
| this.setLastChar(32); | ||
| } | ||
| } | ||
| _getIndent() { | ||
| return this._indentRepeat * this._indent; | ||
| } | ||
| printTerminatorless(node) { | ||
@@ -372,37 +366,56 @@ this._noLineTerminator = true; | ||
| } | ||
| print(node, noLineTerminatorAfter = false, trailingCommentsLineOffset) { | ||
| var _node$extra, _node$leadingComments, _node$leadingComments2; | ||
| print(node, noLineTerminatorAfter = false, resetTokenContext = false, trailingCommentsLineOffset) { | ||
| var _node$leadingComments, _node$leadingComments2; | ||
| if (!node) return; | ||
| this._endsWithInnerRaw = false; | ||
| const nodeType = node.type; | ||
| const format = this.format; | ||
| const oldConcise = format.concise; | ||
| this._innerCommentsState = 0; | ||
| const { | ||
| type, | ||
| loc, | ||
| extra | ||
| } = node; | ||
| const flags = this._flags; | ||
| let changedFlags = false; | ||
| if (node._compact) { | ||
| format.concise = true; | ||
| this._flags |= 4; | ||
| changedFlags = true; | ||
| } | ||
| const printMethod = this[nodeType]; | ||
| if (printMethod === undefined) { | ||
| throw new ReferenceError(`unknown node of type ${JSON.stringify(nodeType)} with constructor ${JSON.stringify(node.constructor.name)}`); | ||
| 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; | ||
| if (this.tokenMap) { | ||
| this._currentTypeId = nodeId; | ||
| if (flags & 1) { | ||
| this._printSemicolonBeforeNextToken = this._printSemicolonBeforeNextNode; | ||
| } | ||
| const oldInAux = this._insideAux; | ||
| this._insideAux = node.loc == null; | ||
| this._maybeAddAuxComment(this._insideAux && !oldInAux); | ||
| const parenthesized = (_node$extra = node.extra) == null ? void 0 : _node$extra.parenthesized; | ||
| let shouldPrintParens = parenthesized && format.preserveFormat || parenthesized && format.retainFunctionParens && nodeType === "FunctionExpression" || needsParens(node, parent, this.tokenContext, format.preserveFormat ? this._boundGetRawIdentifier : undefined); | ||
| 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") { | ||
| const parentType = parent == null ? void 0 : parent.type; | ||
| switch (parentType) { | ||
| case "ExpressionStatement": | ||
| case "VariableDeclarator": | ||
| case "AssignmentExpression": | ||
| case "ReturnStatement": | ||
| switch (parentId) { | ||
| case 65: | ||
| case 243: | ||
| case 6: | ||
| case 143: | ||
| break; | ||
| case "CallExpression": | ||
| case "OptionalCallExpression": | ||
| case "NewExpression": | ||
| case 17: | ||
| case 130: | ||
| case 112: | ||
| if (parent.callee !== node) break; | ||
@@ -414,3 +427,3 @@ default: | ||
| let indentParenthesized = false; | ||
| if (!shouldPrintParens && this._noLineTerminator && ((_node$leadingComments2 = node.leadingComments) != null && _node$leadingComments2.some(commentIsNewline) || this.format.retainLines && node.loc && node.loc.start.line > this._buf.getCurrentLine())) { | ||
| if (!shouldPrintParens && this._noLineTerminator && ((_node$leadingComments2 = node.leadingComments) != null && _node$leadingComments2.some(commentIsNewline) || flags & 8 && loc && loc.start.line > this._buf.getCurrentLine())) { | ||
| shouldPrintParens = true; | ||
@@ -420,5 +433,4 @@ indentParenthesized = true; | ||
| let oldNoLineTerminatorAfterNode; | ||
| let oldTokenContext; | ||
| if (!shouldPrintParens) { | ||
| noLineTerminatorAfter || (noLineTerminatorAfter = !!parent && this._noLineTerminatorAfterNode === parent && n.isLastChild(parent, node)); | ||
| noLineTerminatorAfter || (noLineTerminatorAfter = !!parent && this._noLineTerminatorAfterNode === parent && (0, _index.isLastChild)(parent, node)); | ||
| if (noLineTerminatorAfter) { | ||
@@ -437,14 +449,14 @@ var _node$trailingComment; | ||
| if (indentParenthesized) this.indent(); | ||
| this._endsWithInnerRaw = false; | ||
| if (this.tokenContext & _index.TokenContext.forInOrInitHeadAccumulate) { | ||
| this._innerCommentsState = 0; | ||
| if (!resetTokenContext) { | ||
| oldTokenContext = this.tokenContext; | ||
| this.tokenContext = _index.TokenContext.normal; | ||
| } | ||
| if (oldTokenContext & _index.TokenContext.forInOrInitHeadAccumulate) { | ||
| this.tokenContext = 0; | ||
| } | ||
| oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode; | ||
| this._noLineTerminatorAfterNode = null; | ||
| } | ||
| this._lastCommentLine = 0; | ||
| this._printLeadingComments(node, parent); | ||
| const loc = nodeType === "Program" || nodeType === "File" ? null : node.loc; | ||
| this.exactSource(loc, printMethod.bind(this, node, parent)); | ||
| this.exactSource(nodeId === 139 || nodeId === 66 ? null : loc, printMethod.bind(this, node, parent)); | ||
| if (shouldPrintParens) { | ||
@@ -458,3 +470,2 @@ this._printTrailingComments(node, parent); | ||
| this._noLineTerminator = noLineTerminatorAfter; | ||
| if (oldTokenContext) this.tokenContext = oldTokenContext; | ||
| } else if (noLineTerminatorAfter && !this._noLineTerminator) { | ||
@@ -466,9 +477,15 @@ this._noLineTerminator = true; | ||
| } | ||
| if (oldTokenContext) this.tokenContext = oldTokenContext; | ||
| this._currentNode = parent; | ||
| format.concise = oldConcise; | ||
| this._insideAux = oldInAux; | ||
| if (oldNoLineTerminatorAfterNode !== undefined) { | ||
| this._currentTypeId = parentId; | ||
| if (changedFlags) { | ||
| this._flags = flags; | ||
| } | ||
| if (flags & 32) { | ||
| this._insideAux = oldInAux; | ||
| } | ||
| if (oldNoLineTerminatorAfterNode != null) { | ||
| this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; | ||
| } | ||
| this._endsWithInnerRaw = false; | ||
| this._innerCommentsState = 0; | ||
| } | ||
@@ -507,5 +524,6 @@ _maybeAddAuxComment(enteredPositionlessNode) { | ||
| } | ||
| printJoin(nodes, statement, indent, separator, printTrailingSeparator, iterator, trailingCommentsLineOffset) { | ||
| printJoin(nodes, statement, indent, separator, printTrailingSeparator, resetTokenContext, trailingCommentsLineOffset) { | ||
| if (!(nodes != null && nodes.length)) return; | ||
| if (indent == null && this.format.retainLines) { | ||
| const flags = this._flags; | ||
| if (indent == null && flags & 8) { | ||
| var _nodes$0$loc; | ||
@@ -517,7 +535,3 @@ const startLine = (_nodes$0$loc = nodes[0].loc) == null ? void 0 : _nodes$0$loc.start.line; | ||
| } | ||
| if (indent) this.indent(); | ||
| const newlineOpts = { | ||
| nextNodeStartLine: 0 | ||
| }; | ||
| const boundSeparator = separator == null ? void 0 : separator.bind(this); | ||
| if (indent) this.indent(flags); | ||
| const len = nodes.length; | ||
@@ -527,24 +541,27 @@ for (let i = 0; i < len; i++) { | ||
| if (!node) continue; | ||
| if (statement) this._printNewline(i === 0, newlineOpts); | ||
| this.print(node, undefined, trailingCommentsLineOffset || 0); | ||
| iterator == null || iterator(node, i); | ||
| if (boundSeparator != null) { | ||
| if (i < len - 1) boundSeparator(i, false);else if (printTrailingSeparator) boundSeparator(i, true); | ||
| 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) { | ||
| var _node$trailingComment2; | ||
| if (!((_node$trailingComment2 = node.trailingComments) != null && _node$trailingComment2.length)) { | ||
| this._lastCommentLine = 0; | ||
| } | ||
| if (i + 1 === len) { | ||
| this.newline(1); | ||
| this.newline(1, flags); | ||
| } else { | ||
| var _nextNode$loc; | ||
| const nextNode = nodes[i + 1]; | ||
| newlineOpts.nextNodeStartLine = ((_nextNode$loc = nextNode.loc) == null ? void 0 : _nextNode$loc.start.line) || 0; | ||
| this._printNewline(true, newlineOpts); | ||
| 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(); | ||
| if (indent) this.dedent(flags); | ||
| } | ||
@@ -557,8 +574,7 @@ printAndIndentOnComments(node) { | ||
| } | ||
| printBlock(parent) { | ||
| const node = parent.body; | ||
| if (node.type !== "EmptyStatement") { | ||
| printBlock(body) { | ||
| if (body.type !== "EmptyStatement") { | ||
| this.space(); | ||
| } | ||
| this.print(node); | ||
| this.print(body); | ||
| } | ||
@@ -575,2 +591,4 @@ _printTrailingComments(node, parent, lineOffset) { | ||
| this._printComments(2, trailingComments, node, parent, lineOffset); | ||
| } else { | ||
| this._lastCommentLine = 0; | ||
| } | ||
@@ -584,20 +602,26 @@ } | ||
| _maybePrintInnerComments(nextTokenStr, nextTokenOccurrenceCount) { | ||
| if (this._endsWithInnerRaw) { | ||
| var _this$tokenMap; | ||
| this.printInnerComments((_this$tokenMap = this.tokenMap) == null ? void 0 : _this$tokenMap.findMatching(this._currentNode, nextTokenStr, nextTokenOccurrenceCount)); | ||
| 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)); | ||
| } | ||
| this._endsWithInnerRaw = true; | ||
| this._indentInnerComments = true; | ||
| } | ||
| printInnerComments(nextToken) { | ||
| printInnerComments(indent = true, nextToken) { | ||
| const node = this._currentNode; | ||
| const comments = node.innerComments; | ||
| if (!(comments != null && comments.length)) return; | ||
| if (!(comments != null && comments.length)) { | ||
| this._innerCommentsState = 2; | ||
| return; | ||
| } | ||
| const hasSpace = this.endsWith(32); | ||
| const indent = this._indentInnerComments; | ||
| const printedCommentsCount = this._printedComments.size; | ||
| if (indent) this.indent(); | ||
| this._printComments(1, comments, node, undefined, undefined, nextToken); | ||
| if (hasSpace && printedCommentsCount !== this._printedComments.size) { | ||
| this.space(); | ||
| switch (this._printComments(1, comments, node, undefined, undefined, nextToken)) { | ||
| case 2: | ||
| this._innerCommentsState = 2; | ||
| case 1: | ||
| if (hasSpace) this.space(); | ||
| } | ||
@@ -607,39 +631,16 @@ if (indent) this.dedent(); | ||
| noIndentInnerCommentsHere() { | ||
| this._indentInnerComments = false; | ||
| this._innerCommentsState &= ~4; | ||
| } | ||
| printSequence(nodes, indent, trailingCommentsLineOffset) { | ||
| this.printJoin(nodes, true, indent != null ? indent : false, undefined, undefined, undefined, trailingCommentsLineOffset); | ||
| printSequence(nodes, indent, resetTokenContext, trailingCommentsLineOffset) { | ||
| this.printJoin(nodes, true, indent != null ? indent : false, undefined, undefined, resetTokenContext, trailingCommentsLineOffset); | ||
| } | ||
| printList(items, printTrailingSeparator, statement, indent, separator, iterator) { | ||
| this.printJoin(items, statement, indent, separator != null ? separator : commaSeparator, printTrailingSeparator, iterator); | ||
| 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, listEnd)); | ||
| 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], ","); | ||
| } | ||
| _printNewline(newLine, opts) { | ||
| const format = this.format; | ||
| if (format.retainLines || format.compact) return; | ||
| if (format.concise) { | ||
| this.space(); | ||
| return; | ||
| } | ||
| if (!newLine) { | ||
| return; | ||
| } | ||
| const startLine = opts.nextNodeStartLine; | ||
| const lastCommentLine = this._lastCommentLine; | ||
| if (startLine > 0 && lastCommentLine > 0) { | ||
| const offset = startLine - lastCommentLine; | ||
| if (offset >= 0) { | ||
| this.newline(offset || 1); | ||
| return; | ||
| } | ||
| } | ||
| if (this._buf.hasContent()) { | ||
| this.newline(1); | ||
| } | ||
| } | ||
| _shouldPrintComment(comment, nextToken) { | ||
@@ -666,9 +667,15 @@ if (comment.ignore) return 0; | ||
| const isBlockComment = comment.type === "CommentBlock"; | ||
| const printNewLines = isBlockComment && skipNewLines !== 1 && !this._noLineTerminator; | ||
| const printNewLines = isBlockComment && skipNewLines !== 1 && !noLineTerminator; | ||
| if (printNewLines && this._buf.hasContent() && skipNewLines !== 2) { | ||
| this.newline(1); | ||
| } | ||
| const lastCharCode = this.getLastChar(); | ||
| if (lastCharCode !== 91 && lastCharCode !== 123 && lastCharCode !== 40) { | ||
| this.space(); | ||
| switch (this.getLastChar(true)) { | ||
| case 47: | ||
| this._space(); | ||
| case 91: | ||
| case 123: | ||
| case 40: | ||
| break; | ||
| default: | ||
| this.space(); | ||
| } | ||
@@ -685,8 +692,8 @@ let val; | ||
| } | ||
| if (this.format.concise) { | ||
| if (this._flags & 4) { | ||
| val = val.replace(/\n(?!$)/g, `\n`); | ||
| } else { | ||
| let indentSize = this.format.retainLines ? 0 : this._buf.getCurrentColumn(); | ||
| if (this._shouldIndent(47) || this.format.retainLines) { | ||
| indentSize += this._getIndent(); | ||
| if (this._shouldIndent() || this.format.retainLines) { | ||
| indentSize += this._indent; | ||
| } | ||
@@ -701,20 +708,6 @@ val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`); | ||
| } | ||
| if (this._endsWithDiv) this._space(); | ||
| if (this.tokenMap) { | ||
| const { | ||
| _printSemicolonBeforeNextToken, | ||
| _printSemicolonBeforeNextNode | ||
| } = this; | ||
| this._printSemicolonBeforeNextToken = -1; | ||
| this._printSemicolonBeforeNextNode = -1; | ||
| this.source("start", comment.loc); | ||
| this._append(val, isBlockComment); | ||
| this._printSemicolonBeforeNextNode = _printSemicolonBeforeNextNode; | ||
| this._printSemicolonBeforeNextToken = _printSemicolonBeforeNextToken; | ||
| } else { | ||
| this.source("start", comment.loc); | ||
| this._append(val, isBlockComment); | ||
| } | ||
| this.source("start", comment.loc); | ||
| this._append(val, isBlockComment); | ||
| if (!isBlockComment && !noLineTerminator) { | ||
| this.newline(1, true); | ||
| this._newline(); | ||
| } | ||
@@ -733,3 +726,6 @@ if (printNewLines && skipNewLines !== 3) { | ||
| let leadingCommentNewline = 0; | ||
| const maybeNewline = this._noLineTerminator ? function () {} : this.newline.bind(this); | ||
| const { | ||
| _noLineTerminator, | ||
| _flags | ||
| } = this; | ||
| for (let i = 0; i < len; i++) { | ||
@@ -739,4 +735,3 @@ const comment = comments[i]; | ||
| if (shouldPrint === 2) { | ||
| hasLoc = false; | ||
| break; | ||
| return i === 0 ? 0 : 1; | ||
| } | ||
@@ -756,6 +751,11 @@ if (hasLoc && comment.loc && shouldPrint === 1) { | ||
| lastLine = commentEndLine; | ||
| maybeNewline(offset); | ||
| if (offset > 0 && !_noLineTerminator) { | ||
| this.newline(offset, _flags); | ||
| } | ||
| this._printComment(comment, 1); | ||
| if (i + 1 === len) { | ||
| maybeNewline(Math.max(nodeStartLine - lastLine, leadingCommentNewline)); | ||
| const count = Math.max(nodeStartLine - lastLine, leadingCommentNewline); | ||
| if (count > 0 && !_noLineTerminator) { | ||
| this.newline(count, _flags); | ||
| } | ||
| lastLine = nodeStartLine; | ||
@@ -766,6 +766,11 @@ } | ||
| lastLine = commentEndLine; | ||
| maybeNewline(offset); | ||
| if (offset > 0 && !_noLineTerminator) { | ||
| this.newline(offset, _flags); | ||
| } | ||
| this._printComment(comment, 1); | ||
| if (i + 1 === len) { | ||
| maybeNewline(Math.min(1, nodeEndLine - lastLine)); | ||
| const count = Math.min(1, nodeEndLine - lastLine); | ||
| if (count > 0 && !_noLineTerminator) { | ||
| this.newline(count, _flags); | ||
| } | ||
| lastLine = nodeEndLine; | ||
@@ -776,3 +781,5 @@ } | ||
| lastLine = commentEndLine; | ||
| maybeNewline(offset); | ||
| if (offset > 0 && !_noLineTerminator) { | ||
| this.newline(offset, _flags); | ||
| } | ||
| this._printComment(comment, 1); | ||
@@ -789,5 +796,3 @@ } | ||
| if (type === 0) { | ||
| this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent, { | ||
| body: node | ||
| }) ? 1 : 0); | ||
| this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent) && parent.body === node ? 1 : 0); | ||
| } else if (shouldSkipNewline && type === 2) { | ||
@@ -808,9 +813,8 @@ this._printComment(comment, 1); | ||
| } | ||
| return 2; | ||
| } | ||
| } | ||
| Object.assign(Printer.prototype, generatorFunctions); | ||
| (0, _deprecated.addDeprecatedGenerators)(Printer); | ||
| var _default = exports.default = Printer; | ||
| function commaSeparator(occurrenceCount, last) { | ||
| this.token(",", false, occurrenceCount); | ||
| this.tokenChar(44, occurrenceCount); | ||
| if (!last) this.space(); | ||
@@ -817,0 +821,0 @@ } |
+3
-0
@@ -58,2 +58,5 @@ "use strict"; | ||
| if (indexes) { | ||
| if (typeof test === "number") { | ||
| test = String.fromCharCode(test); | ||
| } | ||
| let i = 0; | ||
@@ -60,0 +63,0 @@ const count = occurrenceCount; |
+4
-4
| { | ||
| "name": "@babel/generator", | ||
| "version": "7.28.6", | ||
| "version": "7.29.0", | ||
| "description": "Turns an AST into code.", | ||
@@ -22,4 +22,4 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
| "dependencies": { | ||
| "@babel/parser": "^7.28.6", | ||
| "@babel/types": "^7.28.6", | ||
| "@babel/parser": "^7.29.0", | ||
| "@babel/types": "^7.29.0", | ||
| "@jridgewell/gen-mapping": "^0.3.12", | ||
@@ -30,3 +30,3 @@ "@jridgewell/trace-mapping": "^0.3.28", | ||
| "devDependencies": { | ||
| "@babel/core": "^7.28.6", | ||
| "@babel/core": "^7.29.0", | ||
| "@babel/helper-fixtures": "^7.28.6", | ||
@@ -33,0 +33,0 @@ "@babel/plugin-transform-typescript": "^7.28.6", |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.nodes = void 0; | ||
| var _t = require("@babel/types"); | ||
| const { | ||
| FLIPPED_ALIAS_KEYS, | ||
| isArrayExpression, | ||
| isAssignmentExpression, | ||
| isBinary, | ||
| isBlockStatement, | ||
| isCallExpression, | ||
| isFunction, | ||
| isIdentifier, | ||
| isLiteral, | ||
| isMemberExpression, | ||
| isObjectExpression, | ||
| isOptionalCallExpression, | ||
| isOptionalMemberExpression, | ||
| isStringLiteral | ||
| } = _t; | ||
| function crawlInternal(node, state) { | ||
| if (!node) return state; | ||
| if (isMemberExpression(node) || isOptionalMemberExpression(node)) { | ||
| crawlInternal(node.object, state); | ||
| if (node.computed) crawlInternal(node.property, state); | ||
| } else if (isBinary(node) || isAssignmentExpression(node)) { | ||
| crawlInternal(node.left, state); | ||
| crawlInternal(node.right, state); | ||
| } else if (isCallExpression(node) || isOptionalCallExpression(node)) { | ||
| state.hasCall = true; | ||
| crawlInternal(node.callee, state); | ||
| } else if (isFunction(node)) { | ||
| state.hasFunction = true; | ||
| } else if (isIdentifier(node)) { | ||
| state.hasHelper = state.hasHelper || node.callee && isHelper(node.callee); | ||
| } | ||
| return state; | ||
| } | ||
| function crawl(node) { | ||
| return crawlInternal(node, { | ||
| hasCall: false, | ||
| hasFunction: false, | ||
| hasHelper: false | ||
| }); | ||
| } | ||
| function isHelper(node) { | ||
| if (!node) return false; | ||
| if (isMemberExpression(node)) { | ||
| return isHelper(node.object) || isHelper(node.property); | ||
| } else if (isIdentifier(node)) { | ||
| return node.name === "require" || node.name.charCodeAt(0) === 95; | ||
| } else if (isCallExpression(node)) { | ||
| return isHelper(node.callee); | ||
| } else if (isBinary(node) || isAssignmentExpression(node)) { | ||
| return isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right); | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
| function isType(node) { | ||
| return isLiteral(node) || isObjectExpression(node) || isArrayExpression(node) || isIdentifier(node) || isMemberExpression(node); | ||
| } | ||
| const nodes = exports.nodes = { | ||
| AssignmentExpression(node) { | ||
| const state = crawl(node.right); | ||
| if (state.hasCall && state.hasHelper || state.hasFunction) { | ||
| return state.hasFunction ? 1 | 2 : 2; | ||
| } | ||
| return 0; | ||
| }, | ||
| SwitchCase(node, parent) { | ||
| return (!!node.consequent.length || parent.cases[0] === node ? 1 : 0) | (!node.consequent.length && parent.cases[parent.cases.length - 1] === node ? 2 : 0); | ||
| }, | ||
| LogicalExpression(node) { | ||
| if (isFunction(node.left) || isFunction(node.right)) { | ||
| return 2; | ||
| } | ||
| return 0; | ||
| }, | ||
| Literal(node) { | ||
| if (isStringLiteral(node) && node.value === "use strict") { | ||
| return 2; | ||
| } | ||
| return 0; | ||
| }, | ||
| CallExpression(node) { | ||
| if (isFunction(node.callee) || isHelper(node)) { | ||
| return 1 | 2; | ||
| } | ||
| return 0; | ||
| }, | ||
| OptionalCallExpression(node) { | ||
| if (isFunction(node.callee)) { | ||
| return 1 | 2; | ||
| } | ||
| return 0; | ||
| }, | ||
| VariableDeclaration(node) { | ||
| for (let i = 0; i < node.declarations.length; i++) { | ||
| const declar = node.declarations[i]; | ||
| let enabled = isHelper(declar.id) && !isType(declar.init); | ||
| if (!enabled && declar.init) { | ||
| const state = crawl(declar.init); | ||
| enabled = isHelper(declar.init) && state.hasCall || state.hasFunction; | ||
| } | ||
| if (enabled) { | ||
| return 1 | 2; | ||
| } | ||
| } | ||
| return 0; | ||
| }, | ||
| IfStatement(node) { | ||
| if (isBlockStatement(node.consequent)) { | ||
| return 1 | 2; | ||
| } | ||
| return 0; | ||
| } | ||
| }; | ||
| nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) { | ||
| if (parent.properties[0] === node) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| }; | ||
| nodes.ObjectTypeCallProperty = function (node, parent) { | ||
| var _parent$properties; | ||
| if (parent.callProperties[0] === node && !((_parent$properties = parent.properties) != null && _parent$properties.length)) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| }; | ||
| nodes.ObjectTypeIndexer = function (node, parent) { | ||
| var _parent$properties2, _parent$callPropertie; | ||
| if (parent.indexers[0] === node && !((_parent$properties2 = parent.properties) != null && _parent$properties2.length) && !((_parent$callPropertie = parent.callProperties) != null && _parent$callPropertie.length)) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| }; | ||
| nodes.ObjectTypeInternalSlot = function (node, parent) { | ||
| var _parent$properties3, _parent$callPropertie2, _parent$indexers; | ||
| if (parent.internalSlots[0] === node && !((_parent$properties3 = parent.properties) != null && _parent$properties3.length) && !((_parent$callPropertie2 = parent.callProperties) != null && _parent$callPropertie2.length) && !((_parent$indexers = parent.indexers) != null && _parent$indexers.length)) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| }; | ||
| [["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function ([type, amounts]) { | ||
| [type].concat(FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) { | ||
| const ret = amounts ? 1 | 2 : 0; | ||
| nodes[type] = () => ret; | ||
| }); | ||
| }); | ||
| //# sourceMappingURL=whitespace.js.map |
| {"version":3,"names":["_t","require","FLIPPED_ALIAS_KEYS","isArrayExpression","isAssignmentExpression","isBinary","isBlockStatement","isCallExpression","isFunction","isIdentifier","isLiteral","isMemberExpression","isObjectExpression","isOptionalCallExpression","isOptionalMemberExpression","isStringLiteral","crawlInternal","node","state","object","computed","property","left","right","hasCall","callee","hasFunction","hasHelper","isHelper","crawl","name","charCodeAt","isType","nodes","exports","AssignmentExpression","SwitchCase","parent","consequent","length","cases","LogicalExpression","Literal","value","CallExpression","OptionalCallExpression","VariableDeclaration","i","declarations","declar","enabled","id","init","IfStatement","ObjectProperty","ObjectTypeProperty","ObjectMethod","properties","ObjectTypeCallProperty","_parent$properties","callProperties","ObjectTypeIndexer","_parent$properties2","_parent$callPropertie","indexers","ObjectTypeInternalSlot","_parent$properties3","_parent$callPropertie2","_parent$indexers","internalSlots","forEach","type","amounts","concat","ret"],"sources":["../../src/node/whitespace.ts"],"sourcesContent":["import {\n FLIPPED_ALIAS_KEYS,\n isArrayExpression,\n isAssignmentExpression,\n isBinary,\n isBlockStatement,\n isCallExpression,\n isFunction,\n isIdentifier,\n isLiteral,\n isMemberExpression,\n isObjectExpression,\n isOptionalCallExpression,\n isOptionalMemberExpression,\n isStringLiteral,\n} from \"@babel/types\";\n\n// We inline this package\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport * as charCodes from \"charcodes\";\n\nimport type { NodeHandlers } from \"./index.ts\";\n\nimport type * as t from \"@babel/types\";\n\nconst enum WhitespaceFlag {\n none = 0,\n before = 1 << 0,\n after = 1 << 1,\n}\n\nexport type { WhitespaceFlag };\n\nfunction crawlInternal(\n node: t.Node,\n state: { hasCall: boolean; hasFunction: boolean; hasHelper: boolean },\n) {\n if (!node) return state;\n\n if (isMemberExpression(node) || isOptionalMemberExpression(node)) {\n crawlInternal(node.object, state);\n if (node.computed) crawlInternal(node.property, state);\n } else if (isBinary(node) || isAssignmentExpression(node)) {\n crawlInternal(node.left, state);\n crawlInternal(node.right, state);\n } else if (isCallExpression(node) || isOptionalCallExpression(node)) {\n state.hasCall = true;\n crawlInternal(node.callee, state);\n } else if (isFunction(node)) {\n state.hasFunction = true;\n } else if (isIdentifier(node)) {\n state.hasHelper =\n // @ts-expect-error todo(flow->ts): node.callee is not really expected here…\n state.hasHelper || (node.callee && isHelper(node.callee));\n }\n\n return state;\n}\n\n/**\n * Crawl a node to test if it contains a CallExpression, a Function, or a Helper.\n *\n * @example\n * crawl(node)\n * // { hasCall: false, hasFunction: true, hasHelper: false }\n */\n\nfunction crawl(node: t.Node) {\n return crawlInternal(node, {\n hasCall: false,\n hasFunction: false,\n hasHelper: false,\n });\n}\n\n/**\n * Test if a node is or has a helper.\n */\n\nfunction isHelper(node: t.Node): boolean {\n if (!node) return false;\n\n if (isMemberExpression(node)) {\n return isHelper(node.object) || isHelper(node.property);\n } else if (isIdentifier(node)) {\n return (\n node.name === \"require\" ||\n node.name.charCodeAt(0) === charCodes.underscore\n );\n } else if (isCallExpression(node)) {\n return isHelper(node.callee);\n } else if (isBinary(node) || isAssignmentExpression(node)) {\n return (\n (isIdentifier(node.left) && isHelper(node.left)) || isHelper(node.right)\n );\n } else {\n return false;\n }\n}\n\nfunction isType(node: t.Node | null | undefined) {\n return (\n isLiteral(node) ||\n isObjectExpression(node) ||\n isArrayExpression(node) ||\n isIdentifier(node) ||\n isMemberExpression(node)\n );\n}\n\n/**\n * Tests for node types that need whitespace.\n */\n\nexport const nodes: NodeHandlers<WhitespaceFlag> = {\n /**\n * Test if AssignmentExpression needs whitespace.\n */\n\n AssignmentExpression(node: t.AssignmentExpression): WhitespaceFlag {\n const state = crawl(node.right);\n if ((state.hasCall && state.hasHelper) || state.hasFunction) {\n return state.hasFunction\n ? WhitespaceFlag.before | WhitespaceFlag.after\n : WhitespaceFlag.after;\n }\n return WhitespaceFlag.none;\n },\n\n /**\n * Test if SwitchCase needs whitespace.\n */\n\n SwitchCase(node: t.SwitchCase, parent: t.SwitchStatement): WhitespaceFlag {\n return (\n (!!node.consequent.length || parent.cases[0] === node\n ? WhitespaceFlag.before\n : WhitespaceFlag.none) |\n (!node.consequent.length && parent.cases[parent.cases.length - 1] === node\n ? WhitespaceFlag.after\n : WhitespaceFlag.none)\n );\n },\n\n /**\n * Test if LogicalExpression needs whitespace.\n */\n\n LogicalExpression(node: t.LogicalExpression): WhitespaceFlag {\n if (isFunction(node.left) || isFunction(node.right)) {\n return WhitespaceFlag.after;\n }\n return WhitespaceFlag.none;\n },\n\n /**\n * Test if Literal needs whitespace.\n */\n\n Literal(node: t.Literal): WhitespaceFlag {\n if (isStringLiteral(node) && node.value === \"use strict\") {\n return WhitespaceFlag.after;\n }\n return WhitespaceFlag.none;\n },\n\n /**\n * Test if CallExpressionish needs whitespace.\n */\n\n CallExpression(node: t.CallExpression): WhitespaceFlag {\n if (isFunction(node.callee) || isHelper(node)) {\n return WhitespaceFlag.before | WhitespaceFlag.after;\n }\n return WhitespaceFlag.none;\n },\n\n OptionalCallExpression(node: t.OptionalCallExpression): WhitespaceFlag {\n if (isFunction(node.callee)) {\n return WhitespaceFlag.before | WhitespaceFlag.after;\n }\n return WhitespaceFlag.none;\n },\n\n /**\n * Test if VariableDeclaration needs whitespace.\n */\n\n VariableDeclaration(node: t.VariableDeclaration): WhitespaceFlag {\n for (let i = 0; i < node.declarations.length; i++) {\n const declar = node.declarations[i];\n\n let enabled = isHelper(declar.id) && !isType(declar.init);\n if (!enabled && declar.init) {\n const state = crawl(declar.init);\n enabled = (isHelper(declar.init) && state.hasCall) || state.hasFunction;\n }\n\n if (enabled) {\n return WhitespaceFlag.before | WhitespaceFlag.after;\n }\n }\n return WhitespaceFlag.none;\n },\n\n /**\n * Test if IfStatement needs whitespace.\n */\n\n IfStatement(node: t.IfStatement): WhitespaceFlag {\n if (isBlockStatement(node.consequent)) {\n return WhitespaceFlag.before | WhitespaceFlag.after;\n }\n return WhitespaceFlag.none;\n },\n};\n\n/**\n * Test if Property needs whitespace.\n */\n\nnodes.ObjectProperty =\n nodes.ObjectTypeProperty =\n nodes.ObjectMethod =\n function (\n node: t.ObjectProperty | t.ObjectTypeProperty | t.ObjectMethod,\n parent: t.ObjectExpression,\n ): WhitespaceFlag {\n if (parent.properties[0] === node) {\n return WhitespaceFlag.before;\n }\n return WhitespaceFlag.none;\n };\n\nnodes.ObjectTypeCallProperty = function (\n node: t.ObjectTypeCallProperty,\n parent: t.ObjectTypeAnnotation,\n): WhitespaceFlag {\n // @ts-ignore(Babel 7 vs Babel 8) Difference parent.indexers\n if (parent.callProperties[0] === node && !parent.properties?.length) {\n return WhitespaceFlag.before;\n }\n return WhitespaceFlag.none;\n};\n\nnodes.ObjectTypeIndexer = function (\n node: t.ObjectTypeIndexer,\n parent: t.ObjectTypeAnnotation,\n): WhitespaceFlag {\n if (\n // @ts-ignore(Babel 7 vs Babel 8) Difference parent.indexers\n parent.indexers[0] === node &&\n !parent.properties?.length &&\n !parent.callProperties?.length\n ) {\n return WhitespaceFlag.before;\n }\n return WhitespaceFlag.none;\n};\n\nnodes.ObjectTypeInternalSlot = function (\n node: t.ObjectTypeInternalSlot,\n parent: t.ObjectTypeAnnotation,\n): WhitespaceFlag {\n if (\n // @ts-ignore(Babel 7 vs Babel 8) Difference parent.indexers\n parent.internalSlots[0] === node &&\n !parent.properties?.length &&\n !parent.callProperties?.length &&\n !parent.indexers?.length\n ) {\n return WhitespaceFlag.before;\n }\n return WhitespaceFlag.none;\n};\n\n/**\n * Add whitespace tests for nodes and their aliases.\n */\n\n(\n [\n [\"Function\", true],\n [\"Class\", true],\n [\"Loop\", true],\n [\"LabeledStatement\", true],\n [\"SwitchStatement\", true],\n [\"TryStatement\", true],\n ] as const\n).forEach(function ([type, amounts]) {\n [type as string]\n .concat(FLIPPED_ALIAS_KEYS[type] || [])\n .forEach(function (type) {\n const ret = amounts ? WhitespaceFlag.before | WhitespaceFlag.after : 0;\n nodes[type] = () => ret;\n });\n});\n"],"mappings":"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","ignoreList":[]} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
537009
-4.78%5106
-2.93%Updated
Updated