@babel/generator
Advanced tools
Comparing version 7.17.10 to 7.17.12
@@ -13,4 +13,3 @@ "use strict"; | ||
column: undefined, | ||
filename: undefined, | ||
force: false | ||
filename: undefined | ||
}; | ||
@@ -77,7 +76,6 @@ } | ||
filename, | ||
identifierName, | ||
force | ||
identifierName | ||
} = this._sourcePosition; | ||
this._append(str, line, column, identifierName, filename, force); | ||
this._append(str, line, column, identifierName, filename); | ||
} | ||
@@ -96,11 +94,10 @@ | ||
filename, | ||
identifierName, | ||
force | ||
identifierName | ||
} = this._sourcePosition; | ||
this._queue.unshift([str, line, column, identifierName, filename, force]); | ||
this._queue.unshift([str, line, column, identifierName, filename]); | ||
} | ||
queueIndentation(str) { | ||
this._queue.unshift([str, undefined, undefined, undefined, undefined, false]); | ||
this._queue.unshift([str, undefined, undefined, undefined, undefined]); | ||
} | ||
@@ -116,3 +113,3 @@ | ||
_append(str, line, column, identifierName, filename, force) { | ||
_append(str, line, column, identifierName, filename) { | ||
this._buf += str; | ||
@@ -124,3 +121,3 @@ this._last = str.charCodeAt(str.length - 1); | ||
if (i !== 0) { | ||
this._mark(line, column, identifierName, filename, force); | ||
this._mark(line, column, identifierName, filename); | ||
} | ||
@@ -134,3 +131,3 @@ | ||
if (last < str.length) { | ||
this._mark(++line, 0, identifierName, filename, force); | ||
this._mark(++line, 0, identifierName, filename); | ||
} | ||
@@ -144,6 +141,6 @@ | ||
_mark(line, column, identifierName, filename, force) { | ||
_mark(line, column, identifierName, filename) { | ||
var _this$_map; | ||
(_this$_map = this._map) == null ? void 0 : _this$_map.mark(this._position, line, column, identifierName, filename, force); | ||
(_this$_map = this._map) == null ? void 0 : _this$_map.mark(this._position, line, column, identifierName, filename); | ||
} | ||
@@ -198,3 +195,3 @@ | ||
exactSource(loc, cb) { | ||
this.source("start", loc, true); | ||
this.source("start", loc); | ||
cb(); | ||
@@ -206,6 +203,6 @@ this.source("end", loc); | ||
source(prop, loc, force) { | ||
source(prop, loc) { | ||
if (prop && !loc) return; | ||
this._normalizePosition(prop, loc, this._sourcePosition, force); | ||
this._normalizePosition(prop, loc, this._sourcePosition); | ||
} | ||
@@ -222,3 +219,3 @@ | ||
if ((!this._sourcePosition.force || this._sourcePosition.line !== originalLine || this._sourcePosition.column !== originalColumn || this._sourcePosition.filename !== originalFilename) && (!this._disallowedPop || this._disallowedPop.line !== originalLine || this._disallowedPop.column !== originalColumn || this._disallowedPop.filename !== originalFilename)) { | ||
if (!this._disallowedPop || this._disallowedPop.line !== originalLine || this._disallowedPop.column !== originalColumn || this._disallowedPop.filename !== originalFilename) { | ||
this._sourcePosition.line = originalLine; | ||
@@ -228,3 +225,2 @@ this._sourcePosition.column = originalColumn; | ||
this._sourcePosition.identifierName = originalIdentifierName; | ||
this._sourcePosition.force = false; | ||
this._disallowedPop = null; | ||
@@ -236,19 +232,11 @@ } | ||
if (prop && !loc) return; | ||
this._disallowedPop = this._normalizePosition(prop, loc, SourcePos(), false); | ||
this._disallowedPop = this._normalizePosition(prop, loc, SourcePos()); | ||
} | ||
_normalizePosition(prop, loc, targetObj, force) { | ||
_normalizePosition(prop, loc, targetObj) { | ||
const pos = loc ? loc[prop] : null; | ||
const origLine = targetObj.line; | ||
const origColumn = targetObj.column; | ||
const origFilename = targetObj.filename; | ||
targetObj.identifierName = prop === "start" && (loc == null ? void 0 : loc.identifierName) || null; | ||
targetObj.identifierName = prop === "start" && (loc == null ? void 0 : loc.identifierName) || undefined; | ||
targetObj.line = pos == null ? void 0 : pos.line; | ||
targetObj.column = pos == null ? void 0 : pos.column; | ||
targetObj.filename = loc == null ? void 0 : loc.filename; | ||
if (force || targetObj.line !== origLine || targetObj.column !== origColumn || targetObj.filename !== origFilename) { | ||
targetObj.force = force; | ||
} | ||
return targetObj; | ||
@@ -255,0 +243,0 @@ } |
@@ -40,2 +40,3 @@ "use strict"; | ||
isBinaryExpression, | ||
isUpdateExpression, | ||
isCallExpression, | ||
@@ -53,2 +54,3 @@ isClassDeclaration, | ||
isForStatement, | ||
isFunctionExpression, | ||
isIfStatement, | ||
@@ -278,2 +280,10 @@ isIndexedAccessType, | ||
function Identifier(node, parent, printStack) { | ||
var _node$extra; | ||
if ((_node$extra = node.extra) != null && _node$extra.parenthesized && isAssignmentExpression(parent, { | ||
left: node | ||
}) && (isFunctionExpression(parent.right) || isClassExpression(parent.right)) && parent.right.id == null) { | ||
return true; | ||
} | ||
if (node.name === "let") { | ||
@@ -329,3 +339,3 @@ const isFollowedByBracket = isMemberExpression(parent, { | ||
if (hasPostfixPart(node, parent) && !isNewExpression(parent) || isSequenceExpression(parent) && parent.expressions[0] === node || isConditional(parent, { | ||
if (hasPostfixPart(node, parent) && !isNewExpression(parent) || isSequenceExpression(parent) && parent.expressions[0] === node || isUpdateExpression(parent) && !parent.prefix || isConditional(parent, { | ||
test: node | ||
@@ -332,0 +342,0 @@ }) || isBinary(parent, { |
@@ -36,7 +36,7 @@ "use strict"; | ||
get() { | ||
return (0, _genMapping.encodedMap)(this._map); | ||
return (0, _genMapping.toEncodedMap)(this._map); | ||
} | ||
getDecoded() { | ||
return (0, _genMapping.decodedMap)(this._map); | ||
return (0, _genMapping.toDecodedMap)(this._map); | ||
} | ||
@@ -48,15 +48,5 @@ | ||
mark(generated, line, column, identifierName, filename, force) { | ||
const generatedLine = generated.line; | ||
if (this._lastGenLine !== generatedLine && line == null) return; | ||
if (!force && this._lastGenLine === generatedLine && this._lastSourceLine === line && this._lastSourceColumn === column) { | ||
return; | ||
} | ||
mark(generated, line, column, identifierName, filename) { | ||
this._rawMappings = undefined; | ||
this._lastGenLine = generatedLine; | ||
this._lastSourceLine = line; | ||
this._lastSourceColumn = column; | ||
(0, _genMapping.addMapping)(this._map, { | ||
(0, _genMapping.maybeAddMapping)(this._map, { | ||
name: identifierName, | ||
@@ -63,0 +53,0 @@ generated, |
{ | ||
"name": "@babel/generator", | ||
"version": "7.17.10", | ||
"version": "7.17.12", | ||
"description": "Turns an AST into code.", | ||
@@ -22,4 +22,4 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"dependencies": { | ||
"@babel/types": "^7.17.10", | ||
"@jridgewell/gen-mapping": "^0.1.0", | ||
"@babel/types": "^7.17.12", | ||
"@jridgewell/gen-mapping": "^0.3.0", | ||
"jsesc": "^2.5.1" | ||
@@ -29,3 +29,3 @@ }, | ||
"@babel/helper-fixtures": "^7.17.10", | ||
"@babel/parser": "^7.17.10", | ||
"@babel/parser": "^7.17.12", | ||
"@jridgewell/trace-mapping": "^0.3.8", | ||
@@ -32,0 +32,0 @@ "@types/jsesc": "^2.5.0", |
119604
4267
+ Added@jridgewell/gen-mapping@0.3.5(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
- Removed@jridgewell/gen-mapping@0.1.1(transitive)
Updated@babel/types@^7.17.12