@vobs/compiler 1.2.2 → 1.3.1
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.
- package/dist/compile.cjs +81 -17
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.js +81 -17
- package/dist/compile.js.map +1 -1
- package/dist/index.cjs +81 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +81 -17
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +6 -0
- package/dist/plugin.d.ts +6 -0
- package/package.json +2 -2
- package/src/compile.test.ts +74 -0
- package/src/compile.ts +113 -17
- package/src/plugin.ts +6 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/compile.ts","../src/i18n-extractor.ts"],"sourcesContent":["import ts from 'typescript'\nimport { VobsError } from '@vobs/runtime/error'\nimport type {\n CompilerContext,\n CompilerOptions,\n CompilerPlugin,\n CompileOptions,\n CompileResult,\n CompilerDiagnostic,\n VobsCompiler\n} from './plugin'\n\n/**\n * 单次编译的全部可变状态。\n *\n * 此前这些字段是模块级变量,编译器因此不可重入:嵌套调用 compile()\n * (如插件内部再次编译片段)会互相污染状态。现在每次 compile 调用\n * 创建独立的 CompileState 并显式穿参,编译器对并发与嵌套完全安全。\n */\ninterface CompileState {\n /** 临时标识符计数器(_el0、_el1…)。 */\n generatedId: number\n filename: string\n /** 最初解析出的源文件。插件 program 变换后的树节点无法回溯原始位置时,用它兜底取行列。 */\n sourceFile: ts.SourceFile\n /** 生成语句 → 原始源码位置,用于 source map 生成。 */\n statementSources: WeakMap<ts.Statement, SourcePosition>\n /** 源文件中已声明的绑定名(含嵌套作用域):注入运行时 import 与生成临时变量时避开命名冲突。 */\n takenNames: Set<string>\n /** 运行时 helper 的规范名 → 产物中的引用名(无冲突时与规范名相同)。 */\n helperAliases: Map<string, string>\n /** 静态模板声明:HTML → 模块级模板变量,按内容去重,输出在 import 之后。 */\n templates: Map<string, ts.Identifier>\n /** 是否为组件调用生成源码位置(生产构建传 false 剔除,减小产物体积)。 */\n sourceLocation: boolean\n /** 从 @vobs/reactivity / @vobs/vobs 导入的 `state` 别名(含 as 别名),用于 debugName 自动推断。 */\n stateAliases: ReadonlySet<string>\n /** 非 import 的本地声明绑定名:`state` 被本地声明遮蔽时禁用 debugName 推断。 */\n localBindings: ReadonlySet<string>\n /** 编译器自身产出的诊断(如不支持的 JSX 形态),与 TypeScript 解析诊断合并返回。 */\n diagnostics: CompilerDiagnostic[]\n}\n\ninterface SourcePosition {\n readonly line: number\n readonly column: number\n}\n\nexport function createCompiler(options: CompilerOptions = {}): VobsCompiler {\n const basePlugins = options.plugins ?? []\n\n return {\n compile(code: string, overrides: CompileOptions = {}): string {\n return compile(code, {\n ...overrides,\n plugins: [...basePlugins, ...(overrides.plugins ?? [])]\n })\n },\n compileWithSourceMap(code: string, overrides: CompileOptions = {}): CompileResult {\n return compileWithSourceMap(code, {\n ...overrides,\n plugins: [...basePlugins, ...(overrides.plugins ?? [])]\n })\n }\n }\n}\n\nexport function compile(code: string, options: CompileOptions = {}): string {\n const result = compileWithSourceMap(code, options)\n const firstError = result.diagnostics.find(diagnostic => diagnostic.severity === 'error')\n if (firstError) {\n throw new VobsError({\n code: firstError.code,\n layer: 'compiler',\n message: firstError.message,\n location: firstError.location,\n codeFrame: firstError.codeFrame,\n fix: firstError.fix\n })\n }\n return result.code\n}\n\nexport function compileWithSourceMap(code: string, options: CompileOptions = {}): CompileResult {\n const filename = options.filename ?? 'component.tsx'\n let sourceFile = ts.createSourceFile(\n filename,\n code,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX\n )\n const state: CompileState = {\n generatedId: 0,\n filename,\n sourceFile,\n statementSources: new WeakMap(),\n takenNames: collectDeclaredNames(sourceFile),\n helperAliases: new Map(),\n templates: new Map(),\n sourceLocation: options.sourceLocation ?? true,\n stateAliases: collectStateAliases(sourceFile),\n localBindings: collectLocallyDeclaredNames(sourceFile),\n diagnostics: []\n }\n const cleanFilename = filename.split(/[?#]/u, 1)[0] || filename\n const diagnostics = ts.transpileModule(code, {\n // Vite appends query strings (for example `?direct`) to module IDs;\n // strip them so TypeScript still recognizes TSX syntax for diagnostics.\n fileName: cleanFilename,\n reportDiagnostics: true,\n compilerOptions: { jsx: ts.JsxEmit.Preserve, target: ts.ScriptTarget.Latest }\n }).diagnostics?.map(diagnostic => toCompilerDiagnostic(diagnostic, sourceFile, cleanFilename)) ?? []\n const plugins = options.plugins ?? []\n validatePlugins(plugins)\n\n const context: CompilerContext = {\n filename,\n factory: ts.factory,\n addRuntimeImport(name: string): void {\n resolveHelperName(state, name)\n },\n helperRef: (name: string) => helperRef(state, name)\n }\n\n for (const plugin of plugins) plugin.analyze?.(sourceFile, context)\n for (const plugin of plugins) {\n sourceFile = plugin.transform?.program?.(sourceFile, context) ?? sourceFile\n }\n for (const plugin of plugins) sourceFile = transformPluginNodes(sourceFile, plugin, context)\n\n const statements = sourceFile.statements.map(statement =>\n ts.isImportDeclaration(statement) ? rebuildImport(state, statement) : transformStatement(state, statement)\n )\n // 模板声明必须先于 runtime import 生成:声明里的 createTemplate 依赖\n // helperRef 注册别名,import 需要在别名全部就绪后再构建。\n const templateDeclarations = createTemplateDeclarations(state)\n const resultFile = ts.factory.updateSourceFile(sourceFile, [\n ...createRuntimeImports(state),\n ...templateDeclarations,\n ...statements\n ])\n\n const generated = ts.createPrinter().printFile(resultFile)\n return {\n code: generated,\n map: buildSourceMap(state, filename, code, generated, resultFile),\n diagnostics: [...diagnostics, ...state.diagnostics]\n }\n}\n\nfunction toCompilerDiagnostic(\n diagnostic: ts.Diagnostic,\n sourceFile: ts.SourceFile,\n filename: string\n): CompilerDiagnostic {\n const start = diagnostic.start ?? 0\n const length = diagnostic.length ?? 1\n const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n const { line, column, codeFrame } = buildCodeFrame(sourceFile, start, length)\n return {\n code: `VOBS_C${String(diagnostic.code).padStart(3, '0')}`,\n severity: diagnostic.category === ts.DiagnosticCategory.Warning ? 'warning' : 'error',\n message,\n location: { file: filename, line, column },\n codeFrame\n }\n}\n\nfunction buildCodeFrame(\n sourceFile: ts.SourceFile,\n start: number,\n length: number\n): { line: number; column: number; codeFrame: string } {\n const position = sourceFile.getLineAndCharacterOfPosition(start)\n const lineText = sourceFile.text.split(/\\r?\\n/u)[position.line] ?? ''\n const markerLength = Math.max(1, Math.min(length, Math.max(1, lineText.length - position.character)))\n return {\n line: position.line + 1,\n column: position.character + 1,\n codeFrame: `${position.line + 1} | ${lineText}\\n${' '.repeat(String(position.line + 1).length + 3 + position.character)}${'^'.repeat(markerLength)}`\n }\n}\n\n/**\n * 不支持的 JSX 标签形态(成员表达式 `<Foo.Bar>`、命名空间 `<svg:rect>` 等)。\n * 诊断以 error 级返回,compile() 与 Vite 插件会直接失败,不再静默产出无效 DOM 标签。\n */\nfunction reportUnsupportedTag(state: CompileState, tagName: ts.JsxTagNameExpression): void {\n const sourceFile = tagName.getSourceFile() ?? state.sourceFile\n if (!sourceFile) return\n const label = tagName.getText()\n const kindNote = tagName.kind === ts.SyntaxKind.JsxNamespacedName ? '(JSX 命名空间标签)' : ''\n const { line, column, codeFrame } = buildCodeFrame(sourceFile, tagName.getStart(sourceFile), tagName.getWidth(sourceFile))\n state.diagnostics.push({\n code: 'VOBS_C101',\n severity: 'error',\n message: `不支持的 JSX 标签形态:<${label}>${kindNote}。组件必须是大写开头的标识符,DOM 元素必须是小写标签名。`,\n location: { file: state.filename, line, column },\n codeFrame,\n fix: `把 <${label}> 改为 <Component /> 形式的组件或小写 DOM 标签;Fragment 请使用 <Fragment> 或 <>...</>。`\n })\n}\n\ninterface MappingSegment {\n readonly genLine: number\n readonly genCol: number\n readonly srcLine: number\n readonly srcCol: number\n}\n\n/**\n * Build a real statement-level source map. The generated file is re-parsed and\n * paired structurally with the compiled tree (statements map 1:1 inside every\n * block), so each emitted statement points back to the JSX or original\n * statement it was produced from.\n */\nfunction buildSourceMap(\n state: CompileState,\n filename: string,\n source: string,\n generated: string,\n resultFile: ts.SourceFile\n): import('./plugin').VobsSourceMap {\n const reparsed = ts.createSourceFile(filename, generated, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX)\n const segments: MappingSegment[] = []\n walkPairedTrees(state, resultFile, reparsed, reparsed, segments)\n segments.sort((a, b) => a.genLine - b.genLine || a.genCol - b.genCol)\n return {\n version: 3,\n file: filename,\n sources: [filename],\n sourcesContent: [source],\n names: [],\n mappings: encodeMappings(segments, generated.split('\\n').length)\n }\n}\n\n/** Statements only nest inside these container kinds. */\nfunction statementLists(node: ts.Node): readonly ts.Statement[] | null {\n if (ts.isSourceFile(node) || ts.isBlock(node) || ts.isModuleBlock(node)) return node.statements\n if (ts.isCaseClause(node) || ts.isDefaultClause(node)) return node.statements\n return null\n}\n\n/**\n * Pair the compiled tree with the re-parsed generated tree node by node.\n * Both trees were printed from the same AST, so their shapes are identical;\n * any divergence (length mismatch) simply abandons that subtree.\n */\nfunction walkPairedTrees(\n state: CompileState,\n original: ts.Node,\n generated: ts.Node,\n reparsed: ts.SourceFile,\n segments: MappingSegment[]\n): void {\n const originalStatements = statementLists(original)\n const generatedStatements = statementLists(generated)\n if (originalStatements && generatedStatements) {\n if (originalStatements.length !== generatedStatements.length) return\n for (let index = 0; index < originalStatements.length; index++) {\n const originalStatement = originalStatements[index]\n const generatedStatement = generatedStatements[index]\n recordSegment(state, originalStatement, generatedStatement, reparsed, segments)\n walkPairedTrees(state, originalStatement, generatedStatement, reparsed, segments)\n }\n return\n }\n\n const originalChildren: ts.Node[] = []\n const generatedChildren: ts.Node[] = []\n ts.forEachChild(original, node => { originalChildren.push(node) })\n ts.forEachChild(generated, node => { generatedChildren.push(node) })\n if (originalChildren.length !== generatedChildren.length) return\n for (let index = 0; index < originalChildren.length; index++) {\n walkPairedTrees(state, originalChildren[index], generatedChildren[index], reparsed, segments)\n }\n}\n\nfunction recordSegment(\n state: CompileState,\n originalStatement: ts.Statement,\n generatedStatement: ts.Statement,\n reparsed: ts.SourceFile,\n segments: MappingSegment[]\n): void {\n const source = state.statementSources.get(originalStatement) ?? positionOfOriginalStatement(state, originalStatement)\n if (!source) return\n const position = reparsed.getLineAndCharacterOfPosition(generatedStatement.getStart(reparsed))\n segments.push({\n genLine: position.line,\n genCol: position.character,\n srcLine: source.line,\n srcCol: source.column\n })\n}\n\nfunction positionOfOriginalStatement(state: CompileState, statement: ts.Statement): SourcePosition | null {\n if (statement.pos < 0 || !state.sourceFile) return null\n const { line, character } = state.sourceFile.getLineAndCharacterOfPosition(\n statement.getStart(state.sourceFile)\n )\n return { line, column: character }\n}\n\nfunction encodeMappings(segments: readonly MappingSegment[], lineCount: number): string {\n const lines: string[][] = Array.from({ length: lineCount }, () => [])\n let prevGenLine = -1\n let prevGenCol = 0\n let prevSrcLine = 0\n let prevSrcCol = 0\n for (const segment of segments) {\n if (segment.genLine !== prevGenLine) {\n prevGenCol = 0\n prevGenLine = segment.genLine\n }\n const values = [\n segment.genCol - prevGenCol,\n 0,\n segment.srcLine - prevSrcLine,\n segment.srcCol - prevSrcCol\n ]\n lines[segment.genLine].push(values.map(encodeVlq).join(''))\n prevGenCol = segment.genCol\n prevSrcLine = segment.srcLine\n prevSrcCol = segment.srcCol\n }\n return lines.map(line => line.join(',')).join(';')\n}\n\nconst base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n\nfunction encodeVlq(value: number): string {\n let encoded = value < 0 ? ((-value) << 1) | 1 : value << 1\n let result = ''\n do {\n let digit = encoded & 31\n encoded >>>= 5\n if (encoded > 0) digit |= 32\n result += base64Chars[digit]\n } while (encoded > 0)\n return result\n}\n\nfunction validatePlugins(plugins: readonly CompilerPlugin[]): void {\n const names = new Set<string>()\n for (const plugin of plugins) {\n if (!plugin.name) throw new VobsError({ code: 'VOBS_C007', layer: 'compiler', message: '编译器插件必须提供 name', fix: '为插件添加稳定且唯一的 name。' })\n if (names.has(plugin.name)) throw new VobsError({ code: 'VOBS_C007', layer: 'compiler', message: `检测到重复插件: ${plugin.name}`, fix: '为每个编译器插件使用唯一的 name。' })\n names.add(plugin.name)\n }\n}\n\nfunction transformPluginNodes(\n sourceFile: ts.SourceFile,\n plugin: CompilerPlugin,\n context: CompilerContext\n): ts.SourceFile {\n const transformNode = plugin.transform?.node ?? plugin.transformNode\n if (!transformNode) return sourceFile\n\n const transformer: ts.TransformerFactory<ts.SourceFile> = transformContext => root => {\n const visit: ts.Visitor = node => {\n const replacement = transformNode(node, context)\n if (replacement === null) return undefined\n return ts.visitEachChild(replacement ?? node, visit, transformContext)\n }\n return ts.visitNode(root, visit) as ts.SourceFile\n }\n\n const result = ts.transform(sourceFile, [transformer])\n try {\n return result.transformed[0]\n } finally {\n result.dispose()\n }\n}\n\n/**\n * Collect every binding name declared anywhere in the source (imports, variables,\n * functions, parameters, ... including nested scopes). If a helper name is bound\n * in ANY scope, the injected runtime import must switch to an alias: generated\n * references uniformly use the alias, so user code is never captured or duplicated.\n */\nfunction collectDeclaredNames(sourceFile: ts.SourceFile): Set<string> {\n const names = new Set<string>()\n const visit = (node: ts.Node): void => {\n if (ts.isIdentifier(node) && isBindingName(node)) names.add(node.text)\n ts.forEachChild(node, visit)\n }\n visit(sourceFile)\n return names\n}\n\n/** 收集从 @vobs/reactivity / @vobs/vobs 导入的 `state` 绑定名(含 `as` 别名)。 */\nfunction collectStateAliases(sourceFile: ts.SourceFile): Set<string> {\n const aliases = new Set<string>()\n for (const statement of sourceFile.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue\n const module = statement.moduleSpecifier.text\n if (module !== '@vobs/reactivity' && module !== '@vobs/vobs') continue\n const clause = statement.importClause\n if (!clause?.namedBindings || !ts.isNamedImports(clause.namedBindings)) continue\n for (const element of clause.namedBindings.elements) {\n if (element.propertyName ? element.propertyName.text === 'state' : element.name.text === 'state') {\n aliases.add(element.name.text)\n }\n }\n }\n return aliases\n}\n\n/** 与 collectDeclaredNames 相同,但跳过 import 声明:用于判断 helper 名是否被本地声明遮蔽。 */\nfunction collectLocallyDeclaredNames(sourceFile: ts.SourceFile): Set<string> {\n const names = new Set<string>()\n const visit = (node: ts.Node): void => {\n if (ts.isImportDeclaration(node)) return\n if (ts.isIdentifier(node) && isBindingName(node)) names.add(node.text)\n ts.forEachChild(node, visit)\n }\n visit(sourceFile)\n return names\n}\n\n/** 标识符是否为某个声明的绑定名(import、变量、函数、参数、类成员等)。 */\nfunction isBindingName(node: ts.Identifier): boolean {\n const parent = node.parent\n if (!parent) return false\n // 属性访问(document.createElement)与 JSX 属性名不是绑定名\n if (ts.isPropertyAccessExpression(parent) && parent.name === node) return false\n if (ts.isQualifiedName(parent) && parent.right === node) return false\n if (ts.isJsxAttribute(parent)) return false\n return (parent as { name?: ts.Node }).name === node\n}\n\n/**\n * Resolve the reference name for a runtime helper. The plain name is kept when\n * the source never binds it; otherwise a collision-free alias is allocated and\n * the injected import uses the same alias (`import { createElement as _vobs_createElement }`).\n */\nfunction resolveHelperName(state: CompileState, name: string): string {\n const existing = state.helperAliases.get(name)\n if (existing) return existing\n let alias = name\n if (state.takenNames.has(alias)) {\n alias = `_vobs_${name}`\n let suffix = 1\n while (state.takenNames.has(alias)) alias = `_vobs_${name}_${suffix++}`\n }\n state.helperAliases.set(name, alias)\n return alias\n}\n\n/** Create a reference to a runtime helper in generated code, matching the injected import. */\nfunction helperRef(state: CompileState, name: string): ts.Identifier {\n return ts.factory.createIdentifier(resolveHelperName(state, name))\n}\n\nfunction createRuntimeImports(state: CompileState): ts.ImportDeclaration[] {\n const modules = new Map<string, ts.ImportSpecifier[]>()\n for (const [name, alias] of state.helperAliases) {\n const module = name === 'insertResourceBoundary' ? '@vobs/resource' : '@vobs/vobs'\n const imported = modules.get(module) ?? []\n imported.push(ts.factory.createImportSpecifier(\n false,\n alias === name ? undefined : ts.factory.createIdentifier(name),\n ts.factory.createIdentifier(alias)\n ))\n modules.set(module, imported)\n }\n return [...modules.entries()].map(([module, imported]) => ts.factory.createImportDeclaration(\n undefined,\n ts.factory.createImportClause(\n false,\n undefined,\n ts.factory.createNamedImports(imported)\n ),\n ts.factory.createStringLiteral(module)\n ))\n}\n\nfunction rebuildImport(state: CompileState, node: ts.ImportDeclaration): ts.ImportDeclaration {\n if (!ts.isStringLiteral(node.moduleSpecifier)) return node\n return tagStatement(state, ts.factory.createImportDeclaration(\n node.modifiers,\n node.importClause,\n ts.factory.createStringLiteral(node.moduleSpecifier.text),\n node.attributes\n ), node)\n}\n\nfunction transformStatement(state: CompileState, node: ts.Statement): ts.Statement {\n if (ts.isFunctionDeclaration(node) && node.body) {\n return tagStatement(state, ts.factory.updateFunctionDeclaration(\n node,\n node.modifiers,\n node.asteriskToken,\n node.name,\n node.typeParameters,\n node.parameters,\n node.type,\n transformBlock(state, node.body)\n ), node)\n }\n\n if (ts.isVariableStatement(node)) return transformVariableStatement(state, node)\n if (ts.isExportAssignment(node) && containsJsx(node.expression)) {\n return tagStatement(state, ts.factory.updateExportAssignment(node, node.modifiers, transformEmbeddedExpression(state, node.expression)), node)\n }\n if (ts.isExpressionStatement(node) && containsJsx(node.expression)) {\n return tagStatement(state, ts.factory.updateExpressionStatement(node, transformEmbeddedExpression(state, node.expression)), node)\n }\n if (ts.isReturnStatement(node) && node.expression && containsJsx(node.expression)) {\n return tagStatement(state, ts.factory.updateReturnStatement(node, transformEmbeddedExpression(state, node.expression)), node)\n }\n return node\n}\n\nfunction transformVariableStatement(state: CompileState, node: ts.VariableStatement): ts.VariableStatement {\n let changed = false\n const declarations = node.declarationList.declarations.map(declaration => {\n const initializer = declaration.initializer\n if (!initializer) return declaration\n\n let nextInitializer = inferStateDebugName(state, declaration, initializer) ?? initializer\n if (containsJsx(nextInitializer)) {\n nextInitializer = transformEmbeddedExpression(state, nextInitializer)\n }\n if (nextInitializer === initializer) return declaration\n\n changed = true\n return ts.factory.updateVariableDeclaration(\n declaration,\n declaration.name,\n declaration.exclamationToken,\n declaration.type,\n nextInitializer\n )\n })\n\n if (!changed) return node\n\n return tagStatement(state, ts.factory.updateVariableStatement(\n node,\n node.modifiers,\n ts.factory.updateVariableDeclarationList(node.declarationList, declarations)\n ), node)\n}\n\n/**\n * `const name = state(initial)` 在未显式传入 debugName 时从变量名推断:\n * `const username = state('')` → `state('', 'username')`,使 DevTools 信号名称与源码命名一致。\n * 仅当 `state` 确认来自 @vobs/reactivity / @vobs/vobs、未被本地声明遮蔽、\n * 且调用只带一个参数时启用;其余形态保持原样。\n */\nfunction inferStateDebugName(\n state: CompileState,\n declaration: ts.VariableDeclaration,\n initializer: ts.Expression\n): ts.Expression | undefined {\n if (state.stateAliases.size === 0) return undefined\n if (!ts.isIdentifier(declaration.name)) return undefined\n\n let call = initializer\n while (ts.isParenthesizedExpression(call) || ts.isAsExpression(call) || ts.isTypeAssertionExpression(call) || ts.isSatisfiesExpression(call)) {\n call = call.expression\n }\n if (!ts.isCallExpression(call)) return undefined\n const callee = call.expression\n if (!ts.isIdentifier(callee) || !state.stateAliases.has(callee.text)) return undefined\n if (state.localBindings.has(callee.text)) return undefined\n if (call.arguments.length !== 1) return undefined\n\n return ts.factory.createCallExpression(callee, call.typeArguments, [\n ...call.arguments,\n ts.factory.createStringLiteral(declaration.name.text)\n ])\n}\n\nfunction containsJsx(expression: ts.Expression): boolean {\n let found = false\n const visit = (node: ts.Node): void => {\n if (isJsxExpression(node as ts.Expression)) {\n found = true\n return\n }\n ts.forEachChild(node, visit)\n }\n visit(expression)\n return found\n}\n\nfunction transformBlock(state: CompileState, block: ts.Block): ts.Block {\n const statements = block.statements.map(statement => {\n if (!ts.isReturnStatement(statement) || !statement.expression) return transformStatement(state, statement)\n const expression = ts.isParenthesizedExpression(statement.expression)\n ? statement.expression.expression\n : statement.expression\n return isJsxExpression(expression)\n ? tagStatement(state, ts.factory.updateReturnStatement(statement, transformJsxExpression(state, expression)), statement)\n : statement\n })\n return ts.factory.updateBlock(block, statements)\n}\n\nfunction isJsxExpression(node: ts.Expression): node is ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment {\n return ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)\n}\n\nfunction transformJsxExpression(state: CompileState, node: ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment): ts.Expression {\n if (ts.isJsxFragment(node)) return transformFragment(state, node.children)\n if (ts.isJsxElement(node)) {\n return transformElement(state, node, node.openingElement.tagName, node.openingElement.attributes, node.children)\n }\n return transformElement(state, node, node.tagName, node.attributes, [])\n}\n\nfunction transformElement(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n tagName: ts.JsxTagNameExpression,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n if (isFragmentTag(tagName)) return transformFragment(state, children)\n if (!ts.isIdentifier(tagName)) {\n // <Foo.Bar>、<svg:rect> 等形态此前会静默编译成无效 DOM 标签(createElement(\"Foo.Bar\"))。\n // 报结构化诊断后按原路径继续,保证产物结构稳定;compile()/Vite 插件会因 error 诊断直接失败。\n reportUnsupportedTag(state, tagName)\n }\n if (ts.isIdentifier(tagName) && tagName.text === 'ResourceBoundary') {\n return transformResourceBoundary(state, node, attributes, children)\n }\n if (ts.isIdentifier(tagName) && tagName.text === 'AsyncBoundary') {\n return transformAsyncBoundary(state, node, attributes, children)\n }\n if (ts.isIdentifier(tagName) && tagName.text === 'ErrorBoundary') {\n return transformErrorBoundary(state, node, attributes, children)\n }\n if (ts.isIdentifier(tagName) && tagName.text === 'Profiler') {\n return transformProfiler(state, node, attributes, children)\n }\n if (ts.isIdentifier(tagName) && /^[A-Z]/.test(tagName.text)) {\n const args: ts.Expression[] = [\n ts.factory.createCallExpression(helperRef(state, 'resolveComponent'), undefined, [\n tagName,\n ts.factory.createStringLiteral(state.filename),\n ts.factory.createStringLiteral(tagName.text)\n ]),\n createComponentProps(state, attributes, children)\n ]\n // 源码位置仅用于错误定位与 DevTools;生产构建可整体剔除(错误仍带组件名,定位走 source map)。\n if (state.sourceLocation) args.push(createSourceLocation(tagName))\n return ts.factory.createCallExpression(helperRef(state, 'createComponent'), undefined, args)\n }\n\n // 静态模板提升:完全静态的 DOM 子树(无事件/动态绑定/spread/property 属性)序列化为\n // 模块级模板,运行时一次 cloneNode 替代 createElement + setStaticProps + 逐子插入。\n if (isStaticElement(tagName, attributes, children)) {\n return ts.factory.createCallExpression(\n helperRef(state, 'cloneTemplate'),\n undefined,\n [registerTemplate(state, serializeStaticHtml(node))]\n )\n }\n\n const elementName = tagName.getText()\n const elementId = nextIdentifier(state, '_el')\n const statements: ts.Statement[] = [\n createConstStatement(\n state,\n elementId,\n ts.factory.createCallExpression(\n helperRef(state, 'createElement'),\n undefined,\n [ts.factory.createStringLiteral(elementName)]\n ),\n node\n )\n ]\n\n appendAttributes(state, statements, elementId, attributes)\n appendChildren(state, statements, elementId, children)\n statements.push(tagStatement(state, ts.factory.createReturnStatement(elementId), node))\n\n return ts.factory.createCallExpression(\n ts.factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n ts.factory.createBlock(statements, true)\n ),\n undefined,\n []\n )\n}\n\nfunction isFragmentTag(tagName: ts.JsxTagNameExpression): boolean {\n return tagName.getText() === 'Fragment' || tagName.getText() === 'Vobs.Fragment'\n}\n\nfunction transformFragment(state: CompileState, children: readonly ts.JsxChild[]): ts.Expression {\n const parent = nextIdentifier(state, '_fragmentParent')\n const anchor = nextIdentifier(state, '_fragmentAnchor')\n const statements: ts.Statement[] = []\n appendChildren(state, statements, parent, children, anchor)\n return ts.factory.createCallExpression(\n helperRef(state, 'createFragment'),\n undefined,\n [ts.factory.createArrowFunction(\n undefined,\n undefined,\n [\n ts.factory.createParameterDeclaration(undefined, undefined, parent),\n ts.factory.createParameterDeclaration(undefined, undefined, anchor)\n ],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n ts.factory.createBlock(statements, true)\n )]\n )\n}\n\nfunction transformResourceBoundary(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n const resource = getAttributeExpression(attributes, 'resource')\n if (!resource) throw new VobsError({ code: 'VOBS_C002', layer: 'compiler', message: 'ResourceBoundary 必须提供 resource 属性', fix: '为 ResourceBoundary 添加 resource={resource}。' })\n const options: ts.ObjectLiteralElementLike[] = [\n ts.factory.createPropertyAssignment('resource', transformEmbeddedExpression(state, resource)),\n ts.factory.createPropertyAssignment('children', createBoundaryFactory(state, children))\n ]\n appendBoundaryOptionalProperty(state, options, attributes, 'loading')\n appendBoundaryOptionalProperty(state, options, attributes, 'empty')\n appendBoundaryOptionalProperty(state, options, attributes, 'fallback')\n return createBoundaryFragment(state, node, 'insertResourceBoundary', options)\n}\n\nfunction transformErrorBoundary(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n const fallback = getAttributeExpression(attributes, 'fallback')\n if (!fallback) throw new VobsError({ code: 'VOBS_C002', layer: 'compiler', message: 'ErrorBoundary 必须提供 fallback 属性', fix: '为 ErrorBoundary 添加 fallback={(error, retry) => ...}。' })\n return createBoundaryFragment(state, node, 'insertErrorBoundary', [\n ts.factory.createPropertyAssignment('children', createBoundaryFactory(state, children)),\n ts.factory.createPropertyAssignment('fallback', transformEmbeddedExpression(state, fallback))\n ])\n}\n\nfunction transformAsyncBoundary(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n const promise = getAttributeExpression(attributes, 'promise')\n if (!promise) throw new VobsError({ code: 'VOBS_C002', layer: 'compiler', message: 'AsyncBoundary 必须提供 promise 属性', fix: '为 AsyncBoundary 添加 promise={promise}。' })\n const options: ts.ObjectLiteralElementLike[] = [\n ts.factory.createPropertyAssignment('promise', transformEmbeddedExpression(state, promise)),\n ts.factory.createPropertyAssignment('children', createAsyncFactory(state, children))\n ]\n appendBoundaryOptionalProperty(state, options, attributes, 'loading')\n appendBoundaryOptionalProperty(state, options, attributes, 'fallback')\n const resetKey = getAttributeExpression(attributes, 'resetKey')\n if (resetKey) options.push(ts.factory.createPropertyAssignment('resetKey', createGetter(resetKey)))\n return createBoundaryFragment(state, node, 'insertAsyncBoundary', options)\n}\n\nfunction transformProfiler(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n const idAttribute = attributes.properties.find(attribute => ts.isJsxAttribute(attribute) && attribute.name.getText() === 'id')\n const id = idAttribute && ts.isJsxAttribute(idAttribute) && idAttribute.initializer && ts.isStringLiteral(idAttribute.initializer)\n ? ts.factory.createStringLiteral(idAttribute.initializer.text)\n : idAttribute && ts.isJsxAttribute(idAttribute) && idAttribute.initializer && ts.isJsxExpression(idAttribute.initializer)\n ? idAttribute.initializer.expression\n : null\n if (!id) throw new VobsError({ code: 'VOBS_C002', layer: 'compiler', message: 'Profiler 必须提供 id 属性', fix: '为 Profiler 添加 id=\"ComponentName\"。' })\n const options: ts.ObjectLiteralElementLike[] = [\n ts.factory.createPropertyAssignment('id', transformEmbeddedExpression(state, id)),\n ts.factory.createPropertyAssignment('children', createBoundaryFactory(state, children))\n ]\n appendBoundaryOptionalProperty(state, options, attributes, 'onRender')\n return createBoundaryFragment(state, node, 'insertProfiler', options)\n}\n\nfunction createBoundaryFragment(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n helper: 'insertResourceBoundary' | 'insertErrorBoundary' | 'insertAsyncBoundary' | 'insertProfiler',\n options: readonly ts.ObjectLiteralElementLike[]\n): ts.Expression {\n const parent = nextIdentifier(state, '_boundaryParent')\n const anchor = nextIdentifier(state, '_boundaryAnchor')\n return ts.factory.createCallExpression(\n helperRef(state, 'createFragment'),\n undefined,\n [ts.factory.createArrowFunction(\n undefined,\n undefined,\n [\n ts.factory.createParameterDeclaration(undefined, undefined, parent),\n ts.factory.createParameterDeclaration(undefined, undefined, anchor)\n ],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n ts.factory.createBlock([callStatement(state, helper, [\n parent,\n anchor,\n ts.factory.createObjectLiteralExpression(options, true)\n ], node)], true)\n )]\n )\n}\n\nfunction createBoundaryFactory(state: CompileState, children: readonly ts.JsxChild[]): ts.ArrowFunction {\n const content = transformFragment(state, children)\n return ts.factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n content\n )\n}\n\nfunction createAsyncFactory(state: CompileState, children: readonly ts.JsxChild[]): ts.ArrowFunction {\n const value = ts.factory.createIdentifier('value')\n const expressionChild = children.length === 1 && children[0].kind === ts.SyntaxKind.JsxExpression\n ? (children[0] as ts.JsxExpression).expression\n : undefined\n if (expressionChild && ts.isArrowFunction(expressionChild)) {\n const transformed = transformEmbeddedExpression(state, expressionChild)\n return transformed as ts.ArrowFunction\n }\n const content = transformFragment(state, children)\n return ts.factory.createArrowFunction(undefined, undefined, [\n ts.factory.createParameterDeclaration(undefined, undefined, value)\n ], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), content)\n}\n\nfunction appendBoundaryOptionalProperty(\n state: CompileState,\n properties: ts.ObjectLiteralElementLike[],\n attributes: ts.JsxAttributes,\n name: string\n): void {\n const expression = getAttributeExpression(attributes, name)\n if (expression) {\n const transformed = transformEmbeddedExpression(state, expression)\n const value = isJsxExpression(unwrapExpression(expression))\n ? createGetter(transformed)\n : transformed\n properties.push(ts.factory.createPropertyAssignment(name, value))\n }\n}\n\nfunction getAttributeExpression(attributes: ts.JsxAttributes, name: string): ts.Expression | null {\n for (const attribute of attributes.properties) {\n if (!ts.isJsxAttribute(attribute) || attribute.name.getText() !== name) continue\n if (attribute.initializer && ts.isJsxExpression(attribute.initializer)) {\n return attribute.initializer.expression ?? null\n }\n }\n return null\n}\n\nfunction transformEmbeddedExpression(state: CompileState, expression: ts.Expression): ts.Expression {\n const result = ts.transform(expression, [context => root => {\n const visit: ts.Visitor = node => {\n if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) {\n return transformJsxExpression(state, node)\n }\n return ts.visitEachChild(node, visit, context)\n }\n return ts.visitNode(root, visit) as ts.Expression\n }])\n try {\n return result.transformed[0]\n } finally {\n result.dispose()\n }\n}\n\n/**\n * 静态元素判定:DOM 标签 + 全部属性为字符串字面量或无值 + 全部子节点为文本或递归静态元素。\n * 保守排除项(语义或序列化等价性无把握,走原路径):\n * - property 属性(value/checked/disabled 等):HTML attribute 与 setProperty 初始语义存在差异;\n * - 事件(on*)、ref、spread、key:本身是动态行为;\n * - 嵌套组件/Fragment/Boundary:不是纯 DOM 子树。\n */\nfunction isStaticElement(\n tagName: ts.JsxTagNameExpression,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): boolean {\n if (!ts.isIdentifier(tagName) || !/^[a-z]/.test(tagName.text)) return false\n for (const attribute of attributes.properties) {\n if (ts.isJsxSpreadAttribute(attribute)) return false\n if (!ts.isJsxAttribute(attribute)) return false\n const name = attribute.name.getText()\n if (name === 'key' || name === 'ref' || name.startsWith('on')) return false\n if (isPropertyAttribute(name)) return false\n const initializer = attribute.initializer\n if (initializer && !ts.isStringLiteral(initializer)) return false\n }\n for (const child of children) {\n if (ts.isJsxText(child)) continue\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child)) {\n const nested = ts.isJsxElement(child)\n ? { tagName: child.openingElement.tagName, attributes: child.openingElement.attributes, children: child.children }\n : { tagName: child.tagName, attributes: child.attributes, children: [] as readonly ts.JsxChild[] }\n if (!isStaticElement(nested.tagName, nested.attributes, nested.children)) return false\n continue\n }\n return false\n }\n return true\n}\n\n/** Serialize a fully-static JSX element to HTML, preserving the compiler's text normalization. */\nfunction serializeStaticHtml(node: ts.JsxElement | ts.JsxSelfClosingElement): string {\n const { tagName, attributes, children } = ts.isJsxElement(node)\n ? { tagName: node.openingElement.tagName, attributes: node.openingElement.attributes, children: node.children }\n : { tagName: node.tagName, attributes: node.attributes, children: [] as readonly ts.JsxChild[] }\n return serializeStaticElement(tagName, attributes, children)\n}\n\nfunction serializeStaticElement(\n tagName: ts.JsxTagNameExpression,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): string {\n const name = tagName.getText()\n let html = `<${name}`\n for (const attribute of attributes.properties) {\n if (!ts.isJsxAttribute(attribute)) continue\n const attributeName = attribute.name.getText() === 'className' ? 'class' : attribute.name.getText()\n const initializer = attribute.initializer\n if (!initializer) {\n html += ` ${attributeName}=\"\"`\n continue\n }\n if (ts.isStringLiteral(initializer)) {\n html += ` ${attributeName}=\"${escapeHtmlAttribute(initializer.text)}\"`\n }\n }\n html += '>'\n\n for (const child of children) {\n if (ts.isJsxText(child)) {\n // 与 appendChildren 的文本规范化保持一致,保证提升前后 DOM 文本逐字相同。\n const text = child.text.replace(/\\s+/g, ' ').trimStart()\n if (text.trim()) html += escapeHtmlText(text)\n continue\n }\n if (ts.isJsxElement(child)) {\n html += serializeStaticElement(\n child.openingElement.tagName,\n child.openingElement.attributes,\n child.children\n )\n continue\n }\n if (ts.isJsxSelfClosingElement(child)) {\n html += serializeStaticElement(child.tagName, child.attributes, [])\n }\n }\n html += `</${name}>`\n return html\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n return value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<')\n}\n\nfunction escapeHtmlText(value: string): string {\n return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')\n}\n\n/** Register a hoisted template declaration; identical HTML shares one declaration. */\nfunction registerTemplate(state: CompileState, html: string): ts.Expression {\n const existing = state.templates.get(html)\n if (existing) return existing\n const identifier = nextIdentifier(state, '_tpl')\n state.templates.set(html, identifier)\n return identifier\n}\n\nfunction createTemplateDeclarations(state: CompileState): ts.Statement[] {\n return [...state.templates.entries()].map(([html, identifier]) =>\n ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([\n ts.factory.createVariableDeclaration(identifier, undefined, undefined, ts.factory.createCallExpression(\n helperRef(state, 'createTemplate'),\n undefined,\n [ts.factory.createStringLiteral(html)]\n ))\n ], ts.NodeFlags.Const))\n )\n}\n\nfunction appendAttributes(\n state: CompileState,\n statements: ts.Statement[],\n element: ts.Identifier,\n attributes: ts.JsxAttributes\n): void {\n const staticProps: ts.ObjectLiteralElementLike[] = []\n const hasSpread = attributes.properties.some(attribute => ts.isJsxSpreadAttribute(attribute))\n for (const attribute of attributes.properties) {\n if (ts.isJsxSpreadAttribute(attribute)) {\n statements.push(callStatement(state, 'spreadProps', [element, transformEmbeddedExpression(state, attribute.expression)], attribute))\n continue\n }\n if (!ts.isJsxAttribute(attribute)) continue\n const name = attribute.name.getText()\n if (name === 'key') continue\n if (name === 'ref') {\n const initializer = attribute.initializer\n if (initializer && ts.isJsxExpression(initializer) && initializer.expression) {\n statements.push(callStatement(state, 'setRef', [element, transformEmbeddedExpression(state, initializer.expression)], attribute))\n }\n continue\n }\n const initializer = attribute.initializer\n\n if (name.startsWith('on') && initializer && ts.isJsxExpression(initializer) && initializer.expression) {\n statements.push(callStatement(state, 'addEventListener', [\n element,\n ts.factory.createStringLiteral(name.slice(2).toLowerCase()),\n initializer.expression\n ], attribute))\n continue\n }\n\n if (!initializer) {\n if (hasSpread) {\n statements.push(callStatement(state, isPropertyAttribute(name) ? 'setProperty' : 'setAttribute', [element, ts.factory.createStringLiteral(isPropertyAttribute(name) ? name : name === 'className' ? 'class' : name), isPropertyAttribute(name) ? ts.factory.createTrue() : ts.factory.createStringLiteral('')], attribute))\n continue\n }\n if (isPropertyAttribute(name)) staticProps.push(createStaticProperty(name, ts.factory.createTrue()))\n else staticProps.push(createStaticProperty(name === 'className' ? 'class' : name, ts.factory.createStringLiteral('')))\n continue\n }\n if (ts.isStringLiteral(initializer)) {\n if (hasSpread) {\n statements.push(callStatement(state, isPropertyAttribute(name) ? 'setProperty' : 'setAttribute', [element, ts.factory.createStringLiteral(isPropertyAttribute(name) ? name : name === 'className' ? 'class' : name), ts.factory.createStringLiteral(initializer.text)], attribute))\n continue\n }\n staticProps.push(createStaticProperty(isPropertyAttribute(name) ? name : name === 'className' ? 'class' : name,\n ts.factory.createStringLiteral(initializer.text)))\n continue\n }\n\n const attributeName = name === 'className' ? 'class' : name\n const propertyAttribute = isPropertyAttribute(name)\n if (ts.isJsxExpression(initializer) && initializer.expression) {\n statements.push(callStatement(state, propertyAttribute ? 'bindProperty' : 'bindAttribute', [\n element,\n ts.factory.createStringLiteral(propertyAttribute ? name : attributeName),\n createGetter(initializer.expression)\n ], attribute))\n }\n }\n if (staticProps.length) statements.splice(1, 0, callStatement(state, 'setStaticProps', [\n element,\n ts.factory.createObjectLiteralExpression(staticProps, true)\n ], attributes))\n}\n\nfunction createStaticProperty(name: string, value: ts.Expression): ts.PropertyAssignment {\n return ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(name), value)\n}\n\nfunction isPropertyAttribute(name: string): boolean {\n return name === 'value' || name === 'checked' || name === 'selected' || name === 'disabled'\n || name === 'multiple' || name === 'readOnly' || name === 'required'\n || name === 'autofocus' || name === 'hidden' || name === 'tabIndex'\n}\n\nfunction appendChildren(\n state: CompileState,\n statements: ts.Statement[],\n element: ts.Identifier,\n children: readonly ts.JsxChild[],\n anchor: ts.Expression = ts.factory.createNull()\n): void {\n for (const child of children) {\n if (ts.isJsxText(child)) {\n const text = child.text.replace(/\\s+/g, ' ').trimStart()\n if (text.trim()) {\n statements.push(callStatement(state, 'insertBefore', [\n element,\n ts.factory.createCallExpression(helperRef(state, 'createText'), undefined, [\n ts.factory.createStringLiteral(text)\n ]),\n anchor\n ], child))\n }\n continue\n }\n\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child) || ts.isJsxFragment(child)) {\n statements.push(callStatement(state, 'insertBefore', [\n element,\n transformJsxExpression(state, child),\n anchor\n ], child))\n continue\n }\n\n if (child.kind === ts.SyntaxKind.JsxExpression) {\n const expression = (child as ts.JsxExpression).expression\n if (!expression) continue\n const list = transformListExpression(state, element, expression, anchor)\n if (list) {\n statements.push(callStatement(state, 'insertList', list, child))\n continue\n }\n const dynamic = transformDynamicExpression(state, expression)\n if (dynamic) {\n statements.push(callStatement(state, 'insertDynamic', [element, anchor, dynamic], child))\n continue\n }\n if (!containsJsx(expression) && !ts.isIdentifier(expression)) {\n const textId = nextIdentifier(state, '_text')\n statements.push(createConstStatement(state, textId, ts.factory.createCallExpression(helperRef(state, 'createText'), undefined, [ts.factory.createStringLiteral('')]), child))\n statements.push(callStatement(state, 'insertBefore', [element, textId, anchor], child))\n statements.push(callStatement(state, 'bindText', [textId, createGetter(expression)], child))\n continue\n }\n const value = transformEmbeddedExpression(state, expression)\n statements.push(callStatement(state, 'insertDynamicValue', [element, anchor, createGetter(value)], child))\n }\n }\n}\n\nfunction createComponentProps(\n state: CompileState,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.ObjectLiteralExpression {\n const properties: ts.ObjectLiteralElementLike[] = []\n\n for (const attribute of attributes.properties) {\n if (ts.isJsxSpreadAttribute(attribute)) {\n properties.push(ts.factory.createSpreadAssignment(attribute.expression))\n continue\n }\n\n const name = propertyName(attribute.name.getText())\n if (attribute.name.getText() === 'key') continue\n const initializer = attribute.initializer\n if (!initializer) {\n properties.push(ts.factory.createPropertyAssignment(name, ts.factory.createTrue()))\n } else if (ts.isStringLiteral(initializer)) {\n properties.push(ts.factory.createPropertyAssignment(name, ts.factory.createStringLiteral(initializer.text)))\n } else if (ts.isJsxExpression(initializer) && initializer.expression) {\n properties.push(createGetterProperty(name, transformEmbeddedExpression(state, initializer.expression)))\n }\n }\n\n const childExpressions = children.flatMap(child => childToComponentExpression(state, child))\n if (childExpressions.length === 1) {\n properties.push(createGetterProperty('children', childExpressions[0]))\n } else if (childExpressions.length > 1) {\n properties.push(createGetterProperty('children', ts.factory.createArrayLiteralExpression(childExpressions)))\n }\n\n return ts.factory.createObjectLiteralExpression(properties, true)\n}\n\nfunction createSourceLocation(node: ts.Node): ts.ObjectLiteralExpression {\n const sourceFile = node.getSourceFile()\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile))\n return ts.factory.createObjectLiteralExpression([\n ts.factory.createPropertyAssignment('file', ts.factory.createStringLiteral(sourceFile.fileName)),\n ts.factory.createPropertyAssignment('line', ts.factory.createNumericLiteral(position.line + 1)),\n ts.factory.createPropertyAssignment('column', ts.factory.createNumericLiteral(position.character + 1))\n ], true)\n}\n\nfunction transformDynamicExpression(state: CompileState, expression: ts.Expression): ts.ArrowFunction | null {\n if (ts.isBinaryExpression(expression) && expression.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {\n const right = unwrapExpression(expression.right)\n if (!isJsxExpression(right)) return null\n return createGetter(ts.factory.createConditionalExpression(\n expression.left,\n ts.factory.createToken(ts.SyntaxKind.QuestionToken),\n transformJsxExpression(state, right),\n ts.factory.createToken(ts.SyntaxKind.ColonToken),\n ts.factory.createNull()\n ))\n }\n\n if (ts.isConditionalExpression(expression)) {\n const whenTrue = transformDynamicBranch(state, expression.whenTrue)\n const whenFalse = transformDynamicBranch(state, expression.whenFalse)\n if (!whenTrue && !whenFalse) return null\n return createGetter(ts.factory.createConditionalExpression(\n expression.condition,\n ts.factory.createToken(ts.SyntaxKind.QuestionToken),\n whenTrue ?? ts.factory.createNull(),\n ts.factory.createToken(ts.SyntaxKind.ColonToken),\n whenFalse ?? ts.factory.createNull()\n ))\n }\n\n return null\n}\n\nfunction transformDynamicBranch(state: CompileState, expression: ts.Expression): ts.Expression | null {\n const branch = unwrapExpression(expression)\n if (isJsxExpression(branch)) return transformJsxExpression(state, branch)\n if (branch.kind === ts.SyntaxKind.NullKeyword || branch.kind === ts.SyntaxKind.FalseKeyword) return branch\n return null\n}\n\nfunction transformListExpression(\n state: CompileState,\n parent: ts.Identifier,\n expression: ts.Expression,\n anchor: ts.Expression\n): ts.Expression[] | null {\n if (!ts.isCallExpression(expression) || expression.arguments.length !== 1) return null\n if (!ts.isPropertyAccessExpression(expression.expression) || expression.expression.name.text !== 'map') return null\n\n const callback = expression.arguments[0]\n if (!ts.isArrowFunction(callback) && !ts.isFunctionExpression(callback)) return null\n const body = unwrapExpression(callback.body)\n if (!isJsxExpression(body) || ts.isJsxFragment(body)) return null\n\n const key = findKeyExpression(body)\n const renderItem = transformListCallback(callback, transformJsxExpression(state, body))\n const args: ts.Expression[] = [\n parent,\n anchor,\n createGetter(expression.expression.expression),\n renderItem\n ]\n if (key) args.push(createKeyCallback(callback, key))\n return args\n}\n\nfunction transformListCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n body: ts.Expression\n): ts.Expression {\n if (ts.isArrowFunction(callback)) {\n return ts.factory.updateArrowFunction(\n callback,\n callback.modifiers,\n callback.typeParameters,\n callback.parameters,\n callback.type,\n callback.equalsGreaterThanToken,\n body\n )\n }\n\n return ts.factory.updateFunctionExpression(\n callback,\n callback.modifiers,\n callback.asteriskToken,\n callback.name,\n callback.typeParameters,\n callback.parameters,\n callback.type,\n ts.factory.createBlock([ts.factory.createReturnStatement(body)], true)\n )\n}\n\nfunction createKeyCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n key: ts.Expression\n): ts.ArrowFunction {\n return ts.factory.createArrowFunction(\n undefined,\n undefined,\n callback.parameters,\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n key\n )\n}\n\nfunction findKeyExpression(node: ts.JsxElement | ts.JsxSelfClosingElement): ts.Expression | null {\n const attributes = ts.isJsxElement(node) ? node.openingElement.attributes : node.attributes\n for (const attribute of attributes.properties) {\n if (!ts.isJsxAttribute(attribute) || attribute.name.getText() !== 'key') continue\n if (attribute.initializer && ts.isJsxExpression(attribute.initializer)) {\n return attribute.initializer.expression ?? null\n }\n }\n return null\n}\n\nfunction unwrapExpression(node: ts.Expression | ts.ConciseBody): ts.Expression {\n return ts.isParenthesizedExpression(node) ? node.expression : node as ts.Expression\n}\n\nfunction childToComponentExpression(state: CompileState, child: ts.JsxChild): ts.Expression[] {\n if (ts.isJsxText(child)) {\n const text = child.text.replace(/\\s+/g, ' ').trim()\n return text ? [ts.factory.createStringLiteral(text)] : []\n }\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child) || ts.isJsxFragment(child)) {\n return [transformJsxExpression(state, child)]\n }\n if (child.kind === ts.SyntaxKind.JsxExpression) {\n const expression = (child as ts.JsxExpression).expression\n return expression ? [transformEmbeddedExpression(state, expression)] : []\n }\n return []\n}\n\nfunction propertyName(name: string): ts.PropertyName {\n return /^[$A-Z_a-z][$\\w]*$/u.test(name)\n ? ts.factory.createIdentifier(name)\n : ts.factory.createStringLiteral(name)\n}\n\nfunction createGetter(expression: ts.Expression): ts.ArrowFunction {\n return ts.factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n expression\n )\n}\n\nfunction createGetterProperty(name: string | ts.PropertyName, expression: ts.Expression): ts.GetAccessorDeclaration {\n return ts.factory.createGetAccessorDeclaration(\n undefined,\n typeof name === 'string' ? propertyName(name) : name,\n [],\n undefined,\n ts.factory.createBlock([ts.factory.createReturnStatement(expression)], true)\n )\n}\n\nfunction callStatement(state: CompileState, name: string, args: ts.Expression[], source?: ts.Node): ts.ExpressionStatement {\n const statement = ts.factory.createExpressionStatement(\n ts.factory.createCallExpression(helperRef(state, name), undefined, args)\n )\n return source ? tagStatement(state, statement, source) : statement\n}\n\nfunction createConstStatement(state: CompileState, name: ts.Identifier, initializer: ts.Expression, source?: ts.Node): ts.VariableStatement {\n const statement = ts.factory.createVariableStatement(\n undefined,\n ts.factory.createVariableDeclarationList([\n ts.factory.createVariableDeclaration(name, undefined, undefined, initializer)\n ], ts.NodeFlags.Const)\n )\n return source ? tagStatement(state, statement, source) : statement\n}\n\n/** Record where an emitted statement originated from, for source map generation. */\nfunction tagStatement<T extends ts.Statement>(state: CompileState, statement: T, source: ts.Node): T {\n const position = positionOfNode(state, source)\n if (position) state.statementSources.set(statement, position)\n return statement\n}\n\nfunction positionOfNode(state: CompileState, node: ts.Node): SourcePosition | null {\n // ts.transform 产生的节点副本可能丢失 sourceFile 引用,回退到当前编译的源文件。\n const sourceFile = node.getSourceFile() ?? state.sourceFile\n if (!sourceFile || node.pos < 0) return null\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile))\n return { line, column: character }\n}\n\nfunction nextIdentifier(state: CompileState, prefix: string): ts.Identifier {\n let name: string\n do {\n name = `${prefix}${state.generatedId++}`\n } while (state.takenNames.has(name))\n return ts.factory.createIdentifier(name)\n}\n","import ts from 'typescript'\nimport type { CompilerPlugin } from './plugin'\n\nexport interface I18nExtractorOptions {\n readonly functions?: readonly string[]\n readonly onKey?: (key: string, filename: string) => void\n}\n\nexport interface I18nExtractor {\n readonly plugin: CompilerPlugin\n getKeys(): readonly string[]\n reset(): void\n}\n\n/** Collects statically addressable translation keys without changing emitted code. */\nexport function createI18nExtractor(options: I18nExtractorOptions = {}): I18nExtractor {\n const names = new Set(options.functions ?? ['t'])\n const keys = new Set<string>()\n const plugin: CompilerPlugin = {\n name: 'i18n-extractor',\n analyze(program, context) {\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node) && isTranslationCall(node.expression, names)) {\n const key = readStaticKey(node.arguments[0])\n if (key) {\n keys.add(key)\n options.onKey?.(key, context.filename)\n }\n }\n ts.forEachChild(node, visit)\n }\n visit(program)\n }\n }\n return {\n plugin,\n getKeys: () => [...keys].sort(),\n reset: () => keys.clear()\n }\n}\n\nfunction isTranslationCall(expression: ts.LeftHandSideExpression, names: Set<string>): boolean {\n if (ts.isIdentifier(expression)) return names.has(expression.text)\n return ts.isPropertyAccessExpression(expression) && names.has(expression.name.text)\n}\n\nfunction readStaticKey(argument: ts.Expression | undefined): string | undefined {\n if (!argument) return undefined\n if (ts.isStringLiteral(argument) || ts.isNoSubstitutionTemplateLiteral(argument)) return argument.text\n return undefined\n}\n"],"mappings":";;;;AAAA,OAAO,QAAQ;AACf,SAAS,iBAAiB;AA+CnB,SAAS,eAAe,UAA2B,CAAC,GAAiB;AAC1E,QAAM,cAAc,QAAQ,WAAW,CAAC;AAExC,SAAO;AAAA,IACL,QAAQ,MAAc,YAA4B,CAAC,GAAW;AAC5D,aAAO,QAAQ,MAAM;AAAA,QACnB,GAAG;AAAA,QACH,SAAS,CAAC,GAAG,aAAa,GAAI,UAAU,WAAW,CAAC,CAAE;AAAA,MACxD,CAAC;AAAA,IACH;AAAA,IACA,qBAAqB,MAAc,YAA4B,CAAC,GAAkB;AAChF,aAAO,qBAAqB,MAAM;AAAA,QAChC,GAAG;AAAA,QACH,SAAS,CAAC,GAAG,aAAa,GAAI,UAAU,WAAW,CAAC,CAAE;AAAA,MACxD,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAjBgB;AAmBT,SAAS,QAAQ,MAAc,UAA0B,CAAC,GAAW;AAC1E,QAAM,SAAS,qBAAqB,MAAM,OAAO;AACjD,QAAM,aAAa,OAAO,YAAY,KAAK,gBAAc,WAAW,aAAa,OAAO;AACxF,MAAI,YAAY;AACd,UAAM,IAAI,UAAU;AAAA,MAClB,MAAM,WAAW;AAAA,MACjB,OAAO;AAAA,MACP,SAAS,WAAW;AAAA,MACpB,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,MACtB,KAAK,WAAW;AAAA,IAClB,CAAC;AAAA,EACH;AACA,SAAO,OAAO;AAChB;AAdgB;AAgBT,SAAS,qBAAqB,MAAc,UAA0B,CAAC,GAAkB;AAC9F,QAAM,WAAW,QAAQ,YAAY;AACrC,MAAI,aAAa,GAAG;AAAA,IAClB;AAAA,IACA;AAAA,IACA,GAAG,aAAa;AAAA,IAChB;AAA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AIA,IAAG,gBAAgB,QAAQ,KAAKA,IAAG,gCAAgC,QAAQ,EAAG,QAAO,SAAS;AAClG,SAAO;AACT;AAJS;","names":["initializer","ts","ts"]}
|
|
1
|
+
{"version":3,"sources":["../src/compile.ts","../src/i18n-extractor.ts"],"sourcesContent":["import ts from 'typescript'\nimport { VobsError } from '@vobs/runtime/error'\nimport type {\n CompilerContext,\n CompilerOptions,\n CompilerPlugin,\n CompileOptions,\n CompileResult,\n CompilerDiagnostic,\n VobsCompiler\n} from './plugin'\n\n/**\n * 单次编译的全部可变状态。\n *\n * 此前这些字段是模块级变量,编译器因此不可重入:嵌套调用 compile()\n * (如插件内部再次编译片段)会互相污染状态。现在每次 compile 调用\n * 创建独立的 CompileState 并显式穿参,编译器对并发与嵌套完全安全。\n */\ninterface CompileState {\n /** 临时标识符计数器(_el0、_el1…)。 */\n generatedId: number\n filename: string\n /** 最初解析出的源文件。插件 program 变换后的树节点无法回溯原始位置时,用它兜底取行列。 */\n sourceFile: ts.SourceFile\n /** 生成语句 → 原始源码位置,用于 source map 生成。 */\n statementSources: WeakMap<ts.Statement, SourcePosition>\n /** 源文件中已声明的绑定名(含嵌套作用域):注入运行时 import 与生成临时变量时避开命名冲突。 */\n takenNames: Set<string>\n /** 运行时 helper 的规范名 → 产物中的引用名(无冲突时与规范名相同)。 */\n helperAliases: Map<string, string>\n /** 静态模板声明:HTML → 模块级模板变量,按内容去重,输出在 import 之后。 */\n templates: Map<string, ts.Identifier>\n /** 是否为组件调用生成源码位置(生产构建传 false 剔除,减小产物体积)。 */\n sourceLocation: boolean\n /** 从 @vobs/reactivity / @vobs/vobs 导入的 `state` 别名(含 as 别名),用于 debugName 自动推断。 */\n stateAliases: ReadonlySet<string>\n /** 非 import 的本地声明绑定名:`state` 被本地声明遮蔽时禁用 debugName 推断。 */\n localBindings: ReadonlySet<string>\n /** 编译器自身产出的诊断(如不支持的 JSX 形态),与 TypeScript 解析诊断合并返回。 */\n diagnostics: CompilerDiagnostic[]\n /** HMR 模块标识:提供后模块顶层 state() 声明包装为 hmrStateRef,跨热更新保活信号。 */\n hmrModuleId: string | null\n}\n\ninterface SourcePosition {\n readonly line: number\n readonly column: number\n}\n\nexport function createCompiler(options: CompilerOptions = {}): VobsCompiler {\n const basePlugins = options.plugins ?? []\n\n return {\n compile(code: string, overrides: CompileOptions = {}): string {\n return compile(code, {\n ...overrides,\n plugins: [...basePlugins, ...(overrides.plugins ?? [])]\n })\n },\n compileWithSourceMap(code: string, overrides: CompileOptions = {}): CompileResult {\n return compileWithSourceMap(code, {\n ...overrides,\n plugins: [...basePlugins, ...(overrides.plugins ?? [])]\n })\n }\n }\n}\n\nexport function compile(code: string, options: CompileOptions = {}): string {\n const result = compileWithSourceMap(code, options)\n const firstError = result.diagnostics.find(diagnostic => diagnostic.severity === 'error')\n if (firstError) {\n throw new VobsError({\n code: firstError.code,\n layer: 'compiler',\n message: firstError.message,\n location: firstError.location,\n codeFrame: firstError.codeFrame,\n fix: firstError.fix\n })\n }\n return result.code\n}\n\nexport function compileWithSourceMap(code: string, options: CompileOptions = {}): CompileResult {\n const filename = options.filename ?? 'component.tsx'\n let sourceFile = ts.createSourceFile(\n filename,\n code,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX\n )\n const state: CompileState = {\n generatedId: 0,\n filename,\n sourceFile,\n statementSources: new WeakMap(),\n takenNames: collectDeclaredNames(sourceFile),\n helperAliases: new Map(),\n templates: new Map(),\n sourceLocation: options.sourceLocation ?? true,\n stateAliases: collectStateAliases(sourceFile),\n localBindings: collectLocallyDeclaredNames(sourceFile),\n diagnostics: [],\n hmrModuleId: options.hmrModuleId ?? null\n }\n const cleanFilename = filename.split(/[?#]/u, 1)[0] || filename\n const diagnostics = ts.transpileModule(code, {\n // Vite appends query strings (for example `?direct`) to module IDs;\n // strip them so TypeScript still recognizes TSX syntax for diagnostics.\n fileName: cleanFilename,\n reportDiagnostics: true,\n compilerOptions: { jsx: ts.JsxEmit.Preserve, target: ts.ScriptTarget.Latest }\n }).diagnostics?.map(diagnostic => toCompilerDiagnostic(diagnostic, sourceFile, cleanFilename)) ?? []\n const plugins = options.plugins ?? []\n validatePlugins(plugins)\n\n const context: CompilerContext = {\n filename,\n factory: ts.factory,\n addRuntimeImport(name: string): void {\n resolveHelperName(state, name)\n },\n helperRef: (name: string) => helperRef(state, name)\n }\n\n for (const plugin of plugins) plugin.analyze?.(sourceFile, context)\n for (const plugin of plugins) {\n sourceFile = plugin.transform?.program?.(sourceFile, context) ?? sourceFile\n }\n for (const plugin of plugins) sourceFile = transformPluginNodes(sourceFile, plugin, context)\n\n const statements = sourceFile.statements.map(statement =>\n ts.isImportDeclaration(statement) ? rebuildImport(state, statement) : transformStatement(state, statement, true)\n )\n // 模板声明必须先于 runtime import 生成:声明里的 createTemplate 依赖\n // helperRef 注册别名,import 需要在别名全部就绪后再构建。\n const templateDeclarations = createTemplateDeclarations(state)\n let resultFile = ts.factory.updateSourceFile(sourceFile, [\n ...createRuntimeImports(state),\n ...templateDeclarations,\n ...statements\n ])\n resultFile = transformResidualJsx(state, resultFile)\n\n const generated = ts.createPrinter().printFile(resultFile)\n return {\n code: generated,\n map: buildSourceMap(state, filename, code, generated, resultFile),\n diagnostics: [...diagnostics, ...state.diagnostics]\n }\n}\n\nfunction toCompilerDiagnostic(\n diagnostic: ts.Diagnostic,\n sourceFile: ts.SourceFile,\n filename: string\n): CompilerDiagnostic {\n const start = diagnostic.start ?? 0\n const length = diagnostic.length ?? 1\n const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n const { line, column, codeFrame } = buildCodeFrame(sourceFile, start, length)\n return {\n code: `VOBS_C${String(diagnostic.code).padStart(3, '0')}`,\n severity: diagnostic.category === ts.DiagnosticCategory.Warning ? 'warning' : 'error',\n message,\n location: { file: filename, line, column },\n codeFrame\n }\n}\n\nfunction buildCodeFrame(\n sourceFile: ts.SourceFile,\n start: number,\n length: number\n): { line: number; column: number; codeFrame: string } {\n const position = sourceFile.getLineAndCharacterOfPosition(start)\n const lineText = sourceFile.text.split(/\\r?\\n/u)[position.line] ?? ''\n const markerLength = Math.max(1, Math.min(length, Math.max(1, lineText.length - position.character)))\n return {\n line: position.line + 1,\n column: position.character + 1,\n codeFrame: `${position.line + 1} | ${lineText}\\n${' '.repeat(String(position.line + 1).length + 3 + position.character)}${'^'.repeat(markerLength)}`\n }\n}\n\n/**\n * 不支持的 JSX 标签形态(成员表达式 `<Foo.Bar>`、命名空间 `<svg:rect>` 等)。\n * 诊断以 error 级返回,compile() 与 Vite 插件会直接失败,不再静默产出无效 DOM 标签。\n */\nfunction reportUnsupportedTag(state: CompileState, tagName: ts.JsxTagNameExpression): void {\n const sourceFile = tagName.getSourceFile() ?? state.sourceFile\n if (!sourceFile) return\n const label = tagName.getText()\n const kindNote = tagName.kind === ts.SyntaxKind.JsxNamespacedName ? '(JSX 命名空间标签)' : ''\n const { line, column, codeFrame } = buildCodeFrame(sourceFile, tagName.getStart(sourceFile), tagName.getWidth(sourceFile))\n state.diagnostics.push({\n code: 'VOBS_C101',\n severity: 'error',\n message: `不支持的 JSX 标签形态:<${label}>${kindNote}。组件必须是大写开头的标识符,DOM 元素必须是小写标签名。`,\n location: { file: state.filename, line, column },\n codeFrame,\n fix: `把 <${label}> 改为 <Component /> 形式的组件或小写 DOM 标签;Fragment 请使用 <Fragment> 或 <>...</>。`\n })\n}\n\ninterface MappingSegment {\n readonly genLine: number\n readonly genCol: number\n readonly srcLine: number\n readonly srcCol: number\n}\n\n/**\n * Build a real statement-level source map. The generated file is re-parsed and\n * paired structurally with the compiled tree (statements map 1:1 inside every\n * block), so each emitted statement points back to the JSX or original\n * statement it was produced from.\n */\nfunction buildSourceMap(\n state: CompileState,\n filename: string,\n source: string,\n generated: string,\n resultFile: ts.SourceFile\n): import('./plugin').VobsSourceMap {\n const reparsed = ts.createSourceFile(filename, generated, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX)\n const segments: MappingSegment[] = []\n walkPairedTrees(state, resultFile, reparsed, reparsed, segments)\n segments.sort((a, b) => a.genLine - b.genLine || a.genCol - b.genCol)\n return {\n version: 3,\n file: filename,\n sources: [filename],\n sourcesContent: [source],\n names: [],\n mappings: encodeMappings(segments, generated.split('\\n').length)\n }\n}\n\n/** Statements only nest inside these container kinds. */\nfunction statementLists(node: ts.Node): readonly ts.Statement[] | null {\n if (ts.isSourceFile(node) || ts.isBlock(node) || ts.isModuleBlock(node)) return node.statements\n if (ts.isCaseClause(node) || ts.isDefaultClause(node)) return node.statements\n return null\n}\n\n/**\n * Pair the compiled tree with the re-parsed generated tree node by node.\n * Both trees were printed from the same AST, so their shapes are identical;\n * any divergence (length mismatch) simply abandons that subtree.\n */\nfunction walkPairedTrees(\n state: CompileState,\n original: ts.Node,\n generated: ts.Node,\n reparsed: ts.SourceFile,\n segments: MappingSegment[]\n): void {\n const originalStatements = statementLists(original)\n const generatedStatements = statementLists(generated)\n if (originalStatements && generatedStatements) {\n if (originalStatements.length !== generatedStatements.length) return\n for (let index = 0; index < originalStatements.length; index++) {\n const originalStatement = originalStatements[index]\n const generatedStatement = generatedStatements[index]\n recordSegment(state, originalStatement, generatedStatement, reparsed, segments)\n walkPairedTrees(state, originalStatement, generatedStatement, reparsed, segments)\n }\n return\n }\n\n const originalChildren: ts.Node[] = []\n const generatedChildren: ts.Node[] = []\n ts.forEachChild(original, node => { originalChildren.push(node) })\n ts.forEachChild(generated, node => { generatedChildren.push(node) })\n if (originalChildren.length !== generatedChildren.length) return\n for (let index = 0; index < originalChildren.length; index++) {\n walkPairedTrees(state, originalChildren[index], generatedChildren[index], reparsed, segments)\n }\n}\n\nfunction recordSegment(\n state: CompileState,\n originalStatement: ts.Statement,\n generatedStatement: ts.Statement,\n reparsed: ts.SourceFile,\n segments: MappingSegment[]\n): void {\n const source = state.statementSources.get(originalStatement) ?? positionOfOriginalStatement(state, originalStatement)\n if (!source) return\n const position = reparsed.getLineAndCharacterOfPosition(generatedStatement.getStart(reparsed))\n segments.push({\n genLine: position.line,\n genCol: position.character,\n srcLine: source.line,\n srcCol: source.column\n })\n}\n\nfunction positionOfOriginalStatement(state: CompileState, statement: ts.Statement): SourcePosition | null {\n if (statement.pos < 0 || !state.sourceFile) return null\n const { line, character } = state.sourceFile.getLineAndCharacterOfPosition(\n statement.getStart(state.sourceFile)\n )\n return { line, column: character }\n}\n\nfunction encodeMappings(segments: readonly MappingSegment[], lineCount: number): string {\n const lines: string[][] = Array.from({ length: lineCount }, () => [])\n let prevGenLine = -1\n let prevGenCol = 0\n let prevSrcLine = 0\n let prevSrcCol = 0\n for (const segment of segments) {\n if (segment.genLine !== prevGenLine) {\n prevGenCol = 0\n prevGenLine = segment.genLine\n }\n const values = [\n segment.genCol - prevGenCol,\n 0,\n segment.srcLine - prevSrcLine,\n segment.srcCol - prevSrcCol\n ]\n lines[segment.genLine].push(values.map(encodeVlq).join(''))\n prevGenCol = segment.genCol\n prevSrcLine = segment.srcLine\n prevSrcCol = segment.srcCol\n }\n return lines.map(line => line.join(',')).join(';')\n}\n\nconst base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n\nfunction encodeVlq(value: number): string {\n let encoded = value < 0 ? ((-value) << 1) | 1 : value << 1\n let result = ''\n do {\n let digit = encoded & 31\n encoded >>>= 5\n if (encoded > 0) digit |= 32\n result += base64Chars[digit]\n } while (encoded > 0)\n return result\n}\n\nfunction validatePlugins(plugins: readonly CompilerPlugin[]): void {\n const names = new Set<string>()\n for (const plugin of plugins) {\n if (!plugin.name) throw new VobsError({ code: 'VOBS_C007', layer: 'compiler', message: '编译器插件必须提供 name', fix: '为插件添加稳定且唯一的 name。' })\n if (names.has(plugin.name)) throw new VobsError({ code: 'VOBS_C007', layer: 'compiler', message: `检测到重复插件: ${plugin.name}`, fix: '为每个编译器插件使用唯一的 name。' })\n names.add(plugin.name)\n }\n}\n\nfunction transformPluginNodes(\n sourceFile: ts.SourceFile,\n plugin: CompilerPlugin,\n context: CompilerContext\n): ts.SourceFile {\n const transformNode = plugin.transform?.node ?? plugin.transformNode\n if (!transformNode) return sourceFile\n\n const transformer: ts.TransformerFactory<ts.SourceFile> = transformContext => root => {\n const visit: ts.Visitor = node => {\n const replacement = transformNode(node, context)\n if (replacement === null) return undefined\n return ts.visitEachChild(replacement ?? node, visit, transformContext)\n }\n return ts.visitNode(root, visit) as ts.SourceFile\n }\n\n const result = ts.transform(sourceFile, [transformer])\n try {\n return result.transformed[0]\n } finally {\n result.dispose()\n }\n}\n\n/**\n * Collect every binding name declared anywhere in the source (imports, variables,\n * functions, parameters, ... including nested scopes). If a helper name is bound\n * in ANY scope, the injected runtime import must switch to an alias: generated\n * references uniformly use the alias, so user code is never captured or duplicated.\n */\nfunction collectDeclaredNames(sourceFile: ts.SourceFile): Set<string> {\n const names = new Set<string>()\n const visit = (node: ts.Node): void => {\n if (ts.isIdentifier(node) && isBindingName(node)) names.add(node.text)\n ts.forEachChild(node, visit)\n }\n visit(sourceFile)\n return names\n}\n\n/** 收集从 @vobs/reactivity / @vobs/vobs 导入的 `state` 绑定名(含 `as` 别名)。 */\nfunction collectStateAliases(sourceFile: ts.SourceFile): Set<string> {\n const aliases = new Set<string>()\n for (const statement of sourceFile.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue\n const module = statement.moduleSpecifier.text\n if (module !== '@vobs/reactivity' && module !== '@vobs/vobs') continue\n const clause = statement.importClause\n if (!clause?.namedBindings || !ts.isNamedImports(clause.namedBindings)) continue\n for (const element of clause.namedBindings.elements) {\n if (element.propertyName ? element.propertyName.text === 'state' : element.name.text === 'state') {\n aliases.add(element.name.text)\n }\n }\n }\n return aliases\n}\n\n/** 与 collectDeclaredNames 相同,但跳过 import 声明:用于判断 helper 名是否被本地声明遮蔽。 */\nfunction collectLocallyDeclaredNames(sourceFile: ts.SourceFile): Set<string> {\n const names = new Set<string>()\n const visit = (node: ts.Node): void => {\n if (ts.isImportDeclaration(node)) return\n if (ts.isIdentifier(node) && isBindingName(node)) names.add(node.text)\n ts.forEachChild(node, visit)\n }\n visit(sourceFile)\n return names\n}\n\n/** 标识符是否为某个声明的绑定名(import、变量、函数、参数、类成员等)。 */\nfunction isBindingName(node: ts.Identifier): boolean {\n const parent = node.parent\n if (!parent) return false\n // 属性访问(document.createElement)与 JSX 属性名不是绑定名\n if (ts.isPropertyAccessExpression(parent) && parent.name === node) return false\n if (ts.isQualifiedName(parent) && parent.right === node) return false\n if (ts.isJsxAttribute(parent)) return false\n return (parent as { name?: ts.Node }).name === node\n}\n\n/**\n * Resolve the reference name for a runtime helper. The plain name is kept when\n * the source never binds it; otherwise a collision-free alias is allocated and\n * the injected import uses the same alias (`import { createElement as _vobs_createElement }`).\n */\nfunction resolveHelperName(state: CompileState, name: string): string {\n const existing = state.helperAliases.get(name)\n if (existing) return existing\n let alias = name\n if (state.takenNames.has(alias)) {\n alias = `_vobs_${name}`\n let suffix = 1\n while (state.takenNames.has(alias)) alias = `_vobs_${name}_${suffix++}`\n }\n state.helperAliases.set(name, alias)\n return alias\n}\n\n/** Create a reference to a runtime helper in generated code, matching the injected import. */\nfunction helperRef(state: CompileState, name: string): ts.Identifier {\n return ts.factory.createIdentifier(resolveHelperName(state, name))\n}\n\nfunction createRuntimeImports(state: CompileState): ts.ImportDeclaration[] {\n const modules = new Map<string, ts.ImportSpecifier[]>()\n for (const [name, alias] of state.helperAliases) {\n const module = name === 'insertResourceBoundary' ? '@vobs/resource' : '@vobs/vobs'\n const imported = modules.get(module) ?? []\n imported.push(ts.factory.createImportSpecifier(\n false,\n alias === name ? undefined : ts.factory.createIdentifier(name),\n ts.factory.createIdentifier(alias)\n ))\n modules.set(module, imported)\n }\n return [...modules.entries()].map(([module, imported]) => ts.factory.createImportDeclaration(\n undefined,\n ts.factory.createImportClause(\n false,\n undefined,\n ts.factory.createNamedImports(imported)\n ),\n ts.factory.createStringLiteral(module)\n ))\n}\n\nfunction rebuildImport(state: CompileState, node: ts.ImportDeclaration): ts.ImportDeclaration {\n if (!ts.isStringLiteral(node.moduleSpecifier)) return node\n return tagStatement(state, ts.factory.createImportDeclaration(\n node.modifiers,\n node.importClause,\n ts.factory.createStringLiteral(node.moduleSpecifier.text),\n node.attributes\n ), node)\n}\n\nfunction transformStatement(state: CompileState, node: ts.Statement, moduleScope = false): ts.Statement {\n if (ts.isFunctionDeclaration(node) && node.body) {\n return tagStatement(state, ts.factory.updateFunctionDeclaration(\n node,\n node.modifiers,\n node.asteriskToken,\n node.name,\n node.typeParameters,\n node.parameters,\n node.type,\n transformBlock(state, node.body)\n ), node)\n }\n\n if (ts.isVariableStatement(node)) return transformVariableStatement(state, node, moduleScope)\n if (ts.isExportAssignment(node) && containsJsx(node.expression)) {\n return tagStatement(state, ts.factory.updateExportAssignment(node, node.modifiers, transformEmbeddedExpression(state, node.expression)), node)\n }\n if (ts.isExpressionStatement(node) && containsJsx(node.expression)) {\n return tagStatement(state, ts.factory.updateExpressionStatement(node, transformEmbeddedExpression(state, node.expression)), node)\n }\n if (ts.isReturnStatement(node) && node.expression && containsJsx(node.expression)) {\n return tagStatement(state, ts.factory.updateReturnStatement(node, transformEmbeddedExpression(state, node.expression)), node)\n }\n return node\n}\n\nfunction transformVariableStatement(state: CompileState, node: ts.VariableStatement, moduleScope = false): ts.VariableStatement {\n let changed = false\n const declarations = node.declarationList.declarations.map(declaration => {\n const initializer = declaration.initializer\n if (!initializer) return declaration\n\n let nextInitializer = inferStateDebugName(state, declaration, initializer) ?? initializer\n if (containsJsx(nextInitializer)) {\n nextInitializer = transformEmbeddedExpression(state, nextInitializer)\n } else if (moduleScope && state.hmrModuleId !== null) {\n // HMR 状态保鲜仅限模块顶层:函数内局部 state 每次调用都应创建新信号\n nextInitializer = wrapStateWithHmrRef(state, declaration, nextInitializer) ?? nextInitializer\n }\n if (nextInitializer === initializer) return declaration\n\n changed = true\n return ts.factory.updateVariableDeclaration(\n declaration,\n declaration.name,\n declaration.exclamationToken,\n declaration.type,\n nextInitializer\n )\n })\n\n if (!changed) return node\n\n return tagStatement(state, ts.factory.updateVariableStatement(\n node,\n node.modifiers,\n ts.factory.updateVariableDeclarationList(node.declarationList, declarations)\n ), node)\n}\n\n/**\n * `const name = state(initial)` 在未显式传入 debugName 时从变量名推断:\n * `const username = state('')` → `state('', 'username')`,使 DevTools 信号名称与源码命名一致。\n * 仅当 `state` 确认来自 @vobs/reactivity / @vobs/vobs、未被本地声明遮蔽、\n * 且调用只带一个参数时启用;其余形态保持原样。\n */\nfunction inferStateDebugName(\n state: CompileState,\n declaration: ts.VariableDeclaration,\n initializer: ts.Expression\n): ts.Expression | undefined {\n if (state.stateAliases.size === 0) return undefined\n if (!ts.isIdentifier(declaration.name)) return undefined\n\n let call = initializer\n while (ts.isParenthesizedExpression(call) || ts.isAsExpression(call) || ts.isTypeAssertionExpression(call) || ts.isSatisfiesExpression(call)) {\n call = call.expression\n }\n if (!ts.isCallExpression(call)) return undefined\n const callee = call.expression\n if (!ts.isIdentifier(callee) || !state.stateAliases.has(callee.text)) return undefined\n if (state.localBindings.has(callee.text)) return undefined\n if (call.arguments.length !== 1) return undefined\n\n return ts.factory.createCallExpression(callee, call.typeArguments, [\n ...call.arguments,\n ts.factory.createStringLiteral(declaration.name.text)\n ])\n}\n\n/**\n * HMR 状态保鲜:模块热更新重执行时,模块级 state() 会创建全新信号实例,与未重执行的\n * 导入方持有旧实例并存,形成\"两份状态\"(症状:编辑不生效、页面半边失灵,全量刷新也无法\n * 消除)。开启 hmrModuleId 后,模块顶层的 state 声明改经运行时注册表取值:\n * `const x = state(init)` → `const x = hmrStateRef(moduleId, 'x', () => state(init, 'x'))`。\n * 首次执行照常创建;模块重执行时直接复用既有信号,模块逻辑(副作用、导出绑定)照常重跑。\n */\nfunction wrapStateWithHmrRef(\n state: CompileState,\n declaration: ts.VariableDeclaration,\n initializer: ts.Expression\n): ts.Expression | undefined {\n let call = initializer\n while (ts.isParenthesizedExpression(call) || ts.isAsExpression(call) || ts.isTypeAssertionExpression(call) || ts.isSatisfiesExpression(call)) {\n call = call.expression\n }\n if (!ts.isCallExpression(call)) return undefined\n const callee = call.expression\n if (!ts.isIdentifier(callee) || !state.stateAliases.has(callee.text)) return undefined\n if (state.localBindings.has(callee.text)) return undefined\n if (!ts.isIdentifier(declaration.name)) return undefined\n return ts.factory.createCallExpression(helperRef(state, 'hmrStateRef'), undefined, [\n ts.factory.createStringLiteral(`${state.hmrModuleId}#${declaration.name.text}`),\n ts.factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n initializer\n )\n ])\n}\n\nfunction containsJsx(expression: ts.Expression | ts.SourceFile): boolean {\n let found = false\n const visit = (node: ts.Node): void => {\n if (isJsxExpression(node as ts.Expression)) {\n found = true\n return\n }\n ts.forEachChild(node, visit)\n }\n visit(expression)\n return found\n}\n\nfunction transformBlock(state: CompileState, block: ts.Block): ts.Block {\n const statements = block.statements.map(statement => {\n if (!ts.isReturnStatement(statement) || !statement.expression) return transformStatement(state, statement)\n const expression = ts.isParenthesizedExpression(statement.expression)\n ? statement.expression.expression\n : statement.expression\n return isJsxExpression(expression)\n ? tagStatement(state, ts.factory.updateReturnStatement(statement, transformJsxExpression(state, expression)), statement)\n : statement\n })\n return ts.factory.updateBlock(block, statements)\n}\n\nfunction isJsxExpression(node: ts.Expression): node is ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment {\n return ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)\n}\n\nfunction transformJsxExpression(state: CompileState, node: ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment): ts.Expression {\n if (ts.isJsxFragment(node)) return transformFragment(state, node.children)\n if (ts.isJsxElement(node)) {\n return transformElement(state, node, node.openingElement.tagName, node.openingElement.attributes, node.children)\n }\n return transformElement(state, node, node.tagName, node.attributes, [])\n}\n\nfunction transformElement(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n tagName: ts.JsxTagNameExpression,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n if (isFragmentTag(tagName)) return transformFragment(state, children)\n if (!ts.isIdentifier(tagName)) {\n // <Foo.Bar>、<svg:rect> 等形态此前会静默编译成无效 DOM 标签(createElement(\"Foo.Bar\"))。\n // 报结构化诊断后按原路径继续,保证产物结构稳定;compile()/Vite 插件会因 error 诊断直接失败。\n reportUnsupportedTag(state, tagName)\n }\n if (ts.isIdentifier(tagName) && tagName.text === 'ResourceBoundary') {\n return transformResourceBoundary(state, node, attributes, children)\n }\n if (ts.isIdentifier(tagName) && tagName.text === 'AsyncBoundary') {\n return transformAsyncBoundary(state, node, attributes, children)\n }\n if (ts.isIdentifier(tagName) && tagName.text === 'ErrorBoundary') {\n return transformErrorBoundary(state, node, attributes, children)\n }\n if (ts.isIdentifier(tagName) && tagName.text === 'Profiler') {\n return transformProfiler(state, node, attributes, children)\n }\n if (ts.isIdentifier(tagName) && /^[A-Z]/.test(tagName.text)) {\n const args: ts.Expression[] = [\n ts.factory.createCallExpression(helperRef(state, 'resolveComponent'), undefined, [\n tagName,\n ts.factory.createStringLiteral(state.filename),\n ts.factory.createStringLiteral(tagName.text)\n ]),\n createComponentProps(state, attributes, children)\n ]\n // 源码位置仅用于错误定位与 DevTools;生产构建可整体剔除(错误仍带组件名,定位走 source map)。\n if (state.sourceLocation) args.push(createSourceLocation(tagName))\n return ts.factory.createCallExpression(helperRef(state, 'createComponent'), undefined, args)\n }\n\n // 静态模板提升:完全静态的 DOM 子树(无事件/动态绑定/spread/property 属性)序列化为\n // 模块级模板,运行时一次 cloneNode 替代 createElement + setStaticProps + 逐子插入。\n if (isStaticElement(tagName, attributes, children)) {\n return ts.factory.createCallExpression(\n helperRef(state, 'cloneTemplate'),\n undefined,\n [registerTemplate(state, serializeStaticHtml(node))]\n )\n }\n\n const elementName = tagName.getText()\n const elementId = nextIdentifier(state, '_el')\n const statements: ts.Statement[] = [\n createConstStatement(\n state,\n elementId,\n ts.factory.createCallExpression(\n helperRef(state, 'createElement'),\n undefined,\n [ts.factory.createStringLiteral(elementName)]\n ),\n node\n )\n ]\n\n appendAttributes(state, statements, elementId, attributes)\n appendChildren(state, statements, elementId, children)\n statements.push(tagStatement(state, ts.factory.createReturnStatement(elementId), node))\n\n return ts.factory.createCallExpression(\n ts.factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n ts.factory.createBlock(statements, true)\n ),\n undefined,\n []\n )\n}\n\nfunction isFragmentTag(tagName: ts.JsxTagNameExpression): boolean {\n return tagName.getText() === 'Fragment' || tagName.getText() === 'Vobs.Fragment'\n}\n\nfunction transformFragment(state: CompileState, children: readonly ts.JsxChild[]): ts.Expression {\n const parent = nextIdentifier(state, '_fragmentParent')\n const anchor = nextIdentifier(state, '_fragmentAnchor')\n const statements: ts.Statement[] = []\n appendChildren(state, statements, parent, children, anchor)\n return ts.factory.createCallExpression(\n helperRef(state, 'createFragment'),\n undefined,\n [ts.factory.createArrowFunction(\n undefined,\n undefined,\n [\n ts.factory.createParameterDeclaration(undefined, undefined, parent),\n ts.factory.createParameterDeclaration(undefined, undefined, anchor)\n ],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n ts.factory.createBlock(statements, true)\n )]\n )\n}\n\nfunction transformResourceBoundary(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n const resource = getAttributeExpression(attributes, 'resource')\n if (!resource) throw new VobsError({ code: 'VOBS_C002', layer: 'compiler', message: 'ResourceBoundary 必须提供 resource 属性', fix: '为 ResourceBoundary 添加 resource={resource}。' })\n const options: ts.ObjectLiteralElementLike[] = [\n ts.factory.createPropertyAssignment('resource', transformEmbeddedExpression(state, resource)),\n ts.factory.createPropertyAssignment('children', createBoundaryFactory(state, children))\n ]\n appendBoundaryOptionalProperty(state, options, attributes, 'loading')\n appendBoundaryOptionalProperty(state, options, attributes, 'empty')\n appendBoundaryOptionalProperty(state, options, attributes, 'fallback')\n return createBoundaryFragment(state, node, 'insertResourceBoundary', options)\n}\n\nfunction transformErrorBoundary(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n const fallback = getAttributeExpression(attributes, 'fallback')\n if (!fallback) throw new VobsError({ code: 'VOBS_C002', layer: 'compiler', message: 'ErrorBoundary 必须提供 fallback 属性', fix: '为 ErrorBoundary 添加 fallback={(error, retry) => ...}。' })\n return createBoundaryFragment(state, node, 'insertErrorBoundary', [\n ts.factory.createPropertyAssignment('children', createBoundaryFactory(state, children)),\n ts.factory.createPropertyAssignment('fallback', transformEmbeddedExpression(state, fallback))\n ])\n}\n\nfunction transformAsyncBoundary(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n const promise = getAttributeExpression(attributes, 'promise')\n if (!promise) throw new VobsError({ code: 'VOBS_C002', layer: 'compiler', message: 'AsyncBoundary 必须提供 promise 属性', fix: '为 AsyncBoundary 添加 promise={promise}。' })\n const options: ts.ObjectLiteralElementLike[] = [\n ts.factory.createPropertyAssignment('promise', transformEmbeddedExpression(state, promise)),\n ts.factory.createPropertyAssignment('children', createAsyncFactory(state, children))\n ]\n appendBoundaryOptionalProperty(state, options, attributes, 'loading')\n appendBoundaryOptionalProperty(state, options, attributes, 'fallback')\n const resetKey = getAttributeExpression(attributes, 'resetKey')\n if (resetKey) options.push(ts.factory.createPropertyAssignment('resetKey', createGetter(resetKey)))\n return createBoundaryFragment(state, node, 'insertAsyncBoundary', options)\n}\n\nfunction transformProfiler(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.Expression {\n const idAttribute = attributes.properties.find(attribute => ts.isJsxAttribute(attribute) && attribute.name.getText() === 'id')\n const id = idAttribute && ts.isJsxAttribute(idAttribute) && idAttribute.initializer && ts.isStringLiteral(idAttribute.initializer)\n ? ts.factory.createStringLiteral(idAttribute.initializer.text)\n : idAttribute && ts.isJsxAttribute(idAttribute) && idAttribute.initializer && ts.isJsxExpression(idAttribute.initializer)\n ? idAttribute.initializer.expression\n : null\n if (!id) throw new VobsError({ code: 'VOBS_C002', layer: 'compiler', message: 'Profiler 必须提供 id 属性', fix: '为 Profiler 添加 id=\"ComponentName\"。' })\n const options: ts.ObjectLiteralElementLike[] = [\n ts.factory.createPropertyAssignment('id', transformEmbeddedExpression(state, id)),\n ts.factory.createPropertyAssignment('children', createBoundaryFactory(state, children))\n ]\n appendBoundaryOptionalProperty(state, options, attributes, 'onRender')\n return createBoundaryFragment(state, node, 'insertProfiler', options)\n}\n\nfunction createBoundaryFragment(\n state: CompileState,\n node: ts.JsxElement | ts.JsxSelfClosingElement,\n helper: 'insertResourceBoundary' | 'insertErrorBoundary' | 'insertAsyncBoundary' | 'insertProfiler',\n options: readonly ts.ObjectLiteralElementLike[]\n): ts.Expression {\n const parent = nextIdentifier(state, '_boundaryParent')\n const anchor = nextIdentifier(state, '_boundaryAnchor')\n return ts.factory.createCallExpression(\n helperRef(state, 'createFragment'),\n undefined,\n [ts.factory.createArrowFunction(\n undefined,\n undefined,\n [\n ts.factory.createParameterDeclaration(undefined, undefined, parent),\n ts.factory.createParameterDeclaration(undefined, undefined, anchor)\n ],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n ts.factory.createBlock([callStatement(state, helper, [\n parent,\n anchor,\n ts.factory.createObjectLiteralExpression(options, true)\n ], node)], true)\n )]\n )\n}\n\nfunction createBoundaryFactory(state: CompileState, children: readonly ts.JsxChild[]): ts.ArrowFunction {\n const content = transformFragment(state, children)\n return ts.factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n content\n )\n}\n\nfunction createAsyncFactory(state: CompileState, children: readonly ts.JsxChild[]): ts.ArrowFunction {\n const value = ts.factory.createIdentifier('value')\n const expressionChild = children.length === 1 && children[0].kind === ts.SyntaxKind.JsxExpression\n ? (children[0] as ts.JsxExpression).expression\n : undefined\n if (expressionChild && ts.isArrowFunction(expressionChild)) {\n const transformed = transformEmbeddedExpression(state, expressionChild)\n return transformed as ts.ArrowFunction\n }\n const content = transformFragment(state, children)\n return ts.factory.createArrowFunction(undefined, undefined, [\n ts.factory.createParameterDeclaration(undefined, undefined, value)\n ], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), content)\n}\n\nfunction appendBoundaryOptionalProperty(\n state: CompileState,\n properties: ts.ObjectLiteralElementLike[],\n attributes: ts.JsxAttributes,\n name: string\n): void {\n const expression = getAttributeExpression(attributes, name)\n if (expression) {\n const transformed = transformEmbeddedExpression(state, expression)\n const value = isJsxExpression(unwrapExpression(expression))\n ? createGetter(transformed)\n : transformed\n properties.push(ts.factory.createPropertyAssignment(name, value))\n }\n}\n\nfunction getAttributeExpression(attributes: ts.JsxAttributes, name: string): ts.Expression | null {\n for (const attribute of attributes.properties) {\n if (!ts.isJsxAttribute(attribute) || attribute.name.getText() !== name) continue\n if (attribute.initializer && ts.isJsxExpression(attribute.initializer)) {\n return attribute.initializer.expression ?? null\n }\n }\n return null\n}\n\nfunction transformEmbeddedExpression(state: CompileState, expression: ts.Expression): ts.Expression {\n const result = ts.transform(expression, [context => root => {\n const visit: ts.Visitor = node => {\n if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) {\n return transformJsxExpression(state, node)\n }\n return ts.visitEachChild(node, visit, context)\n }\n return ts.visitNode(root, visit) as ts.Expression\n }])\n try {\n return result.transformed[0]\n } finally {\n result.dispose()\n }\n}\n\n\nfunction transformResidualJsx(state: CompileState, sourceFile: ts.SourceFile): ts.SourceFile {\n if (!containsJsx(sourceFile)) return sourceFile\n const result = ts.transform(sourceFile, [context => root => {\n const visit: ts.Visitor = node => {\n if (ts.isReturnStatement(node) && node.expression && containsJsx(node.expression)) {\n return ts.factory.updateReturnStatement(node, transformEmbeddedExpression(state, node.expression))\n }\n if (isJsxExpression(node as ts.Expression)) {\n return transformJsxExpression(state, node as ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment)\n }\n return ts.visitEachChild(node, visit, context)\n }\n return ts.visitNode(root, visit) as ts.SourceFile\n }])\n try {\n return result.transformed[0]\n } finally {\n result.dispose()\n }\n}\n\n/**\n * 静态元素判定:DOM 标签 + 全部属性为字符串字面量或无值 + 全部子节点为文本或递归静态元素。\n * 保守排除项(语义或序列化等价性无把握,走原路径):\n * - property 属性(value/checked/disabled 等):HTML attribute 与 setProperty 初始语义存在差异;\n * - 事件(on*)、ref、spread、key:本身是动态行为;\n * - 嵌套组件/Fragment/Boundary:不是纯 DOM 子树。\n */\nfunction isStaticElement(\n tagName: ts.JsxTagNameExpression,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): boolean {\n if (!ts.isIdentifier(tagName) || !/^[a-z]/.test(tagName.text)) return false\n for (const attribute of attributes.properties) {\n if (ts.isJsxSpreadAttribute(attribute)) return false\n if (!ts.isJsxAttribute(attribute)) return false\n const name = attribute.name.getText()\n if (name === 'key' || name === 'ref' || name.startsWith('on')) return false\n if (isPropertyAttribute(name)) return false\n const initializer = attribute.initializer\n if (initializer && !ts.isStringLiteral(initializer)) return false\n }\n for (const child of children) {\n if (ts.isJsxText(child)) continue\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child)) {\n const nested = ts.isJsxElement(child)\n ? { tagName: child.openingElement.tagName, attributes: child.openingElement.attributes, children: child.children }\n : { tagName: child.tagName, attributes: child.attributes, children: [] as readonly ts.JsxChild[] }\n if (!isStaticElement(nested.tagName, nested.attributes, nested.children)) return false\n continue\n }\n return false\n }\n return true\n}\n\n/** Serialize a fully-static JSX element to HTML, preserving the compiler's text normalization. */\nfunction serializeStaticHtml(node: ts.JsxElement | ts.JsxSelfClosingElement): string {\n const { tagName, attributes, children } = ts.isJsxElement(node)\n ? { tagName: node.openingElement.tagName, attributes: node.openingElement.attributes, children: node.children }\n : { tagName: node.tagName, attributes: node.attributes, children: [] as readonly ts.JsxChild[] }\n return serializeStaticElement(tagName, attributes, children)\n}\n\nfunction serializeStaticElement(\n tagName: ts.JsxTagNameExpression,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): string {\n const name = tagName.getText()\n let html = `<${name}`\n for (const attribute of attributes.properties) {\n if (!ts.isJsxAttribute(attribute)) continue\n const attributeName = attribute.name.getText() === 'className' ? 'class' : attribute.name.getText()\n const initializer = attribute.initializer\n if (!initializer) {\n html += ` ${attributeName}=\"\"`\n continue\n }\n if (ts.isStringLiteral(initializer)) {\n html += ` ${attributeName}=\"${escapeHtmlAttribute(initializer.text)}\"`\n }\n }\n html += '>'\n\n for (const child of children) {\n if (ts.isJsxText(child)) {\n // 与 appendChildren 的文本规范化保持一致,保证提升前后 DOM 文本逐字相同。\n const text = child.text.replace(/\\s+/g, ' ').trimStart()\n if (text.trim()) html += escapeHtmlText(text)\n continue\n }\n if (ts.isJsxElement(child)) {\n html += serializeStaticElement(\n child.openingElement.tagName,\n child.openingElement.attributes,\n child.children\n )\n continue\n }\n if (ts.isJsxSelfClosingElement(child)) {\n html += serializeStaticElement(child.tagName, child.attributes, [])\n }\n }\n html += `</${name}>`\n return html\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n return value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<')\n}\n\nfunction escapeHtmlText(value: string): string {\n return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')\n}\n\n/** Register a hoisted template declaration; identical HTML shares one declaration. */\nfunction registerTemplate(state: CompileState, html: string): ts.Expression {\n const existing = state.templates.get(html)\n if (existing) return existing\n const identifier = nextIdentifier(state, '_tpl')\n state.templates.set(html, identifier)\n return identifier\n}\n\nfunction createTemplateDeclarations(state: CompileState): ts.Statement[] {\n return [...state.templates.entries()].map(([html, identifier]) =>\n ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([\n ts.factory.createVariableDeclaration(identifier, undefined, undefined, ts.factory.createCallExpression(\n helperRef(state, 'createTemplate'),\n undefined,\n [ts.factory.createStringLiteral(html)]\n ))\n ], ts.NodeFlags.Const))\n )\n}\n\nfunction appendAttributes(\n state: CompileState,\n statements: ts.Statement[],\n element: ts.Identifier,\n attributes: ts.JsxAttributes\n): void {\n const staticProps: ts.ObjectLiteralElementLike[] = []\n const hasSpread = attributes.properties.some(attribute => ts.isJsxSpreadAttribute(attribute))\n for (const attribute of attributes.properties) {\n if (ts.isJsxSpreadAttribute(attribute)) {\n statements.push(callStatement(state, 'spreadProps', [element, transformEmbeddedExpression(state, attribute.expression)], attribute))\n continue\n }\n if (!ts.isJsxAttribute(attribute)) continue\n const name = attribute.name.getText()\n if (name === 'key') continue\n if (name === 'ref') {\n const initializer = attribute.initializer\n if (initializer && ts.isJsxExpression(initializer) && initializer.expression) {\n statements.push(callStatement(state, 'setRef', [element, transformEmbeddedExpression(state, initializer.expression)], attribute))\n }\n continue\n }\n const initializer = attribute.initializer\n\n if (name.startsWith('on') && initializer && ts.isJsxExpression(initializer) && initializer.expression) {\n statements.push(callStatement(state, 'addEventListener', [\n element,\n ts.factory.createStringLiteral(name.slice(2).toLowerCase()),\n initializer.expression\n ], attribute))\n continue\n }\n\n if (!initializer) {\n if (hasSpread) {\n statements.push(callStatement(state, isPropertyAttribute(name) ? 'setProperty' : 'setAttribute', [element, ts.factory.createStringLiteral(isPropertyAttribute(name) ? name : name === 'className' ? 'class' : name), isPropertyAttribute(name) ? ts.factory.createTrue() : ts.factory.createStringLiteral('')], attribute))\n continue\n }\n if (isPropertyAttribute(name)) staticProps.push(createStaticProperty(name, ts.factory.createTrue()))\n else staticProps.push(createStaticProperty(name === 'className' ? 'class' : name, ts.factory.createStringLiteral('')))\n continue\n }\n if (ts.isStringLiteral(initializer)) {\n if (hasSpread) {\n statements.push(callStatement(state, isPropertyAttribute(name) ? 'setProperty' : 'setAttribute', [element, ts.factory.createStringLiteral(isPropertyAttribute(name) ? name : name === 'className' ? 'class' : name), ts.factory.createStringLiteral(initializer.text)], attribute))\n continue\n }\n staticProps.push(createStaticProperty(isPropertyAttribute(name) ? name : name === 'className' ? 'class' : name,\n ts.factory.createStringLiteral(initializer.text)))\n continue\n }\n\n const attributeName = name === 'className' ? 'class' : name\n const propertyAttribute = isPropertyAttribute(name)\n if (ts.isJsxExpression(initializer) && initializer.expression) {\n statements.push(callStatement(state, propertyAttribute ? 'bindProperty' : 'bindAttribute', [\n element,\n ts.factory.createStringLiteral(propertyAttribute ? name : attributeName),\n createGetter(initializer.expression)\n ], attribute))\n }\n }\n if (staticProps.length) statements.splice(1, 0, callStatement(state, 'setStaticProps', [\n element,\n ts.factory.createObjectLiteralExpression(staticProps, true)\n ], attributes))\n}\n\nfunction createStaticProperty(name: string, value: ts.Expression): ts.PropertyAssignment {\n return ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(name), value)\n}\n\nfunction isPropertyAttribute(name: string): boolean {\n return name === 'value' || name === 'checked' || name === 'selected' || name === 'disabled'\n || name === 'multiple' || name === 'readOnly' || name === 'required'\n || name === 'autofocus' || name === 'hidden' || name === 'tabIndex'\n}\n\nfunction appendChildren(\n state: CompileState,\n statements: ts.Statement[],\n element: ts.Identifier,\n children: readonly ts.JsxChild[],\n anchor: ts.Expression = ts.factory.createNull()\n): void {\n for (const child of children) {\n if (ts.isJsxText(child)) {\n const text = child.text.replace(/\\s+/g, ' ').trimStart()\n if (text.trim()) {\n statements.push(callStatement(state, 'insertBefore', [\n element,\n ts.factory.createCallExpression(helperRef(state, 'createText'), undefined, [\n ts.factory.createStringLiteral(text)\n ]),\n anchor\n ], child))\n }\n continue\n }\n\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child) || ts.isJsxFragment(child)) {\n statements.push(callStatement(state, 'insertBefore', [\n element,\n transformJsxExpression(state, child),\n anchor\n ], child))\n continue\n }\n\n if (child.kind === ts.SyntaxKind.JsxExpression) {\n const expression = (child as ts.JsxExpression).expression\n if (!expression) continue\n const list = transformListExpression(state, element, expression, anchor)\n if (list) {\n statements.push(callStatement(state, 'insertList', list, child))\n continue\n }\n const dynamic = transformDynamicExpression(state, expression)\n if (dynamic) {\n statements.push(callStatement(state, 'insertDynamic', [element, anchor, dynamic], child))\n continue\n }\n if (!containsJsx(expression) && !ts.isIdentifier(expression)) {\n const textId = nextIdentifier(state, '_text')\n statements.push(createConstStatement(state, textId, ts.factory.createCallExpression(helperRef(state, 'createText'), undefined, [ts.factory.createStringLiteral('')]), child))\n statements.push(callStatement(state, 'insertBefore', [element, textId, anchor], child))\n statements.push(callStatement(state, 'bindText', [textId, createGetter(expression)], child))\n continue\n }\n const value = transformEmbeddedExpression(state, expression)\n statements.push(callStatement(state, 'insertDynamicValue', [element, anchor, createGetter(value)], child))\n }\n }\n}\n\nfunction createComponentProps(\n state: CompileState,\n attributes: ts.JsxAttributes,\n children: readonly ts.JsxChild[]\n): ts.ObjectLiteralExpression {\n const properties: ts.ObjectLiteralElementLike[] = []\n\n for (const attribute of attributes.properties) {\n if (ts.isJsxSpreadAttribute(attribute)) {\n properties.push(ts.factory.createSpreadAssignment(attribute.expression))\n continue\n }\n\n const name = propertyName(attribute.name.getText())\n if (attribute.name.getText() === 'key') continue\n const initializer = attribute.initializer\n if (!initializer) {\n properties.push(ts.factory.createPropertyAssignment(name, ts.factory.createTrue()))\n } else if (ts.isStringLiteral(initializer)) {\n properties.push(ts.factory.createPropertyAssignment(name, ts.factory.createStringLiteral(initializer.text)))\n } else if (ts.isJsxExpression(initializer) && initializer.expression) {\n properties.push(createGetterProperty(name, transformEmbeddedExpression(state, initializer.expression)))\n }\n }\n\n const childExpressions = children.flatMap(child => childToComponentExpression(state, child))\n if (childExpressions.length === 1) {\n properties.push(createGetterProperty('children', childExpressions[0]))\n } else if (childExpressions.length > 1) {\n properties.push(createGetterProperty('children', ts.factory.createArrayLiteralExpression(childExpressions)))\n }\n\n return ts.factory.createObjectLiteralExpression(properties, true)\n}\n\nfunction createSourceLocation(node: ts.Node): ts.ObjectLiteralExpression {\n const sourceFile = node.getSourceFile()\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile))\n return ts.factory.createObjectLiteralExpression([\n ts.factory.createPropertyAssignment('file', ts.factory.createStringLiteral(sourceFile.fileName)),\n ts.factory.createPropertyAssignment('line', ts.factory.createNumericLiteral(position.line + 1)),\n ts.factory.createPropertyAssignment('column', ts.factory.createNumericLiteral(position.character + 1))\n ], true)\n}\n\nfunction transformDynamicExpression(state: CompileState, expression: ts.Expression): ts.ArrowFunction | null {\n const converted = convertDynamicNodeExpression(state, expression)\n return converted ? createGetter(converted) : null\n}\n\n/**\n * 把产出节点的动态表达式(`cond ? <A/> : <B/>`、`cond && <A/>`,含任意嵌套组合)\n * 转换为条件表达式树;各分支中的 JSX 递归编译为节点工厂,由 insertDynamic 挂载/卸载。\n * 返回 null 表示没有任何分支产出节点(纯文本/数值场景走 insertDynamicValue 文本绑定)。\n */\nfunction convertDynamicNodeExpression(state: CompileState, expression: ts.Expression): ts.ConditionalExpression | null {\n if (ts.isBinaryExpression(expression) && expression.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {\n const right = unwrapExpression(expression.right)\n if (isJsxExpression(right)) {\n return createNodeConditional(expression.left, transformJsxExpression(state, right), null)\n }\n // 右侧是嵌套的动态节点表达式(如 cond && (sub ? <A/> : <B/>))时递归转换,\n // 转换失败(纯文本分支)则整体回落为动态值绑定,保持语义可静态判定。\n const convertedRight = convertDynamicNodeExpression(state, right)\n if (convertedRight) return createNodeConditional(expression.left, convertedRight, null)\n return null\n }\n\n if (ts.isConditionalExpression(expression)) {\n const whenTrue = transformDynamicBranch(state, expression.whenTrue)\n const whenFalse = transformDynamicBranch(state, expression.whenFalse)\n if (!whenTrue && !whenFalse) return null\n return ts.factory.createConditionalExpression(\n expression.condition,\n ts.factory.createToken(ts.SyntaxKind.QuestionToken),\n whenTrue ?? ts.factory.createNull(),\n ts.factory.createToken(ts.SyntaxKind.ColonToken),\n whenFalse ?? ts.factory.createNull()\n )\n }\n\n return null\n}\n\nfunction createNodeConditional(\n condition: ts.Expression,\n whenTrue: ts.Expression,\n whenFalse: ts.Expression | null\n): ts.ConditionalExpression {\n return ts.factory.createConditionalExpression(\n condition,\n ts.factory.createToken(ts.SyntaxKind.QuestionToken),\n whenTrue,\n ts.factory.createToken(ts.SyntaxKind.ColonToken),\n whenFalse ?? ts.factory.createNull()\n )\n}\n\n/**\n * 转换单个分支:JSX → 节点工厂;null/false 原样保留;嵌套的三元与 `&&`\n * 动态节点表达式递归转换(此前嵌套三元只编译第一个分支,其余分支被静默丢弃)。\n * 其余表达式(字符串、数值等)返回 null,由调用方回落为 null 分支。\n */\nfunction transformDynamicBranch(state: CompileState, expression: ts.Expression): ts.Expression | null {\n const branch = unwrapExpression(expression)\n if (isJsxExpression(branch)) return transformJsxExpression(state, branch)\n if (branch.kind === ts.SyntaxKind.NullKeyword || branch.kind === ts.SyntaxKind.FalseKeyword) return branch\n if (ts.isConditionalExpression(branch)\n || (ts.isBinaryExpression(branch) && branch.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken)) {\n return convertDynamicNodeExpression(state, branch)\n }\n return null\n}\n\nfunction transformListExpression(\n state: CompileState,\n parent: ts.Identifier,\n expression: ts.Expression,\n anchor: ts.Expression\n): ts.Expression[] | null {\n if (!ts.isCallExpression(expression) || expression.arguments.length !== 1) return null\n if (!ts.isPropertyAccessExpression(expression.expression) || expression.expression.name.text !== 'map') return null\n\n const callback = expression.arguments[0]\n if (!ts.isArrowFunction(callback) && !ts.isFunctionExpression(callback)) return null\n const body = unwrapExpression(callback.body)\n if (!isJsxExpression(body) || ts.isJsxFragment(body)) return null\n\n const key = findKeyExpression(body)\n const renderItem = transformListCallback(callback, transformJsxExpression(state, body))\n const args: ts.Expression[] = [\n parent,\n anchor,\n createGetter(expression.expression.expression),\n renderItem\n ]\n if (key) args.push(createKeyCallback(callback, key))\n return args\n}\n\nfunction transformListCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n body: ts.Expression\n): ts.Expression {\n if (ts.isArrowFunction(callback)) {\n return ts.factory.updateArrowFunction(\n callback,\n callback.modifiers,\n callback.typeParameters,\n callback.parameters,\n callback.type,\n callback.equalsGreaterThanToken,\n body\n )\n }\n\n return ts.factory.updateFunctionExpression(\n callback,\n callback.modifiers,\n callback.asteriskToken,\n callback.name,\n callback.typeParameters,\n callback.parameters,\n callback.type,\n ts.factory.createBlock([ts.factory.createReturnStatement(body)], true)\n )\n}\n\nfunction createKeyCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n key: ts.Expression\n): ts.ArrowFunction {\n return ts.factory.createArrowFunction(\n undefined,\n undefined,\n callback.parameters,\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n key\n )\n}\n\nfunction findKeyExpression(node: ts.JsxElement | ts.JsxSelfClosingElement): ts.Expression | null {\n const attributes = ts.isJsxElement(node) ? node.openingElement.attributes : node.attributes\n for (const attribute of attributes.properties) {\n if (!ts.isJsxAttribute(attribute) || attribute.name.getText() !== 'key') continue\n if (attribute.initializer && ts.isJsxExpression(attribute.initializer)) {\n return attribute.initializer.expression ?? null\n }\n }\n return null\n}\n\nfunction unwrapExpression(node: ts.Expression | ts.ConciseBody): ts.Expression {\n return ts.isParenthesizedExpression(node) ? node.expression : node as ts.Expression\n}\n\nfunction childToComponentExpression(state: CompileState, child: ts.JsxChild): ts.Expression[] {\n if (ts.isJsxText(child)) {\n const text = child.text.replace(/\\s+/g, ' ').trim()\n return text ? [ts.factory.createStringLiteral(text)] : []\n }\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child) || ts.isJsxFragment(child)) {\n return [transformJsxExpression(state, child)]\n }\n if (child.kind === ts.SyntaxKind.JsxExpression) {\n const expression = (child as ts.JsxExpression).expression\n return expression ? [transformEmbeddedExpression(state, expression)] : []\n }\n return []\n}\n\nfunction propertyName(name: string): ts.PropertyName {\n return /^[$A-Z_a-z][$\\w]*$/u.test(name)\n ? ts.factory.createIdentifier(name)\n : ts.factory.createStringLiteral(name)\n}\n\nfunction createGetter(expression: ts.Expression): ts.ArrowFunction {\n return ts.factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n expression\n )\n}\n\nfunction createGetterProperty(name: string | ts.PropertyName, expression: ts.Expression): ts.GetAccessorDeclaration {\n return ts.factory.createGetAccessorDeclaration(\n undefined,\n typeof name === 'string' ? propertyName(name) : name,\n [],\n undefined,\n ts.factory.createBlock([ts.factory.createReturnStatement(expression)], true)\n )\n}\n\nfunction callStatement(state: CompileState, name: string, args: ts.Expression[], source?: ts.Node): ts.ExpressionStatement {\n const statement = ts.factory.createExpressionStatement(\n ts.factory.createCallExpression(helperRef(state, name), undefined, args)\n )\n return source ? tagStatement(state, statement, source) : statement\n}\n\nfunction createConstStatement(state: CompileState, name: ts.Identifier, initializer: ts.Expression, source?: ts.Node): ts.VariableStatement {\n const statement = ts.factory.createVariableStatement(\n undefined,\n ts.factory.createVariableDeclarationList([\n ts.factory.createVariableDeclaration(name, undefined, undefined, initializer)\n ], ts.NodeFlags.Const)\n )\n return source ? tagStatement(state, statement, source) : statement\n}\n\n/** Record where an emitted statement originated from, for source map generation. */\nfunction tagStatement<T extends ts.Statement>(state: CompileState, statement: T, source: ts.Node): T {\n const position = positionOfNode(state, source)\n if (position) state.statementSources.set(statement, position)\n return statement\n}\n\nfunction positionOfNode(state: CompileState, node: ts.Node): SourcePosition | null {\n // ts.transform 产生的节点副本可能丢失 sourceFile 引用,回退到当前编译的源文件。\n const sourceFile = node.getSourceFile() ?? state.sourceFile\n if (!sourceFile || node.pos < 0) return null\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile))\n return { line, column: character }\n}\n\nfunction nextIdentifier(state: CompileState, prefix: string): ts.Identifier {\n let name: string\n do {\n name = `${prefix}${state.generatedId++}`\n } while (state.takenNames.has(name))\n return ts.factory.createIdentifier(name)\n}\n","import ts from 'typescript'\nimport type { CompilerPlugin } from './plugin'\n\nexport interface I18nExtractorOptions {\n readonly functions?: readonly string[]\n readonly onKey?: (key: string, filename: string) => void\n}\n\nexport interface I18nExtractor {\n readonly plugin: CompilerPlugin\n getKeys(): readonly string[]\n reset(): void\n}\n\n/** Collects statically addressable translation keys without changing emitted code. */\nexport function createI18nExtractor(options: I18nExtractorOptions = {}): I18nExtractor {\n const names = new Set(options.functions ?? ['t'])\n const keys = new Set<string>()\n const plugin: CompilerPlugin = {\n name: 'i18n-extractor',\n analyze(program, context) {\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node) && isTranslationCall(node.expression, names)) {\n const key = readStaticKey(node.arguments[0])\n if (key) {\n keys.add(key)\n options.onKey?.(key, context.filename)\n }\n }\n ts.forEachChild(node, visit)\n }\n visit(program)\n }\n }\n return {\n plugin,\n getKeys: () => [...keys].sort(),\n reset: () => keys.clear()\n }\n}\n\nfunction isTranslationCall(expression: ts.LeftHandSideExpression, names: Set<string>): boolean {\n if (ts.isIdentifier(expression)) return names.has(expression.text)\n return ts.isPropertyAccessExpression(expression) && names.has(expression.name.text)\n}\n\nfunction readStaticKey(argument: ts.Expression | undefined): string | undefined {\n if (!argument) return undefined\n if (ts.isStringLiteral(argument) || ts.isNoSubstitutionTemplateLiteral(argument)) return argument.text\n return undefined\n}\n"],"mappings":";;;;AAAA,OAAO,QAAQ;AACf,SAAS,iBAAiB;AAiDnB,SAAS,eAAe,UAA2B,CAAC,GAAiB;AAC1E,QAAM,cAAc,QAAQ,WAAW,CAAC;AAExC,SAAO;AAAA,IACL,QAAQ,MAAc,YAA4B,CAAC,GAAW;AAC5D,aAAO,QAAQ,MAAM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aAAa,MAAM,KAAK;AAAA,MAC7B,GATc;AAUd,YAAM,OAAO;AAAA,IACf;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,SAAS,6BAAM,CAAC,GAAG,IAAI,EAAE,KAAK,GAArB;AAAA,IACT,OAAO,6BAAM,KAAK,MAAM,GAAjB;AAAA,EACT;AACF;AAxBgB;AA0BhB,SAAS,kBAAkB,YAAuC,OAA6B;AAC7F,MAAIA,IAAG,aAAa,UAAU,EAAG,QAAO,MAAM,IAAI,WAAW,IAAI;AACjE,SAAOA,IAAG,2BAA2B,UAAU,KAAK,MAAM,IAAI,WAAW,KAAK,IAAI;AACpF;AAHS;AAKT,SAAS,cAAc,UAAyD;AAC9E,MAAI,CAAC,SAAU,QAAO;AACtB,MAAIA,IAAG,gBAAgB,QAAQ,KAAKA,IAAG,gCAAgC,QAAQ,EAAG,QAAO,SAAS;AAClG,SAAO;AACT;AAJS;","names":["initializer","ts","ts"]}
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import ts from 'typescript'\n\nexport type ASTNode = ts.Node\nexport type Program = ts.SourceFile\n\nexport interface CompilerContext {\n readonly filename: string\n readonly factory: typeof ts.factory\n addRuntimeImport(name: string): void\n /**\n * Create a reference to a runtime helper in generated code. When the source\n * binds the same name, the compiler imports the helper under an alias and\n * this returns the aliased identifier, so plugin-generated calls never\n * collide with user bindings.\n */\n helperRef(name: string): ts.Identifier\n}\n\nexport type AnalyzeContext = CompilerContext\nexport type TransformContext = CompilerContext\n\nexport interface CompilerPlugin {\n readonly name: string\n analyze?: (program: Program, context: AnalyzeContext) => void\n transform?: {\n program?: (program: Program, context: TransformContext) => Program | undefined\n node?: (node: ASTNode, context: TransformContext) => ASTNode | null | undefined\n }\n /** @deprecated Use transform.node for new plugins. */\n transformNode?: (node: ASTNode, context: TransformContext) => ASTNode | null | undefined\n}\n\nexport interface CompilerOptions {\n plugins?: readonly CompilerPlugin[]\n}\n\nexport interface CompileOptions extends CompilerOptions {\n filename?: string\n /**\n * 是否为组件调用生成源码位置({ file, line, column },用于错误定位与 DevTools)。\n * 默认 true。生产构建应传 false 以减小产物体积,省略后错误仍带组件名,定位走 source map。\n */\n sourceLocation?: boolean\n}\n\nexport interface VobsSourceMap {\n readonly version: 3\n readonly file: string\n readonly sources: string[]\n readonly sourcesContent: string[]\n readonly names: string[]\n readonly mappings: string\n}\n\nexport interface CompileResult {\n readonly code: string\n readonly map: VobsSourceMap\n readonly diagnostics: readonly CompilerDiagnostic[]\n}\n\nexport interface CompilerDiagnostic {\n readonly code: string\n readonly severity: 'error' | 'warning'\n readonly message: string\n readonly location: {\n readonly file: string\n readonly line: number\n readonly column: number\n }\n readonly codeFrame?: string\n readonly fix?: string\n}\n\nexport interface VobsCompiler {\n compile(code: string, options?: CompileOptions): string\n compileWithSourceMap(code: string, options?: CompileOptions): CompileResult\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import ts from 'typescript'\n\nexport type ASTNode = ts.Node\nexport type Program = ts.SourceFile\n\nexport interface CompilerContext {\n readonly filename: string\n readonly factory: typeof ts.factory\n addRuntimeImport(name: string): void\n /**\n * Create a reference to a runtime helper in generated code. When the source\n * binds the same name, the compiler imports the helper under an alias and\n * this returns the aliased identifier, so plugin-generated calls never\n * collide with user bindings.\n */\n helperRef(name: string): ts.Identifier\n}\n\nexport type AnalyzeContext = CompilerContext\nexport type TransformContext = CompilerContext\n\nexport interface CompilerPlugin {\n readonly name: string\n analyze?: (program: Program, context: AnalyzeContext) => void\n transform?: {\n program?: (program: Program, context: TransformContext) => Program | undefined\n node?: (node: ASTNode, context: TransformContext) => ASTNode | null | undefined\n }\n /** @deprecated Use transform.node for new plugins. */\n transformNode?: (node: ASTNode, context: TransformContext) => ASTNode | null | undefined\n}\n\nexport interface CompilerOptions {\n plugins?: readonly CompilerPlugin[]\n}\n\nexport interface CompileOptions extends CompilerOptions {\n filename?: string\n /**\n * 是否为组件调用生成源码位置({ file, line, column },用于错误定位与 DevTools)。\n * 默认 true。生产构建应传 false 以减小产物体积,省略后错误仍带组件名,定位走 source map。\n */\n sourceLocation?: boolean\n /**\n * HMR 模块标识(dev 由 Vite 插件注入,通常为模块绝对路径)。提供后,模块顶层的\n * state() 声明会包装为 hmrStateRef(...):热更新重执行模块时复用既有信号实例,\n * 避免\"新旧两份模块实例、两份状态\"导致的页面半边失灵。\n */\n hmrModuleId?: string\n}\n\nexport interface VobsSourceMap {\n readonly version: 3\n readonly file: string\n readonly sources: string[]\n readonly sourcesContent: string[]\n readonly names: string[]\n readonly mappings: string\n}\n\nexport interface CompileResult {\n readonly code: string\n readonly map: VobsSourceMap\n readonly diagnostics: readonly CompilerDiagnostic[]\n}\n\nexport interface CompilerDiagnostic {\n readonly code: string\n readonly severity: 'error' | 'warning'\n readonly message: string\n readonly location: {\n readonly file: string\n readonly line: number\n readonly column: number\n }\n readonly codeFrame?: string\n readonly fix?: string\n}\n\nexport interface VobsCompiler {\n compile(code: string, options?: CompileOptions): string\n compileWithSourceMap(code: string, options?: CompileOptions): CompileResult\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/plugin.d.cts
CHANGED
|
@@ -36,6 +36,12 @@ interface CompileOptions extends CompilerOptions {
|
|
|
36
36
|
* 默认 true。生产构建应传 false 以减小产物体积,省略后错误仍带组件名,定位走 source map。
|
|
37
37
|
*/
|
|
38
38
|
sourceLocation?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* HMR 模块标识(dev 由 Vite 插件注入,通常为模块绝对路径)。提供后,模块顶层的
|
|
41
|
+
* state() 声明会包装为 hmrStateRef(...):热更新重执行模块时复用既有信号实例,
|
|
42
|
+
* 避免"新旧两份模块实例、两份状态"导致的页面半边失灵。
|
|
43
|
+
*/
|
|
44
|
+
hmrModuleId?: string;
|
|
39
45
|
}
|
|
40
46
|
interface VobsSourceMap {
|
|
41
47
|
readonly version: 3;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ interface CompileOptions extends CompilerOptions {
|
|
|
36
36
|
* 默认 true。生产构建应传 false 以减小产物体积,省略后错误仍带组件名,定位走 source map。
|
|
37
37
|
*/
|
|
38
38
|
sourceLocation?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* HMR 模块标识(dev 由 Vite 插件注入,通常为模块绝对路径)。提供后,模块顶层的
|
|
41
|
+
* state() 声明会包装为 hmrStateRef(...):热更新重执行模块时复用既有信号实例,
|
|
42
|
+
* 避免"新旧两份模块实例、两份状态"导致的页面半边失灵。
|
|
43
|
+
*/
|
|
44
|
+
hmrModuleId?: string;
|
|
39
45
|
}
|
|
40
46
|
interface VobsSourceMap {
|
|
41
47
|
readonly version: 3;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git+https://github.com/vobsjs/vobs.git"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.3.1",
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
|
-
"@vobs/runtime": "1.
|
|
43
|
+
"@vobs/runtime": "1.3.1"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/compile.test.ts
CHANGED
|
@@ -170,6 +170,80 @@ describe('compiler', () => {
|
|
|
170
170
|
expect(result).not.toContain('setAttribute(_el2, "key"')
|
|
171
171
|
})
|
|
172
172
|
|
|
173
|
+
it('编译嵌套三元的全部分支(不再只保留第一个分支)', () => {
|
|
174
|
+
const result = compile(`const el = <div>{flag ? <A /> : other ? <B /> : <C />}</div>`)
|
|
175
|
+
|
|
176
|
+
expect(result).toContain('insertDynamic')
|
|
177
|
+
// 三个分支全部编译为组件调用
|
|
178
|
+
expect(result.match(/createComponent\(resolveComponent/gu)).toHaveLength(3)
|
|
179
|
+
expect(result).not.toContain('React')
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('编译 && 与嵌套动态节点组合', () => {
|
|
183
|
+
const result = compile(`const el = <div>{flag && (other ? <A /> : <B />)}</div>`)
|
|
184
|
+
|
|
185
|
+
expect(result).toContain('insertDynamic')
|
|
186
|
+
expect(result.match(/createComponent\(resolveComponent/gu)).toHaveLength(2)
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
it('编译 if 块内的 JSX 早返回(不再泄漏到 React 降级路径)', () => {
|
|
190
|
+
const code = `
|
|
191
|
+
function App() {
|
|
192
|
+
if (items.value.length === 0) return <Empty />
|
|
193
|
+
return <div><Footer /></div>
|
|
194
|
+
}
|
|
195
|
+
`
|
|
196
|
+
const result = compile(code)
|
|
197
|
+
|
|
198
|
+
// 早返回分支与主 return 分支都编译为 vobs 组件调用,源码中不残留 JSX
|
|
199
|
+
expect(result.match(/createComponent\(resolveComponent/gu)).toHaveLength(2)
|
|
200
|
+
expect(result).not.toContain('<Empty')
|
|
201
|
+
expect(result).not.toContain('<Footer')
|
|
202
|
+
expect(result).not.toContain('React')
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it('编译函数体内部初始化器与嵌套函数中的 JSX', () => {
|
|
206
|
+
const code = `
|
|
207
|
+
function App() {
|
|
208
|
+
const render = () => <Inner />
|
|
209
|
+
if (cond.value) { slot = <Aside /> }
|
|
210
|
+
return <div>{render()}</div>
|
|
211
|
+
}
|
|
212
|
+
`
|
|
213
|
+
const result = compile(code)
|
|
214
|
+
|
|
215
|
+
expect(result.match(/createComponent\(resolveComponent/gu)).toHaveLength(2)
|
|
216
|
+
expect(result).not.toContain('<Inner')
|
|
217
|
+
expect(result).not.toContain('<Aside')
|
|
218
|
+
expect(result).not.toContain('React')
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it('hmrModuleId 将模块顶层 state 包装为 HMR 保鲜引用', () => {
|
|
222
|
+
const code = `import { state } from '@vobs/reactivity'
|
|
223
|
+
export const count = state(0)
|
|
224
|
+
function helper() {
|
|
225
|
+
const local = state(1)
|
|
226
|
+
return local.value
|
|
227
|
+
}
|
|
228
|
+
`
|
|
229
|
+
const result = compile(code, { hmrModuleId: 'src/stores/counter.ts' })
|
|
230
|
+
|
|
231
|
+
// 顶层声明被包装,函数内的局部声明不受影响
|
|
232
|
+
expect(result).toContain('hmrStateRef("src/stores/counter.ts#count"')
|
|
233
|
+
expect(result).toContain('() => state(0, "count")')
|
|
234
|
+
expect(result).not.toContain('hmrStateRef("src/stores/counter.ts#local"')
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it('hmrModuleId 保留显式 debugName 且兼容别名导入', () => {
|
|
238
|
+
const code = `import { state as st } from '@vobs/reactivity'
|
|
239
|
+
export const width = st(50, 'doc.width')
|
|
240
|
+
`
|
|
241
|
+
const result = compile(code, { hmrModuleId: 'src/stores/doc.ts' })
|
|
242
|
+
|
|
243
|
+
expect(result).toContain('hmrStateRef("src/stores/doc.ts#width"')
|
|
244
|
+
expect(result).toContain("() => st(50, 'doc.width')")
|
|
245
|
+
})
|
|
246
|
+
|
|
173
247
|
it('在 JSX 转换前执行编译器插件的分析、程序与节点钩子', () => {
|
|
174
248
|
const filenames: string[] = []
|
|
175
249
|
const plugin: CompilerPlugin = {
|