the-forest/client/node_modules/@babel/plugin-transform-classes/lib/index.js.map
2024-09-17 20:35:18 -04:00

1 line
7.3 KiB
Plaintext

{"version":3,"names":["_helperPluginUtils","require","_helperCompilationTargets","_helperAnnotateAsPure","_core","_globals","_transformClass","getBuiltinClasses","category","Object","keys","globals","filter","name","test","builtinClasses","Set","_default","exports","default","declare","api","options","_api$assumption","_api$assumption2","_api$assumption3","_api$assumption4","assertVersion","loose","setClassMethods","assumption","constantSuper","superIsCallableConstructor","noClassCalls","supportUnicodeId","isRequired","targets","VISITED","WeakSet","visitor","ExportDefaultDeclaration","path","get","isClassDeclaration","_path$splitExportDecl","splitExportDeclaration","NodePath","prototype","ClassDeclaration","node","ref","id","scope","generateUidIdentifier","replaceWith","t","variableDeclaration","variableDeclarator","toExpression","ClassExpression","state","has","_path$ensureFunctionN","ensureFunctionName","replacement","add","replacedPath","transformClass","file","isCallExpression","annotateAsPure","callee","isArrowFunctionExpression","arrowFunctionToExpression"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { isRequired } from \"@babel/helper-compilation-targets\";\nimport annotateAsPure from \"@babel/helper-annotate-as-pure\";\nimport { types as t } from \"@babel/core\";\nimport globals from \"globals\";\nimport transformClass from \"./transformClass.ts\";\n\nconst getBuiltinClasses = (category: keyof typeof globals) =>\n Object.keys(globals[category]).filter(name => /^[A-Z]/.test(name));\n\nconst builtinClasses = new Set([\n ...getBuiltinClasses(\"builtin\"),\n ...getBuiltinClasses(\"browser\"),\n]);\n\nexport interface Options {\n loose?: boolean;\n}\n\nexport default declare((api, options: Options) => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n const { loose = false } = options;\n\n const setClassMethods = api.assumption(\"setClassMethods\") ?? loose;\n const constantSuper = api.assumption(\"constantSuper\") ?? loose;\n const superIsCallableConstructor =\n api.assumption(\"superIsCallableConstructor\") ?? loose;\n const noClassCalls = api.assumption(\"noClassCalls\") ?? loose;\n const supportUnicodeId = !isRequired(\n \"transform-unicode-escapes\",\n api.targets(),\n );\n\n // todo: investigate traversal requeueing\n const VISITED = new WeakSet();\n\n return {\n name: \"transform-classes\",\n\n visitor: {\n ExportDefaultDeclaration(path) {\n if (!path.get(\"declaration\").isClassDeclaration()) return;\n if (!process.env.BABEL_8_BREAKING && !USE_ESM && !IS_STANDALONE) {\n // polyfill when being run by an older Babel version\n path.splitExportDeclaration ??=\n // eslint-disable-next-line no-restricted-globals\n require(\"@babel/traverse\").NodePath.prototype.splitExportDeclaration;\n }\n path.splitExportDeclaration();\n },\n\n ClassDeclaration(path) {\n const { node } = path;\n\n const ref = node.id || path.scope.generateUidIdentifier(\"class\");\n\n path.replaceWith(\n t.variableDeclaration(\"let\", [\n t.variableDeclarator(ref, t.toExpression(node)),\n ]),\n );\n },\n\n ClassExpression(path, state) {\n const { node } = path;\n if (VISITED.has(node)) return;\n\n if (!process.env.BABEL_8_BREAKING && !USE_ESM && !IS_STANDALONE) {\n // polyfill when being run by an older Babel version\n path.ensureFunctionName ??=\n // eslint-disable-next-line no-restricted-globals\n require(\"@babel/traverse\").NodePath.prototype.ensureFunctionName;\n }\n const replacement = path.ensureFunctionName(supportUnicodeId);\n if (replacement && replacement.node !== node) return;\n\n VISITED.add(node);\n\n const [replacedPath] = path.replaceWith(\n transformClass(\n path,\n state.file,\n builtinClasses,\n loose,\n {\n setClassMethods,\n constantSuper,\n superIsCallableConstructor,\n noClassCalls,\n },\n supportUnicodeId,\n ),\n );\n\n if (replacedPath.isCallExpression()) {\n annotateAsPure(replacedPath);\n const callee = replacedPath.get(\"callee\");\n if (callee.isArrowFunctionExpression()) {\n // This is an IIFE, so we don't need to worry about the noNewArrows assumption\n callee.arrowFunctionToExpression();\n }\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAA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