dismantle 0.2.0

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.
Files changed (73) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +40 -0
  3. package/dist/cjs/development/index.cjs +1484 -0
  4. package/dist/cjs/development/index.cjs.map +7 -0
  5. package/dist/cjs/development/runtime.cjs +1484 -0
  6. package/dist/cjs/development/runtime.cjs.map +7 -0
  7. package/dist/cjs/production/index.cjs +1 -0
  8. package/dist/cjs/production/runtime.cjs +1 -0
  9. package/dist/esm/development/index.mjs +1453 -0
  10. package/dist/esm/development/index.mjs.map +7 -0
  11. package/dist/esm/development/runtime.mjs +1453 -0
  12. package/dist/esm/development/runtime.mjs.map +7 -0
  13. package/dist/esm/production/index.mjs +1 -0
  14. package/dist/esm/production/runtime.mjs +1 -0
  15. package/dist/types/hidden-imports.d.ts +4 -0
  16. package/dist/types/hidden-imports.d.ts.map +1 -0
  17. package/dist/types/index.d.ts +9 -0
  18. package/dist/types/index.d.ts.map +1 -0
  19. package/dist/types/plugin.d.ts +8 -0
  20. package/dist/types/plugin.d.ts.map +1 -0
  21. package/dist/types/split.d.ts +7 -0
  22. package/dist/types/split.d.ts.map +1 -0
  23. package/dist/types/transform-block.d.ts +5 -0
  24. package/dist/types/transform-block.d.ts.map +1 -0
  25. package/dist/types/transform-call.d.ts +5 -0
  26. package/dist/types/transform-call.d.ts.map +1 -0
  27. package/dist/types/types.d.ts +62 -0
  28. package/dist/types/types.d.ts.map +1 -0
  29. package/dist/types/utils/assert.d.ts +2 -0
  30. package/dist/types/utils/assert.d.ts.map +1 -0
  31. package/dist/types/utils/generator-shim.d.ts +4 -0
  32. package/dist/types/utils/generator-shim.d.ts.map +1 -0
  33. package/dist/types/utils/get-descriptive-name.d.ts +3 -0
  34. package/dist/types/utils/get-descriptive-name.d.ts.map +1 -0
  35. package/dist/types/utils/get-foreign-bindings.d.ts +3 -0
  36. package/dist/types/utils/get-foreign-bindings.d.ts.map +1 -0
  37. package/dist/types/utils/get-identifiers-from-lval.d.ts +3 -0
  38. package/dist/types/utils/get-identifiers-from-lval.d.ts.map +1 -0
  39. package/dist/types/utils/get-import-identifier.d.ts +5 -0
  40. package/dist/types/utils/get-import-identifier.d.ts.map +1 -0
  41. package/dist/types/utils/get-import-specifier-name.d.ts +3 -0
  42. package/dist/types/utils/get-import-specifier-name.d.ts.map +1 -0
  43. package/dist/types/utils/get-module-definition.d.ts +4 -0
  44. package/dist/types/utils/get-module-definition.d.ts.map +1 -0
  45. package/dist/types/utils/get-root-statement-path.d.ts +3 -0
  46. package/dist/types/utils/get-root-statement-path.d.ts.map +1 -0
  47. package/dist/types/utils/register-import-specifiers.d.ts +5 -0
  48. package/dist/types/utils/register-import-specifiers.d.ts.map +1 -0
  49. package/dist/types/utils/unwrap.d.ts +11 -0
  50. package/dist/types/utils/unwrap.d.ts.map +1 -0
  51. package/dist/types/utils/xxhash32.d.ts +7 -0
  52. package/dist/types/utils/xxhash32.d.ts.map +1 -0
  53. package/package.json +90 -0
  54. package/src/hidden-imports.ts +13 -0
  55. package/src/index.ts +90 -0
  56. package/src/plugin.ts +26 -0
  57. package/src/split.ts +1074 -0
  58. package/src/transform-block.ts +115 -0
  59. package/src/transform-call.ts +100 -0
  60. package/src/types.ts +73 -0
  61. package/src/utils/assert.ts +5 -0
  62. package/src/utils/errors.ts +21 -0
  63. package/src/utils/generator-shim.ts +22 -0
  64. package/src/utils/get-descriptive-name.ts +42 -0
  65. package/src/utils/get-foreign-bindings.ts +60 -0
  66. package/src/utils/get-identifiers-from-lval.ts +44 -0
  67. package/src/utils/get-import-identifier.ts +23 -0
  68. package/src/utils/get-import-specifier-name.ts +10 -0
  69. package/src/utils/get-module-definition.ts +53 -0
  70. package/src/utils/get-root-statement-path.ts +14 -0
  71. package/src/utils/register-import-specifiers.ts +77 -0
  72. package/src/utils/unwrap.ts +63 -0
  73. package/src/utils/xxhash32.ts +214 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/index.ts", "../../../src/split.ts", "../../../src/hidden-imports.ts", "../../../src/utils/assert.ts", "../../../src/utils/generator-shim.ts", "../../../src/utils/get-descriptive-name.ts", "../../../src/utils/get-foreign-bindings.ts", "../../../src/utils/get-identifiers-from-lval.ts", "../../../src/utils/get-import-identifier.ts", "../../../src/utils/get-module-definition.ts", "../../../src/utils/get-import-specifier-name.ts", "../../../src/utils/unwrap.ts", "../../../src/utils/get-root-statement-path.ts", "../../../src/transform-block.ts", "../../../src/transform-call.ts", "../../../src/utils/register-import-specifiers.ts", "../../../src/plugin.ts", "../../../src/utils/xxhash32.ts"],
4
+ "sourcesContent": ["import * as babel from '@babel/core';\nimport path from 'node:path';\nimport { plugin } from './plugin';\nimport type { CodeOutput, Options, StateContext } from './types';\nimport assert from './utils/assert';\nimport xxHash32 from './utils/xxhash32';\n\nexport interface Output extends CodeOutput {\n files: Map<string, CodeOutput>;\n entries: string[];\n roots: string[];\n}\n\nexport type {\n CodeOutput,\n DefaultImportDefinition,\n DirectiveDefinition,\n ImportDefinition,\n NamedImportDefinition,\n Options,\n} from './types';\n\nexport async function compile(\n id: string,\n code: string,\n options: Options,\n): Promise<Output> {\n const parsedPath = path.parse(id);\n\n const entries: string[] = [];\n const roots: string[] = [];\n const files = new Map<string, CodeOutput>();\n\n const ctx: StateContext = {\n id,\n path: parsedPath,\n imports: new Map(),\n virtual: {\n count: 0,\n },\n options,\n bindings: new Map(),\n blocks: {\n hash: xxHash32(id).toString(16),\n count: 0,\n },\n onVirtualFile(current, content, mode) {\n const filePath = path.join(parsedPath.dir, current);\n files.set(path.join(parsedPath.dir, current), content);\n if (mode === 'entry') {\n entries.push(filePath);\n } else if (mode === 'root') {\n roots.push(filePath);\n }\n },\n registrations: {\n identifiers: new Map(),\n namespaces: new Map(),\n },\n };\n\n const plugins: babel.ParserOptions['plugins'] = ['jsx'];\n\n if (/\\.[mc]?tsx?$/i.test(id)) {\n plugins.push('typescript');\n }\n\n const result = await babel.transformAsync(code, {\n plugins: [[plugin, ctx]],\n parserOpts: {\n plugins,\n },\n filename: parsedPath.base,\n ast: false,\n sourceFileName: id,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n });\n\n assert(result, 'invariant');\n\n return {\n code: result.code,\n map: result.map,\n files,\n entries,\n roots,\n };\n}\n", "import type * as babel from '@babel/core';\nimport type { Binding, BindingKind } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { HIDDEN_FUNC, HIDDEN_GENERATOR } from './hidden-imports';\nimport type {\n DirectiveDefinition,\n FunctionDefinition,\n ImportDefinition,\n ModuleDefinition,\n StateContext,\n} from './types';\nimport assert from './utils/assert';\nimport { generateCode } from './utils/generator-shim';\nimport { getDescriptiveName } from './utils/get-descriptive-name';\nimport getForeignBindings from './utils/get-foreign-bindings';\nimport { getIdentifiersFromLVal } from './utils/get-identifiers-from-lval';\nimport { getImportIdentifier } from './utils/get-import-identifier';\nimport { getModuleDefinition } from './utils/get-module-definition';\nimport { getRootStatementPath } from './utils/get-root-statement-path';\nimport { isPathValid, unwrapPath } from './utils/unwrap';\n\nfunction moduleDefinitionToImportSpecifier(definition: ModuleDefinition) {\n switch (definition.kind) {\n case 'default':\n return t.importDefaultSpecifier(t.identifier(definition.local));\n case 'named':\n return t.importSpecifier(\n t.identifier(definition.local),\n definition.imported\n ? t.identifier(definition.imported)\n : t.identifier(definition.local),\n );\n case 'namespace':\n return t.importNamespaceSpecifier(t.identifier(definition.local));\n }\n}\n\nfunction moduleDefinitionToImportDeclaration(definition: ModuleDefinition) {\n return t.importDeclaration(\n [moduleDefinitionToImportSpecifier(definition)],\n t.stringLiteral(definition.source),\n );\n}\n\nfunction moduleDefinitionsToImportDeclarations(\n definitions: ModuleDefinition[],\n) {\n const declarations: t.ImportDeclaration[] = [];\n for (let i = 0, len = definitions.length; i < len; i++) {\n declarations[i] = moduleDefinitionToImportDeclaration(definitions[i]);\n }\n return declarations;\n}\n\nfunction isMutation(kind: BindingKind): boolean {\n switch (kind) {\n case 'let':\n case 'var':\n case 'param':\n return true;\n case 'const':\n case 'hoisted':\n case 'local':\n case 'module':\n case 'unknown':\n return false;\n }\n}\n\nfunction registerModuleLevelBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n binding: string,\n target: Binding,\n): void {\n const current = ctx.bindings.get(binding);\n if (current) {\n modules.push(current);\n } else if (isPathValid(target.path, t.isVariableDeclarator)) {\n const definitions = splitVariableDeclarator(ctx, target.path);\n for (let k = 0, klen = definitions.length; k < klen; k++) {\n modules.push(definitions[k]);\n ctx.bindings.set(definitions[k].local, definitions[k]);\n }\n } else if (isPathValid(target.path, t.isFunctionDeclaration)) {\n const definition = splitFunctionDeclaration(ctx, target.path);\n modules.push(definition);\n ctx.bindings.set(definition.local, definition);\n }\n}\n\nfunction registerBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n locals: t.Identifier[],\n mutations: t.Identifier[],\n binding: string,\n target: Binding,\n pure?: boolean,\n): void {\n if (target.kind === 'module') {\n const result = getModuleDefinition(target.path);\n if (result) {\n modules.push(result);\n }\n } else if (target.kind === 'param') {\n locals.push(target.identifier);\n } else {\n let blockParent = target.path.scope.getBlockParent();\n const programParent = target.path.scope.getProgramParent();\n // a FunctionDeclaration binding refers to itself as the block parent\n if (blockParent.path === target.path) {\n blockParent = blockParent.parent;\n }\n if (blockParent === programParent) {\n registerModuleLevelBinding(ctx, modules, binding, target);\n } else if (!pure) {\n locals.push(target.identifier);\n if (isMutation(target.kind)) {\n mutations.push(target.identifier);\n }\n }\n }\n}\n\ninterface ExtractedBindings {\n modules: ModuleDefinition[];\n locals: t.Identifier[];\n mutations: t.Identifier[];\n}\n\nfunction extractBindings(\n ctx: StateContext,\n path: babel.NodePath,\n bindings: Set<string>,\n pure?: boolean,\n): ExtractedBindings {\n const modules: ModuleDefinition[] = [];\n const locals: t.Identifier[] = [];\n const mutations: t.Identifier[] = [];\n for (const binding of bindings) {\n const target = path.scope.getBinding(binding);\n if (target) {\n registerBinding(ctx, modules, locals, mutations, binding, target, pure);\n }\n }\n\n return {\n modules,\n locals,\n mutations,\n };\n}\n\nfunction createVirtualFileName(ctx: StateContext) {\n return `./${ctx.path.base}?${ctx.options.key}=${ctx.virtual.count++}${\n ctx.path.ext\n }`;\n}\n\nfunction createRootFile(\n ctx: StateContext,\n bindings: ExtractedBindings,\n replacement: t.Expression,\n): string {\n const rootFile = createVirtualFileName(ctx);\n const rootContent = generateCode(\n ctx.id,\n t.program([\n ...(ctx.options.mode === 'server'\n ? moduleDefinitionsToImportDeclarations(bindings.modules)\n : []),\n t.exportDefaultDeclaration(replacement),\n ]),\n );\n ctx.onVirtualFile(\n rootFile,\n { code: rootContent.code, map: rootContent.map },\n 'root',\n );\n return rootFile;\n}\n\nfunction createEntryFile(\n ctx: StateContext,\n path: babel.NodePath,\n rootFile: string,\n imported: ImportDefinition,\n): string {\n // Create an ID\n let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;\n if (ctx.options.env !== 'production') {\n id += `-${getDescriptiveName(path, 'anonymous')}`;\n }\n const entryID = path.scope.generateUidIdentifier('entry');\n const entryImports: ModuleDefinition[] = [\n {\n kind: imported.kind,\n source: imported.source,\n local: entryID.name,\n imported: imported.kind === 'named' ? imported.name : undefined,\n },\n ];\n const args: t.Expression[] = [t.stringLiteral(id)];\n if (ctx.options.mode === 'server') {\n const rootID = path.scope.generateUidIdentifier('root');\n entryImports.push({\n kind: 'default',\n source: rootFile,\n local: rootID.name,\n });\n args.push(rootID);\n }\n\n // Create the registration call\n const entryFile = createVirtualFileName(ctx);\n const entryContent = generateCode(\n ctx.id,\n t.program([\n ...moduleDefinitionsToImportDeclarations(entryImports),\n t.exportDefaultDeclaration(t.callExpression(entryID, args)),\n ]),\n );\n ctx.onVirtualFile(\n entryFile,\n { code: entryContent.code, map: entryContent.map },\n 'entry',\n );\n\n return entryFile;\n}\n\nfunction splitFunctionDeclaration(\n ctx: StateContext,\n path: babel.NodePath<t.FunctionDeclaration>,\n): ModuleDefinition {\n const bindings = getForeignBindings(path, 'function');\n const { modules } = extractBindings(ctx, path, bindings);\n const file = createVirtualFileName(ctx);\n const compiled = generateCode(\n ctx.id,\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportNamedDeclaration(path.node),\n ]),\n );\n ctx.onVirtualFile(file, { code: compiled.code, map: compiled.map }, 'none');\n\n const statement = getRootStatementPath(path);\n\n const identifier = path.node.id || path.scope.generateUidIdentifier('func');\n const definition: ModuleDefinition = {\n kind: 'named',\n local: identifier.name,\n source: file,\n };\n\n statement.insertBefore(moduleDefinitionToImportDeclaration(definition));\n path.remove();\n return definition;\n}\n\nfunction splitVariableDeclarator(\n ctx: StateContext,\n path: babel.NodePath<t.VariableDeclarator>,\n): ModuleDefinition[] {\n const init = unwrapPath(path.get('init'), t.isExpression);\n const modules = init\n ? extractBindings(\n ctx,\n path,\n getForeignBindings(\n path,\n isPathValid(init, t.isArrowFunctionExpression) ||\n isPathValid(init, t.isFunctionExpression)\n ? 'function'\n : 'expression',\n ),\n ).modules\n : [];\n const file = createVirtualFileName(ctx);\n const parent = path.parentPath.node as t.VariableDeclaration;\n const compiled = generateCode(\n ctx.id,\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportNamedDeclaration(t.variableDeclaration(parent.kind, [path.node])),\n ]),\n );\n ctx.onVirtualFile(file, { code: compiled.code, map: compiled.map }, 'none');\n const definitions: ModuleDefinition[] = getIdentifiersFromLVal(\n path.node.id,\n ).map(name => ({\n kind: 'named',\n local: name,\n source: file,\n }));\n // Replace declaration with definition\n const statement = getRootStatementPath(path);\n if (statement) {\n statement.insertBefore(moduleDefinitionsToImportDeclarations(definitions));\n }\n path.remove();\n return definitions;\n}\n/**\n * These are internal code for the control flow of the server block\n * The goal is to transform these into return statements, and the\n * the return value with the associated control flow code.\n * This allows the replacement statement for the server block to\n * know what to do if it encounters the said statement on the server.\n */\nconst BREAK_KEY = t.numericLiteral(0);\nconst CONTINUE_KEY = t.numericLiteral(1);\nconst RETURN_KEY = t.numericLiteral(2);\n// If the function has no explicit return\nconst NO_HALT_KEY = t.numericLiteral(3);\nconst THROW_KEY = t.numericLiteral(4);\nconst YIELD_KEY = t.numericLiteral(5);\n\ninterface HaltingBlockResult {\n breaks: string[];\n breakCount: number;\n continues: string[];\n continueCount: number;\n hasReturn: boolean;\n hasYield: boolean;\n}\n\nfunction transformBlockContent(\n path: babel.NodePath<t.BlockStatement>,\n mutations: t.Identifier[],\n): HaltingBlockResult {\n const target =\n path.scope.getFunctionParent() || path.scope.getProgramParent();\n\n const breaks: string[] = [];\n let breakCount = 0;\n const continues: string[] = [];\n let continueCount = 0;\n let hasReturn = false;\n let hasYield = false;\n\n const applyMutations = mutations.length\n ? path.scope.generateUidIdentifier('mutate')\n : undefined;\n\n // Transform the control flow statements\n path.traverse({\n BreakStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [BREAK_KEY];\n breakCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n breaks.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ContinueStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [CONTINUE_KEY];\n continueCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n continues.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ReturnStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasReturn = true;\n const arg = child.get('argument');\n arg.replaceWith(\n t.arrayExpression([\n RETURN_KEY,\n arg.node ? arg.node : t.nullLiteral(),\n applyMutations\n ? t.callExpression(applyMutations, [])\n : t.nullLiteral(),\n ]),\n );\n }\n },\n YieldExpression(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasYield = true;\n if (child.node.delegate) {\n // TODO\n } else {\n const arg = child.get('argument');\n arg.replaceWith(\n t.arrayExpression([\n YIELD_KEY,\n arg.node ? arg.node : t.nullLiteral(),\n applyMutations\n ? t.callExpression(applyMutations, [])\n : t.nullLiteral(),\n ]),\n );\n }\n }\n },\n });\n\n const error = path.scope.generateUidIdentifier('error');\n\n const throwResult: t.Expression[] = [THROW_KEY, error];\n const haltResult: t.Expression[] = [NO_HALT_KEY];\n\n if (applyMutations) {\n throwResult.push(t.callExpression(applyMutations, []));\n haltResult.push(t.nullLiteral());\n haltResult.push(t.callExpression(applyMutations, []));\n }\n\n const statements: t.Statement[] = [\n t.tryStatement(\n t.blockStatement(path.node.body),\n t.catchClause(\n error,\n t.blockStatement([t.returnStatement(t.arrayExpression(throwResult))]),\n ),\n ),\n t.returnStatement(t.arrayExpression(haltResult)),\n ];\n\n if (applyMutations) {\n statements.unshift(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n applyMutations,\n t.arrowFunctionExpression(\n [],\n t.objectExpression(\n mutations.map(item => t.objectProperty(item, item, false, true)),\n ),\n ),\n ),\n ]),\n );\n }\n\n path.node.body = statements;\n return { breaks, continues, hasReturn, hasYield, breakCount, continueCount };\n}\n\n/**\n * This generates a chain of if-statements that checks the\n * received server return (which is transformed from the original block's\n * server statement)\n * Each if-statement matches an specific label, assuming that the original\n * break statement is a labeled break statement.\n * Otherwise, the output code is either a normal break statement or none.\n */\nfunction getBreakCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n breakCount: number,\n breaks: string[],\n check: t.Statement | undefined,\n): t.Statement | undefined {\n let current: t.Statement | undefined;\n if (breakCount !== breaks.length) {\n current = t.blockStatement([t.breakStatement()]);\n }\n for (let i = 0, len = breaks.length; i < len; i++) {\n const target = breaks[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.breakStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, BREAK_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\n/**\n * This generates a chain of if-statements that checks the\n * received server return (which is transformed from the original block's\n * server statement)\n * Each if-statement matches an specific label, assuming that the original\n * continue statement is a labeled continue statement.\n * Otherwise, the output code is either a normal continue statement or none.\n */\nfunction getContinueCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n continueCount: number,\n continues: string[],\n check: t.Statement | undefined,\n): t.Statement | undefined {\n let current: t.Statement | undefined;\n if (continueCount !== continues.length) {\n current = t.blockStatement([t.continueStatement()]);\n }\n for (let i = 0, len = continues.length; i < len; i++) {\n const target = continues[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.continueStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, CONTINUE_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\nfunction getGeneratorReplacementForServerBlock(\n path: babel.NodePath,\n registerID: t.Identifier,\n args: (t.Identifier | t.SpreadElement | t.ArrayExpression)[],\n): [replacements: t.Statement[], step: t.Identifier] {\n const iterator = path.scope.generateUidIdentifier('iterator');\n const step = path.scope.generateUidIdentifier('step');\n const replacement: t.Statement[] = [\n t.variableDeclaration('let', [\n t.variableDeclarator(step),\n // First, get the iterator by calling the generator\n t.variableDeclarator(\n iterator,\n t.awaitExpression(t.callExpression(registerID, args)),\n ),\n ]),\n // Create a while statement, the intent is to\n // repeatedly iterate the generator\n t.whileStatement(\n t.booleanLiteral(true),\n t.blockStatement([\n // Get the next value\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n step,\n t.awaitExpression(\n t.callExpression(\n t.memberExpression(iterator, t.identifier('next')),\n [],\n ),\n ),\n ),\n ),\n // Check if the step is done\n t.ifStatement(\n t.memberExpression(step, t.identifier('done')),\n t.blockStatement([\n // exit the loop\n t.breakStatement(),\n ]),\n // Otherwise, yield the value\n t.blockStatement([\n t.expressionStatement(\n t.yieldExpression(\n t.memberExpression(step, t.identifier('value')),\n ),\n ),\n ]),\n ),\n ]),\n ),\n ];\n return [replacement, step];\n}\n\nfunction getBlockReplacement(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n entryFile: string,\n bindings: ExtractedBindings,\n halting: HaltingBlockResult,\n) {\n // Move to the replacement for the server block,\n // declare the type and result based from transformBlockContent\n const returnType = path.scope.generateUidIdentifier('type');\n const returnResult = path.scope.generateUidIdentifier('result');\n const returnMutations = path.scope.generateUidIdentifier('mutations');\n let check: t.Statement | undefined;\n // If the block has a return, we need to make sure that the\n // replacement does too.\n if (halting.hasReturn) {\n check = t.ifStatement(\n t.binaryExpression('===', returnType, RETURN_KEY),\n t.blockStatement([t.returnStatement(returnResult)]),\n check,\n );\n }\n // If the block has a break, we also do it.\n if (halting.breakCount > 0) {\n check = getBreakCheck(\n returnType,\n returnResult,\n halting.breakCount,\n halting.breaks,\n check,\n );\n }\n // If the block has a continue, we also do it.\n if (halting.continueCount > 0) {\n check = getContinueCheck(\n returnType,\n returnResult,\n halting.continueCount,\n halting.continues,\n check,\n );\n }\n const replacement: t.Statement[] = [];\n if (halting.hasYield) {\n const blockID = path.scope.generateUidIdentifier('block');\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n blockID,\n t.callExpression(getImportIdentifier(ctx, path, HIDDEN_GENERATOR), [\n t.memberExpression(\n t.awaitExpression(t.importExpression(t.stringLiteral(entryFile))),\n t.identifier('default'),\n ),\n bindings.mutations.length\n ? t.arrowFunctionExpression(\n [returnMutations],\n t.assignmentExpression(\n '=',\n t.objectPattern(\n bindings.mutations.map(item =>\n t.objectProperty(item, item, false, true),\n ),\n ),\n returnMutations,\n ),\n )\n : t.nullLiteral(),\n ]),\n ),\n ]),\n );\n const [reps, step] = getGeneratorReplacementForServerBlock(\n path,\n blockID,\n bindings.locals,\n );\n for (let i = 0, len = reps.length; i < len; i++) {\n replacement.push(reps[i]);\n }\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult]),\n t.memberExpression(step, t.identifier('value')),\n ),\n ]),\n );\n } else {\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult]),\n t.awaitExpression(\n t.callExpression(\n t.callExpression(getImportIdentifier(ctx, path, HIDDEN_FUNC), [\n t.memberExpression(\n t.awaitExpression(\n t.importExpression(t.stringLiteral(entryFile)),\n ),\n t.identifier('default'),\n ),\n bindings.mutations.length\n ? t.arrowFunctionExpression(\n [returnMutations],\n t.assignmentExpression(\n '=',\n t.objectPattern(\n bindings.mutations.map(item =>\n t.objectProperty(item, item, false, true),\n ),\n ),\n returnMutations,\n ),\n )\n : t.nullLiteral(),\n ]),\n bindings.locals,\n ),\n ),\n ),\n ]),\n );\n }\n if (check) {\n replacement.push(check);\n }\n\n return t.blockStatement(replacement);\n}\n\nfunction replaceBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n bindings: ExtractedBindings,\n): void {\n // Transform all control statements\n const halting = transformBlockContent(path, bindings.mutations);\n const rootFile = createRootFile(\n ctx,\n bindings,\n t.functionExpression(\n undefined,\n bindings.locals,\n t.blockStatement(path.node.body),\n halting.hasYield,\n true,\n ),\n );\n const entryFile = createEntryFile(ctx, path, rootFile, directive.target);\n path.replaceWith(\n getBlockReplacement(ctx, path, entryFile, bindings, halting),\n );\n}\n\nexport function splitBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n): void {\n replaceBlock(\n ctx,\n path,\n directive,\n extractBindings(\n ctx,\n path,\n getForeignBindings(path, 'block'),\n directive.pure,\n ),\n );\n}\n\ninterface HaltingFunctionResult {\n hasReturn: boolean;\n hasYield: boolean;\n}\n\nfunction transformFunctionContent(\n path: babel.NodePath<t.BlockStatement>,\n mutations: t.Identifier[],\n): HaltingFunctionResult {\n const target =\n path.scope.getFunctionParent() || path.scope.getProgramParent();\n\n const applyMutations = mutations.length\n ? path.scope.generateUidIdentifier('mutate')\n : undefined;\n let hasReturn = false;\n let hasYield = false;\n\n // Transform the control flow statements\n path.traverse({\n ReturnStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasReturn = true;\n const replacement: t.Expression[] = [RETURN_KEY];\n if (child.node.argument) {\n replacement.push(child.node.argument);\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n YieldExpression(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasYield = true;\n }\n },\n });\n\n const error = path.scope.generateUidIdentifier('error');\n\n const throwResult: t.Expression[] = [THROW_KEY, error];\n const haltResult: t.Expression[] = [NO_HALT_KEY];\n\n if (applyMutations) {\n throwResult.push(t.callExpression(applyMutations, []));\n haltResult.push(t.nullLiteral());\n haltResult.push(t.callExpression(applyMutations, []));\n }\n\n const statements: t.Statement[] = [\n t.tryStatement(\n t.blockStatement(path.node.body),\n t.catchClause(\n error,\n t.blockStatement([t.returnStatement(t.arrayExpression(throwResult))]),\n ),\n ),\n t.returnStatement(t.arrayExpression(haltResult)),\n ];\n\n if (applyMutations) {\n statements.unshift(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n applyMutations,\n t.arrowFunctionExpression(\n [],\n t.objectExpression(\n mutations.map(item => t.objectProperty(item, item, false, true)),\n ),\n ),\n ),\n ]),\n );\n }\n\n path.node.body = statements;\n\n return {\n hasReturn,\n hasYield,\n };\n}\n\nfunction getFunctionReplacement(\n ctx: StateContext,\n path: babel.NodePath<t.ArrowFunctionExpression | t.FunctionExpression>,\n entryFile: string,\n bindings: ExtractedBindings,\n halting: HaltingFunctionResult,\n): t.Expression {\n const rest = path.scope.generateUidIdentifier('rest');\n\n const returnType = path.scope.generateUidIdentifier('type');\n const returnResult = path.scope.generateUidIdentifier('result');\n const returnMutations = path.scope.generateUidIdentifier('mutations');\n\n const replacement: t.Statement[] = [];\n if (halting.hasYield) {\n const funcID = path.scope.generateUidIdentifier('fn');\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n funcID,\n t.callExpression(getImportIdentifier(ctx, path, HIDDEN_GENERATOR), [\n t.memberExpression(\n t.awaitExpression(t.importExpression(t.stringLiteral(entryFile))),\n t.identifier('default'),\n ),\n bindings.mutations.length\n ? t.arrowFunctionExpression(\n [returnMutations],\n t.assignmentExpression(\n '=',\n t.objectPattern(\n bindings.mutations.map(item =>\n t.objectProperty(item, item, false, true),\n ),\n ),\n returnMutations,\n ),\n )\n : t.nullLiteral(),\n ]),\n ),\n ]),\n );\n const [reps, step] = getGeneratorReplacementForServerBlock(path, funcID, [\n t.arrayExpression(bindings.locals),\n t.spreadElement(rest),\n ]);\n for (let i = 0, len = reps.length; i < len; i++) {\n replacement.push(reps[i]);\n }\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult]),\n t.memberExpression(step, t.identifier('value')),\n ),\n ]),\n );\n } else {\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult]),\n t.awaitExpression(\n t.callExpression(\n t.callExpression(getImportIdentifier(ctx, path, HIDDEN_FUNC), [\n t.memberExpression(\n t.awaitExpression(\n t.importExpression(t.stringLiteral(entryFile)),\n ),\n t.identifier('default'),\n ),\n bindings.mutations.length\n ? t.arrowFunctionExpression(\n [returnMutations],\n t.assignmentExpression(\n '=',\n t.objectPattern(\n bindings.mutations.map(item =>\n t.objectProperty(item, item, false, true),\n ),\n ),\n returnMutations,\n ),\n )\n : t.nullLiteral(),\n ]),\n [t.arrayExpression(bindings.locals), t.spreadElement(rest)],\n ),\n ),\n ),\n ]),\n );\n }\n\n replacement.push(t.returnStatement(returnResult));\n\n if (isPathValid(path, t.isFunctionExpression)) {\n return t.functionExpression(\n path.node.id,\n [t.restElement(rest)],\n t.blockStatement(replacement),\n true,\n halting.hasYield,\n );\n }\n return t.arrowFunctionExpression(\n [t.restElement(rest)],\n t.blockStatement(replacement),\n true,\n );\n}\n\nfunction replaceFunction(\n ctx: StateContext,\n path: babel.NodePath<t.ArrowFunctionExpression | t.FunctionExpression>,\n func: FunctionDefinition,\n bindings: ExtractedBindings,\n): t.Expression {\n const body = path.get('body');\n if (isPathValid(body, t.isExpression)) {\n body.replaceWith(t.blockStatement([t.returnStatement(body.node)]));\n }\n assert(isPathValid(body, t.isBlockStatement), 'invariant');\n const halting = transformFunctionContent(body, bindings.mutations);\n const rootFile = createRootFile(\n ctx,\n bindings,\n t.isFunctionExpression(path.node)\n ? t.functionExpression(\n path.node.id,\n [t.arrayPattern(bindings.locals), ...path.node.params],\n path.node.body,\n path.node.async,\n path.node.generator,\n )\n : t.arrowFunctionExpression(\n [t.arrayPattern(bindings.locals), ...path.node.params],\n path.node.body,\n path.node.async,\n ),\n );\n\n const entryFile = createEntryFile(ctx, path, rootFile, func.target);\n\n return getFunctionReplacement(ctx, path, entryFile, bindings, halting);\n}\n\nexport function splitFunction(\n ctx: StateContext,\n path: babel.NodePath<t.ArrowFunctionExpression | t.FunctionExpression>,\n func: FunctionDefinition,\n): t.Expression {\n return replaceFunction(\n ctx,\n path,\n func,\n extractBindings(ctx, path, getForeignBindings(path, 'function'), func.pure),\n );\n}\n\nfunction replaceExpression(\n ctx: StateContext,\n path: babel.NodePath<t.Expression>,\n func: FunctionDefinition,\n bindings: ExtractedBindings,\n): t.Expression {\n const rootFile = createRootFile(ctx, bindings, path.node);\n const entryFile = createEntryFile(ctx, path, rootFile, func.target);\n\n const rest = path.scope.generateUidIdentifier('rest');\n\n return t.arrowFunctionExpression(\n [t.restElement(rest)],\n t.callExpression(\n t.memberExpression(\n t.awaitExpression(t.importExpression(t.stringLiteral(entryFile))),\n t.identifier('default'),\n ),\n [t.spreadElement(rest)],\n ),\n true,\n );\n}\n\nexport function splitExpression(\n ctx: StateContext,\n path: babel.NodePath<t.Expression>,\n func: FunctionDefinition,\n): t.Expression {\n return replaceExpression(\n ctx,\n path,\n func,\n extractBindings(\n ctx,\n path,\n getForeignBindings(path, 'expression'),\n func.pure,\n ),\n );\n}\n", "import type { ImportDefinition } from './types';\n\nexport const HIDDEN_FUNC: ImportDefinition = {\n kind: 'named',\n source: 'dismantle/runtime',\n name: '$$func',\n};\n\nexport const HIDDEN_GENERATOR: ImportDefinition = {\n kind: 'named',\n source: 'dismantle/runtime',\n name: '$$gen',\n};\n", "export default function assert(cond: unknown, error: string): asserts cond {\n if (!cond) {\n throw new Error(error);\n }\n}\n", "import _generator from '@babel/generator';\nimport type * as t from '@babel/types';\nimport type { CodeOutput } from '../types';\n\ntype GeneratorShim = typeof _generator;\n\n// https://github.com/babel/babel/issues/15269\nconst generator: GeneratorShim =\n typeof _generator !== 'function'\n ? (_generator as unknown as { default: GeneratorShim }).default\n : _generator;\n\nexport function generateCode(id: string, node: t.Node): CodeOutput {\n const result = generator(node, {\n sourceMaps: true,\n sourceFileName: id,\n });\n return {\n code: result.code,\n map: result.map,\n };\n}\n", "import type { NodePath } from '@babel/core';\n\nexport function getDescriptiveName(\n path: NodePath,\n defaultName: string,\n): string {\n let current: NodePath | null = path;\n while (current) {\n switch (current.node.type) {\n case 'FunctionDeclaration':\n case 'FunctionExpression': {\n if (current.node.id) {\n return current.node.id.name;\n }\n break;\n }\n case 'VariableDeclarator': {\n if (current.node.id.type === 'Identifier') {\n return current.node.id.name;\n }\n break;\n }\n case 'ClassPrivateMethod':\n case 'ClassMethod':\n case 'ObjectMethod': {\n switch (current.node.key.type) {\n case 'Identifier':\n return current.node.key.name;\n case 'PrivateName':\n return current.node.key.id.name;\n default:\n break;\n }\n break;\n }\n default:\n break;\n }\n current = current.parentPath;\n }\n return defaultName;\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nfunction isForeignBinding(\n source: babel.NodePath,\n current: babel.NodePath,\n name: string,\n mode: 'block' | 'function',\n): boolean {\n if (current.scope.hasGlobal(name)) {\n return false;\n }\n if (source === current) {\n return true;\n }\n if (current.scope.hasOwnBinding(name)) {\n if (mode === 'block') {\n const binding = current.scope.getBinding(name);\n return !!binding && binding.kind === 'param';\n }\n return false;\n }\n if (current.parentPath) {\n return isForeignBinding(source, current.parentPath, name, mode);\n }\n return true;\n}\n\nfunction isInTypescript(path: babel.NodePath): boolean {\n let parent = path.parentPath;\n while (parent) {\n if (t.isTypeScript(parent.node) && !t.isExpression(parent.node)) {\n return true;\n }\n parent = parent.parentPath;\n }\n return false;\n}\n\nexport default function getForeignBindings(\n path: babel.NodePath,\n mode: 'block' | 'function' | 'expression',\n): Set<string> {\n const identifiers = new Set<string>();\n path.traverse({\n ReferencedIdentifier(p) {\n // Check identifiers that aren't in a TS expression\n if (\n !isInTypescript(p) &&\n (mode === 'expression'\n ? !path.scope.hasGlobal(p.node.name)\n : isForeignBinding(path, p, p.node.name, mode))\n ) {\n identifiers.add(p.node.name);\n }\n },\n });\n\n return identifiers;\n}\n", "import * as t from '@babel/types';\n\nfunction getIdentifiersFromArrayPattern(node: t.ArrayPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.elements.length; i < len; i++) {\n const el = node.elements[i];\n if (el) {\n ids.push(...getIdentifiersFromLVal(el));\n }\n }\n return ids;\n}\n\nfunction getIdentifiersFromObjectPattern(node: t.ObjectPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.properties.length; i < len; i++) {\n const el = node.properties[i];\n if (el) {\n if (el.type === 'RestElement') {\n ids.push(...getIdentifiersFromLVal(el));\n } else if (t.isLVal(el.value)) {\n ids.push(...getIdentifiersFromLVal(el.value));\n }\n }\n }\n return ids;\n}\n\nexport function getIdentifiersFromLVal(node: t.LVal): string[] {\n switch (node.type) {\n case 'Identifier':\n return [node.name];\n case 'ArrayPattern':\n return getIdentifiersFromArrayPattern(node);\n case 'AssignmentPattern':\n return getIdentifiersFromLVal(node.left);\n case 'ObjectPattern':\n return getIdentifiersFromObjectPattern(node);\n case 'RestElement':\n return getIdentifiersFromLVal(node.argument);\n default:\n return [];\n }\n}\n", "import type * as babel from '@babel/core';\nimport { addDefault, addNamed } from '@babel/helper-module-imports';\nimport type * as t from '@babel/types';\nimport type { ImportDefinition, StateContext } from '../types';\n\nexport function getImportIdentifier(\n state: StateContext,\n path: babel.NodePath,\n registration: ImportDefinition,\n): t.Identifier {\n const name = registration.kind === 'named' ? registration.name : 'default';\n const target = `${registration.source}[${name}]`;\n const current = state.imports.get(target);\n if (current) {\n return current;\n }\n const newID =\n registration.kind === 'named'\n ? addNamed(path, registration.name, registration.source)\n : addDefault(path, registration.source);\n state.imports.set(target, newID);\n return newID;\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\nimport type { ModuleDefinition } from '../types';\nimport { getImportSpecifierName } from './get-import-specifier-name';\nimport { isPathValid } from './unwrap';\n\nexport function getModuleDefinition(\n path: babel.NodePath,\n): ModuleDefinition | undefined {\n if (\n !(\n isPathValid(path, t.isImportSpecifier) ||\n isPathValid(path, t.isImportDefaultSpecifier) ||\n isPathValid(path, t.isImportNamespaceSpecifier)\n )\n ) {\n return undefined;\n }\n const parent =\n path.getStatementParent() as babel.NodePath<t.ImportDeclaration>;\n const source = parent.node.source.value;\n switch (path.node.type) {\n case 'ImportDefaultSpecifier':\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n };\n case 'ImportNamespaceSpecifier':\n return {\n source,\n kind: 'namespace',\n local: path.node.local.name,\n };\n case 'ImportSpecifier': {\n const imported = getImportSpecifierName(path.node);\n if (imported === 'default') {\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n imported: '',\n };\n }\n return {\n source,\n kind: 'named',\n local: path.node.local.name,\n imported,\n };\n }\n }\n}\n", "import type * as t from '@babel/types';\n\nexport function getImportSpecifierName(node: t.ImportSpecifier) {\n switch (node.imported.type) {\n case 'Identifier':\n return node.imported.name;\n case 'StringLiteral':\n return node.imported.value;\n }\n}\n", "import type * as babel from '@babel/core';\nimport type * as t from '@babel/types';\n\ntype TypeFilter<V extends t.Node> = (node: t.Node) => node is V;\n\nexport function isPathValid<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): path is babel.NodePath<V> {\n return key((path as babel.NodePath).node);\n}\n\nexport type NestedExpression =\n | t.ParenthesizedExpression\n | t.TypeCastExpression\n | t.TSAsExpression\n | t.TSSatisfiesExpression\n | t.TSNonNullExpression\n | t.TSInstantiationExpression\n | t.TSTypeAssertion;\n\nexport function isNestedExpression(node: t.Node): node is NestedExpression {\n switch (node.type) {\n case 'ParenthesizedExpression':\n case 'TypeCastExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n case 'TSInstantiationExpression':\n return true;\n default:\n return false;\n }\n}\n\ntype TypeCheck<K> = K extends TypeFilter<infer U> ? U : never;\n\nexport function unwrapNode<K extends (value: t.Node) => boolean>(\n node: t.Node,\n key: K,\n): TypeCheck<K> | undefined {\n if (key(node)) {\n return node as TypeCheck<K>;\n }\n if (isNestedExpression(node)) {\n return unwrapNode(node.expression, key);\n }\n return undefined;\n}\n\nexport function unwrapPath<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): babel.NodePath<V> | undefined {\n if (isPathValid(path, key)) {\n return path;\n }\n if (isPathValid(path, isNestedExpression)) {\n return unwrapPath(path.get('expression'), key);\n }\n return undefined;\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nexport function getRootStatementPath(path: babel.NodePath): babel.NodePath {\n let current = path.parentPath;\n while (current) {\n const next = current.parentPath;\n if (next && t.isProgram(next.node)) {\n return current;\n }\n current = next;\n }\n return path;\n}\n", "import type * as babel from '@babel/core';\nimport type * as t from '@babel/types';\nimport { splitBlock } from './split';\nimport type { DirectiveDefinition, StateContext } from './types';\n\nfunction getValidDirectiveFromString(\n ctx: StateContext,\n string: string,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = ctx.options.directives.length; i < len; i++) {\n const current = ctx.options.directives[i];\n if (current.value === string) {\n return current;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const statement = path.node.directives[i].value.value;\n const directive = getValidDirectiveFromString(ctx, statement);\n if (directive) {\n return directive;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromFauxDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.body.length; i < len; i++) {\n const statement = path.node.body[i];\n if (\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'StringLiteral'\n ) {\n const directive = getValidDirectiveFromString(\n ctx,\n statement.expression.value,\n );\n if (directive) {\n return directive;\n }\n } else {\n break;\n }\n }\n return undefined;\n}\n\nfunction getDirectiveDefinitionFromBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n const parent = path.getFunctionParent();\n if (parent && !parent.node.async) {\n return undefined;\n }\n return (\n getDefinitionFromDirectives(ctx, path) ||\n getDefinitionFromFauxDirectives(ctx, path)\n );\n}\n\nfunction cleanBlockForDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const newDirectives: t.Directive[] = [];\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const current = path.node.directives[i];\n if (current.value.value !== definition.value) {\n newDirectives.push(current);\n }\n }\n path.node.directives = newDirectives;\n}\n\nfunction cleanBlockForFauxDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const body = path.get('body');\n for (let i = 0, len = body.length; i < len; i++) {\n const statement = body[i];\n if (\n statement.node.type === 'ExpressionStatement' &&\n statement.node.expression.type === 'StringLiteral'\n ) {\n if (statement.node.expression.value === definition.value) {\n statement.remove();\n return;\n }\n }\n }\n}\n\nexport function transformBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): void {\n const definition = getDirectiveDefinitionFromBlock(ctx, path);\n if (!definition) {\n return;\n }\n cleanBlockForDirectives(path, definition);\n cleanBlockForFauxDirectives(path, definition);\n splitBlock(ctx, path, definition);\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\nimport { splitExpression, splitFunction } from './split';\nimport type { FunctionDefinition, StateContext } from './types';\nimport { isPathValid, unwrapNode } from './utils/unwrap';\n\nfunction getFunctionDefinitionFromPropName(\n definitions: FunctionDefinition[],\n propName: string,\n): FunctionDefinition | undefined {\n for (let i = 0, len = definitions.length; i < len; i++) {\n const def = definitions[i];\n if (def.source.kind === 'default' && propName === 'default') {\n return def;\n }\n if (def.source.kind === 'named' && propName === def.source.name) {\n return def;\n }\n }\n return undefined;\n}\n\nfunction getFunctionDefinitionFromCallee(\n ctx: StateContext,\n path: babel.NodePath<t.CallExpression>,\n): FunctionDefinition | undefined {\n const callee = path.node.callee;\n const id = unwrapNode(callee, t.isIdentifier);\n if (id) {\n const binding = path.scope.getBindingIdentifier(id.name);\n if (binding) {\n return ctx.registrations.identifiers.get(binding);\n }\n return undefined;\n }\n const memberExpr = unwrapNode(callee, t.isMemberExpression);\n if (\n memberExpr &&\n !memberExpr.computed &&\n t.isIdentifier(memberExpr.property)\n ) {\n const object = unwrapNode(memberExpr.object, t.isIdentifier);\n if (object) {\n const binding = path.scope.getBindingIdentifier(object.name);\n if (binding) {\n const definitions = ctx.registrations.namespaces.get(binding);\n if (definitions) {\n return getFunctionDefinitionFromPropName(\n definitions,\n memberExpr.property.name,\n );\n }\n }\n }\n }\n return undefined;\n}\n\nfunction isValidFunction(\n node: t.Node,\n): node is t.ArrowFunctionExpression | t.FunctionExpression {\n return t.isArrowFunctionExpression(node) || t.isFunctionExpression(node);\n}\n\nfunction isSkippableFunction(node: t.Expression): boolean {\n if (node.leadingComments) {\n for (let i = 0, len = node.leadingComments.length; i < len; i++) {\n if (/^@dismantle skip$/.test(node.leadingComments[i].value)) {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function transformCall(\n ctx: StateContext,\n path: babel.NodePath<t.CallExpression>,\n): void {\n const definition = getFunctionDefinitionFromCallee(ctx, path);\n if (!definition) {\n return;\n }\n const args = path.get('arguments');\n const expr = args[0];\n if (isPathValid(expr, t.isExpression)) {\n if (isSkippableFunction(expr.node)) {\n return;\n }\n const replacement = isPathValid(expr, isValidFunction)\n ? splitFunction(ctx, expr, definition)\n : splitExpression(ctx, expr, definition);\n\n if (definition.preserve) {\n expr.replaceWith(t.addComment(replacement, 'leading', '@dismantle skip'));\n } else {\n path.replaceWith(replacement);\n }\n }\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\nimport type { FunctionDefinition, StateContext } from '../types';\nimport { getImportSpecifierName } from './get-import-specifier-name';\n\nfunction registerImportSpecifier(\n ctx: StateContext,\n node:\n | t.ImportSpecifier\n | t.ImportDefaultSpecifier\n | t.ImportNamespaceSpecifier,\n definition: FunctionDefinition,\n): void {\n if (t.isImportSpecifier(node)) {\n if (node.importKind === 'type' || node.importKind === 'typeof') {\n return;\n }\n const key = getImportSpecifierName(node);\n if (\n (definition.source.kind === 'named' && key === definition.source.name) ||\n (definition.source.kind === 'default' && key === 'default')\n ) {\n ctx.registrations.identifiers.set(node.local, definition);\n }\n }\n if (\n t.isImportDefaultSpecifier(node) &&\n definition.source.kind === 'default'\n ) {\n ctx.registrations.identifiers.set(node.local, definition);\n }\n if (t.isImportNamespaceSpecifier(node)) {\n let current = ctx.registrations.namespaces.get(node.local);\n if (!current) {\n current = [];\n }\n current.push(definition);\n ctx.registrations.namespaces.set(node.local, current);\n }\n}\n\nfunction registerImportDeclarationByDefinition(\n ctx: StateContext,\n path: babel.NodePath<t.ImportDeclaration>,\n definition: FunctionDefinition,\n): void {\n for (let i = 0, len = path.node.specifiers.length; i < len; i++) {\n const specifier = path.node.specifiers[i];\n registerImportSpecifier(ctx, specifier, definition);\n }\n}\n\nexport function registerImportSpecifiers(\n ctx: StateContext,\n programPath: babel.NodePath<t.Program>,\n): void {\n const len = ctx.options.functions.length;\n if (!len) {\n return;\n }\n programPath.traverse({\n ImportDeclaration(path) {\n if (\n path.node.importKind === 'type' ||\n path.node.importKind === 'typeof'\n ) {\n return;\n }\n for (let i = 0; i < len; i++) {\n const func = ctx.options.functions[i];\n if (func.source.source === path.node.source.value) {\n registerImportDeclarationByDefinition(ctx, path, func);\n }\n }\n },\n });\n}\n", "import type * as babel from '@babel/core';\nimport { transformBlock } from './transform-block';\nimport { transformCall } from './transform-call';\nimport type { StateContext } from './types';\nimport { registerImportSpecifiers } from './utils/register-import-specifiers';\n\ninterface State extends babel.PluginPass {\n opts: StateContext;\n}\n\nexport function plugin(): babel.PluginObj<State> {\n return {\n name: 'dismantle',\n visitor: {\n Program(path, ctx) {\n registerImportSpecifiers(ctx.opts, path);\n },\n BlockStatement(path, ctx) {\n transformBlock(ctx.opts, path);\n },\n CallExpression(path, ctx) {\n transformCall(ctx.opts, path);\n },\n },\n };\n}\n", "/* eslint-disable @typescript-eslint/no-shadow */\n/**\n * Copyright (c) 2019 Jason Dent\n * https://github.com/Jason3S/xxhash\n */\nconst PRIME32_1 = 2654435761;\nconst PRIME32_2 = 2246822519;\nconst PRIME32_3 = 3266489917;\nconst PRIME32_4 = 668265263;\nconst PRIME32_5 = 374761393;\n\nfunction toUtf8(text: string): Uint8Array {\n const bytes: number[] = [];\n for (let i = 0, n = text.length; i < n; ++i) {\n const c = text.charCodeAt(i);\n if (c < 0x80) {\n bytes.push(c);\n } else if (c < 0x800) {\n bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));\n } else if (c < 0xd800 || c >= 0xe000) {\n bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));\n } else {\n const cp =\n 0x10000 + (((c & 0x3ff) << 10) | (text.charCodeAt(++i) & 0x3ff));\n bytes.push(\n 0xf0 | ((cp >> 18) & 0x7),\n 0x80 | ((cp >> 12) & 0x3f),\n 0x80 | ((cp >> 6) & 0x3f),\n 0x80 | (cp & 0x3f),\n );\n }\n }\n return new Uint8Array(bytes);\n}\n/**\n *\n * @param buffer - byte array or string\n * @param seed - optional seed (32-bit unsigned);\n */\nexport default function xxHash32(\n buffer: Uint8Array | string,\n seed = 0,\n): number {\n buffer = typeof buffer === 'string' ? toUtf8(buffer) : buffer;\n const b = buffer;\n\n /*\n Step 1. Initialize internal accumulators\n Each accumulator gets an initial value based on optional seed input.\n Since the seed is optional, it can be 0.\n ```\n u32 acc1 = seed + PRIME32_1 + PRIME32_2;\n u32 acc2 = seed + PRIME32_2;\n u32 acc3 = seed + 0;\n u32 acc4 = seed - PRIME32_1;\n ```\n Special case : input is less than 16 bytes\n When input is too small (< 16 bytes), the algorithm will not process any stripe.\n Consequently, it will not make use of parallel accumulators.\n In which case, a simplified initialization is performed, using a single accumulator :\n u32 acc = seed + PRIME32_5;\n The algorithm then proceeds directly to step 4.\n */\n\n let acc = (seed + PRIME32_5) & 0xffffffff;\n let offset = 0;\n\n if (b.length >= 16) {\n const accN = [\n (seed + PRIME32_1 + PRIME32_2) & 0xffffffff,\n (seed + PRIME32_2) & 0xffffffff,\n (seed + 0) & 0xffffffff,\n (seed - PRIME32_1) & 0xffffffff,\n ];\n\n /*\n Step 2. Process stripes\n A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes,\n of 4 bytes each. The first lane is used to update accumulator 1, the second lane\n is used to update accumulator 2, and so on. Each lane read its associated 32-bit\n value using little-endian convention. For each {lane, accumulator}, the update\n process is called a round, and applies the following formula :\n ```\n accN = accN + (laneN * PRIME32_2);\n accN = accN <<< 13;\n accN = accN * PRIME32_1;\n ```\n This shuffles the bits so that any bit from input lane impacts several bits in\n output accumulator. All operations are performed modulo 2^32.\n Input is consumed one full stripe at a time. Step 2 is looped as many times as\n necessary to consume the whole input, except the last remaining bytes which cannot\n form a stripe (< 16 bytes). When that happens, move to step 3.\n */\n\n const b = buffer;\n const limit = b.length - 16;\n let lane = 0;\n for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16);\n let acc = (accN[lane] + laneNP) & 0xffffffff;\n acc = (acc << 13) | (acc >>> 19);\n const acc0 = acc & 0xffff;\n const acc1 = acc >>> 16;\n accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff;\n lane = (lane + 1) & 0x3;\n }\n\n /*\n Step 3. Accumulator convergence\n All 4 lane accumulators from previous steps are merged to produce a\n single remaining accumulator\n of same width (32-bit). The associated formula is as follows :\n ```\n acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);\n ```\n */\n acc =\n (((accN[0] << 1) | (accN[0] >>> 31)) +\n ((accN[1] << 7) | (accN[1] >>> 25)) +\n ((accN[2] << 12) | (accN[2] >>> 20)) +\n ((accN[3] << 18) | (accN[3] >>> 14))) &\n 0xffffffff;\n }\n\n /*\n Step 4. Add input length\n The input total length is presumed known at this stage.\n This step is just about adding the length to\n accumulator, so that it participates to final mixing.\n ```\n acc = acc + (u32)inputLength;\n ```\n */\n acc = (acc + buffer.length) & 0xffffffff;\n\n /*\n Step 5. Consume remaining input\n There may be up to 15 bytes remaining to consume from the input.\n The final stage will digest them according\n to following pseudo-code :\n ```\n while (remainingLength >= 4) {\n lane = read_32bit_little_endian(input_ptr);\n acc = acc + lane * PRIME32_3;\n acc = (acc <<< 17) * PRIME32_4;\n input_ptr += 4; remainingLength -= 4;\n }\n ```\n This process ensures that all input bytes are present in the final mix.\n */\n\n const limit = buffer.length - 4;\n for (; offset <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16);\n acc = (acc + laneP) & 0xffffffff;\n acc = (acc << 17) | (acc >>> 15);\n acc =\n ((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) &\n 0xffffffff;\n }\n\n /*\n ```\n while (remainingLength >= 1) {\n lane = read_byte(input_ptr);\n acc = acc + lane * PRIME32_5;\n acc = (acc <<< 11) * PRIME32_1;\n input_ptr += 1; remainingLength -= 1;\n }\n ```\n */\n\n for (; offset < b.length; ++offset) {\n const lane = b[offset];\n acc += lane * PRIME32_5;\n acc = (acc << 11) | (acc >>> 21);\n acc =\n ((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) &\n 0xffffffff;\n }\n\n /*\n Step 6. Final mix (avalanche)\n The final mix ensures that all input bits have a chance to impact any bit in\n the output digest, resulting in an unbiased distribution. This is also called\n avalanche effect.\n ```\n acc = acc xor (acc >> 15);\n acc = acc * PRIME32_2;\n acc = acc xor (acc >> 13);\n acc = acc * PRIME32_3;\n acc = acc xor (acc >> 16);\n ```\n */\n\n acc ^= acc >>> 15;\n acc =\n (((acc & 0xffff) * PRIME32_2) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_2) << 16);\n acc ^= acc >>> 13;\n acc =\n (((acc & 0xffff) * PRIME32_3) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_3) << 16);\n acc ^= acc >>> 16;\n\n // turn any negatives back into a positive number;\n return acc < 0 ? acc + 4294967296 : acc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ACA,UAAU,oBAAI,IAAI;AAAA,IAClB,QAAQ;AAAA,MACN,MAAM,SAAS,EAAE,EAAE,SAAS,EAAE;AAAA,MAC9B,OAAO;AAAA,IACT;AAAA,IACA,cAAc,SAAS,SAAS,MAAM;AACpC,YAAM,WAAW,KAAK,KAAK,WAAW,KAAK,OAAO;AAClD,YAAM,IAAI,KAAK,KAAK,WAAW,KAAK,OAAO,GAAG,OAAO;AACrD,UAAI,SAAS,SAAS;AACpB,gBAAQ,KAAK,QAAQ;AAAA,MACvB,WAAW,SAAS,QAAQ;AAC1B,cAAM,KAAK,QAAQ;AAAA,MACrB;AAAA,IACF;AAAA,IACA,eAAe;AAAA,MACb,aAAa,oBAAI,IAAI;AAAA,MACrB,YAAY,oBAAI,IAAI;AAAA,IACtB;AAAA,EACF;AAEA,QAAM,UAA0C,CAAC,KAAK;AAEtD,MAAI,gBAAgB,KAAK,EAAE,GAAG;AAC5B,YAAQ,KAAK,YAAY;AAAA,EAC3B;AAEA,QAAM,SAAS,MAAY,qBAAe,MAAM;AAAA,IAC9C,SAAS,CAAC,CAAC,QAAQ,GAAG,CAAC;AAAA,IACvB,YAAY;AAAA,MACV;AAAA,IACF;AAAA,IACA,UAAU,WAAW;AAAA,IACrB,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,SAAS;AAAA,EACX,CAAC;AAED,SAAO,QAAQ,WAAW;AAE1B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": ["t", "path", "path", "t", "path", "t", "path", "path", "t", "path", "path", "identifier", "path", "t", "path", "t", "path", "path", "b", "limit", "acc"]
7
+ }
@@ -0,0 +1 @@
1
+ import*as fe from"@babel/core";import Y from"node:path";import*as e from"@babel/types";var L={kind:"named",source:"dismantle/runtime",name:"$$func"},_={kind:"named",source:"dismantle/runtime",name:"$$gen"};function v(t,n){if(!t)throw new Error(n)}import T from"@babel/generator";var pe=typeof T!="function"?T.default:T;function F(t,n){let r=pe(n,{sourceMaps:!0,sourceFileName:t});return{code:r.code,map:r.map}}function $(t,n){let r=t;for(;r;){switch(r.node.type){case"FunctionDeclaration":case"FunctionExpression":{if(r.node.id)return r.node.id.name;break}case"VariableDeclarator":{if(r.node.id.type==="Identifier")return r.node.id.name;break}case"ClassPrivateMethod":case"ClassMethod":case"ObjectMethod":{switch(r.node.key.type){case"Identifier":return r.node.key.name;case"PrivateName":return r.node.key.id.name;default:break}break}default:break}r=r.parentPath}return n}import*as w from"@babel/types";function H(t,n,r,i){if(n.scope.hasGlobal(r))return!1;if(t===n)return!0;if(n.scope.hasOwnBinding(r)){if(i==="block"){let o=n.scope.getBinding(r);return!!o&&o.kind==="param"}return!1}return n.parentPath?H(t,n.parentPath,r,i):!0}function ue(t){let n=t.parentPath;for(;n;){if(w.isTypeScript(n.node)&&!w.isExpression(n.node))return!0;n=n.parentPath}return!1}function S(t,n){let r=new Set;return t.traverse({ReferencedIdentifier(i){!ue(i)&&(n==="expression"?!t.scope.hasGlobal(i.node.name):H(t,i,i.node.name,n))&&r.add(i.node.name)}}),r}import*as W from"@babel/types";function me(t){let n=[];for(let r=0,i=t.elements.length;r<i;r++){let o=t.elements[r];o&&n.push(...y(o))}return n}function de(t){let n=[];for(let r=0,i=t.properties.length;r<i;r++){let o=t.properties[r];o&&(o.type==="RestElement"?n.push(...y(o)):W.isLVal(o.value)&&n.push(...y(o.value)))}return n}function y(t){switch(t.type){case"Identifier":return[t.name];case"ArrayPattern":return me(t);case"AssignmentPattern":return y(t.left);case"ObjectPattern":return de(t);case"RestElement":return y(t.argument);default:return[]}}import{addDefault as be,addNamed as xe}from"@babel/helper-module-imports";function N(t,n,r){let i=r.kind==="named"?r.name:"default",o=`${r.source}[${i}]`,s=t.imports.get(o);if(s)return s;let a=r.kind==="named"?xe(n,r.name,r.source):be(n,r.source);return t.imports.set(o,a),a}import*as P from"@babel/types";function M(t){switch(t.imported.type){case"Identifier":return t.imported.name;case"StringLiteral":return t.imported.value}}function x(t,n){return n(t.node)}function G(t){switch(t.type){case"ParenthesizedExpression":case"TypeCastExpression":case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"TSInstantiationExpression":return!0;default:return!1}}function h(t,n){if(n(t))return t;if(G(t))return h(t.expression,n)}function U(t,n){if(x(t,n))return t;if(x(t,G))return U(t.get("expression"),n)}function z(t){if(!(x(t,P.isImportSpecifier)||x(t,P.isImportDefaultSpecifier)||x(t,P.isImportNamespaceSpecifier)))return;let r=t.getStatementParent().node.source.value;switch(t.node.type){case"ImportDefaultSpecifier":return{source:r,kind:"default",local:t.node.local.name};case"ImportNamespaceSpecifier":return{source:r,kind:"namespace",local:t.node.local.name};case"ImportSpecifier":{let i=M(t.node);return i==="default"?{source:r,kind:"default",local:t.node.local.name,imported:""}:{source:r,kind:"named",local:t.node.local.name,imported:i}}}}import*as q from"@babel/types";function V(t){let n=t.parentPath;for(;n;){let r=n.parentPath;if(r&&q.isProgram(r.node))return n;n=r}return t}function ge(t){switch(t.kind){case"default":return e.importDefaultSpecifier(e.identifier(t.local));case"named":return e.importSpecifier(e.identifier(t.local),t.imported?e.identifier(t.imported):e.identifier(t.local));case"namespace":return e.importNamespaceSpecifier(e.identifier(t.local))}}function J(t){return e.importDeclaration([ge(t)],e.stringLiteral(t.source))}function C(t){let n=[];for(let r=0,i=t.length;r<i;r++)n[r]=J(t[r]);return n}function Ee(t){switch(t){case"let":case"var":case"param":return!0;case"const":case"hoisted":case"local":case"module":case"unknown":return!1}}function Se(t,n,r,i){let o=t.bindings.get(r);if(o)n.push(o);else if(x(i.path,e.isVariableDeclarator)){let s=De(t,i.path);for(let a=0,l=s.length;a<l;a++)n.push(s[a]),t.bindings.set(s[a].local,s[a])}else if(x(i.path,e.isFunctionDeclaration)){let s=Pe(t,i.path);n.push(s),t.bindings.set(s.local,s)}}function ye(t,n,r,i,o,s,a){if(s.kind==="module"){let l=z(s.path);l&&n.push(l)}else if(s.kind==="param")r.push(s.identifier);else{let l=s.path.scope.getBlockParent(),c=s.path.scope.getProgramParent();l.path===s.path&&(l=l.parent),l===c?Se(t,n,o,s):a||(r.push(s.identifier),Ee(s.kind)&&i.push(s.identifier))}}function R(t,n,r,i){let o=[],s=[],a=[];for(let l of r){let c=n.scope.getBinding(l);c&&ye(t,o,s,a,l,c,i)}return{modules:o,locals:s,mutations:a}}function B(t){return`./${t.path.base}?${t.options.key}=${t.virtual.count++}${t.path.ext}`}function A(t,n,r){let i=B(t),o=F(t.id,e.program([...t.options.mode==="server"?C(n.modules):[],e.exportDefaultDeclaration(r)]));return t.onVirtualFile(i,{code:o.code,map:o.map},"root"),i}function O(t,n,r,i){let o=`${t.blocks.hash}-${t.blocks.count++}`;t.options.env!=="production"&&(o+=`-${$(n,"anonymous")}`);let s=n.scope.generateUidIdentifier("entry"),a=[{kind:i.kind,source:i.source,local:s.name,imported:i.kind==="named"?i.name:void 0}],l=[e.stringLiteral(o)];if(t.options.mode==="server"){let p=n.scope.generateUidIdentifier("root");a.push({kind:"default",source:r,local:p.name}),l.push(p)}let c=B(t),f=F(t.id,e.program([...C(a),e.exportDefaultDeclaration(e.callExpression(s,l))]));return t.onVirtualFile(c,{code:f.code,map:f.map},"entry"),c}function Pe(t,n){let r=S(n,"function"),{modules:i}=R(t,n,r),o=B(t),s=F(t.id,e.program([...C(i),e.exportNamedDeclaration(n.node)]));t.onVirtualFile(o,{code:s.code,map:s.map},"none");let a=V(n),c={kind:"named",local:(n.node.id||n.scope.generateUidIdentifier("func")).name,source:o};return a.insertBefore(J(c)),n.remove(),c}function De(t,n){let r=U(n.get("init"),e.isExpression),i=r?R(t,n,S(n,x(r,e.isArrowFunctionExpression)||x(r,e.isFunctionExpression)?"function":"expression")).modules:[],o=B(t),s=n.parentPath.node,a=F(t.id,e.program([...C(i),e.exportNamedDeclaration(e.variableDeclaration(s.kind,[n.node]))]));t.onVirtualFile(o,{code:a.code,map:a.map},"none");let l=y(n.node.id).map(f=>({kind:"named",local:f,source:o})),c=V(n);return c&&c.insertBefore(C(l)),n.remove(),l}var Q=e.numericLiteral(0),X=e.numericLiteral(1),j=e.numericLiteral(2),Z=e.numericLiteral(3),ee=e.numericLiteral(4),Ie=e.numericLiteral(5);function ke(t,n){let r=t.scope.getFunctionParent()||t.scope.getProgramParent(),i=[],o=0,s=[],a=0,l=!1,c=!1,f=n.length?t.scope.generateUidIdentifier("mutate"):void 0;t.traverse({BreakStatement(u){if((u.scope.getFunctionParent()||u.scope.getProgramParent())===r){let d=[Q];if(o++,u.node.label){let k=u.node.label.name;i.push(k),d.push(e.stringLiteral(k))}else d.push(e.nullLiteral());f&&d.push(e.callExpression(f,[])),u.replaceWith(e.returnStatement(e.arrayExpression(d))),u.skip()}},ContinueStatement(u){if((u.scope.getFunctionParent()||u.scope.getProgramParent())===r){let d=[X];if(a++,u.node.label){let k=u.node.label.name;s.push(k),d.push(e.stringLiteral(k))}else d.push(e.nullLiteral());f&&d.push(e.callExpression(f,[])),u.replaceWith(e.returnStatement(e.arrayExpression(d))),u.skip()}},ReturnStatement(u){if((u.scope.getFunctionParent()||u.scope.getProgramParent())===r){l=!0;let d=u.get("argument");d.replaceWith(e.arrayExpression([j,d.node?d.node:e.nullLiteral(),f?e.callExpression(f,[]):e.nullLiteral()]))}},YieldExpression(u){if((u.scope.getFunctionParent()||u.scope.getProgramParent())===r&&(c=!0,!u.node.delegate)){let d=u.get("argument");d.replaceWith(e.arrayExpression([Ie,d.node?d.node:e.nullLiteral(),f?e.callExpression(f,[]):e.nullLiteral()]))}}});let p=t.scope.generateUidIdentifier("error"),g=[ee,p],b=[Z];f&&(g.push(e.callExpression(f,[])),b.push(e.nullLiteral()),b.push(e.callExpression(f,[])));let m=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(p,e.blockStatement([e.returnStatement(e.arrayExpression(g))]))),e.returnStatement(e.arrayExpression(b))];return f&&m.unshift(e.variableDeclaration("const",[e.variableDeclarator(f,e.arrowFunctionExpression([],e.objectExpression(n.map(u=>e.objectProperty(u,u,!1,!0)))))])),t.node.body=m,{breaks:i,continues:s,hasReturn:l,hasYield:c,breakCount:o,continueCount:a}}function ve(t,n,r,i,o){let s;r!==i.length&&(s=e.blockStatement([e.breakStatement()]));for(let a=0,l=i.length;a<l;a++){let c=i[a];s=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(c)),e.blockStatement([e.breakStatement(e.identifier(c))]),s)])}return s?e.ifStatement(e.binaryExpression("===",t,Q),s,o):o}function Fe(t,n,r,i,o){let s;r!==i.length&&(s=e.blockStatement([e.continueStatement()]));for(let a=0,l=i.length;a<l;a++){let c=i[a];s=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(c)),e.blockStatement([e.continueStatement(e.identifier(c))]),s)])}return s?e.ifStatement(e.binaryExpression("===",t,X),s,o):o}function te(t,n,r){let i=t.scope.generateUidIdentifier("iterator"),o=t.scope.generateUidIdentifier("step");return[[e.variableDeclaration("let",[e.variableDeclarator(o),e.variableDeclarator(i,e.awaitExpression(e.callExpression(n,r)))]),e.whileStatement(e.booleanLiteral(!0),e.blockStatement([e.expressionStatement(e.assignmentExpression("=",o,e.awaitExpression(e.callExpression(e.memberExpression(i,e.identifier("next")),[])))),e.ifStatement(e.memberExpression(o,e.identifier("done")),e.blockStatement([e.breakStatement()]),e.blockStatement([e.expressionStatement(e.yieldExpression(e.memberExpression(o,e.identifier("value"))))]))]))],o]}function Ne(t,n,r,i,o){let s=n.scope.generateUidIdentifier("type"),a=n.scope.generateUidIdentifier("result"),l=n.scope.generateUidIdentifier("mutations"),c;o.hasReturn&&(c=e.ifStatement(e.binaryExpression("===",s,j),e.blockStatement([e.returnStatement(a)]),c)),o.breakCount>0&&(c=ve(s,a,o.breakCount,o.breaks,c)),o.continueCount>0&&(c=Fe(s,a,o.continueCount,o.continues,c));let f=[];if(o.hasYield){let p=n.scope.generateUidIdentifier("block");f.push(e.variableDeclaration("const",[e.variableDeclarator(p,e.callExpression(N(t,n,_),[e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(r))),e.identifier("default")),i.mutations.length?e.arrowFunctionExpression([l],e.assignmentExpression("=",e.objectPattern(i.mutations.map(m=>e.objectProperty(m,m,!1,!0))),l)):e.nullLiteral()]))]));let[g,b]=te(n,p,i.locals);for(let m=0,u=g.length;m<u;m++)f.push(g[m]);f.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([s,a]),e.memberExpression(b,e.identifier("value")))]))}else f.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([s,a]),e.awaitExpression(e.callExpression(e.callExpression(N(t,n,L),[e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(r))),e.identifier("default")),i.mutations.length?e.arrowFunctionExpression([l],e.assignmentExpression("=",e.objectPattern(i.mutations.map(p=>e.objectProperty(p,p,!1,!0))),l)):e.nullLiteral()]),i.locals)))]));return c&&f.push(c),e.blockStatement(f)}function he(t,n,r,i){let o=ke(n,i.mutations),s=A(t,i,e.functionExpression(void 0,i.locals,e.blockStatement(n.node.body),o.hasYield,!0)),a=O(t,n,s,r.target);n.replaceWith(Ne(t,n,a,i,o))}function ne(t,n,r){he(t,n,r,R(t,n,S(n,"block"),r.pure))}function Ce(t,n){let r=t.scope.getFunctionParent()||t.scope.getProgramParent(),i=n.length?t.scope.generateUidIdentifier("mutate"):void 0,o=!1,s=!1;t.traverse({ReturnStatement(p){if((p.scope.getFunctionParent()||p.scope.getProgramParent())===r){o=!0;let b=[j];p.node.argument?b.push(p.node.argument):b.push(e.nullLiteral()),i&&b.push(e.callExpression(i,[])),p.replaceWith(e.returnStatement(e.arrayExpression(b))),p.skip()}},YieldExpression(p){(p.scope.getFunctionParent()||p.scope.getProgramParent())===r&&(s=!0)}});let a=t.scope.generateUidIdentifier("error"),l=[ee,a],c=[Z];i&&(l.push(e.callExpression(i,[])),c.push(e.nullLiteral()),c.push(e.callExpression(i,[])));let f=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(a,e.blockStatement([e.returnStatement(e.arrayExpression(l))]))),e.returnStatement(e.arrayExpression(c))];return i&&f.unshift(e.variableDeclaration("const",[e.variableDeclarator(i,e.arrowFunctionExpression([],e.objectExpression(n.map(p=>e.objectProperty(p,p,!1,!0)))))])),t.node.body=f,{hasReturn:o,hasYield:s}}function Re(t,n,r,i,o){let s=n.scope.generateUidIdentifier("rest"),a=n.scope.generateUidIdentifier("type"),l=n.scope.generateUidIdentifier("result"),c=n.scope.generateUidIdentifier("mutations"),f=[];if(o.hasYield){let p=n.scope.generateUidIdentifier("fn");f.push(e.variableDeclaration("const",[e.variableDeclarator(p,e.callExpression(N(t,n,_),[e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(r))),e.identifier("default")),i.mutations.length?e.arrowFunctionExpression([c],e.assignmentExpression("=",e.objectPattern(i.mutations.map(m=>e.objectProperty(m,m,!1,!0))),c)):e.nullLiteral()]))]));let[g,b]=te(n,p,[e.arrayExpression(i.locals),e.spreadElement(s)]);for(let m=0,u=g.length;m<u;m++)f.push(g[m]);f.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([a,l]),e.memberExpression(b,e.identifier("value")))]))}else f.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([a,l]),e.awaitExpression(e.callExpression(e.callExpression(N(t,n,L),[e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(r))),e.identifier("default")),i.mutations.length?e.arrowFunctionExpression([c],e.assignmentExpression("=",e.objectPattern(i.mutations.map(p=>e.objectProperty(p,p,!1,!0))),c)):e.nullLiteral()]),[e.arrayExpression(i.locals),e.spreadElement(s)])))]));return f.push(e.returnStatement(l)),x(n,e.isFunctionExpression)?e.functionExpression(n.node.id,[e.restElement(s)],e.blockStatement(f),!0,o.hasYield):e.arrowFunctionExpression([e.restElement(s)],e.blockStatement(f),!0)}function we(t,n,r,i){let o=n.get("body");x(o,e.isExpression)&&o.replaceWith(e.blockStatement([e.returnStatement(o.node)])),v(x(o,e.isBlockStatement),"invariant");let s=Ce(o,i.mutations),a=A(t,i,e.isFunctionExpression(n.node)?e.functionExpression(n.node.id,[e.arrayPattern(i.locals),...n.node.params],n.node.body,n.node.async,n.node.generator):e.arrowFunctionExpression([e.arrayPattern(i.locals),...n.node.params],n.node.body,n.node.async)),l=O(t,n,a,r.target);return Re(t,n,l,i,s)}function re(t,n,r){return we(t,n,r,R(t,n,S(n,"function"),r.pure))}function Me(t,n,r,i){let o=A(t,i,n.node),s=O(t,n,o,r.target),a=n.scope.generateUidIdentifier("rest");return e.arrowFunctionExpression([e.restElement(a)],e.callExpression(e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(s))),e.identifier("default")),[e.spreadElement(a)]),!0)}function ie(t,n,r){return Me(t,n,r,R(t,n,S(n,"expression"),r.pure))}function oe(t,n){for(let r=0,i=t.options.directives.length;r<i;r++){let o=t.options.directives[r];if(o.value===n)return o}}function Be(t,n){for(let r=0,i=n.node.directives.length;r<i;r++){let o=n.node.directives[r].value.value,s=oe(t,o);if(s)return s}}function Le(t,n){for(let r=0,i=n.node.body.length;r<i;r++){let o=n.node.body[r];if(o.type==="ExpressionStatement"&&o.expression.type==="StringLiteral"){let s=oe(t,o.expression.value);if(s)return s}else break}}function _e(t,n){let r=n.getFunctionParent();if(!(r&&!r.node.async))return Be(t,n)||Le(t,n)}function Te(t,n){let r=[];for(let i=0,o=t.node.directives.length;i<o;i++){let s=t.node.directives[i];s.value.value!==n.value&&r.push(s)}t.node.directives=r}function Ue(t,n){let r=t.get("body");for(let i=0,o=r.length;i<o;i++){let s=r[i];if(s.node.type==="ExpressionStatement"&&s.node.expression.type==="StringLiteral"&&s.node.expression.value===n.value){s.remove();return}}}function se(t,n){let r=_e(t,n);r&&(Te(n,r),Ue(n,r),ne(t,n,r))}import*as E from"@babel/types";function Ve(t,n){for(let r=0,i=t.length;r<i;r++){let o=t[r];if(o.source.kind==="default"&&n==="default"||o.source.kind==="named"&&n===o.source.name)return o}}function Ae(t,n){let r=n.node.callee,i=h(r,E.isIdentifier);if(i){let s=n.scope.getBindingIdentifier(i.name);return s?t.registrations.identifiers.get(s):void 0}let o=h(r,E.isMemberExpression);if(o&&!o.computed&&E.isIdentifier(o.property)){let s=h(o.object,E.isIdentifier);if(s){let a=n.scope.getBindingIdentifier(s.name);if(a){let l=t.registrations.namespaces.get(a);if(l)return Ve(l,o.property.name)}}}}function Oe(t){return E.isArrowFunctionExpression(t)||E.isFunctionExpression(t)}function je(t){if(t.leadingComments){for(let n=0,r=t.leadingComments.length;n<r;n++)if(/^@dismantle skip$/.test(t.leadingComments[n].value))return!0}return!1}function ae(t,n){let r=Ae(t,n);if(!r)return;let o=n.get("arguments")[0];if(x(o,E.isExpression)){if(je(o.node))return;let s=x(o,Oe)?re(t,o,r):ie(t,o,r);r.preserve?o.replaceWith(E.addComment(s,"leading","@dismantle skip")):n.replaceWith(s)}}import*as D from"@babel/types";function Ke(t,n,r){if(D.isImportSpecifier(n)){if(n.importKind==="type"||n.importKind==="typeof")return;let i=M(n);(r.source.kind==="named"&&i===r.source.name||r.source.kind==="default"&&i==="default")&&t.registrations.identifiers.set(n.local,r)}if(D.isImportDefaultSpecifier(n)&&r.source.kind==="default"&&t.registrations.identifiers.set(n.local,r),D.isImportNamespaceSpecifier(n)){let i=t.registrations.namespaces.get(n.local);i||(i=[]),i.push(r),t.registrations.namespaces.set(n.local,i)}}function Ye(t,n,r){for(let i=0,o=n.node.specifiers.length;i<o;i++){let s=n.node.specifiers[i];Ke(t,s,r)}}function le(t,n){let r=t.options.functions.length;r&&n.traverse({ImportDeclaration(i){if(!(i.node.importKind==="type"||i.node.importKind==="typeof"))for(let o=0;o<r;o++){let s=t.options.functions[o];s.source.source===i.node.source.value&&Ye(t,i,s)}}})}function ce(){return{name:"dismantle",visitor:{Program(t,n){le(n.opts,t)},BlockStatement(t,n){se(n.opts,t)},CallExpression(t,n){ae(n.opts,t)}}}}function $e(t){let n=[];for(let r=0,i=t.length;r<i;++r){let o=t.charCodeAt(r);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|o&63);else if(o<55296||o>=57344)n.push(224|o>>12,128|o>>6&63,128|o&63);else{let s=65536+((o&1023)<<10|t.charCodeAt(++r)&1023);n.push(240|s>>18&7,128|s>>12&63,128|s>>6&63,128|s&63)}}return new Uint8Array(n)}function K(t,n=0){t=typeof t=="string"?$e(t):t;let r=t,i=n+374761393&4294967295,o=0;if(r.length>=16){let a=[n+2654435761+2246822519&4294967295,n+2246822519&4294967295,n+0&4294967295,n-2654435761&4294967295],l=t,c=l.length-16,f=0;for(o=0;(o&4294967280)<=c;o+=4){let p=o,g=l[p+0]+(l[p+1]<<8),b=l[p+2]+(l[p+3]<<8),m=g*2246822519+(b*2246822519<<16),u=a[f]+m&4294967295;u=u<<13|u>>>19;let I=u&65535,d=u>>>16;a[f]=I*2654435761+(d*2654435761<<16)&4294967295,f=f+1&3}i=(a[0]<<1|a[0]>>>31)+(a[1]<<7|a[1]>>>25)+(a[2]<<12|a[2]>>>20)+(a[3]<<18|a[3]>>>14)&4294967295}i=i+t.length&4294967295;let s=t.length-4;for(;o<=s;o+=4){let a=o,l=r[a+0]+(r[a+1]<<8),c=r[a+2]+(r[a+3]<<8),f=l*3266489917+(c*3266489917<<16);i=i+f&4294967295,i=i<<17|i>>>15,i=(i&65535)*668265263+((i>>>16)*668265263<<16)&4294967295}for(;o<r.length;++o){let a=r[o];i+=a*374761393,i=i<<11|i>>>21,i=(i&65535)*2654435761+((i>>>16)*2654435761<<16)&4294967295}return i^=i>>>15,i=((i&65535)*2246822519&4294967295)+((i>>>16)*2246822519<<16),i^=i>>>13,i=((i&65535)*3266489917&4294967295)+((i>>>16)*3266489917<<16),i^=i>>>16,i<0?i+4294967296:i}async function Bt(t,n,r){let i=Y.parse(t),o=[],s=[],a=new Map,l={id:t,path:i,imports:new Map,virtual:{count:0},options:r,bindings:new Map,blocks:{hash:K(t).toString(16),count:0},onVirtualFile(p,g,b){let m=Y.join(i.dir,p);a.set(Y.join(i.dir,p),g),b==="entry"?o.push(m):b==="root"&&s.push(m)},registrations:{identifiers:new Map,namespaces:new Map}},c=["jsx"];/\.[mc]?tsx?$/i.test(t)&&c.push("typescript");let f=await fe.transformAsync(n,{plugins:[[ce,l]],parserOpts:{plugins:c},filename:i.base,ast:!1,sourceFileName:t,sourceMaps:!0,configFile:!1,babelrc:!1});return v(f,"invariant"),{code:f.code,map:f.map,files:a,entries:o,roots:s}}export{Bt as compile};
@@ -0,0 +1 @@
1
+ import*as fe from"@babel/core";import Y from"node:path";import*as e from"@babel/types";var L={kind:"named",source:"dismantle/runtime",name:"$$func"},_={kind:"named",source:"dismantle/runtime",name:"$$gen"};function v(t,n){if(!t)throw new Error(n)}import T from"@babel/generator";var pe=typeof T!="function"?T.default:T;function F(t,n){let r=pe(n,{sourceMaps:!0,sourceFileName:t});return{code:r.code,map:r.map}}function $(t,n){let r=t;for(;r;){switch(r.node.type){case"FunctionDeclaration":case"FunctionExpression":{if(r.node.id)return r.node.id.name;break}case"VariableDeclarator":{if(r.node.id.type==="Identifier")return r.node.id.name;break}case"ClassPrivateMethod":case"ClassMethod":case"ObjectMethod":{switch(r.node.key.type){case"Identifier":return r.node.key.name;case"PrivateName":return r.node.key.id.name;default:break}break}default:break}r=r.parentPath}return n}import*as w from"@babel/types";function H(t,n,r,i){if(n.scope.hasGlobal(r))return!1;if(t===n)return!0;if(n.scope.hasOwnBinding(r)){if(i==="block"){let o=n.scope.getBinding(r);return!!o&&o.kind==="param"}return!1}return n.parentPath?H(t,n.parentPath,r,i):!0}function ue(t){let n=t.parentPath;for(;n;){if(w.isTypeScript(n.node)&&!w.isExpression(n.node))return!0;n=n.parentPath}return!1}function S(t,n){let r=new Set;return t.traverse({ReferencedIdentifier(i){!ue(i)&&(n==="expression"?!t.scope.hasGlobal(i.node.name):H(t,i,i.node.name,n))&&r.add(i.node.name)}}),r}import*as W from"@babel/types";function me(t){let n=[];for(let r=0,i=t.elements.length;r<i;r++){let o=t.elements[r];o&&n.push(...y(o))}return n}function de(t){let n=[];for(let r=0,i=t.properties.length;r<i;r++){let o=t.properties[r];o&&(o.type==="RestElement"?n.push(...y(o)):W.isLVal(o.value)&&n.push(...y(o.value)))}return n}function y(t){switch(t.type){case"Identifier":return[t.name];case"ArrayPattern":return me(t);case"AssignmentPattern":return y(t.left);case"ObjectPattern":return de(t);case"RestElement":return y(t.argument);default:return[]}}import{addDefault as be,addNamed as xe}from"@babel/helper-module-imports";function N(t,n,r){let i=r.kind==="named"?r.name:"default",o=`${r.source}[${i}]`,s=t.imports.get(o);if(s)return s;let a=r.kind==="named"?xe(n,r.name,r.source):be(n,r.source);return t.imports.set(o,a),a}import*as P from"@babel/types";function M(t){switch(t.imported.type){case"Identifier":return t.imported.name;case"StringLiteral":return t.imported.value}}function x(t,n){return n(t.node)}function G(t){switch(t.type){case"ParenthesizedExpression":case"TypeCastExpression":case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"TSInstantiationExpression":return!0;default:return!1}}function h(t,n){if(n(t))return t;if(G(t))return h(t.expression,n)}function U(t,n){if(x(t,n))return t;if(x(t,G))return U(t.get("expression"),n)}function z(t){if(!(x(t,P.isImportSpecifier)||x(t,P.isImportDefaultSpecifier)||x(t,P.isImportNamespaceSpecifier)))return;let r=t.getStatementParent().node.source.value;switch(t.node.type){case"ImportDefaultSpecifier":return{source:r,kind:"default",local:t.node.local.name};case"ImportNamespaceSpecifier":return{source:r,kind:"namespace",local:t.node.local.name};case"ImportSpecifier":{let i=M(t.node);return i==="default"?{source:r,kind:"default",local:t.node.local.name,imported:""}:{source:r,kind:"named",local:t.node.local.name,imported:i}}}}import*as q from"@babel/types";function V(t){let n=t.parentPath;for(;n;){let r=n.parentPath;if(r&&q.isProgram(r.node))return n;n=r}return t}function ge(t){switch(t.kind){case"default":return e.importDefaultSpecifier(e.identifier(t.local));case"named":return e.importSpecifier(e.identifier(t.local),t.imported?e.identifier(t.imported):e.identifier(t.local));case"namespace":return e.importNamespaceSpecifier(e.identifier(t.local))}}function J(t){return e.importDeclaration([ge(t)],e.stringLiteral(t.source))}function C(t){let n=[];for(let r=0,i=t.length;r<i;r++)n[r]=J(t[r]);return n}function Ee(t){switch(t){case"let":case"var":case"param":return!0;case"const":case"hoisted":case"local":case"module":case"unknown":return!1}}function Se(t,n,r,i){let o=t.bindings.get(r);if(o)n.push(o);else if(x(i.path,e.isVariableDeclarator)){let s=De(t,i.path);for(let a=0,l=s.length;a<l;a++)n.push(s[a]),t.bindings.set(s[a].local,s[a])}else if(x(i.path,e.isFunctionDeclaration)){let s=Pe(t,i.path);n.push(s),t.bindings.set(s.local,s)}}function ye(t,n,r,i,o,s,a){if(s.kind==="module"){let l=z(s.path);l&&n.push(l)}else if(s.kind==="param")r.push(s.identifier);else{let l=s.path.scope.getBlockParent(),c=s.path.scope.getProgramParent();l.path===s.path&&(l=l.parent),l===c?Se(t,n,o,s):a||(r.push(s.identifier),Ee(s.kind)&&i.push(s.identifier))}}function R(t,n,r,i){let o=[],s=[],a=[];for(let l of r){let c=n.scope.getBinding(l);c&&ye(t,o,s,a,l,c,i)}return{modules:o,locals:s,mutations:a}}function B(t){return`./${t.path.base}?${t.options.key}=${t.virtual.count++}${t.path.ext}`}function A(t,n,r){let i=B(t),o=F(t.id,e.program([...t.options.mode==="server"?C(n.modules):[],e.exportDefaultDeclaration(r)]));return t.onVirtualFile(i,{code:o.code,map:o.map},"root"),i}function O(t,n,r,i){let o=`${t.blocks.hash}-${t.blocks.count++}`;t.options.env!=="production"&&(o+=`-${$(n,"anonymous")}`);let s=n.scope.generateUidIdentifier("entry"),a=[{kind:i.kind,source:i.source,local:s.name,imported:i.kind==="named"?i.name:void 0}],l=[e.stringLiteral(o)];if(t.options.mode==="server"){let p=n.scope.generateUidIdentifier("root");a.push({kind:"default",source:r,local:p.name}),l.push(p)}let c=B(t),f=F(t.id,e.program([...C(a),e.exportDefaultDeclaration(e.callExpression(s,l))]));return t.onVirtualFile(c,{code:f.code,map:f.map},"entry"),c}function Pe(t,n){let r=S(n,"function"),{modules:i}=R(t,n,r),o=B(t),s=F(t.id,e.program([...C(i),e.exportNamedDeclaration(n.node)]));t.onVirtualFile(o,{code:s.code,map:s.map},"none");let a=V(n),c={kind:"named",local:(n.node.id||n.scope.generateUidIdentifier("func")).name,source:o};return a.insertBefore(J(c)),n.remove(),c}function De(t,n){let r=U(n.get("init"),e.isExpression),i=r?R(t,n,S(n,x(r,e.isArrowFunctionExpression)||x(r,e.isFunctionExpression)?"function":"expression")).modules:[],o=B(t),s=n.parentPath.node,a=F(t.id,e.program([...C(i),e.exportNamedDeclaration(e.variableDeclaration(s.kind,[n.node]))]));t.onVirtualFile(o,{code:a.code,map:a.map},"none");let l=y(n.node.id).map(f=>({kind:"named",local:f,source:o})),c=V(n);return c&&c.insertBefore(C(l)),n.remove(),l}var Q=e.numericLiteral(0),X=e.numericLiteral(1),j=e.numericLiteral(2),Z=e.numericLiteral(3),ee=e.numericLiteral(4),Ie=e.numericLiteral(5);function ke(t,n){let r=t.scope.getFunctionParent()||t.scope.getProgramParent(),i=[],o=0,s=[],a=0,l=!1,c=!1,f=n.length?t.scope.generateUidIdentifier("mutate"):void 0;t.traverse({BreakStatement(u){if((u.scope.getFunctionParent()||u.scope.getProgramParent())===r){let d=[Q];if(o++,u.node.label){let k=u.node.label.name;i.push(k),d.push(e.stringLiteral(k))}else d.push(e.nullLiteral());f&&d.push(e.callExpression(f,[])),u.replaceWith(e.returnStatement(e.arrayExpression(d))),u.skip()}},ContinueStatement(u){if((u.scope.getFunctionParent()||u.scope.getProgramParent())===r){let d=[X];if(a++,u.node.label){let k=u.node.label.name;s.push(k),d.push(e.stringLiteral(k))}else d.push(e.nullLiteral());f&&d.push(e.callExpression(f,[])),u.replaceWith(e.returnStatement(e.arrayExpression(d))),u.skip()}},ReturnStatement(u){if((u.scope.getFunctionParent()||u.scope.getProgramParent())===r){l=!0;let d=u.get("argument");d.replaceWith(e.arrayExpression([j,d.node?d.node:e.nullLiteral(),f?e.callExpression(f,[]):e.nullLiteral()]))}},YieldExpression(u){if((u.scope.getFunctionParent()||u.scope.getProgramParent())===r&&(c=!0,!u.node.delegate)){let d=u.get("argument");d.replaceWith(e.arrayExpression([Ie,d.node?d.node:e.nullLiteral(),f?e.callExpression(f,[]):e.nullLiteral()]))}}});let p=t.scope.generateUidIdentifier("error"),g=[ee,p],b=[Z];f&&(g.push(e.callExpression(f,[])),b.push(e.nullLiteral()),b.push(e.callExpression(f,[])));let m=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(p,e.blockStatement([e.returnStatement(e.arrayExpression(g))]))),e.returnStatement(e.arrayExpression(b))];return f&&m.unshift(e.variableDeclaration("const",[e.variableDeclarator(f,e.arrowFunctionExpression([],e.objectExpression(n.map(u=>e.objectProperty(u,u,!1,!0)))))])),t.node.body=m,{breaks:i,continues:s,hasReturn:l,hasYield:c,breakCount:o,continueCount:a}}function ve(t,n,r,i,o){let s;r!==i.length&&(s=e.blockStatement([e.breakStatement()]));for(let a=0,l=i.length;a<l;a++){let c=i[a];s=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(c)),e.blockStatement([e.breakStatement(e.identifier(c))]),s)])}return s?e.ifStatement(e.binaryExpression("===",t,Q),s,o):o}function Fe(t,n,r,i,o){let s;r!==i.length&&(s=e.blockStatement([e.continueStatement()]));for(let a=0,l=i.length;a<l;a++){let c=i[a];s=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(c)),e.blockStatement([e.continueStatement(e.identifier(c))]),s)])}return s?e.ifStatement(e.binaryExpression("===",t,X),s,o):o}function te(t,n,r){let i=t.scope.generateUidIdentifier("iterator"),o=t.scope.generateUidIdentifier("step");return[[e.variableDeclaration("let",[e.variableDeclarator(o),e.variableDeclarator(i,e.awaitExpression(e.callExpression(n,r)))]),e.whileStatement(e.booleanLiteral(!0),e.blockStatement([e.expressionStatement(e.assignmentExpression("=",o,e.awaitExpression(e.callExpression(e.memberExpression(i,e.identifier("next")),[])))),e.ifStatement(e.memberExpression(o,e.identifier("done")),e.blockStatement([e.breakStatement()]),e.blockStatement([e.expressionStatement(e.yieldExpression(e.memberExpression(o,e.identifier("value"))))]))]))],o]}function Ne(t,n,r,i,o){let s=n.scope.generateUidIdentifier("type"),a=n.scope.generateUidIdentifier("result"),l=n.scope.generateUidIdentifier("mutations"),c;o.hasReturn&&(c=e.ifStatement(e.binaryExpression("===",s,j),e.blockStatement([e.returnStatement(a)]),c)),o.breakCount>0&&(c=ve(s,a,o.breakCount,o.breaks,c)),o.continueCount>0&&(c=Fe(s,a,o.continueCount,o.continues,c));let f=[];if(o.hasYield){let p=n.scope.generateUidIdentifier("block");f.push(e.variableDeclaration("const",[e.variableDeclarator(p,e.callExpression(N(t,n,_),[e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(r))),e.identifier("default")),i.mutations.length?e.arrowFunctionExpression([l],e.assignmentExpression("=",e.objectPattern(i.mutations.map(m=>e.objectProperty(m,m,!1,!0))),l)):e.nullLiteral()]))]));let[g,b]=te(n,p,i.locals);for(let m=0,u=g.length;m<u;m++)f.push(g[m]);f.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([s,a]),e.memberExpression(b,e.identifier("value")))]))}else f.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([s,a]),e.awaitExpression(e.callExpression(e.callExpression(N(t,n,L),[e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(r))),e.identifier("default")),i.mutations.length?e.arrowFunctionExpression([l],e.assignmentExpression("=",e.objectPattern(i.mutations.map(p=>e.objectProperty(p,p,!1,!0))),l)):e.nullLiteral()]),i.locals)))]));return c&&f.push(c),e.blockStatement(f)}function he(t,n,r,i){let o=ke(n,i.mutations),s=A(t,i,e.functionExpression(void 0,i.locals,e.blockStatement(n.node.body),o.hasYield,!0)),a=O(t,n,s,r.target);n.replaceWith(Ne(t,n,a,i,o))}function ne(t,n,r){he(t,n,r,R(t,n,S(n,"block"),r.pure))}function Ce(t,n){let r=t.scope.getFunctionParent()||t.scope.getProgramParent(),i=n.length?t.scope.generateUidIdentifier("mutate"):void 0,o=!1,s=!1;t.traverse({ReturnStatement(p){if((p.scope.getFunctionParent()||p.scope.getProgramParent())===r){o=!0;let b=[j];p.node.argument?b.push(p.node.argument):b.push(e.nullLiteral()),i&&b.push(e.callExpression(i,[])),p.replaceWith(e.returnStatement(e.arrayExpression(b))),p.skip()}},YieldExpression(p){(p.scope.getFunctionParent()||p.scope.getProgramParent())===r&&(s=!0)}});let a=t.scope.generateUidIdentifier("error"),l=[ee,a],c=[Z];i&&(l.push(e.callExpression(i,[])),c.push(e.nullLiteral()),c.push(e.callExpression(i,[])));let f=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(a,e.blockStatement([e.returnStatement(e.arrayExpression(l))]))),e.returnStatement(e.arrayExpression(c))];return i&&f.unshift(e.variableDeclaration("const",[e.variableDeclarator(i,e.arrowFunctionExpression([],e.objectExpression(n.map(p=>e.objectProperty(p,p,!1,!0)))))])),t.node.body=f,{hasReturn:o,hasYield:s}}function Re(t,n,r,i,o){let s=n.scope.generateUidIdentifier("rest"),a=n.scope.generateUidIdentifier("type"),l=n.scope.generateUidIdentifier("result"),c=n.scope.generateUidIdentifier("mutations"),f=[];if(o.hasYield){let p=n.scope.generateUidIdentifier("fn");f.push(e.variableDeclaration("const",[e.variableDeclarator(p,e.callExpression(N(t,n,_),[e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(r))),e.identifier("default")),i.mutations.length?e.arrowFunctionExpression([c],e.assignmentExpression("=",e.objectPattern(i.mutations.map(m=>e.objectProperty(m,m,!1,!0))),c)):e.nullLiteral()]))]));let[g,b]=te(n,p,[e.arrayExpression(i.locals),e.spreadElement(s)]);for(let m=0,u=g.length;m<u;m++)f.push(g[m]);f.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([a,l]),e.memberExpression(b,e.identifier("value")))]))}else f.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([a,l]),e.awaitExpression(e.callExpression(e.callExpression(N(t,n,L),[e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(r))),e.identifier("default")),i.mutations.length?e.arrowFunctionExpression([c],e.assignmentExpression("=",e.objectPattern(i.mutations.map(p=>e.objectProperty(p,p,!1,!0))),c)):e.nullLiteral()]),[e.arrayExpression(i.locals),e.spreadElement(s)])))]));return f.push(e.returnStatement(l)),x(n,e.isFunctionExpression)?e.functionExpression(n.node.id,[e.restElement(s)],e.blockStatement(f),!0,o.hasYield):e.arrowFunctionExpression([e.restElement(s)],e.blockStatement(f),!0)}function we(t,n,r,i){let o=n.get("body");x(o,e.isExpression)&&o.replaceWith(e.blockStatement([e.returnStatement(o.node)])),v(x(o,e.isBlockStatement),"invariant");let s=Ce(o,i.mutations),a=A(t,i,e.isFunctionExpression(n.node)?e.functionExpression(n.node.id,[e.arrayPattern(i.locals),...n.node.params],n.node.body,n.node.async,n.node.generator):e.arrowFunctionExpression([e.arrayPattern(i.locals),...n.node.params],n.node.body,n.node.async)),l=O(t,n,a,r.target);return Re(t,n,l,i,s)}function re(t,n,r){return we(t,n,r,R(t,n,S(n,"function"),r.pure))}function Me(t,n,r,i){let o=A(t,i,n.node),s=O(t,n,o,r.target),a=n.scope.generateUidIdentifier("rest");return e.arrowFunctionExpression([e.restElement(a)],e.callExpression(e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(s))),e.identifier("default")),[e.spreadElement(a)]),!0)}function ie(t,n,r){return Me(t,n,r,R(t,n,S(n,"expression"),r.pure))}function oe(t,n){for(let r=0,i=t.options.directives.length;r<i;r++){let o=t.options.directives[r];if(o.value===n)return o}}function Be(t,n){for(let r=0,i=n.node.directives.length;r<i;r++){let o=n.node.directives[r].value.value,s=oe(t,o);if(s)return s}}function Le(t,n){for(let r=0,i=n.node.body.length;r<i;r++){let o=n.node.body[r];if(o.type==="ExpressionStatement"&&o.expression.type==="StringLiteral"){let s=oe(t,o.expression.value);if(s)return s}else break}}function _e(t,n){let r=n.getFunctionParent();if(!(r&&!r.node.async))return Be(t,n)||Le(t,n)}function Te(t,n){let r=[];for(let i=0,o=t.node.directives.length;i<o;i++){let s=t.node.directives[i];s.value.value!==n.value&&r.push(s)}t.node.directives=r}function Ue(t,n){let r=t.get("body");for(let i=0,o=r.length;i<o;i++){let s=r[i];if(s.node.type==="ExpressionStatement"&&s.node.expression.type==="StringLiteral"&&s.node.expression.value===n.value){s.remove();return}}}function se(t,n){let r=_e(t,n);r&&(Te(n,r),Ue(n,r),ne(t,n,r))}import*as E from"@babel/types";function Ve(t,n){for(let r=0,i=t.length;r<i;r++){let o=t[r];if(o.source.kind==="default"&&n==="default"||o.source.kind==="named"&&n===o.source.name)return o}}function Ae(t,n){let r=n.node.callee,i=h(r,E.isIdentifier);if(i){let s=n.scope.getBindingIdentifier(i.name);return s?t.registrations.identifiers.get(s):void 0}let o=h(r,E.isMemberExpression);if(o&&!o.computed&&E.isIdentifier(o.property)){let s=h(o.object,E.isIdentifier);if(s){let a=n.scope.getBindingIdentifier(s.name);if(a){let l=t.registrations.namespaces.get(a);if(l)return Ve(l,o.property.name)}}}}function Oe(t){return E.isArrowFunctionExpression(t)||E.isFunctionExpression(t)}function je(t){if(t.leadingComments){for(let n=0,r=t.leadingComments.length;n<r;n++)if(/^@dismantle skip$/.test(t.leadingComments[n].value))return!0}return!1}function ae(t,n){let r=Ae(t,n);if(!r)return;let o=n.get("arguments")[0];if(x(o,E.isExpression)){if(je(o.node))return;let s=x(o,Oe)?re(t,o,r):ie(t,o,r);r.preserve?o.replaceWith(E.addComment(s,"leading","@dismantle skip")):n.replaceWith(s)}}import*as D from"@babel/types";function Ke(t,n,r){if(D.isImportSpecifier(n)){if(n.importKind==="type"||n.importKind==="typeof")return;let i=M(n);(r.source.kind==="named"&&i===r.source.name||r.source.kind==="default"&&i==="default")&&t.registrations.identifiers.set(n.local,r)}if(D.isImportDefaultSpecifier(n)&&r.source.kind==="default"&&t.registrations.identifiers.set(n.local,r),D.isImportNamespaceSpecifier(n)){let i=t.registrations.namespaces.get(n.local);i||(i=[]),i.push(r),t.registrations.namespaces.set(n.local,i)}}function Ye(t,n,r){for(let i=0,o=n.node.specifiers.length;i<o;i++){let s=n.node.specifiers[i];Ke(t,s,r)}}function le(t,n){let r=t.options.functions.length;r&&n.traverse({ImportDeclaration(i){if(!(i.node.importKind==="type"||i.node.importKind==="typeof"))for(let o=0;o<r;o++){let s=t.options.functions[o];s.source.source===i.node.source.value&&Ye(t,i,s)}}})}function ce(){return{name:"dismantle",visitor:{Program(t,n){le(n.opts,t)},BlockStatement(t,n){se(n.opts,t)},CallExpression(t,n){ae(n.opts,t)}}}}function $e(t){let n=[];for(let r=0,i=t.length;r<i;++r){let o=t.charCodeAt(r);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|o&63);else if(o<55296||o>=57344)n.push(224|o>>12,128|o>>6&63,128|o&63);else{let s=65536+((o&1023)<<10|t.charCodeAt(++r)&1023);n.push(240|s>>18&7,128|s>>12&63,128|s>>6&63,128|s&63)}}return new Uint8Array(n)}function K(t,n=0){t=typeof t=="string"?$e(t):t;let r=t,i=n+374761393&4294967295,o=0;if(r.length>=16){let a=[n+2654435761+2246822519&4294967295,n+2246822519&4294967295,n+0&4294967295,n-2654435761&4294967295],l=t,c=l.length-16,f=0;for(o=0;(o&4294967280)<=c;o+=4){let p=o,g=l[p+0]+(l[p+1]<<8),b=l[p+2]+(l[p+3]<<8),m=g*2246822519+(b*2246822519<<16),u=a[f]+m&4294967295;u=u<<13|u>>>19;let I=u&65535,d=u>>>16;a[f]=I*2654435761+(d*2654435761<<16)&4294967295,f=f+1&3}i=(a[0]<<1|a[0]>>>31)+(a[1]<<7|a[1]>>>25)+(a[2]<<12|a[2]>>>20)+(a[3]<<18|a[3]>>>14)&4294967295}i=i+t.length&4294967295;let s=t.length-4;for(;o<=s;o+=4){let a=o,l=r[a+0]+(r[a+1]<<8),c=r[a+2]+(r[a+3]<<8),f=l*3266489917+(c*3266489917<<16);i=i+f&4294967295,i=i<<17|i>>>15,i=(i&65535)*668265263+((i>>>16)*668265263<<16)&4294967295}for(;o<r.length;++o){let a=r[o];i+=a*374761393,i=i<<11|i>>>21,i=(i&65535)*2654435761+((i>>>16)*2654435761<<16)&4294967295}return i^=i>>>15,i=((i&65535)*2246822519&4294967295)+((i>>>16)*2246822519<<16),i^=i>>>13,i=((i&65535)*3266489917&4294967295)+((i>>>16)*3266489917<<16),i^=i>>>16,i<0?i+4294967296:i}async function Bt(t,n,r){let i=Y.parse(t),o=[],s=[],a=new Map,l={id:t,path:i,imports:new Map,virtual:{count:0},options:r,bindings:new Map,blocks:{hash:K(t).toString(16),count:0},onVirtualFile(p,g,b){let m=Y.join(i.dir,p);a.set(Y.join(i.dir,p),g),b==="entry"?o.push(m):b==="root"&&s.push(m)},registrations:{identifiers:new Map,namespaces:new Map}},c=["jsx"];/\.[mc]?tsx?$/i.test(t)&&c.push("typescript");let f=await fe.transformAsync(n,{plugins:[[ce,l]],parserOpts:{plugins:c},filename:i.base,ast:!1,sourceFileName:t,sourceMaps:!0,configFile:!1,babelrc:!1});return v(f,"invariant"),{code:f.code,map:f.map,files:a,entries:o,roots:s}}export{Bt as compile};
@@ -0,0 +1,4 @@
1
+ import type { ImportDefinition } from './types';
2
+ export declare const HIDDEN_FUNC: ImportDefinition;
3
+ export declare const HIDDEN_GENERATOR: ImportDefinition;
4
+ //# sourceMappingURL=hidden-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hidden-imports.d.ts","sourceRoot":"","sources":["../../src/hidden-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,gBAIzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,gBAI9B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { CodeOutput, Options } from './types';
2
+ export interface Output extends CodeOutput {
3
+ files: Map<string, CodeOutput>;
4
+ entries: string[];
5
+ roots: string[];
6
+ }
7
+ export type { CodeOutput, DefaultImportDefinition, DirectiveDefinition, ImportDefinition, NamedImportDefinition, Options, } from './types';
8
+ export declare function compile(id: string, code: string, options: Options): Promise<Output>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAIjE,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,YAAY,EACV,UAAU,EACV,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,wBAAsB,OAAO,CAC3B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,CA+DjB"}
@@ -0,0 +1,8 @@
1
+ import type * as babel from '@babel/core';
2
+ import type { StateContext } from './types';
3
+ interface State extends babel.PluginPass {
4
+ opts: StateContext;
5
+ }
6
+ export declare function plugin(): babel.PluginObj<State>;
7
+ export {};
8
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAG1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,UAAU,KAAM,SAAQ,KAAK,CAAC,UAAU;IACtC,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,wBAAgB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAe/C"}
@@ -0,0 +1,7 @@
1
+ import type * as babel from '@babel/core';
2
+ import * as t from '@babel/types';
3
+ import type { DirectiveDefinition, FunctionDefinition, StateContext } from './types';
4
+ export declare function splitBlock(ctx: StateContext, path: babel.NodePath<t.BlockStatement>, directive: DirectiveDefinition): void;
5
+ export declare function splitFunction(ctx: StateContext, path: babel.NodePath<t.ArrowFunctionExpression | t.FunctionExpression>, func: FunctionDefinition): t.Expression;
6
+ export declare function splitExpression(ctx: StateContext, path: babel.NodePath<t.Expression>, func: FunctionDefinition): t.Expression;
7
+ //# sourceMappingURL=split.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/split.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAGlB,YAAY,EACb,MAAM,SAAS,CAAC;AA+uBjB,wBAAgB,UAAU,CACxB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EACtC,SAAS,EAAE,mBAAmB,GAC7B,IAAI,CAYN;AAmPD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,uBAAuB,GAAG,CAAC,CAAC,kBAAkB,CAAC,EACtE,IAAI,EAAE,kBAAkB,GACvB,CAAC,CAAC,UAAU,CAOd;AA0BD,wBAAgB,eAAe,CAC7B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,EAClC,IAAI,EAAE,kBAAkB,GACvB,CAAC,CAAC,UAAU,CAYd"}
@@ -0,0 +1,5 @@
1
+ import type * as babel from '@babel/core';
2
+ import type * as t from '@babel/types';
3
+ import type { StateContext } from './types';
4
+ export declare function transformBlock(ctx: StateContext, path: babel.NodePath<t.BlockStatement>): void;
5
+ //# sourceMappingURL=transform-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-block.d.ts","sourceRoot":"","sources":["../../src/transform-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AAEvC,OAAO,KAAK,EAAuB,YAAY,EAAE,MAAM,SAAS,CAAC;AAoGjE,wBAAgB,cAAc,CAC5B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,GACrC,IAAI,CAQN"}
@@ -0,0 +1,5 @@
1
+ import type * as babel from '@babel/core';
2
+ import * as t from '@babel/types';
3
+ import type { StateContext } from './types';
4
+ export declare function transformCall(ctx: StateContext, path: babel.NodePath<t.CallExpression>): void;
5
+ //# sourceMappingURL=transform-call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-call.d.ts","sourceRoot":"","sources":["../../src/transform-call.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,KAAK,EAAsB,YAAY,EAAE,MAAM,SAAS,CAAC;AAwEhE,wBAAgB,aAAa,CAC3B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,GACrC,IAAI,CAqBN"}
@@ -0,0 +1,62 @@
1
+ /// <reference types="node" />
2
+ import type * as babel from '@babel/core';
3
+ import type * as t from '@babel/types';
4
+ import type * as path from 'node:path';
5
+ export interface NamedImportDefinition {
6
+ kind: 'named';
7
+ name: string;
8
+ source: string;
9
+ }
10
+ export interface DefaultImportDefinition {
11
+ kind: 'default';
12
+ source: string;
13
+ }
14
+ export type ImportDefinition = DefaultImportDefinition | NamedImportDefinition;
15
+ export interface DirectiveDefinition {
16
+ value: string;
17
+ target: ImportDefinition;
18
+ pure?: boolean;
19
+ }
20
+ export interface FunctionDefinition {
21
+ source: ImportDefinition;
22
+ target: ImportDefinition;
23
+ preserve?: boolean;
24
+ pure?: boolean;
25
+ }
26
+ export interface Options {
27
+ key: string;
28
+ mode: 'server' | 'client';
29
+ env: 'production' | 'development';
30
+ directives: DirectiveDefinition[];
31
+ functions: FunctionDefinition[];
32
+ }
33
+ export interface ModuleDefinition {
34
+ source: string;
35
+ kind: 'default' | 'named' | 'namespace';
36
+ local: string;
37
+ imported?: string;
38
+ }
39
+ export interface CodeOutput {
40
+ code: babel.BabelFileResult['code'];
41
+ map: babel.BabelFileResult['map'];
42
+ }
43
+ export interface StateContext {
44
+ id: string;
45
+ path: path.ParsedPath;
46
+ imports: Map<string, t.Identifier>;
47
+ virtual: {
48
+ count: number;
49
+ };
50
+ blocks: {
51
+ hash: string;
52
+ count: number;
53
+ };
54
+ bindings: Map<string, ModuleDefinition>;
55
+ options: Options;
56
+ onVirtualFile: (path: string, content: CodeOutput, mode: 'entry' | 'root' | 'none') => void;
57
+ registrations: {
58
+ identifiers: Map<t.Identifier, FunctionDefinition>;
59
+ namespaces: Map<t.Identifier, FunctionDefinition[]>;
60
+ };
61
+ }
62
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAE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EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IACnC,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,CACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,KAC5B,IAAI,CAAC;IACV,aAAa,EAAE;QACb,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;QACnD,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,kBAAkB,EAAE,CAAC,CAAC;KACrD,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ export default function assert(cond: unknown, error: string): asserts cond;
2
+ //# sourceMappingURL=assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/utils/assert.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAIzE"}
@@ -0,0 +1,4 @@
1
+ import type * as t from '@babel/types';
2
+ import type { CodeOutput } from '../types';
3
+ export declare function generateCode(id: string, node: t.Node): CodeOutput;
4
+ //# sourceMappingURL=generator-shim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-shim.d.ts","sourceRoot":"","sources":["../../../src/utils/generator-shim.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAU3C,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,UAAU,CASjE"}
@@ -0,0 +1,3 @@
1
+ import type { NodePath } from '@babel/core';
2
+ export declare function getDescriptiveName(path: NodePath, defaultName: string): string;
3
+ //# sourceMappingURL=get-descriptive-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-descriptive-name.d.ts","sourceRoot":"","sources":["../../../src/utils/get-descriptive-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,GAClB,MAAM,CAoCR"}
@@ -0,0 +1,3 @@
1
+ import type * as babel from '@babel/core';
2
+ export default function getForeignBindings(path: babel.NodePath, mode: 'block' | 'function' | 'expression'): Set<string>;
3
+ //# sourceMappingURL=get-foreign-bindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-foreign-bindings.d.ts","sourceRoot":"","sources":["../../../src/utils/get-foreign-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAuC1C,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,IAAI,EAAE,KAAK,CAAC,QAAQ,EACpB,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,YAAY,GACxC,GAAG,CAAC,MAAM,CAAC,CAiBb"}
@@ -0,0 +1,3 @@
1
+ import * as t from '@babel/types';
2
+ export declare function getIdentifiersFromLVal(node: t.LVal): string[];
3
+ //# sourceMappingURL=get-identifiers-from-lval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-identifiers-from-lval.d.ts","sourceRoot":"","sources":["../../../src/utils/get-identifiers-from-lval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AA4BlC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,MAAM,EAAE,CAe7D"}
@@ -0,0 +1,5 @@
1
+ import type * as babel from '@babel/core';
2
+ import type * as t from '@babel/types';
3
+ import type { ImportDefinition, StateContext } from '../types';
4
+ export declare function getImportIdentifier(state: StateContext, path: babel.NodePath, registration: ImportDefinition): t.Identifier;
5
+ //# sourceMappingURL=get-import-identifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-import-identifier.d.ts","sourceRoot":"","sources":["../../../src/utils/get-import-identifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE/D,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,KAAK,CAAC,QAAQ,EACpB,YAAY,EAAE,gBAAgB,GAC7B,CAAC,CAAC,UAAU,CAad"}
@@ -0,0 +1,3 @@
1
+ import type * as t from '@babel/types';
2
+ export declare function getImportSpecifierName(node: t.ImportSpecifier): string;
3
+ //# sourceMappingURL=get-import-specifier-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-import-specifier-name.d.ts","sourceRoot":"","sources":["../../../src/utils/get-import-specifier-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AAEvC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC,eAAe,UAO7D"}
@@ -0,0 +1,4 @@
1
+ import type * as babel from '@babel/core';
2
+ import type { ModuleDefinition } from '../types';
3
+ export declare function getModuleDefinition(path: babel.NodePath): ModuleDefinition | undefined;
4
+ //# sourceMappingURL=get-module-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-module-definition.d.ts","sourceRoot":"","sources":["../../../src/utils/get-module-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,KAAK,CAAC,QAAQ,GACnB,gBAAgB,GAAG,SAAS,CA4C9B"}
@@ -0,0 +1,3 @@
1
+ import type * as babel from '@babel/core';
2
+ export declare function getRootStatementPath(path: babel.NodePath): babel.NodePath;
3
+ //# sourceMappingURL=get-root-statement-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-root-statement-path.d.ts","sourceRoot":"","sources":["../../../src/utils/get-root-statement-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAG1C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAUzE"}
@@ -0,0 +1,5 @@
1
+ import type * as babel from '@babel/core';
2
+ import * as t from '@babel/types';
3
+ import type { StateContext } from '../types';
4
+ export declare function registerImportSpecifiers(ctx: StateContext, programPath: babel.NodePath<t.Program>): void;
5
+ //# sourceMappingURL=register-import-specifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-import-specifiers.d.ts","sourceRoot":"","sources":["../../../src/utils/register-import-specifiers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,EAAsB,YAAY,EAAE,MAAM,UAAU,CAAC;AAkDjE,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,YAAY,EACjB,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GACrC,IAAI,CAqBN"}
@@ -0,0 +1,11 @@
1
+ import type * as babel from '@babel/core';
2
+ import type * as t from '@babel/types';
3
+ type TypeFilter<V extends t.Node> = (node: t.Node) => node is V;
4
+ export declare function isPathValid<V extends t.Node>(path: unknown, key: TypeFilter<V>): path is babel.NodePath<V>;
5
+ export type NestedExpression = t.ParenthesizedExpression | t.TypeCastExpression | t.TSAsExpression | t.TSSatisfiesExpression | t.TSNonNullExpression | t.TSInstantiationExpression | t.TSTypeAssertion;
6
+ export declare function isNestedExpression(node: t.Node): node is NestedExpression;
7
+ type TypeCheck<K> = K extends TypeFilter<infer U> ? U : never;
8
+ export declare function unwrapNode<K extends (value: t.Node) => boolean>(node: t.Node, key: K): TypeCheck<K> | undefined;
9
+ export declare function unwrapPath<V extends t.Node>(path: unknown, key: TypeFilter<V>): babel.NodePath<V> | undefined;
10
+ export {};
11
+ //# sourceMappingURL=unwrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unwrap.d.ts","sourceRoot":"","sources":["../../../src/utils/unwrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AAEvC,KAAK,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC;AAEhE,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAC1C,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GACjB,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAE3B;AAED,MAAM,MAAM,gBAAgB,GACxB,CAAC,CAAC,uBAAuB,GACzB,CAAC,CAAC,kBAAkB,GACpB,CAAC,CAAC,cAAc,GAChB,CAAC,CAAC,qBAAqB,GACvB,CAAC,CAAC,mBAAmB,GACrB,CAAC,CAAC,yBAAyB,GAC3B,CAAC,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