node-ejs-renderer/node_modules/@babel/plugin-transform-async-generator-functions/lib/index.js.map
2024-06-09 13:55:01 -04:00

1 line
7.2 KiB
Plaintext

{"version":3,"names":["_helperPluginUtils","require","_helperRemapAsyncToGenerator","_core","_forAwait","_helperEnvironmentVisitor","_default","exports","default","declare","api","assertVersion","yieldStarVisitor","traverse","visitors","merge","ArrowFunctionExpression","path","skip","YieldExpression","node","state","delegate","asyncIter","t","callExpression","addHelper","argument","environmentVisitor","forAwaitVisitor","ForOfStatement","file","await","build","rewriteForAwait","getAsyncIterator","declar","loop","block","body","ensureBlock","push","length","blockStatement","inherits","p","replaceParent","parentPath","replaceWithMultiple","scope","parent","crawl","visitor","Function","async","generator","remapAsyncToGenerator","wrapAsync","wrapAwait","name","version","undefined","Program"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport remapAsyncToGenerator from \"@babel/helper-remap-async-to-generator\";\nimport type { NodePath, Visitor } from \"@babel/traverse\";\nimport { traverse, types as t, type PluginPass } from \"@babel/core\";\nimport rewriteForAwait from \"./for-await.ts\";\nimport environmentVisitor from \"@babel/helper-environment-visitor\";\n\nexport default declare(api => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n const yieldStarVisitor = traverse.visitors.merge<PluginPass>([\n {\n ArrowFunctionExpression(path) {\n path.skip();\n },\n\n YieldExpression({ node }, state) {\n if (!node.delegate) return;\n const asyncIter = t.callExpression(state.addHelper(\"asyncIterator\"), [\n node.argument,\n ]);\n node.argument = t.callExpression(\n state.addHelper(\"asyncGeneratorDelegate\"),\n process.env.BABEL_8_BREAKING\n ? [asyncIter]\n : [asyncIter, state.addHelper(\"awaitAsyncGenerator\")],\n );\n },\n },\n environmentVisitor,\n ]);\n\n const forAwaitVisitor = traverse.visitors.merge<PluginPass>([\n {\n ArrowFunctionExpression(path) {\n path.skip();\n },\n\n ForOfStatement(path: NodePath<t.ForOfStatement>, { file }) {\n const { node } = path;\n if (!node.await) return;\n\n const build = rewriteForAwait(path, {\n getAsyncIterator: file.addHelper(\"asyncIterator\"),\n });\n\n const { declar, loop } = build;\n const block = loop.body as t.BlockStatement;\n\n // ensure that it's a block so we can take all its statements\n path.ensureBlock();\n\n // add the value declaration to the new loop body\n if (declar) {\n block.body.push(declar);\n if (path.node.body.body.length) {\n block.body.push(t.blockStatement(path.node.body.body));\n }\n } else {\n block.body.push(...path.node.body.body);\n }\n\n t.inherits(loop, node);\n t.inherits(loop.body, node.body);\n\n const p = build.replaceParent ? path.parentPath : path;\n p.replaceWithMultiple(build.node);\n\n // TODO: Avoid crawl\n p.scope.parent.crawl();\n },\n },\n environmentVisitor,\n ]);\n\n const visitor: Visitor<PluginPass> = {\n Function(path, state) {\n if (!path.node.async) return;\n\n path.traverse(forAwaitVisitor, state);\n\n if (!path.node.generator) return;\n\n path.traverse(yieldStarVisitor, state);\n\n // We don't need to pass the noNewArrows assumption, since\n // async generators are never arrow functions.\n remapAsyncToGenerator(path, {\n wrapAsync: state.addHelper(\"wrapAsyncGenerator\"),\n wrapAwait: state.addHelper(\"awaitAsyncGenerator\"),\n });\n },\n };\n\n return {\n name: \"transform-async-generator-functions\",\n inherits:\n USE_ESM || IS_STANDALONE || api.version[0] === \"8\"\n ? undefined\n : // eslint-disable-next-line no-restricted-globals\n require(\"@babel/plugin-syntax-async-generators\").default,\n\n visitor: {\n Program(path, state) {\n // We need to traverse the ast here (instead of just vising Function\n // in the top level visitor) because for-await needs to run before the\n // async-to-generator plugin. This is because for-await is transpiled\n // using \"await\" expressions, which are then converted to \"yield\".\n //\n // This is bad for performance, but plugin ordering will allow as to\n // directly visit Function in the top level visitor.\n path.traverse(visitor, state);\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,4BAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,yBAAA,GAAAJ,OAAA;AAAmE,IAAA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