@babel/traverse 7.27.1 → 7.27.3
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/scope/binding.js.map +1 -1
- package/lib/visitors.js +1 -1
- package/package.json +6 -6
package/lib/scope/binding.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Binding","constructor","identifier","scope","path","kind","constantViolations","constant","referencePaths","referenced","references","isInitInLoop","reassign","clearValue","deoptValue","hasDeoptedValue","setValue","value","hasValue","includes","push","reference","dereference","exports","default","isFunctionDeclarationOrHasInit","isVariableDeclarator","node","init","parentPath","key","isFunctionParent","isForXStatement","isLoop"],"sources":["../../src/scope/binding.ts"],"sourcesContent":["import type NodePath from \"../path/index.ts\";\nimport type * as t from \"@babel/types\";\nimport type Scope from \"./index.ts\";\n\nexport type BindingKind =\n | \"var\" /* var declarator */\n | \"let\" /* let declarator, class declaration id, catch clause parameters */\n | \"const\" /* const/using declarator */\n | \"module\" /* import specifiers */\n | \"hoisted\" /* function declaration id */\n | \"param\" /* function declaration parameters */\n | \"local\" /* function expression id, class expression id */\n | \"unknown\"; /* export specifiers */\n/**\n * This class is responsible for a binding inside of a scope.\n *\n * It tracks the following:\n *\n * * Node path.\n * * Amount of times referenced by other nodes.\n * * Paths to nodes that reassign or modify this binding.\n * * The kind of binding. (Is it a parameter, declaration etc)\n */\n\nexport default class Binding {\n identifier: t.Identifier;\n scope: Scope;\n path: NodePath;\n kind: BindingKind;\n\n constructor({\n identifier,\n scope,\n path,\n kind,\n }: {\n identifier: t.Identifier;\n scope: Scope;\n path: NodePath;\n kind: BindingKind;\n }) {\n this.identifier = identifier;\n this.scope = scope;\n this.path = path;\n this.kind = kind;\n\n if ((kind === \"var\" || kind === \"hoisted\") && isInitInLoop(path)) {\n this.reassign(path);\n }\n\n this.clearValue();\n }\n\n constantViolations: Array<NodePath> = [];\n constant: boolean = true;\n\n referencePaths: Array<NodePath> = [];\n referenced: boolean = false;\n references: number = 0;\n\n declare hasDeoptedValue: boolean;\n declare hasValue: boolean;\n declare value: any;\n\n deoptValue() {\n this.clearValue();\n this.hasDeoptedValue = true;\n }\n\n setValue(value: any) {\n if (this.hasDeoptedValue) return;\n this.hasValue = true;\n this.value = value;\n }\n\n clearValue() {\n this.hasDeoptedValue = false;\n this.hasValue = false;\n this.value = null;\n }\n\n /**\n * Register a constant violation with the provided `path`.\n */\n\n reassign(path: NodePath) {\n this.constant = false;\n if (this.constantViolations.includes(path)) {\n return;\n }\n this.constantViolations.push(path);\n }\n\n /**\n * Increment the amount of references to this binding.\n */\n\n reference(path: NodePath) {\n if (this.referencePaths.includes(path)) {\n return;\n }\n this.referenced = true;\n this.references++;\n this.referencePaths.push(path);\n }\n\n /**\n * Decrement the amount of references to this binding.\n */\n\n dereference() {\n this.references--;\n this.referenced = !!this.references;\n }\n}\n\nfunction isInitInLoop(path: NodePath) {\n const isFunctionDeclarationOrHasInit =\n !path.isVariableDeclarator() || path.node.init;\n for (\n let { parentPath, key } = path;\n parentPath;\n { parentPath, key } = parentPath\n ) {\n if (parentPath.isFunctionParent()) return false;\n if (\n (key === \"left\" && parentPath.isForXStatement()) ||\n (isFunctionDeclarationOrHasInit && key === \"body\" && parentPath.isLoop())\n ) {\n return true;\n }\n }\n return false;\n}\n"],"mappings":";;;;;;AAwBe,MAAMA,OAAO,CAAC;EAM3BC,WAAWA,CAAC;IACVC,UAAU;IACVC,KAAK;IACLC,IAAI;IACJC;EAMF,CAAC,EAAE;IAAA,KAfHH,UAAU;IAAA,KACVC,KAAK;IAAA,KACLC,IAAI;IAAA,KACJC,IAAI;IAAA,KAyBJC,kBAAkB,GAAoB,EAAE;IAAA,KACxCC,QAAQ,GAAY,IAAI;IAAA,KAExBC,cAAc,GAAoB,EAAE;IAAA,KACpCC,UAAU,GAAY,KAAK;IAAA,KAC3BC,UAAU,GAAW,CAAC;IAjBpB,IAAI,CAACR,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,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CAAC,IAAI,CAACC,UAAU;EACrC;AACF;AAACa,OAAA,CAAAC,OAAA,GAAAxB,OAAA;AAED,SAASW,YAAYA,CAACP,IAAc,EAAE;EACpC,MAAMqB,8BAA8B,GAClC,CAACrB,IAAI,CAACsB,oBAAoB,CAAC,CAAC,IAAItB,IAAI,CAACuB,IAAI,CAACC,IAAI;EAChD,KACE,IAAI;IAAEC,UAAU;IAAEC;EAAI,CAAC,GAAG1B,IAAI,EAC9ByB,UAAU,EACV;IAAEA,UAAU;IAAEC;EAAI,CAAC,GAAGD,UAAU,EAChC;IACA,IAAIA,UAAU,CAACE,gBAAgB,CAAC,CAAC,EAAE,OAAO,KAAK;IAC/C,IACGD,GAAG,KAAK,MAAM,IAAID,UAAU,CAACG,eAAe,CAAC,CAAC,IAC9CP,8BAA8B,IAAIK,GAAG,KAAK,MAAM,IAAID,UAAU,CAACI,MAAM,CAAC,CAAE,EACzE;MACA,OAAO,IAAI;IACb;EACF;EACA,OAAO,KAAK;AACd","ignoreList":[]}
|
1
|
+
{"version":3,"names":["Binding","constructor","identifier","scope","path","kind","constantViolations","constant","referencePaths","referenced","references","isInitInLoop","reassign","clearValue","deoptValue","hasDeoptedValue","setValue","value","hasValue","includes","push","reference","dereference","exports","default","isFunctionDeclarationOrHasInit","isVariableDeclarator","node","init","parentPath","key","isFunctionParent","isForXStatement","isLoop"],"sources":["../../src/scope/binding.ts"],"sourcesContent":["import type NodePath from \"../path/index.ts\";\nimport type * as t from \"@babel/types\";\nimport type Scope from \"./index.ts\";\n\nexport type BindingKind =\n | \"var\" /* var declarator */\n | \"let\" /* let declarator, class declaration id, catch clause parameters */\n | \"const\" /* const/using/await using declarator */\n | \"module\" /* import specifiers */\n | \"hoisted\" /* function declaration id */\n | \"param\" /* function declaration parameters */\n | \"local\" /* function expression id, class expression id */\n | \"unknown\"; /* export specifiers */\n/**\n * This class is responsible for a binding inside of a scope.\n *\n * It tracks the following:\n *\n * * Node path.\n * * Amount of times referenced by other nodes.\n * * Paths to nodes that reassign or modify this binding.\n * * The kind of binding. (Is it a parameter, declaration etc)\n */\n\nexport default class Binding {\n identifier: t.Identifier;\n scope: Scope;\n path: NodePath;\n kind: BindingKind;\n\n constructor({\n identifier,\n scope,\n path,\n kind,\n }: {\n identifier: t.Identifier;\n scope: Scope;\n path: NodePath;\n kind: BindingKind;\n }) {\n this.identifier = identifier;\n this.scope = scope;\n this.path = path;\n this.kind = kind;\n\n if ((kind === \"var\" || kind === \"hoisted\") && isInitInLoop(path)) {\n this.reassign(path);\n }\n\n this.clearValue();\n }\n\n constantViolations: Array<NodePath> = [];\n constant: boolean = true;\n\n referencePaths: Array<NodePath> = [];\n referenced: boolean = false;\n references: number = 0;\n\n declare hasDeoptedValue: boolean;\n declare hasValue: boolean;\n declare value: any;\n\n deoptValue() {\n this.clearValue();\n this.hasDeoptedValue = true;\n }\n\n setValue(value: any) {\n if (this.hasDeoptedValue) return;\n this.hasValue = true;\n this.value = value;\n }\n\n clearValue() {\n this.hasDeoptedValue = false;\n this.hasValue = false;\n this.value = null;\n }\n\n /**\n * Register a constant violation with the provided `path`.\n */\n\n reassign(path: NodePath) {\n this.constant = false;\n if (this.constantViolations.includes(path)) {\n return;\n }\n this.constantViolations.push(path);\n }\n\n /**\n * Increment the amount of references to this binding.\n */\n\n reference(path: NodePath) {\n if (this.referencePaths.includes(path)) {\n return;\n }\n this.referenced = true;\n this.references++;\n this.referencePaths.push(path);\n }\n\n /**\n * Decrement the amount of references to this binding.\n */\n\n dereference() {\n this.references--;\n this.referenced = !!this.references;\n }\n}\n\nfunction isInitInLoop(path: NodePath) {\n const isFunctionDeclarationOrHasInit =\n !path.isVariableDeclarator() || path.node.init;\n for (\n let { parentPath, key } = path;\n parentPath;\n { parentPath, key } = parentPath\n ) {\n if (parentPath.isFunctionParent()) return false;\n if (\n (key === \"left\" && parentPath.isForXStatement()) ||\n (isFunctionDeclarationOrHasInit && key === \"body\" && parentPath.isLoop())\n ) {\n return true;\n }\n }\n return false;\n}\n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,CAAC,EAAE;MAC1C;IACF;IACA,IAAI,CAACE,kBAAkB,CAACc,IAAI,CAAChB,IAAI,CAAC;EACpC;EAMAiB,SAASA,CAACjB,IAAc,EAAE;IACxB,IAAI,IAAI,CAACI,cAAc,CAACW,QAAQ,CAACf,IAAI,CAAC,EAAE;MACtC;IACF;IACA,IAAI,CAACK,UAAU,GAAG,IAAI;IACtB,IAAI,CAACC,UAAU,EAAE;IACjB,IAAI,CAACF,cAAc,CAACY,IAAI,CAAChB,IAAI,CAAC;EAChC;EAMAkB,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACZ,UAAU,EAAE;IACjB,IAAI,CAACD,UAAU,GAAG,CAAC,CAAC,IAAI,CAACC,UAAU;EACrC;AACF;AAACa,OAAA,CAAAC,OAAA,GAAAxB,OAAA;AAED,SAASW,YAAYA,CAACP,IAAc,EAAE;EACpC,MAAMqB,8BAA8B,GAClC,CAACrB,IAAI,CAACsB,oBAAoB,CAAC,CAAC,IAAItB,IAAI,CAACuB,IAAI,CAACC,IAAI;EAChD,KACE,IAAI;IAAEC,UAAU;IAAEC;EAAI,CAAC,GAAG1B,IAAI,EAC9ByB,UAAU,EACV;IAAEA,UAAU;IAAEC;EAAI,CAAC,GAAGD,UAAU,EAChC;IACA,IAAIA,UAAU,CAACE,gBAAgB,CAAC,CAAC,EAAE,OAAO,KAAK;IAC/C,IACGD,GAAG,KAAK,MAAM,IAAID,UAAU,CAACG,eAAe,CAAC,CAAC,IAC9CP,8BAA8B,IAAIK,GAAG,KAAK,MAAM,IAAID,UAAU,CAACI,MAAM,CAAC,CAAE,EACzE;MACA,OAAO,IAAI;IACb;EACF;EACA,OAAO,KAAK;AACd","ignoreList":[]}
|
package/lib/visitors.js
CHANGED
@@ -104,7 +104,7 @@ function verify$1(visitor) {
|
|
104
104
|
}
|
105
105
|
if (shouldIgnoreKey(nodeType)) continue;
|
106
106
|
if (!TYPES.includes(nodeType)) {
|
107
|
-
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.27.
|
107
|
+
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.27.3"}`);
|
108
108
|
}
|
109
109
|
const visitors = visitor[nodeType];
|
110
110
|
if (typeof visitors === "object") {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babel/traverse",
|
3
|
-
"version": "7.27.
|
3
|
+
"version": "7.27.3",
|
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,15 +17,15 @@
|
|
17
17
|
"main": "./lib/index.js",
|
18
18
|
"dependencies": {
|
19
19
|
"@babel/code-frame": "^7.27.1",
|
20
|
-
"@babel/generator": "^7.27.
|
21
|
-
"@babel/parser": "^7.27.
|
22
|
-
"@babel/template": "^7.27.
|
23
|
-
"@babel/types": "^7.27.
|
20
|
+
"@babel/generator": "^7.27.3",
|
21
|
+
"@babel/parser": "^7.27.3",
|
22
|
+
"@babel/template": "^7.27.2",
|
23
|
+
"@babel/types": "^7.27.3",
|
24
24
|
"debug": "^4.3.1",
|
25
25
|
"globals": "^11.1.0"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
|
-
"@babel/core": "^7.27.
|
28
|
+
"@babel/core": "^7.27.3",
|
29
29
|
"@babel/helper-plugin-test-runner": "^7.27.1"
|
30
30
|
},
|
31
31
|
"engines": {
|