You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@babel/generator

Package Overview
Dependencies
Maintainers
4
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/generator - npm Package Compare versions

Comparing version
7.28.5
to
7.28.6
+62
-16
lib/generators/deprecated.js

@@ -8,22 +8,68 @@ "use strict";

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;
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;
}
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.word(node.value + "m");
}
};
Object.assign(PrinterClass.prototype, deprecatedBabel7Generators);
}
this.token(endToken);
}
};
Object.assign(PrinterClass.prototype, deprecatedBabel7Generators);
}
//# sourceMappingURL=deprecated.js.map

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

this.print(node.typeArguments);
{
this.print(node.typeParameters);
if (node.optional) {
this.token("?.");
}
this.print(node.typeParameters);
if (node.optional) {
this.token("?.");
}

@@ -167,5 +165,3 @@ if (node.arguments.length === 0 && this.tokenMap && !this.tokenMap.endMatches(node, ")")) {

this.print(node.callee);
{
this.print(node.typeParameters);
}
this.print(node.typeParameters);
if (node.optional) {

@@ -184,5 +180,3 @@ this.token("?.");

this.print(node.typeArguments);
{
this.print(node.typeParameters);
}
this.print(node.typeParameters);
this.tokenChar(40);

@@ -189,0 +183,0 @@ const exit = this.enterDelimited();

@@ -83,8 +83,6 @@ "use strict";

this.print(node.name);
{
if (node.typeArguments) {
this.print(node.typeArguments);
}
this.print(node.typeParameters);
if (node.typeArguments) {
this.print(node.typeArguments);
}
this.print(node.typeParameters);
if (node.attributes.length > 0) {

@@ -91,0 +89,0 @@ this.space();

@@ -72,8 +72,10 @@ "use strict";

const {
attributes
} = node;
var {
assertions
} = node;
const {
importAttributesKeyword
} = this.format;
const {
attributes,
assertions
} = node;
if (attributes && !importAttributesKeyword && node.extra && (node.extra.deprecatedAssertSyntax || node.extra.deprecatedWithLegacySyntax) && !warningShown) {

@@ -80,0 +82,0 @@ warningShown = true;

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

this.print(node.tag);
{
this.print(node.typeParameters);
}
this.print(node.typeParameters);
this.print(node.quasi);

@@ -17,0 +15,0 @@ }

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

exports.PipelineTopicExpression = PipelineTopicExpression;
exports.RecordExpression = RecordExpression;
exports.RegExpLiteral = RegExpLiteral;

@@ -25,3 +24,2 @@ exports.SpreadElement = exports.RestElement = RestElement;

exports.TopicReference = TopicReference;
exports.TupleExpression = TupleExpression;
exports.VoidPattern = VoidPattern;

@@ -121,54 +119,2 @@ exports._getRawIdentifier = _getRawIdentifier;

}
function RecordExpression(node) {
const props = node.properties;
let startToken;
let endToken;
{
if (this.format.recordAndTupleSyntaxType === "bar") {
startToken = "{|";
endToken = "|}";
} else if (this.format.recordAndTupleSyntaxType !== "hash" && this.format.recordAndTupleSyntaxType != null) {
throw new Error(`The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify(this.format.recordAndTupleSyntaxType)} received).`);
} else {
startToken = "#{";
endToken = "}";
}
}
this.token(startToken);
if (props.length) {
this.space();
this.printList(props, this.shouldPrintTrailingComma(endToken), true, true);
this.space();
}
this.token(endToken);
}
function TupleExpression(node) {
const elems = node.elements;
const len = elems.length;
let startToken;
let endToken;
{
if (this.format.recordAndTupleSyntaxType === "bar") {
startToken = "[|";
endToken = "|]";
} else if (this.format.recordAndTupleSyntaxType === "hash") {
startToken = "#[";
endToken = "]";
} else {
throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`);
}
}
this.token(startToken);
for (let i = 0; i < elems.length; i++) {
const elem = elems[i];
if (elem) {
if (i > 0) this.space();
this.print(elem);
if (i < len - 1 || this.shouldPrintTrailingComma(endToken)) {
this.token(",", false, i);
}
}
}
this.token(endToken);
}
function RegExpLiteral(node) {

@@ -175,0 +121,0 @@ this.word(`/${node.pattern}/${node.flags}`);

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

this.tokenChar(91);
{
this.word(node.typeParameter.name);
}
this.word(node.typeParameter.name);
this.space();
this.word("in");
this.space();
{
this.print(node.typeParameter.constraint);
}
this.print(node.typeParameter.constraint);
if (nameType) {

@@ -531,5 +527,3 @@ this.space();

this.print(node.expression);
{
this.print(node.typeParameters);
}
this.print(node.typeParameters);
}

@@ -554,5 +548,3 @@ function TSEnumDeclaration(node) {

this.space();
{
TSEnumBody.call(this, node);
}
TSEnumBody.call(this, node);
}

@@ -588,21 +580,19 @@ function TSEnumBody(node) {

}
{
if (!node.global) {
this.word(kind != null ? kind : id.type === "Identifier" ? "namespace" : "module");
this.space();
}
this.print(id);
if (!node.body) {
this.semicolon();
return;
}
let body = node.body;
while (body.type === "TSModuleDeclaration") {
this.tokenChar(46);
this.print(body.id);
body = body.body;
}
if (!node.global) {
this.word(kind != null ? kind : id.type === "Identifier" ? "namespace" : "module");
this.space();
this.print(body);
}
this.print(id);
if (!node.body) {
this.semicolon();
return;
}
let body = node.body;
while (body.type === "TSModuleDeclaration") {
this.tokenChar(46);
this.print(body.id);
body = body.body;
}
this.space();
this.print(body);
}

@@ -614,3 +604,2 @@ function TSModuleBlock(node) {

const {
argument,
qualifier,

@@ -621,3 +610,3 @@ options

this.tokenChar(40);
this.print(argument);
this.print(node.argument);
if (options) {

@@ -624,0 +613,0 @@ this.tokenChar(44);

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

function normalizeOptions(code, opts, ast) {
var _opts$recordAndTupleS;
if (opts.experimental_preserveFormat) {

@@ -52,11 +53,8 @@ if (typeof code !== "string") {

}, opts.jsescOption),
topicToken: opts.topicToken,
importAttributesKeyword: opts.importAttributesKeyword
topicToken: opts.topicToken
};
{
var _opts$recordAndTupleS;
format.decoratorsBeforeExport = opts.decoratorsBeforeExport;
format.jsescOption.json = opts.jsonCompatibleStrings;
format.recordAndTupleSyntaxType = (_opts$recordAndTupleS = opts.recordAndTupleSyntaxType) != null ? _opts$recordAndTupleS : "hash";
}
format.decoratorsBeforeExport = opts.decoratorsBeforeExport;
format.jsescOption.json = opts.jsonCompatibleStrings;
format.recordAndTupleSyntaxType = (_opts$recordAndTupleS = opts.recordAndTupleSyntaxType) != null ? _opts$recordAndTupleS : "hash";
format.importAttributesKeyword = opts.importAttributesKeyword;
if (format.minified) {

@@ -90,18 +88,16 @@ format.compact = true;

}
{
exports.CodeGenerator = class CodeGenerator {
constructor(ast, opts = {}, code) {
this._ast = void 0;
this._format = void 0;
this._map = void 0;
this._ast = ast;
this._format = normalizeOptions(code, opts, ast);
this._map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
}
generate() {
const printer = new _printer.default(this._format, this._map);
return printer.generate(this._ast);
}
};
}
exports.CodeGenerator = class CodeGenerator {
constructor(ast, opts = {}, code) {
this._ast = void 0;
this._format = void 0;
this._map = void 0;
this._ast = ast;
this._format = normalizeOptions(code, opts, ast);
this._map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
}
generate() {
const printer = new _printer.default(this._format, this._map);
return printer.generate(this._ast);
}
};
function generate(ast, opts = {}, code) {

@@ -108,0 +104,0 @@ const format = normalizeOptions(code, opts, ast);

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

Object.assign(Printer.prototype, generatorFunctions);
{
(0, _deprecated.addDeprecatedGenerators)(Printer);
}
(0, _deprecated.addDeprecatedGenerators)(Printer);
var _default = exports.default = Printer;

@@ -776,0 +774,0 @@ function commaSeparator(occurrenceCount, last) {

@@ -62,3 +62,3 @@ "use strict";

const cache = this._nodesOccurrencesCountCache.get(node);
if (cache && cache.test === test && cache.count < count) {
if ((cache == null ? void 0 : cache.test) === test && cache.count < count) {
i = cache.i + 1;

@@ -107,2 +107,3 @@ occurrenceCount -= cache.count + 1;

_getTokensIndexesOfNode(node) {
var _node$declaration;
if (node.start == null || node.end == null) return [];

@@ -115,3 +116,3 @@ const {

const children = childrenIterator(node);
if ((node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") && node.declaration && node.declaration.type === "ClassDeclaration") {
if ((node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") && ((_node$declaration = node.declaration) == null ? void 0 : _node$declaration.type) === "ClassDeclaration") {
children.next();

@@ -118,0 +119,0 @@ }

{
"name": "@babel/generator",
"version": "7.28.5",
"version": "7.28.6",
"description": "Turns an AST into code.",

@@ -22,4 +22,4 @@ "author": "The Babel Team (https://babel.dev/team)",

"dependencies": {
"@babel/parser": "^7.28.5",
"@babel/types": "^7.28.5",
"@babel/parser": "^7.28.6",
"@babel/types": "^7.28.6",
"@jridgewell/gen-mapping": "^0.3.12",

@@ -30,5 +30,5 @@ "@jridgewell/trace-mapping": "^0.3.28",

"devDependencies": {
"@babel/core": "^7.28.5",
"@babel/helper-fixtures": "^7.28.0",
"@babel/plugin-transform-typescript": "^7.28.5",
"@babel/core": "^7.28.6",
"@babel/helper-fixtures": "^7.28.6",
"@babel/plugin-transform-typescript": "^7.28.6",
"@jridgewell/sourcemap-codec": "^1.5.3",

@@ -35,0 +35,0 @@ "charcodes": "^0.2.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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet