@babel/traverse
Advanced tools
Comparing version 7.22.8 to 7.22.10
@@ -9,5 +9,7 @@ "use strict"; | ||
exports.clearScope = clearScope; | ||
exports.getCachedPaths = getCachedPaths; | ||
exports.getOrCreateCachedPaths = getOrCreateCachedPaths; | ||
exports.scope = exports.path = void 0; | ||
let path = new WeakMap(); | ||
exports.path = path; | ||
let pathsCache = new WeakMap(); | ||
exports.path = pathsCache; | ||
let scope = new WeakMap(); | ||
@@ -20,3 +22,3 @@ exports.scope = scope; | ||
function clearPath() { | ||
exports.path = path = new WeakMap(); | ||
exports.path = pathsCache = new WeakMap(); | ||
} | ||
@@ -26,3 +28,22 @@ function clearScope() { | ||
} | ||
const nullHub = Object.freeze({}); | ||
function getCachedPaths(hub, parent) { | ||
var _pathsCache$get, _hub; | ||
{ | ||
hub = null; | ||
} | ||
return (_pathsCache$get = pathsCache.get((_hub = hub) != null ? _hub : nullHub)) == null ? void 0 : _pathsCache$get.get(parent); | ||
} | ||
function getOrCreateCachedPaths(hub, parent) { | ||
var _hub2, _hub3; | ||
{ | ||
hub = null; | ||
} | ||
let parents = pathsCache.get((_hub2 = hub) != null ? _hub2 : nullHub); | ||
if (!parents) pathsCache.set((_hub3 = hub) != null ? _hub3 : nullHub, parents = new WeakMap()); | ||
let paths = parents.get(parent); | ||
if (!paths) parents.set(parent, paths = new Map()); | ||
return paths; | ||
} | ||
//# sourceMappingURL=cache.js.map |
@@ -38,3 +38,3 @@ "use strict"; | ||
} = _t; | ||
function traverse(parent, opts = {}, scope, state, parentPath) { | ||
function traverse(parent, opts = {}, scope, state, parentPath, visitSelf) { | ||
if (!parent) return; | ||
@@ -46,2 +46,5 @@ if (!opts.noScope && !scope) { | ||
} | ||
if (!parentPath && visitSelf) { | ||
throw new Error("visitSelf can only be used when providing a NodePath."); | ||
} | ||
if (!VISITOR_KEYS[parent.type]) { | ||
@@ -51,3 +54,3 @@ return; | ||
visitors.explode(opts); | ||
(0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath); | ||
(0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath, null, visitSelf); | ||
} | ||
@@ -68,3 +71,2 @@ var _default = traverse; | ||
removeProperties(node, opts); | ||
cache.path.delete(node); | ||
}; | ||
@@ -71,0 +73,0 @@ traverse.removeProperties = function (tree, opts) { |
@@ -110,6 +110,3 @@ "use strict"; | ||
allowInsertArrowWithRest = allowInsertArrow, | ||
noNewArrows = !(() => { | ||
var _arguments$; | ||
return (_arguments$ = arguments[0]) == null ? void 0 : _arguments$.specCompliant; | ||
})() | ||
noNewArrows = !(_arguments$ => (_arguments$ = arguments[0]) == null ? void 0 : _arguments$.specCompliant)() | ||
} = {}) { | ||
@@ -116,0 +113,0 @@ if (!this.isArrowFunctionExpression()) { |
@@ -13,3 +13,3 @@ "use strict"; | ||
var t = _t; | ||
var _cache = require("../cache"); | ||
var cache = require("../cache"); | ||
var _generator = require("@babel/generator"); | ||
@@ -72,7 +72,3 @@ var NodePath_ancestry = require("./ancestry"); | ||
const targetNode = container[key]; | ||
let paths = _cache.path.get(parent); | ||
if (!paths) { | ||
paths = new Map(); | ||
_cache.path.set(parent, paths); | ||
} | ||
const paths = cache.getOrCreateCachedPaths(hub, parent); | ||
let path = paths.get(targetNode); | ||
@@ -79,0 +75,0 @@ if (!path) { |
@@ -8,3 +8,2 @@ "use strict"; | ||
exports.isBlockScoped = isBlockScoped; | ||
exports.isExistentialTypeParam = isExistentialTypeParam; | ||
exports.isExpression = isExpression; | ||
@@ -14,3 +13,2 @@ exports.isFlow = isFlow; | ||
exports.isGenerated = isGenerated; | ||
exports.isNumericLiteralTypeAnnotation = isNumericLiteralTypeAnnotation; | ||
exports.isPure = isPure; | ||
@@ -156,9 +154,13 @@ exports.isReferenced = isReferenced; | ||
} | ||
function isExistentialTypeParam() { | ||
throw new Error("`path.isExistentialTypeParam` has been renamed to `path.isExistsTypeAnnotation()` in Babel 7."); | ||
{ | ||
{ | ||
exports.isExistentialTypeParam = function isExistentialTypeParam() { | ||
throw new Error("`path.isExistentialTypeParam` has been renamed to `path.isExistsTypeAnnotation()` in Babel 7."); | ||
}; | ||
exports.isNumericLiteralTypeAnnotation = function isNumericLiteralTypeAnnotation() { | ||
throw new Error("`path.isNumericLiteralTypeAnnotation()` has been renamed to `path.isNumberLiteralTypeAnnotation()` in Babel 7."); | ||
}; | ||
} | ||
} | ||
function isNumericLiteralTypeAnnotation() { | ||
throw new Error("`path.isNumericLiteralTypeAnnotation()` has been renamed to `path.isNumberLiteralTypeAnnotation()` in Babel 7."); | ||
} | ||
//# sourceMappingURL=virtual-types-validator.js.map |
@@ -65,6 +65,7 @@ "use strict"; | ||
for (let i = 0; i < nodes.length; i++) { | ||
var _this$context; | ||
const to = from + i; | ||
const path = this.getSibling(to); | ||
paths.push(path); | ||
if (this.context && this.context.queue) { | ||
if ((_this$context = this.context) != null && _this$context.queue) { | ||
path.pushContext(this.context); | ||
@@ -162,3 +163,3 @@ } | ||
if (!this.parent) return; | ||
const paths = _cache.path.get(this.parent); | ||
const paths = (0, _cache.getCachedPaths)(this.hub, this.parent) || []; | ||
for (const [, path] of paths) { | ||
@@ -165,0 +166,0 @@ if (typeof path.key === "number" && path.key >= fromIndex) { |
@@ -49,3 +49,5 @@ "use strict"; | ||
this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED; | ||
if (this.parent) _cache.path.get(this.parent).delete(this.node); | ||
if (this.parent) { | ||
(0, _cache.getCachedPaths)(this.hub, this.parent).delete(this.node); | ||
} | ||
this.node = null; | ||
@@ -52,0 +54,0 @@ } |
@@ -42,3 +42,3 @@ "use strict"; | ||
function replaceWithMultiple(nodes) { | ||
var _pathCache$get; | ||
var _getCachedPaths; | ||
this.resync(); | ||
@@ -48,3 +48,3 @@ nodes = this._verifyNodeList(nodes); | ||
inheritTrailingComments(nodes[nodes.length - 1], this.node); | ||
(_pathCache$get = _cache.path.get(this.parent)) == null ? void 0 : _pathCache$get.delete(this.node); | ||
(_getCachedPaths = (0, _cache.getCachedPaths)(this.hub, this.parent)) == null ? void 0 : _getCachedPaths.delete(this.node); | ||
this.node = this.container[this.key] = null; | ||
@@ -127,3 +127,3 @@ const paths = this.insertAfter(nodes); | ||
function _replaceWith(node) { | ||
var _pathCache$get2; | ||
var _getCachedPaths2; | ||
if (!this.container) { | ||
@@ -138,3 +138,3 @@ throw new ReferenceError("Container is falsy"); | ||
this.debug(`Replace with ${node == null ? void 0 : node.type}`); | ||
(_pathCache$get2 = _cache.path.get(this.parent)) == null ? void 0 : _pathCache$get2.set(node, this).delete(this.node); | ||
(_getCachedPaths2 = (0, _cache.getCachedPaths)(this.hub, this.parent)) == null ? void 0 : _getCachedPaths2.set(node, this).delete(this.node); | ||
this.node = this.container[this.key] = node; | ||
@@ -141,0 +141,0 @@ } |
@@ -65,5 +65,6 @@ "use strict"; | ||
if (isImportDeclaration(node) || isExportDeclaration(node)) { | ||
var _node$specifiers; | ||
if ((isExportAllDeclaration(node) || isExportNamedDeclaration(node) || isImportDeclaration(node)) && node.source) { | ||
gatherNodeParts(node.source, parts); | ||
} else if ((isExportNamedDeclaration(node) || isImportDeclaration(node)) && node.specifiers && node.specifiers.length) { | ||
} else if ((isExportNamedDeclaration(node) || isImportDeclaration(node)) && (_node$specifiers = node.specifiers) != null && _node$specifiers.length) { | ||
for (const e of node.specifiers) gatherNodeParts(e, parts); | ||
@@ -70,0 +71,0 @@ } else if ((isExportDefaultDeclaration(node) || isExportNamedDeclaration(node)) && node.declaration) { |
@@ -12,8 +12,12 @@ "use strict"; | ||
} = _t; | ||
function traverseNode(node, opts, scope, state, path, skipKeys) { | ||
function traverseNode(node, opts, scope, state, path, skipKeys, visitSelf) { | ||
const keys = VISITOR_KEYS[node.type]; | ||
if (!keys) return false; | ||
const context = new _context.default(scope, opts, state, path); | ||
if (visitSelf) { | ||
if (skipKeys != null && skipKeys[path.parentKey]) return false; | ||
return context.visitQueue([path]); | ||
} | ||
for (const key of keys) { | ||
if (skipKeys && skipKeys[key]) continue; | ||
if (skipKeys != null && skipKeys[key]) continue; | ||
if (context.visit(node, key)) { | ||
@@ -20,0 +24,0 @@ return true; |
{ | ||
"name": "@babel/traverse", | ||
"version": "7.22.8", | ||
"version": "7.22.10", | ||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", | ||
@@ -19,4 +19,4 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"dependencies": { | ||
"@babel/code-frame": "^7.22.5", | ||
"@babel/generator": "^7.22.7", | ||
"@babel/code-frame": "^7.22.10", | ||
"@babel/generator": "^7.22.10", | ||
"@babel/helper-environment-visitor": "^7.22.5", | ||
@@ -26,4 +26,4 @@ "@babel/helper-function-name": "^7.22.5", | ||
"@babel/helper-split-export-declaration": "^7.22.6", | ||
"@babel/parser": "^7.22.7", | ||
"@babel/types": "^7.22.5", | ||
"@babel/parser": "^7.22.10", | ||
"@babel/types": "^7.22.10", | ||
"debug": "^4.1.0", | ||
@@ -33,2 +33,3 @@ "globals": "^11.1.0" | ||
"devDependencies": { | ||
"@babel/core": "^7.22.10", | ||
"@babel/helper-plugin-test-runner": "^7.22.5" | ||
@@ -35,0 +36,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
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
602271
5141
2
Updated@babel/code-frame@^7.22.10
Updated@babel/generator@^7.22.10
Updated@babel/parser@^7.22.10
Updated@babel/types@^7.22.10