@babel/traverse 7.23.5 → 7.23.7

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.
@@ -36,8 +36,10 @@ function _removeFromScope() {
36
36
  Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
37
37
  }
38
38
  function _callRemovalHooks() {
39
- for (const fn of _removalHooks.hooks) {
40
- if (fn(this, this.parentPath)) return true;
39
+ if (this.parentPath) {
40
+ for (const fn of _removalHooks.hooks) {
41
+ if (fn(this, this.parentPath)) return true;
42
+ }
41
43
  }
42
44
  }
43
45
  function _remove() {
@@ -1 +1 @@
1
- {"version":3,"names":["_removalHooks","require","_cache","_index","_t","getBindingIdentifiers","remove","_this$opts","_assertUnremoved","resync","opts","noScope","_removeFromScope","_callRemovalHooks","_markRemoved","shareCommentsWithSiblings","_remove","bindings","node","Object","keys","forEach","name","scope","removeBinding","fn","hooks","parentPath","Array","isArray","container","splice","key","updateSiblingKeys","_replaceWith","_traverseFlags","SHOULD_SKIP","REMOVED","parent","getCachedPaths","hub","delete","removed","buildCodeFrameError"],"sources":["../../src/path/removal.ts"],"sourcesContent":["// This file contains methods responsible for removing a node.\n\nimport { hooks } from \"./lib/removal-hooks.ts\";\nimport { getCachedPaths } from \"../cache.ts\";\nimport type NodePath from \"./index.ts\";\nimport { REMOVED, SHOULD_SKIP } from \"./index.ts\";\nimport { getBindingIdentifiers } from \"@babel/types\";\n\nexport function remove(this: NodePath) {\n this._assertUnremoved();\n\n this.resync();\n if (!this.opts?.noScope) {\n this._removeFromScope();\n }\n\n if (this._callRemovalHooks()) {\n this._markRemoved();\n return;\n }\n\n this.shareCommentsWithSiblings();\n this._remove();\n this._markRemoved();\n}\n\nexport function _removeFromScope(this: NodePath) {\n const bindings = getBindingIdentifiers(this.node, false, false, true);\n Object.keys(bindings).forEach(name => this.scope.removeBinding(name));\n}\n\nexport function _callRemovalHooks(this: NodePath) {\n for (const fn of hooks) {\n if (fn(this, this.parentPath)) return true;\n }\n}\n\nexport function _remove(this: NodePath) {\n if (Array.isArray(this.container)) {\n this.container.splice(this.key as number, 1);\n this.updateSiblingKeys(this.key as number, -1);\n } else {\n this._replaceWith(null);\n }\n}\n\nexport function _markRemoved(this: NodePath) {\n // this.shouldSkip = true; this.removed = true;\n this._traverseFlags |= SHOULD_SKIP | REMOVED;\n if (this.parent) {\n getCachedPaths(this.hub, this.parent).delete(this.node);\n }\n this.node = null;\n}\n\nexport function _assertUnremoved(this: NodePath) {\n if (this.removed) {\n throw this.buildCodeFrameError(\n \"NodePath has been removed so is read-only.\",\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,EAAA,GAAAH,OAAA;AAAqD;EAA5CI;AAAqB,IAAAD,EAAA;AAEvB,SAASE,MAAMA,CAAA,EAAiB;EAAA,IAAAC,UAAA;EACrC,IAAI,CAACC,gBAAgB,CAAC,CAAC;EAEvB,IAAI,CAACC,MAAM,CAAC,CAAC;EACb,IAAI,GAAAF,UAAA,GAAC,IAAI,CAACG,IAAI,aAATH,UAAA,CAAWI,OAAO,GAAE;IACvB,IAAI,CAACC,gBAAgB,CAAC,CAAC;EACzB;EAEA,IAAI,IAAI,CAACC,iBAAiB,CAAC,CAAC,EAAE;IAC5B,IAAI,CAACC,YAAY,CAAC,CAAC;IACnB;EACF;EAEA,IAAI,CAACC,yBAAyB,CAAC,CAAC;EAChC,IAAI,CAACC,OAAO,CAAC,CAAC;EACd,IAAI,CAACF,YAAY,CAAC,CAAC;AACrB;AAEO,SAASF,gBAAgBA,CAAA,EAAiB;EAC/C,MAAMK,QAAQ,GAAGZ,qBAAqB,CAAC,IAAI,CAACa,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC;EACrEC,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAACI,OAAO,CAACC,IAAI,IAAI,IAAI,CAACC,KAAK,CAACC,aAAa,CAACF,IAAI,CAAC,CAAC;AACvE;AAEO,SAAST,iBAAiBA,CAAA,EAAiB;EAChD,KAAK,MAAMY,EAAE,IAAIC,mBAAK,EAAE;IACtB,IAAID,EAAE,CAAC,IAAI,EAAE,IAAI,CAACE,UAAU,CAAC,EAAE,OAAO,IAAI;EAC5C;AACF;AAEO,SAASX,OAAOA,CAAA,EAAiB;EACtC,IAAIY,KAAK,CAACC,OAAO,CAAC,IAAI,CAACC,SAAS,CAAC,EAAE;IACjC,IAAI,CAACA,SAAS,CAACC,MAAM,CAAC,IAAI,CAACC,GAAG,EAAY,CAAC,CAAC;IAC5C,IAAI,CAACC,iBAAiB,CAAC,IAAI,CAACD,GAAG,EAAY,CAAC,CAAC,CAAC;EAChD,CAAC,MAAM;IACL,IAAI,CAACE,YAAY,CAAC,IAAI,CAAC;EACzB;AACF;AAEO,SAASpB,YAAYA,CAAA,EAAiB;EAE3C,IAAI,CAACqB,cAAc,IAAIC,kBAAW,GAAGC,cAAO;EAC5C,IAAI,IAAI,CAACC,MAAM,EAAE;IACf,IAAAC,qBAAc,EAAC,IAAI,CAACC,GAAG,EAAE,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,CAAC,IAAI,CAACvB,IAAI,CAAC;EACzD;EACA,IAAI,CAACA,IAAI,GAAG,IAAI;AAClB;AAEO,SAASV,gBAAgBA,CAAA,EAAiB;EAC/C,IAAI,IAAI,CAACkC,OAAO,EAAE;IAChB,MAAM,IAAI,CAACC,mBAAmB,CAC5B,4CACF,CAAC;EACH;AACF"}
1
+ {"version":3,"names":["_removalHooks","require","_cache","_index","_t","getBindingIdentifiers","remove","_this$opts","_assertUnremoved","resync","opts","noScope","_removeFromScope","_callRemovalHooks","_markRemoved","shareCommentsWithSiblings","_remove","bindings","node","Object","keys","forEach","name","scope","removeBinding","parentPath","fn","hooks","Array","isArray","container","splice","key","updateSiblingKeys","_replaceWith","_traverseFlags","SHOULD_SKIP","REMOVED","parent","getCachedPaths","hub","delete","removed","buildCodeFrameError"],"sources":["../../src/path/removal.ts"],"sourcesContent":["// This file contains methods responsible for removing a node.\n\nimport { hooks } from \"./lib/removal-hooks.ts\";\nimport { getCachedPaths } from \"../cache.ts\";\nimport type NodePath from \"./index.ts\";\nimport { REMOVED, SHOULD_SKIP } from \"./index.ts\";\nimport { getBindingIdentifiers } from \"@babel/types\";\n\nexport function remove(this: NodePath) {\n this._assertUnremoved();\n\n this.resync();\n if (!this.opts?.noScope) {\n this._removeFromScope();\n }\n\n if (this._callRemovalHooks()) {\n this._markRemoved();\n return;\n }\n\n this.shareCommentsWithSiblings();\n this._remove();\n this._markRemoved();\n}\n\nexport function _removeFromScope(this: NodePath) {\n const bindings = getBindingIdentifiers(this.node, false, false, true);\n Object.keys(bindings).forEach(name => this.scope.removeBinding(name));\n}\n\nexport function _callRemovalHooks(this: NodePath) {\n if (this.parentPath) {\n for (const fn of hooks) {\n if (fn(this, this.parentPath)) return true;\n }\n }\n}\n\nexport function _remove(this: NodePath) {\n if (Array.isArray(this.container)) {\n this.container.splice(this.key as number, 1);\n this.updateSiblingKeys(this.key as number, -1);\n } else {\n this._replaceWith(null);\n }\n}\n\nexport function _markRemoved(this: NodePath) {\n // this.shouldSkip = true; this.removed = true;\n this._traverseFlags |= SHOULD_SKIP | REMOVED;\n if (this.parent) {\n getCachedPaths(this.hub, this.parent).delete(this.node);\n }\n this.node = null;\n}\n\nexport function _assertUnremoved(this: NodePath) {\n if (this.removed) {\n throw this.buildCodeFrameError(\n \"NodePath has been removed so is read-only.\",\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,EAAA,GAAAH,OAAA;AAAqD;EAA5CI;AAAqB,IAAAD,EAAA;AAEvB,SAASE,MAAMA,CAAA,EAAiB;EAAA,IAAAC,UAAA;EAC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B,YAAYA,CAAA,EAAiB;EAE3C,IAAI,CAACqB,cAAc,IAAIC,kBAAW,GAAGC,cAAO;EAC5C,IAAI,IAAI,CAACC,MAAM,EAAE;IACf,IAAAC,qBAAc,EAAC,IAAI,CAACC,GAAG,EAAE,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,CAAC,IAAI,CAACvB,IAAI,CAAC;EACzD;EACA,IAAI,CAACA,IAAI,GAAG,IAAI;AAClB;AAEO,SAASV,gBAAgBA,CAAA,EAAiB;EAC/C,IAAI,IAAI,CAACkC,OAAO,EAAE;IAChB,MAAM,IAAI,CAACC,mBAAmB,CAC5B,4CACF,CAAC;EACH;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.23.5",
3
+ "version": "7.23.7",
4
4
  "description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
5
5
  "author": "The Babel Team (https://babel.dev/team)",
6
6
  "homepage": "https://babel.dev/docs/en/next/babel-traverse",
@@ -17,18 +17,18 @@
17
17
  "main": "./lib/index.js",
18
18
  "dependencies": {
19
19
  "@babel/code-frame": "^7.23.5",
20
- "@babel/generator": "^7.23.5",
20
+ "@babel/generator": "^7.23.6",
21
21
  "@babel/helper-environment-visitor": "^7.22.20",
22
22
  "@babel/helper-function-name": "^7.23.0",
23
23
  "@babel/helper-hoist-variables": "^7.22.5",
24
24
  "@babel/helper-split-export-declaration": "^7.22.6",
25
- "@babel/parser": "^7.23.5",
26
- "@babel/types": "^7.23.5",
27
- "debug": "^4.1.0",
25
+ "@babel/parser": "^7.23.6",
26
+ "@babel/types": "^7.23.6",
27
+ "debug": "^4.3.1",
28
28
  "globals": "^11.1.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/core": "^7.23.5",
31
+ "@babel/core": "^7.23.7",
32
32
  "@babel/helper-plugin-test-runner": "^7.22.5"
33
33
  },
34
34
  "engines": {