@babel/traverse
Advanced tools
Comparing version 7.25.4 to 7.25.6
@@ -9,2 +9,3 @@ "use strict"; | ||
var _t = require("@babel/types"); | ||
var _context = require("./path/context.js"); | ||
const { | ||
@@ -80,5 +81,5 @@ VISITOR_KEYS | ||
visitIndex++; | ||
path.resync(); | ||
_context.resync.call(path); | ||
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) { | ||
path.pushContext(this); | ||
_context.pushContext.call(path, this); | ||
} | ||
@@ -103,3 +104,3 @@ if (path.key === null) continue; | ||
for (let i = 0; i < visitIndex; i++) { | ||
queue[i].popContext(); | ||
_context.popContext.call(queue[i]); | ||
} | ||
@@ -106,0 +107,0 @@ this.queue = null; |
@@ -13,3 +13,3 @@ "use strict"; | ||
exports.call = call; | ||
exports.isBlacklisted = exports.isDenylisted = isDenylisted; | ||
exports.isDenylisted = isDenylisted; | ||
exports.popContext = popContext; | ||
@@ -67,2 +67,5 @@ exports.pushContext = pushContext; | ||
} | ||
{ | ||
exports.isBlacklisted = isDenylisted; | ||
} | ||
function restoreContext(path, context) { | ||
@@ -87,3 +90,3 @@ if (path.context !== context) { | ||
const currentContext = this.context; | ||
if (this.shouldSkip || this.call("enter")) { | ||
if (this.shouldSkip || call.call(this, "enter")) { | ||
this.debug("Skip..."); | ||
@@ -96,3 +99,3 @@ return this.shouldStop; | ||
restoreContext(this, currentContext); | ||
this.call("exit"); | ||
call.call(this, "exit"); | ||
return this.shouldStop; | ||
@@ -139,3 +142,3 @@ } | ||
} | ||
this.setScope(); | ||
setScope.call(this); | ||
return this; | ||
@@ -162,3 +165,3 @@ } | ||
if (this.container[i] === this.node) { | ||
this.setKey(i); | ||
setKey.call(this, i); | ||
return; | ||
@@ -170,3 +173,3 @@ } | ||
if (this.container[key] === this.node) { | ||
this.setKey(key); | ||
setKey.call(this, key); | ||
return; | ||
@@ -205,3 +208,3 @@ } | ||
this.parentPath = parentPath || this.parentPath; | ||
this.setKey(key); | ||
setKey.call(this, key); | ||
} | ||
@@ -208,0 +211,0 @@ function setKey(key) { |
@@ -15,2 +15,3 @@ "use strict"; | ||
var _visitors = require("../visitors.js"); | ||
var _context = require("./context.js"); | ||
const { | ||
@@ -100,3 +101,3 @@ arrowFunctionExpression, | ||
const parentPath = this.get(stringPath); | ||
body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key); | ||
_context.setup.call(body, parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key); | ||
return this.node; | ||
@@ -103,0 +104,0 @@ } |
@@ -21,3 +21,4 @@ "use strict"; | ||
var NodePath_introspection = require("./introspection.js"); | ||
var NodePath_context = require("./context.js"); | ||
var _context = require("./context.js"); | ||
var NodePath_context = _context; | ||
var NodePath_removal = require("./removal.js"); | ||
@@ -93,3 +94,3 @@ var NodePath_modification = require("./modification.js"); | ||
} | ||
path.setup(parentPath, container, listKey, key); | ||
_context.setup.call(path, parentPath, container, listKey, key); | ||
return path; | ||
@@ -186,7 +187,3 @@ } | ||
matchesPattern: NodePath_introspection.matchesPattern, | ||
has: NodePath_introspection.has, | ||
isStatic: NodePath_introspection.isStatic, | ||
is: NodePath_introspection.is, | ||
isnt: NodePath_introspection.isnt, | ||
equals: NodePath_introspection.equals, | ||
isNodeType: NodePath_introspection.isNodeType, | ||
@@ -204,5 +201,3 @@ canHaveVariableDeclarationOrExpression: NodePath_introspection.canHaveVariableDeclarationOrExpression, | ||
isInStrictMode: NodePath_introspection.isInStrictMode, | ||
call: NodePath_context.call, | ||
isDenylisted: NodePath_context.isDenylisted, | ||
isBlacklisted: NodePath_context.isBlacklisted, | ||
visit: NodePath_context.visit, | ||
@@ -212,9 +207,3 @@ skip: NodePath_context.skip, | ||
stop: NodePath_context.stop, | ||
setScope: NodePath_context.setScope, | ||
setContext: NodePath_context.setContext, | ||
resync: NodePath_context.resync, | ||
popContext: NodePath_context.popContext, | ||
pushContext: NodePath_context.pushContext, | ||
setup: NodePath_context.setup, | ||
setKey: NodePath_context.setKey, | ||
requeue: NodePath_context.requeue, | ||
@@ -225,6 +214,4 @@ requeueComputedKeyAndDecorators: NodePath_context.requeueComputedKeyAndDecorators, | ||
insertAfter: NodePath_modification.insertAfter, | ||
updateSiblingKeys: NodePath_modification.updateSiblingKeys, | ||
unshiftContainer: NodePath_modification.unshiftContainer, | ||
pushContainer: NodePath_modification.pushContainer, | ||
hoist: NodePath_modification.hoist, | ||
getOpposite: NodePath_family.getOpposite, | ||
@@ -250,7 +237,21 @@ getCompletionRecords: NodePath_family.getCompletionRecords, | ||
NodePath_Final.prototype.arrowFunctionToShadowed = NodePath_conversion[String("arrowFunctionToShadowed")]; | ||
Object.assign(NodePath_Final.prototype, { | ||
has: NodePath_introspection[String("has")], | ||
is: NodePath_introspection[String("is")], | ||
isnt: NodePath_introspection[String("isnt")], | ||
equals: NodePath_introspection[String("equals")], | ||
hoist: NodePath_modification[String("hoist")], | ||
updateSiblingKeys: NodePath_modification.updateSiblingKeys, | ||
call: NodePath_context.call, | ||
isBlacklisted: NodePath_context[String("isBlacklisted")], | ||
setScope: NodePath_context.setScope, | ||
resync: NodePath_context.resync, | ||
popContext: NodePath_context.popContext, | ||
pushContext: NodePath_context.pushContext, | ||
setup: NodePath_context.setup, | ||
setKey: NodePath_context.setKey | ||
}); | ||
} | ||
{ | ||
NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo; | ||
} | ||
{ | ||
NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo; | ||
@@ -257,0 +258,0 @@ Object.assign(NodePath_Final.prototype, { |
@@ -10,6 +10,3 @@ "use strict"; | ||
exports.canSwapBetweenExpressionAndStatement = canSwapBetweenExpressionAndStatement; | ||
exports.equals = equals; | ||
exports.getSource = getSource; | ||
exports.has = has; | ||
exports.is = void 0; | ||
exports.isCompletionRecord = isCompletionRecord; | ||
@@ -21,3 +18,2 @@ exports.isConstantExpression = isConstantExpression; | ||
exports.isStatic = isStatic; | ||
exports.isnt = isnt; | ||
exports.matchesPattern = matchesPattern; | ||
@@ -42,10 +38,12 @@ exports.referencesImport = referencesImport; | ||
} | ||
function has(key) { | ||
var _this$node; | ||
const val = (_this$node = this.node) == null ? void 0 : _this$node[key]; | ||
if (val && Array.isArray(val)) { | ||
return !!val.length; | ||
} else { | ||
return !!val; | ||
} | ||
{ | ||
exports.has = function has(key) { | ||
var _this$node; | ||
const val = (_this$node = this.node) == null ? void 0 : _this$node[key]; | ||
if (val && Array.isArray(val)) { | ||
return !!val.length; | ||
} else { | ||
return !!val; | ||
} | ||
}; | ||
} | ||
@@ -55,9 +53,11 @@ function isStatic() { | ||
} | ||
const is = exports.is = has; | ||
function isnt(key) { | ||
return !this.has(key); | ||
{ | ||
exports.is = exports.has; | ||
exports.isnt = function isnt(key) { | ||
return !this.has(key); | ||
}; | ||
exports.equals = function equals(key, value) { | ||
return this.node[key] === value; | ||
}; | ||
} | ||
function equals(key, value) { | ||
return this.node[key] === value; | ||
} | ||
function isNodeType(type) { | ||
@@ -64,0 +64,0 @@ return isType(this.type, type); |
@@ -10,3 +10,2 @@ "use strict"; | ||
exports._verifyNodeList = _verifyNodeList; | ||
exports.hoist = hoist; | ||
exports.insertAfter = insertAfter; | ||
@@ -64,3 +63,3 @@ exports.insertBefore = insertBefore; | ||
function _containerInsert(from, nodes) { | ||
this.updateSiblingKeys(from, nodes.length); | ||
updateSiblingKeys.call(this, from, nodes.length); | ||
const paths = []; | ||
@@ -74,3 +73,3 @@ this.container.splice(from, 0, ...nodes); | ||
if ((_this$context = this.context) != null && _this$context.queue) { | ||
path.pushContext(this.context); | ||
_context.pushContext.call(path, this.context); | ||
} | ||
@@ -80,3 +79,3 @@ } | ||
for (const path of paths) { | ||
path.setScope(); | ||
_context.setScope.call(path); | ||
path.debug("Inserted."); | ||
@@ -227,7 +226,9 @@ for (const context of contexts) { | ||
} | ||
function hoist(scope = this.scope) { | ||
const hoister = new _hoister.default(this, scope); | ||
return hoister.run(); | ||
{ | ||
exports.hoist = function hoist(scope = this.scope) { | ||
const hoister = new _hoister.default(this, scope); | ||
return hoister.run(); | ||
}; | ||
} | ||
//# sourceMappingURL=modification.js.map |
@@ -17,2 +17,4 @@ "use strict"; | ||
var _t = require("@babel/types"); | ||
var _modification = require("./modification.js"); | ||
var _context = require("./context.js"); | ||
const { | ||
@@ -24,3 +26,3 @@ getBindingIdentifiers | ||
_assertUnremoved.call(this); | ||
this.resync(); | ||
_context.resync.call(this); | ||
if (_callRemovalHooks.call(this)) { | ||
@@ -51,3 +53,3 @@ _markRemoved.call(this); | ||
this.container.splice(this.key, 1); | ||
this.updateSiblingKeys(this.key, -1); | ||
_modification.updateSiblingKeys.call(this, this.key, -1); | ||
} else { | ||
@@ -54,0 +56,0 @@ _replacement._replaceWith.call(this, null); |
@@ -19,2 +19,3 @@ "use strict"; | ||
var _t = require("@babel/types"); | ||
var _context = require("./context.js"); | ||
const { | ||
@@ -52,3 +53,3 @@ FUNCTION_TYPES, | ||
var _getCachedPaths; | ||
this.resync(); | ||
_context.resync.call(this); | ||
nodes = _modification._verifyNodeList.call(this, nodes); | ||
@@ -68,3 +69,3 @@ inheritLeadingComments(nodes[0], this.node); | ||
function replaceWithSourceString(replacement) { | ||
this.resync(); | ||
_context.resync.call(this); | ||
let ast; | ||
@@ -92,3 +93,3 @@ try { | ||
function replaceWith(replacementPath) { | ||
this.resync(); | ||
_context.resync.call(this); | ||
if (this.removed) { | ||
@@ -132,3 +133,3 @@ throw new Error("You can't replace this node, we've already removed it"); | ||
this.type = replacement.type; | ||
this.setScope(); | ||
_context.setScope.call(this); | ||
this.requeue(); | ||
@@ -152,3 +153,3 @@ return [nodePath ? this.get(nodePath) : this]; | ||
function replaceExpressionWithStatements(nodes) { | ||
this.resync(); | ||
_context.resync.call(this); | ||
const declars = []; | ||
@@ -163,4 +164,4 @@ const nodesAsSingleExpression = gatherSequenceExpressions(nodes, declars); | ||
const functionParent = this.getFunctionParent(); | ||
const isParentAsync = functionParent == null ? void 0 : functionParent.is("async"); | ||
const isParentGenerator = functionParent == null ? void 0 : functionParent.is("generator"); | ||
const isParentAsync = functionParent == null ? void 0 : functionParent.node.async; | ||
const isParentGenerator = functionParent == null ? void 0 : functionParent.node.generator; | ||
const container = arrowFunctionExpression([], blockStatement(nodes)); | ||
@@ -254,3 +255,3 @@ this.replaceWith(callExpression(container, [])); | ||
function replaceInline(nodes) { | ||
this.resync(); | ||
_context.resync.call(this); | ||
if (Array.isArray(nodes)) { | ||
@@ -257,0 +258,0 @@ if (Array.isArray(this.container)) { |
@@ -274,3 +274,3 @@ "use strict"; | ||
} | ||
if (path.isFunctionExpression() && path.has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) { | ||
if (path.isFunctionExpression() && path.node.id && !path.node.id[NOT_LOCAL_BINDING]) { | ||
path.scope.registerBinding("local", path.get("id"), path); | ||
@@ -280,3 +280,3 @@ } | ||
ClassExpression(path) { | ||
if (path.has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) { | ||
if (path.node.id && !path.node.id[NOT_LOCAL_BINDING]) { | ||
path.scope.registerBinding("local", path.get("id"), path); | ||
@@ -283,0 +283,0 @@ } |
@@ -8,5 +8,9 @@ "use strict"; | ||
var t = require("@babel/types"); | ||
var _t = t; | ||
var _traverseNode = require("../../traverse-node.js"); | ||
var _visitors = require("../../visitors.js"); | ||
var _context = require("../../path/context.js"); | ||
const { | ||
getAssignmentIdentifiers | ||
} = _t; | ||
const renameVisitor = { | ||
@@ -49,3 +53,3 @@ ReferencedIdentifier({ | ||
if (path.isVariableDeclaration()) return; | ||
const ids = path.isAssignmentExpression() ? path.getAssignmentIdentifiers() : path.getOuterBindingIdentifiers(); | ||
const ids = path.isAssignmentExpression() ? getAssignmentIdentifiers(path.node) : path.getOuterBindingIdentifiers(); | ||
for (const name in ids) { | ||
@@ -52,0 +56,0 @@ if (name === state.oldName) ids[name].name = state.newName; |
@@ -107,3 +107,3 @@ "use strict"; | ||
if (!TYPES.includes(nodeType)) { | ||
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.25.4"}`); | ||
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.25.6"}`); | ||
} | ||
@@ -110,0 +110,0 @@ const visitors = visitor[nodeType]; |
{ | ||
"name": "@babel/traverse", | ||
"version": "7.25.4", | ||
"version": "7.25.6", | ||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", | ||
@@ -20,6 +20,6 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"@babel/code-frame": "^7.24.7", | ||
"@babel/generator": "^7.25.4", | ||
"@babel/parser": "^7.25.4", | ||
"@babel/generator": "^7.25.6", | ||
"@babel/parser": "^7.25.6", | ||
"@babel/template": "^7.25.0", | ||
"@babel/types": "^7.25.4", | ||
"@babel/types": "^7.25.6", | ||
"debug": "^4.3.1", | ||
@@ -26,0 +26,0 @@ "globals": "^11.1.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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
730693
5631
Updated@babel/generator@^7.25.6
Updated@babel/parser@^7.25.6
Updated@babel/types@^7.25.6