challenge-algorithms-v2.0-u.../node_modules/@babel/helpers/lib/index.js.map

1 line
19 KiB
Plaintext

{"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<t.Identifier, string>;\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<string>();\n const localBindingNames = new Set<string>();\n // Maps imported identifier -> helper name\n const dependencies = new Map<t.Identifier, string>();\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<string, t.Expression> = {};\n dependencies.forEach((name, id) => {\n dependenciesRefs[id.name] =\n (typeof getDependency === \"function\" && getDependency(name)) || id;\n });\n\n const toRename: Record<string, string> = {};\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<t.ExportDefaultDeclaration> = path.get(exportPath);\n const imps: NodePath<t.ImportDeclaration>[] = importPaths.map(p =>\n path.get(p),\n );\n const impsBindingRefs: NodePath<t.Identifier>[] =\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<t.FunctionDeclaration>;\n\n if (id.type === \"Identifier\") {\n exp.replaceWith(decl);\n } else if (id.type === \"MemberExpression\") {\n exportBindingAssignments.forEach(assignPath => {\n const assign: NodePath<t.Expression> = 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<string, HelperData> = 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<string> {\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;;;EAPEA,oB;EACAC,S;EACAC,mB;EACAC,I;EACAC;;;AAKF,SAASC,QAAT,CAAkBC,IAAlB,EAAkC;EAChC,MAAMC,KAAK,GAAG,EAAd;;EAEA,OAAOD,IAAI,CAACE,UAAZ,EAAwBF,IAAI,GAAGA,IAAI,CAACE,UAApC,EAAgD;IAC9CD,KAAK,CAACE,IAAN,CAAWH,IAAI,CAACI,GAAhB;IACA,IAAIJ,IAAI,CAACK,MAAT,EAAiBJ,KAAK,CAACE,IAAN,CAAWH,IAAI,CAACM,OAAhB;EAClB;;EAED,OAAOL,KAAK,CAACM,OAAN,GAAgBC,IAAhB,CAAqB,GAArB,CAAP;AACD;;AAED,IAAIC,S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