import { N as NodeTransform, v as RootNode } from './types-DlGtUPo9.js'; import { SourceLocation } from '@lytjs/common-error'; /** * @lytjs/compiler - WASM Compiler Interface * WASM-ready 浏览器端编译器接口。 * 当前使用 JavaScript 模拟实现,接口设计兼容真实 WASM 模块, * 便于后续无缝替换。 */ /** WASM 编译选项 */ interface WASMCompileOptions { /** 编译模式:'module' 生成 ES module 导出,'function' 生成独立函数 */ mode?: 'module' | 'function'; /** 是否内联编译(跳过 hoist 优化) */ inline?: boolean; /** 是否启用 SSR 模式 */ ssr?: boolean; /** 模板文件名,用于错误提示和 source map */ filename?: string; } /** WASM 编译结果 */ interface WASMCompileResult { /** 生成的渲染函数代码 */ code: string; /** 序列化后的 AST 节点数组 */ ast: ASTNode[]; /** 编译错误列表 */ errors: WASMCompileError[]; /** 编译警告列表 */ warnings: WASMCompileWarning[]; /** 提取的渲染函数名称 */ renderFn: string; /** 静态节点数量 */ staticCount: number; /** 动态节点数量 */ dynamicCount: number; /** 编译耗时(毫秒) */ compileTime: number; } /** WASM 编译错误 */ interface WASMCompileError { /** 错误信息 */ message: string; /** 错误位置 */ loc?: SourceLocation; /** 错误代码标识 */ code?: string; } /** WASM 编译警告 */ interface WASMCompileWarning { /** 警告信息 */ message: string; /** 警告位置 */ loc?: SourceLocation; } /** WASM 转换选项 */ interface WASMTransformOptions { /** 是否标记静态节点 */ markStatic?: boolean; /** 自定义节点转换器 */ nodeTransforms?: NodeTransform[]; } /** WASM 代码生成选项 */ interface WASMGenerateOptions { /** 代码生成模式 */ mode?: 'module' | 'function'; /** 代码前缀(如 import 语句) */ prefix?: string; /** 是否内联生成 */ inline?: boolean; } /** 序列化 AST 节点(浏览器可传输的 JSON 友好格式) */ interface ASTNode { /** 节点类型 */ type: string; /** 节点标签名(仅元素节点) */ tag?: string; /** 子节点 */ children?: ASTNode[]; /** 属性列表 */ props?: Array<{ name: string; value?: string; dynamic?: boolean; }>; /** 文本内容(仅文本/插值节点) */ content?: string; /** 是否为静态节点 */ isStatic?: boolean; /** patch flag(仅元素节点) */ patchFlag?: number; /** 源码位置 */ loc?: SourceLocation; } /** Token 类型 */ interface Token { type: 'tag-open' | 'tag-close' | 'tag-name' | 'attr-name' | 'attr-value' | 'text' | 'interpolation' | 'comment'; value: string; loc?: SourceLocation; } /** * WASM 编译器入口函数。 * 执行完整的 parse -> transform -> generate 流程, * 返回结构化的编译结果。 */ declare function wasmCompile(source: string, options?: WASMCompileOptions): WASMCompileResult; /** * 将编译器内部 AST 序列化为 JSON 友好的 ASTNode[] 格式。 */ declare function serializeAST(root: RootNode): ASTNode[]; /** * @lytjs/compiler - WASM Parser Interface * 封装 Parser 相关的 WASM-ready 接口。 */ /** * 将模板源码分词为 Token 流。 */ declare function tokenize(source: string): Token[]; /** * 将模板源码解析为序列化 AST。 */ declare function buildAST(source: string): ASTNode[]; /** * 解析 {{ expression }} 中的表达式内容。 */ declare function parseInterpolation(source: string): string | null; /** * @lytjs/compiler - WASM Generator Interface * 封装 Generator 相关的 WASM-ready 接口。 */ /** * 从模板源码生成渲染函数代码。 */ declare function generateRenderCode(source: string, options?: WASMGenerateOptions): string; /** * 生成静态提升(hoisted)变量的声明代码。 */ declare function generateHoistedCode(source: string): string; /** * 遍历 AST,收集所有元素的 patch flag。 */ declare function generatePatchFlags(source: string): Record; export { type ASTNode, type Token, type WASMCompileError, type WASMCompileOptions, type WASMCompileResult, type WASMCompileWarning, type WASMGenerateOptions, type WASMTransformOptions, buildAST, generateHoistedCode, generatePatchFlags, generateRenderCode, parseInterpolation, serializeAST, tokenize, wasmCompile };