@babel/traverse 7.20.12 → 7.21.0
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["arrowFunctionExpression","assertExpression","assignmentExpression","blockStatement","callExpression","cloneNode","expressionStatement","isAssignmentExpression","isCallExpression","isExportNamedDeclaration","isExpression","isIdentifier","isSequenceExpression","isSuper","thisExpression","insertBefore","nodes_","_assertUnremoved","nodes","_verifyNodeList","parentPath","parent","isExpressionStatement","isLabeledStatement","isExportDefaultDeclaration","isDeclaration","isNodeType","isJSXElement","isForStatement","key","node","push","replaceExpressionWithStatements","Array","isArray","container","_containerInsertBefore","isStatementOrBlock","shouldInsertCurrentNode","expression","replaceWith","unshiftContainer","Error","_containerInsert","from","updateSiblingKeys","length","paths","splice","i","to","path","getSibling","context","queue","pushContext","contexts","_getQueueContexts","setScope","debug","maybeQueue","_containerInsertAfter","last","arr","isHiddenInSequenceExpression","expressions","isAlmostConstantAssignment","scope","left","blockScope","getBlockParent","hasOwnBinding","name","getOwnBinding","constantViolations","insertAfter","get","map","isPattern","unshift","callee","isPure","isMethod","computed","temp","generateDeclaredUidIdentifier","pushContainer","fromIndex","incrementBy","pathCache","msg","type","NodePath","listKey","setContext","verifiedNodes","replaceWithMultiple","hoist","hoister","PathHoister","run"],"sources":["../../src/path/modification.ts"],"sourcesContent":["// This file contains methods that modify the path/node in some ways.\n\nimport { path as pathCache } from \"../cache\";\nimport PathHoister from \"./lib/hoister\";\nimport NodePath from \"./index\";\nimport {\n arrowFunctionExpression,\n assertExpression,\n assignmentExpression,\n blockStatement,\n callExpression,\n cloneNode,\n expressionStatement,\n isAssignmentExpression,\n isCallExpression,\n isExportNamedDeclaration,\n isExpression,\n isIdentifier,\n isSequenceExpression,\n isSuper,\n thisExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type Scope from \"../scope\";\n\n/**\n * Insert the provided nodes before the current one.\n */\n\nexport function insertBefore(\n this: NodePath,\n nodes_: t.Node | t.Node[],\n): NodePath[] {\n this._assertUnremoved();\n\n const nodes = this._verifyNodeList(nodes_);\n\n const { parentPath, parent } = this;\n\n if (\n parentPath.isExpressionStatement() ||\n parentPath.isLabeledStatement() ||\n // https://github.com/babel/babel/issues/15293\n // When Babel transforms `export class String { field }`, the class properties plugin will inject the defineProperty\n // helper, which depends on the builtins e.g. String, Number, Symbol, etc. To prevent them from being shadowed by local\n // exports, the helper injector replaces the named export into `class _String { field }; export { _String as String }`,\n // with `parentPath` here changed to the moved ClassDeclaration, causing rare inconsistency between `parent` and `parentPath`.\n // Here we retrieve the parent type from the `parent` property. This is a temporary fix and we should revisit when\n // helpers should get injected.\n isExportNamedDeclaration(parent) ||\n (parentPath.isExportDefaultDeclaration() && this.isDeclaration())\n ) {\n return parentPath.insertBefore(nodes);\n } else if (\n (this.isNodeType(\"Expression\") && !this.isJSXElement()) ||\n (parentPath.isForStatement() && this.key === \"init\")\n ) {\n if (this.node) nodes.push(this.node);\n // @ts-expect-error todo(flow->ts): check that nodes is an array of statements\n return this.replaceExpressionWithStatements(nodes);\n } else if (Array.isArray(this.container)) {\n return this._containerInsertBefore(nodes);\n } else if (this.isStatementOrBlock()) {\n const node = this.node as t.Statement;\n const shouldInsertCurrentNode =\n node &&\n (!this.isExpressionStatement() ||\n (node as t.ExpressionStatement).expression != null);\n\n this.replaceWith(blockStatement(shouldInsertCurrentNode ? [node] : []));\n return (this as NodePath<t.BlockStatement>).unshiftContainer(\n \"body\",\n // @ts-expect-error Fixme: refine nodes to t.BlockStatement[\"body\"] when this is a BlockStatement path\n nodes,\n );\n } else {\n throw new Error(\n \"We don't know what to do with this node type. \" +\n \"We were previously a Statement but we can't fit in here?\",\n );\n }\n}\n\nexport function _containerInsert<N extends t.Node>(\n this: NodePath,\n from: number,\n nodes: N[],\n): NodePath<N>[] {\n this.updateSiblingKeys(from, nodes.length);\n\n const paths: NodePath<N>[] = [];\n\n // @ts-expect-error todo(flow->ts): this.container could be a NodePath\n this.container.splice(from, 0, ...nodes);\n for (let i = 0; i < nodes.length; i++) {\n const to = from + i;\n const path = this.getSibling(to) as NodePath<N>;\n paths.push(path);\n\n if (this.context && this.context.queue) {\n path.pushContext(this.context);\n }\n }\n\n const contexts = this._getQueueContexts();\n\n for (const path of paths) {\n path.setScope();\n path.debug(\"Inserted.\");\n\n for (const context of contexts) {\n context.maybeQueue(path, true);\n }\n }\n\n return paths;\n}\n\nexport function _containerInsertBefore<N extends t.Node>(\n this: NodePath,\n nodes: N[],\n) {\n return this._containerInsert(this.key as number, nodes);\n}\n\nexport function _containerInsertAfter<N extends t.Node>(\n this: NodePath,\n nodes: N[],\n) {\n return this._containerInsert((this.key as number) + 1, nodes);\n}\n\nconst last = <T>(arr: T[]) => arr[arr.length - 1];\n\nfunction isHiddenInSequenceExpression(path: NodePath): boolean {\n return (\n isSequenceExpression(path.parent) &&\n (last(path.parent.expressions) !== path.node ||\n isHiddenInSequenceExpression(path.parentPath))\n );\n}\n\nfunction isAlmostConstantAssignment(\n node: t.Node,\n scope: Scope,\n): node is t.AssignmentExpression & { left: t.Identifier } {\n if (!isAssignmentExpression(node) || !isIdentifier(node.left)) {\n return false;\n }\n\n // Not every scope can contain variables. For example, we might be in\n // a ClassScope either in the ClassHeritage or in a computed key.\n const blockScope = scope.getBlockParent();\n\n // If the variable is defined in the current scope and only assigned here,\n // we can be sure that its value won't change.\n return (\n blockScope.hasOwnBinding(node.left.name) &&\n blockScope.getOwnBinding(node.left.name).constantViolations.length <= 1\n );\n}\n\n/**\n * Insert the provided nodes after the current one. When inserting nodes after an\n * expression, ensure that the completion record is correct by pushing the current node.\n */\n\nexport function insertAfter(\n this: NodePath,\n nodes_: t.Node | t.Node[],\n): NodePath[] {\n this._assertUnremoved();\n\n if (this.isSequenceExpression()) {\n return last(this.get(\"expressions\")).insertAfter(nodes_);\n }\n\n const nodes = this._verifyNodeList(nodes_);\n\n const { parentPath, parent } = this;\n if (\n parentPath.isExpressionStatement() ||\n parentPath.isLabeledStatement() ||\n // see insertBefore\n isExportNamedDeclaration(parent) ||\n (parentPath.isExportDefaultDeclaration() && this.isDeclaration())\n ) {\n return parentPath.insertAfter(\n nodes.map(node => {\n // Usually after an expression we can safely insert another expression:\n // A.insertAfter(B)\n // foo = A; -> foo = (A, B);\n // If A is an expression statement, it isn't safe anymore so we need to\n // convert B to an expression statement\n // A; -> A; B // No semicolon! It could break if followed by [!\n return isExpression(node) ? expressionStatement(node) : node;\n }),\n );\n } else if (\n (this.isNodeType(\"Expression\") &&\n !this.isJSXElement() &&\n !parentPath.isJSXElement()) ||\n (parentPath.isForStatement() && this.key === \"init\")\n ) {\n if (this.node) {\n const node = this.node as t.Expression | t.VariableDeclaration;\n let { scope } = this;\n\n if (scope.path.isPattern()) {\n assertExpression(node);\n\n this.replaceWith(callExpression(arrowFunctionExpression([], node), []));\n (this.get(\"callee.body\") as NodePath<t.Expression>).insertAfter(nodes);\n return [this];\n }\n\n if (isHiddenInSequenceExpression(this)) {\n nodes.unshift(node);\n }\n // We need to preserve the value of this expression.\n else if (isCallExpression(node) && isSuper(node.callee)) {\n nodes.unshift(node);\n // `super(...)` always evaluates to `this`.\n nodes.push(thisExpression());\n } else if (isAlmostConstantAssignment(node, scope)) {\n nodes.unshift(node);\n nodes.push(cloneNode(node.left));\n } else if (scope.isPure(node, true)) {\n // Insert the nodes before rather than after; it's not observable.\n nodes.push(node);\n } else {\n // Inserting after the computed key of a method should insert the\n // temporary binding in the method's parent's scope.\n if (parentPath.isMethod({ computed: true, key: node })) {\n scope = scope.parent;\n }\n const temp = scope.generateDeclaredUidIdentifier();\n nodes.unshift(\n expressionStatement(\n // @ts-expect-error todo(flow->ts): This can be a variable\n // declaraion in the \"init\" of a for statement, but that's\n // invalid here.\n assignmentExpression(\"=\", cloneNode(temp), node),\n ),\n );\n nodes.push(expressionStatement(cloneNode(temp)));\n }\n }\n // @ts-expect-error todo(flow->ts): check that nodes is an array of statements\n return this.replaceExpressionWithStatements(nodes);\n } else if (Array.isArray(this.container)) {\n return this._containerInsertAfter(nodes);\n } else if (this.isStatementOrBlock()) {\n const node = this.node as t.Statement;\n const shouldInsertCurrentNode =\n node &&\n (!this.isExpressionStatement() ||\n (node as t.ExpressionStatement).expression != null);\n\n this.replaceWith(blockStatement(shouldInsertCurrentNode ? [node] : []));\n // @ts-expect-error Fixme: refine nodes to t.BlockStatement[\"body\"] when this is a BlockStatement path\n return this.pushContainer(\"body\", nodes);\n } else {\n throw new Error(\n \"We don't know what to do with this node type. \" +\n \"We were previously a Statement but we can't fit in here?\",\n );\n }\n}\n\n/**\n * Update all sibling node paths after `fromIndex` by `incrementBy`.\n */\n\nexport function updateSiblingKeys(\n this: NodePath,\n fromIndex: number,\n incrementBy: number,\n) {\n if (!this.parent) return;\n\n const paths = pathCache.get(this.parent);\n for (const [, path] of paths) {\n if (path.key >= fromIndex) {\n path.key += incrementBy;\n }\n }\n}\n\nexport function _verifyNodeList<N extends t.Node>(\n this: NodePath,\n nodes: N | N[],\n): N[] {\n if (!nodes) {\n return [];\n }\n\n if (!Array.isArray(nodes)) {\n nodes = [nodes];\n }\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n let msg;\n\n if (!node) {\n msg = \"has falsy node\";\n } else if (typeof node !== \"object\") {\n msg = \"contains a non-object node\";\n } else if (!node.type) {\n msg = \"without a type\";\n } else if (node instanceof NodePath) {\n msg = \"has a NodePath when it expected a raw object\";\n }\n\n if (msg) {\n const type = Array.isArray(node) ? \"array\" : typeof node;\n throw new Error(\n `Node list ${msg} with the index of ${i} and type of ${type}`,\n );\n }\n }\n\n return nodes;\n}\n\nexport function unshiftContainer<N extends t.Node, K extends keyof N & string>(\n this: NodePath<N>,\n listKey: K,\n nodes: N[K] extends (infer E)[]\n ? E | E[]\n : // todo: refine to t.Node[]\n // ? E extends t.Node\n // ? E | E[]\n // : never\n never,\n) {\n // todo: NodePaths<Nodes>\n this._assertUnremoved();\n\n // @ts-expect-error fixme\n nodes = this._verifyNodeList(nodes);\n\n // get the first path and insert our nodes before it, if it doesn't exist then it\n // doesn't matter, our nodes will be inserted anyway\n const path = NodePath.get({\n parentPath: this,\n parent: this.node,\n container: this.node[listKey] as unknown as t.Node | t.Node[],\n listKey,\n key: 0,\n }).setContext(this.context);\n\n return path._containerInsertBefore(\n // @ts-expect-error typings needed to narrow down nodes as t.Node[]\n nodes,\n );\n}\n\nexport function pushContainer<N extends t.Node, K extends keyof N & string>(\n this: NodePath<N>,\n listKey: K,\n nodes: N[K] extends (infer E)[]\n ? E | E[]\n : // todo: refine to t.Node[]\n // ? E extends t.Node\n // ? E | E[]\n // : never\n never,\n) {\n this._assertUnremoved();\n\n const verifiedNodes = this._verifyNodeList(\n // @ts-expect-error refine typings\n nodes,\n );\n\n // get an invisible path that represents the last node + 1 and replace it with our\n // nodes, effectively inlining it\n\n const container = this.node[listKey];\n const path = NodePath.get({\n parentPath: this,\n parent: this.node,\n container: container as unknown as t.Node | t.Node[],\n listKey,\n // @ts-expect-error TS cannot infer that container is t.Node[]\n key: container.length,\n }).setContext(this.context);\n\n return path.replaceWithMultiple(verifiedNodes);\n}\n\n/**\n * Hoist the current node to the highest scope possible and return a UID\n * referencing it.\n */\nexport function hoist<T extends t.Node>(\n this: NodePath<T>,\n scope: Scope = this.scope,\n) {\n const hoister = new PathHoister<T>(this, scope);\n return hoister.run();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AAgBsB;EAfpBA,uBAAuB;EACvBC,gBAAgB;EAChBC,oBAAoB;EACpBC,cAAc;EACdC,cAAc;EACdC,SAAS;EACTC,mBAAmB;EACnBC,sBAAsB;EACtBC,gBAAgB;EAChBC,wBAAwB;EACxBC,YAAY;EACZC,YAAY;EACZC,oBAAoB;EACpBC,OAAO;EACPC;AAAc;AAST,SAASC,YAAY,CAE1BC,MAAyB,EACb;EACZ,IAAI,CAACC,g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AAC,CAACgD,UAAU,CAAC,IAAI,CAACzC,OAAO,CAAC;EAE3B,OAAOF,IAAI,CAAC6C,mBAAmB,CAACD,aAAa,CAAC;AAChD;AAMO,SAASE,KAAK,CAEnB9B,KAAY,GAAG,IAAI,CAACA,KAAK,EACzB;EACA,MAAM+B,OAAO,GAAG,IAAIC,gBAAW,CAAI,IAAI,EAAEhC,KAAK,CAAC;EAC/C,OAAO+B,OAAO,CAACE,GAAG,EAAE;AACtB"}
|
1
|
+
{"version":3,"names":["arrowFunctionExpression","assertExpression","assignmentExpression","blockStatement","callExpression","cloneNode","expressionStatement","isAssignmentExpression","isCallExpression","isExportNamedDeclaration","isExpression","isIdentifier","isSequenceExpression","isSuper","thisExpression","insertBefore","nodes_","_assertUnremoved","nodes","_verifyNodeList","parentPath","parent","isExpressionStatement","isLabeledStatement","isExportDefaultDeclaration","isDeclaration","isNodeType","isJSXElement","isForStatement","key","node","push","replaceExpressionWithStatements","Array","isArray","container","_containerInsertBefore","isStatementOrBlock","shouldInsertCurrentNode","expression","replaceWith","unshiftContainer","Error","_containerInsert","from","updateSiblingKeys","length","paths","splice","i","to","path","getSibling","context","queue","pushContext","contexts","_getQueueContexts","setScope","debug","maybeQueue","_containerInsertAfter","last","arr","isHiddenInSequenceExpression","expressions","isAlmostConstantAssignment","scope","left","blockScope","getBlockParent","hasOwnBinding","name","getOwnBinding","constantViolations","insertAfter","get","map","isPattern","unshift","callee","isPure","isMethod","computed","temp","generateDeclaredUidIdentifier","pushContainer","fromIndex","incrementBy","pathCache","msg","type","NodePath","listKey","setContext","verifiedNodes","replaceWithMultiple","hoist","hoister","PathHoister","run"],"sources":["../../src/path/modification.ts"],"sourcesContent":["// This file contains methods that modify the path/node in some ways.\n\nimport { path as pathCache } from \"../cache\";\nimport PathHoister from \"./lib/hoister\";\nimport NodePath from \"./index\";\nimport {\n arrowFunctionExpression,\n assertExpression,\n assignmentExpression,\n blockStatement,\n callExpression,\n cloneNode,\n expressionStatement,\n isAssignmentExpression,\n isCallExpression,\n isExportNamedDeclaration,\n isExpression,\n isIdentifier,\n isSequenceExpression,\n isSuper,\n thisExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type Scope from \"../scope\";\n\n/**\n * Insert the provided nodes before the current one.\n */\n\nexport function insertBefore(\n this: NodePath,\n nodes_: t.Node | t.Node[],\n): NodePath[] {\n this._assertUnremoved();\n\n const nodes = this._verifyNodeList(nodes_);\n\n const { parentPath, parent } = this;\n\n if (\n parentPath.isExpressionStatement() ||\n parentPath.isLabeledStatement() ||\n // https://github.com/babel/babel/issues/15293\n // When Babel transforms `export class String { field }`, the class properties plugin will inject the defineProperty\n // helper, which depends on the builtins e.g. String, Number, Symbol, etc. To prevent them from being shadowed by local\n // exports, the helper injector replaces the named export into `class _String { field }; export { _String as String }`,\n // with `parentPath` here changed to the moved ClassDeclaration, causing rare inconsistency between `parent` and `parentPath`.\n // Here we retrieve the parent type from the `parent` property. This is a temporary fix and we should revisit when\n // helpers should get injected.\n isExportNamedDeclaration(parent) ||\n (parentPath.isExportDefaultDeclaration() && this.isDeclaration())\n ) {\n return parentPath.insertBefore(nodes);\n } else if (\n (this.isNodeType(\"Expression\") && !this.isJSXElement()) ||\n (parentPath.isForStatement() && this.key === \"init\")\n ) {\n if (this.node) nodes.push(this.node);\n // @ts-expect-error todo(flow->ts): check that nodes is an array of statements\n return this.replaceExpressionWithStatements(nodes);\n } else if (Array.isArray(this.container)) {\n return this._containerInsertBefore(nodes);\n } else if (this.isStatementOrBlock()) {\n const node = this.node as t.Statement;\n const shouldInsertCurrentNode =\n node &&\n (!this.isExpressionStatement() ||\n (node as t.ExpressionStatement).expression != null);\n\n this.replaceWith(blockStatement(shouldInsertCurrentNode ? [node] : []));\n return (this as NodePath<t.BlockStatement>).unshiftContainer(\n \"body\",\n // @ts-expect-error Fixme: refine nodes to t.BlockStatement[\"body\"] when this is a BlockStatement path\n nodes,\n );\n } else {\n throw new Error(\n \"We don't know what to do with this node type. \" +\n \"We were previously a Statement but we can't fit in here?\",\n );\n }\n}\n\nexport function _containerInsert<N extends t.Node>(\n this: NodePath,\n from: number,\n nodes: N[],\n): NodePath<N>[] {\n this.updateSiblingKeys(from, nodes.length);\n\n const paths: NodePath<N>[] = [];\n\n // @ts-expect-error todo(flow->ts): this.container could be a NodePath\n this.container.splice(from, 0, ...nodes);\n for (let i = 0; i < nodes.length; i++) {\n const to = from + i;\n const path = this.getSibling(to) as NodePath<N>;\n paths.push(path);\n\n if (this.context && this.context.queue) {\n path.pushContext(this.context);\n }\n }\n\n const contexts = this._getQueueContexts();\n\n for (const path of paths) {\n path.setScope();\n path.debug(\"Inserted.\");\n\n for (const context of contexts) {\n context.maybeQueue(path, true);\n }\n }\n\n return paths;\n}\n\nexport function _containerInsertBefore<N extends t.Node>(\n this: NodePath,\n nodes: N[],\n) {\n return this._containerInsert(this.key as number, nodes);\n}\n\nexport function _containerInsertAfter<N extends t.Node>(\n this: NodePath,\n nodes: N[],\n) {\n return this._containerInsert((this.key as number) + 1, nodes);\n}\n\nconst last = <T>(arr: T[]) => arr[arr.length - 1];\n\nfunction isHiddenInSequenceExpression(path: NodePath): boolean {\n return (\n isSequenceExpression(path.parent) &&\n (last(path.parent.expressions) !== path.node ||\n isHiddenInSequenceExpression(path.parentPath))\n );\n}\n\nfunction isAlmostConstantAssignment(\n node: t.Node,\n scope: Scope,\n): node is t.AssignmentExpression & { left: t.Identifier } {\n if (!isAssignmentExpression(node) || !isIdentifier(node.left)) {\n return false;\n }\n\n // Not every scope can contain variables. For example, we might be in\n // a ClassScope either in the ClassHeritage or in a computed key.\n const blockScope = scope.getBlockParent();\n\n // If the variable is defined in the current scope and only assigned here,\n // we can be sure that its value won't change.\n return (\n blockScope.hasOwnBinding(node.left.name) &&\n blockScope.getOwnBinding(node.left.name).constantViolations.length <= 1\n );\n}\n\n/**\n * Insert the provided nodes after the current one. When inserting nodes after an\n * expression, ensure that the completion record is correct by pushing the current node.\n */\n\nexport function insertAfter(\n this: NodePath,\n nodes_: t.Node | t.Node[],\n): NodePath[] {\n this._assertUnremoved();\n\n if (this.isSequenceExpression()) {\n return last(this.get(\"expressions\")).insertAfter(nodes_);\n }\n\n const nodes = this._verifyNodeList(nodes_);\n\n const { parentPath, parent } = this;\n if (\n parentPath.isExpressionStatement() ||\n parentPath.isLabeledStatement() ||\n // see insertBefore\n isExportNamedDeclaration(parent) ||\n (parentPath.isExportDefaultDeclaration() && this.isDeclaration())\n ) {\n return parentPath.insertAfter(\n nodes.map(node => {\n // Usually after an expression we can safely insert another expression:\n // A.insertAfter(B)\n // foo = A; -> foo = (A, B);\n // If A is an expression statement, it isn't safe anymore so we need to\n // convert B to an expression statement\n // A; -> A; B // No semicolon! It could break if followed by [!\n return isExpression(node) ? expressionStatement(node) : node;\n }),\n );\n } else if (\n (this.isNodeType(\"Expression\") &&\n !this.isJSXElement() &&\n !parentPath.isJSXElement()) ||\n (parentPath.isForStatement() && this.key === \"init\")\n ) {\n if (this.node) {\n const node = this.node as t.Expression | t.VariableDeclaration;\n let { scope } = this;\n\n if (scope.path.isPattern()) {\n assertExpression(node);\n\n this.replaceWith(callExpression(arrowFunctionExpression([], node), []));\n (this.get(\"callee.body\") as NodePath<t.Expression>).insertAfter(nodes);\n return [this];\n }\n\n if (isHiddenInSequenceExpression(this)) {\n nodes.unshift(node);\n }\n // We need to preserve the value of this expression.\n else if (isCallExpression(node) && isSuper(node.callee)) {\n nodes.unshift(node);\n // `super(...)` always evaluates to `this`.\n nodes.push(thisExpression());\n } else if (isAlmostConstantAssignment(node, scope)) {\n nodes.unshift(node);\n nodes.push(cloneNode(node.left));\n } else if (scope.isPure(node, true)) {\n // Insert the nodes before rather than after; it's not observable.\n nodes.push(node);\n } else {\n // Inserting after the computed key of a method should insert the\n // temporary binding in the method's parent's scope.\n if (parentPath.isMethod({ computed: true, key: node })) {\n scope = scope.parent;\n }\n const temp = scope.generateDeclaredUidIdentifier();\n nodes.unshift(\n expressionStatement(\n // @ts-expect-error todo(flow->ts): This can be a variable\n // declaration in the \"init\" of a for statement, but that's\n // invalid here.\n assignmentExpression(\"=\", cloneNode(temp), node),\n ),\n );\n nodes.push(expressionStatement(cloneNode(temp)));\n }\n }\n // @ts-expect-error todo(flow->ts): check that nodes is an array of statements\n return this.replaceExpressionWithStatements(nodes);\n } else if (Array.isArray(this.container)) {\n return this._containerInsertAfter(nodes);\n } else if (this.isStatementOrBlock()) {\n const node = this.node as t.Statement;\n const shouldInsertCurrentNode =\n node &&\n (!this.isExpressionStatement() ||\n (node as t.ExpressionStatement).expression != null);\n\n this.replaceWith(blockStatement(shouldInsertCurrentNode ? [node] : []));\n // @ts-expect-error Fixme: refine nodes to t.BlockStatement[\"body\"] when this is a BlockStatement path\n return this.pushContainer(\"body\", nodes);\n } else {\n throw new Error(\n \"We don't know what to do with this node type. \" +\n \"We were previously a Statement but we can't fit in here?\",\n );\n }\n}\n\n/**\n * Update all sibling node paths after `fromIndex` by `incrementBy`.\n */\n\nexport function updateSiblingKeys(\n this: NodePath,\n fromIndex: number,\n incrementBy: number,\n) {\n if (!this.parent) return;\n\n const paths = pathCache.get(this.parent);\n for (const [, path] of paths) {\n if (path.key >= fromIndex) {\n path.key += incrementBy;\n }\n }\n}\n\nexport function _verifyNodeList<N extends t.Node>(\n this: NodePath,\n nodes: N | N[],\n): N[] {\n if (!nodes) {\n return [];\n }\n\n if (!Array.isArray(nodes)) {\n nodes = [nodes];\n }\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n let msg;\n\n if (!node) {\n msg = \"has falsy node\";\n } else if (typeof node !== \"object\") {\n msg = \"contains a non-object node\";\n } else if (!node.type) {\n msg = \"without a type\";\n } else if (node instanceof NodePath) {\n msg = \"has a NodePath when it expected a raw object\";\n }\n\n if (msg) {\n const type = Array.isArray(node) ? \"array\" : typeof node;\n throw new Error(\n `Node list ${msg} with the index of ${i} and type of ${type}`,\n );\n }\n }\n\n return nodes;\n}\n\nexport function unshiftContainer<N extends t.Node, K extends keyof N & string>(\n this: NodePath<N>,\n listKey: K,\n nodes: N[K] extends (infer E)[]\n ? E | E[]\n : // todo: refine to t.Node[]\n // ? E extends t.Node\n // ? E | E[]\n // : never\n never,\n) {\n // todo: NodePaths<Nodes>\n this._assertUnremoved();\n\n // @ts-expect-error fixme\n nodes = this._verifyNodeList(nodes);\n\n // get the first path and insert our nodes before it, if it doesn't exist then it\n // doesn't matter, our nodes will be inserted anyway\n const path = NodePath.get({\n parentPath: this,\n parent: this.node,\n container: this.node[listKey] as unknown as t.Node | t.Node[],\n listKey,\n key: 0,\n }).setContext(this.context);\n\n return path._containerInsertBefore(\n // @ts-expect-error typings needed to narrow down nodes as t.Node[]\n nodes,\n );\n}\n\nexport function pushContainer<N extends t.Node, K extends keyof N & string>(\n this: NodePath<N>,\n listKey: K,\n nodes: N[K] extends (infer E)[]\n ? E | E[]\n : // todo: refine to t.Node[]\n // ? E extends t.Node\n // ? E | E[]\n // : never\n never,\n) {\n this._assertUnremoved();\n\n const verifiedNodes = this._verifyNodeList(\n // @ts-expect-error refine typings\n nodes,\n );\n\n // get an invisible path that represents the last node + 1 and replace it with our\n // nodes, effectively inlining it\n\n const container = this.node[listKey];\n const path = NodePath.get({\n parentPath: this,\n parent: this.node,\n container: container as unknown as t.Node | t.Node[],\n listKey,\n // @ts-expect-error TS cannot infer that container is t.Node[]\n key: container.length,\n }).setContext(this.context);\n\n return path.replaceWithMultiple(verifiedNodes);\n}\n\n/**\n * Hoist the current node to the highest scope possible and return a UID\n * referencing it.\n */\nexport function hoist<T extends t.Node>(\n this: NodePath<T>,\n scope: Scope = this.scope,\n) {\n const hoister = new PathHoister<T>(this, scope);\n return hoister.run();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AAgBsB;EAfpBA,uBAAuB;EACvBC,gBAAgB;EAChBC,oBAAoB;EACpBC,cAAc;EACdC,cAAc;EACdC,SAAS;EACTC,mBAAmB;EACnBC,sBAAsB;EACtBC,gBAAgB;EAChBC,wBA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IAChBC,MAAM,EAAE,IAAI,CAACS,IAAI;IACjBK,SAAS,EAAEA,SAAyC;IACpD0D,OAAO;IAEPhE,GAAG,EAAEM,SAAS,CAACW;EACjB,CAAC,CAAC,CAACgD,UAAU,CAAC,IAAI,CAACzC,OAAO,CAAC;EAE3B,OAAOF,IAAI,CAAC6C,mBAAmB,CAACD,aAAa,CAAC;AAChD;AAMO,SAASE,KAAK,CAEnB9B,KAAY,GAAG,IAAI,CAACA,KAAK,EACzB;EACA,MAAM+B,OAAO,GAAG,IAAIC,gBAAW,CAAI,IAAI,EAAEhC,KAAK,CAAC;EAC/C,OAAO+B,OAAO,CAACE,GAAG,EAAE;AACtB"}
|
package/lib/scope/index.js
CHANGED
@@ -396,11 +396,12 @@ class Scope {
|
|
396
396
|
throw this.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
|
397
397
|
}
|
398
398
|
}
|
399
|
-
rename(oldName, newName
|
399
|
+
rename(oldName, newName) {
|
400
400
|
const binding = this.getBinding(oldName);
|
401
401
|
if (binding) {
|
402
|
-
newName
|
403
|
-
|
402
|
+
newName || (newName = this.generateUidIdentifier(oldName).name);
|
403
|
+
const renamer = new _renamer.default(binding, oldName, newName);
|
404
|
+
return renamer.rename(arguments[2]);
|
404
405
|
}
|
405
406
|
}
|
406
407
|
_renameFromMap(map, oldName, newName, value) {
|
package/lib/scope/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NOT_LOCAL_BINDING","callExpression","cloneNode","getBindingIdentifiers","identifier","isArrayExpression","isBinary","isClass","isClassBody","isClassDeclaration","isExportAllDeclaration","isExportDefaultDeclaration","isExportNamedDeclaration","isFunctionDeclaration","isIdentifier","isImportDeclaration","isLiteral","isMethod","isModuleSpecifier","isNullLiteral","isObjectExpression","isProperty","isPureish","isRegExpLiteral","isSuper","isTaggedTemplateExpression","isTemplateLiteral","isThisExpression","isUnaryExpression","isVariableDeclaration","matchesPattern","memberExpression","numericLiteral","toIdentifier","unaryExpression","variableDeclaration","variableDeclarator","isRecordExpression","isTupleExpression","isObjectProperty","isTopicReference","isMetaProperty","isPrivateName","isExportDeclaration","gatherNodeParts","node","parts","type","source","specifiers","length","e","declaration","local","push","value","object","property","name","callee","properties","argument","key","left","id","expression","meta","openingElement","openingFragment","namespace","collectorVisitor","ForStatement","path","declar","get","isVar","scope","parentScope","getFunctionParent","getProgramParent","registerBinding","Declaration","isBlockScoped","parent","registerDeclaration","ImportDeclaration","getBlockParent","ReferencedIdentifier","state","references","ForXStatement","isPattern","constantViolations","ExportDeclaration","exit","binding","getBinding","reference","decl","declarations","Object","keys","LabeledStatement","AssignmentExpression","assignments","UpdateExpression","UnaryExpression","operator","BlockScoped","bindings","CatchClause","Function","params","param","isFunctionExpression","has","ClassExpression","uid","Scope","constructor","block","labels","inited","globals","uids","data","crawling","cached","scopeCache","set","Map","shouldSkip","listKey","parentPath","isScope","parentBlock","hub","traverse","opts","generateDeclaredUidIdentifier","generateUidIdentifier","generateUid","replace","i","_generateUid","hasLabel","hasBinding","hasGlobal","hasReference","program","generateUidBasedOnNode","defaultName","join","slice","generateUidIdentifierBasedOnNode","isStatic","constant","maybeGenerateMemoised","dontPush","checkBlockScopedCollisions","kind","duplicate","buildError","TypeError","rename","oldName","newName","Renamer","_renameFromMap","map","dump","sep","repeat","console","log","violations","toArray","arrayLikeIsIterable","isGenericType","helperName","args","unshift","addHelper","getLabel","registerLabel","label","isLabeledStatement","declare","isTypeDeclaration","importKind","specifier","isTypeSpecifier","isImportSpecifier","buildUndefinedNode","registerConstantViolation","ids","reassign","bindingPath","ReferenceError","declarators","getOuterBindingIdentifiers","getOwnBinding","Binding","addGlobal","hasUid","isPure","constantsOnly","superClass","decorators","body","method","right","elem","elements","prop","computed","static","tag","quasi","expressions","setData","val","getData","removeData","init","crawl","create","programParent","_exploded","visit","enter","typeVisitors","ref","getPatternParent","isBlockStatement","isProgram","isSwitchStatement","isLoop","isCatchClause","isFunction","ensureBlock","unique","blockHoist","_blockHoist","dataKey","declarPath","unshiftContainer","declarator","len","Error","isFunctionParent","isBlockParent","getAllBindings","getAllBindingsOfKind","kinds","bindingIdentifierEquals","getBindingIdentifier","previousPath","isArrowFunctionExpression","getOwnBindingIdentifier","hasOwnBinding","noGlobals","parentHasBinding","noUids","includes","contextVariables","moveBindingTo","info","removeOwnBinding","removeBinding","builtin"],"sources":["../../src/scope/index.ts"],"sourcesContent":["import Renamer from \"./lib/renamer\";\nimport type NodePath from \"../path\";\nimport traverse from \"../index\";\nimport type { TraverseOptions } from \"../index\";\nimport Binding from \"./binding\";\nimport type { BindingKind } from \"./binding\";\nimport globals from \"globals\";\nimport {\n NOT_LOCAL_BINDING,\n callExpression,\n cloneNode,\n getBindingIdentifiers,\n identifier,\n isArrayExpression,\n isBinary,\n isClass,\n isClassBody,\n isClassDeclaration,\n isExportAllDeclaration,\n isExportDefaultDeclaration,\n isExportNamedDeclaration,\n isFunctionDeclaration,\n isIdentifier,\n isImportDeclaration,\n isLiteral,\n isMethod,\n isModuleSpecifier,\n isNullLiteral,\n isObjectExpression,\n isProperty,\n isPureish,\n isRegExpLiteral,\n isSuper,\n isTaggedTemplateExpression,\n isTemplateLiteral,\n isThisExpression,\n isUnaryExpression,\n isVariableDeclaration,\n matchesPattern,\n memberExpression,\n numericLiteral,\n toIdentifier,\n unaryExpression,\n variableDeclaration,\n variableDeclarator,\n isRecordExpression,\n isTupleExpression,\n isObjectProperty,\n isTopicReference,\n isMetaProperty,\n isPrivateName,\n isExportDeclaration,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport { scope as scopeCache } from \"../cache\";\nimport type { Visitor } from \"../types\";\n\ntype NodePart = string | number | boolean;\n// Recursively gathers the identifying names of a node.\nfunction gatherNodeParts(node: t.Node, parts: NodePart[]) {\n switch (node?.type) {\n default:\n if (isImportDeclaration(node) || isExportDeclaration(node)) {\n if (\n (isExportAllDeclaration(node) ||\n isExportNamedDeclaration(node) ||\n isImportDeclaration(node)) &&\n node.source\n ) {\n gatherNodeParts(node.source, parts);\n } else if (\n (isExportNamedDeclaration(node) || isImportDeclaration(node)) &&\n node.specifiers &&\n node.specifiers.length\n ) {\n for (const e of node.specifiers) gatherNodeParts(e, parts);\n } else if (\n (isExportDefaultDeclaration(node) ||\n isExportNamedDeclaration(node)) &&\n node.declaration\n ) {\n gatherNodeParts(node.declaration, parts);\n }\n } else if (isModuleSpecifier(node)) {\n // todo(flow->ts): should condition instead be:\n // ```\n // t.isExportSpecifier(node) ||\n // t.isImportDefaultSpecifier(node) ||\n // t.isImportNamespaceSpecifier(node) ||\n // t.isImportSpecifier(node)\n // ```\n // allowing only nodes with `.local`?\n // @ts-expect-error todo(flow->ts)\n gatherNodeParts(node.local, parts);\n } else if (\n isLiteral(node) &&\n !isNullLiteral(node) &&\n !isRegExpLiteral(node) &&\n !isTemplateLiteral(node)\n ) {\n parts.push(node.value);\n }\n break;\n\n case \"MemberExpression\":\n case \"OptionalMemberExpression\":\n case \"JSXMemberExpression\":\n gatherNodeParts(node.object, parts);\n gatherNodeParts(node.property, parts);\n break;\n\n case \"Identifier\":\n case \"JSXIdentifier\":\n parts.push(node.name);\n break;\n\n case \"CallExpression\":\n case \"OptionalCallExpression\":\n case \"NewExpression\":\n gatherNodeParts(node.callee, parts);\n break;\n\n case \"ObjectExpression\":\n case \"ObjectPattern\":\n for (const e of node.properties) {\n gatherNodeParts(e, parts);\n }\n break;\n\n case \"SpreadElement\":\n case \"RestElement\":\n gatherNodeParts(node.argument, parts);\n break;\n\n case \"ObjectProperty\":\n case \"ObjectMethod\":\n case \"ClassProperty\":\n case \"ClassMethod\":\n case \"ClassPrivateProperty\":\n case \"ClassPrivateMethod\":\n gatherNodeParts(node.key, parts);\n break;\n\n case \"ThisExpression\":\n parts.push(\"this\");\n break;\n\n case \"Super\":\n parts.push(\"super\");\n break;\n\n case \"Import\":\n parts.push(\"import\");\n break;\n\n case \"DoExpression\":\n parts.push(\"do\");\n break;\n\n case \"YieldExpression\":\n parts.push(\"yield\");\n gatherNodeParts(node.argument, parts);\n break;\n\n case \"AwaitExpression\":\n parts.push(\"await\");\n gatherNodeParts(node.argument, parts);\n break;\n\n case \"AssignmentExpression\":\n gatherNodeParts(node.left, parts);\n break;\n\n case \"VariableDeclarator\":\n gatherNodeParts(node.id, parts);\n break;\n\n case \"FunctionExpression\":\n case \"FunctionDeclaration\":\n case \"ClassExpression\":\n case \"ClassDeclaration\":\n gatherNodeParts(node.id, parts);\n break;\n\n case \"PrivateName\":\n gatherNodeParts(node.id, parts);\n break;\n\n case \"ParenthesizedExpression\":\n gatherNodeParts(node.expression, parts);\n break;\n\n case \"UnaryExpression\":\n case \"UpdateExpression\":\n gatherNodeParts(node.argument, parts);\n break;\n\n case \"MetaProperty\":\n gatherNodeParts(node.meta, parts);\n gatherNodeParts(node.property, parts);\n break;\n\n case \"JSXElement\":\n gatherNodeParts(node.openingElement, parts);\n break;\n\n case \"JSXOpeningElement\":\n gatherNodeParts(node.name, parts);\n break;\n\n case \"JSXFragment\":\n gatherNodeParts(node.openingFragment, parts);\n break;\n\n case \"JSXOpeningFragment\":\n parts.push(\"Fragment\");\n break;\n\n case \"JSXNamespacedName\":\n gatherNodeParts(node.namespace, parts);\n gatherNodeParts(node.name, parts);\n break;\n }\n}\n\n//\ninterface CollectVisitorState {\n assignments: NodePath<t.AssignmentExpression>[];\n references: NodePath<t.Identifier | t.JSXIdentifier>[];\n constantViolations: NodePath[];\n}\n\nconst collectorVisitor: Visitor<CollectVisitorState> = {\n ForStatement(path) {\n const declar = path.get(\"init\");\n // delegate block scope handling to the `BlockScoped` method\n if (declar.isVar()) {\n const { scope } = path;\n const parentScope = scope.getFunctionParent() || scope.getProgramParent();\n parentScope.registerBinding(\"var\", declar);\n }\n },\n\n Declaration(path) {\n // delegate block scope handling to the `BlockScoped` method\n if (path.isBlockScoped()) return;\n\n // delegate import handing to the `ImportDeclaration` method\n if (path.isImportDeclaration()) return;\n\n // this will be hit again once we traverse into it after this iteration\n if (path.isExportDeclaration()) return;\n\n // we've ran into a declaration!\n const parent =\n path.scope.getFunctionParent() || path.scope.getProgramParent();\n parent.registerDeclaration(path);\n },\n\n ImportDeclaration(path) {\n // import may only appear in the top level or inside a module/namespace (for TS/flow)\n const parent = path.scope.getBlockParent();\n\n parent.registerDeclaration(path);\n },\n\n ReferencedIdentifier(path, state) {\n state.references.push(path);\n },\n\n ForXStatement(path, state) {\n const left = path.get(\"left\");\n if (left.isPattern() || left.isIdentifier()) {\n state.constantViolations.push(path);\n }\n // delegate block scope handling to the `BlockScoped` method\n else if (left.isVar()) {\n const { scope } = path;\n const parentScope = scope.getFunctionParent() || scope.getProgramParent();\n parentScope.registerBinding(\"var\", left);\n }\n },\n\n ExportDeclaration: {\n exit(path) {\n const { node, scope } = path;\n // ExportAllDeclaration does not have `declaration`\n if (isExportAllDeclaration(node)) return;\n const declar = node.declaration;\n if (isClassDeclaration(declar) || isFunctionDeclaration(declar)) {\n const id = declar.id;\n if (!id) return;\n\n const binding = scope.getBinding(id.name);\n binding?.reference(path);\n } else if (isVariableDeclaration(declar)) {\n for (const decl of declar.declarations) {\n for (const name of Object.keys(getBindingIdentifiers(decl))) {\n const binding = scope.getBinding(name);\n binding?.reference(path);\n }\n }\n }\n },\n },\n\n LabeledStatement(path) {\n path.scope.getBlockParent().registerDeclaration(path);\n },\n\n AssignmentExpression(path, state) {\n state.assignments.push(path);\n },\n\n UpdateExpression(path, state) {\n state.constantViolations.push(path);\n },\n\n UnaryExpression(path, state) {\n if (path.node.operator === \"delete\") {\n state.constantViolations.push(path);\n }\n },\n\n BlockScoped(path) {\n let scope = path.scope;\n if (scope.path === path) scope = scope.parent;\n\n const parent = scope.getBlockParent();\n parent.registerDeclaration(path);\n\n // Register class identifier in class' scope if this is a class declaration.\n if (path.isClassDeclaration() && path.node.id) {\n const id = path.node.id;\n const name = id.name;\n\n path.scope.bindings[name] = path.scope.parent.getBinding(name);\n }\n },\n\n CatchClause(path) {\n path.scope.registerBinding(\"let\", path);\n },\n\n Function(path) {\n const params: Array<NodePath> = path.get(\"params\");\n for (const param of params) {\n path.scope.registerBinding(\"param\", param);\n }\n\n // Register function expression id after params. When the id\n // collides with a function param, the id effectively can't be\n // referenced: here we registered it as a constantViolation\n if (\n path.isFunctionExpression() &&\n path.has(\"id\") &&\n // @ts-expect-error Fixme: document symbol ast properties\n !path.get(\"id\").node[NOT_LOCAL_BINDING]\n ) {\n path.scope.registerBinding(\"local\", path.get(\"id\"), path);\n }\n },\n\n ClassExpression(path) {\n if (\n path.has(\"id\") &&\n // @ts-expect-error Fixme: document symbol ast properties\n !path.get(\"id\").node[NOT_LOCAL_BINDING]\n ) {\n path.scope.registerBinding(\"local\", path);\n }\n },\n};\n\nlet uid = 0;\n\nexport type { Binding };\n\nexport default class Scope {\n uid;\n\n path: NodePath;\n block: t.Pattern | t.Scopable;\n\n labels;\n inited;\n\n bindings: { [name: string]: Binding };\n references: { [name: string]: true };\n globals: { [name: string]: t.Identifier | t.JSXIdentifier };\n uids: { [name: string]: boolean };\n data: { [key: string | symbol]: unknown };\n crawling: boolean;\n\n /**\n * This searches the current \"scope\" and collects all references/bindings\n * within.\n */\n constructor(path: NodePath<t.Pattern | t.Scopable>) {\n const { node } = path;\n const cached = scopeCache.get(node);\n // Sometimes, a scopable path is placed higher in the AST tree.\n // In these cases, have to create a new Scope.\n if (cached?.path === path) {\n return cached;\n }\n scopeCache.set(node, this);\n\n this.uid = uid++;\n\n this.block = node;\n this.path = path;\n\n this.labels = new Map();\n this.inited = false;\n }\n\n /**\n * Globals.\n */\n\n static globals = Object.keys(globals.builtin);\n\n /**\n * Variables available in current context.\n */\n\n static contextVariables = [\"arguments\", \"undefined\", \"Infinity\", \"NaN\"];\n\n get parent() {\n let parent,\n path = this.path;\n do {\n // Skip method scope if coming from inside computed key or decorator expression\n const shouldSkip = path.key === \"key\" || path.listKey === \"decorators\";\n path = path.parentPath;\n if (shouldSkip && path.isMethod()) path = path.parentPath;\n if (path && path.isScope()) parent = path;\n } while (path && !parent);\n\n return parent?.scope;\n }\n\n get parentBlock() {\n return this.path.parent;\n }\n\n get hub() {\n return this.path.hub;\n }\n\n traverse<S>(\n node: t.Node | t.Node[],\n opts: TraverseOptions<S>,\n state: S,\n ): void;\n traverse(node: t.Node | t.Node[], opts?: TraverseOptions, state?: any): void;\n /**\n * Traverse node with current scope and path.\n *\n * !!! WARNING !!!\n * This method assumes that `this.path` is the NodePath representing `node`.\n * After running the traversal, the `.parentPath` of the NodePaths\n * corresponding to `node`'s children will be set to `this.path`.\n *\n * There is no good reason to use this method, since the only safe way to use\n * it is equivalent to `scope.path.traverse(opts, state)`.\n */\n traverse<S>(node: any, opts: any, state?: S) {\n traverse(node, opts, this, state, this.path);\n }\n\n /**\n * Generate a unique identifier and add it to the current scope.\n */\n\n generateDeclaredUidIdentifier(name?: string) {\n const id = this.generateUidIdentifier(name);\n this.push({ id });\n return cloneNode(id);\n }\n\n /**\n * Generate a unique identifier.\n */\n\n generateUidIdentifier(name?: string) {\n return identifier(this.generateUid(name));\n }\n\n /**\n * Generate a unique `_id1` binding.\n */\n\n generateUid(name: string = \"temp\"): string {\n name = toIdentifier(name)\n .replace(/^_+/, \"\")\n .replace(/[0-9]+$/g, \"\");\n\n let uid;\n let i = 1;\n do {\n uid = this._generateUid(name, i);\n i++;\n } while (\n this.hasLabel(uid) ||\n this.hasBinding(uid) ||\n this.hasGlobal(uid) ||\n this.hasReference(uid)\n );\n\n const program = this.getProgramParent();\n program.references[uid] = true;\n program.uids[uid] = true;\n\n return uid;\n }\n\n /**\n * Generate an `_id1`.\n */\n\n _generateUid(name: string, i: number) {\n let id = name;\n if (i > 1) id += i;\n return `_${id}`;\n }\n\n generateUidBasedOnNode(node: t.Node, defaultName?: string) {\n const parts: NodePart[] = [];\n gatherNodeParts(node, parts);\n\n let id = parts.join(\"$\");\n id = id.replace(/^_/, \"\") || defaultName || \"ref\";\n\n return this.generateUid(id.slice(0, 20));\n }\n\n /**\n * Generate a unique identifier based on a node.\n */\n\n generateUidIdentifierBasedOnNode(node: t.Node, defaultName?: string) {\n return identifier(this.generateUidBasedOnNode(node, defaultName));\n }\n\n /**\n * Determine whether evaluating the specific input `node` is a consequenceless reference. ie.\n * evaluating it wont result in potentially arbitrary code from being ran. The following are\n * allowed and determined not to cause side effects:\n *\n * - `this` expressions\n * - `super` expressions\n * - Bound identifiers\n */\n\n isStatic(node: t.Node): boolean {\n if (isThisExpression(node) || isSuper(node) || isTopicReference(node)) {\n return true;\n }\n\n if (isIdentifier(node)) {\n const binding = this.getBinding(node.name);\n if (binding) {\n return binding.constant;\n } else {\n return this.hasBinding(node.name);\n }\n }\n\n return false;\n }\n\n /**\n * Possibly generate a memoised identifier if it is not static and has consequences.\n */\n\n maybeGenerateMemoised(node: t.Node, dontPush?: boolean) {\n if (this.isStatic(node)) {\n return null;\n } else {\n const id = this.generateUidIdentifierBasedOnNode(node);\n if (!dontPush) {\n this.push({ id });\n return cloneNode(id);\n }\n return id;\n }\n }\n\n checkBlockScopedCollisions(\n local: Binding,\n kind: BindingKind,\n name: string,\n id: any,\n ) {\n // ignore parameters\n if (kind === \"param\") return;\n\n // Ignore existing binding if it's the name of the current function or\n // class expression\n if (local.kind === \"local\") return;\n\n const duplicate =\n // don't allow duplicate bindings to exist alongside\n kind === \"let\" ||\n local.kind === \"let\" ||\n local.kind === \"const\" ||\n local.kind === \"module\" ||\n // don't allow a local of param with a kind of let\n (local.kind === \"param\" && kind === \"const\");\n\n if (duplicate) {\n throw this.hub.buildError(\n id,\n `Duplicate declaration \"${name}\"`,\n TypeError,\n );\n }\n }\n\n rename(oldName: string, newName?: string, block?: t.Pattern | t.Scopable) {\n const binding = this.getBinding(oldName);\n if (binding) {\n newName = newName || this.generateUidIdentifier(oldName).name;\n return new Renamer(binding, oldName, newName).rename(block);\n }\n }\n\n /** @deprecated Not used in our codebase */\n _renameFromMap(\n map: Record<string | symbol, unknown>,\n oldName: string | symbol,\n newName: string | symbol,\n value: unknown,\n ) {\n if (map[oldName]) {\n map[newName] = value;\n map[oldName] = null;\n }\n }\n\n dump() {\n const sep = \"-\".repeat(60);\n console.log(sep);\n let scope: Scope = this;\n do {\n console.log(\"#\", scope.block.type);\n for (const name of Object.keys(scope.bindings)) {\n const binding = scope.bindings[name];\n console.log(\" -\", name, {\n constant: binding.constant,\n references: binding.references,\n violations: binding.constantViolations.length,\n kind: binding.kind,\n });\n }\n } while ((scope = scope.parent));\n console.log(sep);\n }\n\n // TODO: (Babel 8) Split i in two parameters, and use an object of flags\n toArray(\n node: t.Node,\n i?: number | boolean,\n arrayLikeIsIterable?: boolean | void,\n ) {\n if (isIdentifier(node)) {\n const binding = this.getBinding(node.name);\n if (binding?.constant && binding.path.isGenericType(\"Array\")) {\n return node;\n }\n }\n\n if (isArrayExpression(node)) {\n return node;\n }\n\n if (isIdentifier(node, { name: \"arguments\" })) {\n return callExpression(\n memberExpression(\n memberExpression(\n memberExpression(identifier(\"Array\"), identifier(\"prototype\")),\n identifier(\"slice\"),\n ),\n identifier(\"call\"),\n ),\n [node],\n );\n }\n\n let helperName;\n const args = [node];\n if (i === true) {\n // Used in array-spread to create an array.\n helperName = \"toConsumableArray\";\n } else if (typeof i === \"number\") {\n args.push(numericLiteral(i));\n\n // Used in array-rest to create an array from a subset of an iterable.\n helperName = \"slicedToArray\";\n // TODO if (this.hub.isLoose(\"es6.forOf\")) helperName += \"-loose\";\n } else {\n // Used in array-rest to create an array\n helperName = \"toArray\";\n }\n\n if (arrayLikeIsIterable) {\n args.unshift(this.hub.addHelper(helperName));\n helperName = \"maybeArrayLike\";\n }\n\n // @ts-expect-error todo(flow->ts): t.Node is not valid to use in args, function argument typeneeds to be clarified\n return callExpression(this.hub.addHelper(helperName), args);\n }\n\n hasLabel(name: string) {\n return !!this.getLabel(name);\n }\n\n getLabel(name: string) {\n return this.labels.get(name);\n }\n\n registerLabel(path: NodePath<t.LabeledStatement>) {\n this.labels.set(path.node.label.name, path);\n }\n\n registerDeclaration(path: NodePath) {\n if (path.isLabeledStatement()) {\n this.registerLabel(path);\n } else if (path.isFunctionDeclaration()) {\n this.registerBinding(\"hoisted\", path.get(\"id\"), path);\n } else if (path.isVariableDeclaration()) {\n const declarations = path.get(\"declarations\");\n const { kind } = path.node;\n for (const declar of declarations) {\n this.registerBinding(kind === \"using\" ? \"const\" : kind, declar);\n }\n } else if (path.isClassDeclaration()) {\n if (path.node.declare) return;\n this.registerBinding(\"let\", path);\n } else if (path.isImportDeclaration()) {\n const isTypeDeclaration =\n path.node.importKind === \"type\" || path.node.importKind === \"typeof\";\n const specifiers = path.get(\"specifiers\");\n for (const specifier of specifiers) {\n const isTypeSpecifier =\n isTypeDeclaration ||\n (specifier.isImportSpecifier() &&\n (specifier.node.importKind === \"type\" ||\n specifier.node.importKind === \"typeof\"));\n\n this.registerBinding(isTypeSpecifier ? \"unknown\" : \"module\", specifier);\n }\n } else if (path.isExportDeclaration()) {\n // todo: improve babel-types\n const declar = path.get(\"declaration\") as NodePath;\n if (\n declar.isClassDeclaration() ||\n declar.isFunctionDeclaration() ||\n declar.isVariableDeclaration()\n ) {\n this.registerDeclaration(declar);\n }\n } else {\n this.registerBinding(\"unknown\", path);\n }\n }\n\n buildUndefinedNode() {\n return unaryExpression(\"void\", numericLiteral(0), true);\n }\n\n registerConstantViolation(path: NodePath) {\n const ids = path.getBindingIdentifiers();\n for (const name of Object.keys(ids)) {\n const binding = this.getBinding(name);\n if (binding) binding.reassign(path);\n }\n }\n\n registerBinding(\n kind: Binding[\"kind\"],\n path: NodePath,\n bindingPath: NodePath = path,\n ) {\n if (!kind) throw new ReferenceError(\"no `kind`\");\n\n if (path.isVariableDeclaration()) {\n const declarators: Array<NodePath> = path.get(\"declarations\");\n for (const declar of declarators) {\n this.registerBinding(kind, declar);\n }\n return;\n }\n\n const parent = this.getProgramParent();\n const ids = path.getOuterBindingIdentifiers(true);\n\n for (const name of Object.keys(ids)) {\n parent.references[name] = true;\n\n for (const id of ids[name]) {\n const local = this.getOwnBinding(name);\n\n if (local) {\n // same identifier so continue safely as we're likely trying to register it\n // multiple times\n if (local.identifier === id) continue;\n\n this.checkBlockScopedCollisions(local, kind, name, id);\n }\n\n // A redeclaration of an existing variable is a modification\n if (local) {\n this.registerConstantViolation(bindingPath);\n } else {\n this.bindings[name] = new Binding({\n identifier: id,\n scope: this,\n path: bindingPath,\n kind: kind,\n });\n }\n }\n }\n }\n\n addGlobal(node: t.Identifier | t.JSXIdentifier) {\n this.globals[node.name] = node;\n }\n\n hasUid(name: string): boolean {\n let scope: Scope = this;\n\n do {\n if (scope.uids[name]) return true;\n } while ((scope = scope.parent));\n\n return false;\n }\n\n hasGlobal(name: string): boolean {\n let scope: Scope = this;\n\n do {\n if (scope.globals[name]) return true;\n } while ((scope = scope.parent));\n\n return false;\n }\n\n hasReference(name: string): boolean {\n return !!this.getProgramParent().references[name];\n }\n\n isPure(node: t.Node, constantsOnly?: boolean): boolean {\n if (isIdentifier(node)) {\n const binding = this.getBinding(node.name);\n if (!binding) return false;\n if (constantsOnly) return binding.constant;\n return true;\n } else if (\n isThisExpression(node) ||\n isMetaProperty(node) ||\n isTopicReference(node) ||\n isPrivateName(node)\n ) {\n return true;\n } else if (isClass(node)) {\n if (node.superClass && !this.isPure(node.superClass, constantsOnly)) {\n return false;\n }\n if (node.decorators?.length > 0) {\n return false;\n }\n return this.isPure(node.body, constantsOnly);\n } else if (isClassBody(node)) {\n for (const method of node.body) {\n if (!this.isPure(method, constantsOnly)) return false;\n }\n return true;\n } else if (isBinary(node)) {\n return (\n this.isPure(node.left, constantsOnly) &&\n this.isPure(node.right, constantsOnly)\n );\n } else if (isArrayExpression(node) || isTupleExpression(node)) {\n for (const elem of node.elements) {\n if (elem !== null && !this.isPure(elem, constantsOnly)) return false;\n }\n return true;\n } else if (isObjectExpression(node) || isRecordExpression(node)) {\n for (const prop of node.properties) {\n if (!this.isPure(prop, constantsOnly)) return false;\n }\n return true;\n } else if (isMethod(node)) {\n if (node.computed && !this.isPure(node.key, constantsOnly)) return false;\n if (node.decorators?.length > 0) {\n return false;\n }\n return true;\n } else if (isProperty(node)) {\n // @ts-expect-error todo(flow->ts): computed in not present on private properties\n if (node.computed && !this.isPure(node.key, constantsOnly)) return false;\n if (node.decorators?.length > 0) {\n return false;\n }\n if (isObjectProperty(node) || node.static) {\n if (node.value !== null && !this.isPure(node.value, constantsOnly)) {\n return false;\n }\n }\n return true;\n } else if (isUnaryExpression(node)) {\n return this.isPure(node.argument, constantsOnly);\n } else if (isTaggedTemplateExpression(node)) {\n return (\n matchesPattern(node.tag, \"String.raw\") &&\n !this.hasBinding(\"String\", true) &&\n this.isPure(node.quasi, constantsOnly)\n );\n } else if (isTemplateLiteral(node)) {\n for (const expression of node.expressions) {\n if (!this.isPure(expression, constantsOnly)) return false;\n }\n return true;\n } else {\n return isPureish(node);\n }\n }\n\n /**\n * Set some arbitrary data on the current scope.\n */\n\n setData(key: string | symbol, val: any) {\n return (this.data[key] = val);\n }\n\n /**\n * Recursively walk up scope tree looking for the data `key`.\n */\n\n getData(key: string | symbol): any {\n let scope: Scope = this;\n do {\n const data = scope.data[key];\n if (data != null) return data;\n } while ((scope = scope.parent));\n }\n\n /**\n * Recursively walk up scope tree looking for the data `key` and if it exists,\n * remove it.\n */\n\n removeData(key: string) {\n let scope: Scope = this;\n do {\n const data = scope.data[key];\n if (data != null) scope.data[key] = null;\n } while ((scope = scope.parent));\n }\n\n init() {\n if (!this.inited) {\n this.inited = true;\n this.crawl();\n }\n }\n\n crawl() {\n const path = this.path;\n\n this.references = Object.create(null);\n this.bindings = Object.create(null);\n this.globals = Object.create(null);\n this.uids = Object.create(null);\n this.data = Object.create(null);\n\n const programParent = this.getProgramParent();\n if (programParent.crawling) return;\n\n const state: CollectVisitorState = {\n references: [],\n constantViolations: [],\n assignments: [],\n };\n\n this.crawling = true;\n // traverse does not visit the root node, here we explicitly collect\n // root node binding info when the root is not a Program.\n if (path.type !== \"Program\" && collectorVisitor._exploded) {\n // @ts-expect-error when collectorVisitor is exploded, `enter` always exists\n for (const visit of collectorVisitor.enter) {\n visit(path, state);\n }\n const typeVisitors = collectorVisitor[path.type];\n if (typeVisitors) {\n // @ts-expect-error when collectorVisitor is exploded, `enter` always exists\n for (const visit of typeVisitors.enter) {\n visit(path, state);\n }\n }\n }\n path.traverse(collectorVisitor, state);\n this.crawling = false;\n\n // register assignments\n for (const path of state.assignments) {\n // register undeclared bindings as globals\n const ids = path.getBindingIdentifiers();\n for (const name of Object.keys(ids)) {\n if (path.scope.getBinding(name)) continue;\n programParent.addGlobal(ids[name]);\n }\n\n // register as constant violation\n path.scope.registerConstantViolation(path);\n }\n\n // register references\n for (const ref of state.references) {\n const binding = ref.scope.getBinding(ref.node.name);\n if (binding) {\n binding.reference(ref);\n } else {\n programParent.addGlobal(ref.node);\n }\n }\n\n // register constant violations\n for (const path of state.constantViolations) {\n path.scope.registerConstantViolation(path);\n }\n }\n\n push(opts: {\n id: t.LVal;\n init?: t.Expression;\n unique?: boolean;\n _blockHoist?: number | undefined;\n kind?: \"var\" | \"let\" | \"const\";\n }) {\n let path = this.path;\n\n if (path.isPattern()) {\n path = this.getPatternParent().path;\n } else if (!path.isBlockStatement() && !path.isProgram()) {\n path = this.getBlockParent().path;\n }\n\n if (path.isSwitchStatement()) {\n path = (this.getFunctionParent() || this.getProgramParent()).path;\n }\n\n if (path.isLoop() || path.isCatchClause() || path.isFunction()) {\n // @ts-expect-error TS can not infer NodePath<Loop> | NodePath<CatchClause> as NodePath<Loop | CatchClause>\n path.ensureBlock();\n // @ts-expect-error todo(flow->ts): improve types\n path = path.get(\"body\");\n }\n\n const unique = opts.unique;\n const kind = opts.kind || \"var\";\n const blockHoist = opts._blockHoist == null ? 2 : opts._blockHoist;\n\n const dataKey = `declaration:${kind}:${blockHoist}`;\n let declarPath = !unique && path.getData(dataKey);\n\n if (!declarPath) {\n const declar = variableDeclaration(kind, []);\n // @ts-expect-error todo(flow->ts): avoid modifying nodes\n declar._blockHoist = blockHoist;\n\n [declarPath] = (path as NodePath<t.BlockStatement>).unshiftContainer(\n \"body\",\n [declar],\n );\n if (!unique) path.setData(dataKey, declarPath);\n }\n\n const declarator = variableDeclarator(opts.id, opts.init);\n const len = declarPath.node.declarations.push(declarator);\n path.scope.registerBinding(kind, declarPath.get(\"declarations\")[len - 1]);\n }\n\n /**\n * Walk up to the top of the scope tree and get the `Program`.\n */\n\n getProgramParent() {\n let scope: Scope = this;\n do {\n if (scope.path.isProgram()) {\n return scope;\n }\n } while ((scope = scope.parent));\n throw new Error(\"Couldn't find a Program\");\n }\n\n /**\n * Walk up the scope tree until we hit either a Function or return null.\n */\n\n getFunctionParent(): Scope | null {\n let scope: Scope = this;\n do {\n if (scope.path.isFunctionParent()) {\n return scope;\n }\n } while ((scope = scope.parent));\n return null;\n }\n\n /**\n * Walk up the scope tree until we hit either a BlockStatement/Loop/Program/Function/Switch or reach the\n * very top and hit Program.\n */\n\n getBlockParent() {\n let scope: Scope = this;\n do {\n if (scope.path.isBlockParent()) {\n return scope;\n }\n } while ((scope = scope.parent));\n throw new Error(\n \"We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...\",\n );\n }\n\n /**\n * Walk up from a pattern scope (function param initializer) until we hit a non-pattern scope,\n * then returns its block parent\n * @returns An ancestry scope whose path is a block parent\n */\n getPatternParent() {\n let scope: Scope = this;\n do {\n if (!scope.path.isPattern()) {\n return scope.getBlockParent();\n }\n } while ((scope = scope.parent.parent));\n throw new Error(\n \"We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...\",\n );\n }\n\n /**\n * Walks the scope tree and gathers **all** bindings.\n */\n\n getAllBindings(): Record<string, Binding> {\n const ids = Object.create(null);\n\n let scope: Scope = this;\n do {\n for (const key of Object.keys(scope.bindings)) {\n if (key in ids === false) {\n ids[key] = scope.bindings[key];\n }\n }\n scope = scope.parent;\n } while (scope);\n\n return ids;\n }\n\n /**\n * Walks the scope tree and gathers all declarations of `kind`.\n */\n\n getAllBindingsOfKind(...kinds: string[]): Record<string, Binding> {\n const ids = Object.create(null);\n\n for (const kind of kinds) {\n let scope: Scope = this;\n do {\n for (const name of Object.keys(scope.bindings)) {\n const binding = scope.bindings[name];\n if (binding.kind === kind) ids[name] = binding;\n }\n scope = scope.parent;\n } while (scope);\n }\n\n return ids;\n }\n\n bindingIdentifierEquals(name: string, node: t.Node): boolean {\n return this.getBindingIdentifier(name) === node;\n }\n\n getBinding(name: string): Binding | undefined {\n let scope: Scope = this;\n let previousPath;\n\n do {\n const binding = scope.getOwnBinding(name);\n if (binding) {\n // Check if a pattern is a part of parameter expressions.\n // Note: for performance reason we skip checking previousPath.parentPath.isFunction()\n // because `scope.path` is validated as scope in packages/babel-types/src/validators/isScope.js\n // That is, if a scope path is pattern, its parent must be Function/CatchClause\n\n // Spec 9.2.10.28: The closure created by this expression should not have visibility of\n // declarations in the function body. If the binding is not a `param`-kind (as function parameters)\n // or `local`-kind (as id in function expression),\n // then it must be defined inside the function body, thus it should be skipped\n if (\n previousPath?.isPattern() &&\n binding.kind !== \"param\" &&\n binding.kind !== \"local\"\n ) {\n // do nothing\n } else {\n return binding;\n }\n } else if (\n !binding &&\n name === \"arguments\" &&\n scope.path.isFunction() &&\n !scope.path.isArrowFunctionExpression()\n ) {\n break;\n }\n previousPath = scope.path;\n } while ((scope = scope.parent));\n }\n\n getOwnBinding(name: string): Binding | undefined {\n return this.bindings[name];\n }\n\n // todo: return probably can be undefined…\n getBindingIdentifier(name: string): t.Identifier {\n return this.getBinding(name)?.identifier;\n }\n\n // todo: flow->ts return probably can be undefined\n getOwnBindingIdentifier(name: string): t.Identifier {\n const binding = this.bindings[name];\n return binding?.identifier;\n }\n\n hasOwnBinding(name: string) {\n return !!this.getOwnBinding(name);\n }\n\n // By default, we consider generated UIDs as bindings.\n // This is because they are almost always used to declare variables,\n // and since the scope isn't always up-to-date it's better to assume that\n // there is a variable with that name. The `noUids` option can be used to\n // turn off this behavior, for example if you know that the generate UID\n // was used to declare a variable in a different scope.\n hasBinding(\n name: string,\n opts?: boolean | { noGlobals?: boolean; noUids?: boolean },\n ) {\n if (!name) return false;\n if (this.hasOwnBinding(name)) return true;\n {\n // TODO: Only accept the object form.\n if (typeof opts === \"boolean\") opts = { noGlobals: opts };\n }\n if (this.parentHasBinding(name, opts)) return true;\n if (!opts?.noUids && this.hasUid(name)) return true;\n if (!opts?.noGlobals && Scope.globals.includes(name)) return true;\n if (!opts?.noGlobals && Scope.contextVariables.includes(name)) return true;\n return false;\n }\n\n parentHasBinding(\n name: string,\n opts?: { noGlobals?: boolean; noUids?: boolean },\n ) {\n return this.parent?.hasBinding(name, opts);\n }\n\n /**\n * Move a binding of `name` to another `scope`.\n */\n\n moveBindingTo(name: string, scope: Scope) {\n const info = this.getBinding(name);\n if (info) {\n info.scope.removeOwnBinding(name);\n info.scope = scope;\n scope.bindings[name] = info;\n }\n }\n\n removeOwnBinding(name: string) {\n delete this.bindings[name];\n }\n\n removeBinding(name: string) {\n // clear literal binding\n this.getBinding(name)?.scope.removeOwnBinding(name);\n\n // clear uids with this name - https://github.com/babel/babel/issues/2101\n let scope: Scope = this;\n do {\n if (scope.uids[name]) {\n scope.uids[name] = false;\n }\n } while ((scope = scope.parent));\n }\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAEA;AAEA;AACA;AA+CA;AAA+C;EA9C7CA,iBAAiB;EACjBC,cAAc;EACdC,SAAS;EACTC,qBAAqB;EACrBC,UAAU;EACVC,iBAAiB;EACjBC,QAAQ;EACRC,OAAO;EACPC,WAAW;EACXC,kBAAkB;EAClBC,sBAAsB;EACtBC,0BAA0B;EAC1BC,wBAAwB;EACxBC,qBAAqB;EACrBC,YAAY;EACZC,mBAAmB;EACnBC,SAAS;EACTC,QAAQ;EACRC,iBAAiB;EACjBC,aAAa;EACbC,kBAAkB;EAClBC,UAAU;EACVC,SAAS;EACTC,eAAe;EACfC,OAAO;EACPC,0BAA0B;EAC1BC,iBAAiB;EACjBC,gBAAgB;EAChBC,iBAAiB;EACjBC,qBAAqB;EACrBC,cAAc;EACdC,gBAAgB;EAChBC,cAAc;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KAAY,GAAG,IAAI;IACvB,GAAG;MACD,IAAIA,KAAK,CAACgD,IAAI,CAAClE,IAAI,CAAC,EAAE;QACpBkB,KAAK,CAACgD,IAAI,CAAClE,IAAI,CAAC,GAAG,KAAK;MAC1B;IACF,CAAC,QAASkB,KAAK,GAAGA,KAAK,CAACO,MAAM;EAChC;AACF;AAAC;AAt6BoBmC,KAAK,CA2CjBK,OAAO,GAAGvB,MAAM,CAACC,IAAI,CAACsB,QAAO,CAACmJ,OAAO,CAAC;AA3C1BxJ,KAAK,CAiDjBmJ,gBAAgB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,CAAC"}
|
1
|
+
{"version":3,"names":["NOT_LOCAL_BINDING","callExpression","cloneNode","getBindingIdentifiers","identifier","isArrayExpression","isBinary","isClass","isClassBody","isClassDeclaration","isExportAllDeclaration","isExportDefaultDeclaration","isExportNamedDeclaration","isFunctionDeclaration","isIdentifier","isImportDeclaration","isLiteral","isMethod","isModuleSpecifier","isNullLiteral","isObjectExpression","isProperty","isPureish","isRegExpLiteral","isSuper","isTaggedTemplateExpression","isTemplateLiteral","isThisExpression","isUnaryExpression","isVariableDeclaration","matchesPattern","memberExpression","numericLiteral","toIdentifier","unaryExpression","variableDeclaration","variableDeclarator","isRecordExpression","isTupleExpression","isObjectProperty","isTopicReference","isMetaProperty","isPrivateName","isExportDeclaration","gatherNodeParts","node","parts","type","source","specifiers","length","e","declaration","local","push","value","object","property","name","callee","properties","argument","key","left","id","expression","meta","openingElement","openingFragment","namespace","collectorVisitor","ForStatement","path","declar","get","isVar","scope","parentScope","getFunctionParent","getProgramParent","registerBinding","Declaration","isBlockScoped","parent","registerDeclaration","ImportDeclaration","getBlockParent","ReferencedIdentifier","state","references","ForXStatement","isPattern","constantViolations","ExportDeclaration","exit","binding","getBinding","reference","decl","declarations","Object","keys","LabeledStatement","AssignmentExpression","assignments","UpdateExpression","UnaryExpression","operator","BlockScoped","bindings","CatchClause","Function","params","param","isFunctionExpression","has","ClassExpression","uid","Scope","constructor","block","labels","inited","globals","uids","data","crawling","cached","scopeCache","set","Map","shouldSkip","listKey","parentPath","isScope","parentBlock","hub","traverse","opts","generateDeclaredUidIdentifier","generateUidIdentifier","generateUid","replace","i","_generateUid","hasLabel","hasBinding","hasGlobal","hasReference","program","generateUidBasedOnNode","defaultName","join","slice","generateUidIdentifierBasedOnNode","isStatic","constant","maybeGenerateMemoised","dontPush","checkBlockScopedCollisions","kind","duplicate","buildError","TypeError","rename","oldName","newName","renamer","Renamer","arguments","_renameFromMap","map","dump","sep","repeat","console","log","violations","toArray","arrayLikeIsIterable","isGenericType","helperName","args","unshift","addHelper","getLabel","registerLabel","label","isLabeledStatement","declare","isTypeDeclaration","importKind","specifier","isTypeSpecifier","isImportSpecifier","buildUndefinedNode","registerConstantViolation","ids","reassign","bindingPath","ReferenceError","declarators","getOuterBindingIdentifiers","getOwnBinding","Binding","addGlobal","hasUid","isPure","constantsOnly","superClass","decorators","body","method","right","elem","elements","prop","computed","static","tag","quasi","expressions","setData","val","getData","removeData","init","crawl","create","programParent","_exploded","visit","enter","typeVisitors","ref","getPatternParent","isBlockStatement","isProgram","isSwitchStatement","isLoop","isCatchClause","isFunction","ensureBlock","unique","blockHoist","_blockHoist","dataKey","declarPath","unshiftContainer","declarator","len","Error","isFunctionParent","isBlockParent","getAllBindings","getAllBindingsOfKind","kinds","bindingIdentifierEquals","getBindingIdentifier","previousPath","isArrowFunctionExpression","getOwnBindingIdentifier","hasOwnBinding","noGlobals","parentHasBinding","noUids","includes","contextVariables","moveBindingTo","info","removeOwnBinding","removeBinding","builtin"],"sources":["../../src/scope/index.ts"],"sourcesContent":["import Renamer from \"./lib/renamer\";\nimport type NodePath from \"../path\";\nimport traverse from \"../index\";\nimport type { TraverseOptions } from \"../index\";\nimport Binding from \"./binding\";\nimport type { BindingKind } from \"./binding\";\nimport globals from \"globals\";\nimport {\n NOT_LOCAL_BINDING,\n callExpression,\n cloneNode,\n getBindingIdentifiers,\n identifier,\n isArrayExpression,\n isBinary,\n isClass,\n isClassBody,\n isClassDeclaration,\n isExportAllDeclaration,\n isExportDefaultDeclaration,\n isExportNamedDeclaration,\n isFunctionDeclaration,\n isIdentifier,\n isImportDeclaration,\n isLiteral,\n isMethod,\n isModuleSpecifier,\n isNullLiteral,\n isObjectExpression,\n isProperty,\n isPureish,\n isRegExpLiteral,\n isSuper,\n isTaggedTemplateExpression,\n isTemplateLiteral,\n isThisExpression,\n isUnaryExpression,\n isVariableDeclaration,\n matchesPattern,\n memberExpression,\n numericLiteral,\n toIdentifier,\n unaryExpression,\n variableDeclaration,\n variableDeclarator,\n isRecordExpression,\n isTupleExpression,\n isObjectProperty,\n isTopicReference,\n isMetaProperty,\n isPrivateName,\n isExportDeclaration,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport { scope as scopeCache } from \"../cache\";\nimport type { Visitor } from \"../types\";\n\ntype NodePart = string | number | boolean;\n// Recursively gathers the identifying names of a node.\nfunction gatherNodeParts(node: t.Node, parts: NodePart[]) {\n switch (node?.type) {\n default:\n if (isImportDeclaration(node) || isExportDeclaration(node)) {\n if (\n (isExportAllDeclaration(node) ||\n isExportNamedDeclaration(node) ||\n isImportDeclaration(node)) &&\n node.source\n ) {\n gatherNodeParts(node.source, parts);\n } else if (\n (isExportNamedDeclaration(node) || isImportDeclaration(node)) &&\n node.specifiers &&\n node.specifiers.length\n ) {\n for (const e of node.specifiers) gatherNodeParts(e, parts);\n } else if (\n (isExportDefaultDeclaration(node) ||\n isExportNamedDeclaration(node)) &&\n node.declaration\n ) {\n gatherNodeParts(node.declaration, parts);\n }\n } else if (isModuleSpecifier(node)) {\n // todo(flow->ts): should condition instead be:\n // ```\n // t.isExportSpecifier(node) ||\n // t.isImportDefaultSpecifier(node) ||\n // t.isImportNamespaceSpecifier(node) ||\n // t.isImportSpecifier(node)\n // ```\n // allowing only nodes with `.local`?\n // @ts-expect-error todo(flow->ts)\n gatherNodeParts(node.local, parts);\n } else if (\n isLiteral(node) &&\n !isNullLiteral(node) &&\n !isRegExpLiteral(node) &&\n !isTemplateLiteral(node)\n ) {\n parts.push(node.value);\n }\n break;\n\n case \"MemberExpression\":\n case \"OptionalMemberExpression\":\n case \"JSXMemberExpression\":\n gatherNodeParts(node.object, parts);\n gatherNodeParts(node.property, parts);\n break;\n\n case \"Identifier\":\n case \"JSXIdentifier\":\n parts.push(node.name);\n break;\n\n case \"CallExpression\":\n case \"OptionalCallExpression\":\n case \"NewExpression\":\n gatherNodeParts(node.callee, parts);\n break;\n\n case \"ObjectExpression\":\n case \"ObjectPattern\":\n for (const e of node.properties) {\n gatherNodeParts(e, parts);\n }\n break;\n\n case \"SpreadElement\":\n case \"RestElement\":\n gatherNodeParts(node.argument, parts);\n break;\n\n case \"ObjectProperty\":\n case \"ObjectMethod\":\n case \"ClassProperty\":\n case \"ClassMethod\":\n case \"ClassPrivateProperty\":\n case \"ClassPrivateMethod\":\n gatherNodeParts(node.key, parts);\n break;\n\n case \"ThisExpression\":\n parts.push(\"this\");\n break;\n\n case \"Super\":\n parts.push(\"super\");\n break;\n\n case \"Import\":\n parts.push(\"import\");\n break;\n\n case \"DoExpression\":\n parts.push(\"do\");\n break;\n\n case \"YieldExpression\":\n parts.push(\"yield\");\n gatherNodeParts(node.argument, parts);\n break;\n\n case \"AwaitExpression\":\n parts.push(\"await\");\n gatherNodeParts(node.argument, parts);\n break;\n\n case \"AssignmentExpression\":\n gatherNodeParts(node.left, parts);\n break;\n\n case \"VariableDeclarator\":\n gatherNodeParts(node.id, parts);\n break;\n\n case \"FunctionExpression\":\n case \"FunctionDeclaration\":\n case \"ClassExpression\":\n case \"ClassDeclaration\":\n gatherNodeParts(node.id, parts);\n break;\n\n case \"PrivateName\":\n gatherNodeParts(node.id, parts);\n break;\n\n case \"ParenthesizedExpression\":\n gatherNodeParts(node.expression, parts);\n break;\n\n case \"UnaryExpression\":\n case \"UpdateExpression\":\n gatherNodeParts(node.argument, parts);\n break;\n\n case \"MetaProperty\":\n gatherNodeParts(node.meta, parts);\n gatherNodeParts(node.property, parts);\n break;\n\n case \"JSXElement\":\n gatherNodeParts(node.openingElement, parts);\n break;\n\n case \"JSXOpeningElement\":\n gatherNodeParts(node.name, parts);\n break;\n\n case \"JSXFragment\":\n gatherNodeParts(node.openingFragment, parts);\n break;\n\n case \"JSXOpeningFragment\":\n parts.push(\"Fragment\");\n break;\n\n case \"JSXNamespacedName\":\n gatherNodeParts(node.namespace, parts);\n gatherNodeParts(node.name, parts);\n break;\n }\n}\n\n//\ninterface CollectVisitorState {\n assignments: NodePath<t.AssignmentExpression>[];\n references: NodePath<t.Identifier | t.JSXIdentifier>[];\n constantViolations: NodePath[];\n}\n\nconst collectorVisitor: Visitor<CollectVisitorState> = {\n ForStatement(path) {\n const declar = path.get(\"init\");\n // delegate block scope handling to the `BlockScoped` method\n if (declar.isVar()) {\n const { scope } = path;\n const parentScope = scope.getFunctionParent() || scope.getProgramParent();\n parentScope.registerBinding(\"var\", declar);\n }\n },\n\n Declaration(path) {\n // delegate block scope handling to the `BlockScoped` method\n if (path.isBlockScoped()) return;\n\n // delegate import handing to the `ImportDeclaration` method\n if (path.isImportDeclaration()) return;\n\n // this will be hit again once we traverse into it after this iteration\n if (path.isExportDeclaration()) return;\n\n // we've ran into a declaration!\n const parent =\n path.scope.getFunctionParent() || path.scope.getProgramParent();\n parent.registerDeclaration(path);\n },\n\n ImportDeclaration(path) {\n // import may only appear in the top level or inside a module/namespace (for TS/flow)\n const parent = path.scope.getBlockParent();\n\n parent.registerDeclaration(path);\n },\n\n ReferencedIdentifier(path, state) {\n state.references.push(path);\n },\n\n ForXStatement(path, state) {\n const left = path.get(\"left\");\n if (left.isPattern() || left.isIdentifier()) {\n state.constantViolations.push(path);\n }\n // delegate block scope handling to the `BlockScoped` method\n else if (left.isVar()) {\n const { scope } = path;\n const parentScope = scope.getFunctionParent() || scope.getProgramParent();\n parentScope.registerBinding(\"var\", left);\n }\n },\n\n ExportDeclaration: {\n exit(path) {\n const { node, scope } = path;\n // ExportAllDeclaration does not have `declaration`\n if (isExportAllDeclaration(node)) return;\n const declar = node.declaration;\n if (isClassDeclaration(declar) || isFunctionDeclaration(declar)) {\n const id = declar.id;\n if (!id) return;\n\n const binding = scope.getBinding(id.name);\n binding?.reference(path);\n } else if (isVariableDeclaration(declar)) {\n for (const decl of declar.declarations) {\n for (const name of Object.keys(getBindingIdentifiers(decl))) {\n const binding = scope.getBinding(name);\n binding?.reference(path);\n }\n }\n }\n },\n },\n\n LabeledStatement(path) {\n path.scope.getBlockParent().registerDeclaration(path);\n },\n\n AssignmentExpression(path, state) {\n state.assignments.push(path);\n },\n\n UpdateExpression(path, state) {\n state.constantViolations.push(path);\n },\n\n UnaryExpression(path, state) {\n if (path.node.operator === \"delete\") {\n state.constantViolations.push(path);\n }\n },\n\n BlockScoped(path) {\n let scope = path.scope;\n if (scope.path === path) scope = scope.parent;\n\n const parent = scope.getBlockParent();\n parent.registerDeclaration(path);\n\n // Register class identifier in class' scope if this is a class declaration.\n if (path.isClassDeclaration() && path.node.id) {\n const id = path.node.id;\n const name = id.name;\n\n path.scope.bindings[name] = path.scope.parent.getBinding(name);\n }\n },\n\n CatchClause(path) {\n path.scope.registerBinding(\"let\", path);\n },\n\n Function(path) {\n const params: Array<NodePath> = path.get(\"params\");\n for (const param of params) {\n path.scope.registerBinding(\"param\", param);\n }\n\n // Register function expression id after params. When the id\n // collides with a function param, the id effectively can't be\n // referenced: here we registered it as a constantViolation\n if (\n path.isFunctionExpression() &&\n path.has(\"id\") &&\n // @ts-expect-error Fixme: document symbol ast properties\n !path.get(\"id\").node[NOT_LOCAL_BINDING]\n ) {\n path.scope.registerBinding(\"local\", path.get(\"id\"), path);\n }\n },\n\n ClassExpression(path) {\n if (\n path.has(\"id\") &&\n // @ts-expect-error Fixme: document symbol ast properties\n !path.get(\"id\").node[NOT_LOCAL_BINDING]\n ) {\n path.scope.registerBinding(\"local\", path);\n }\n },\n};\n\nlet uid = 0;\n\nexport type { Binding };\n\nexport default class Scope {\n uid;\n\n path: NodePath;\n block: t.Pattern | t.Scopable;\n\n labels;\n inited;\n\n bindings: { [name: string]: Binding };\n references: { [name: string]: true };\n globals: { [name: string]: t.Identifier | t.JSXIdentifier };\n uids: { [name: string]: boolean };\n data: { [key: string | symbol]: unknown };\n crawling: boolean;\n\n /**\n * This searches the current \"scope\" and collects all references/bindings\n * within.\n */\n constructor(path: NodePath<t.Pattern | t.Scopable>) {\n const { node } = path;\n const cached = scopeCache.get(node);\n // Sometimes, a scopable path is placed higher in the AST tree.\n // In these cases, have to create a new Scope.\n if (cached?.path === path) {\n return cached;\n }\n scopeCache.set(node, this);\n\n this.uid = uid++;\n\n this.block = node;\n this.path = path;\n\n this.labels = new Map();\n this.inited = false;\n }\n\n /**\n * Globals.\n */\n\n static globals = Object.keys(globals.builtin);\n\n /**\n * Variables available in current context.\n */\n\n static contextVariables = [\"arguments\", \"undefined\", \"Infinity\", \"NaN\"];\n\n get parent() {\n let parent,\n path = this.path;\n do {\n // Skip method scope if coming from inside computed key or decorator expression\n const shouldSkip = path.key === \"key\" || path.listKey === \"decorators\";\n path = path.parentPath;\n if (shouldSkip && path.isMethod()) path = path.parentPath;\n if (path && path.isScope()) parent = path;\n } while (path && !parent);\n\n return parent?.scope;\n }\n\n get parentBlock() {\n return this.path.parent;\n }\n\n get hub() {\n return this.path.hub;\n }\n\n traverse<S>(\n node: t.Node | t.Node[],\n opts: TraverseOptions<S>,\n state: S,\n ): void;\n traverse(node: t.Node | t.Node[], opts?: TraverseOptions, state?: any): void;\n /**\n * Traverse node with current scope and path.\n *\n * !!! WARNING !!!\n * This method assumes that `this.path` is the NodePath representing `node`.\n * After running the traversal, the `.parentPath` of the NodePaths\n * corresponding to `node`'s children will be set to `this.path`.\n *\n * There is no good reason to use this method, since the only safe way to use\n * it is equivalent to `scope.path.traverse(opts, state)`.\n */\n traverse<S>(node: any, opts: any, state?: S) {\n traverse(node, opts, this, state, this.path);\n }\n\n /**\n * Generate a unique identifier and add it to the current scope.\n */\n\n generateDeclaredUidIdentifier(name?: string) {\n const id = this.generateUidIdentifier(name);\n this.push({ id });\n return cloneNode(id);\n }\n\n /**\n * Generate a unique identifier.\n */\n\n generateUidIdentifier(name?: string) {\n return identifier(this.generateUid(name));\n }\n\n /**\n * Generate a unique `_id1` binding.\n */\n\n generateUid(name: string = \"temp\"): string {\n name = toIdentifier(name)\n .replace(/^_+/, \"\")\n .replace(/[0-9]+$/g, \"\");\n\n let uid;\n let i = 1;\n do {\n uid = this._generateUid(name, i);\n i++;\n } while (\n this.hasLabel(uid) ||\n this.hasBinding(uid) ||\n this.hasGlobal(uid) ||\n this.hasReference(uid)\n );\n\n const program = this.getProgramParent();\n program.references[uid] = true;\n program.uids[uid] = true;\n\n return uid;\n }\n\n /**\n * Generate an `_id1`.\n */\n\n _generateUid(name: string, i: number) {\n let id = name;\n if (i > 1) id += i;\n return `_${id}`;\n }\n\n generateUidBasedOnNode(node: t.Node, defaultName?: string) {\n const parts: NodePart[] = [];\n gatherNodeParts(node, parts);\n\n let id = parts.join(\"$\");\n id = id.replace(/^_/, \"\") || defaultName || \"ref\";\n\n return this.generateUid(id.slice(0, 20));\n }\n\n /**\n * Generate a unique identifier based on a node.\n */\n\n generateUidIdentifierBasedOnNode(node: t.Node, defaultName?: string) {\n return identifier(this.generateUidBasedOnNode(node, defaultName));\n }\n\n /**\n * Determine whether evaluating the specific input `node` is a consequenceless reference. ie.\n * evaluating it wont result in potentially arbitrary code from being ran. The following are\n * allowed and determined not to cause side effects:\n *\n * - `this` expressions\n * - `super` expressions\n * - Bound identifiers\n */\n\n isStatic(node: t.Node): boolean {\n if (isThisExpression(node) || isSuper(node) || isTopicReference(node)) {\n return true;\n }\n\n if (isIdentifier(node)) {\n const binding = this.getBinding(node.name);\n if (binding) {\n return binding.constant;\n } else {\n return this.hasBinding(node.name);\n }\n }\n\n return false;\n }\n\n /**\n * Possibly generate a memoised identifier if it is not static and has consequences.\n */\n\n maybeGenerateMemoised(node: t.Node, dontPush?: boolean) {\n if (this.isStatic(node)) {\n return null;\n } else {\n const id = this.generateUidIdentifierBasedOnNode(node);\n if (!dontPush) {\n this.push({ id });\n return cloneNode(id);\n }\n return id;\n }\n }\n\n checkBlockScopedCollisions(\n local: Binding,\n kind: BindingKind,\n name: string,\n id: any,\n ) {\n // ignore parameters\n if (kind === \"param\") return;\n\n // Ignore existing binding if it's the name of the current function or\n // class expression\n if (local.kind === \"local\") return;\n\n const duplicate =\n // don't allow duplicate bindings to exist alongside\n kind === \"let\" ||\n local.kind === \"let\" ||\n local.kind === \"const\" ||\n local.kind === \"module\" ||\n // don't allow a local of param with a kind of let\n (local.kind === \"param\" && kind === \"const\");\n\n if (duplicate) {\n throw this.hub.buildError(\n id,\n `Duplicate declaration \"${name}\"`,\n TypeError,\n );\n }\n }\n\n rename(\n oldName: string,\n newName?: string,\n // prettier-ignore\n /* Babel 7 - block?: t.Pattern | t.Scopable */\n ) {\n const binding = this.getBinding(oldName);\n if (binding) {\n newName ||= this.generateUidIdentifier(oldName).name;\n const renamer = new Renamer(binding, oldName, newName);\n return process.env.BABEL_8_BREAKING\n ? renamer.rename()\n : // @ts-expect-error: babel 7->8\n renamer.rename(arguments[2]);\n }\n }\n\n /** @deprecated Not used in our codebase */\n _renameFromMap(\n map: Record<string | symbol, unknown>,\n oldName: string | symbol,\n newName: string | symbol,\n value: unknown,\n ) {\n if (map[oldName]) {\n map[newName] = value;\n map[oldName] = null;\n }\n }\n\n dump() {\n const sep = \"-\".repeat(60);\n console.log(sep);\n let scope: Scope = this;\n do {\n console.log(\"#\", scope.block.type);\n for (const name of Object.keys(scope.bindings)) {\n const binding = scope.bindings[name];\n console.log(\" -\", name, {\n constant: binding.constant,\n references: binding.references,\n violations: binding.constantViolations.length,\n kind: binding.kind,\n });\n }\n } while ((scope = scope.parent));\n console.log(sep);\n }\n\n // TODO: (Babel 8) Split i in two parameters, and use an object of flags\n toArray(\n node: t.Node,\n i?: number | boolean,\n arrayLikeIsIterable?: boolean | void,\n ) {\n if (isIdentifier(node)) {\n const binding = this.getBinding(node.name);\n if (binding?.constant && binding.path.isGenericType(\"Array\")) {\n return node;\n }\n }\n\n if (isArrayExpression(node)) {\n return node;\n }\n\n if (isIdentifier(node, { name: \"arguments\" })) {\n return callExpression(\n memberExpression(\n memberExpression(\n memberExpression(identifier(\"Array\"), identifier(\"prototype\")),\n identifier(\"slice\"),\n ),\n identifier(\"call\"),\n ),\n [node],\n );\n }\n\n let helperName;\n const args = [node];\n if (i === true) {\n // Used in array-spread to create an array.\n helperName = \"toConsumableArray\";\n } else if (typeof i === \"number\") {\n args.push(numericLiteral(i));\n\n // Used in array-rest to create an array from a subset of an iterable.\n helperName = \"slicedToArray\";\n // TODO if (this.hub.isLoose(\"es6.forOf\")) helperName += \"-loose\";\n } else {\n // Used in array-rest to create an array\n helperName = \"toArray\";\n }\n\n if (arrayLikeIsIterable) {\n args.unshift(this.hub.addHelper(helperName));\n helperName = \"maybeArrayLike\";\n }\n\n // @ts-expect-error todo(flow->ts): t.Node is not valid to use in args, function argument typeneeds to be clarified\n return callExpression(this.hub.addHelper(helperName), args);\n }\n\n hasLabel(name: string) {\n return !!this.getLabel(name);\n }\n\n getLabel(name: string) {\n return this.labels.get(name);\n }\n\n registerLabel(path: NodePath<t.LabeledStatement>) {\n this.labels.set(path.node.label.name, path);\n }\n\n registerDeclaration(path: NodePath) {\n if (path.isLabeledStatement()) {\n this.registerLabel(path);\n } else if (path.isFunctionDeclaration()) {\n this.registerBinding(\"hoisted\", path.get(\"id\"), path);\n } else if (path.isVariableDeclaration()) {\n const declarations = path.get(\"declarations\");\n const { kind } = path.node;\n for (const declar of declarations) {\n this.registerBinding(kind === \"using\" ? \"const\" : kind, declar);\n }\n } else if (path.isClassDeclaration()) {\n if (path.node.declare) return;\n this.registerBinding(\"let\", path);\n } else if (path.isImportDeclaration()) {\n const isTypeDeclaration =\n path.node.importKind === \"type\" || path.node.importKind === \"typeof\";\n const specifiers = path.get(\"specifiers\");\n for (const specifier of specifiers) {\n const isTypeSpecifier =\n isTypeDeclaration ||\n (specifier.isImportSpecifier() &&\n (specifier.node.importKind === \"type\" ||\n specifier.node.importKind === \"typeof\"));\n\n this.registerBinding(isTypeSpecifier ? \"unknown\" : \"module\", specifier);\n }\n } else if (path.isExportDeclaration()) {\n // todo: improve babel-types\n const declar = path.get(\"declaration\") as NodePath;\n if (\n declar.isClassDeclaration() ||\n declar.isFunctionDeclaration() ||\n declar.isVariableDeclaration()\n ) {\n this.registerDeclaration(declar);\n }\n } else {\n this.registerBinding(\"unknown\", path);\n }\n }\n\n buildUndefinedNode() {\n return unaryExpression(\"void\", numericLiteral(0), true);\n }\n\n registerConstantViolation(path: NodePath) {\n const ids = path.getBindingIdentifiers();\n for (const name of Object.keys(ids)) {\n const binding = this.getBinding(name);\n if (binding) binding.reassign(path);\n }\n }\n\n registerBinding(\n kind: Binding[\"kind\"],\n path: NodePath,\n bindingPath: NodePath = path,\n ) {\n if (!kind) throw new ReferenceError(\"no `kind`\");\n\n if (path.isVariableDeclaration()) {\n const declarators: Array<NodePath> = path.get(\"declarations\");\n for (const declar of declarators) {\n this.registerBinding(kind, declar);\n }\n return;\n }\n\n const parent = this.getProgramParent();\n const ids = path.getOuterBindingIdentifiers(true);\n\n for (const name of Object.keys(ids)) {\n parent.references[name] = true;\n\n for (const id of ids[name]) {\n const local = this.getOwnBinding(name);\n\n if (local) {\n // same identifier so continue safely as we're likely trying to register it\n // multiple times\n if (local.identifier === id) continue;\n\n this.checkBlockScopedCollisions(local, kind, name, id);\n }\n\n // A redeclaration of an existing variable is a modification\n if (local) {\n this.registerConstantViolation(bindingPath);\n } else {\n this.bindings[name] = new Binding({\n identifier: id,\n scope: this,\n path: bindingPath,\n kind: kind,\n });\n }\n }\n }\n }\n\n addGlobal(node: t.Identifier | t.JSXIdentifier) {\n this.globals[node.name] = node;\n }\n\n hasUid(name: string): boolean {\n let scope: Scope = this;\n\n do {\n if (scope.uids[name]) return true;\n } while ((scope = scope.parent));\n\n return false;\n }\n\n hasGlobal(name: string): boolean {\n let scope: Scope = this;\n\n do {\n if (scope.globals[name]) return true;\n } while ((scope = scope.parent));\n\n return false;\n }\n\n hasReference(name: string): boolean {\n return !!this.getProgramParent().references[name];\n }\n\n isPure(node: t.Node, constantsOnly?: boolean): boolean {\n if (isIdentifier(node)) {\n const binding = this.getBinding(node.name);\n if (!binding) return false;\n if (constantsOnly) return binding.constant;\n return true;\n } else if (\n isThisExpression(node) ||\n isMetaProperty(node) ||\n isTopicReference(node) ||\n isPrivateName(node)\n ) {\n return true;\n } else if (isClass(node)) {\n if (node.superClass && !this.isPure(node.superClass, constantsOnly)) {\n return false;\n }\n if (node.decorators?.length > 0) {\n return false;\n }\n return this.isPure(node.body, constantsOnly);\n } else if (isClassBody(node)) {\n for (const method of node.body) {\n if (!this.isPure(method, constantsOnly)) return false;\n }\n return true;\n } else if (isBinary(node)) {\n return (\n this.isPure(node.left, constantsOnly) &&\n this.isPure(node.right, constantsOnly)\n );\n } else if (isArrayExpression(node) || isTupleExpression(node)) {\n for (const elem of node.elements) {\n if (elem !== null && !this.isPure(elem, constantsOnly)) return false;\n }\n return true;\n } else if (isObjectExpression(node) || isRecordExpression(node)) {\n for (const prop of node.properties) {\n if (!this.isPure(prop, constantsOnly)) return false;\n }\n return true;\n } else if (isMethod(node)) {\n if (node.computed && !this.isPure(node.key, constantsOnly)) return false;\n if (node.decorators?.length > 0) {\n return false;\n }\n return true;\n } else if (isProperty(node)) {\n // @ts-expect-error todo(flow->ts): computed in not present on private properties\n if (node.computed && !this.isPure(node.key, constantsOnly)) return false;\n if (node.decorators?.length > 0) {\n return false;\n }\n if (isObjectProperty(node) || node.static) {\n if (node.value !== null && !this.isPure(node.value, constantsOnly)) {\n return false;\n }\n }\n return true;\n } else if (isUnaryExpression(node)) {\n return this.isPure(node.argument, constantsOnly);\n } else if (isTaggedTemplateExpression(node)) {\n return (\n matchesPattern(node.tag, \"String.raw\") &&\n !this.hasBinding(\"String\", true) &&\n this.isPure(node.quasi, constantsOnly)\n );\n } else if (isTemplateLiteral(node)) {\n for (const expression of node.expressions) {\n if (!this.isPure(expression, constantsOnly)) return false;\n }\n return true;\n } else {\n return isPureish(node);\n }\n }\n\n /**\n * Set some arbitrary data on the current scope.\n */\n\n setData(key: string | symbol, val: any) {\n return (this.data[key] = val);\n }\n\n /**\n * Recursively walk up scope tree looking for the data `key`.\n */\n\n getData(key: string | symbol): any {\n let scope: Scope = this;\n do {\n const data = scope.data[key];\n if (data != null) return data;\n } while ((scope = scope.parent));\n }\n\n /**\n * Recursively walk up scope tree looking for the data `key` and if it exists,\n * remove it.\n */\n\n removeData(key: string) {\n let scope: Scope = this;\n do {\n const data = scope.data[key];\n if (data != null) scope.data[key] = null;\n } while ((scope = scope.parent));\n }\n\n init() {\n if (!this.inited) {\n this.inited = true;\n this.crawl();\n }\n }\n\n crawl() {\n const path = this.path;\n\n this.references = Object.create(null);\n this.bindings = Object.create(null);\n this.globals = Object.create(null);\n this.uids = Object.create(null);\n this.data = Object.create(null);\n\n const programParent = this.getProgramParent();\n if (programParent.crawling) return;\n\n const state: CollectVisitorState = {\n references: [],\n constantViolations: [],\n assignments: [],\n };\n\n this.crawling = true;\n // traverse does not visit the root node, here we explicitly collect\n // root node binding info when the root is not a Program.\n if (path.type !== \"Program\" && collectorVisitor._exploded) {\n // @ts-expect-error when collectorVisitor is exploded, `enter` always exists\n for (const visit of collectorVisitor.enter) {\n visit(path, state);\n }\n const typeVisitors = collectorVisitor[path.type];\n if (typeVisitors) {\n // @ts-expect-error when collectorVisitor is exploded, `enter` always exists\n for (const visit of typeVisitors.enter) {\n visit(path, state);\n }\n }\n }\n path.traverse(collectorVisitor, state);\n this.crawling = false;\n\n // register assignments\n for (const path of state.assignments) {\n // register undeclared bindings as globals\n const ids = path.getBindingIdentifiers();\n for (const name of Object.keys(ids)) {\n if (path.scope.getBinding(name)) continue;\n programParent.addGlobal(ids[name]);\n }\n\n // register as constant violation\n path.scope.registerConstantViolation(path);\n }\n\n // register references\n for (const ref of state.references) {\n const binding = ref.scope.getBinding(ref.node.name);\n if (binding) {\n binding.reference(ref);\n } else {\n programParent.addGlobal(ref.node);\n }\n }\n\n // register constant violations\n for (const path of state.constantViolations) {\n path.scope.registerConstantViolation(path);\n }\n }\n\n push(opts: {\n id: t.LVal;\n init?: t.Expression;\n unique?: boolean;\n _blockHoist?: number | undefined;\n kind?: \"var\" | \"let\" | \"const\";\n }) {\n let path = this.path;\n\n if (path.isPattern()) {\n path = this.getPatternParent().path;\n } else if (!path.isBlockStatement() && !path.isProgram()) {\n path = this.getBlockParent().path;\n }\n\n if (path.isSwitchStatement()) {\n path = (this.getFunctionParent() || this.getProgramParent()).path;\n }\n\n if (path.isLoop() || path.isCatchClause() || path.isFunction()) {\n // @ts-expect-error TS can not infer NodePath<Loop> | NodePath<CatchClause> as NodePath<Loop | CatchClause>\n path.ensureBlock();\n // @ts-expect-error todo(flow->ts): improve types\n path = path.get(\"body\");\n }\n\n const unique = opts.unique;\n const kind = opts.kind || \"var\";\n const blockHoist = opts._blockHoist == null ? 2 : opts._blockHoist;\n\n const dataKey = `declaration:${kind}:${blockHoist}`;\n let declarPath = !unique && path.getData(dataKey);\n\n if (!declarPath) {\n const declar = variableDeclaration(kind, []);\n // @ts-expect-error todo(flow->ts): avoid modifying nodes\n declar._blockHoist = blockHoist;\n\n [declarPath] = (path as NodePath<t.BlockStatement>).unshiftContainer(\n \"body\",\n [declar],\n );\n if (!unique) path.setData(dataKey, declarPath);\n }\n\n const declarator = variableDeclarator(opts.id, opts.init);\n const len = declarPath.node.declarations.push(declarator);\n path.scope.registerBinding(kind, declarPath.get(\"declarations\")[len - 1]);\n }\n\n /**\n * Walk up to the top of the scope tree and get the `Program`.\n */\n\n getProgramParent() {\n let scope: Scope = this;\n do {\n if (scope.path.isProgram()) {\n return scope;\n }\n } while ((scope = scope.parent));\n throw new Error(\"Couldn't find a Program\");\n }\n\n /**\n * Walk up the scope tree until we hit either a Function or return null.\n */\n\n getFunctionParent(): Scope | null {\n let scope: Scope = this;\n do {\n if (scope.path.isFunctionParent()) {\n return scope;\n }\n } while ((scope = scope.parent));\n return null;\n }\n\n /**\n * Walk up the scope tree until we hit either a BlockStatement/Loop/Program/Function/Switch or reach the\n * very top and hit Program.\n */\n\n getBlockParent() {\n let scope: Scope = this;\n do {\n if (scope.path.isBlockParent()) {\n return scope;\n }\n } while ((scope = scope.parent));\n throw new Error(\n \"We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...\",\n );\n }\n\n /**\n * Walk up from a pattern scope (function param initializer) until we hit a non-pattern scope,\n * then returns its block parent\n * @returns An ancestry scope whose path is a block parent\n */\n getPatternParent() {\n let scope: Scope = this;\n do {\n if (!scope.path.isPattern()) {\n return scope.getBlockParent();\n }\n } while ((scope = scope.parent.parent));\n throw new Error(\n \"We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...\",\n );\n }\n\n /**\n * Walks the scope tree and gathers **all** bindings.\n */\n\n getAllBindings(): Record<string, Binding> {\n const ids = Object.create(null);\n\n let scope: Scope = this;\n do {\n for (const key of Object.keys(scope.bindings)) {\n if (key in ids === false) {\n ids[key] = scope.bindings[key];\n }\n }\n scope = scope.parent;\n } while (scope);\n\n return ids;\n }\n\n /**\n * Walks the scope tree and gathers all declarations of `kind`.\n */\n\n getAllBindingsOfKind(...kinds: string[]): Record<string, Binding> {\n const ids = Object.create(null);\n\n for (const kind of kinds) {\n let scope: Scope = this;\n do {\n for (const name of Object.keys(scope.bindings)) {\n const binding = scope.bindings[name];\n if (binding.kind === kind) ids[name] = binding;\n }\n scope = scope.parent;\n } while (scope);\n }\n\n return ids;\n }\n\n bindingIdentifierEquals(name: string, node: t.Node): boolean {\n return this.getBindingIdentifier(name) === node;\n }\n\n getBinding(name: string): Binding | undefined {\n let scope: Scope = this;\n let previousPath;\n\n do {\n const binding = scope.getOwnBinding(name);\n if (binding) {\n // Check if a pattern is a part of parameter expressions.\n // Note: for performance reason we skip checking previousPath.parentPath.isFunction()\n // because `scope.path` is validated as scope in packages/babel-types/src/validators/isScope.js\n // That is, if a scope path is pattern, its parent must be Function/CatchClause\n\n // Spec 9.2.10.28: The closure created by this expression should not have visibility of\n // declarations in the function body. If the binding is not a `param`-kind (as function parameters)\n // or `local`-kind (as id in function expression),\n // then it must be defined inside the function body, thus it should be skipped\n if (\n previousPath?.isPattern() &&\n binding.kind !== \"param\" &&\n binding.kind !== \"local\"\n ) {\n // do nothing\n } else {\n return binding;\n }\n } else if (\n !binding &&\n name === \"arguments\" &&\n scope.path.isFunction() &&\n !scope.path.isArrowFunctionExpression()\n ) {\n break;\n }\n previousPath = scope.path;\n } while ((scope = scope.parent));\n }\n\n getOwnBinding(name: string): Binding | undefined {\n return this.bindings[name];\n }\n\n // todo: return probably can be undefined…\n getBindingIdentifier(name: string): t.Identifier {\n return this.getBinding(name)?.identifier;\n }\n\n // todo: flow->ts return probably can be undefined\n getOwnBindingIdentifier(name: string): t.Identifier {\n const binding = this.bindings[name];\n return binding?.identifier;\n }\n\n hasOwnBinding(name: string) {\n return !!this.getOwnBinding(name);\n }\n\n // By default, we consider generated UIDs as bindings.\n // This is because they are almost always used to declare variables,\n // and since the scope isn't always up-to-date it's better to assume that\n // there is a variable with that name. The `noUids` option can be used to\n // turn off this behavior, for example if you know that the generate UID\n // was used to declare a variable in a different scope.\n hasBinding(\n name: string,\n opts?: boolean | { noGlobals?: boolean; noUids?: boolean },\n ) {\n if (!name) return false;\n if (this.hasOwnBinding(name)) return true;\n {\n // TODO: Only accept the object form.\n if (typeof opts === \"boolean\") opts = { noGlobals: opts };\n }\n if (this.parentHasBinding(name, opts)) return true;\n if (!opts?.noUids && this.hasUid(name)) return true;\n if (!opts?.noGlobals && Scope.globals.includes(name)) return true;\n if (!opts?.noGlobals && Scope.contextVariables.includes(name)) return true;\n return false;\n }\n\n parentHasBinding(\n name: string,\n opts?: { noGlobals?: boolean; noUids?: boolean },\n ) {\n return this.parent?.hasBinding(name, opts);\n }\n\n /**\n * Move a binding of `name` to another `scope`.\n */\n\n moveBindingTo(name: string, scope: Scope) {\n const info = this.getBinding(name);\n if (info) {\n info.scope.removeOwnBinding(name);\n info.scope = scope;\n scope.bindings[name] = info;\n }\n }\n\n removeOwnBinding(name: string) {\n delete this.bindings[name];\n }\n\n removeBinding(name: string) {\n // clear literal binding\n this.getBinding(name)?.scope.removeOwnBinding(name);\n\n // clear uids with this name - https://github.com/babel/babel/issues/2101\n let scope: Scope = this;\n do {\n if (scope.uids[name]) {\n scope.uids[name] = false;\n }\n } while ((scope = scope.parent));\n }\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAEA;AAEA;AACA;AA+CA;AAA+C;EA9C7CA,iBAAiB;EACjBC,cAAc;EACdC,SAAS;EACTC,qBAAqB;EACrBC,UAAU;EACVC,iBAAiB;EACjBC,QAAQ;EACRC,OAAO;EACPC,WAAW;EACXC,kBAAkB;EAClBC,sBAAsB;EACtBC,0BAA0B;EAC1BC,wBAAwB;EACxBC,qBAAqB;EACrBC,YAAY;EACZC,mBAAmB;EACnBC,SAAS;EACTC,QAAQ;EACRC,iBAAiB;EACjBC,aAAa;EACbC,kBAAkB;EAClBC,UAAU;EACVC,SAAS;EACTC,eAAe;EACfC,OAAO;EACPC,0BAA0B;EAC1BC,iBAAiB;EACjBC,gBAAgB;EAChBC,iBAAiB;EACjBC,qBAAqB;EACrBC,cAAc;EACdC,gBAAgB;EAChBC,cAAc;EACdC,YAAY;EACZC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;EAClBC,kBAAkB;EAClBC,iBAAiB;EACjBC,gBAAgB;EAChBC,gBAAgB;EAChBC,cAAc;EACdC,aAAa;EACbC;AAAmB;AAQrB,SAASC,eAAe,CAACC,IAAY,EAAEC,KAAiB,EAAE;EACxD,QAAQD,IAAI,oBAAJA,IAAI,CAAEE,IAAI;IAChB;MACE,IAAIhC,mBAAmB,CAAC8B,IAAI,CAAC,IAAIF,mBAAmB,CAACE,IAAI,CAAC,EAAE;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J,KAAK,CAiDjBqJ,gBAAgB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,CAAC"}
|
package/lib/scope/lib/renamer.js
CHANGED
@@ -63,7 +63,7 @@ class Renamer {
|
|
63
63
|
maybeConvertFromClassFunctionExpression(path) {
|
64
64
|
return path;
|
65
65
|
}
|
66
|
-
rename(
|
66
|
+
rename() {
|
67
67
|
const {
|
68
68
|
binding,
|
69
69
|
oldName,
|
@@ -80,10 +80,11 @@ class Renamer {
|
|
80
80
|
this.maybeConvertFromExportDeclaration(parentDeclar);
|
81
81
|
}
|
82
82
|
}
|
83
|
-
|
83
|
+
const blockToTraverse = arguments[0] || scope.block;
|
84
|
+
(0, _traverseNode.traverseNode)(blockToTraverse, (0, _visitors.explode)(renameVisitor), scope, this, scope.path, {
|
84
85
|
discriminant: true
|
85
86
|
});
|
86
|
-
if (!
|
87
|
+
if (!arguments[0]) {
|
87
88
|
scope.removeOwnBinding(oldName);
|
88
89
|
scope.bindings[newName] = binding;
|
89
90
|
this.binding.identifier.name = newName;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["renameVisitor","ReferencedIdentifier","node","state","name","oldName","newName","Scope","path","scope","bindingIdentifierEquals","binding","identifier","skip","isMethod","requeueComputedKeyAndDecorators","isVariableDeclaration","ids","getOuterBindingIdentifiers","Renamer","constructor","maybeConvertFromExportDeclaration","parentDeclar","maybeExportDeclar","parentPath","isExportDeclaration","isExportDefaultDeclaration","declaration","t","isDeclaration","id","isExportAllDeclaration","splitExportDeclaration","maybeConvertFromClassFunctionDeclaration","maybeConvertFromClassFunctionExpression","rename","
|
1
|
+
{"version":3,"names":["renameVisitor","ReferencedIdentifier","node","state","name","oldName","newName","Scope","path","scope","bindingIdentifierEquals","binding","identifier","skip","isMethod","requeueComputedKeyAndDecorators","isVariableDeclaration","ids","getOuterBindingIdentifiers","Renamer","constructor","maybeConvertFromExportDeclaration","parentDeclar","maybeExportDeclar","parentPath","isExportDeclaration","isExportDefaultDeclaration","declaration","t","isDeclaration","id","isExportAllDeclaration","splitExportDeclaration","maybeConvertFromClassFunctionDeclaration","maybeConvertFromClassFunctionExpression","rename","find","isFunctionExpression","isClassExpression","bindingIds","blockToTraverse","arguments","block","traverseNode","explode","discriminant","removeOwnBinding","bindings"],"sources":["../../../src/scope/lib/renamer.ts"],"sourcesContent":["import type Binding from \"../binding\";\nimport splitExportDeclaration from \"@babel/helper-split-export-declaration\";\nimport * as t from \"@babel/types\";\nimport type { NodePath, Visitor } from \"../..\";\nimport { requeueComputedKeyAndDecorators } from \"@babel/helper-environment-visitor\";\nimport { traverseNode } from \"../../traverse-node\";\nimport { explode } from \"../../visitors\";\n\nconst renameVisitor: Visitor<Renamer> = {\n ReferencedIdentifier({ node }, state) {\n if (node.name === state.oldName) {\n node.name = state.newName;\n }\n },\n\n Scope(path, state) {\n if (\n !path.scope.bindingIdentifierEquals(\n state.oldName,\n state.binding.identifier,\n )\n ) {\n path.skip();\n if (path.isMethod()) {\n requeueComputedKeyAndDecorators(path);\n }\n }\n },\n\n \"AssignmentExpression|Declaration|VariableDeclarator\"(\n path: NodePath<t.AssignmentPattern | t.Declaration | t.VariableDeclarator>,\n state,\n ) {\n if (path.isVariableDeclaration()) return;\n const ids = path.getOuterBindingIdentifiers();\n\n for (const name in ids) {\n if (name === state.oldName) ids[name].name = state.newName;\n }\n },\n};\n\nexport default class Renamer {\n constructor(binding: Binding, oldName: string, newName: string) {\n this.newName = newName;\n this.oldName = oldName;\n this.binding = binding;\n }\n\n declare oldName: string;\n declare newName: string;\n declare binding: Binding;\n\n maybeConvertFromExportDeclaration(parentDeclar: NodePath) {\n const maybeExportDeclar = parentDeclar.parentPath;\n\n if (!maybeExportDeclar.isExportDeclaration()) {\n return;\n }\n\n if (maybeExportDeclar.isExportDefaultDeclaration()) {\n const { declaration } = maybeExportDeclar.node;\n if (t.isDeclaration(declaration) && !declaration.id) {\n return;\n }\n }\n\n if (maybeExportDeclar.isExportAllDeclaration()) {\n return;\n }\n\n splitExportDeclaration(\n maybeExportDeclar as NodePath<\n Exclude<t.ExportDeclaration, t.ExportAllDeclaration>\n >,\n );\n }\n\n maybeConvertFromClassFunctionDeclaration(path: NodePath) {\n return path; // TODO\n\n // // retain the `name` of a class/function declaration\n\n // if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return;\n // if (this.binding.kind !== \"hoisted\") return;\n\n // path.node.id = identifier(this.oldName);\n // path.node._blockHoist = 3;\n\n // path.replaceWith(\n // variableDeclaration(\"let\", [\n // variableDeclarator(identifier(this.newName), toExpression(path.node)),\n // ]),\n // );\n }\n\n maybeConvertFromClassFunctionExpression(path: NodePath) {\n return path; // TODO\n\n // // retain the `name` of a class/function expression\n\n // if (!path.isFunctionExpression() && !path.isClassExpression()) return;\n // if (this.binding.kind !== \"local\") return;\n\n // path.node.id = identifier(this.oldName);\n\n // this.binding.scope.parent.push({\n // id: identifier(this.newName),\n // });\n\n // path.replaceWith(\n // assignmentExpression(\"=\", identifier(this.newName), path.node),\n // );\n }\n\n rename(/* Babel 7 - block?: t.Pattern | t.Scopable */) {\n const { binding, oldName, newName } = this;\n const { scope, path } = binding;\n\n const parentDeclar = path.find(\n path =>\n path.isDeclaration() ||\n path.isFunctionExpression() ||\n path.isClassExpression(),\n );\n if (parentDeclar) {\n const bindingIds = parentDeclar.getOuterBindingIdentifiers();\n if (bindingIds[oldName] === binding.identifier) {\n // When we are renaming an exported identifier, we need to ensure that\n // the exported binding keeps the old name.\n this.maybeConvertFromExportDeclaration(parentDeclar);\n }\n }\n\n const blockToTraverse = process.env.BABEL_8_BREAKING\n ? scope.block\n : (arguments[0] as t.Pattern | t.Scopable) || scope.block;\n traverseNode(\n blockToTraverse,\n explode(renameVisitor),\n scope,\n this,\n scope.path,\n // When blockToTraverse is a SwitchStatement, the discriminant\n // is not part of the current scope and thus should be skipped.\n { discriminant: true },\n );\n\n if (process.env.BABEL_8_BREAKING) {\n scope.removeOwnBinding(oldName);\n scope.bindings[newName] = binding;\n this.binding.identifier.name = newName;\n } else if (!arguments[0]) {\n scope.removeOwnBinding(oldName);\n scope.bindings[newName] = binding;\n this.binding.identifier.name = newName;\n }\n\n if (parentDeclar) {\n this.maybeConvertFromClassFunctionDeclaration(path);\n this.maybeConvertFromClassFunctionExpression(path);\n }\n }\n}\n"],"mappings":";;;;;;AACA;AACA;AAEA;AACA;AACA;AAEA,MAAMA,aAA+B,GAAG;EACtCC,oBAAoB,CAAC;IAAEC;EAAK,CAAC,EAAEC,KAAK,EAAE;IACpC,IAAID,IAAI,CAACE,IAAI,KAAKD,KAAK,CAACE,OAAO,EAAE;MAC/BH,IAAI,CAACE,IAAI,GAAGD,KAAK,CAACG,OAAO;IAC3B;EACF,CAAC;EAEDC,KAAK,CAACC,IAAI,EAAEL,KAAK,EAAE;IACjB,IACE,CAACK,IAAI,CAACC,KAAK,CAACC,uBAAuB,CACjCP,KAAK,CAACE,OAAO,EACbF,KAAK,CAACQ,OAAO,CAACC,UAAU,CACzB,EACD;MACAJ,IAAI,CAACK,IAAI,EAAE;MACX,IAAIL,IAAI,CAACM,QAAQ,EAAE,EAAE;QACnB,IAAAC,yDAA+B,EAACP,IAAI,CAAC;MACvC;IACF;EACF,CAAC;EAED,qDAAqD,CACnDA,IAA0E,EAC1EL,KAAK,EACL;IACA,IAAIK,IAAI,CAACQ,qBAAqB,EAAE,EAAE;IAClC,MAAMC,GAAG,GAAGT,IAAI,CAACU,0BAA0B,EAAE;IAE7C,KAAK,MAAMd,IAAI,IAAIa,GAAG,EAAE;MACtB,IAAIb,IAAI,KAAKD,KAAK,CAACE,OAAO,EAAEY,GAAG,CAACb,IAAI,CAAC,CAACA,IAAI,GAAGD,KAAK,CAACG,OAAO;IAC5D;EACF;AACF,CAAC;AAEc,MAAMa,OAAO,CAAC;EAC3BC,WAAW,CAACT,OAAgB,EAAEN,OAAe,EAAEC,OAAe,EAAE;IAC9D,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACD,OAAO,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CAAC,CAAC,IAA+BhC,KAAK,CAACiC,KAAK;IAC3D,IAAAC,0BAAY,EACVH,eAAe,EACf,IAAAI,iBAAO,EAAC5C,aAAa,CAAC,EACtBS,KAAK,EACL,IAAI,EACJA,KAAK,CAACD,IAAI,EAGV;MAAEqC,YAAY,EAAE;IAAK,CAAC,CACvB;IAMM,IAAI,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAE;MACxBhC,KAAK,CAACqC,gBAAgB,CAACzC,OAAO,CAAC;MAC/BI,KAAK,CAACsC,QAAQ,CAACzC,OAAO,CAAC,GAAGK,OAAO;MACjC,IAAI,CAACA,OAAO,CAACC,UAAU,CAACR,IAAI,GAAGE,OAAO;IACxC;IAEA,IAAIgB,YAAY,EAAE;MAChB,IAAI,CAACW,wCAAwC,CAACzB,IAAI,CAAC;MACnD,IAAI,CAAC0B,uCAAuC,CAAC1B,IAAI,CAAC;IACpD;EACF;AACF;AAAC"}
|
package/lib/visitors.js
CHANGED
@@ -10,6 +10,7 @@ var virtualTypes = require("./path/lib/virtual-types");
|
|
10
10
|
var _t = require("@babel/types");
|
11
11
|
const {
|
12
12
|
DEPRECATED_KEYS,
|
13
|
+
DEPRECATED_ALIASES,
|
13
14
|
FLIPPED_ALIAS_KEYS,
|
14
15
|
TYPES
|
15
16
|
} = _t;
|
@@ -56,14 +57,18 @@ function explode(visitor) {
|
|
56
57
|
}
|
57
58
|
for (const nodeType of Object.keys(visitor)) {
|
58
59
|
if (shouldIgnoreKey(nodeType)) continue;
|
59
|
-
const fns = visitor[nodeType];
|
60
60
|
let aliases = FLIPPED_ALIAS_KEYS[nodeType];
|
61
|
-
|
62
|
-
|
61
|
+
if (nodeType in DEPRECATED_KEYS) {
|
62
|
+
const deprecatedKey = DEPRECATED_KEYS[nodeType];
|
63
63
|
console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`);
|
64
64
|
aliases = [deprecatedKey];
|
65
|
+
} else if (nodeType in DEPRECATED_ALIASES) {
|
66
|
+
const deprecatedAlias = DEPRECATED_ALIASES[nodeType];
|
67
|
+
console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecatedAlias}`);
|
68
|
+
aliases = FLIPPED_ALIAS_KEYS[deprecatedAlias];
|
65
69
|
}
|
66
70
|
if (!aliases) continue;
|
71
|
+
const fns = visitor[nodeType];
|
67
72
|
delete visitor[nodeType];
|
68
73
|
for (const alias of aliases) {
|
69
74
|
const existing = visitor[alias];
|
package/lib/visitors.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["DEPRECATED_KEYS","FLIPPED_ALIAS_KEYS","TYPES","isVirtualType","type","virtualTypes","explode","visitor","_exploded","nodeType","Object","keys","shouldIgnoreKey","parts","split","length","fns","part","verify","__esModule","ensureEntranceObjects","ensureCallbackArrays","wrapCheck","types","mergePair","aliases","deprecatedKey","console","trace","alias","existing","_verified","Error","validateVisitorMethods","indexOf","visitors","visitorKey","path","val","concat","fn","TypeError","merge","states","wrapper","rootVisitor","i","state","visitorType","wrapWithStateOrWrapper","nodeVisitor","oldVisitor","newVisitor","key","Array","isArray","map","newFn","call","toString","obj","enter","exit","apply","arguments","dest","src"],"sources":["../src/visitors.ts"],"sourcesContent":["import * as virtualTypes from \"./path/lib/virtual-types\";\nimport { DEPRECATED_KEYS, FLIPPED_ALIAS_KEYS, TYPES } from \"@babel/types\";\nimport type { NodePath, Visitor } from \"./index\";\n\ntype VIRTUAL_TYPES = keyof typeof virtualTypes;\nfunction isVirtualType(type: string): type is VIRTUAL_TYPES {\n return type in virtualTypes;\n}\n\n/**\n * explode() will take a visitor object with all of the various shorthands\n * that we support, and validates & normalizes it into a common format, ready\n * to be used in traversal\n *\n * The various shorthands are:\n * * `Identifier() { ... }` -> `Identifier: { enter() { ... } }`\n * * `\"Identifier|NumericLiteral\": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }`\n * * Aliases in `@babel/types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }`\n *\n * Other normalizations are:\n * * Visitors of virtual types are wrapped, so that they are only visited when\n * their dynamic check passes\n * * `enter` and `exit` functions are wrapped in arrays, to ease merging of\n * visitors\n */\nexport function explode(visitor: Visitor) {\n if (visitor._exploded) return visitor;\n visitor._exploded = true;\n\n // normalise pipes\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n const parts: Array<string> = nodeType.split(\"|\");\n if (parts.length === 1) continue;\n\n const fns = visitor[nodeType];\n delete visitor[nodeType];\n\n for (const part of parts) {\n // @ts-expect-error part will be verified by `verify` later\n visitor[part] = fns;\n }\n }\n\n // verify data structure\n verify(visitor);\n\n // make sure there's no __esModule type since this is because we're using loose mode\n // and it sets __esModule to be enumerable on all modules :(\n // @ts-expect-error ESModule interop\n delete visitor.__esModule;\n\n // ensure visitors are objects\n ensureEntranceObjects(visitor);\n\n // ensure enter/exit callbacks are arrays\n ensureCallbackArrays(visitor);\n\n // add type wrappers\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (!isVirtualType(nodeType)) continue;\n\n // wrap all the functions\n const fns = visitor[nodeType];\n for (const type of Object.keys(fns)) {\n // @ts-expect-error manipulating visitors\n fns[type] = wrapCheck(nodeType, fns[type]);\n }\n\n // clear it from the visitor\n delete visitor[nodeType];\n\n const types = virtualTypes[nodeType];\n if (types !== null) {\n for (const type of types) {\n // merge the visitor if necessary or just put it back in\n if (visitor[type]) {\n mergePair(visitor[type], fns);\n } else {\n // @ts-expect-error Expression produces too complex union\n visitor[type] = fns;\n }\n }\n } else {\n mergePair(visitor, fns);\n }\n }\n\n // add aliases\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n const fns = visitor[nodeType];\n\n let aliases = FLIPPED_ALIAS_KEYS[nodeType];\n\n const deprecatedKey = DEPRECATED_KEYS[nodeType];\n if (deprecatedKey) {\n console.trace(\n `Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`,\n );\n aliases = [deprecatedKey];\n }\n\n if (!aliases) continue;\n\n // clear it from the visitor\n delete visitor[nodeType];\n\n for (const alias of aliases) {\n const existing = visitor[alias];\n if (existing) {\n mergePair(existing, fns);\n } else {\n // @ts-expect-error Expression produces a union type that is too complex to represent.\n visitor[alias] = { ...fns };\n }\n }\n }\n\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n ensureCallbackArrays(\n // @ts-expect-error nodeType must present in visitor after previous validations\n visitor[nodeType],\n );\n }\n\n return visitor;\n}\n\nexport function verify(visitor: Visitor) {\n if (visitor._verified) return;\n\n if (typeof visitor === \"function\") {\n throw new Error(\n \"You passed `traverse()` a function when it expected a visitor object, \" +\n \"are you sure you didn't mean `{ enter: Function }`?\",\n );\n }\n\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (nodeType === \"enter\" || nodeType === \"exit\") {\n validateVisitorMethods(nodeType, visitor[nodeType]);\n }\n\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (TYPES.indexOf(nodeType) < 0) {\n throw new Error(\n `You gave us a visitor for the node type ${nodeType} but it's not a valid type`,\n );\n }\n\n const visitors = visitor[nodeType];\n if (typeof visitors === \"object\") {\n for (const visitorKey of Object.keys(visitors)) {\n if (visitorKey === \"enter\" || visitorKey === \"exit\") {\n // verify that it just contains functions\n validateVisitorMethods(\n `${nodeType}.${visitorKey}`,\n visitors[visitorKey],\n );\n } else {\n throw new Error(\n \"You passed `traverse()` a visitor object with the property \" +\n `${nodeType} that has the invalid property ${visitorKey}`,\n );\n }\n }\n }\n }\n\n visitor._verified = true;\n}\n\nfunction validateVisitorMethods(\n path: string,\n val: any,\n): asserts val is Function | Function[] {\n const fns = [].concat(val);\n for (const fn of fns) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\n `Non-function found defined in ${path} with type ${typeof fn}`,\n );\n }\n }\n}\n\nexport function merge<State>(visitors: Visitor<State>[]): Visitor<State>;\nexport function merge(\n visitors: Visitor<unknown>[],\n states?: any[],\n wrapper?: Function | null,\n): Visitor<unknown>;\nexport function merge(\n visitors: any[],\n states: any[] = [],\n wrapper?: Function | null,\n) {\n const rootVisitor: Visitor = {};\n\n for (let i = 0; i < visitors.length; i++) {\n const visitor = visitors[i];\n const state = states[i];\n\n explode(visitor);\n\n for (const type of Object.keys(visitor) as (keyof Visitor)[]) {\n let visitorType = visitor[type];\n\n // if we have state or wrapper then overload the callbacks to take it\n if (state || wrapper) {\n visitorType = wrapWithStateOrWrapper(visitorType, state, wrapper);\n }\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n const nodeVisitor = (rootVisitor[type] ||= {});\n mergePair(nodeVisitor, visitorType);\n }\n }\n\n return rootVisitor;\n}\n\nfunction wrapWithStateOrWrapper<State>(\n oldVisitor: Visitor<State>,\n state: State,\n wrapper?: Function | null,\n) {\n const newVisitor: Visitor = {};\n\n for (const key of Object.keys(oldVisitor) as (keyof Visitor<State>)[]) {\n let fns = oldVisitor[key];\n\n // not an enter/exit array of callbacks\n if (!Array.isArray(fns)) continue;\n\n // @ts-expect-error manipulating visitors\n fns = fns.map(function (fn) {\n let newFn = fn;\n\n if (state) {\n newFn = function (path: NodePath) {\n return fn.call(state, path, state);\n };\n }\n\n if (wrapper) {\n // @ts-expect-error Fixme: document state.key\n newFn = wrapper(state.key, key, newFn);\n }\n\n // Override toString in case this function is printed, we want to print the wrapped function, same as we do in `wrapCheck`\n if (newFn !== fn) {\n newFn.toString = () => fn.toString();\n }\n\n return newFn;\n });\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n newVisitor[key] = fns;\n }\n\n return newVisitor;\n}\n\nfunction ensureEntranceObjects(obj: Visitor) {\n for (const key of Object.keys(obj) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(key)) continue;\n\n const fns = obj[key];\n if (typeof fns === \"function\") {\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n obj[key] = { enter: fns };\n }\n }\n}\n\nfunction ensureCallbackArrays(obj: Visitor) {\n // @ts-expect-error normalizing enter property\n if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];\n // @ts-expect-error normalizing exit property\n if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];\n}\n\nfunction wrapCheck(nodeType: VIRTUAL_TYPES, fn: Function) {\n const newFn = function (this: unknown, path: NodePath) {\n if (path[`is${nodeType}`]()) {\n return fn.apply(this, arguments);\n }\n };\n newFn.toString = () => fn.toString();\n return newFn;\n}\n\nfunction shouldIgnoreKey(\n key: string,\n): key is\n | \"enter\"\n | \"exit\"\n | \"shouldSkip\"\n | \"denylist\"\n | \"noScope\"\n | \"skipKeys\"\n | \"blacklist\" {\n // internal/hidden key\n if (key[0] === \"_\") return true;\n\n // ignore function keys\n if (key === \"enter\" || key === \"exit\" || key === \"shouldSkip\") return true;\n\n // ignore other options\n if (\n key === \"denylist\" ||\n key === \"noScope\" ||\n key === \"skipKeys\" ||\n // TODO: Remove in Babel 8\n key === \"blacklist\"\n ) {\n return true;\n }\n\n return false;\n}\n\nfunction mergePair(dest: any, src: any) {\n for (const key of Object.keys(src)) {\n dest[key] = [].concat(dest[key] || [], src[key]);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAA0E;EAAjEA,eAAe;EAAEC,kBAAkB;EAAEC;AAAK;AAInD,SAASC,aAAa,CAACC,IAAY,EAAyB;EAC1D,OAAOA,IAAI,IAAIC,YAAY;AAC7B;AAkBO,SAASC,OAAO,CAACC,OAAgB,EAAE;EACxC,IAAIA,OAAO,CAACC,SAAS,EAAE,OAAOD,OAAO;EACrCA,OAAO,CAACC,SAAS,GAAG,IAAI;EAGxB,KAAK,MAAMC,QAAQ,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CAAC,EAAuB;IAChE,IAAIK,eAAe,CAACH,QAAQ,CAAC,EAAE;IAE/B,MAAMI,KAAoB,GAAGJ,QAAQ,CAACK,KAAK,CAA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,CAAE,KAAI5B,QAAS,EAAC,CAAC,EAAE,EAAE;MAC3B,OAAO+B,EAAE,CAACuB,KAAK,CAAC,IAAI,EAAEC,SAAS,CAAC;IAClC;EACF,CAAC;EACDP,KAAK,CAACE,QAAQ,GAAG,MAAMnB,EAAE,CAACmB,QAAQ,EAAE;EACpC,OAAOF,KAAK;AACd;AAEA,SAAS7C,eAAe,CACtByC,GAAW,EAQG;EAEd,IAAIA,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,OAAO,IAAI;EAG/B,IAAIA,GAAG,KAAK,OAAO,IAAIA,GAAG,KAAK,MAAM,IAAIA,GAAG,KAAK,YAAY,EAAE,OAAO,IAAI;EAG1E,IACEA,GAAG,KAAK,UAAU,IAClBA,GAAG,KAAK,SAAS,IACjBA,GAAG,KAAK,UAAU,IAElBA,GAAG,KAAK,WAAW,EACnB;IACA,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd;AAEA,SAAS7B,SAAS,CAACyC,IAAS,EAAEC,GAAQ,EAAE;EACtC,KAAK,MAAMb,GAAG,IAAI3C,MAAM,CAACC,IAAI,CAACuD,GAAG,CAAC,EAAE;IAClCD,IAAI,CAACZ,GAAG,CAAC,GAAG,EAAE,CAACd,MAAM,CAAC0B,IAAI,CAACZ,GAAG,CAAC,IAAI,EAAE,EAAEa,GAAG,CAACb,GAAG,CAAC,CAAC;EAClD;AACF"}
|
1
|
+
{"version":3,"names":["DEPRECATED_KEYS","DEPRECATED_ALIASES","FLIPPED_ALIAS_KEYS","TYPES","isVirtualType","type","virtualTypes","explode","visitor","_exploded","nodeType","Object","keys","shouldIgnoreKey","parts","split","length","fns","part","verify","__esModule","ensureEntranceObjects","ensureCallbackArrays","wrapCheck","types","mergePair","aliases","deprecatedKey","console","trace","deprecatedAlias","alias","existing","_verified","Error","validateVisitorMethods","indexOf","visitors","visitorKey","path","val","concat","fn","TypeError","merge","states","wrapper","rootVisitor","i","state","visitorType","wrapWithStateOrWrapper","nodeVisitor","oldVisitor","newVisitor","key","Array","isArray","map","newFn","call","toString","obj","enter","exit","apply","arguments","dest","src"],"sources":["../src/visitors.ts"],"sourcesContent":["import * as virtualTypes from \"./path/lib/virtual-types\";\nimport {\n DEPRECATED_KEYS,\n DEPRECATED_ALIASES,\n FLIPPED_ALIAS_KEYS,\n TYPES,\n} from \"@babel/types\";\nimport type { NodePath, Visitor } from \"./index\";\n\ntype VIRTUAL_TYPES = keyof typeof virtualTypes;\nfunction isVirtualType(type: string): type is VIRTUAL_TYPES {\n return type in virtualTypes;\n}\n\n/**\n * explode() will take a visitor object with all of the various shorthands\n * that we support, and validates & normalizes it into a common format, ready\n * to be used in traversal\n *\n * The various shorthands are:\n * * `Identifier() { ... }` -> `Identifier: { enter() { ... } }`\n * * `\"Identifier|NumericLiteral\": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }`\n * * Aliases in `@babel/types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }`\n *\n * Other normalizations are:\n * * Visitors of virtual types are wrapped, so that they are only visited when\n * their dynamic check passes\n * * `enter` and `exit` functions are wrapped in arrays, to ease merging of\n * visitors\n */\nexport function explode(visitor: Visitor) {\n if (visitor._exploded) return visitor;\n visitor._exploded = true;\n\n // normalise pipes\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n const parts: Array<string> = nodeType.split(\"|\");\n if (parts.length === 1) continue;\n\n const fns = visitor[nodeType];\n delete visitor[nodeType];\n\n for (const part of parts) {\n // @ts-expect-error part will be verified by `verify` later\n visitor[part] = fns;\n }\n }\n\n // verify data structure\n verify(visitor);\n\n // make sure there's no __esModule type since this is because we're using loose mode\n // and it sets __esModule to be enumerable on all modules :(\n // @ts-expect-error ESModule interop\n delete visitor.__esModule;\n\n // ensure visitors are objects\n ensureEntranceObjects(visitor);\n\n // ensure enter/exit callbacks are arrays\n ensureCallbackArrays(visitor);\n\n // add type wrappers\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (!isVirtualType(nodeType)) continue;\n\n // wrap all the functions\n const fns = visitor[nodeType];\n for (const type of Object.keys(fns)) {\n // @ts-expect-error manipulating visitors\n fns[type] = wrapCheck(nodeType, fns[type]);\n }\n\n // clear it from the visitor\n delete visitor[nodeType];\n\n const types = virtualTypes[nodeType];\n if (types !== null) {\n for (const type of types) {\n // merge the visitor if necessary or just put it back in\n if (visitor[type]) {\n mergePair(visitor[type], fns);\n } else {\n // @ts-expect-error Expression produces too complex union\n visitor[type] = fns;\n }\n }\n } else {\n mergePair(visitor, fns);\n }\n }\n\n // add aliases\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n let aliases = FLIPPED_ALIAS_KEYS[nodeType];\n\n if (nodeType in DEPRECATED_KEYS) {\n const deprecatedKey = DEPRECATED_KEYS[nodeType];\n console.trace(\n `Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`,\n );\n aliases = [deprecatedKey];\n } else if (nodeType in DEPRECATED_ALIASES) {\n const deprecatedAlias =\n DEPRECATED_ALIASES[nodeType as keyof typeof DEPRECATED_ALIASES];\n console.trace(\n `Visitor defined for ${nodeType} but it has been renamed to ${deprecatedAlias}`,\n );\n aliases = FLIPPED_ALIAS_KEYS[deprecatedAlias];\n }\n\n if (!aliases) continue;\n\n const fns = visitor[nodeType];\n // clear it from the visitor\n delete visitor[nodeType];\n\n for (const alias of aliases) {\n const existing = visitor[alias];\n if (existing) {\n mergePair(existing, fns);\n } else {\n // @ts-expect-error Expression produces a union type that is too complex to represent.\n visitor[alias] = { ...fns };\n }\n }\n }\n\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n ensureCallbackArrays(\n // @ts-expect-error nodeType must present in visitor after previous validations\n visitor[nodeType],\n );\n }\n\n return visitor;\n}\n\nexport function verify(visitor: Visitor) {\n if (visitor._verified) return;\n\n if (typeof visitor === \"function\") {\n throw new Error(\n \"You passed `traverse()` a function when it expected a visitor object, \" +\n \"are you sure you didn't mean `{ enter: Function }`?\",\n );\n }\n\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (nodeType === \"enter\" || nodeType === \"exit\") {\n validateVisitorMethods(nodeType, visitor[nodeType]);\n }\n\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (TYPES.indexOf(nodeType) < 0) {\n throw new Error(\n `You gave us a visitor for the node type ${nodeType} but it's not a valid type`,\n );\n }\n\n const visitors = visitor[nodeType];\n if (typeof visitors === \"object\") {\n for (const visitorKey of Object.keys(visitors)) {\n if (visitorKey === \"enter\" || visitorKey === \"exit\") {\n // verify that it just contains functions\n validateVisitorMethods(\n `${nodeType}.${visitorKey}`,\n visitors[visitorKey],\n );\n } else {\n throw new Error(\n \"You passed `traverse()` a visitor object with the property \" +\n `${nodeType} that has the invalid property ${visitorKey}`,\n );\n }\n }\n }\n }\n\n visitor._verified = true;\n}\n\nfunction validateVisitorMethods(\n path: string,\n val: any,\n): asserts val is Function | Function[] {\n const fns = [].concat(val);\n for (const fn of fns) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\n `Non-function found defined in ${path} with type ${typeof fn}`,\n );\n }\n }\n}\n\nexport function merge<State>(visitors: Visitor<State>[]): Visitor<State>;\nexport function merge(\n visitors: Visitor<unknown>[],\n states?: any[],\n wrapper?: Function | null,\n): Visitor<unknown>;\nexport function merge(\n visitors: any[],\n states: any[] = [],\n wrapper?: Function | null,\n) {\n const rootVisitor: Visitor = {};\n\n for (let i = 0; i < visitors.length; i++) {\n const visitor = visitors[i];\n const state = states[i];\n\n explode(visitor);\n\n for (const type of Object.keys(visitor) as (keyof Visitor)[]) {\n let visitorType = visitor[type];\n\n // if we have state or wrapper then overload the callbacks to take it\n if (state || wrapper) {\n visitorType = wrapWithStateOrWrapper(visitorType, state, wrapper);\n }\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n const nodeVisitor = (rootVisitor[type] ||= {});\n mergePair(nodeVisitor, visitorType);\n }\n }\n\n return rootVisitor;\n}\n\nfunction wrapWithStateOrWrapper<State>(\n oldVisitor: Visitor<State>,\n state: State,\n wrapper?: Function | null,\n) {\n const newVisitor: Visitor = {};\n\n for (const key of Object.keys(oldVisitor) as (keyof Visitor<State>)[]) {\n let fns = oldVisitor[key];\n\n // not an enter/exit array of callbacks\n if (!Array.isArray(fns)) continue;\n\n // @ts-expect-error manipulating visitors\n fns = fns.map(function (fn) {\n let newFn = fn;\n\n if (state) {\n newFn = function (path: NodePath) {\n return fn.call(state, path, state);\n };\n }\n\n if (wrapper) {\n // @ts-expect-error Fixme: document state.key\n newFn = wrapper(state.key, key, newFn);\n }\n\n // Override toString in case this function is printed, we want to print the wrapped function, same as we do in `wrapCheck`\n if (newFn !== fn) {\n newFn.toString = () => fn.toString();\n }\n\n return newFn;\n });\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n newVisitor[key] = fns;\n }\n\n return newVisitor;\n}\n\nfunction ensureEntranceObjects(obj: Visitor) {\n for (const key of Object.keys(obj) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(key)) continue;\n\n const fns = obj[key];\n if (typeof fns === \"function\") {\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n obj[key] = { enter: fns };\n }\n }\n}\n\nfunction ensureCallbackArrays(obj: Visitor) {\n // @ts-expect-error normalizing enter property\n if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];\n // @ts-expect-error normalizing exit property\n if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];\n}\n\nfunction wrapCheck(nodeType: VIRTUAL_TYPES, fn: Function) {\n const newFn = function (this: unknown, path: NodePath) {\n if (path[`is${nodeType}`]()) {\n return fn.apply(this, arguments);\n }\n };\n newFn.toString = () => fn.toString();\n return newFn;\n}\n\nfunction shouldIgnoreKey(\n key: string,\n): key is\n | \"enter\"\n | \"exit\"\n | \"shouldSkip\"\n | \"denylist\"\n | \"noScope\"\n | \"skipKeys\"\n | \"blacklist\" {\n // internal/hidden key\n if (key[0] === \"_\") return true;\n\n // ignore function keys\n if (key === \"enter\" || key === \"exit\" || key === \"shouldSkip\") return true;\n\n // ignore other options\n if (\n key === \"denylist\" ||\n key === \"noScope\" ||\n key === \"skipKeys\" ||\n // TODO: Remove in Babel 8\n key === \"blacklist\"\n ) {\n return true;\n }\n\n return false;\n}\n\nfunction mergePair(dest: any, src: any) {\n for (const key of Object.keys(src)) {\n dest[key] = [].concat(dest[key] || [], src[key]);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAKsB;EAJpBA,eAAe;EACfC,kBAAkB;EAClBC,kBAAkB;EAClBC;AAAK;AAKP,SAASC,aAAa,CAACC,IAAY,EAAyB;EAC1D,OAAOA,IAAI,IAAIC,YAAY;AAC7B;AAkBO,SAASC,OAAO,CAACC,OAAgB,EAAE;EACxC,IAAIA,OAAO,CAACC,SAAS,EAAE,OAAOD,OAAO;EACrCA,OAAO,CAACC,SAAS,GAAG,IAAI;EAGxB,KAAK,MAAMC,QAAQ,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CAAC,EAAuB;IAChE,IAAIK,eAAe,CAACH,QAAQ,CAAC,EAAE;IAE/B,MAAMI,KAAoB,GAAGJ,QAAQ,CAACK,KAAK,CAAC,GAAG,CAAC;IAChD,IAAID,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IAExB,MAAMC,GAAG,GAAGT,OAAO,CAACE,QAAQ,CAAC;IAC7B,OAAOF,OAAO,CAACE,QAAQ,CAAC;IAExB,KAAK,MAAMQ,IAAI,IAAIJ,KAAK,EAAE;MAExBN,OAAO,CAACU,IAAI,CAAC,GAAGD,GAAG;IACrB;EACF;EAGAE,MAAM,CAACX,OAAO,CAAC;EAKf,OAAOA,OAAO,CAACY,UAAU;EAGzBC,qBAAqB,CAACb,OAAO,CAAC;EAG9Bc,oBAAoB,CAACd,OAAO,CAAC;EAG7B,KAAK,MAAME,QA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QAAQ,GAAG,MAAMnB,EAAE,CAACmB,QAAQ,EAAE;EACpC,OAAOF,KAAK;AACd;AAEA,SAAS9C,eAAe,CACtB0C,GAAW,EAQG;EAEd,IAAIA,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,OAAO,IAAI;EAG/B,IAAIA,GAAG,KAAK,OAAO,IAAIA,GAAG,KAAK,MAAM,IAAIA,GAAG,KAAK,YAAY,EAAE,OAAO,IAAI;EAG1E,IACEA,GAAG,KAAK,UAAU,IAClBA,GAAG,KAAK,SAAS,IACjBA,GAAG,KAAK,UAAU,IAElBA,GAAG,KAAK,WAAW,EACnB;IACA,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd;AAEA,SAAS9B,SAAS,CAAC0C,IAAS,EAAEC,GAAQ,EAAE;EACtC,KAAK,MAAMb,GAAG,IAAI5C,MAAM,CAACC,IAAI,CAACwD,GAAG,CAAC,EAAE;IAClCD,IAAI,CAACZ,GAAG,CAAC,GAAG,EAAE,CAACd,MAAM,CAAC0B,IAAI,CAACZ,GAAG,CAAC,IAAI,EAAE,EAAEa,GAAG,CAACb,GAAG,CAAC,CAAC;EAClD;AACF"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babel/traverse",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.21.0",
|
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,13 +17,13 @@
|
|
17
17
|
"main": "./lib/index.js",
|
18
18
|
"dependencies": {
|
19
19
|
"@babel/code-frame": "^7.18.6",
|
20
|
-
"@babel/generator": "^7.
|
20
|
+
"@babel/generator": "^7.21.0",
|
21
21
|
"@babel/helper-environment-visitor": "^7.18.9",
|
22
|
-
"@babel/helper-function-name": "^7.
|
22
|
+
"@babel/helper-function-name": "^7.21.0",
|
23
23
|
"@babel/helper-hoist-variables": "^7.18.6",
|
24
24
|
"@babel/helper-split-export-declaration": "^7.18.6",
|
25
|
-
"@babel/parser": "^7.
|
26
|
-
"@babel/types": "^7.
|
25
|
+
"@babel/parser": "^7.21.0",
|
26
|
+
"@babel/types": "^7.21.0",
|
27
27
|
"debug": "^4.1.0",
|
28
28
|
"globals": "^11.1.0"
|
29
29
|
},
|