{"version":3,"names":["assignmentExpression","cloneNode","expressionStatement","file","identifier","makePath","path","parts","parentPath","push","key","inList","listKey","reverse","join","FileClass","undefined","getHelperMetadata","globals","Set","localBindingNames","dependencies","Map","exportName","exportPath","exportBindingAssignments","importPaths","importBindingsReferences","dependencyVisitor","ImportDeclaration","child","name","node","source","value","helpers","buildCodeFrameError","get","length","isImportDefaultSpecifier","bindingIdentifier","specifiers","local","set","ExportDefaultDeclaration","decl","isFunctionDeclaration","id","ExportAllDeclaration","ExportNamedDeclaration","Statement","isModuleDeclaration","skip","referenceVisitor","Program","bindings","scope","getAllBindings","Object","keys","forEach","has","add","ReferencedIdentifier","binding","getBinding","AssignmentExpression","left","getBindingIdentifiers","isIdentifier","isProgram","traverse","ast","Error","Array","from","permuteHelperAST","metadata","localBindings","getDependency","dependenciesRefs","toRename","newName","type","exp","imps","map","p","impsBindingRefs","replaceWith","assignPath","assign","pushContainer","rename","remove","helperData","create","loadHelper","helper","ReferenceError","code","fn","fakeFile","stop","filename","inputMap","minVersion","build","nodes","program","body","getDependencies","values","ensure","newFileClass","list","replace"],"sources":["../src/index.ts"],"sourcesContent":["import type { File } from \"@babel/core\";\nimport type { NodePath, Visitor } from \"@babel/traverse\";\nimport traverse from \"@babel/traverse\";\nimport {\n assignmentExpression,\n cloneNode,\n expressionStatement,\n file,\n identifier,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport helpers from \"./helpers\";\n\nfunction makePath(path: NodePath) {\n const parts = [];\n\n for (; path.parentPath; path = path.parentPath) {\n parts.push(path.key);\n if (path.inList) parts.push(path.listKey);\n }\n\n return parts.reverse().join(\".\");\n}\n\nlet FileClass: typeof File | undefined = undefined;\n\ninterface HelperMetadata {\n globals: string[];\n localBindingNames: string[];\n dependencies: Map;\n exportBindingAssignments: string[];\n exportPath: string;\n exportName: string;\n importBindingsReferences: string[];\n importPaths: string[];\n}\n\n/**\n * Given a file AST for a given helper, get a bunch of metadata about it so that Babel can quickly render\n * the helper is whatever context it is needed in.\n */\nfunction getHelperMetadata(file: File): HelperMetadata {\n const globals = new Set();\n const localBindingNames = new Set();\n // Maps imported identifier -> helper name\n const dependencies = new Map();\n\n let exportName: string | undefined;\n let exportPath: string | undefined;\n const exportBindingAssignments: string[] = [];\n const importPaths: string[] = [];\n const importBindingsReferences: string[] = [];\n\n const dependencyVisitor: Visitor = {\n ImportDeclaration(child) {\n const name = child.node.source.value;\n if (!helpers[name]) {\n throw child.buildCodeFrameError(`Unknown helper ${name}`);\n }\n if (\n child.get(\"specifiers\").length !== 1 ||\n // @ts-expect-error isImportDefaultSpecifier does not work with NodePath union\n !child.get(\"specifiers.0\").isImportDefaultSpecifier()\n ) {\n throw child.buildCodeFrameError(\n \"Helpers can only import a default value\",\n );\n }\n const bindingIdentifier = child.node.specifiers[0].local;\n dependencies.set(bindingIdentifier, name);\n importPaths.push(makePath(child));\n },\n ExportDefaultDeclaration(child) {\n const decl = child.get(\"declaration\");\n\n if (!decl.isFunctionDeclaration() || !decl.node.id) {\n throw decl.buildCodeFrameError(\n \"Helpers can only export named function declarations\",\n );\n }\n\n exportName = decl.node.id.name;\n exportPath = makePath(child);\n },\n ExportAllDeclaration(child) {\n throw child.buildCodeFrameError(\"Helpers can only export default\");\n },\n ExportNamedDeclaration(child) {\n throw child.buildCodeFrameError(\"Helpers can only export default\");\n },\n Statement(child) {\n if (child.isModuleDeclaration()) return;\n\n child.skip();\n },\n };\n\n const referenceVisitor: Visitor = {\n Program(path) {\n const bindings = path.scope.getAllBindings();\n\n Object.keys(bindings).forEach(name => {\n if (name === exportName) return;\n if (dependencies.has(bindings[name].identifier)) return;\n\n localBindingNames.add(name);\n });\n },\n ReferencedIdentifier(child) {\n const name = child.node.name;\n const binding = child.scope.getBinding(name);\n if (!binding) {\n globals.add(name);\n } else if (dependencies.has(binding.identifier)) {\n importBindingsReferences.push(makePath(child));\n }\n },\n AssignmentExpression(child) {\n const left = child.get(\"left\");\n\n if (!(exportName in left.getBindingIdentifiers())) return;\n\n if (!left.isIdentifier()) {\n throw left.buildCodeFrameError(\n \"Only simple assignments to exports are allowed in helpers\",\n );\n }\n\n const binding = child.scope.getBinding(exportName);\n\n if (binding?.scope.path.isProgram()) {\n exportBindingAssignments.push(makePath(child));\n }\n },\n };\n\n traverse(file.ast, dependencyVisitor, file.scope);\n traverse(file.ast, referenceVisitor, file.scope);\n\n if (!exportPath) throw new Error(\"Helpers must have a default export.\");\n\n // Process these in reverse so that mutating the references does not invalidate any later paths in\n // the list.\n exportBindingAssignments.reverse();\n\n return {\n globals: Array.from(globals),\n localBindingNames: Array.from(localBindingNames),\n dependencies,\n exportBindingAssignments,\n exportPath,\n exportName,\n importBindingsReferences,\n importPaths,\n };\n}\n\ntype GetDependency = (name: string) => t.Expression;\n\n/**\n * Given a helper AST and information about how it will be used, update the AST to match the usage.\n */\nfunction permuteHelperAST(\n file: File,\n metadata: HelperMetadata,\n id?: t.Identifier | t.MemberExpression,\n localBindings?: string[],\n getDependency?: GetDependency,\n) {\n if (localBindings && !id) {\n throw new Error(\"Unexpected local bindings for module-based helpers.\");\n }\n\n if (!id) return;\n\n const {\n localBindingNames,\n dependencies,\n exportBindingAssignments,\n exportPath,\n exportName,\n importBindingsReferences,\n importPaths,\n } = metadata;\n\n const dependenciesRefs: Record = {};\n dependencies.forEach((name, id) => {\n dependenciesRefs[id.name] =\n (typeof getDependency === \"function\" && getDependency(name)) || id;\n });\n\n const toRename: Record = {};\n const bindings = new Set(localBindings || []);\n localBindingNames.forEach(name => {\n let newName = name;\n while (bindings.has(newName)) newName = \"_\" + newName;\n\n if (newName !== name) toRename[name] = newName;\n });\n\n if (id.type === \"Identifier\" && exportName !== id.name) {\n toRename[exportName] = id.name;\n }\n\n const { path } = file;\n\n // We need to compute these in advance because removing nodes would\n // invalidate the paths.\n const exp: NodePath = path.get(exportPath);\n const imps: NodePath[] = importPaths.map(p =>\n path.get(p),\n );\n const impsBindingRefs: NodePath[] =\n importBindingsReferences.map(p => path.get(p));\n\n // We assert that this is a FunctionDeclaration in dependencyVisitor.\n const decl = exp.get(\"declaration\") as NodePath;\n\n if (id.type === \"Identifier\") {\n exp.replaceWith(decl);\n } else if (id.type === \"MemberExpression\") {\n exportBindingAssignments.forEach(assignPath => {\n const assign: NodePath = path.get(assignPath);\n assign.replaceWith(assignmentExpression(\"=\", id, assign.node));\n });\n exp.replaceWith(decl);\n path.pushContainer(\n \"body\",\n expressionStatement(\n assignmentExpression(\"=\", id, identifier(exportName)),\n ),\n );\n } else {\n throw new Error(\"Unexpected helper format.\");\n }\n\n Object.keys(toRename).forEach(name => {\n path.scope.rename(name, toRename[name]);\n });\n\n for (const path of imps) path.remove();\n for (const path of impsBindingRefs) {\n const node = cloneNode(dependenciesRefs[path.node.name]);\n path.replaceWith(node);\n }\n}\n\ninterface HelperData {\n build: (\n getDependency: GetDependency,\n id: t.Identifier | t.MemberExpression,\n localBindings: string[],\n ) => {\n nodes: t.Program[\"body\"];\n globals: string[];\n };\n minVersion: string;\n getDependencies: () => string[];\n}\n\nconst helperData: Record = Object.create(null);\nfunction loadHelper(name: string) {\n if (!helperData[name]) {\n const helper = helpers[name];\n if (!helper) {\n throw Object.assign(new ReferenceError(`Unknown helper ${name}`), {\n code: \"BABEL_HELPER_UNKNOWN\",\n helper: name,\n });\n }\n\n const fn = (): File => {\n if (!process.env.BABEL_8_BREAKING) {\n if (!FileClass) {\n const fakeFile = { ast: file(helper.ast()), path: null } as File;\n traverse(fakeFile.ast, {\n Program: path => (fakeFile.path = path).stop(),\n });\n return fakeFile;\n }\n }\n return new FileClass(\n { filename: `babel-helper://${name}` },\n {\n ast: file(helper.ast()),\n code: \"[internal Babel helper code]\",\n inputMap: null,\n },\n );\n };\n\n // We compute the helper metadata lazily, so that we skip that\n // work if we only need the `.minVersion` (for example because\n // of a call to `.availableHelper` when `@babel/rutime`).\n let metadata: HelperMetadata | null = null;\n\n helperData[name] = {\n minVersion: helper.minVersion,\n build(getDependency, id, localBindings) {\n const file = fn();\n metadata ||= getHelperMetadata(file);\n permuteHelperAST(file, metadata, id, localBindings, getDependency);\n\n return {\n nodes: file.ast.program.body,\n globals: metadata.globals,\n };\n },\n getDependencies() {\n metadata ||= getHelperMetadata(fn());\n return Array.from(metadata.dependencies.values());\n },\n };\n }\n\n return helperData[name];\n}\n\nexport function get(\n name: string,\n getDependency?: GetDependency,\n id?: t.Identifier | t.MemberExpression,\n localBindings?: string[],\n) {\n return loadHelper(name).build(getDependency, id, localBindings);\n}\n\nexport function minVersion(name: string) {\n return loadHelper(name).minVersion;\n}\n\nexport function getDependencies(name: string): ReadonlyArray {\n return loadHelper(name).getDependencies();\n}\n\nexport function ensure(name: string, newFileClass: typeof File) {\n // We inject the File class here rather than importing it to avoid\n // circular dependencies between @babel/core and @babel/helpers.\n FileClass ||= newFileClass;\n\n loadHelper(name);\n}\n\nexport const list = Object.keys(helpers).map(name => name.replace(/^_/, \"\"));\n\nexport default get;\n"],"mappings":";;;;;;;;;;;AAEA;AACA;AAQA;AAAgC;EAP9BA,oBAAoB;EACpBC,SAAS;EACTC,mBAAmB;EACnBC,IAAI;EACJC;AAAU;AAKZ,SAASC,QAAQ,CAACC,IAAc,EAAE;EAChC,MAAMC,KAAK,GAAG,EAAE;EAEhB,OAAOD,IAAI,CAACE,UAAU,EAAEF,IAAI,GAAGA,IAAI,CAACE,UAAU,EAAE;IAC9CD,KAAK,CAACE,IAAI,CAACH,IAAI,CAACI,GAAG,CAAC;IACpB,IAAIJ,IAAI,CAACK,MAAM,EAAEJ,KAAK,CAACE,IAAI,CAACH,IAAI,CAACM,OAAO,CAAC;EAC3C;EAEA,OAAOL,KAAK,CAACM,OAAO,EAAE,CAACC,IAAI,CAAC,GAAG,CAAC;AAClC;AAEA,IAAIC,SAAkC,GAAGC,SAAS;AAiBlD,SAASC,iBAAiB,CAACd,IAAU,EAAkB;EACrD,MAAMe,OAAO,GAAG,IAAIC,GAAG,EAAU;EACjC,MAAMC,iBAAiB,GAAG,IAAID,GAAG,EAAU;EAE3C,MAAME,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