@babel/traverse 8.0.0-alpha.7 → 8.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -63,7 +63,7 @@ const {
63
63
  isImportSpecifier,
64
64
  isJSXIdentifier,
65
65
  isJSXMemberExpression,
66
- isMemberExpression,
66
+ isMemberExpression: isMemberExpression$1,
67
67
  isRestElement: nodeIsRestElement,
68
68
  isReferenced: nodeIsReferenced,
69
69
  isScope: nodeIsScope,
@@ -95,7 +95,7 @@ function isReferencedMemberExpression() {
95
95
  node,
96
96
  parent
97
97
  } = this;
98
- return isMemberExpression(node) && nodeIsReferenced(node, parent);
98
+ return isMemberExpression$1(node) && nodeIsReferenced(node, parent);
99
99
  }
100
100
  function isBindingIdentifier() {
101
101
  const {
@@ -169,10 +169,10 @@ function isFlow() {
169
169
  }
170
170
  }
171
171
  function isRestProperty() {
172
- return nodeIsRestElement(this.node) && this.parentPath && this.parentPath.isObjectPattern();
172
+ return nodeIsRestElement(this.node) && this.parentPath?.isObjectPattern();
173
173
  }
174
174
  function isSpreadProperty() {
175
- return nodeIsRestElement(this.node) && this.parentPath && this.parentPath.isObjectExpression();
175
+ return nodeIsRestElement(this.node) && this.parentPath?.isObjectExpression();
176
176
  }
177
177
  function isForAwaitStatement() {
178
178
  return isForOfStatement(this.node, {
@@ -213,7 +213,7 @@ function isVirtualType(type) {
213
213
  function isExplodedVisitor(visitor) {
214
214
  return visitor?._exploded;
215
215
  }
216
- function explode(visitor) {
216
+ function explode$1(visitor) {
217
217
  if (isExplodedVisitor(visitor)) return visitor;
218
218
  visitor._exploded = true;
219
219
  for (const nodeType of Object.keys(visitor)) {
@@ -226,7 +226,7 @@ function explode(visitor) {
226
226
  visitor[part] = fns;
227
227
  }
228
228
  }
229
- verify(visitor);
229
+ verify$1(visitor);
230
230
  delete visitor.__esModule;
231
231
  ensureEntranceObjects(visitor);
232
232
  ensureCallbackArrays(visitor);
@@ -281,7 +281,7 @@ function explode(visitor) {
281
281
  }
282
282
  return visitor;
283
283
  }
284
- function verify(visitor) {
284
+ function verify$1(visitor) {
285
285
  if (visitor._verified) return;
286
286
  if (typeof visitor === "function") {
287
287
  throw new Error("You passed `traverse()` a function when it expected a visitor object, " + "are you sure you didn't mean `{ enter: Function }`?");
@@ -318,7 +318,7 @@ function validateVisitorMethods(path, val) {
318
318
  function merge(visitors, states = [], wrapper) {
319
319
  const mergedVisitor = {};
320
320
  for (let i = 0; i < visitors.length; i++) {
321
- const visitor = explode(visitors[i]);
321
+ const visitor = explode$1(visitors[i]);
322
322
  const state = states[i];
323
323
  let topVisitor = visitor;
324
324
  if (state || wrapper) {
@@ -409,10 +409,10 @@ function mergePair(dest, src) {
409
409
 
410
410
  var visitors = /*#__PURE__*/Object.freeze({
411
411
  __proto__: null,
412
- explode: explode,
412
+ explode: explode$1,
413
413
  isExplodedVisitor: isExplodedVisitor,
414
414
  merge: merge,
415
- verify: verify
415
+ verify: verify$1
416
416
  });
417
417
 
418
418
  let pathsCache = new WeakMap();
@@ -475,7 +475,6 @@ const renameVisitor = {
475
475
  } = node.key;
476
476
  if (node.shorthand && (name === state.oldName || name === state.newName) && scope.getBindingIdentifier(name) === state.binding.identifier) {
477
477
  node.shorthand = false;
478
- if (node.extra?.shorthand) node.extra.shorthand = false;
479
478
  }
480
479
  },
481
480
  "AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
@@ -534,7 +533,7 @@ class Renamer {
534
533
  }
535
534
  }
536
535
  const blockToTraverse = scope.block;
537
- traverseNode(blockToTraverse, explode(renameVisitor), scope, this, scope.path, {
536
+ traverseNode(blockToTraverse, explode$1(renameVisitor), scope, this, scope.path, {
538
537
  discriminant: true
539
538
  });
540
539
  {
@@ -632,6 +631,7 @@ const {
632
631
  identifier: identifier$3,
633
632
  isArrayExpression,
634
633
  isBinary,
634
+ isCallExpression: isCallExpression$1,
635
635
  isClass,
636
636
  isClassBody,
637
637
  isClassDeclaration,
@@ -642,6 +642,7 @@ const {
642
642
  isIdentifier: isIdentifier$5,
643
643
  isImportDeclaration,
644
644
  isLiteral: isLiteral$1,
645
+ isMemberExpression,
645
646
  isMethod,
646
647
  isModuleSpecifier,
647
648
  isNullLiteral,
@@ -885,6 +886,9 @@ const collectorVisitor = {
885
886
  if (path.has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) {
886
887
  path.scope.registerBinding("local", path);
887
888
  }
889
+ },
890
+ TSTypeAnnotation(path) {
891
+ path.skip();
888
892
  }
889
893
  };
890
894
  let uid = 0;
@@ -924,7 +928,7 @@ class Scope {
924
928
  const shouldSkip = path.key === "key" || path.listKey === "decorators";
925
929
  path = path.parentPath;
926
930
  if (shouldSkip && path.isMethod()) path = path.parentPath;
927
- if (path && path.isScope()) parent = path;
931
+ if (path?.isScope()) parent = path;
928
932
  } while (path && !parent);
929
933
  return parent?.scope;
930
934
  }
@@ -1230,13 +1234,23 @@ class Scope {
1230
1234
  return true;
1231
1235
  } else if (isUnaryExpression(node)) {
1232
1236
  return this.isPure(node.argument, constantsOnly);
1233
- } else if (isTaggedTemplateExpression(node)) {
1234
- return matchesPattern$1(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly);
1235
1237
  } else if (isTemplateLiteral(node)) {
1236
1238
  for (const expression of node.expressions) {
1237
1239
  if (!this.isPure(expression, constantsOnly)) return false;
1238
1240
  }
1239
1241
  return true;
1242
+ } else if (isTaggedTemplateExpression(node)) {
1243
+ return matchesPattern$1(node.tag, "String.raw") && !this.hasBinding("String", {
1244
+ noGlobals: true
1245
+ }) && this.isPure(node.quasi, constantsOnly);
1246
+ } else if (isMemberExpression(node)) {
1247
+ return !node.computed && isIdentifier$5(node.object) && node.object.name === "Symbol" && isIdentifier$5(node.property) && node.property.name !== "for" && !this.hasBinding("Symbol", {
1248
+ noGlobals: true
1249
+ });
1250
+ } else if (isCallExpression$1(node)) {
1251
+ return matchesPattern$1(node.callee, "Symbol.for") && !this.hasBinding("Symbol", {
1252
+ noGlobals: true
1253
+ }) && node.arguments.length === 1 && _t.isStringLiteral(node.arguments[0]);
1240
1254
  } else {
1241
1255
  return isPureish(node);
1242
1256
  }
@@ -1328,9 +1342,9 @@ class Scope {
1328
1342
  kind = "var",
1329
1343
  id
1330
1344
  } = opts;
1331
- if (!init && !unique && (kind === "var" || kind === "let") && path.isFunction() && !path.node.name && _t.isCallExpression(path.parent, {
1345
+ if (!init && !unique && (kind === "var" || kind === "let") && path.isFunction() && !path.node.name && isCallExpression$1(path.parent, {
1332
1346
  callee: path.node
1333
- }) && path.parent.arguments.length <= path.node.params.length && _t.isIdentifier(id)) {
1347
+ }) && path.parent.arguments.length <= path.node.params.length && isIdentifier$5(id)) {
1334
1348
  path.pushContainer("params", id);
1335
1349
  path.scope.registerBinding("param", path.get("params")[path.node.params.length - 1]);
1336
1350
  return;
@@ -1609,20 +1623,6 @@ function inType(...candidateTypes) {
1609
1623
  return false;
1610
1624
  }
1611
1625
 
1612
- var NodePath_ancestry = /*#__PURE__*/Object.freeze({
1613
- __proto__: null,
1614
- find: find,
1615
- findParent: findParent,
1616
- getAncestry: getAncestry,
1617
- getDeepestCommonAncestorFrom: getDeepestCommonAncestorFrom,
1618
- getEarliestCommonAncestorFrom: getEarliestCommonAncestorFrom,
1619
- getFunctionParent: getFunctionParent,
1620
- getStatementParent: getStatementParent,
1621
- inType: inType,
1622
- isAncestor: isAncestor,
1623
- isDescendant: isDescendant
1624
- });
1625
-
1626
1626
  const {
1627
1627
  createFlowUnionType,
1628
1628
  createTSUnionType,
@@ -2118,16 +2118,6 @@ function isGenericType(genericName) {
2118
2118
  });
2119
2119
  }
2120
2120
 
2121
- var NodePath_inference = /*#__PURE__*/Object.freeze({
2122
- __proto__: null,
2123
- _getTypeAnnotation: _getTypeAnnotation,
2124
- baseTypeStrictlyMatches: baseTypeStrictlyMatches,
2125
- couldBeBaseType: couldBeBaseType,
2126
- getTypeAnnotation: getTypeAnnotation,
2127
- isBaseType: isBaseType,
2128
- isGenericType: isGenericType
2129
- });
2130
-
2131
2121
  const {
2132
2122
  FUNCTION_TYPES,
2133
2123
  arrowFunctionExpression: arrowFunctionExpression$2,
@@ -2201,7 +2191,7 @@ function replaceWith(replacementPath) {
2201
2191
  if (this.removed) {
2202
2192
  throw new Error("You can't replace this node, we've already removed it");
2203
2193
  }
2204
- let replacement = replacementPath instanceof NodePath ? replacementPath.node : replacementPath;
2194
+ let replacement = replacementPath instanceof NodePath_Final ? replacementPath.node : replacementPath;
2205
2195
  if (!replacement) {
2206
2196
  throw new Error("You passed `path.replaceWith()` a falsy node, use `path.remove()` instead");
2207
2197
  }
@@ -2371,16 +2361,6 @@ function replaceInline(nodes) {
2371
2361
  }
2372
2362
  }
2373
2363
 
2374
- var NodePath_replacement = /*#__PURE__*/Object.freeze({
2375
- __proto__: null,
2376
- _replaceWith: _replaceWith,
2377
- replaceExpressionWithStatements: replaceExpressionWithStatements,
2378
- replaceInline: replaceInline,
2379
- replaceWith: replaceWith,
2380
- replaceWithMultiple: replaceWithMultiple,
2381
- replaceWithSourceString: replaceWithSourceString
2382
- });
2383
-
2384
2364
  const VALID_OBJECT_CALLEES = ["Number", "String", "Math"];
2385
2365
  const VALID_IDENTIFIER_CALLEES = ["isFinite", "isNaN", "parseFloat", "parseInt", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "btoa", "atob"];
2386
2366
  const INVALID_METHODS = ["random"];
@@ -2720,12 +2700,6 @@ function evaluate() {
2720
2700
  };
2721
2701
  }
2722
2702
 
2723
- var NodePath_evaluation = /*#__PURE__*/Object.freeze({
2724
- __proto__: null,
2725
- evaluate: evaluate,
2726
- evaluateTruthy: evaluateTruthy
2727
- });
2728
-
2729
2703
  const {
2730
2704
  arrowFunctionExpression: arrowFunctionExpression$1,
2731
2705
  assignmentExpression: assignmentExpression$1,
@@ -3173,14 +3147,6 @@ function getScopeInformation(fnPath) {
3173
3147
  };
3174
3148
  }
3175
3149
 
3176
- var NodePath_conversion = /*#__PURE__*/Object.freeze({
3177
- __proto__: null,
3178
- arrowFunctionToExpression: arrowFunctionToExpression,
3179
- ensureBlock: ensureBlock,
3180
- toComputedKey: toComputedKey,
3181
- unwrapFunctionEnvironment: unwrapFunctionEnvironment
3182
- });
3183
-
3184
3150
  const {
3185
3151
  STATEMENT_OR_BLOCK_KEYS,
3186
3152
  VISITOR_KEYS: VISITOR_KEYS$3,
@@ -3196,7 +3162,7 @@ function matchesPattern(pattern, allowPartial) {
3196
3162
  return _matchesPattern(this.node, pattern, allowPartial);
3197
3163
  }
3198
3164
  function has(key) {
3199
- const val = this.node && this.node[key];
3165
+ const val = this.node?.[key];
3200
3166
  if (val && Array.isArray(val)) {
3201
3167
  return !!val.length;
3202
3168
  } else {
@@ -3510,6 +3476,18 @@ function isConstantExpression() {
3510
3476
  } = this.node;
3511
3477
  return operator !== "in" && operator !== "instanceof" && this.get("left").isConstantExpression() && this.get("right").isConstantExpression();
3512
3478
  }
3479
+ if (this.isMemberExpression()) {
3480
+ return !this.node.computed && this.get("object").isIdentifier({
3481
+ name: "Symbol"
3482
+ }) && !this.scope.hasBinding("Symbol", {
3483
+ noGlobals: true
3484
+ });
3485
+ }
3486
+ if (this.isCallExpression()) {
3487
+ return this.node.arguments.length === 1 && this.get("callee").matchesPattern("Symbol.for") && !this.scope.hasBinding("Symbol", {
3488
+ noGlobals: true
3489
+ }) && this.get("arguments")[0].isStringLiteral();
3490
+ }
3513
3491
  return false;
3514
3492
  }
3515
3493
  function isInStrictMode() {
@@ -3539,29 +3517,6 @@ function isInStrictMode() {
3539
3517
  return !!strictParent;
3540
3518
  }
3541
3519
 
3542
- var NodePath_introspection = /*#__PURE__*/Object.freeze({
3543
- __proto__: null,
3544
- _guessExecutionStatusRelativeTo: _guessExecutionStatusRelativeTo,
3545
- _resolve: _resolve,
3546
- canHaveVariableDeclarationOrExpression: canHaveVariableDeclarationOrExpression,
3547
- canSwapBetweenExpressionAndStatement: canSwapBetweenExpressionAndStatement,
3548
- equals: equals,
3549
- getSource: getSource,
3550
- has: has,
3551
- is: is,
3552
- isCompletionRecord: isCompletionRecord,
3553
- isConstantExpression: isConstantExpression,
3554
- isInStrictMode: isInStrictMode,
3555
- isNodeType: isNodeType,
3556
- isStatementOrBlock: isStatementOrBlock,
3557
- isStatic: isStatic,
3558
- isnt: isnt,
3559
- matchesPattern: matchesPattern,
3560
- referencesImport: referencesImport,
3561
- resolve: resolve,
3562
- willIMaybeExecuteBefore: willIMaybeExecuteBefore
3563
- });
3564
-
3565
3520
  function call(key) {
3566
3521
  const opts = this.opts;
3567
3522
  this.debug(key);
@@ -3752,31 +3707,6 @@ function _getQueueContexts() {
3752
3707
  return contexts;
3753
3708
  }
3754
3709
 
3755
- var NodePath_context = /*#__PURE__*/Object.freeze({
3756
- __proto__: null,
3757
- _call: _call,
3758
- _getQueueContexts: _getQueueContexts,
3759
- _resyncKey: _resyncKey,
3760
- _resyncList: _resyncList,
3761
- _resyncParent: _resyncParent,
3762
- _resyncRemoved: _resyncRemoved,
3763
- call: call,
3764
- isBlacklisted: isDenylisted,
3765
- isDenylisted: isDenylisted,
3766
- popContext: popContext,
3767
- pushContext: pushContext,
3768
- requeue: requeue,
3769
- resync: resync,
3770
- setContext: setContext,
3771
- setKey: setKey,
3772
- setScope: setScope,
3773
- setup: setup,
3774
- skip: skip,
3775
- skipKey: skipKey,
3776
- stop: stop,
3777
- visit: visit
3778
- });
3779
-
3780
3710
  const hooks = [function (self, parent) {
3781
3711
  const removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement();
3782
3712
  if (removeParent) {
@@ -3856,16 +3786,6 @@ function _assertUnremoved() {
3856
3786
  }
3857
3787
  }
3858
3788
 
3859
- var NodePath_removal = /*#__PURE__*/Object.freeze({
3860
- __proto__: null,
3861
- _assertUnremoved: _assertUnremoved,
3862
- _callRemovalHooks: _callRemovalHooks,
3863
- _markRemoved: _markRemoved,
3864
- _remove: _remove,
3865
- _removeFromScope: _removeFromScope,
3866
- remove: remove
3867
- });
3868
-
3869
3789
  const {
3870
3790
  react
3871
3791
  } = _t;
@@ -4121,18 +4041,19 @@ function insertAfter(nodes_) {
4121
4041
  return isExpression(node) ? expressionStatement(node) : node;
4122
4042
  }));
4123
4043
  } else if (this.isNodeType("Expression") && !this.isJSXElement() && !parentPath.isJSXElement() || parentPath.isForStatement() && this.key === "init") {
4124
- if (this.node) {
4125
- const node = this.node;
4044
+ const self = this;
4045
+ if (self.node) {
4046
+ const node = self.node;
4126
4047
  let {
4127
4048
  scope
4128
4049
  } = this;
4129
4050
  if (scope.path.isPattern()) {
4130
4051
  assertExpression(node);
4131
- this.replaceWith(callExpression(arrowFunctionExpression([], node), []));
4132
- this.get("callee.body").insertAfter(nodes);
4133
- return [this];
4052
+ self.replaceWith(callExpression(arrowFunctionExpression([], node), []));
4053
+ self.get("callee.body").insertAfter(nodes);
4054
+ return [self];
4134
4055
  }
4135
- if (isHiddenInSequenceExpression(this)) {
4056
+ if (isHiddenInSequenceExpression(self)) {
4136
4057
  nodes.unshift(node);
4137
4058
  } else if (isCallExpression(node) && isSuper(node.callee)) {
4138
4059
  nodes.unshift(node);
@@ -4191,7 +4112,7 @@ function _verifyNodeList(nodes) {
4191
4112
  msg = "contains a non-object node";
4192
4113
  } else if (!node.type) {
4193
4114
  msg = "without a type";
4194
- } else if (node instanceof NodePath) {
4115
+ } else if (node instanceof NodePath_Final) {
4195
4116
  msg = "has a NodePath when it expected a raw object";
4196
4117
  }
4197
4118
  if (msg) {
@@ -4204,7 +4125,7 @@ function _verifyNodeList(nodes) {
4204
4125
  function unshiftContainer(listKey, nodes) {
4205
4126
  this._assertUnremoved();
4206
4127
  nodes = this._verifyNodeList(nodes);
4207
- const path = NodePath.get({
4128
+ const path = NodePath_Final.get({
4208
4129
  parentPath: this,
4209
4130
  parent: this.node,
4210
4131
  container: this.node[listKey],
@@ -4217,7 +4138,7 @@ function pushContainer(listKey, nodes) {
4217
4138
  this._assertUnremoved();
4218
4139
  const verifiedNodes = this._verifyNodeList(nodes);
4219
4140
  const container = this.node[listKey];
4220
- const path = NodePath.get({
4141
+ const path = NodePath_Final.get({
4221
4142
  parentPath: this,
4222
4143
  parent: this.node,
4223
4144
  container: container,
@@ -4231,24 +4152,9 @@ function hoist(scope = this.scope) {
4231
4152
  return hoister.run();
4232
4153
  }
4233
4154
 
4234
- var NodePath_modification = /*#__PURE__*/Object.freeze({
4235
- __proto__: null,
4236
- _containerInsert: _containerInsert,
4237
- _containerInsertAfter: _containerInsertAfter,
4238
- _containerInsertBefore: _containerInsertBefore,
4239
- _verifyNodeList: _verifyNodeList,
4240
- hoist: hoist,
4241
- insertAfter: insertAfter,
4242
- insertBefore: insertBefore,
4243
- pushContainer: pushContainer,
4244
- unshiftContainer: unshiftContainer,
4245
- updateSiblingKeys: updateSiblingKeys
4246
- });
4247
-
4248
4155
  const {
4249
4156
  getBindingIdentifiers: _getBindingIdentifiers,
4250
4157
  getOuterBindingIdentifiers: _getOuterBindingIdentifiers,
4251
- isDeclaration,
4252
4158
  numericLiteral,
4253
4159
  unaryExpression
4254
4160
  } = _t;
@@ -4421,7 +4327,7 @@ function getCompletionRecords() {
4421
4327
  return records.map(r => r.path);
4422
4328
  }
4423
4329
  function getSibling(key) {
4424
- return NodePath.get({
4330
+ return NodePath_Final.get({
4425
4331
  parentPath: this.parentPath,
4426
4332
  parent: this.parent,
4427
4333
  container: this.container,
@@ -4469,7 +4375,7 @@ function _getKey(key, context) {
4469
4375
  const container = node[key];
4470
4376
  if (Array.isArray(container)) {
4471
4377
  return container.map((_, i) => {
4472
- return NodePath.get({
4378
+ return NodePath_Final.get({
4473
4379
  listKey: key,
4474
4380
  parentPath: this,
4475
4381
  parent: node,
@@ -4478,7 +4384,7 @@ function _getKey(key, context) {
4478
4384
  }).setContext(context);
4479
4385
  });
4480
4386
  } else {
4481
- return NodePath.get({
4387
+ return NodePath_Final.get({
4482
4388
  parentPath: this,
4483
4389
  parent: node,
4484
4390
  container: node,
@@ -4527,7 +4433,7 @@ function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
4527
4433
  }
4528
4434
  if (id.isExportDeclaration()) {
4529
4435
  const declaration = id.get("declaration");
4530
- if (isDeclaration(declaration)) {
4436
+ if (declaration.isDeclaration()) {
4531
4437
  search.push(declaration);
4532
4438
  }
4533
4439
  continue;
@@ -4559,24 +4465,6 @@ function getOuterBindingIdentifierPaths(duplicates = false) {
4559
4465
  return this.getBindingIdentifierPaths(duplicates, true);
4560
4466
  }
4561
4467
 
4562
- var NodePath_family = /*#__PURE__*/Object.freeze({
4563
- __proto__: null,
4564
- _getKey: _getKey,
4565
- _getPattern: _getPattern,
4566
- get: get,
4567
- getAllNextSiblings: getAllNextSiblings,
4568
- getAllPrevSiblings: getAllPrevSiblings,
4569
- getBindingIdentifierPaths: getBindingIdentifierPaths,
4570
- getBindingIdentifiers: getBindingIdentifiers,
4571
- getCompletionRecords: getCompletionRecords,
4572
- getNextSibling: getNextSibling,
4573
- getOpposite: getOpposite,
4574
- getOuterBindingIdentifierPaths: getOuterBindingIdentifierPaths,
4575
- getOuterBindingIdentifiers: getOuterBindingIdentifiers,
4576
- getPrevSibling: getPrevSibling,
4577
- getSibling: getSibling
4578
- });
4579
-
4580
4468
  const {
4581
4469
  addComment: _addComment,
4582
4470
  addComments: _addComments
@@ -4619,13 +4507,6 @@ function addComments(type, comments) {
4619
4507
  _addComments(this.node, type, comments);
4620
4508
  }
4621
4509
 
4622
- var NodePath_comments = /*#__PURE__*/Object.freeze({
4623
- __proto__: null,
4624
- addComment: addComment,
4625
- addComments: addComments,
4626
- shareCommentsWithSiblings: shareCommentsWithSiblings
4627
- });
4628
-
4629
4510
  const {
4630
4511
  validate
4631
4512
  } = _t;
@@ -4633,7 +4514,7 @@ const debug = buildDebug("babel");
4633
4514
  const REMOVED = 1 << 0;
4634
4515
  const SHOULD_STOP = 1 << 1;
4635
4516
  const SHOULD_SKIP = 1 << 2;
4636
- class NodePath {
4517
+ const NodePath_Final = class NodePath {
4637
4518
  constructor(hub, parent) {
4638
4519
  this.parent = parent;
4639
4520
  this.hub = hub;
@@ -4645,6 +4526,24 @@ class NodePath {
4645
4526
  state = null;
4646
4527
  opts = null;
4647
4528
  _traverseFlags = 0;
4529
+ get removed() {
4530
+ return (this._traverseFlags & 1) > 0;
4531
+ }
4532
+ set removed(v) {
4533
+ if (v) this._traverseFlags |= 1;else this._traverseFlags &= -2;
4534
+ }
4535
+ get shouldStop() {
4536
+ return (this._traverseFlags & 2) > 0;
4537
+ }
4538
+ set shouldStop(v) {
4539
+ if (v) this._traverseFlags |= 2;else this._traverseFlags &= -3;
4540
+ }
4541
+ get shouldSkip() {
4542
+ return (this._traverseFlags & 4) > 0;
4543
+ }
4544
+ set shouldSkip(v) {
4545
+ if (v) this._traverseFlags |= 4;else this._traverseFlags &= -5;
4546
+ }
4648
4547
  skipKeys = null;
4649
4548
  parentPath = null;
4650
4549
  container = null;
@@ -4734,51 +4633,124 @@ class NodePath {
4734
4633
  get parentKey() {
4735
4634
  return this.listKey || this.key;
4736
4635
  }
4737
- get shouldSkip() {
4738
- return !!(this._traverseFlags & SHOULD_SKIP);
4739
- }
4740
- set shouldSkip(v) {
4741
- if (v) {
4742
- this._traverseFlags |= SHOULD_SKIP;
4743
- } else {
4744
- this._traverseFlags &= ~SHOULD_SKIP;
4745
- }
4746
- }
4747
- get shouldStop() {
4748
- return !!(this._traverseFlags & SHOULD_STOP);
4749
- }
4750
- set shouldStop(v) {
4751
- if (v) {
4752
- this._traverseFlags |= SHOULD_STOP;
4753
- } else {
4754
- this._traverseFlags &= ~SHOULD_STOP;
4755
- }
4756
- }
4757
- get removed() {
4758
- return !!(this._traverseFlags & REMOVED);
4759
- }
4760
- set removed(v) {
4761
- if (v) {
4762
- this._traverseFlags |= REMOVED;
4763
- } else {
4764
- this._traverseFlags &= ~REMOVED;
4765
- }
4766
- }
4767
- }
4768
- Object.assign(NodePath.prototype, NodePath_ancestry, NodePath_inference, NodePath_replacement, NodePath_evaluation, NodePath_conversion, NodePath_introspection, NodePath_context, NodePath_removal, NodePath_modification, NodePath_family, NodePath_comments);
4636
+ };
4637
+ const methods = {
4638
+ findParent: findParent,
4639
+ find: find,
4640
+ getFunctionParent: getFunctionParent,
4641
+ getStatementParent: getStatementParent,
4642
+ getEarliestCommonAncestorFrom: getEarliestCommonAncestorFrom,
4643
+ getDeepestCommonAncestorFrom: getDeepestCommonAncestorFrom,
4644
+ getAncestry: getAncestry,
4645
+ isAncestor: isAncestor,
4646
+ isDescendant: isDescendant,
4647
+ inType: inType,
4648
+ getTypeAnnotation: getTypeAnnotation,
4649
+ _getTypeAnnotation: _getTypeAnnotation,
4650
+ isBaseType: isBaseType,
4651
+ couldBeBaseType: couldBeBaseType,
4652
+ baseTypeStrictlyMatches: baseTypeStrictlyMatches,
4653
+ isGenericType: isGenericType,
4654
+ replaceWithMultiple: replaceWithMultiple,
4655
+ replaceWithSourceString: replaceWithSourceString,
4656
+ replaceWith: replaceWith,
4657
+ _replaceWith: _replaceWith,
4658
+ replaceExpressionWithStatements: replaceExpressionWithStatements,
4659
+ replaceInline: replaceInline,
4660
+ evaluateTruthy: evaluateTruthy,
4661
+ evaluate: evaluate,
4662
+ toComputedKey: toComputedKey,
4663
+ ensureBlock: ensureBlock,
4664
+ unwrapFunctionEnvironment: unwrapFunctionEnvironment,
4665
+ arrowFunctionToExpression: arrowFunctionToExpression,
4666
+ matchesPattern: matchesPattern,
4667
+ has: has,
4668
+ isStatic: isStatic,
4669
+ is: is,
4670
+ isnt: isnt,
4671
+ equals: equals,
4672
+ isNodeType: isNodeType,
4673
+ canHaveVariableDeclarationOrExpression: canHaveVariableDeclarationOrExpression,
4674
+ canSwapBetweenExpressionAndStatement: canSwapBetweenExpressionAndStatement,
4675
+ isCompletionRecord: isCompletionRecord,
4676
+ isStatementOrBlock: isStatementOrBlock,
4677
+ referencesImport: referencesImport,
4678
+ getSource: getSource,
4679
+ willIMaybeExecuteBefore: willIMaybeExecuteBefore,
4680
+ _guessExecutionStatusRelativeTo: _guessExecutionStatusRelativeTo,
4681
+ resolve: resolve,
4682
+ _resolve: _resolve,
4683
+ isConstantExpression: isConstantExpression,
4684
+ isInStrictMode: isInStrictMode,
4685
+ call: call,
4686
+ _call: _call,
4687
+ isDenylisted: isDenylisted,
4688
+ isBlacklisted: isDenylisted,
4689
+ visit: visit,
4690
+ skip: skip,
4691
+ skipKey: skipKey,
4692
+ stop: stop,
4693
+ setScope: setScope,
4694
+ setContext: setContext,
4695
+ resync: resync,
4696
+ _resyncParent: _resyncParent,
4697
+ _resyncKey: _resyncKey,
4698
+ _resyncList: _resyncList,
4699
+ _resyncRemoved: _resyncRemoved,
4700
+ popContext: popContext,
4701
+ pushContext: pushContext,
4702
+ setup: setup,
4703
+ setKey: setKey,
4704
+ requeue: requeue,
4705
+ _getQueueContexts: _getQueueContexts,
4706
+ remove: remove,
4707
+ _removeFromScope: _removeFromScope,
4708
+ _callRemovalHooks: _callRemovalHooks,
4709
+ _remove: _remove,
4710
+ _markRemoved: _markRemoved,
4711
+ _assertUnremoved: _assertUnremoved,
4712
+ insertBefore: insertBefore,
4713
+ _containerInsert: _containerInsert,
4714
+ _containerInsertBefore: _containerInsertBefore,
4715
+ _containerInsertAfter: _containerInsertAfter,
4716
+ insertAfter: insertAfter,
4717
+ updateSiblingKeys: updateSiblingKeys,
4718
+ _verifyNodeList: _verifyNodeList,
4719
+ unshiftContainer: unshiftContainer,
4720
+ pushContainer: pushContainer,
4721
+ hoist: hoist,
4722
+ getOpposite: getOpposite,
4723
+ getCompletionRecords: getCompletionRecords,
4724
+ getSibling: getSibling,
4725
+ getPrevSibling: getPrevSibling,
4726
+ getNextSibling: getNextSibling,
4727
+ getAllNextSiblings: getAllNextSiblings,
4728
+ getAllPrevSiblings: getAllPrevSiblings,
4729
+ get: get,
4730
+ _getKey: _getKey,
4731
+ _getPattern: _getPattern,
4732
+ getBindingIdentifiers: getBindingIdentifiers,
4733
+ getOuterBindingIdentifiers: getOuterBindingIdentifiers,
4734
+ getBindingIdentifierPaths: getBindingIdentifierPaths,
4735
+ getOuterBindingIdentifierPaths: getOuterBindingIdentifierPaths,
4736
+ shareCommentsWithSiblings: shareCommentsWithSiblings,
4737
+ addComment: addComment,
4738
+ addComments: addComments
4739
+ };
4740
+ Object.assign(NodePath_Final.prototype, methods);
4769
4741
  for (const type of _t.TYPES) {
4770
4742
  const typeKey = `is${type}`;
4771
4743
  const fn = _t[typeKey];
4772
- NodePath.prototype[typeKey] = function (opts) {
4744
+ NodePath_Final.prototype[typeKey] = function (opts) {
4773
4745
  return fn(this.node, opts);
4774
4746
  };
4775
- NodePath.prototype[`assert${type}`] = function (opts) {
4747
+ NodePath_Final.prototype[`assert${type}`] = function (opts) {
4776
4748
  if (!fn(this.node, opts)) {
4777
4749
  throw new TypeError(`Expected node path of type ${type}`);
4778
4750
  }
4779
4751
  };
4780
4752
  }
4781
- Object.assign(NodePath.prototype, NodePath_virtual_types_validator);
4753
+ Object.assign(NodePath_Final.prototype, NodePath_virtual_types_validator);
4782
4754
  for (const type of Object.keys(virtualTypes)) {
4783
4755
  if (type[0] === "_") continue;
4784
4756
  if (!_t.TYPES.includes(type)) _t.TYPES.push(type);
@@ -4810,7 +4782,7 @@ class TraversalContext {
4810
4782
  return false;
4811
4783
  }
4812
4784
  create(node, container, key, listKey) {
4813
- return NodePath.get({
4785
+ return NodePath_Final.get({
4814
4786
  parentPath: this.parentPath,
4815
4787
  parent: node,
4816
4788
  container,
@@ -4941,12 +4913,12 @@ function traverse(parent, opts = {}, scope, state, parentPath, visitSelf) {
4941
4913
  if (!VISITOR_KEYS[parent.type]) {
4942
4914
  return;
4943
4915
  }
4944
- explode(opts);
4916
+ explode$1(opts);
4945
4917
  traverseNode(parent, opts, scope, state, parentPath, null, visitSelf);
4946
4918
  }
4947
4919
  traverse.visitors = visitors;
4948
- traverse.verify = verify;
4949
- traverse.explode = explode;
4920
+ traverse.verify = verify$1;
4921
+ traverse.explode = explode$1;
4950
4922
  traverse.cheap = function (node, enter) {
4951
4923
  traverseFast(node, enter);
4952
4924
  return;
@@ -4983,5 +4955,5 @@ traverse.hasType = function (tree, type, denylistTypes) {
4983
4955
  };
4984
4956
  traverse.cache = cache;
4985
4957
 
4986
- export { Hub, NodePath, Scope, traverse as default, visitors };
4958
+ export { Hub, NodePath_Final as NodePath, Scope, traverse as default, visitors };
4987
4959
  //# sourceMappingURL=index.js.map