@babel/traverse 8.0.0-alpha.1 → 8.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +171 -160
- package/lib/index.js.map +1 -1
- package/package.json +11 -10
- package/lib/cache.js +0 -14
- package/lib/cache.js.map +0 -1
- package/lib/context.js +0 -108
- package/lib/context.js.map +0 -1
- package/lib/hub.js +0 -12
- package/lib/hub.js.map +0 -1
- package/lib/path/ancestry.js +0 -126
- package/lib/path/ancestry.js.map +0 -1
- package/lib/path/comments.js +0 -46
- package/lib/path/comments.js.map +0 -1
- package/lib/path/context.js +0 -194
- package/lib/path/context.js.map +0 -1
- package/lib/path/conversion.js +0 -453
- package/lib/path/conversion.js.map +0 -1
- package/lib/path/evaluation.js +0 -333
- package/lib/path/evaluation.js.map +0 -1
- package/lib/path/family.js +0 -322
- package/lib/path/family.js.map +0 -1
- package/lib/path/index.js +0 -185
- package/lib/path/index.js.map +0 -1
- package/lib/path/inference/index.js +0 -137
- package/lib/path/inference/index.js.map +0 -1
- package/lib/path/inference/inferer-reference.js +0 -145
- package/lib/path/inference/inferer-reference.js.map +0 -1
- package/lib/path/inference/inferers.js +0 -172
- package/lib/path/inference/inferers.js.map +0 -1
- package/lib/path/inference/util.js +0 -20
- package/lib/path/inference/util.js.map +0 -1
- package/lib/path/introspection.js +0 -360
- package/lib/path/introspection.js.map +0 -1
- package/lib/path/lib/hoister.js +0 -164
- package/lib/path/lib/hoister.js.map +0 -1
- package/lib/path/lib/removal-hooks.js +0 -31
- package/lib/path/lib/removal-hooks.js.map +0 -1
- package/lib/path/lib/virtual-types-validator.js +0 -138
- package/lib/path/lib/virtual-types-validator.js.map +0 -1
- package/lib/path/lib/virtual-types.js +0 -20
- package/lib/path/lib/virtual-types.js.map +0 -1
- package/lib/path/modification.js +0 -209
- package/lib/path/modification.js.map +0 -1
- package/lib/path/removal.js +0 -46
- package/lib/path/removal.js.map +0 -1
- package/lib/path/replacement.js +0 -192
- package/lib/path/replacement.js.map +0 -1
- package/lib/scope/binding.js +0 -78
- package/lib/scope/binding.js.map +0 -1
- package/lib/scope/index.js +0 -870
- package/lib/scope/index.js.map +0 -1
- package/lib/scope/lib/renamer.js +0 -105
- package/lib/scope/lib/renamer.js.map +0 -1
- package/lib/traverse-node.js +0 -19
- package/lib/traverse-node.js.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lib/visitors.js +0 -210
- package/lib/visitors.js.map +0 -1
package/lib/scope/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["Renamer","traverse","Binding","globals","_t","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","t","scope","scopeCache","isExplodedVisitor","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","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","block","labels","inited","uids","data","crawling","constructor","cached","set","Map","builtin","contextVariables","shouldSkip","listKey","parentPath","isScope","parentBlock","hub","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","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","visit","enter","call","typeVisitors","ref","getPatternParent","isBlockStatement","isProgram","isSwitchStatement","unique","isFunction","isCallExpression","arguments","pushContainer","isLoop","isCatchClause","ensureBlock","blockHoist","_blockHoist","dataKey","declarPath","unshiftContainer","declarator","len","Error","isFunctionParent","isBlockParent","getAllBindings","getAllBindingsOfKind","kinds","bindingIdentifierEquals","getBindingIdentifier","previousPath","isArrowFunctionExpression","getOwnBindingIdentifier","hasOwnBinding","noGlobals","parentHasBinding","noUids","includes","moveBindingTo","info","removeOwnBinding","removeBinding"],"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 * as t from \"@babel/types\";\nimport { scope as scopeCache } from \"../cache\";\nimport type { Visitor } from \"../types\";\nimport { isExplodedVisitor } from \"../visitors\";\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?.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 won't 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 if (process.env.BABEL_8_BREAKING) {\n renamer.rename();\n } else {\n // @ts-ignore(Babel 7 vs Babel 8) TODO: Delete this\n renamer.rename(arguments[2]);\n }\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(\n kind === \"using\" || kind === \"await using\" ? \"const\" : kind,\n declar,\n );\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 this.getBinding(name)?.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\" && isExplodedVisitor(collectorVisitor)) {\n for (const visit of collectorVisitor.enter) {\n visit.call(state, path, state);\n }\n const typeVisitors = collectorVisitor[path.type];\n if (typeVisitors) {\n for (const visit of typeVisitors.enter) {\n visit.call(state, 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 const { init, unique, kind = \"var\", id } = opts;\n\n // When injecting a non-const non-initialized binding inside\n // an IIFE, if the number of call arguments is less than or\n // equal to the number of function parameters, we can safely\n // inject the binding into the parameter list.\n if (\n !init &&\n !unique &&\n (kind === \"var\" || kind === \"let\") &&\n path.isFunction() &&\n // @ts-expect-error ArrowFunctionExpression never has a name\n !path.node.name &&\n t.isCallExpression(path.parent, { callee: path.node }) &&\n path.parent.arguments.length <= path.node.params.length &&\n t.isIdentifier(id)\n ) {\n path.pushContainer(\"params\", id);\n path.scope.registerBinding(\n \"param\",\n path.get(\"params\")[path.node.params.length - 1],\n );\n return;\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 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(id, 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,OAAOA,OAAO,MAAM,kBAAe;AAEnC,OAAOC,QAAQ,MAAM,aAAU;AAE/B,OAAOC,OAAO,MAAM,cAAW;AAE/B,OAAOC,OAAO,MAAM,SAAS;AAC7B,YAAAC,EAAA,MA6CO,cAAc;AAAC;EA5CpBC,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;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AAY,EAAE;IAE1B,IAAI,CAACqC,UAAU,CAACrC,IAAI,CAAC,EAAEjB,KAAK,CAACkO,gBAAgB,CAACjN,IAAI,CAAC;IAGnD,IAAIjB,KAAY,GAAG,IAAI;IACvB,GAAG;MACD,IAAIA,KAAK,CAACgF,IAAI,CAAC/D,IAAI,CAAC,EAAE;QACpBjB,KAAK,CAACgF,IAAI,CAAC/D,IAAI,CAAC,GAAG,KAAK;MAC1B;IACF,CAAC,QAASjB,KAAK,GAAGA,KAAK,CAACyC,MAAM;EAChC;AACF"}
|
package/lib/scope/lib/renamer.js
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
import splitExportDeclaration from "@babel/helper-split-export-declaration";
|
2
|
-
import * as t from "@babel/types";
|
3
|
-
import { requeueComputedKeyAndDecorators } from "@babel/helper-environment-visitor";
|
4
|
-
import { traverseNode } from "../../traverse-node.js";
|
5
|
-
import { explode } from "../../visitors.js";
|
6
|
-
const renameVisitor = {
|
7
|
-
ReferencedIdentifier({
|
8
|
-
node
|
9
|
-
}, state) {
|
10
|
-
if (node.name === state.oldName) {
|
11
|
-
node.name = state.newName;
|
12
|
-
}
|
13
|
-
},
|
14
|
-
Scope(path, state) {
|
15
|
-
if (!path.scope.bindingIdentifierEquals(state.oldName, state.binding.identifier)) {
|
16
|
-
path.skip();
|
17
|
-
if (path.isMethod()) {
|
18
|
-
requeueComputedKeyAndDecorators(path);
|
19
|
-
}
|
20
|
-
}
|
21
|
-
},
|
22
|
-
ObjectProperty({
|
23
|
-
node,
|
24
|
-
scope
|
25
|
-
}, state) {
|
26
|
-
const {
|
27
|
-
name
|
28
|
-
} = node.key;
|
29
|
-
if (node.shorthand && (name === state.oldName || name === state.newName) && scope.getBindingIdentifier(name) === state.binding.identifier) {
|
30
|
-
node.shorthand = false;
|
31
|
-
if (node.extra?.shorthand) node.extra.shorthand = false;
|
32
|
-
}
|
33
|
-
},
|
34
|
-
"AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
|
35
|
-
if (path.isVariableDeclaration()) return;
|
36
|
-
const ids = path.getOuterBindingIdentifiers();
|
37
|
-
for (const name in ids) {
|
38
|
-
if (name === state.oldName) ids[name].name = state.newName;
|
39
|
-
}
|
40
|
-
}
|
41
|
-
};
|
42
|
-
export default class Renamer {
|
43
|
-
constructor(binding, oldName, newName) {
|
44
|
-
this.newName = newName;
|
45
|
-
this.oldName = oldName;
|
46
|
-
this.binding = binding;
|
47
|
-
}
|
48
|
-
maybeConvertFromExportDeclaration(parentDeclar) {
|
49
|
-
const maybeExportDeclar = parentDeclar.parentPath;
|
50
|
-
if (!maybeExportDeclar.isExportDeclaration()) {
|
51
|
-
return;
|
52
|
-
}
|
53
|
-
if (maybeExportDeclar.isExportDefaultDeclaration()) {
|
54
|
-
const {
|
55
|
-
declaration
|
56
|
-
} = maybeExportDeclar.node;
|
57
|
-
if (t.isDeclaration(declaration) && !declaration.id) {
|
58
|
-
return;
|
59
|
-
}
|
60
|
-
}
|
61
|
-
if (maybeExportDeclar.isExportAllDeclaration()) {
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
splitExportDeclaration(maybeExportDeclar);
|
65
|
-
}
|
66
|
-
maybeConvertFromClassFunctionDeclaration(path) {
|
67
|
-
return path;
|
68
|
-
}
|
69
|
-
maybeConvertFromClassFunctionExpression(path) {
|
70
|
-
return path;
|
71
|
-
}
|
72
|
-
rename() {
|
73
|
-
const {
|
74
|
-
binding,
|
75
|
-
oldName,
|
76
|
-
newName
|
77
|
-
} = this;
|
78
|
-
const {
|
79
|
-
scope,
|
80
|
-
path
|
81
|
-
} = binding;
|
82
|
-
const parentDeclar = path.find(path => path.isDeclaration() || path.isFunctionExpression() || path.isClassExpression());
|
83
|
-
if (parentDeclar) {
|
84
|
-
const bindingIds = parentDeclar.getOuterBindingIdentifiers();
|
85
|
-
if (bindingIds[oldName] === binding.identifier) {
|
86
|
-
this.maybeConvertFromExportDeclaration(parentDeclar);
|
87
|
-
}
|
88
|
-
}
|
89
|
-
const blockToTraverse = scope.block;
|
90
|
-
traverseNode(blockToTraverse, explode(renameVisitor), scope, this, scope.path, {
|
91
|
-
discriminant: true
|
92
|
-
});
|
93
|
-
{
|
94
|
-
scope.removeOwnBinding(oldName);
|
95
|
-
scope.bindings[newName] = binding;
|
96
|
-
this.binding.identifier.name = newName;
|
97
|
-
}
|
98
|
-
if (parentDeclar) {
|
99
|
-
this.maybeConvertFromClassFunctionDeclaration(path);
|
100
|
-
this.maybeConvertFromClassFunctionExpression(path);
|
101
|
-
}
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
//# sourceMappingURL=renamer.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["splitExportDeclaration","t","requeueComputedKeyAndDecorators","traverseNode","explode","renameVisitor","ReferencedIdentifier","node","state","name","oldName","newName","Scope","path","scope","bindingIdentifierEquals","binding","identifier","skip","isMethod","ObjectProperty","key","shorthand","getBindingIdentifier","extra","AssignmentExpression|Declaration|VariableDeclarator","isVariableDeclaration","ids","getOuterBindingIdentifiers","Renamer","constructor","maybeConvertFromExportDeclaration","parentDeclar","maybeExportDeclar","parentPath","isExportDeclaration","isExportDefaultDeclaration","declaration","isDeclaration","id","isExportAllDeclaration","maybeConvertFromClassFunctionDeclaration","maybeConvertFromClassFunctionExpression","rename","find","isFunctionExpression","isClassExpression","bindingIds","blockToTraverse","block","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\";\nimport type { Identifier } from \"@babel/types\";\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 ObjectProperty({ node, scope }, state) {\n const { name } = node.key as Identifier;\n if (\n node.shorthand &&\n // In destructuring the identifier is already renamed by the\n // AssignmentExpression|Declaration|VariableDeclarator visitor,\n // while in object literals it's renamed later by the\n // ReferencedIdentifier visitor.\n (name === state.oldName || name === state.newName) &&\n // Ignore shadowed bindings\n scope.getBindingIdentifier(name) === state.binding.identifier\n ) {\n node.shorthand = false;\n if (node.extra?.shorthand) node.extra.shorthand = false;\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,OAAOA,sBAAsB,MAAM,wCAAw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;IAAK,CAAC,GAAGG,OAAO;IAE/B,MAAMgB,YAAY,GAAGnB,IAAI,CAAC+B,IAAI,CAC5B/B,IAAI,IACFA,IAAI,CAACyB,aAAa,CAAC,CAAC,IACpBzB,IAAI,CAACgC,oBAAoB,CAAC,CAAC,IAC3BhC,IAAI,CAACiC,iBAAiB,CAAC,CAC3B,CAAC;IACD,IAAId,YAAY,EAAE;MAChB,MAAMe,UAAU,GAAGf,YAAY,CAACJ,0BAA0B,CAAC,CAAC;MAC5D,IAAImB,UAAU,CAACrC,OAAO,CAAC,KAAKM,OAAO,CAACC,UAAU,EAAE;QAG9C,IAAI,CAACc,iCAAiC,CAACC,YAAY,CAAC;MACtD;IACF;IAEA,MAAMgB,eAAe,GACjBlC,KAAK,CAACmC,KACiD;IAC3D9C,YAAY,CACV6C,eAAe,EACf5C,OAAO,CAACC,aAAa,CAAC,EACtBS,KAAK,EACL,IAAI,EACJA,KAAK,CAACD,IAAI,EAGV;MAAEqC,YAAY,EAAE;IAAK,CACvB,CAAC;IAEiC;MAChCpC,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;IAMA,IAAIqB,YAAY,EAAE;MAChB,IAAI,CAACS,wCAAwC,CAAC5B,IAAI,CAAC;MACnD,IAAI,CAAC6B,uCAAuC,CAAC7B,IAAI,CAAC;IACpD;EACF;AACF"}
|
package/lib/traverse-node.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import TraversalContext from "./context.js";
|
2
|
-
import * as _t from "@babel/types";
|
3
|
-
const {
|
4
|
-
VISITOR_KEYS
|
5
|
-
} = _t;
|
6
|
-
export function traverseNode(node, opts, scope, state, path, skipKeys) {
|
7
|
-
const keys = VISITOR_KEYS[node.type];
|
8
|
-
if (!keys) return false;
|
9
|
-
const context = new TraversalContext(scope, opts, state, path);
|
10
|
-
for (const key of keys) {
|
11
|
-
if (skipKeys && skipKeys[key]) continue;
|
12
|
-
if (context.visit(node, key)) {
|
13
|
-
return true;
|
14
|
-
}
|
15
|
-
}
|
16
|
-
return false;
|
17
|
-
}
|
18
|
-
|
19
|
-
//# sourceMappingURL=traverse-node.js.map
|
package/lib/traverse-node.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["TraversalContext","_t","VISITOR_KEYS","traverseNode","node","opts","scope","state","path","skipKeys","keys","type","context","key","visit"],"sources":["../src/traverse-node.ts"],"sourcesContent":["import TraversalContext from \"./context\";\nimport type { ExplodedTraverseOptions } from \"./index\";\nimport type NodePath from \"./path\";\nimport type Scope from \"./scope\";\nimport type * as t from \"@babel/types\";\nimport { VISITOR_KEYS } from \"@babel/types\";\n\n/**\n * Traverse the children of given node\n * @param {Node} node\n * @param {TraverseOptions} opts The traverse options used to create a new traversal context\n * @param {scope} scope A traversal scope used to create a new traversal context. When opts.noScope is true, scope should not be provided\n * @param {any} state A user data storage provided as the second callback argument for traversal visitors\n * @param {NodePath} path A NodePath of given node\n * @param {Record<string, boolean>} skipKeys A map from key names to whether that should be skipped during traversal. The skipKeys are applied to every descendants\n * @returns {boolean} Whether the traversal stops early\n\n * @note This function does not visit the given `node`.\n */\nexport function traverseNode<S = unknown>(\n node: t.Node,\n opts: ExplodedTraverseOptions<S>,\n scope?: Scope,\n state?: any,\n path?: NodePath,\n skipKeys?: Record<string, boolean>,\n): boolean {\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return false;\n\n const context = new TraversalContext(scope, opts, state, path);\n for (const key of keys) {\n if (skipKeys && skipKeys[key]) continue;\n if (context.visit(node, key)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":"AAAA,OAAOA,gBAAgB,MAAM,cAAW;AAKxC,YAAAC,EAAA,MAA6B,cAAc;AAAC;EAAnCC;AAAY,IAAAD,EAAA;AAcrB,OAAO,SAASE,YAAYA,CAC1BC,IAAY,EACZC,IAAgC,EAChCC,KAAa,EACbC,KAAW,EACXC,IAAe,EACfC,QAAkC,EACzB;EACT,MAAMC,IAAI,GAAGR,YAAY,CAACE,IAAI,CAACO,IAAI,CAAC;EACpC,IAAI,CAACD,IAAI,EAAE,OAAO,KAAK;EAEvB,MAAME,OAAO,GAAG,IAAIZ,gBAAgB,CAACM,KAAK,EAAED,IAAI,EAAEE,KAAK,EAAEC,IAAI,CAAC;EAC9D,KAAK,MAAMK,GAAG,IAAIH,IAAI,EAAE;IACtB,IAAID,QAAQ,IAAIA,QAAQ,CAACI,GAAG,CAAC,EAAE;IAC/B,IAAID,OAAO,CAACE,KAAK,CAACV,IAAI,EAAES,GAAG,CAAC,EAAE;MAC5B,OAAO,IAAI;IACb;EACF;EAEA,OAAO,KAAK;AACd"}
|
package/lib/types.js
DELETED
package/lib/types.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["../src/types.ts"],"sourcesContent":["import type * as t from \"@babel/types\";\nimport type { NodePath } from \"./index\";\nimport type { VirtualTypeAliases } from \"./path/lib/virtual-types\";\n\nexport type VisitPhase = \"enter\" | \"exit\";\n\ntype VisitNodeObject<S, P extends t.Node> = {\n [K in VisitPhase]?: VisitNodeFunction<S, P>;\n};\n\nexport type ExplVisitNode<S, P extends t.Node> = {\n [K in VisitPhase]?: VisitNodeFunction<S, P>[];\n};\n\nexport type ExplodedVisitor<S = unknown> = ExplVisitNode<S, t.Node> & {\n [Type in t.Node[\"type\"]]?: ExplVisitNode<S, Extract<t.Node, { type: Type }>>;\n} & { _exploded: true; _verified: true };\n\nexport type Visitor<S = unknown> =\n | (VisitNodeObject<S, t.Node> & {\n [Type in t.Node[\"type\"]]?: VisitNode<S, Extract<t.Node, { type: Type }>>;\n } & {\n [K in keyof t.Aliases]?: VisitNode<S, t.Aliases[K]>;\n } & {\n [K in keyof VirtualTypeAliases]?: VisitNode<S, VirtualTypeAliases[K]>;\n } & {\n // Babel supports `NodeTypesWithoutComment | NodeTypesWithoutComment | ... ` but it is\n // too complex for TS. So we type it as a general visitor only if the key contains `|`\n // this is good enough for non-visitor traverse options e.g. `noScope`\n [k: `${string}|${string}`]: VisitNode<S, t.Node>;\n })\n | ExplodedVisitor<S>;\n\nexport type VisitNode<S, P extends t.Node> =\n | VisitNodeFunction<S, P>\n | VisitNodeObject<S, P>;\n\nexport type VisitNodeFunction<S, P extends t.Node> = (\n this: S,\n path: NodePath<P>,\n state: S,\n) => void;\n"],"mappings":""}
|
package/lib/visitors.js
DELETED
@@ -1,210 +0,0 @@
|
|
1
|
-
import * as virtualTypes from "./path/lib/virtual-types.js";
|
2
|
-
import * as _t from "@babel/types";
|
3
|
-
const {
|
4
|
-
DEPRECATED_KEYS,
|
5
|
-
DEPRECATED_ALIASES,
|
6
|
-
FLIPPED_ALIAS_KEYS,
|
7
|
-
TYPES,
|
8
|
-
__internal__deprecationWarning: deprecationWarning
|
9
|
-
} = _t;
|
10
|
-
function isVirtualType(type) {
|
11
|
-
return type in virtualTypes;
|
12
|
-
}
|
13
|
-
export function isExplodedVisitor(visitor) {
|
14
|
-
return visitor?._exploded;
|
15
|
-
}
|
16
|
-
export function explode(visitor) {
|
17
|
-
if (isExplodedVisitor(visitor)) return visitor;
|
18
|
-
visitor._exploded = true;
|
19
|
-
for (const nodeType of Object.keys(visitor)) {
|
20
|
-
if (shouldIgnoreKey(nodeType)) continue;
|
21
|
-
const parts = nodeType.split("|");
|
22
|
-
if (parts.length === 1) continue;
|
23
|
-
const fns = visitor[nodeType];
|
24
|
-
delete visitor[nodeType];
|
25
|
-
for (const part of parts) {
|
26
|
-
visitor[part] = fns;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
verify(visitor);
|
30
|
-
delete visitor.__esModule;
|
31
|
-
ensureEntranceObjects(visitor);
|
32
|
-
ensureCallbackArrays(visitor);
|
33
|
-
for (const nodeType of Object.keys(visitor)) {
|
34
|
-
if (shouldIgnoreKey(nodeType)) continue;
|
35
|
-
if (!isVirtualType(nodeType)) continue;
|
36
|
-
const fns = visitor[nodeType];
|
37
|
-
for (const type of Object.keys(fns)) {
|
38
|
-
fns[type] = wrapCheck(nodeType, fns[type]);
|
39
|
-
}
|
40
|
-
delete visitor[nodeType];
|
41
|
-
const types = virtualTypes[nodeType];
|
42
|
-
if (types !== null) {
|
43
|
-
for (const type of types) {
|
44
|
-
if (visitor[type]) {
|
45
|
-
mergePair(visitor[type], fns);
|
46
|
-
} else {
|
47
|
-
visitor[type] = fns;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
} else {
|
51
|
-
mergePair(visitor, fns);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
for (const nodeType of Object.keys(visitor)) {
|
55
|
-
if (shouldIgnoreKey(nodeType)) continue;
|
56
|
-
let aliases = FLIPPED_ALIAS_KEYS[nodeType];
|
57
|
-
if (nodeType in DEPRECATED_KEYS) {
|
58
|
-
const deprecatedKey = DEPRECATED_KEYS[nodeType];
|
59
|
-
deprecationWarning(nodeType, deprecatedKey, "Visitor ");
|
60
|
-
aliases = [deprecatedKey];
|
61
|
-
} else if (nodeType in DEPRECATED_ALIASES) {
|
62
|
-
const deprecatedAlias = DEPRECATED_ALIASES[nodeType];
|
63
|
-
deprecationWarning(nodeType, deprecatedAlias, "Visitor ");
|
64
|
-
aliases = FLIPPED_ALIAS_KEYS[deprecatedAlias];
|
65
|
-
}
|
66
|
-
if (!aliases) continue;
|
67
|
-
const fns = visitor[nodeType];
|
68
|
-
delete visitor[nodeType];
|
69
|
-
for (const alias of aliases) {
|
70
|
-
const existing = visitor[alias];
|
71
|
-
if (existing) {
|
72
|
-
mergePair(existing, fns);
|
73
|
-
} else {
|
74
|
-
visitor[alias] = Object.assign({}, fns);
|
75
|
-
}
|
76
|
-
}
|
77
|
-
}
|
78
|
-
for (const nodeType of Object.keys(visitor)) {
|
79
|
-
if (shouldIgnoreKey(nodeType)) continue;
|
80
|
-
ensureCallbackArrays(visitor[nodeType]);
|
81
|
-
}
|
82
|
-
return visitor;
|
83
|
-
}
|
84
|
-
export function verify(visitor) {
|
85
|
-
if (visitor._verified) return;
|
86
|
-
if (typeof visitor === "function") {
|
87
|
-
throw new Error("You passed `traverse()` a function when it expected a visitor object, " + "are you sure you didn't mean `{ enter: Function }`?");
|
88
|
-
}
|
89
|
-
for (const nodeType of Object.keys(visitor)) {
|
90
|
-
if (nodeType === "enter" || nodeType === "exit") {
|
91
|
-
validateVisitorMethods(nodeType, visitor[nodeType]);
|
92
|
-
}
|
93
|
-
if (shouldIgnoreKey(nodeType)) continue;
|
94
|
-
if (TYPES.indexOf(nodeType) < 0) {
|
95
|
-
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`);
|
96
|
-
}
|
97
|
-
const visitors = visitor[nodeType];
|
98
|
-
if (typeof visitors === "object") {
|
99
|
-
for (const visitorKey of Object.keys(visitors)) {
|
100
|
-
if (visitorKey === "enter" || visitorKey === "exit") {
|
101
|
-
validateVisitorMethods(`${nodeType}.${visitorKey}`, visitors[visitorKey]);
|
102
|
-
} else {
|
103
|
-
throw new Error("You passed `traverse()` a visitor object with the property " + `${nodeType} that has the invalid property ${visitorKey}`);
|
104
|
-
}
|
105
|
-
}
|
106
|
-
}
|
107
|
-
}
|
108
|
-
visitor._verified = true;
|
109
|
-
}
|
110
|
-
function validateVisitorMethods(path, val) {
|
111
|
-
const fns = [].concat(val);
|
112
|
-
for (const fn of fns) {
|
113
|
-
if (typeof fn !== "function") {
|
114
|
-
throw new TypeError(`Non-function found defined in ${path} with type ${typeof fn}`);
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
export function merge(visitors, states = [], wrapper) {
|
119
|
-
const mergedVisitor = {};
|
120
|
-
for (let i = 0; i < visitors.length; i++) {
|
121
|
-
const visitor = explode(visitors[i]);
|
122
|
-
const state = states[i];
|
123
|
-
let topVisitor = visitor;
|
124
|
-
if (state || wrapper) {
|
125
|
-
topVisitor = wrapWithStateOrWrapper(topVisitor, state, wrapper);
|
126
|
-
}
|
127
|
-
mergePair(mergedVisitor, topVisitor);
|
128
|
-
for (const key of Object.keys(visitor)) {
|
129
|
-
if (shouldIgnoreKey(key)) continue;
|
130
|
-
let typeVisitor = visitor[key];
|
131
|
-
if (state || wrapper) {
|
132
|
-
typeVisitor = wrapWithStateOrWrapper(typeVisitor, state, wrapper);
|
133
|
-
}
|
134
|
-
const nodeVisitor = mergedVisitor[key] ||= {};
|
135
|
-
mergePair(nodeVisitor, typeVisitor);
|
136
|
-
}
|
137
|
-
}
|
138
|
-
{
|
139
|
-
return Object.assign({}, mergedVisitor, {
|
140
|
-
_exploded: true,
|
141
|
-
_verified: true
|
142
|
-
});
|
143
|
-
}
|
144
|
-
return mergedVisitor;
|
145
|
-
}
|
146
|
-
function wrapWithStateOrWrapper(oldVisitor, state, wrapper) {
|
147
|
-
const newVisitor = {};
|
148
|
-
for (const phase of ["enter", "exit"]) {
|
149
|
-
let fns = oldVisitor[phase];
|
150
|
-
if (!Array.isArray(fns)) continue;
|
151
|
-
fns = fns.map(function (fn) {
|
152
|
-
let newFn = fn;
|
153
|
-
if (state) {
|
154
|
-
newFn = function (path) {
|
155
|
-
fn.call(state, path, state);
|
156
|
-
};
|
157
|
-
}
|
158
|
-
if (wrapper) {
|
159
|
-
newFn = wrapper(state?.key, phase, newFn);
|
160
|
-
}
|
161
|
-
if (newFn !== fn) {
|
162
|
-
newFn.toString = () => fn.toString();
|
163
|
-
}
|
164
|
-
return newFn;
|
165
|
-
});
|
166
|
-
newVisitor[phase] = fns;
|
167
|
-
}
|
168
|
-
return newVisitor;
|
169
|
-
}
|
170
|
-
function ensureEntranceObjects(obj) {
|
171
|
-
for (const key of Object.keys(obj)) {
|
172
|
-
if (shouldIgnoreKey(key)) continue;
|
173
|
-
const fns = obj[key];
|
174
|
-
if (typeof fns === "function") {
|
175
|
-
obj[key] = {
|
176
|
-
enter: fns
|
177
|
-
};
|
178
|
-
}
|
179
|
-
}
|
180
|
-
}
|
181
|
-
function ensureCallbackArrays(obj) {
|
182
|
-
if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];
|
183
|
-
if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];
|
184
|
-
}
|
185
|
-
function wrapCheck(nodeType, fn) {
|
186
|
-
const newFn = function (path) {
|
187
|
-
if (path[`is${nodeType}`]()) {
|
188
|
-
return fn.apply(this, arguments);
|
189
|
-
}
|
190
|
-
};
|
191
|
-
newFn.toString = () => fn.toString();
|
192
|
-
return newFn;
|
193
|
-
}
|
194
|
-
function shouldIgnoreKey(key) {
|
195
|
-
if (key[0] === "_") return true;
|
196
|
-
if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
|
197
|
-
if (key === "denylist" || key === "noScope" || key === "skipKeys") {
|
198
|
-
return true;
|
199
|
-
}
|
200
|
-
;
|
201
|
-
return false;
|
202
|
-
}
|
203
|
-
function mergePair(dest, src) {
|
204
|
-
for (const phase of ["enter", "exit"]) {
|
205
|
-
if (!src[phase]) continue;
|
206
|
-
dest[phase] = [].concat(dest[phase] || [], src[phase]);
|
207
|
-
}
|
208
|
-
}
|
209
|
-
|
210
|
-
//# sourceMappingURL=visitors.js.map
|
package/lib/visitors.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["virtualTypes","_t","DEPRECATED_KEYS","DEPRECATED_ALIASES","FLIPPED_ALIAS_KEYS","TYPES","__internal__deprecationWarning","deprecationWarning","isVirtualType","type","isExplodedVisitor","visitor","_exploded","explode","nodeType","Object","keys","shouldIgnoreKey","parts","split","length","fns","part","verify","__esModule","ensureEntranceObjects","ensureCallbackArrays","wrapCheck","types","mergePair","aliases","deprecatedKey","deprecatedAlias","alias","existing","assign","_verified","Error","validateVisitorMethods","indexOf","visitors","visitorKey","path","val","concat","fn","TypeError","merge","states","wrapper","mergedVisitor","i","state","topVisitor","wrapWithStateOrWrapper","key","typeVisitor","nodeVisitor","oldVisitor","newVisitor","phase","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 type { Node } from \"@babel/types\";\nimport {\n DEPRECATED_KEYS,\n DEPRECATED_ALIASES,\n FLIPPED_ALIAS_KEYS,\n TYPES,\n __internal__deprecationWarning as deprecationWarning,\n} from \"@babel/types\";\nimport type { ExplodedVisitor, NodePath, Visitor } from \"./index\";\nimport type { ExplVisitNode, VisitNodeFunction, VisitPhase } from \"./types\";\n\ntype VIRTUAL_TYPES = keyof typeof virtualTypes;\nfunction isVirtualType(type: string): type is VIRTUAL_TYPES {\n return type in virtualTypes;\n}\nexport type VisitWrapper<S = any> = (\n stateName: string | undefined,\n visitorType: VisitPhase,\n callback: VisitNodeFunction<S, Node>,\n) => VisitNodeFunction<S, Node>;\n\nexport function isExplodedVisitor(\n visitor: Visitor,\n): visitor is ExplodedVisitor {\n // @ts-expect-error _exploded is not defined on non-exploded Visitor\n return visitor?._exploded;\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 * 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<S>(visitor: Visitor<S>): ExplodedVisitor<S> {\n if (isExplodedVisitor(visitor)) return visitor;\n // @ts-expect-error `visitor` will be cast to ExplodedVisitor by this function\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 normalised as VisitNodeObject\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 deprecationWarning(nodeType, deprecatedKey, \"Visitor \");\n aliases = [deprecatedKey];\n } else if (nodeType in DEPRECATED_ALIASES) {\n const deprecatedAlias =\n DEPRECATED_ALIASES[nodeType as keyof typeof DEPRECATED_ALIASES];\n deprecationWarning(nodeType, deprecatedAlias, \"Visitor \");\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 // @ts-expect-error explosion has been performed\n return visitor as ExplodedVisitor;\n}\n\nexport function verify(visitor: Visitor) {\n // @ts-expect-error _verified is not defined on non-verified Visitor.\n // TODO: unify _verified and _exploded.\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 // @ts-expect-error _verified is not defined on non-verified Visitor.\n // TODO: unify _verified and _exploded.\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>(\n visitors: Visitor<State>[],\n): ExplodedVisitor<State>;\nexport function merge(\n visitors: Visitor<unknown>[],\n states?: any[],\n wrapper?: Function | null,\n): ExplodedVisitor<unknown>;\nexport function merge(\n visitors: any[],\n states: any[] = [],\n wrapper?: VisitWrapper | null,\n): ExplodedVisitor {\n // @ts-expect-error don't bother with internal flags so it can work with earlier @babel/core validations\n const mergedVisitor: ExplodedVisitor = {};\n\n for (let i = 0; i < visitors.length; i++) {\n const visitor = explode(visitors[i]);\n const state = states[i];\n\n let topVisitor: ExplVisitNode<unknown, Node> = visitor;\n if (state || wrapper) {\n topVisitor = wrapWithStateOrWrapper(topVisitor, state, wrapper);\n }\n mergePair(mergedVisitor, topVisitor);\n\n for (const key of Object.keys(visitor) as (keyof ExplodedVisitor)[]) {\n if (shouldIgnoreKey(key)) continue;\n\n let typeVisitor = visitor[key];\n\n // if we have state or wrapper then overload the callbacks to take it\n if (state || wrapper) {\n typeVisitor = wrapWithStateOrWrapper(typeVisitor, state, wrapper);\n }\n\n const nodeVisitor = (mergedVisitor[key] ||= {});\n mergePair(nodeVisitor, typeVisitor);\n }\n }\n\n if (process.env.BABEL_8_BREAKING) {\n return {\n ...mergedVisitor,\n _exploded: true,\n _verified: true,\n };\n }\n\n return mergedVisitor;\n}\n\nfunction wrapWithStateOrWrapper<State>(\n oldVisitor: ExplVisitNode<State, Node>,\n state: State | null,\n wrapper?: VisitWrapper<State> | null,\n): ExplVisitNode<State, Node> {\n const newVisitor: ExplVisitNode<State, Node> = {};\n\n for (const phase of [\"enter\", \"exit\"] as VisitPhase[]) {\n let fns = oldVisitor[phase];\n\n // not an enter/exit array of callbacks\n if (!Array.isArray(fns)) continue;\n\n fns = fns.map(function (fn) {\n let newFn = fn;\n\n if (state) {\n newFn = function (path: NodePath) {\n fn.call(state, path, state);\n };\n }\n\n if (wrapper) {\n // @ts-expect-error Fixme: actually PluginPass.key (aka pluginAlias)?\n newFn = wrapper(state?.key, phase, 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 newVisitor[phase] = 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 if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];\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 | `_${string}`\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 (key === \"denylist\" || key === \"noScope\" || key === \"skipKeys\") {\n return true;\n }\n\n if (!process.env.BABEL_8_BREAKING) {\n if (key === \"blacklist\") {\n return true;\n }\n }\n\n return false;\n}\n\n/*\nfunction mergePair(\n dest: ExplVisitNode<unknown, Node>,\n src: ExplVisitNode<unknown, Node>,\n);\n*/\nfunction mergePair(dest: any, src: any) {\n for (const phase of [\"enter\", \"exit\"] as VisitPhase[]) {\n if (!src[phase]) continue;\n dest[phase] = [].concat(dest[phase] || [], src[phase]);\n }\n}\n"],"mappings":"AAAA,OAAO,KAAKA,YAAY,MAA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