Socket
Socket
Sign inDemoInstall

@babel/generator

Package Overview
Dependencies
10
Maintainers
4
Versions
170
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.20.0 to 7.20.1

62

lib/buffer.js

@@ -7,3 +7,2 @@ "use strict";

exports.default = void 0;
class Buffer {

@@ -29,9 +28,6 @@ constructor(map) {

this._map = map;
this._allocQueue();
}
_allocQueue() {
const queue = this._queue;
for (let i = 0; i < 16; i++) {

@@ -48,10 +44,7 @@ queue.push({

}
_pushQueue(char, repeat, line, column, identifierName, filename) {
const cursor = this._queueCursor;
if (cursor === this._queue.length) {
this._allocQueue();
}
const item = this._queue[cursor];

@@ -66,3 +59,2 @@ item.char = char;

}
_popQueue() {

@@ -72,3 +64,2 @@ if (this._queueCursor === 0) {

}
return this._queue[--this._queueCursor];

@@ -79,3 +70,2 @@ }

this._flush();
const map = this._map;

@@ -85,3 +75,2 @@ const result = {

decodedMap: map == null ? void 0 : map.getDecoded(),
get map() {

@@ -92,3 +81,2 @@ const resultMap = map ? map.get() : null;

},
set map(value) {

@@ -100,3 +88,2 @@ Object.defineProperty(result, "map", {

},
get rawMappings() {

@@ -107,3 +94,2 @@ const mappings = map == null ? void 0 : map.getRawMappings();

},
set rawMappings(value) {

@@ -115,3 +101,2 @@ Object.defineProperty(result, "rawMappings", {

}
};

@@ -123,9 +108,6 @@ return result;

this._flush();
this._append(str, this._sourcePosition, maybeNewline);
}
appendChar(char) {
this._flush();
this._appendChar(char, 1, this._sourcePosition);

@@ -138,13 +120,9 @@ }

const char = this._queue[this._queueCursor - 1].char;
if (char !== 32 && char !== 9) {
break;
}
this._queueCursor--;
}
}
const sourcePosition = this._sourcePosition;
this._pushQueue(char, 1, sourcePosition.line, sourcePosition.column, sourcePosition.identifierName, sourcePosition.filename);

@@ -156,23 +134,16 @@ }

}
_flush() {
const queueCursor = this._queueCursor;
const queue = this._queue;
for (let i = 0; i < queueCursor; i++) {
const item = queue[i];
this._appendChar(item.char, item.repeat, item);
}
this._queueCursor = 0;
}
_appendChar(char, repeat, sourcePos) {
this._last = char;
this._str += repeat > 1 ? String.fromCharCode(char).repeat(repeat) : String.fromCharCode(char);
if (char !== 10) {
this._mark(sourcePos.line, sourcePos.column, sourcePos.identifierName, sourcePos.filename);
this._position.column += repeat;

@@ -184,3 +155,2 @@ } else {

}
_append(str, sourcePos, maybeNewline) {

@@ -190,3 +160,2 @@ const len = str.length;

this._last = str.charCodeAt(len - 1);
if (++this._appendCount > 4096) {

@@ -200,3 +169,2 @@ +this._str;

}
if (!maybeNewline && !this._map) {

@@ -206,3 +174,2 @@ position.column += len;

}
const {

@@ -214,2 +181,3 @@ column,

let line = sourcePos.line;
let i = str.indexOf("\n");

@@ -230,18 +198,12 @@ let last = 0;

}
i = str.indexOf("\n", last);
}
position.column += len - last;
}
_mark(line, column, identifierName, filename) {
var _this$_map;
(_this$_map = this._map) == null ? void 0 : _this$_map.mark(this._position, line, column, identifierName, filename);
}
removeTrailingNewline() {
const queueCursor = this._queueCursor;
if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 10) {

@@ -251,6 +213,4 @@ this._queueCursor--;

}
removeLastSemicolon() {
const queueCursor = this._queueCursor;
if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 59) {

@@ -260,3 +220,2 @@ this._queueCursor--;

}
getLastChar() {

@@ -271,3 +230,2 @@ const queueCursor = this._queueCursor;

if (queueCursor === 0) return this._last === 10 ? 1 : 0;
for (let i = queueCursor - 1; i >= 0; i--) {

@@ -277,6 +235,4 @@ if (this._queue[i].char !== 10) {

}
count++;
}
return count === queueCursor && this._last === 10 ? count + 1 : count;

@@ -288,7 +244,5 @@ }

const queueCursor = this._queueCursor;
if (queueCursor !== 0) {
const lastCp = queue[queueCursor - 1].char;
if (lastCp !== 10) return;
if (queueCursor > 1) {

@@ -318,6 +272,4 @@ return queue[queueCursor - 2].char;

}
sourceWithOffset(prop, loc, lineOffset, columnOffset) {
if (!this._map) return;
this._normalizePosition(prop, loc, lineOffset, columnOffset);

@@ -331,3 +283,2 @@ }

}
_normalizePosition(prop, loc, lineOffset, columnOffset) {

@@ -337,3 +288,2 @@ const pos = loc[prop];

target.identifierName = prop === "start" && loc.identifierName || undefined;
if (pos) {

@@ -345,3 +295,2 @@ target.line = pos.line + lineOffset;

}
getCurrentColumn() {

@@ -352,20 +301,14 @@ const queue = this._queue;

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;
}
getCurrentLine() {
let count = 0;
const queue = this._queue;
for (let i = 0; i < this._queueCursor; i++) {

@@ -376,10 +319,7 @@ if (queue[i].char === 10) {

}
return this._position.line + count;
}
}
exports.default = Buffer;
//# sourceMappingURL=buffer.js.map

@@ -13,3 +13,2 @@ "use strict";

exports.Program = Program;
function File(node) {

@@ -19,15 +18,11 @@ if (node.program) {

}
this.print(node.program, node);
}
function Program(node) {
var _node$directives;
this.printInnerComments(node, false);
this.noIndentInnerCommentsHere();
this.printInnerComments();
const directivesLen = (_node$directives = node.directives) == null ? void 0 : _node$directives.length;
if (directivesLen) {
var _node$directives$trai;
const newline = node.body.length ? 2 : 1;

@@ -37,3 +32,2 @@ this.printSequence(node.directives, node, {

});
if (!((_node$directives$trai = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai.length)) {

@@ -43,16 +37,10 @@ this.newline(newline);

}
this.printSequence(node.body, node);
}
function BlockStatement(node) {
var _node$directives2;
this.tokenChar(123);
this.printInnerComments(node);
const directivesLen = (_node$directives2 = node.directives) == null ? void 0 : _node$directives2.length;
if (directivesLen) {
var _node$directives$trai2;
const newline = node.body.length ? 2 : 1;

@@ -63,3 +51,2 @@ this.printSequence(node.directives, node, {

});
if (!((_node$directives$trai2 = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai2.length)) {

@@ -69,3 +56,2 @@ this.newline(newline);

}
this.printSequence(node.body, node, {

@@ -77,3 +63,2 @@ indent: true

}
function Directive(node) {

@@ -86,6 +71,4 @@ this.print(node.value, node);

const unescapedDoubleQuoteRE = /(?:^|[^\\])(?:\\\\)*"/;
function DirectiveLiteral(node) {
const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw !== undefined) {

@@ -95,3 +78,2 @@ this.token(raw);

}
const {

@@ -109,3 +91,2 @@ value

}
function InterpreterDirective(node) {

@@ -115,3 +96,2 @@ this.token(`#!${node.value}`);

}
function Placeholder(node) {

@@ -121,3 +101,2 @@ this.token("%%");

this.token("%%");
if (node.expectedNode === "Statement") {

@@ -124,0 +103,0 @@ this.semicolon();

@@ -15,5 +15,3 @@ "use strict";

exports._classMethodHead = _classMethodHead;
var _t = require("@babel/types");
const {

@@ -23,3 +21,2 @@ isExportDefaultDeclaration,

} = _t;
function ClassDeclaration(node, parent) {

@@ -31,3 +28,2 @@ {

}
if (node.declare) {

@@ -37,3 +33,2 @@ this.word("declare");

}
if (node.abstract) {

@@ -43,6 +38,3 @@ this.word("abstract");

}
this.word("class");
this.printInnerComments(node);
if (node.id) {

@@ -52,5 +44,3 @@ this.space();

}
this.print(node.typeParameters, node);
if (node.superClass) {

@@ -63,3 +53,2 @@ this.space();

}
if (node.implements) {

@@ -71,11 +60,7 @@ this.space();

}
this.space();
this.print(node.body, node);
}
function ClassBody(node) {
this.tokenChar(123);
this.printInnerComments(node);
if (node.body.length === 0) {

@@ -93,11 +78,9 @@ this.tokenChar(125);

}
function ClassProperty(node) {
var _node$key$loc, _node$key$loc$end;
this.printJoin(node.decorators, node);
this.printJoin(node.decorators, node);
const endLine = (_node$key$loc = node.key.loc) == null ? void 0 : (_node$key$loc$end = _node$key$loc.end) == null ? void 0 : _node$key$loc$end.line;
if (endLine) this.catchUp(endLine);
this.tsPrintClassMemberModifiers(node);
if (node.computed) {

@@ -109,3 +92,2 @@ this.tokenChar(91);

this._variance(node);
this.print(node.key, node);

@@ -117,9 +99,6 @@ }

}
if (node.definite) {
this.tokenChar(33);
}
this.print(node.typeAnnotation, node);
if (node.value) {

@@ -131,17 +110,14 @@ this.space();

}
this.semicolon();
}
function ClassAccessorProperty(node) {
var _node$key$loc2, _node$key$loc2$end;
this.printJoin(node.decorators, node);
this.printJoin(node.decorators, node);
const endLine = (_node$key$loc2 = node.key.loc) == null ? void 0 : (_node$key$loc2$end = _node$key$loc2.end) == null ? void 0 : _node$key$loc2$end.line;
if (endLine) this.catchUp(endLine);
this.tsPrintClassMemberModifiers(node);
this.word("accessor");
this.printInnerComments(node);
this.space();
if (node.computed) {

@@ -153,3 +129,2 @@ this.tokenChar(91);

this._variance(node);
this.print(node.key, node);

@@ -161,9 +136,6 @@ }

}
if (node.definite) {
this.tokenChar(33);
}
this.print(node.typeAnnotation, node);
if (node.value) {

@@ -175,9 +147,6 @@ this.space();

}
this.semicolon();
}
function ClassPrivateProperty(node) {
this.printJoin(node.decorators, node);
if (node.static) {

@@ -187,6 +156,4 @@ this.word("static");

}
this.print(node.key, node);
this.print(node.typeAnnotation, node);
if (node.value) {

@@ -198,31 +165,23 @@ this.space();

}
this.semicolon();
}
function ClassMethod(node) {
this._classMethodHead(node);
this.space();
this.print(node.body, node);
}
function ClassPrivateMethod(node) {
this._classMethodHead(node);
this.space();
this.print(node.body, node);
}
function _classMethodHead(node) {
var _node$key$loc3, _node$key$loc3$end;
this.printJoin(node.decorators, node);
this.printJoin(node.decorators, node);
const endLine = (_node$key$loc3 = node.key.loc) == null ? void 0 : (_node$key$loc3$end = _node$key$loc3.end) == null ? void 0 : _node$key$loc3$end.line;
if (endLine) this.catchUp(endLine);
this.tsPrintClassMemberModifiers(node);
this._methodHead(node);
}
function StaticBlock(node) {

@@ -232,3 +191,2 @@ this.word("static");

this.tokenChar(123);
if (node.body.length === 0) {

@@ -235,0 +193,0 @@ this.tokenChar(125);

@@ -32,7 +32,4 @@ "use strict";

exports.YieldExpression = YieldExpression;
var _t = require("@babel/types");
var n = require("../node");
const {

@@ -44,5 +41,5 @@ isCallExpression,

} = _t;
function UnaryExpression(node) {
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" || node.operator === "throw") {
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" ||
node.operator === "throw") {
this.word(node.operator);

@@ -53,20 +50,15 @@ this.space();

}
this.print(node.argument, node);
}
function DoExpression(node) {
if (node.async) {
this.word("async");
this.ensureNoLineTerminator(() => {
this.printInnerComments(node);
this.ensureNoLineTerminator(() => {
if (node.async) {
this.word("async");
this.space();
});
}
this.word("do");
}
this.word("do");
});
this.space();
this.print(node.body, node);
}
function ParenthesizedExpression(node) {

@@ -77,3 +69,2 @@ this.tokenChar(40);

}
function UpdateExpression(node) {

@@ -88,3 +79,2 @@ if (node.prefix) {

}
function ConditionalExpression(node) {

@@ -101,3 +91,2 @@ this.print(node.test, node);

}
function NewExpression(node, parent) {

@@ -107,3 +96,2 @@ this.word("new");

this.print(node.callee, node);
if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, {

@@ -114,3 +102,2 @@ callee: node

}
this.print(node.typeArguments, node);

@@ -122,3 +109,2 @@ this.print(node.typeParameters, node);

}
this.tokenChar(40);

@@ -128,15 +114,11 @@ this.printList(node.arguments, node);

}
function SequenceExpression(node) {
this.printList(node.expressions, node);
}
function ThisExpression() {
this.word("this");
}
function Super() {
this.word("super");
}
function isDecoratorMemberExpression(node) {

@@ -146,6 +128,4 @@ switch (node.type) {

return true;
case "MemberExpression":
return !node.computed && node.property.type === "Identifier" && isDecoratorMemberExpression(node.object);
default:

@@ -155,3 +135,2 @@ return false;

}
function shouldParenthesizeDecoratorExpression(node) {

@@ -161,6 +140,4 @@ if (node.type === "ParenthesizedExpression") {

}
return !isDecoratorMemberExpression(node.type === "CallExpression" ? node.callee : node);
}
function Decorator(node) {

@@ -171,3 +148,2 @@ this.tokenChar(64);

} = node;
if (shouldParenthesizeDecoratorExpression(expression)) {

@@ -180,23 +156,16 @@ this.tokenChar(40);

}
this.newline();
}
function OptionalMemberExpression(node) {
this.print(node.object, node);
if (!node.computed && isMemberExpression(node.property)) {
throw new TypeError("Got a MemberExpression for MemberExpression property");
}
let computed = node.computed;
if (isLiteral(node.property) && typeof node.property.value === "number") {
computed = true;
}
if (node.optional) {
this.token("?.");
}
if (computed) {

@@ -210,7 +179,5 @@ this.tokenChar(91);

}
this.print(node.property, node);
}
}
function OptionalCallExpression(node) {

@@ -223,4 +190,4 @@ this.print(node.callee, node);

}
this.print(node.typeArguments, node);
this.print(node.typeArguments, node);
this.tokenChar(40);

@@ -230,3 +197,2 @@ this.printList(node.arguments, node);

}
function CallExpression(node) {

@@ -240,10 +206,7 @@ this.print(node.callee, node);

}
function Import() {
this.word("import");
}
function AwaitExpression(node) {
this.word("await");
if (node.argument) {

@@ -254,12 +217,8 @@ this.space();

}
function YieldExpression(node) {
this.word("yield");
if (node.delegate) {
this.ensureNoLineTerminator(() => {
this.printInnerComments(node);
this.tokenChar(42);
});
this.tokenChar(42);
if (node.argument) {

@@ -276,3 +235,2 @@ this.space();

}
function EmptyStatement() {

@@ -286,3 +244,2 @@ this.semicolon(true);

}
function AssignmentPattern(node) {

@@ -297,13 +254,9 @@ this.print(node.left, node);

}
function AssignmentExpression(node, parent) {
const parens = this.inForStatementInitCounter && node.operator === "in" && !n.needsParens(node, parent);
if (parens) {
this.tokenChar(40);
}
this.print(node.left, node);
this.space();
if (node.operator === "in" || node.operator === "instanceof") {

@@ -314,6 +267,4 @@ this.word(node.operator);

}
this.space();
this.print(node.right, node);
if (parens) {

@@ -323,3 +274,2 @@ this.tokenChar(41);

}
function BindExpression(node) {

@@ -330,16 +280,11 @@ this.print(node.object, node);

}
function MemberExpression(node) {
this.print(node.object, node);
if (!node.computed && isMemberExpression(node.property)) {
throw new TypeError("Got a MemberExpression for MemberExpression property");
}
let computed = node.computed;
if (isLiteral(node.property) && typeof node.property.value === "number") {
computed = true;
}
if (computed) {

@@ -354,3 +299,2 @@ this.tokenChar(91);

}
function MetaProperty(node) {

@@ -361,3 +305,2 @@ this.print(node.meta, node);

}
function PrivateName(node) {

@@ -367,3 +310,2 @@ this.tokenChar(35);

}
function V8IntrinsicIdentifier(node) {

@@ -373,10 +315,8 @@ this.tokenChar(37);

}
function ModuleExpression(node) {
this.word("module");
this.space();
this.ensureNoLineTerminator(() => {
this.printInnerComments(node);
this.space();
this.tokenChar(123);
});
this.tokenChar(123);
this.indent();

@@ -386,7 +326,5 @@ const {

} = node;
if (body.body.length || body.directives.length) {
this.newline();
}
this.print(body, node);

@@ -393,0 +331,0 @@ this.dedent();

@@ -80,9 +80,5 @@ "use strict";

exports._variance = _variance;
var _t = require("@babel/types");
var _modules = require("./modules");
var _types2 = require("./types");
const {

@@ -92,7 +88,5 @@ isDeclareExportDeclaration,

} = _t;
function AnyTypeAnnotation() {
this.word("any");
}
function ArrayTypeAnnotation(node) {

@@ -103,15 +97,11 @@ this.print(node.elementType, node, true);

}
function BooleanTypeAnnotation() {
this.word("boolean");
}
function BooleanLiteralTypeAnnotation(node) {
this.word(node.value ? "true" : "false");
}
function NullLiteralTypeAnnotation() {
this.word("null");
}
function DeclareClass(node, parent) {

@@ -122,9 +112,6 @@ if (!isDeclareExportDeclaration(parent)) {

}
this.word("class");
this.space();
this._interfaceish(node);
}
function DeclareFunction(node, parent) {

@@ -135,3 +122,2 @@ if (!isDeclareExportDeclaration(parent)) {

}
this.word("function");

@@ -141,3 +127,2 @@ this.space();

this.print(node.id.typeAnnotation.typeAnnotation, node);
if (node.predicate) {

@@ -147,6 +132,4 @@ this.space();

}
this.semicolon();
}
function InferredPredicate() {

@@ -156,3 +139,2 @@ this.tokenChar(37);

}
function DeclaredPredicate(node) {

@@ -165,3 +147,2 @@ this.tokenChar(37);

}
function DeclareInterface(node) {

@@ -172,3 +153,2 @@ this.word("declare");

}
function DeclareModule(node) {

@@ -183,3 +163,2 @@ this.word("declare");

}
function DeclareModuleExports(node) {

@@ -193,3 +172,2 @@ this.word("declare");

}
function DeclareTypeAlias(node) {

@@ -200,3 +178,2 @@ this.word("declare");

}
function DeclareOpaqueType(node, parent) {

@@ -207,6 +184,4 @@ if (!isDeclareExportDeclaration(parent)) {

}
this.OpaqueType(node);
}
function DeclareVariable(node, parent) {

@@ -217,3 +192,2 @@ if (!isDeclareExportDeclaration(parent)) {

}
this.word("var");

@@ -225,3 +199,2 @@ this.space();

}
function DeclareExportDeclaration(node) {

@@ -232,3 +205,2 @@ this.word("declare");

this.space();
if (node.default) {

@@ -238,13 +210,9 @@ this.word("default");

}
FlowExportDeclaration.call(this, node);
}
function DeclareExportAllDeclaration(node) {
this.word("declare");
this.space();
_modules.ExportAllDeclaration.call(this, node);
}
function EnumDeclaration(node) {

@@ -260,3 +228,2 @@ const {

}
function enumExplicitType(context, name, hasExplicitType) {

@@ -269,6 +236,4 @@ if (hasExplicitType) {

}
context.space();
}
function enumBody(context, node) {

@@ -281,3 +246,2 @@ const {

context.newline();
for (const member of members) {

@@ -287,3 +251,2 @@ context.print(member, node);

}
if (node.hasUnknownMembers) {

@@ -293,7 +256,5 @@ context.token("...");

}
context.dedent();
context.token("}");
}
function EnumBooleanBody(node) {

@@ -306,3 +267,2 @@ const {

}
function EnumNumberBody(node) {

@@ -315,3 +275,2 @@ const {

}
function EnumStringBody(node) {

@@ -324,3 +283,2 @@ const {

}
function EnumSymbolBody(node) {

@@ -330,3 +288,2 @@ enumExplicitType(this, "symbol", true);

}
function EnumDefaultedMember(node) {

@@ -339,3 +296,2 @@ const {

}
function enumInitializedMember(context, node) {

@@ -353,15 +309,11 @@ const {

}
function EnumBooleanMember(node) {
enumInitializedMember(this, node);
}
function EnumNumberMember(node) {
enumInitializedMember(this, node);
}
function EnumStringMember(node) {
enumInitializedMember(this, node);
}
function FlowExportDeclaration(node) {

@@ -374,3 +326,2 @@ if (node.declaration) {

this.tokenChar(123);
if (node.specifiers.length) {

@@ -381,5 +332,3 @@ this.space();

}
this.tokenChar(125);
if (node.source) {

@@ -391,15 +340,11 @@ this.space();

}
this.semicolon();
}
}
function ExistsTypeAnnotation() {
this.tokenChar(42);
}
function FunctionTypeAnnotation(node, parent) {
this.print(node.typeParameters, node);
this.tokenChar(40);
if (node.this) {

@@ -410,3 +355,2 @@ this.word("this");

this.print(node.this.typeAnnotation, node);
if (node.params.length || node.rest) {

@@ -417,5 +361,3 @@ this.tokenChar(44);

}
this.printList(node.params, node);
if (node.rest) {

@@ -426,7 +368,5 @@ if (node.params.length) {

}
this.token("...");
this.print(node.rest, node);
}
this.tokenChar(41);

@@ -440,11 +380,8 @@

}
this.space();
this.print(node.returnType, node);
}
function FunctionTypeParam(node) {
this.print(node.name, node);
if (node.optional) this.tokenChar(63);
if (node.name) {

@@ -454,6 +391,4 @@ this.tokenChar(58);

}
this.print(node.typeAnnotation, node);
}
function InterfaceExtends(node) {

@@ -463,9 +398,6 @@ this.print(node.id, node);

}
function _interfaceish(node) {
var _node$extends;
this.print(node.id, node);
this.print(node.typeParameters, node);
if ((_node$extends = node.extends) != null && _node$extends.length) {

@@ -477,3 +409,2 @@ this.space();

}
if (node.mixins && node.mixins.length) {

@@ -485,3 +416,2 @@ this.space();

}
if (node.implements && node.implements.length) {

@@ -493,7 +423,5 @@ this.space();

}
this.space();
this.print(node.body, node);
}
function _variance(node) {

@@ -508,10 +436,7 @@ if (node.variance) {

}
function InterfaceDeclaration(node) {
this.word("interface");
this.space();
this._interfaceish(node);
}
function andSeparator() {

@@ -522,6 +447,4 @@ this.space();

}
function InterfaceTypeAnnotation(node) {
this.word("interface");
if (node.extends && node.extends.length) {

@@ -533,7 +456,5 @@ this.space();

}
this.space();
this.print(node.body, node);
}
function IntersectionTypeAnnotation(node) {

@@ -544,11 +465,8 @@ this.printJoin(node.types, node, {

}
function MixedTypeAnnotation() {
this.word("mixed");
}
function EmptyTypeAnnotation() {
this.word("empty");
}
function NullableTypeAnnotation(node) {

@@ -558,15 +476,11 @@ this.tokenChar(63);

}
function NumberTypeAnnotation() {
this.word("number");
}
function StringTypeAnnotation() {
this.word("string");
}
function ThisTypeAnnotation() {
this.word("this");
}
function TupleTypeAnnotation(node) {

@@ -577,3 +491,2 @@ this.tokenChar(91);

}
function TypeofTypeAnnotation(node) {

@@ -584,3 +497,2 @@ this.word("typeof");

}
function TypeAlias(node) {

@@ -597,3 +509,2 @@ this.word("type");

}
function TypeAnnotation(node) {

@@ -605,3 +516,2 @@ this.tokenChar(58);

}
function TypeParameterInstantiation(node) {

@@ -612,12 +522,8 @@ this.tokenChar(60);

}
function TypeParameter(node) {
this._variance(node);
this.word(node.name);
if (node.bound) {
this.print(node.bound, node);
}
if (node.default) {

@@ -630,3 +536,2 @@ this.space();

}
function OpaqueType(node) {

@@ -639,3 +544,2 @@ this.word("opaque");

this.print(node.typeParameters, node);
if (node.supertype) {

@@ -646,3 +550,2 @@ this.tokenChar(58);

}
if (node.impltype) {

@@ -654,6 +557,4 @@ this.space();

}
this.semicolon();
}
function ObjectTypeAnnotation(node) {

@@ -667,3 +568,2 @@ if (node.exact) {

const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
if (props.length) {

@@ -676,3 +576,2 @@ this.newline();

},
indent: true,

@@ -689,14 +588,10 @@ statement: true,

}
if (node.inexact) {
this.indent();
this.token("...");
if (props.length) {
this.newline();
}
this.dedent();
}
if (node.exact) {

@@ -708,3 +603,2 @@ this.token("|}");

}
function ObjectTypeInternalSlot(node) {

@@ -715,3 +609,2 @@ if (node.static) {

}
this.tokenChar(91);

@@ -723,3 +616,2 @@ this.tokenChar(91);

if (node.optional) this.tokenChar(63);
if (!node.method) {

@@ -729,6 +621,4 @@ this.tokenChar(58);

}
this.print(node.value, node);
}
function ObjectTypeCallProperty(node) {

@@ -739,6 +629,4 @@ if (node.static) {

}
this.print(node.value, node);
}
function ObjectTypeIndexer(node) {

@@ -749,7 +637,4 @@ if (node.static) {

}
this._variance(node);
this.tokenChar(91);
if (node.id) {

@@ -760,3 +645,2 @@ this.print(node.id, node);

}
this.print(node.key, node);

@@ -768,3 +652,2 @@ this.tokenChar(93);

}
function ObjectTypeProperty(node) {

@@ -775,3 +658,2 @@ if (node.proto) {

}
if (node.static) {

@@ -781,3 +663,2 @@ this.word("static");

}
if (node.kind === "get" || node.kind === "set") {

@@ -787,8 +668,5 @@ this.word(node.kind);

}
this._variance(node);
this.print(node.key, node);
if (node.optional) this.tokenChar(63);
if (!node.method) {

@@ -798,6 +676,4 @@ this.tokenChar(58);

}
this.print(node.value, node);
}
function ObjectTypeSpreadProperty(node) {

@@ -807,3 +683,2 @@ this.token("...");

}
function QualifiedTypeIdentifier(node) {

@@ -814,7 +689,5 @@ this.print(node.qualification, node);

}
function SymbolTypeAnnotation() {
this.word("symbol");
}
function orSeparator() {

@@ -825,3 +698,2 @@ this.space();

}
function UnionTypeAnnotation(node) {

@@ -832,3 +704,2 @@ this.printJoin(node.types, node, {

}
function TypeCastExpression(node) {

@@ -840,3 +711,2 @@ this.tokenChar(40);

}
function Variance(node) {

@@ -849,7 +719,5 @@ if (node.kind === "plus") {

}
function VoidTypeAnnotation() {
this.word("void");
}
function IndexedAccessType(node) {

@@ -861,10 +729,7 @@ this.print(node.objectType, node, true);

}
function OptionalIndexedAccessType(node) {
this.print(node.objectType, node);
if (node.optional) {
this.token("?.");
}
this.tokenChar(91);

@@ -871,0 +736,0 @@ this.print(node.indexType, node);

@@ -6,5 +6,3 @@ "use strict";

});
var _templateLiterals = require("./template-literals");
Object.keys(_templateLiterals).forEach(function (key) {

@@ -20,5 +18,3 @@ if (key === "default" || key === "__esModule") return;

});
var _expressions = require("./expressions");
Object.keys(_expressions).forEach(function (key) {

@@ -34,5 +30,3 @@ if (key === "default" || key === "__esModule") return;

});
var _statements = require("./statements");
Object.keys(_statements).forEach(function (key) {

@@ -48,5 +42,3 @@ if (key === "default" || key === "__esModule") return;

});
var _classes = require("./classes");
Object.keys(_classes).forEach(function (key) {

@@ -62,5 +54,3 @@ if (key === "default" || key === "__esModule") return;

});
var _methods = require("./methods");
Object.keys(_methods).forEach(function (key) {

@@ -76,5 +66,3 @@ if (key === "default" || key === "__esModule") return;

});
var _modules = require("./modules");
Object.keys(_modules).forEach(function (key) {

@@ -90,5 +78,3 @@ if (key === "default" || key === "__esModule") return;

});
var _types = require("./types");
Object.keys(_types).forEach(function (key) {

@@ -104,5 +90,3 @@ if (key === "default" || key === "__esModule") return;

});
var _flow = require("./flow");
Object.keys(_flow).forEach(function (key) {

@@ -118,5 +102,3 @@ if (key === "default" || key === "__esModule") return;

});
var _base = require("./base");
Object.keys(_base).forEach(function (key) {

@@ -132,5 +114,3 @@ if (key === "default" || key === "__esModule") return;

});
var _jsx = require("./jsx");
Object.keys(_jsx).forEach(function (key) {

@@ -146,5 +126,3 @@ if (key === "default" || key === "__esModule") return;

});
var _typescript = require("./typescript");
Object.keys(_typescript).forEach(function (key) {

@@ -151,0 +129,0 @@ if (key === "default" || key === "__esModule") return;

@@ -21,6 +21,4 @@ "use strict";

exports.JSXText = JSXText;
function JSXAttribute(node) {
this.print(node.name, node);
if (node.value) {

@@ -31,7 +29,5 @@ this.tokenChar(61);

}
function JSXIdentifier(node) {
this.word(node.name);
}
function JSXNamespacedName(node) {

@@ -42,3 +38,2 @@ this.print(node.namespace, node);

}
function JSXMemberExpression(node) {

@@ -49,3 +44,2 @@ this.print(node.object, node);

}
function JSXSpreadAttribute(node) {

@@ -57,3 +51,2 @@ this.tokenChar(123);

}
function JSXExpressionContainer(node) {

@@ -64,3 +57,2 @@ this.tokenChar(123);

}
function JSXSpreadChild(node) {

@@ -72,6 +64,4 @@ this.tokenChar(123);

}
function JSXText(node) {
const raw = this.getPossibleRaw(node);
if (raw !== undefined) {

@@ -83,3 +73,2 @@ this.token(raw, true);

}
function JSXElement(node) {

@@ -90,15 +79,11 @@ const open = node.openingElement;

this.indent();
for (const child of node.children) {
this.print(child, node);
}
this.dedent();
this.print(node.closingElement, node);
}
function spaceSeparator() {
this.space();
}
function JSXOpeningElement(node) {

@@ -108,3 +93,2 @@ this.tokenChar(60);

this.print(node.typeParameters, node);
if (node.attributes.length > 0) {

@@ -116,3 +100,2 @@ this.space();

}
if (node.selfClosing) {

@@ -125,3 +108,2 @@ this.space();

}
function JSXClosingElement(node) {

@@ -132,19 +114,14 @@ this.token("</");

}
function JSXEmptyExpression(node) {
this.printInnerComments(node);
function JSXEmptyExpression() {
this.printInnerComments();
}
function JSXFragment(node) {
this.print(node.openingFragment, node);
this.indent();
for (const child of node.children) {
this.print(child, node);
}
this.dedent();
this.print(node.closingFragment, node);
}
function JSXOpeningFragment() {

@@ -154,3 +131,2 @@ this.tokenChar(60);

}
function JSXClosingFragment() {

@@ -157,0 +133,0 @@ this.token("</");

64

lib/generators/methods.js

@@ -14,25 +14,17 @@ "use strict";

exports._predicate = _predicate;
var _t = require("@babel/types");
const {
isIdentifier
} = _t;
function _params(node) {
this.print(node.typeParameters, node);
this.tokenChar(40);
this._parameters(node.params, node);
this.tokenChar(41);
this.print(node.returnType, node, node.type === "ArrowFunctionExpression");
}
function _parameters(parameters, parent) {
const paramLength = parameters.length;
for (let i = 0; i < paramLength; i++) {
this._param(parameters[i], parent);
if (i < parameters.length - 1) {

@@ -43,17 +35,13 @@ this.tokenChar(44);

}
if (paramLength === 0) {
this.printInnerComments(parent);
}
}
function _param(parameter, parent) {
this.printJoin(parameter.decorators, parameter);
this.print(parameter, parent);
if (parameter.optional) {
if (
parameter.optional) {
this.tokenChar(63);
}
this.print(parameter.typeAnnotation, parameter);
this.print(
parameter.typeAnnotation, parameter);
}

@@ -64,3 +52,2 @@

const key = node.key;
if (kind === "get" || kind === "set") {

@@ -70,7 +57,5 @@ this.word(kind);

}
const {
_noLineTerminator
} = this;
if (node.async) {

@@ -81,9 +66,5 @@ this._noLineTerminator = true;

}
if (kind === "method" || kind === "init") {
if (kind === "method" ||
kind === "init") {
if (node.generator) {
if (node.async) {
this.printInnerComments(node);
}
this.tokenChar(42);

@@ -93,3 +74,2 @@ this._noLineTerminator = _noLineTerminator;

}
if (node.computed) {

@@ -100,3 +80,2 @@ this.tokenChar(91);

this.tokenChar(93);
this.printInnerComments(node);
} else {

@@ -106,10 +85,8 @@ this.print(key, node);

}
if (node.optional) {
if (
node.optional) {
this.tokenChar(63);
}
this._params(node);
}
function _predicate(node) {

@@ -120,3 +97,2 @@ if (node.predicate) {

}
this.space();

@@ -126,20 +102,18 @@ this.print(node.predicate, node);

}
function _functionHead(node) {
if (node.async) {
this.word("async");
this._endsWithInnerRaw = false;
this.space();
}
this.word("function");
if (node.generator) this.tokenChar(42);
this.printInnerComments(node);
if (node.generator) {
this._endsWithInnerRaw = false;
this.tokenChar(42);
}
this.space();
if (node.id) {
this.print(node.id, node);
}
this._params(node);
if (node.type !== "TSDeclareFunction") {

@@ -149,10 +123,7 @@ this._predicate(node);

}
function FunctionExpression(node) {
this._functionHead(node);
this.space();
this.print(node.body, node);
}
function ArrowFunctionExpression(node) {

@@ -162,3 +133,2 @@ const {

} = this;
if (node.async) {

@@ -171,3 +141,2 @@ this._noLineTerminator = true;

let firstParam;
if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) {

@@ -178,11 +147,8 @@ this.print(firstParam, node);

this._noLineTerminator = _noLineTerminator;
this._params(node);
}
this._predicate(node);
this.ensureNoLineTerminator(() => {
this.space();
this.printInnerComments(node);
this.printInnerComments();
this.token("=>");

@@ -193,6 +159,4 @@ });

}
function hasTypesOrComments(node, param) {
var _param$leadingComment, _param$trailingCommen;
return !!(node.typeParameters || node.returnType || node.predicate || param.typeAnnotation || param.optional || (_param$leadingComment = param.leadingComments) != null && _param$leadingComment.length || (_param$trailingCommen = param.trailingComments) != null && _param$trailingCommen.length);

@@ -199,0 +163,0 @@ }

@@ -17,5 +17,4 @@ "use strict";

exports.ImportSpecifier = ImportSpecifier;
exports._printAssertions = _printAssertions;
var _t = require("@babel/types");
const {

@@ -29,3 +28,2 @@ isClassDeclaration,

} = _t;
function ImportSpecifier(node) {

@@ -36,5 +34,3 @@ if (node.importKind === "type" || node.importKind === "typeof") {

}
this.print(node.imported, node);
if (node.local && node.local.name !== node.imported.name) {

@@ -47,11 +43,8 @@ this.space();

}
function ImportDefaultSpecifier(node) {
this.print(node.local, node);
}
function ExportDefaultSpecifier(node) {
this.print(node.exported, node);
}
function ExportSpecifier(node) {

@@ -62,5 +55,3 @@ if (node.exportKind === "type") {

}
this.print(node.local, node);
if (node.exported && node.local.name !== node.exported.name) {

@@ -73,3 +64,2 @@ this.space();

}
function ExportNamespaceSpecifier(node) {

@@ -82,9 +72,14 @@ this.tokenChar(42);

}
function _printAssertions(node) {
this.space();
this.tokenChar(123);
this.space();
this.printList(node.assertions, node);
this.space();
this.tokenChar(125);
}
function ExportAllDeclaration(node) {
var _node$assertions;
this.word("export");
this.space();
if (node.exportKind === "type") {

@@ -94,3 +89,2 @@ this.word("type");

}
this.tokenChar(42);

@@ -100,3 +94,2 @@ this.space();

this.space();
if ((_node$assertions = node.assertions) != null && _node$assertions.length) {

@@ -108,10 +101,8 @@ this.ensureNoLineTerminator(() => {

});
this.printAssertions(node);
this._printAssertions(node);
} else {
this.print(node.source, node);
}
this.semicolon();
}
function ExportNamedDeclaration(node) {

@@ -125,3 +116,2 @@ {

this.space();
if (node.declaration) {

@@ -136,13 +126,10 @@ const declar = node.declaration;

}
const specifiers = node.specifiers.slice(0);
const specifiers = node.specifiers.slice(0);
let hasSpecial = false;
for (;;) {
const first = specifiers[0];
if (isExportDefaultSpecifier(first) || isExportNamespaceSpecifier(first)) {
hasSpecial = true;
this.print(specifiers.shift(), node);
if (specifiers.length) {

@@ -156,6 +143,4 @@ this.tokenChar(44);

}
if (specifiers.length || !specifiers.length && !hasSpecial) {
this.tokenChar(123);
if (specifiers.length) {

@@ -166,13 +151,9 @@ this.space();

}
this.tokenChar(125);
}
if (node.source) {
var _node$assertions2;
this.space();
this.word("from");
this.space();
if ((_node$assertions2 = node.assertions) != null && _node$assertions2.length) {

@@ -184,3 +165,3 @@ this.ensureNoLineTerminator(() => {

});
this.printAssertions(node);
this._printAssertions(node);
} else {

@@ -190,7 +171,5 @@ this.print(node.source, node);

}
this.semicolon();
}
}
function ExportDefaultDeclaration(node) {

@@ -203,3 +182,3 @@ {

this.word("export");
this.printInnerComments(node);
this.noIndentInnerCommentsHere();
this.space();

@@ -212,29 +191,22 @@ this.word("default");

}
function ImportDeclaration(node) {
var _node$assertions3;
this.word("import");
this.space();
const isTypeKind = node.importKind === "type" || node.importKind === "typeof";
if (isTypeKind) {
this.printInnerComments(node, false);
this.noIndentInnerCommentsHere();
this.word(node.importKind);
this.space();
} else if (node.module) {
this.printInnerComments(node, false);
this.noIndentInnerCommentsHere();
this.word("module");
this.space();
}
const specifiers = node.specifiers.slice(0);
const hasSpecifiers = !!specifiers.length;
while (hasSpecifiers) {
const first = specifiers[0];
if (isImportDefaultSpecifier(first) || isImportNamespaceSpecifier(first)) {
this.print(specifiers.shift(), node);
if (specifiers.length) {

@@ -248,3 +220,2 @@ this.tokenChar(44);

}
if (specifiers.length) {

@@ -260,3 +231,2 @@ this.tokenChar(123);

}
if (hasSpecifiers || isTypeKind) {

@@ -267,3 +237,2 @@ this.space();

}
if ((_node$assertions3 = node.assertions) != null && _node$assertions3.length) {

@@ -275,10 +244,8 @@ this.print(node.source, node, true);

});
this.printAssertions(node);
this._printAssertions(node);
} else {
this.print(node.source, node);
}
{
var _node$attributes;
if ((_node$attributes = node.attributes) != null && _node$attributes.length) {

@@ -293,3 +260,2 @@ this.space();

}
function ImportAttribute(node) {

@@ -301,3 +267,2 @@ this.print(node.key);

}
function ImportNamespaceSpecifier(node) {

@@ -304,0 +269,0 @@ this.tokenChar(42);

@@ -24,5 +24,3 @@ "use strict";

exports.WithStatement = WithStatement;
var _t = require("@babel/types");
const {

@@ -34,3 +32,2 @@ isFor,

} = _t;
function WithStatement(node) {

@@ -44,3 +41,2 @@ this.word("with");

}
function IfStatement(node) {

@@ -54,3 +50,2 @@ this.word("if");

const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
if (needsBlock) {

@@ -61,5 +56,3 @@ this.tokenChar(123);

}
this.printAndIndentOnComments(node.consequent, node);
if (needsBlock) {

@@ -70,3 +63,2 @@ this.dedent();

}
if (node.alternate) {

@@ -84,10 +76,7 @@ if (this.endsWith(125)) this.space();

} = statement;
if (isStatement(body) === false) {
return statement;
}
return getLastStatement(body);
}
function ForStatement(node) {

@@ -101,3 +90,2 @@ this.word("for");

this.tokenChar(59);
if (node.test) {

@@ -107,5 +95,3 @@ this.space();

}
this.tokenChar(59);
if (node.update) {

@@ -115,7 +101,5 @@ this.space();

}
this.tokenChar(41);
this.printBlock(node);
}
function WhileStatement(node) {

@@ -129,3 +113,2 @@ this.word("while");

}
function ForXStatement(node) {

@@ -135,3 +118,2 @@ this.word("for");

const isForOf = node.type === "ForOfStatement";
if (isForOf && node.await) {

@@ -141,4 +123,3 @@ this.word("await");

}
this.printInnerComments(node, false);
this.noIndentInnerCommentsHere();
this.tokenChar(40);

@@ -153,3 +134,2 @@ this.print(node.left, node);

}
const ForInStatement = ForXStatement;

@@ -159,3 +139,2 @@ exports.ForInStatement = ForInStatement;

exports.ForOfStatement = ForOfStatement;
function DoWhileStatement(node) {

@@ -173,3 +152,2 @@ this.word("do");

}
function printStatementAfterKeyword(printer, node, parent, isLabel) {

@@ -180,6 +158,4 @@ if (node) {

}
printer.semicolon();
}
function BreakStatement(node) {

@@ -189,3 +165,2 @@ this.word("break");

}
function ContinueStatement(node) {

@@ -195,3 +170,2 @@ this.word("continue");

}
function ReturnStatement(node) {

@@ -201,3 +175,2 @@ this.word("return");

}
function ThrowStatement(node) {

@@ -207,3 +180,2 @@ this.word("throw");

}
function LabeledStatement(node) {

@@ -215,3 +187,2 @@ this.print(node.label, node);

}
function TryStatement(node) {

@@ -228,3 +199,2 @@ this.word("try");

}
if (node.finalizer) {

@@ -237,7 +207,5 @@ this.space();

}
function CatchClause(node) {
this.word("catch");
this.space();
if (node.param) {

@@ -250,6 +218,4 @@ this.tokenChar(40);

}
this.print(node.body, node);
}
function SwitchStatement(node) {

@@ -265,11 +231,8 @@ this.word("switch");

indent: true,
addNewlines(leading, cas) {
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
}
});
this.tokenChar(125);
}
function SwitchCase(node) {

@@ -285,3 +248,2 @@ if (node.test) {

}
if (node.consequent.length) {

@@ -294,3 +256,2 @@ this.newline();

}
function DebuggerStatement() {

@@ -300,3 +261,2 @@ this.word("debugger");

}
function VariableDeclaration(node, parent) {

@@ -307,3 +267,2 @@ if (node.declare) {

}
const {

@@ -316,10 +275,7 @@ kind

} = this;
if (kind === "using") {
this._noLineTerminator = true;
}
this.space();
let hasInits = false;
if (!isFor(parent)) {

@@ -334,3 +290,2 @@ for (const declar of node.declarations) {

let iterator;
if (kind === "using") {

@@ -343,3 +298,2 @@ iterator = (_, i) => {

}
this.printList(node.declarations, node, {

@@ -353,3 +307,2 @@ separator: hasInits ? function () {

});
if (isFor(parent)) {

@@ -362,6 +315,4 @@ if (isForStatement(parent)) {

}
this.semicolon();
}
function VariableDeclarator(node) {

@@ -371,3 +322,2 @@ this.print(node.id, node);

this.print(node.id.typeAnnotation, node);
if (node.init) {

@@ -374,0 +324,0 @@ this.space();

@@ -9,3 +9,2 @@ "use strict";

exports.TemplateLiteral = TemplateLiteral;
function TaggedTemplateExpression(node) {

@@ -16,3 +15,2 @@ this.print(node.tag, node);

}
function TemplateElement(node, parent) {

@@ -24,9 +22,6 @@ const isFirst = parent.quasis[0] === node;

}
function TemplateLiteral(node) {
const quasis = node.quasis;
for (let i = 0; i < quasis.length; i++) {
this.print(quasis[i], node);
if (i + 1 < quasis.length) {

@@ -33,0 +28,0 @@ this.print(node.expressions[i], node);

@@ -26,7 +26,4 @@ "use strict";

exports.TupleExpression = TupleExpression;
var _t = require("@babel/types");
var _jsesc = require("jsesc");
const {

@@ -36,11 +33,8 @@ isAssignmentPattern,

} = _t;
function Identifier(node) {
this.word(node.name);
}
function ArgumentPlaceholder() {
this.tokenChar(63);
}
function RestElement(node) {

@@ -50,8 +44,5 @@ this.token("...");

}
function ObjectExpression(node) {
const props = node.properties;
this.tokenChar(123);
this.printInnerComments(node);
if (props.length) {

@@ -65,19 +56,13 @@ this.space();

}
this.sourceWithOffset("end", node.loc, 0, -1);
this.tokenChar(125);
}
function ObjectMethod(node) {
this.printJoin(node.decorators, node);
this._methodHead(node);
this.space();
this.print(node.body, node);
}
function ObjectProperty(node) {
this.printJoin(node.decorators, node);
if (node.computed) {

@@ -88,7 +73,7 @@ this.tokenChar(91);

} else {
if (isAssignmentPattern(node.value) && isIdentifier(node.key) && node.key.name === node.value.left.name) {
if (isAssignmentPattern(node.value) && isIdentifier(node.key) &&
node.key.name === node.value.left.name) {
this.print(node.value, node);
return;
}
this.print(node.key, node);

@@ -100,3 +85,2 @@

}
this.tokenChar(58);

@@ -106,3 +90,2 @@ this.space();

}
function ArrayExpression(node) {

@@ -112,7 +95,4 @@ const elems = node.elements;

this.tokenChar(91);
this.printInnerComments(node);
for (let i = 0; i < elems.length; i++) {
const elem = elems[i];
if (elem) {

@@ -126,6 +106,4 @@ if (i > 0) this.space();

}
this.tokenChar(93);
}
function RecordExpression(node) {

@@ -135,3 +113,2 @@ const props = node.properties;

let endToken;
if (this.format.recordAndTupleSyntaxType === "bar") {

@@ -146,6 +123,3 @@ startToken = "{|";

}
this.token(startToken);
this.printInnerComments(node);
if (props.length) {

@@ -159,6 +133,4 @@ this.space();

}
this.token(endToken);
}
function TupleExpression(node) {

@@ -169,3 +141,2 @@ const elems = node.elements;

let endToken;
if (this.format.recordAndTupleSyntaxType === "bar") {

@@ -180,9 +151,5 @@ startToken = "[|";

}
this.token(startToken);
this.printInnerComments(node);
for (let i = 0; i < elems.length; i++) {
const elem = elems[i];
if (elem) {

@@ -194,18 +161,13 @@ if (i > 0) this.space();

}
this.token(endToken);
}
function RegExpLiteral(node) {
this.word(`/${node.pattern}/${node.flags}`);
}
function BooleanLiteral(node) {
this.word(node.value ? "true" : "false");
}
function NullLiteral() {
this.word("null");
}
function NumericLiteral(node) {

@@ -215,3 +177,2 @@ const raw = this.getPossibleRaw(node);

const value = node.value + "";
if (opts.numbers) {

@@ -227,6 +188,4 @@ this.number(_jsesc(node.value, opts));

}
function StringLiteral(node) {
const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw !== undefined) {

@@ -236,13 +195,9 @@ this.token(raw);

}
const val = _jsesc(node.value, Object.assign(this.format.jsescOption, this.format.jsonCompatibleStrings && {
json: true
}));
return this.token(val);
}
function BigIntLiteral(node) {
const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw !== undefined) {

@@ -252,9 +207,6 @@ this.word(raw);

}
this.word(node.value + "n");
}
function DecimalLiteral(node) {
const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw !== undefined) {

@@ -264,3 +216,2 @@ this.word(raw);

}
this.word(node.value + "m");

@@ -270,3 +221,2 @@ }

const validTopicTokenSet = new Set(["^^", "@@", "^", "%", "#"]);
function TopicReference() {

@@ -276,3 +226,2 @@ const {

} = this.format;
if (validTopicTokenSet.has(topicToken)) {

@@ -290,7 +239,5 @@ this.token(topicToken);

}
function PipelineBareFunction(node) {
this.print(node.callee, node);
}
function PipelinePrimaryTopicReference() {

@@ -297,0 +244,0 @@ this.tokenChar(35);

@@ -74,3 +74,2 @@ "use strict";

exports.tsPrintTypeLiteralOrInterfaceBody = tsPrintTypeLiteralOrInterfaceBody;
function TSTypeAnnotation(node) {

@@ -82,14 +81,10 @@ this.tokenChar(58);

}
function TSTypeParameterInstantiation(node, parent) {
this.tokenChar(60);
this.printList(node.params, node, {});
if (parent.type === "ArrowFunctionExpression" && node.params.length === 1) {
this.tokenChar(44);
}
this.tokenChar(62);
}
function TSTypeParameter(node) {

@@ -100,3 +95,2 @@ if (node.in) {

}
if (node.out) {

@@ -106,5 +100,3 @@ this.word("out");

}
this.word(node.name);
if (node.constraint) {

@@ -116,3 +108,2 @@ this.space();

}
if (node.default) {

@@ -125,3 +116,2 @@ this.space();

}
function TSParameterProperty(node) {

@@ -132,3 +122,2 @@ if (node.accessibility) {

}
if (node.readonly) {

@@ -138,6 +127,4 @@ this.word("readonly");

}
this._param(node.parameter);
}
function TSDeclareFunction(node) {

@@ -148,14 +135,9 @@ if (node.declare) {

}
this._functionHead(node);
this.tokenChar(59);
}
function TSDeclareMethod(node) {
this._classMethodHead(node);
this.tokenChar(59);
}
function TSQualifiedName(node) {

@@ -166,3 +148,2 @@ this.print(node.left, node);

}
function TSCallSignatureDeclaration(node) {

@@ -172,3 +153,2 @@ this.tsPrintSignatureDeclarationBase(node);

}
function TSConstructSignatureDeclaration(node) {

@@ -180,3 +160,2 @@ this.word("new");

}
function TSPropertySignature(node) {

@@ -187,3 +166,2 @@ const {

} = node;
if (readonly) {

@@ -193,6 +171,4 @@ this.word("readonly");

}
this.tsPrintPropertyOrMethodName(node);
this.print(node.typeAnnotation, node);
if (initializer) {

@@ -204,6 +180,4 @@ this.space();

}
this.tokenChar(59);
}
function tsPrintPropertyOrMethodName(node) {

@@ -213,9 +187,6 @@ if (node.computed) {

}
this.print(node.key, node);
if (node.computed) {
this.tokenChar(93);
}
if (node.optional) {

@@ -225,3 +196,2 @@ this.tokenChar(63);

}
function TSMethodSignature(node) {

@@ -231,3 +201,2 @@ const {

} = node;
if (kind === "set" || kind === "get") {

@@ -237,3 +206,2 @@ this.word(kind);

}
this.tsPrintPropertyOrMethodName(node);

@@ -243,3 +211,2 @@ this.tsPrintSignatureDeclarationBase(node);

}
function TSIndexSignature(node) {

@@ -250,3 +217,2 @@ const {

} = node;
if (isStatic) {

@@ -256,3 +222,2 @@ this.word("static");

}
if (readonly) {

@@ -262,7 +227,4 @@ this.word("readonly");

}
this.tokenChar(91);
this._parameters(node.parameters, node);
this.tokenChar(93);

@@ -272,63 +234,47 @@ this.print(node.typeAnnotation, node);

}
function TSAnyKeyword() {
this.word("any");
}
function TSBigIntKeyword() {
this.word("bigint");
}
function TSUnknownKeyword() {
this.word("unknown");
}
function TSNumberKeyword() {
this.word("number");
}
function TSObjectKeyword() {
this.word("object");
}
function TSBooleanKeyword() {
this.word("boolean");
}
function TSStringKeyword() {
this.word("string");
}
function TSSymbolKeyword() {
this.word("symbol");
}
function TSVoidKeyword() {
this.word("void");
}
function TSUndefinedKeyword() {
this.word("undefined");
}
function TSNullKeyword() {
this.word("null");
}
function TSNeverKeyword() {
this.word("never");
}
function TSIntrinsicKeyword() {
this.word("intrinsic");
}
function TSThisType() {
this.word("this");
}
function TSFunctionType(node) {
this.tsPrintFunctionOrConstructorType(node);
}
function TSConstructorType(node) {

@@ -339,3 +285,2 @@ if (node.abstract) {

}
this.word("new");

@@ -345,3 +290,2 @@ this.space();

}
function tsPrintFunctionOrConstructorType(node) {

@@ -351,8 +295,7 @@ const {

} = node;
const parameters = node.parameters;
const parameters =
node.parameters;
this.print(typeParameters, node);
this.tokenChar(40);
this._parameters(parameters, node);
this.tokenChar(41);

@@ -362,6 +305,6 @@ this.space();

this.space();
const returnType = node.typeAnnotation;
const returnType =
node.typeAnnotation;
this.print(returnType.typeAnnotation, node);
}
function TSTypeReference(node) {

@@ -371,3 +314,2 @@ this.print(node.typeName, node, true);

}
function TSTypePredicate(node) {

@@ -378,5 +320,3 @@ if (node.asserts) {

}
this.print(node.parameterName);
if (node.typeAnnotation) {

@@ -389,3 +329,2 @@ this.space();

}
function TSTypeQuery(node) {

@@ -395,3 +334,2 @@ this.word("typeof");

this.print(node.exprName);
if (node.typeParameters) {

@@ -401,18 +339,13 @@ this.print(node.typeParameters, node);

}
function TSTypeLiteral(node) {
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node);
}
function tsPrintTypeLiteralOrInterfaceBody(members, node) {
tsPrintBraced(this, members, node);
}
function tsPrintBraced(printer, members, node) {
printer.token("{");
if (members.length) {
printer.indent();
printer.newline();
for (const member of members) {

@@ -422,10 +355,7 @@ printer.print(member, node);

}
printer.dedent();
}
printer.sourceWithOffset("end", node.loc, 0, -1);
printer.rightBrace();
}
function TSArrayType(node) {

@@ -435,3 +365,2 @@ this.print(node.elementType, node, true);

}
function TSTupleType(node) {

@@ -442,3 +371,2 @@ this.tokenChar(91);

}
function TSOptionalType(node) {

@@ -448,3 +376,2 @@ this.print(node.typeAnnotation, node);

}
function TSRestType(node) {

@@ -454,3 +381,2 @@ this.token("...");

}
function TSNamedTupleMember(node) {

@@ -463,11 +389,8 @@ this.print(node.label, node);

}
function TSUnionType(node) {
tsPrintUnionOrIntersectionType(this, node, "|");
}
function TSIntersectionType(node) {
tsPrintUnionOrIntersectionType(this, node, "&");
}
function tsPrintUnionOrIntersectionType(printer, node, sep) {

@@ -480,6 +403,4 @@ printer.printJoin(node.types, node, {

}
});
}
function TSConditionalType(node) {

@@ -500,3 +421,2 @@ this.print(node.checkType);

}
function TSInferType(node) {

@@ -507,3 +427,2 @@ this.token("infer");

}
function TSParenthesizedType(node) {

@@ -514,3 +433,2 @@ this.tokenChar(40);

}
function TSTypeOperator(node) {

@@ -521,3 +439,2 @@ this.word(node.operator);

}
function TSIndexedAccessType(node) {

@@ -529,3 +446,2 @@ this.print(node.objectType, node, true);

}
function TSMappedType(node) {

@@ -540,3 +456,2 @@ const {

this.space();
if (readonly) {

@@ -547,3 +462,2 @@ tokenIfPlusMinus(this, readonly);

}
this.tokenChar(91);

@@ -555,3 +469,2 @@ this.word(typeParameter.name);

this.print(typeParameter.constraint, typeParameter);
if (nameType) {

@@ -563,5 +476,3 @@ this.space();

}
this.tokenChar(93);
if (optional) {

@@ -571,3 +482,2 @@ tokenIfPlusMinus(this, optional);

}
this.tokenChar(58);

@@ -579,3 +489,2 @@ this.space();

}
function tokenIfPlusMinus(self, tok) {

@@ -586,7 +495,5 @@ if (tok !== true) {

}
function TSLiteralType(node) {
this.print(node.literal, node);
}
function TSExpressionWithTypeArguments(node) {

@@ -596,3 +503,2 @@ this.print(node.expression, node);

}
function TSInterfaceDeclaration(node) {

@@ -606,3 +512,2 @@ const {

} = node;
if (declare) {

@@ -612,3 +517,2 @@ this.word("declare");

}
this.word("interface");

@@ -618,3 +522,2 @@ this.space();

this.print(typeParameters, node);
if (extendz != null && extendz.length) {

@@ -626,11 +529,8 @@ this.space();

}
this.space();
this.print(body, node);
}
function TSInterfaceBody(node) {
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node);
}
function TSTypeAliasDeclaration(node) {

@@ -643,3 +543,2 @@ const {

} = node;
if (declare) {

@@ -649,3 +548,2 @@ this.word("declare");

}
this.word("type");

@@ -661,6 +559,4 @@ this.space();

}
function TSTypeExpression(node) {
var _expression$trailingC;
const {

@@ -678,3 +574,2 @@ type,

}
function TSTypeAssertion(node) {

@@ -691,3 +586,2 @@ const {

}
function TSInstantiationExpression(node) {

@@ -697,3 +591,2 @@ this.print(node.expression, node);

}
function TSEnumDeclaration(node) {

@@ -706,3 +599,2 @@ const {

} = node;
if (declare) {

@@ -712,3 +604,2 @@ this.word("declare");

}
if (isConst) {

@@ -718,3 +609,2 @@ this.word("const");

}
this.word("enum");

@@ -726,3 +616,2 @@ this.space();

}
function TSEnumMember(node) {

@@ -734,3 +623,2 @@ const {

this.print(id, node);
if (initializer) {

@@ -742,6 +630,4 @@ this.space();

}
this.tokenChar(44);
}
function TSModuleDeclaration(node) {

@@ -752,3 +638,2 @@ const {

} = node;
if (declare) {

@@ -758,3 +643,2 @@ this.word("declare");

}
if (!node.global) {

@@ -764,5 +648,3 @@ this.word(id.type === "Identifier" ? "namespace" : "module");

}
this.print(id, node);
if (!node.body) {

@@ -772,5 +654,3 @@ this.tokenChar(59);

}
let body = node.body;
while (body.type === "TSModuleDeclaration") {

@@ -781,11 +661,8 @@ this.tokenChar(46);

}
this.space();
this.print(body, node);
}
function TSModuleBlock(node) {
tsPrintBraced(this, node.body, node);
}
function TSImportType(node) {

@@ -801,3 +678,2 @@ const {

this.tokenChar(41);
if (qualifier) {

@@ -807,3 +683,2 @@ this.tokenChar(46);

}
if (typeParameters) {

@@ -813,3 +688,2 @@ this.print(typeParameters, node);

}
function TSImportEqualsDeclaration(node) {

@@ -821,3 +695,2 @@ const {

} = node;
if (isExport) {

@@ -827,3 +700,2 @@ this.word("export");

}
this.word("import");

@@ -838,3 +710,2 @@ this.space();

}
function TSExternalModuleReference(node) {

@@ -845,3 +716,2 @@ this.token("require(");

}
function TSNonNullExpression(node) {

@@ -851,3 +721,2 @@ this.print(node.expression, node);

}
function TSExportAssignment(node) {

@@ -861,3 +730,2 @@ this.word("export");

}
function TSNamespaceExportDeclaration(node) {

@@ -872,3 +740,2 @@ this.word("export");

}
function tsPrintSignatureDeclarationBase(node) {

@@ -881,5 +748,3 @@ const {

this.tokenChar(40);
this._parameters(parameters, node);
this.tokenChar(41);

@@ -889,6 +754,4 @@ const returnType = node.typeAnnotation;

}
function tsPrintClassMemberModifiers(node) {
const isField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty";
if (isField && node.declare) {

@@ -898,3 +761,2 @@ this.word("declare");

}
if (node.accessibility) {

@@ -904,3 +766,2 @@ this.word(node.accessibility);

}
if (node.static) {

@@ -910,3 +771,2 @@ this.word("static");

}
if (node.override) {

@@ -916,3 +776,2 @@ this.word("override");

}
if (node.abstract) {

@@ -922,3 +781,2 @@ this.word("abstract");

}
if (isField && node.readonly) {

@@ -925,0 +783,0 @@ this.word("readonly");

@@ -8,5 +8,3 @@ "use strict";

exports.default = generate;
var _sourceMap = require("./source-map");
var _printer = require("./printer");

@@ -26,3 +24,2 @@

}
}

@@ -57,6 +54,4 @@

}
if (format.minified) {
format.compact = true;
format.shouldPrintComment = format.shouldPrintComment || (() => format.comments);

@@ -66,3 +61,2 @@ } else {

}
if (format.compact === "auto") {

@@ -75,7 +69,5 @@ format.compact = code.length > 500000;

}
if (format.compact) {
format.indent.adjustMultilineComment = false;
}
return format;

@@ -89,11 +81,8 @@ }

}
generate() {
return this._generator.generate();
}
}
exports.CodeGenerator = CodeGenerator;
function generate(ast, opts, code) {

@@ -100,0 +89,0 @@ const gen = new Generator(ast, opts, code);

@@ -10,9 +10,5 @@ "use strict";

exports.needsWhitespaceBefore = needsWhitespaceBefore;
var whitespace = require("./whitespace");
var parens = require("./parentheses");
var _t = require("@babel/types");
const {

@@ -25,6 +21,4 @@ FLIPPED_ALIAS_KEYS,

} = _t;
function expandAliases(obj) {
const newObj = {};
function add(type, func) {

@@ -37,6 +31,4 @@ const fn = newObj[type];

}
for (const type of Object.keys(obj)) {
const aliases = FLIPPED_ALIAS_KEYS[type];
if (aliases) {

@@ -50,3 +42,2 @@ for (const alias of aliases) {

}
return newObj;

@@ -57,3 +48,2 @@ }

const expandedWhitespaceNodes = expandAliases(whitespace.nodes);
function find(obj, node, parent, printStack) {

@@ -63,3 +53,2 @@ const fn = obj[node.type];

}
function isOrHasCallExpression(node) {

@@ -69,37 +58,26 @@ if (isCallExpression(node)) {

}
return isMemberExpression(node) && isOrHasCallExpression(node.object);
}
function needsWhitespace(node, parent, type) {
if (!node) return false;
if (isExpressionStatement(node)) {
node = node.expression;
}
const flag = find(expandedWhitespaceNodes, node, parent);
if (typeof flag === "number") {
return (flag & type) !== 0;
}
return false;
}
function needsWhitespaceBefore(node, parent) {
return needsWhitespace(node, parent, 1);
}
function needsWhitespaceAfter(node, parent) {
return needsWhitespace(node, parent, 2);
}
function needsParens(node, parent, printStack) {
if (!parent) return false;
if (isNewExpression(parent) && parent.callee === node) {
if (isOrHasCallExpression(node)) return true;
}
return find(expandedParens, node, parent, printStack);

@@ -106,0 +84,0 @@ }

@@ -30,5 +30,3 @@ "use strict";

exports.AwaitExpression = exports.YieldExpression = YieldExpression;
var _t = require("@babel/types");
const {

@@ -115,30 +113,28 @@ isArrayTypeAnnotation,

};
const isClassExtendsClause = (node, parent) => isClass(parent, {
superClass: node
});
const hasPostfixPart = (node, parent) => (isMemberExpression(parent) || isOptionalMemberExpression(parent)) && parent.object === node || (isCallExpression(parent) || isOptionalCallExpression(parent) || isNewExpression(parent)) && parent.callee === node || isTaggedTemplateExpression(parent) && parent.tag === node || isTSNonNullExpression(parent);
function NullableTypeAnnotation(node, parent) {
return isArrayTypeAnnotation(parent);
}
function FunctionTypeAnnotation(node, parent, printStack) {
if (printStack.length < 3) return;
return isUnionTypeAnnotation(parent) || isIntersectionTypeAnnotation(parent) || isArrayTypeAnnotation(parent) || isTypeAnnotation(parent) && isArrowFunctionExpression(printStack[printStack.length - 3]);
return (
isUnionTypeAnnotation(parent) ||
isIntersectionTypeAnnotation(parent) ||
isArrayTypeAnnotation(parent) ||
isTypeAnnotation(parent) &&
isArrowFunctionExpression(printStack[printStack.length - 3])
);
}
function UpdateExpression(node, parent) {
return hasPostfixPart(node, parent) || isClassExtendsClause(node, parent);
}
function ObjectExpression(node, parent, printStack) {
return isFirstInContext(printStack, 1 | 2);
}
function DoExpression(node, parent, printStack) {
return !node.async && isFirstInContext(printStack, 1);
}
function Binary(node, parent) {

@@ -150,11 +146,8 @@ if (node.operator === "**" && isBinaryExpression(parent, {

}
if (isClassExtendsClause(node, parent)) {
return true;
}
if (hasPostfixPart(node, parent) || isUnaryLike(parent) || isAwaitExpression(parent)) {
return true;
}
if (isBinary(parent)) {

@@ -165,4 +158,4 @@ const parentOp = parent.operator;

const nodePos = PRECEDENCE[nodeOp];
if (parentPos === nodePos && parent.right === node && !isLogicalExpression(parent) || parentPos > nodePos) {
if (
parentPos === nodePos && parent.right === node && !isLogicalExpression(parent) || parentPos > nodePos) {
return true;

@@ -172,7 +165,5 @@ }

}
function UnionTypeAnnotation(node, parent) {
return isArrayTypeAnnotation(parent) || isNullableTypeAnnotation(parent) || isIntersectionTypeAnnotation(parent) || isUnionTypeAnnotation(parent);
}
function OptionalIndexedAccessType(node, parent) {

@@ -183,25 +174,20 @@ return isIndexedAccessType(parent, {

}
function TSAsExpression() {
return true;
}
function TSUnionType(node, parent) {
return isTSArrayType(parent) || isTSOptionalType(parent) || isTSIntersectionType(parent) || isTSUnionType(parent) || isTSRestType(parent);
}
function TSInferType(node, parent) {
return isTSArrayType(parent) || isTSOptionalType(parent);
}
function TSInstantiationExpression(node, parent) {
return (isCallExpression(parent) || isOptionalCallExpression(parent) || isNewExpression(parent) || isTSInstantiationExpression(parent)) && !!parent.typeParameters;
}
function BinaryExpression(node, parent) {
return node.operator === "in" && (isVariableDeclarator(parent) || isFor(parent));
}
function SequenceExpression(node, parent) {
if (isForStatement(parent) || isThrowStatement(parent) || isReturnStatement(parent) || isIfStatement(parent) && parent.test === node || isWhileStatement(parent) && parent.test === node || isForInStatement(parent) && parent.right === node || isSwitchStatement(parent) && parent.discriminant === node || isExpressionStatement(parent) && parent.expression === node) {
if (
isForStatement(parent) || isThrowStatement(parent) || isReturnStatement(parent) || isIfStatement(parent) && parent.test === node || isWhileStatement(parent) && parent.test === node || isForInStatement(parent) && parent.right === node || isSwitchStatement(parent) && parent.discriminant === node || isExpressionStatement(parent) && parent.expression === node) {
return false;

@@ -212,11 +198,8 @@ }

}
function YieldExpression(node, parent) {
return isBinary(parent) || isUnaryLike(parent) || hasPostfixPart(node, parent) || isAwaitExpression(parent) && isYieldExpression(node) || isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent);
}
function ClassExpression(node, parent, printStack) {
return isFirstInContext(printStack, 1 | 4);
}
function UnaryLike(node, parent) {

@@ -228,11 +211,8 @@ return hasPostfixPart(node, parent) || isBinaryExpression(parent, {

}
function FunctionExpression(node, parent, printStack) {
return isFirstInContext(printStack, 1 | 4);
}
function ArrowFunctionExpression(node, parent) {
return isExportDeclaration(parent) || ConditionalExpression(node, parent);
}
function ConditionalExpression(node, parent) {

@@ -244,6 +224,4 @@ if (isUnaryLike(parent) || isBinary(parent) || isConditionalExpression(parent, {

}
return UnaryLike(node, parent);
}
function OptionalMemberExpression(node, parent) {

@@ -256,3 +234,2 @@ return isCallExpression(parent, {

}
function AssignmentExpression(node, parent) {

@@ -265,3 +242,2 @@ if (isObjectPattern(node.left)) {

}
function LogicalExpression(node, parent) {

@@ -272,3 +248,2 @@ switch (node.operator) {

return parent.operator === "??" || parent.operator === "&&";
case "&&":

@@ -278,3 +253,2 @@ return isLogicalExpression(parent, {

});
case "??":

@@ -284,6 +258,4 @@ return isLogicalExpression(parent) && parent.operator !== "??";

}
function Identifier(node, parent, printStack) {
var _node$extra;
if ((_node$extra = node.extra) != null && _node$extra.parenthesized && isAssignmentExpression(parent, {

@@ -294,3 +266,2 @@ left: node

}
if (node.name === "let") {

@@ -323,3 +294,2 @@ const isFollowedByBracket = isMemberExpression(parent, {

let parent = printStack[i];
while (i >= 0) {

@@ -341,3 +311,2 @@ if (expressionStatement && isExpressionStatement(parent, {

}
if (i > 0 && (hasPostfixPart(node, parent) && !isNewExpression(parent) || isSequenceExpression(parent) && parent.expressions[0] === node || isUpdateExpression(parent) && !parent.prefix || isConditional(parent, {

@@ -357,3 +326,2 @@ test: node

}
return false;

@@ -360,0 +328,0 @@ }

@@ -7,5 +7,3 @@ "use strict";

exports.nodes = void 0;
var _t = require("@babel/types");
const {

@@ -27,6 +25,4 @@ FLIPPED_ALIAS_KEYS,

} = _t;
function crawlInternal(node, state) {
if (!node) return state;
if (isMemberExpression(node) || isOptionalMemberExpression(node)) {

@@ -44,5 +40,5 @@ crawlInternal(node.object, state);

} else if (isIdentifier(node)) {
state.hasHelper = state.hasHelper || node.callee && isHelper(node.callee);
state.hasHelper =
state.hasHelper || node.callee && isHelper(node.callee);
}
return state;

@@ -61,3 +57,2 @@ }

if (!node) return false;
if (isMemberExpression(node)) {

@@ -75,3 +70,2 @@ return isHelper(node.object) || isHelper(node.property);

}
function isType(node) {

@@ -82,5 +76,5 @@ return isLiteral(node) || isObjectExpression(node) || isArrayExpression(node) || isIdentifier(node) || isMemberExpression(node);

const nodes = {
AssignmentExpression(node) {
const state = crawl(node.right);
if (state.hasCall && state.hasHelper || state.hasFunction) {

@@ -112,3 +106,2 @@ return state.hasFunction ? 1 | 2 : 2;

},
OptionalCallExpression(node) {

@@ -124,3 +117,2 @@ if (isFunction(node.callee)) {

let enabled = isHelper(declar.id) && !isType(declar.init);
if (!enabled && declar.init) {

@@ -130,3 +122,2 @@ const state = crawl(declar.init);

}
if (enabled) {

@@ -143,4 +134,4 @@ return 1 | 2;

}
};
};
exports.nodes = nodes;

@@ -153,6 +144,4 @@

};
nodes.ObjectTypeCallProperty = function (node, parent) {
var _parent$properties;
if (parent.callProperties[0] === node && !((_parent$properties = parent.properties) != null && _parent$properties.length)) {

@@ -162,6 +151,4 @@ return 1;

};
nodes.ObjectTypeIndexer = function (node, parent) {
var _parent$properties2, _parent$callPropertie;
if (parent.indexers[0] === node && !((_parent$properties2 = parent.properties) != null && _parent$properties2.length) && !((_parent$callPropertie = parent.callProperties) != null && _parent$callPropertie.length)) {

@@ -171,6 +158,4 @@ return 1;

};
nodes.ObjectTypeInternalSlot = function (node, parent) {
var _parent$properties3, _parent$callPropertie2, _parent$indexers;
if (parent.internalSlots[0] === node && !((_parent$properties3 = parent.properties) != null && _parent$properties3.length) && !((_parent$callPropertie2 = parent.callProperties) != null && _parent$callPropertie2.length) && !((_parent$indexers = parent.indexers) != null && _parent$indexers.length)) {

@@ -184,3 +169,2 @@ return 1;

const ret = amounts ? 1 | 2 : 0;
nodes[type] = () => ret;

@@ -187,0 +171,0 @@ });

@@ -7,11 +7,6 @@ "use strict";

exports.default = void 0;
var _buffer = require("./buffer");
var n = require("./node");
var _t = require("@babel/types");
var generatorFunctions = require("./generators");
const {

@@ -30,3 +25,2 @@ isFunction,

} = n;
class Printer {

@@ -47,2 +41,4 @@ constructor(format, map) {

this._lastCommentLine = 0;
this._endsWithInnerRaw = false;
this._indentInnerComments = true;
this.format = format;

@@ -53,8 +49,5 @@ this._buf = new _buffer.default(map);

}
generate(ast) {
this.print(ast);
this._maybeAddAuxComment();
return this._buf.get();

@@ -75,3 +68,2 @@ }

this._maybeAddAuxComment();
if (force) {

@@ -88,3 +80,2 @@ this._appendChar(59);

}
this.tokenChar(125);

@@ -95,3 +86,2 @@ }

if (this.format.compact) return;
if (force) {

@@ -101,3 +91,2 @@ this._space();

const lastCp = this.getLastChar();
if (lastCp !== 32 && lastCp !== 10) {

@@ -110,10 +99,9 @@ this._space();

word(str) {
this._maybePrintInnerComments();
if (this._endsWithWord || str.charCodeAt(0) === 47 && this.endsWith(47)) {
this._space();
}
this._maybeAddAuxComment();
this._append(str, false);
this._endsWithWord = true;

@@ -124,2 +112,3 @@ }

this.word(str);
this._endsWithInteger = Number.isInteger(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str.charCodeAt(str.length - 1) !== 46;

@@ -129,23 +118,24 @@ }

token(str, maybeNewline = false) {
this._maybePrintInnerComments();
const lastChar = this.getLastChar();
const strFirst = str.charCodeAt(0);
if (lastChar === 33 && str === "--" || strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 || strFirst === 46 && this._endsWithInteger) {
if (lastChar === 33 && str === "--" ||
strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 ||
strFirst === 46 && this._endsWithInteger) {
this._space();
}
this._maybeAddAuxComment();
this._append(str, maybeNewline);
}
tokenChar(char) {
this._maybePrintInnerComments();
tokenChar(char) {
const lastChar = this.getLastChar();
if (char === 43 && lastChar === 43 || char === 45 && lastChar === 45 || char === 46 && this._endsWithInteger) {
if (
char === 43 && lastChar === 43 || char === 45 && lastChar === 45 ||
char === 46 && this._endsWithInteger) {
this._space();
}
this._maybeAddAuxComment();
this._appendChar(char);

@@ -156,6 +146,4 @@ }

if (i <= 0) return;
if (!force) {
if (this.format.retainLines || this.format.compact) return;
if (this.format.concise) {

@@ -166,102 +154,69 @@ this.space();

}
if (i > 2) i = 2;
if (i > 2) i = 2;
i -= this._buf.getNewlineCount();
for (let j = 0; j < i; j++) {
this._newline();
}
return;
}
endsWith(char) {
return this.getLastChar() === char;
}
getLastChar() {
return this._buf.getLastChar();
}
endsWithCharAndNewline() {
return this._buf.endsWithCharAndNewline();
}
removeTrailingNewline() {
this._buf.removeTrailingNewline();
}
exactSource(loc, cb) {
if (!loc) return cb();
this._catchUp("start", loc);
this._buf.exactSource(loc, cb);
}
source(prop, loc) {
if (!loc) return;
this._catchUp(prop, loc);
this._buf.source(prop, loc);
}
sourceWithOffset(prop, loc, lineOffset, columnOffset) {
if (!loc) return;
this._catchUp(prop, loc);
this._buf.sourceWithOffset(prop, loc, lineOffset, columnOffset);
}
withSource(prop, loc, cb) {
if (!loc) return cb();
this._catchUp(prop, loc);
this._buf.withSource(prop, loc, cb);
}
_space() {
this._queue(32);
}
_newline() {
this._queue(10);
}
_append(str, maybeNewline) {
this._maybeAddParen(str);
this._maybeIndent(str.charCodeAt(0));
this._buf.append(str, maybeNewline);
this._endsWithWord = false;
this._endsWithInteger = false;
}
_appendChar(char) {
this._maybeAddParenChar(char);
this._maybeIndent(char);
this._buf.appendChar(char);
this._endsWithWord = false;
this._endsWithInteger = false;
}
_queue(char) {
this._maybeAddParenChar(char);
this._maybeIndent(char);
this._buf.queue(char);
this._endsWithWord = false;
this._endsWithInteger = false;
}
_maybeIndent(firstChar) {

@@ -272,3 +227,2 @@ if (this._indent && firstChar !== 10 && this.endsWith(10)) {

}
_shouldIndent(firstChar) {

@@ -279,3 +233,2 @@ if (this._indent && firstChar !== 10 && this.endsWith(10)) {

}
_maybeAddParenChar(char) {

@@ -293,3 +246,2 @@ const parenPushNewlineState = this._parenPushNewlineState;

}
this.tokenChar(40);

@@ -299,11 +251,9 @@ this.indent();

}
_maybeAddParen(str) {
const parenPushNewlineState = this._parenPushNewlineState;
if (!parenPushNewlineState) return;
const len = str.length;
let i;
for (i = 0; i < len && str.charCodeAt(i) === 32; i++) continue;
if (i === len) {

@@ -314,15 +264,16 @@ return;

const cha = str.charCodeAt(i);
if (cha !== 10) {
if (cha !== 47 || i + 1 === len) {
if (
cha !== 47 ||
i + 1 === len) {
this._parenPushNewlineState = null;
return;
}
const chaPost = str.charCodeAt(i + 1);
if (chaPost === 42) {
if (chaPost === 42) {
if (PURE_ANNOTATION_RE.test(str.slice(i + 2, len - 2))) {
return;
}
} else if (chaPost !== 47) {

@@ -333,3 +284,2 @@ this._parenPushNewlineState = null;

}
this.tokenChar(40);

@@ -339,3 +289,2 @@ this.indent();

}
catchUp(line) {

@@ -345,3 +294,2 @@ if (!this.format.retainLines) return;

const count = line - this._buf.getCurrentLine();
for (let i = 0; i < count; i++) {

@@ -351,10 +299,8 @@ this._newline();

}
_catchUp(prop, loc) {
if (!this.format.retainLines) return;
const pos = loc ? loc[prop] : null;
if ((pos == null ? void 0 : pos.line) != null) {
const count = pos.line - this._buf.getCurrentLine();
for (let i = 0; i < count; i++) {

@@ -369,3 +315,2 @@ this._newline();

}
ensureNoLineTerminator(fn) {

@@ -379,3 +324,2 @@ const {

}
printTerminatorless(node, parent, isLabel) {

@@ -392,3 +336,2 @@ if (isLabel) {

this.print(node, parent);
if (terminatorState.printed) {

@@ -401,28 +344,22 @@ this.dedent();

}
print(node, parent, noLineTerminator, trailingCommentsLineOffset, forceParens) {
print(node, parent, noLineTerminator,
trailingCommentsLineOffset, forceParens) {
if (!node) return;
this._endsWithInnerRaw = false;
const nodeType = node.type;
const format = this.format;
const oldConcise = format.concise;
if (node._compact) {
if (
node._compact) {
format.concise = 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)}`);
}
this._printStack.push(node);
const oldInAux = this._insideAux;
this._insideAux = node.loc == undefined;
this._maybeAddAuxComment(this._insideAux && !oldInAux);
let shouldPrintParens = false;
if (forceParens) {

@@ -435,16 +372,10 @@ shouldPrintParens = true;

}
if (shouldPrintParens) this.tokenChar(40);
this._lastCommentLine = 0;
this._printLeadingComments(node, parent);
const loc = nodeType === "Program" || nodeType === "File" ? null : node.loc;
this.exactSource(loc, printMethod.bind(this, node, parent));
if (noLineTerminator && !this._noLineTerminator) {
this._noLineTerminator = true;
this._printTrailingComments(node, parent);
this._noLineTerminator = false;

@@ -454,11 +385,9 @@ } else {

}
if (shouldPrintParens) this.tokenChar(41);
this._printStack.pop();
format.concise = oldConcise;
this._insideAux = oldInAux;
this._endsWithInnerRaw = false;
}
_maybeAddAuxComment(enteredPositionlessNode) {

@@ -468,3 +397,2 @@ if (enteredPositionlessNode) this._printAuxBeforeComment();

}
_printAuxBeforeComment() {

@@ -474,3 +402,2 @@ if (this._printAuxAfterOnNextUserNode) return;

const comment = this.format.auxiliaryCommentBefore;
if (comment) {

@@ -483,3 +410,2 @@ this._printComment({

}
_printAuxAfterComment() {

@@ -489,3 +415,2 @@ if (!this._printAuxAfterOnNextUserNode) return;

const comment = this.format.auxiliaryCommentAfter;
if (comment) {

@@ -498,6 +423,4 @@ this._printComment({

}
getPossibleRaw(node) {
const extra = node.extra;
if (extra && extra.raw != null && extra.rawValue != null && node.value === extra.rawValue) {

@@ -507,3 +430,2 @@ return extra.raw;

}
printJoin(nodes, parent, opts = {}) {

@@ -518,3 +440,2 @@ if (!(nodes != null && nodes.length)) return;

const len = nodes.length;
for (let i = 0; i < len; i++) {

@@ -527,3 +448,2 @@ const node = nodes[i];

if (i < len - 1) separator == null ? void 0 : separator();
if (opts.statement) {

@@ -534,6 +454,4 @@ if (i + 1 === len) {

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);

@@ -543,6 +461,4 @@ }

}
if (opts.indent) this.dedent();
}
printAndIndentOnComments(node, parent) {

@@ -554,40 +470,41 @@ const indent = node.leadingComments && node.leadingComments.length > 0;

}
printBlock(parent) {
const node = parent.body;
if (node.type !== "EmptyStatement") {
this.space();
}
this.print(node, parent);
}
_printTrailingComments(node, parent, lineOffset) {
const comments = this._getComments(false, node);
const comments = node.trailingComments;
if (!(comments != null && comments.length)) return;
this._printComments(2, comments, node, parent, lineOffset);
}
_printLeadingComments(node, parent) {
const comments = this._getComments(true, node);
const comments = node.leadingComments;
if (!(comments != null && comments.length)) return;
this._printComments(0, comments, node, parent);
}
printInnerComments(node, indent = true) {
var _node$innerComments;
if (!((_node$innerComments = node.innerComments) != null && _node$innerComments.length)) return;
_maybePrintInnerComments() {
if (this._endsWithInnerRaw) this.printInnerComments();
this._endsWithInnerRaw = true;
this._indentInnerComments = true;
}
printInnerComments() {
const node = this._printStack[this._printStack.length - 1];
const comments = node.innerComments;
if (!(comments != null && comments.length)) return;
const hasSpace = this.endsWith(32);
const indent = this._indentInnerComments;
const printedCommentsCount = this._printedComments.size;
if (indent) this.indent();
this._printComments(1, node.innerComments, node);
this._printComments(1, comments, node);
if (hasSpace && printedCommentsCount !== this._printedComments.size) {
this.space();
}
if (indent) this.dedent();
}
noIndentInnerCommentsHere() {
this._indentInnerComments = false;
}
printSequence(nodes, parent, opts = {}) {

@@ -597,3 +514,2 @@ opts.statement = true;

}
printList(items, parent, opts = {}) {

@@ -603,6 +519,4 @@ if (opts.separator == null) {

}
return this.printJoin(items, parent, opts);
}
_printNewline(newLine, opts) {

@@ -615,13 +529,9 @@ if (this.format.retainLines || this.format.compact) return;

}
if (!newLine) {
return;
}
const startLine = opts.nextNodeStartLine;
const lastCommentLine = this._lastCommentLine;
if (startLine > 0 && lastCommentLine > 0) {
const offset = startLine - lastCommentLine;
if (offset >= 0) {

@@ -634,10 +544,6 @@ this.newline(offset || 1);

if (this._buf.hasContent()) {
this.newline(1);
}
}
_getComments(leading, node) {
return node && (leading ? node.leadingComments : node.trailingComments) || null;
}
_printComment(comment, skipNewLines) {

@@ -647,28 +553,19 @@ if (comment.ignore) return;

if (!this.format.shouldPrintComment(comment.value)) return;
this._printedComments.add(comment);
const isBlockComment = comment.type === "CommentBlock";
const isBlockComment = comment.type === "CommentBlock";
const printNewLines = isBlockComment && skipNewLines !== 1 && !this._noLineTerminator;
if (printNewLines && this._buf.hasContent() && skipNewLines !== 2) {
this.newline(1);
}
const lastCharCode = this.getLastChar();
if (lastCharCode !== 91 && lastCharCode !== 123) {
this.space();
}
let val;
if (isBlockComment) {
val = `/*${comment.value}*/`;
if (this.format.indent.adjustMultilineComment) {
var _comment$loc;
const offset = (_comment$loc = comment.loc) == null ? void 0 : _comment$loc.start.column;
if (offset) {

@@ -678,9 +575,6 @@ const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");

}
let indentSize = this.format.retainLines ? 0 : this._buf.getCurrentColumn();
if (this._shouldIndent(47) || this.format.retainLines) {
indentSize += this._getIndent();
}
val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);

@@ -696,9 +590,6 @@ }

this.source("start", comment.loc);
this._append(val, isBlockComment);
if (!isBlockComment && !this._noLineTerminator) {
this.newline(1, true);
}
if (printNewLines && skipNewLines !== 3) {

@@ -708,3 +599,2 @@ this.newline(1);

}
_printComments(type, comments, node, parent, lineOffset = 0) {

@@ -719,13 +609,9 @@ {

let leadingCommentNewline = 0;
for (let i = 0; i < len; i++) {
const comment = comments[i];
if (hasLoc && comment.loc && !this._printedComments.has(comment)) {
const commentStartLine = comment.loc.start.line;
const commentEndLine = comment.loc.end.line;
if (type === 0) {
let offset = 0;
if (i === 0) {

@@ -738,8 +624,5 @@ if (this._buf.hasContent() && (comment.type === "CommentLine" || commentStartLine != commentEndLine)) {

}
lastLine = commentEndLine;
this.newline(offset);
this._printComment(comment, 1);
if (i + 1 === len) {

@@ -753,5 +636,3 @@ this.newline(Math.max(nodeStartLine - lastLine, leadingCommentNewline));

this.newline(offset);
this._printComment(comment, 1);
if (i + 1 === len) {

@@ -765,3 +646,2 @@ this.newline(Math.min(1, nodeEndLine - lastLine));

this.newline(offset);
this._printComment(comment, 1);

@@ -771,7 +651,5 @@ }

hasLoc = false;
if (len === 1) {
const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !comment.value.includes("\n");
const shouldSkipNewline = singleLine && !isStatement(node) && !isClassBody(parent) && !isTSInterfaceBody(parent);
if (type === 0) {

@@ -787,2 +665,3 @@ this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent, {

} else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") {
this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);

@@ -794,3 +673,2 @@ } else {

}
if (type === 2 && hasLoc && lastLine) {

@@ -801,13 +679,2 @@ this._lastCommentLine = lastLine;

}
printAssertions(node) {
this.space();
this.printInnerComments(node);
this.tokenChar(123);
this.space();
this.printList(node.assertions, node);
this.space();
this.tokenChar(125);
}
}

@@ -821,3 +688,2 @@

exports.default = _default;
function commaSeparator() {

@@ -824,0 +690,0 @@ this.tokenChar(44);

@@ -7,9 +7,8 @@ "use strict";

exports.default = void 0;
var _genMapping = require("@jridgewell/gen-mapping");
class SourceMap {
constructor(opts, code) {
var _opts$sourceFileName;
this._map = void 0;

@@ -26,3 +25,2 @@ this._rawMappings = void 0;

this._rawMappings = undefined;
if (typeof code === "string") {

@@ -40,7 +38,5 @@ (0, _genMapping.setSourceContent)(map, this._sourceFileName, code);

}
getDecoded() {
return (0, _genMapping.toDecodedMap)(this._map);
}
getRawMappings() {

@@ -62,7 +58,5 @@ return this._rawMappings || (this._rawMappings = (0, _genMapping.allMappings)(this._map));

}
}
exports.default = SourceMap;
//# sourceMappingURL=source-map.js.map
{
"name": "@babel/generator",
"version": "7.20.0",
"version": "7.20.1",
"description": "Turns an AST into code.",

@@ -28,3 +28,3 @@ "author": "The Babel Team (https://babel.dev/team)",

"@babel/helper-fixtures": "^7.19.4",
"@babel/parser": "^7.20.0",
"@babel/parser": "^7.20.1",
"@jridgewell/trace-mapping": "^0.3.8",

@@ -31,0 +31,0 @@ "@types/jsesc": "^2.5.0",

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 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc