diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-08-30 17:21:18 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-08-30 17:21:18 +0800 |
| commit | efbc2ffe6a1ee5ec38a4396305561d6515d0943e (patch) | |
| tree | 2b4c94f18f2c792dfda813050755d5c0273fae22 /node_modules/@babel/traverse/lib/visitors.js | |
| parent | 43acceb75957c880a5ba5a31aae221394a36d5f6 (diff) | |
node fixes, updates
Diffstat (limited to 'node_modules/@babel/traverse/lib/visitors.js')
| -rw-r--r-- | node_modules/@babel/traverse/lib/visitors.js | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/node_modules/@babel/traverse/lib/visitors.js b/node_modules/@babel/traverse/lib/visitors.js index cb06c80c..ee7058e0 100644 --- a/node_modules/@babel/traverse/lib/visitors.js +++ b/node_modules/@babel/traverse/lib/visitors.js @@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.explode = explode; +exports.environmentVisitor = environmentVisitor; +exports.explode = explode$1; exports.isExplodedVisitor = isExplodedVisitor; exports.merge = merge; -exports.verify = verify; +exports.verify = verify$1; var virtualTypes = require("./path/lib/virtual-types.js"); var virtualTypesValidators = require("./path/lib/virtual-types-validator.js"); var _t = require("@babel/types"); +var _context = require("./path/context.js"); const { DEPRECATED_KEYS, DEPRECATED_ALIASES, @@ -23,7 +25,7 @@ function isVirtualType(type) { function isExplodedVisitor(visitor) { return visitor == null ? void 0 : visitor._exploded; } -function explode(visitor) { +function explode$1(visitor) { if (isExplodedVisitor(visitor)) return visitor; visitor._exploded = true; for (const nodeType of Object.keys(visitor)) { @@ -36,7 +38,7 @@ function explode(visitor) { visitor[part] = fns; } } - verify(visitor); + verify$1(visitor); delete visitor.__esModule; ensureEntranceObjects(visitor); ensureCallbackArrays(visitor); @@ -91,7 +93,7 @@ function explode(visitor) { } return visitor; } -function verify(visitor) { +function verify$1(visitor) { if (visitor._verified) return; if (typeof visitor === "function") { throw new Error("You passed `traverse()` a function when it expected a visitor object, " + "are you sure you didn't mean `{ enter: Function }`?"); @@ -101,8 +103,8 @@ function verify(visitor) { validateVisitorMethods(nodeType, visitor[nodeType]); } if (shouldIgnoreKey(nodeType)) continue; - if (TYPES.indexOf(nodeType) < 0) { - throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`); + 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.6"}`); } const visitors = visitor[nodeType]; if (typeof visitors === "object") { @@ -126,9 +128,20 @@ function validateVisitorMethods(path, val) { } } function merge(visitors, states = [], wrapper) { - const mergedVisitor = {}; + const mergedVisitor = { + _verified: true, + _exploded: true + }; + { + Object.defineProperty(mergedVisitor, "_exploded", { + enumerable: false + }); + Object.defineProperty(mergedVisitor, "_verified", { + enumerable: false + }); + } for (let i = 0; i < visitors.length; i++) { - const visitor = explode(visitors[i]); + const visitor = explode$1(visitors[i]); const state = states[i]; let topVisitor = visitor; if (state || wrapper) { @@ -145,7 +158,6 @@ function merge(visitors, states = [], wrapper) { mergePair(nodeVisitor, typeVisitor); } } - ; return mergedVisitor; } function wrapWithStateOrWrapper(oldVisitor, state, wrapper) { @@ -217,5 +229,30 @@ function mergePair(dest, src) { dest[phase] = [].concat(dest[phase] || [], src[phase]); } } +const _environmentVisitor = { + FunctionParent(path) { + if (path.isArrowFunctionExpression()) return; + path.skip(); + if (path.isMethod()) { + if (!path.requeueComputedKeyAndDecorators) { + _context.requeueComputedKeyAndDecorators.call(path); + } else { + path.requeueComputedKeyAndDecorators(); + } + } + }, + Property(path) { + if (path.isObjectProperty()) return; + path.skip(); + if (!path.requeueComputedKeyAndDecorators) { + _context.requeueComputedKeyAndDecorators.call(path); + } else { + path.requeueComputedKeyAndDecorators(); + } + } +}; +function environmentVisitor(visitor) { + return merge([_environmentVisitor, visitor]); +} //# sourceMappingURL=visitors.js.map |
