@babel/traverse 7.21.4-esm.4 → 7.21.5

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.

Potentially problematic release.


This version of @babel/traverse might be problematic. Click here for more details.

Files changed (58) hide show
  1. package/lib/cache.js +18 -7
  2. package/lib/cache.js.map +1 -1
  3. package/lib/context.js +11 -4
  4. package/lib/context.js.map +1 -1
  5. package/lib/hub.js +8 -1
  6. package/lib/hub.js.map +1 -1
  7. package/lib/index.js +36 -11
  8. package/lib/index.js.map +1 -1
  9. package/lib/path/ancestry.js +26 -11
  10. package/lib/path/ancestry.js.map +1 -1
  11. package/lib/path/comments.js +12 -4
  12. package/lib/path/comments.js.map +1 -1
  13. package/lib/path/context.js +56 -29
  14. package/lib/path/context.js.map +1 -1
  15. package/lib/path/conversion.js +35 -20
  16. package/lib/path/conversion.js.map +1 -1
  17. package/lib/path/evaluation.js +9 -2
  18. package/lib/path/evaluation.js.map +1 -1
  19. package/lib/path/family.js +33 -19
  20. package/lib/path/family.js.map +1 -1
  21. package/lib/path/index.js +40 -30
  22. package/lib/path/index.js.map +1 -1
  23. package/lib/path/inference/index.js +19 -8
  24. package/lib/path/inference/index.js.map +1 -1
  25. package/lib/path/inference/inferer-reference.js +11 -5
  26. package/lib/path/inference/inferer-reference.js.map +1 -1
  27. package/lib/path/inference/inferers.js +65 -30
  28. package/lib/path/inference/inferers.js.map +1 -1
  29. package/lib/path/inference/util.js +8 -2
  30. package/lib/path/inference/util.js.map +1 -1
  31. package/lib/path/introspection.js +45 -20
  32. package/lib/path/introspection.js.map +1 -1
  33. package/lib/path/lib/hoister.js +10 -3
  34. package/lib/path/lib/hoister.js.map +1 -1
  35. package/lib/path/lib/removal-hooks.js +8 -1
  36. package/lib/path/lib/removal-hooks.js.map +1 -1
  37. package/lib/path/lib/virtual-types-validator.js +42 -19
  38. package/lib/path/lib/virtual-types-validator.js.map +1 -1
  39. package/lib/path/lib/virtual-types.js +42 -18
  40. package/lib/path/lib/virtual-types.js.map +1 -1
  41. package/lib/path/modification.js +34 -19
  42. package/lib/path/modification.js.map +1 -1
  43. package/lib/path/removal.js +23 -12
  44. package/lib/path/removal.js.map +1 -1
  45. package/lib/path/replacement.js +33 -22
  46. package/lib/path/replacement.js.map +1 -1
  47. package/lib/scope/binding.js +8 -1
  48. package/lib/scope/binding.js.map +1 -1
  49. package/lib/scope/index.js +20 -13
  50. package/lib/scope/index.js.map +1 -1
  51. package/lib/scope/lib/renamer.js +16 -9
  52. package/lib/scope/lib/renamer.js.map +1 -1
  53. package/lib/traverse-node.js +10 -4
  54. package/lib/traverse-node.js.map +1 -1
  55. package/lib/visitors.js +19 -6
  56. package/lib/visitors.js.map +1 -1
  57. package/package.json +11 -11
  58. package/lib/package.json +0 -1
@@ -1,6 +1,31 @@
1
- import { traverseNode } from "../traverse-node.js";
2
- import { SHOULD_SKIP, SHOULD_STOP } from "./index.js";
3
- export function call(key) {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports._call = _call;
7
+ exports._getQueueContexts = _getQueueContexts;
8
+ exports._resyncKey = _resyncKey;
9
+ exports._resyncList = _resyncList;
10
+ exports._resyncParent = _resyncParent;
11
+ exports._resyncRemoved = _resyncRemoved;
12
+ exports.call = call;
13
+ exports.isBlacklisted = exports.isDenylisted = isDenylisted;
14
+ exports.popContext = popContext;
15
+ exports.pushContext = pushContext;
16
+ exports.requeue = requeue;
17
+ exports.resync = resync;
18
+ exports.setContext = setContext;
19
+ exports.setKey = setKey;
20
+ exports.setScope = setScope;
21
+ exports.setup = setup;
22
+ exports.skip = skip;
23
+ exports.skipKey = skipKey;
24
+ exports.stop = stop;
25
+ exports.visit = visit;
26
+ var _traverseNode = require("../traverse-node");
27
+ var _index = require("./index");
28
+ function call(key) {
4
29
  const opts = this.opts;
5
30
  this.debug(key);
6
31
  if (this.node) {
@@ -11,7 +36,7 @@ export function call(key) {
11
36
  }
12
37
  return false;
13
38
  }
14
- export function _call(fns) {
39
+ function _call(fns) {
15
40
  if (!fns) return false;
16
41
  for (const fn of fns) {
17
42
  if (!fn) continue;
@@ -29,12 +54,11 @@ export function _call(fns) {
29
54
  }
30
55
  return false;
31
56
  }
32
- export function isDenylisted() {
57
+ function isDenylisted() {
33
58
  var _this$opts$denylist;
34
59
  const denylist = (_this$opts$denylist = this.opts.denylist) != null ? _this$opts$denylist : this.opts.blacklist;
35
60
  return denylist && denylist.indexOf(this.node.type) > -1;
36
61
  }
37
- export { isDenylisted as isBlacklisted };
38
62
  function restoreContext(path, context) {
39
63
  if (path.context !== context) {
40
64
  path.context = context;
@@ -42,14 +66,15 @@ function restoreContext(path, context) {
42
66
  path.opts = context.opts;
43
67
  }
44
68
  }
45
- export function visit() {
69
+ function visit() {
70
+ var _this$opts$shouldSkip, _this$opts;
46
71
  if (!this.node) {
47
72
  return false;
48
73
  }
49
74
  if (this.isDenylisted()) {
50
75
  return false;
51
76
  }
52
- if (this.opts.shouldSkip && this.opts.shouldSkip(this)) {
77
+ if ((_this$opts$shouldSkip = (_this$opts = this.opts).shouldSkip) != null && _this$opts$shouldSkip.call(_this$opts, this)) {
53
78
  return false;
54
79
  }
55
80
  const currentContext = this.context;
@@ -59,39 +84,41 @@ export function visit() {
59
84
  }
60
85
  restoreContext(this, currentContext);
61
86
  this.debug("Recursing into...");
62
- this.shouldStop = traverseNode(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
87
+ this.shouldStop = (0, _traverseNode.traverseNode)(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
63
88
  restoreContext(this, currentContext);
64
89
  this.call("exit");
65
90
  return this.shouldStop;
66
91
  }
67
- export function skip() {
92
+ function skip() {
68
93
  this.shouldSkip = true;
69
94
  }
70
- export function skipKey(key) {
95
+ function skipKey(key) {
71
96
  if (this.skipKeys == null) {
72
97
  this.skipKeys = {};
73
98
  }
74
99
  this.skipKeys[key] = true;
75
100
  }
76
- export function stop() {
77
- this._traverseFlags |= SHOULD_SKIP | SHOULD_STOP;
101
+ function stop() {
102
+ this._traverseFlags |= _index.SHOULD_SKIP | _index.SHOULD_STOP;
78
103
  }
79
- export function setScope() {
80
- if (this.opts && this.opts.noScope) return;
104
+ function setScope() {
105
+ var _this$opts2, _this$scope;
106
+ if ((_this$opts2 = this.opts) != null && _this$opts2.noScope) return;
81
107
  let path = this.parentPath;
82
108
  if ((this.key === "key" || this.listKey === "decorators") && path.isMethod() || this.key === "discriminant" && path.isSwitchStatement()) {
83
109
  path = path.parentPath;
84
110
  }
85
111
  let target;
86
112
  while (path && !target) {
87
- if (path.opts && path.opts.noScope) return;
113
+ var _path$opts;
114
+ if ((_path$opts = path.opts) != null && _path$opts.noScope) return;
88
115
  target = path.scope;
89
116
  path = path.parentPath;
90
117
  }
91
118
  this.scope = this.getScope(target);
92
- if (this.scope) this.scope.init();
119
+ (_this$scope = this.scope) == null ? void 0 : _this$scope.init();
93
120
  }
94
- export function setContext(context) {
121
+ function setContext(context) {
95
122
  if (this.skipKeys != null) {
96
123
  this.skipKeys = {};
97
124
  }
@@ -104,18 +131,18 @@ export function setContext(context) {
104
131
  this.setScope();
105
132
  return this;
106
133
  }
107
- export function resync() {
134
+ function resync() {
108
135
  if (this.removed) return;
109
136
  this._resyncParent();
110
137
  this._resyncList();
111
138
  this._resyncKey();
112
139
  }
113
- export function _resyncParent() {
140
+ function _resyncParent() {
114
141
  if (this.parentPath) {
115
142
  this.parent = this.parentPath.node;
116
143
  }
117
144
  }
118
- export function _resyncKey() {
145
+ function _resyncKey() {
119
146
  if (!this.container) return;
120
147
  if (this.node === this.container[this.key]) {
121
148
  return;
@@ -137,18 +164,18 @@ export function _resyncKey() {
137
164
  }
138
165
  this.key = null;
139
166
  }
140
- export function _resyncList() {
167
+ function _resyncList() {
141
168
  if (!this.parent || !this.inList) return;
142
169
  const newContainer = this.parent[this.listKey];
143
170
  if (this.container === newContainer) return;
144
171
  this.container = newContainer || null;
145
172
  }
146
- export function _resyncRemoved() {
173
+ function _resyncRemoved() {
147
174
  if (this.key == null || !this.container || this.container[this.key] !== this.node) {
148
175
  this._markRemoved();
149
176
  }
150
177
  }
151
- export function popContext() {
178
+ function popContext() {
152
179
  this.contexts.pop();
153
180
  if (this.contexts.length > 0) {
154
181
  this.setContext(this.contexts[this.contexts.length - 1]);
@@ -156,23 +183,23 @@ export function popContext() {
156
183
  this.setContext(undefined);
157
184
  }
158
185
  }
159
- export function pushContext(context) {
186
+ function pushContext(context) {
160
187
  this.contexts.push(context);
161
188
  this.setContext(context);
162
189
  }
163
- export function setup(parentPath, container, listKey, key) {
190
+ function setup(parentPath, container, listKey, key) {
164
191
  this.listKey = listKey;
165
192
  this.container = container;
166
193
  this.parentPath = parentPath || this.parentPath;
167
194
  this.setKey(key);
168
195
  }
169
- export function setKey(key) {
196
+ function setKey(key) {
170
197
  var _this$node;
171
198
  this.key = key;
172
199
  this.node = this.container[this.key];
173
200
  this.type = (_this$node = this.node) == null ? void 0 : _this$node.type;
174
201
  }
175
- export function requeue(pathToQueue = this) {
202
+ function requeue(pathToQueue = this) {
176
203
  if (pathToQueue.removed) return;
177
204
  ;
178
205
  const contexts = this.contexts;
@@ -180,7 +207,7 @@ export function requeue(pathToQueue = this) {
180
207
  context.maybeQueue(pathToQueue);
181
208
  }
182
209
  }
183
- export function _getQueueContexts() {
210
+ function _getQueueContexts() {
184
211
  let path = this;
185
212
  let contexts = this.contexts;
186
213
  while (!contexts.length) {
@@ -1 +1 @@
1
- {"version":3,"names":["traverseNode","SHOULD_SKIP","SHOULD_STOP","call","key","opts","debug","node","_call","type","fns","fn","ret","state","then","Error","_traverseFlags","isDenylisted","_this$opts$denylist","denylist","blacklist","indexOf","isBlacklisted","restoreContext","path","context","visit","shouldSkip","currentContext","shouldStop","scope","skipKeys","skip","skipKey","stop","setScope","noScope","parentPath","listKey","isMethod","isSwitchStatement","target","getScope","init","setContext","resync","removed","_resyncParent","_resyncList","_resyncKey","parent","container","Array","isArray","i","length","setKey","Object","keys","inList","newContainer","_resyncRemoved","_markRemoved","popContext","contexts","pop","undefined","pushContext","push","setup","_this$node","requeue","pathToQueue","maybeQueue","_getQueueContexts"],"sources":["../../src/path/context.ts"],"sourcesContent":["// This file contains methods responsible for maintaining a TraversalContext.\n\nimport { traverseNode } from \"../traverse-node\";\nimport { SHOULD_SKIP, SHOULD_STOP } from \"./index\";\nimport type TraversalContext from \"../context\";\nimport type NodePath from \"./index\";\nimport type * as t from \"@babel/types\";\n\nexport function call(this: NodePath, key: string): boolean {\n const opts = this.opts;\n\n this.debug(key);\n\n if (this.node) {\n if (this._call(opts[key])) return true;\n }\n\n if (this.node) {\n return this._call(opts[this.node.type] && opts[this.node.type][key]);\n }\n\n return false;\n}\n\nexport function _call(this: NodePath, fns?: Array<Function>): boolean {\n if (!fns) return false;\n\n for (const fn of fns) {\n if (!fn) continue;\n\n const node = this.node;\n if (!node) return true;\n\n const ret = fn.call(this.state, this, this.state);\n if (ret && typeof ret === \"object\" && typeof ret.then === \"function\") {\n throw new Error(\n `You appear to be using a plugin with an async traversal visitor, ` +\n `which your current version of Babel does not support. ` +\n `If you're using a published plugin, you may need to upgrade ` +\n `your @babel/core version.`,\n );\n }\n if (ret) {\n throw new Error(`Unexpected return value from visitor method ${fn}`);\n }\n\n // node has been replaced, it will have been requeued\n if (this.node !== node) return true;\n\n // this.shouldSkip || this.shouldStop || this.removed\n if (this._traverseFlags > 0) return true;\n }\n\n return false;\n}\n\nexport function isDenylisted(this: NodePath): boolean {\n const denylist = this.opts.denylist ?? this.opts.blacklist;\n return denylist && denylist.indexOf(this.node.type) > -1;\n}\n\n// TODO: Remove in Babel 8\nexport { isDenylisted as isBlacklisted };\n\nfunction restoreContext(path: NodePath, context: TraversalContext) {\n if (path.context !== context) {\n path.context = context;\n path.state = context.state;\n path.opts = context.opts;\n }\n}\n\nexport function visit(this: NodePath): boolean {\n if (!this.node) {\n return false;\n }\n\n if (this.isDenylisted()) {\n return false;\n }\n\n if (this.opts.shouldSkip && this.opts.shouldSkip(this)) {\n return false;\n }\n\n const currentContext = this.context;\n // Note: We need to check \"this.shouldSkip\" first because\n // another visitor can set it to true. Usually .shouldSkip is false\n // before calling the enter visitor, but it can be true in case of\n // a requeued node (e.g. by .replaceWith()) that is then marked\n // with .skip().\n if (this.shouldSkip || this.call(\"enter\")) {\n this.debug(\"Skip...\");\n return this.shouldStop;\n }\n restoreContext(this, currentContext);\n\n this.debug(\"Recursing into...\");\n this.shouldStop = traverseNode(\n this.node,\n this.opts,\n this.scope,\n this.state,\n this,\n this.skipKeys,\n );\n\n restoreContext(this, currentContext);\n\n this.call(\"exit\");\n\n return this.shouldStop;\n}\n\nexport function skip(this: NodePath) {\n this.shouldSkip = true;\n}\n\nexport function skipKey(this: NodePath, key: string) {\n if (this.skipKeys == null) {\n this.skipKeys = {};\n }\n this.skipKeys[key] = true;\n}\n\nexport function stop(this: NodePath) {\n // this.shouldSkip = true; this.shouldStop = true;\n this._traverseFlags |= SHOULD_SKIP | SHOULD_STOP;\n}\n\nexport function setScope(this: NodePath) {\n if (this.opts && this.opts.noScope) return;\n\n let path = this.parentPath;\n\n if (\n // Skip method scope if is computed method key or decorator expression\n ((this.key === \"key\" || this.listKey === \"decorators\") &&\n path.isMethod()) ||\n // Skip switch scope if for discriminant (`x` in `switch (x) {}`).\n (this.key === \"discriminant\" && path.isSwitchStatement())\n ) {\n path = path.parentPath;\n }\n\n let target;\n while (path && !target) {\n if (path.opts && path.opts.noScope) return;\n\n target = path.scope;\n path = path.parentPath;\n }\n\n this.scope = this.getScope(target);\n if (this.scope) this.scope.init();\n}\n\nexport function setContext<S = unknown>(\n this: NodePath,\n context?: TraversalContext<S>,\n) {\n if (this.skipKeys != null) {\n this.skipKeys = {};\n }\n // this.shouldSkip = false; this.shouldStop = false; this.removed = false;\n this._traverseFlags = 0;\n\n if (context) {\n this.context = context;\n this.state = context.state;\n this.opts = context.opts;\n }\n\n this.setScope();\n\n return this;\n}\n\n/**\n * Here we resync the node paths `key` and `container`. If they've changed according\n * to what we have stored internally then we attempt to resync by crawling and looking\n * for the new values.\n */\n\nexport function resync(this: NodePath) {\n if (this.removed) return;\n\n this._resyncParent();\n this._resyncList();\n this._resyncKey();\n //this._resyncRemoved();\n}\n\nexport function _resyncParent(this: NodePath) {\n if (this.parentPath) {\n this.parent = this.parentPath.node;\n }\n}\n\nexport function _resyncKey(this: NodePath) {\n if (!this.container) return;\n\n if (\n this.node ===\n // @ts-expect-error this.key should present in this.container\n this.container[this.key]\n ) {\n return;\n }\n\n // grrr, path key is out of sync. this is likely due to a modification to the AST\n // not done through our path APIs\n\n if (Array.isArray(this.container)) {\n for (let i = 0; i < this.container.length; i++) {\n if (this.container[i] === this.node) {\n this.setKey(i);\n return;\n }\n }\n } else {\n for (const key of Object.keys(this.container)) {\n // @ts-expect-error this.key should present in this.container\n if (this.container[key] === this.node) {\n this.setKey(key);\n return;\n }\n }\n }\n\n // ¯\\_(ツ)_/¯ who knows where it's gone lol\n this.key = null;\n}\n\nexport function _resyncList(this: NodePath) {\n if (!this.parent || !this.inList) return;\n\n const newContainer =\n // @ts-expect-error this.listKey should present in this.parent\n this.parent[this.listKey];\n if (this.container === newContainer) return;\n\n // container is out of sync. this is likely the result of it being reassigned\n this.container = newContainer || null;\n}\n\nexport function _resyncRemoved(this: NodePath) {\n if (\n this.key == null ||\n !this.container ||\n // @ts-expect-error this.key should present in this.container\n this.container[this.key] !== this.node\n ) {\n this._markRemoved();\n }\n}\n\nexport function popContext(this: NodePath) {\n this.contexts.pop();\n if (this.contexts.length > 0) {\n this.setContext(this.contexts[this.contexts.length - 1]);\n } else {\n this.setContext(undefined);\n }\n}\n\nexport function pushContext(this: NodePath, context: TraversalContext) {\n this.contexts.push(context);\n this.setContext(context);\n}\n\nexport function setup(\n this: NodePath,\n parentPath: NodePath | undefined,\n container: t.Node,\n listKey: string,\n key: string | number,\n) {\n this.listKey = listKey;\n this.container = container;\n\n this.parentPath = parentPath || this.parentPath;\n this.setKey(key);\n}\n\nexport function setKey(this: NodePath, key: string | number) {\n this.key = key;\n this.node =\n // @ts-expect-error this.key must present in this.container\n this.container[this.key];\n this.type = this.node?.type;\n}\n\nexport function requeue(this: NodePath, pathToQueue = this) {\n if (pathToQueue.removed) return;\n\n // If a path is skipped, and then replaced with a\n // new one, the new one shouldn't probably be skipped.\n if (process.env.BABEL_8_BREAKING) {\n pathToQueue.shouldSkip = false;\n }\n\n // TODO(loganfsmyth): This should be switched back to queue in parent contexts\n // automatically once #2892 and #4135 have been resolved. See #4140.\n // let contexts = this._getQueueContexts();\n const contexts = this.contexts;\n\n for (const context of contexts) {\n context.maybeQueue(pathToQueue);\n }\n}\n\nexport function _getQueueContexts(this: NodePath) {\n let path = this;\n let contexts = this.contexts;\n while (!contexts.length) {\n path = path.parentPath;\n if (!path) break;\n contexts = path.contexts;\n }\n return contexts;\n}\n"],"mappings":"AAEA,SAASA,YAAY,QAAQ,qBAAkB;AAC/C,SAASC,WAAW,EAAEC,WAAW,QAAQ,YAAS;AAKlD,OAAO,SAASC,IAAIA,CAAiBC,GAAW,EAAW;EACzD,MAAMC,IAAI,GAAG,IAAI,CAACA,IAAI;EAEtB,IAAI,CAACC,KAAK,CAACF,GAAG,CAAC;EAEf,IAAI,IAAI,CAACG,IAAI,EAAE;IACb,IAAI,IAAI,CAACC,KAAK,CAACH,IAAI,CAACD,GAAG,CAAC,CAAC,EAAE,OAAO,IAAI;EACxC;EAEA,IAAI,IAAI,CAACG,IAAI,EAAE;IACb,OAAO,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC,IAAI,CAACE,IAAI,CAACE,IAAI,CAAC,IAAIJ,IAAI,CAAC,IAAI,CAACE,IAAI,CAACE,IAAI,CAAC,CAACL,GAAG,CAAC,CAAC;EACtE;EAEA,OAAO,KAAK;AACd;AAEA,OAAO,SAASI,KAAKA,CAAiBE,GAAqB,EAAW;EACpE,IAAI,CAACA,GAAG,EAAE,OAAO,KAAK;EAEtB,KAAK,MAAMC,EAAE,IAAID,GAAG,EAAE;I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AG,CAAC;AAClB;AAEA,OAAO,SAASoD,MAAMA,CAAiBpD,GAAoB,EAAE;EAAA,IAAAkE,UAAA;EAC3D,IAAI,CAAClE,GAAG,GAAGA,GAAG;EACd,IAAI,CAACG,IAAI,GAEP,IAAI,CAAC4C,SAAS,CAAC,IAAI,CAAC/C,GAAG,CAAC;EAC1B,IAAI,CAACK,IAAI,IAAA6D,UAAA,GAAG,IAAI,CAAC/D,IAAI,qBAAT+D,UAAA,CAAW7D,IAAI;AAC7B;AAEA,OAAO,SAAS8D,OAAOA,CAAiBC,WAAW,GAAG,IAAI,EAAE;EAC1D,IAAIA,WAAW,CAAC1B,OAAO,EAAE;EAAO;EAWhC,MAAMkB,QAAQ,GAAG,IAAI,CAACA,QAAQ;EAE9B,KAAK,MAAMvC,OAAO,IAAIuC,QAAQ,EAAE;IAC9BvC,OAAO,CAACgD,UAAU,CAACD,WAAW,CAAC;EACjC;AACF;AAEA,OAAO,SAASE,iBAAiBA,CAAA,EAAiB;EAChD,IAAIlD,IAAI,GAAG,IAAI;EACf,IAAIwC,QAAQ,GAAG,IAAI,CAACA,QAAQ;EAC5B,OAAO,CAACA,QAAQ,CAACT,MAAM,EAAE;IACvB/B,IAAI,GAAGA,IAAI,CAACa,UAAU;IACtB,IAAI,CAACb,IAAI,EAAE;IACXwC,QAAQ,GAAGxC,IAAI,CAACwC,QAAQ;EAC1B;EACA,OAAOA,QAAQ;AACjB"}
1
+ {"version":3,"names":["_traverseNode","require","_index","call","key","opts","debug","node","_call","type","fns","fn","ret","state","then","Error","_traverseFlags","isDenylisted","_this$opts$denylist","denylist","blacklist","indexOf","restoreContext","path","context","visit","_this$opts$shouldSkip","_this$opts","shouldSkip","currentContext","shouldStop","traverseNode","scope","skipKeys","skip","skipKey","stop","SHOULD_SKIP","SHOULD_STOP","setScope","_this$opts2","_this$scope","noScope","parentPath","listKey","isMethod","isSwitchStatement","target","_path$opts","getScope","init","setContext","resync","removed","_resyncParent","_resyncList","_resyncKey","parent","container","Array","isArray","i","length","setKey","Object","keys","inList","newContainer","_resyncRemoved","_markRemoved","popContext","contexts","pop","undefined","pushContext","push","setup","_this$node","requeue","pathToQueue","maybeQueue","_getQueueContexts"],"sources":["../../src/path/context.ts"],"sourcesContent":["// This file contains methods responsible for maintaining a TraversalContext.\n\nimport { traverseNode } from \"../traverse-node\";\nimport { SHOULD_SKIP, SHOULD_STOP } from \"./index\";\nimport type TraversalContext from \"../context\";\nimport type NodePath from \"./index\";\nimport type * as t from \"@babel/types\";\n\nexport function call(this: NodePath, key: string): boolean {\n const opts = this.opts;\n\n this.debug(key);\n\n if (this.node) {\n if (this._call(opts[key])) return true;\n }\n\n if (this.node) {\n return this._call(opts[this.node.type] && opts[this.node.type][key]);\n }\n\n return false;\n}\n\nexport function _call(this: NodePath, fns?: Array<Function>): boolean {\n if (!fns) return false;\n\n for (const fn of fns) {\n if (!fn) continue;\n\n const node = this.node;\n if (!node) return true;\n\n const ret = fn.call(this.state, this, this.state);\n if (ret && typeof ret === \"object\" && typeof ret.then === \"function\") {\n throw new Error(\n `You appear to be using a plugin with an async traversal visitor, ` +\n `which your current version of Babel does not support. ` +\n `If you're using a published plugin, you may need to upgrade ` +\n `your @babel/core version.`,\n );\n }\n if (ret) {\n throw new Error(`Unexpected return value from visitor method ${fn}`);\n }\n\n // node has been replaced, it will have been requeued\n if (this.node !== node) return true;\n\n // this.shouldSkip || this.shouldStop || this.removed\n if (this._traverseFlags > 0) return true;\n }\n\n return false;\n}\n\nexport function isDenylisted(this: NodePath): boolean {\n const denylist = this.opts.denylist ?? this.opts.blacklist;\n return denylist && denylist.indexOf(this.node.type) > -1;\n}\n\n// TODO: Remove in Babel 8\nexport { isDenylisted as isBlacklisted };\n\nfunction restoreContext(path: NodePath, context: TraversalContext) {\n if (path.context !== context) {\n path.context = context;\n path.state = context.state;\n path.opts = context.opts;\n }\n}\n\nexport function visit(this: NodePath): boolean {\n if (!this.node) {\n return false;\n }\n\n if (this.isDenylisted()) {\n return false;\n }\n\n if (this.opts.shouldSkip?.(this)) {\n return false;\n }\n\n const currentContext = this.context;\n // Note: We need to check \"this.shouldSkip\" first because\n // another visitor can set it to true. Usually .shouldSkip is false\n // before calling the enter visitor, but it can be true in case of\n // a requeued node (e.g. by .replaceWith()) that is then marked\n // with .skip().\n if (this.shouldSkip || this.call(\"enter\")) {\n this.debug(\"Skip...\");\n return this.shouldStop;\n }\n restoreContext(this, currentContext);\n\n this.debug(\"Recursing into...\");\n this.shouldStop = traverseNode(\n this.node,\n this.opts,\n this.scope,\n this.state,\n this,\n this.skipKeys,\n );\n\n restoreContext(this, currentContext);\n\n this.call(\"exit\");\n\n return this.shouldStop;\n}\n\nexport function skip(this: NodePath) {\n this.shouldSkip = true;\n}\n\nexport function skipKey(this: NodePath, key: string) {\n if (this.skipKeys == null) {\n this.skipKeys = {};\n }\n this.skipKeys[key] = true;\n}\n\nexport function stop(this: NodePath) {\n // this.shouldSkip = true; this.shouldStop = true;\n this._traverseFlags |= SHOULD_SKIP | SHOULD_STOP;\n}\n\nexport function setScope(this: NodePath) {\n if (this.opts?.noScope) return;\n\n let path = this.parentPath;\n\n if (\n // Skip method scope if is computed method key or decorator expression\n ((this.key === \"key\" || this.listKey === \"decorators\") &&\n path.isMethod()) ||\n // Skip switch scope if for discriminant (`x` in `switch (x) {}`).\n (this.key === \"discriminant\" && path.isSwitchStatement())\n ) {\n path = path.parentPath;\n }\n\n let target;\n while (path && !target) {\n if (path.opts?.noScope) return;\n\n target = path.scope;\n path = path.parentPath;\n }\n\n this.scope = this.getScope(target);\n this.scope?.init();\n}\n\nexport function setContext<S = unknown>(\n this: NodePath,\n context?: TraversalContext<S>,\n) {\n if (this.skipKeys != null) {\n this.skipKeys = {};\n }\n // this.shouldSkip = false; this.shouldStop = false; this.removed = false;\n this._traverseFlags = 0;\n\n if (context) {\n this.context = context;\n this.state = context.state;\n this.opts = context.opts;\n }\n\n this.setScope();\n\n return this;\n}\n\n/**\n * Here we resync the node paths `key` and `container`. If they've changed according\n * to what we have stored internally then we attempt to resync by crawling and looking\n * for the new values.\n */\n\nexport function resync(this: NodePath) {\n if (this.removed) return;\n\n this._resyncParent();\n this._resyncList();\n this._resyncKey();\n //this._resyncRemoved();\n}\n\nexport function _resyncParent(this: NodePath) {\n if (this.parentPath) {\n this.parent = this.parentPath.node;\n }\n}\n\nexport function _resyncKey(this: NodePath) {\n if (!this.container) return;\n\n if (\n this.node ===\n // @ts-expect-error this.key should present in this.container\n this.container[this.key]\n ) {\n return;\n }\n\n // grrr, path key is out of sync. this is likely due to a modification to the AST\n // not done through our path APIs\n\n if (Array.isArray(this.container)) {\n for (let i = 0; i < this.container.length; i++) {\n if (this.container[i] === this.node) {\n this.setKey(i);\n return;\n }\n }\n } else {\n for (const key of Object.keys(this.container)) {\n // @ts-expect-error this.key should present in this.container\n if (this.container[key] === this.node) {\n this.setKey(key);\n return;\n }\n }\n }\n\n // ¯\\_(ツ)_/¯ who knows where it's gone lol\n this.key = null;\n}\n\nexport function _resyncList(this: NodePath) {\n if (!this.parent || !this.inList) return;\n\n const newContainer =\n // @ts-expect-error this.listKey should present in this.parent\n this.parent[this.listKey];\n if (this.container === newContainer) return;\n\n // container is out of sync. this is likely the result of it being reassigned\n this.container = newContainer || null;\n}\n\nexport function _resyncRemoved(this: NodePath) {\n if (\n this.key == null ||\n !this.container ||\n // @ts-expect-error this.key should present in this.container\n this.container[this.key] !== this.node\n ) {\n this._markRemoved();\n }\n}\n\nexport function popContext(this: NodePath) {\n this.contexts.pop();\n if (this.contexts.length > 0) {\n this.setContext(this.contexts[this.contexts.length - 1]);\n } else {\n this.setContext(undefined);\n }\n}\n\nexport function pushContext(this: NodePath, context: TraversalContext) {\n this.contexts.push(context);\n this.setContext(context);\n}\n\nexport function setup(\n this: NodePath,\n parentPath: NodePath | undefined,\n container: t.Node,\n listKey: string,\n key: string | number,\n) {\n this.listKey = listKey;\n this.container = container;\n\n this.parentPath = parentPath || this.parentPath;\n this.setKey(key);\n}\n\nexport function setKey(this: NodePath, key: string | number) {\n this.key = key;\n this.node =\n // @ts-expect-error this.key must present in this.container\n this.container[this.key];\n this.type = this.node?.type;\n}\n\nexport function requeue(this: NodePath, pathToQueue = this) {\n if (pathToQueue.removed) return;\n\n // If a path is skipped, and then replaced with a\n // new one, the new one shouldn't probably be skipped.\n if (process.env.BABEL_8_BREAKING) {\n pathToQueue.shouldSkip = false;\n }\n\n // TODO(loganfsmyth): This should be switched back to queue in parent contexts\n // automatically once #2892 and #4135 have been resolved. See #4140.\n // let contexts = this._getQueueContexts();\n const contexts = this.contexts;\n\n for (const context of contexts) {\n context.maybeQueue(pathToQueue);\n }\n}\n\nexport function _getQueueContexts(this: NodePath) {\n let path = this;\n let contexts = this.contexts;\n while (!contexts.length) {\n path = path.parentPath;\n if (!path) break;\n contexts = path.contexts;\n }\n return contexts;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKO,SAASE,IAAIA,CAAiBC,GAAW,EAAW;EACzD,MAAMC,IAAI,GAAG,IAAI,CAACA,IAAI;EAEtB,IAAI,CAACC,KAAK,CAACF,GAAG,CAAC;EAEf,IAAI,IAAI,CAACG,IAAI,EAAE;IACb,IAAI,IAAI,CAACC,KAAK,CAACH,IAAI,CAACD,GAAG,CAAC,CAAC,EAAE,OAAO,IAAI;EACxC;EAEA,IAAI,IAAI,CAACG,IAAI,EAAE;IACb,OAAO,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC,IAAI,CAACE,IAAI,CAACE,IAAI,CAAC,IAAIJ,IAAI,CAAC,IAAI,CAACE,IAAI,CAACE,IAAI,CAAC,CAACL,GAAG,CAAC,CAAC;EACtE;EAEA,OAAO,KAAK;AACd;AAEO,SAASI,KAAKA,CAAiBE,GAAqB,EAAW;EACpE,IAAI,CAACA,GAAG,EAAE,OAAO,KAAK;EAEtB,KAAK,MAAMC,EAAE,IAAID,GAAG,EAAE;IACp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AC;AAClB;AAEO,SAAS2D,MAAMA,CAAiB3D,GAAoB,EAAE;EAAA,IAAAyE,UAAA;EAC3D,IAAI,CAACzE,GAAG,GAAGA,GAAG;EACd,IAAI,CAACG,IAAI,GAEP,IAAI,CAACmD,SAAS,CAAC,IAAI,CAACtD,GAAG,CAAC;EAC1B,IAAI,CAACK,IAAI,IAAAoE,UAAA,GAAG,IAAI,CAACtE,IAAI,qBAATsE,UAAA,CAAWpE,IAAI;AAC7B;AAEO,SAASqE,OAAOA,CAAiBC,WAAW,GAAG,IAAI,EAAE;EAC1D,IAAIA,WAAW,CAAC1B,OAAO,EAAE;EAAO;EAWhC,MAAMkB,QAAQ,GAAG,IAAI,CAACA,QAAQ;EAE9B,KAAK,MAAM/C,OAAO,IAAI+C,QAAQ,EAAE;IAC9B/C,OAAO,CAACwD,UAAU,CAACD,WAAW,CAAC;EACjC;AACF;AAEO,SAASE,iBAAiBA,CAAA,EAAiB;EAChD,IAAI1D,IAAI,GAAG,IAAI;EACf,IAAIgD,QAAQ,GAAG,IAAI,CAACA,QAAQ;EAC5B,OAAO,CAACA,QAAQ,CAACT,MAAM,EAAE;IACvBvC,IAAI,GAAGA,IAAI,CAACoB,UAAU;IACtB,IAAI,CAACpB,IAAI,EAAE;IACXgD,QAAQ,GAAGhD,IAAI,CAACgD,QAAQ;EAC1B;EACA,OAAOA,QAAQ;AACjB"}
@@ -1,4 +1,16 @@
1
- import * as _t from "@babel/types";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.arrowFunctionToExpression = arrowFunctionToExpression;
7
+ exports.ensureBlock = ensureBlock;
8
+ exports.toComputedKey = toComputedKey;
9
+ exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
10
+ var _t = require("@babel/types");
11
+ var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
12
+ var _helperFunctionName = require("@babel/helper-function-name");
13
+ var _visitors = require("../visitors");
2
14
  const {
3
15
  arrowFunctionExpression,
4
16
  assignmentExpression,
@@ -26,10 +38,7 @@ const {
26
38
  toExpression,
27
39
  unaryExpression
28
40
  } = _t;
29
- import environmentVisitor from "@babel/helper-environment-visitor";
30
- import nameFunction from "@babel/helper-function-name";
31
- import { merge as mergeVisitors } from "../visitors.js";
32
- export function toComputedKey() {
41
+ function toComputedKey() {
33
42
  let key;
34
43
  if (this.isMemberExpression()) {
35
44
  key = this.node.property;
@@ -43,7 +52,7 @@ export function toComputedKey() {
43
52
  }
44
53
  return key;
45
54
  }
46
- export function ensureBlock() {
55
+ function ensureBlock() {
47
56
  const body = this.get("body");
48
57
  const bodyNode = body.node;
49
58
  if (Array.isArray(body)) {
@@ -78,11 +87,15 @@ export function ensureBlock() {
78
87
  body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
79
88
  return this.node;
80
89
  }
81
- export function arrowFunctionToShadowed() {
82
- if (!this.isArrowFunctionExpression()) return;
83
- this.arrowFunctionToExpression();
90
+ {
91
+ {
92
+ exports.arrowFunctionToShadowed = function () {
93
+ if (!this.isArrowFunctionExpression()) return;
94
+ this.arrowFunctionToExpression();
95
+ };
96
+ }
84
97
  }
85
- export function unwrapFunctionEnvironment() {
98
+ function unwrapFunctionEnvironment() {
86
99
  if (!this.isArrowFunctionExpression() && !this.isFunctionExpression() && !this.isFunctionDeclaration()) {
87
100
  throw this.buildCodeFrameError("Can only unwrap the environment of a function.");
88
101
  }
@@ -91,11 +104,13 @@ export function unwrapFunctionEnvironment() {
91
104
  function setType(path, type) {
92
105
  path.node.type = type;
93
106
  }
94
- export function arrowFunctionToExpression({
107
+ function arrowFunctionToExpression({
95
108
  allowInsertArrow = true,
96
109
  allowInsertArrowWithRest = allowInsertArrow,
97
- specCompliant = false,
98
- noNewArrows = !specCompliant
110
+ noNewArrows = !(() => {
111
+ var _arguments$;
112
+ return (_arguments$ = arguments[0]) == null ? void 0 : _arguments$.specCompliant;
113
+ })()
99
114
  } = {}) {
100
115
  if (!this.isArrowFunctionExpression()) {
101
116
  throw this.buildCodeFrameError("Cannot convert non-arrow function to a function expression.");
@@ -115,19 +130,19 @@ export function arrowFunctionToExpression({
115
130
  });
116
131
  }
117
132
  fn.get("body").unshiftContainer("body", expressionStatement(callExpression(this.hub.addHelper("newArrowCheck"), [thisExpression(), checkBinding ? identifier(checkBinding.name) : identifier(thisBinding)])));
118
- fn.replaceWith(callExpression(memberExpression(nameFunction(this, true) || fn.node, identifier("bind")), [checkBinding ? identifier(checkBinding.name) : thisExpression()]));
133
+ fn.replaceWith(callExpression(memberExpression((0, _helperFunctionName.default)(this, true) || fn.node, identifier("bind")), [checkBinding ? identifier(checkBinding.name) : thisExpression()]));
119
134
  return fn.get("callee.object");
120
135
  }
121
136
  return fn;
122
137
  }
123
- const getSuperCallsVisitor = mergeVisitors([{
138
+ const getSuperCallsVisitor = (0, _visitors.merge)([{
124
139
  CallExpression(child, {
125
140
  allSuperCalls
126
141
  }) {
127
142
  if (!child.get("callee").isSuper()) return;
128
143
  allSuperCalls.push(child);
129
144
  }
130
- }, environmentVisitor]);
145
+ }, _helperEnvironmentVisitor.default]);
131
146
  function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow = true, allowInsertArrowWithRest = true) {
132
147
  let arrowParent;
133
148
  let thisEnvFn = fnPath.findParent(p => {
@@ -314,7 +329,7 @@ function standardizeSuperProperty(superProp) {
314
329
  function hasSuperClass(thisEnvFn) {
315
330
  return thisEnvFn.isClassMethod() && !!thisEnvFn.parentPath.parentPath.node.superClass;
316
331
  }
317
- const assignSuperThisVisitor = mergeVisitors([{
332
+ const assignSuperThisVisitor = (0, _visitors.merge)([{
318
333
  CallExpression(child, {
319
334
  supers,
320
335
  thisBinding
@@ -324,7 +339,7 @@ const assignSuperThisVisitor = mergeVisitors([{
324
339
  supers.add(child.node);
325
340
  child.replaceWithMultiple([child.node, assignmentExpression("=", identifier(thisBinding), identifier("this"))]);
326
341
  }
327
- }, environmentVisitor]);
342
+ }, _helperEnvironmentVisitor.default]);
328
343
  function getThisBinding(thisEnvFn, inConstructor) {
329
344
  return getBinding(thisEnvFn, "this", thisBinding => {
330
345
  if (!inConstructor || !hasSuperClass(thisEnvFn)) return thisExpression();
@@ -374,7 +389,7 @@ function getBinding(thisEnvFn, key, init) {
374
389
  }
375
390
  return data;
376
391
  }
377
- const getScopeInformationVisitor = mergeVisitors([{
392
+ const getScopeInformationVisitor = (0, _visitors.merge)([{
378
393
  ThisExpression(child, {
379
394
  thisPaths
380
395
  }) {
@@ -432,7 +447,7 @@ const getScopeInformationVisitor = mergeVisitors([{
432
447
  })) return;
433
448
  newTargetPaths.push(child);
434
449
  }
435
- }, environmentVisitor]);
450
+ }, _helperEnvironmentVisitor.default]);
436
451
  function getScopeInformation(fnPath) {
437
452
  const thisPaths = [];
438
453
  const argumentsPaths = [];