import { t as ParserOptions, v as RootNode, w as TemplateChildNode, z as TransformContext, h as DirectiveTransform, E as ElementNode, e as CompilerOptions, F as TransformOptions, C as CodegenOptions, c as CodegenResult, n as JSChildNode, J as JSArrayExpression, y as TextNode, A as AttributeNode, m as JSCallExpression, d as CommentNode, S as SimpleExpressionNode, f as CompoundExpressionNode, o as JSConditionalExpression, k as ExpressionNode, D as DirectiveNode, j as ElementTypes, I as InterpolationNode, r as JSProperty, q as JSObjectExpression, V as VNodeCall, R as RawSourceMap } from './types-DlGtUPo9.cjs'; export { B as BaseNode, a as BindingMetadata, b as BindingTypes, g as ConstantTypes, i as DirectiveTransformResult, l as JSCacheExpression, p as JSFunctionExpression, N as NodeTransform, s as NodeTypes, P as ParentNode, u as Property, T as TagType, x as TextModes, G as helperNameMap } from './types-DlGtUPo9.cjs'; import { SourceLocation } from '@lytjs/common-error'; export { SourceLocation } from '@lytjs/common-error'; export { PatchFlags } from '@lytjs/common-vnode'; declare function parse(source: string, options?: ParserOptions): RootNode; declare function transformIf(node: RootNode | TemplateChildNode, context: TransformContext): void; declare function transformFor(node: RootNode | TemplateChildNode, context: TransformContext): void; declare const transformModel: DirectiveTransform; declare const transformOn: DirectiveTransform; declare const transformBind: DirectiveTransform; declare const transformShow: DirectiveTransform; declare function transformOnce(node: RootNode | TemplateChildNode, context: TransformContext): void; declare function transformSlot(node: RootNode | TemplateChildNode, context: TransformContext): void; declare function transformElement(node: ElementNode, context: TransformContext): void; /** * v-memo 转换函数(NodeTransform) * * 处理流程: * 1. 检测元素上的 v-memo 指令 * 2. 提取依赖数组表达式 * 3. 将依赖信息存储为节点元数据 * 4. 移除 v-memo 指令 * 5. 正常执行 transformElement */ declare function transformVMemo(node: RootNode | TemplateChildNode, context: TransformContext): void; declare function transform(root: RootNode, options?: TransformOptions): void; /** * 向后兼容的 optimize 函数。 * 原 optimize 阶段的逻辑(markConstants、hoistStatic、collectDynamicChildren) * 已合并到 transform() 中,此函数保留仅为向后兼容。 * 调用此函数是安全的(幂等操作),但推荐直接使用 transform()。 */ declare function optimize(root: RootNode, _options?: CompilerOptions): void; declare function generate(ast: RootNode, options?: CodegenOptions): CodegenResult; declare function generateSignalOptimized(ast: RootNode, _options?: CompilerOptions): CodegenResult; /** Server Component 指令 */ type ServerDirective = 'use server' | 'use client'; /** Server Component 分析结果 */ interface ServerComponentAnalysis { /** 是否是 Server Component */ isServerComponent: boolean; /** 是否是 Client Component */ isClientComponent: boolean; /** 服务端函数列表 */ serverFunctions: string[]; /** 客户端导入列表 */ clientImports: string[]; /** 数据获取函数 */ dataFetchers: string[]; /** 序列化数据 */ serializedData: Record; } /** Server Component 编译选项 */ interface ServerComponentOptions { /** 服务端组件输出目录 */ serverOutputDir?: string; /** 客户端组件输出目录 */ clientOutputDir?: string; /** 是否生成客户端桩 */ generateClientStubs?: boolean; /** 服务端函数命名前缀 */ serverFunctionPrefix?: string; } /** Server Component 编译结果 */ interface ServerComponentResult { /** 服务端代码 */ serverCode: string | null; /** 客户端代码 */ clientCode: string | null; /** 类型定义 */ typeDefinition: string | null; /** 分析结果 */ analysis: ServerComponentAnalysis; } /** * 检测源码中的 Server Component 指令 */ declare function detectServerDirective(source: string): ServerDirective | null; /** * 分析组件是否为 Server Component */ declare function analyzeServerComponent(source: string, _options?: ServerComponentOptions): ServerComponentAnalysis; /** * 编译 Server Component */ declare function compileServerComponent(source: string, filename: string, options?: ServerComponentOptions): ServerComponentResult; /** * 创建服务端函数引用 * 用于在服务端标记可被客户端调用的函数 */ declare function createServerReference Promise>(id: string, fn: T): T; /** * 创建客户端代理 * 用于在客户端调用服务端函数 */ declare function createServerProxy Promise>(componentName: string, functionName: string): T; /** 边界类型 */ type BoundaryType = 'client' | 'server' | 'shared'; /** 边界分析结果 */ interface BoundaryAnalysis { /** 模块边界类型 */ type: BoundaryType; /** 服务端专用导入 */ serverImports: string[]; /** 客户端专用导入 */ clientImports: string[]; /** 服务端专用函数 */ serverFunctions: string[]; /** 客户端专用函数 */ clientFunctions: string[]; /** 需要分割的组件 */ componentsToSplit: ComponentBoundary[]; /** 是否需要生成客户端桩 */ needsClientStub: boolean; /** 是否需要生成服务端桩 */ needsServerStub: boolean; } /** 组件边界信息 */ interface ComponentBoundary { /** 组件名称 */ name: string; /** 边界类型 */ type: BoundaryType; /** 服务端专用 props */ serverProps: string[]; /** 客户端专用 props */ clientProps: string[]; /** 服务端专用方法 */ serverMethods: string[]; /** 客户端专用方法 */ clientMethods: string[]; /** 生命周期钩子位置 */ lifecycleHooks: { name: string; type: 'client' | 'server'; }[]; } /** 分割结果 */ interface SplitResult { /** 服务端代码 */ serverCode: string; /** 客户端代码 */ clientCode: string; /** 共享代码 */ sharedCode: string; /** 类型定义 */ typeDefinition: string; /** 分析结果 */ analysis: BoundaryAnalysis; } /** 分割选项 */ interface SplitOptions { /** 服务端环境标识符 */ serverEnvId?: string; /** 客户端环境标识符 */ clientEnvId?: string; /** 是否生成类型定义 */ generateTypes?: boolean; /** 是否内联共享代码 */ inlineShared?: boolean; } /** * 分析源码的客户端/服务端边界 */ declare function analyzeBoundary(source: string): BoundaryAnalysis; /** * 分割客户端/服务端代码 */ declare function splitClientServer(source: string, options?: SplitOptions): SplitResult; /** * 运行时环境检测 */ declare const runtime: { /** 是否是服务端 */ isServer: boolean; /** 是否是客户端 */ isClient: boolean; /** 是否是 Web Worker */ isWorker: boolean; /** 是否是 Node.js */ isNode: boolean; /** 是否是 Edge Runtime */ isEdge: boolean; }; /** * 条件执行:仅在服务端执行 */ declare function serverOnly(fn: () => T): T | undefined; /** * 条件执行:仅在客户端执行 */ declare function clientOnly(fn: () => T): T | undefined; /** * 创建环境特定的值 */ declare function createEnvironmentValue(options: { server?: () => T; client?: () => T; }): T | undefined; /** * Memo 分析结果 */ interface MemoAnalysis { /** 是否需要 memo */ needsMemo: boolean; /** 检测到的静态子树 */ staticSubtrees: StaticSubtree[]; /** 检测到的稳定 props */ stableProps: string[]; /** 检测到的动态绑定 */ dynamicBindings: DynamicBinding[]; /** 建议的 memo 边界 */ suggestedMemoBoundaries: MemoBoundary[]; } /** 静态子树 */ interface StaticSubtree { /** 节点路径 */ path: number[]; /** 节点类型 */ nodeType: string; /** 是否完全静态 */ isFullyStatic: boolean; } /** 动态绑定 */ interface DynamicBinding { /** 绑定名称 */ name: string; /** 绑定类型 */ type: 'prop' | 'event' | 'directive' | 'interpolation'; /** 依赖的表达式 */ expression: string; /** 是否稳定(不随渲染变化) */ isStable: boolean; } /** Memo 边界建议 */ interface MemoBoundary { /** 节点路径 */ path: number[]; /** 原因 */ reason: string; /** 预期收益 */ expectedBenefit: 'high' | 'medium' | 'low'; } /** * 分析模板是否需要 memo */ declare function analyzeMemoNeeds(ast: RootNode): MemoAnalysis; /** * 死代码分析结果 */ interface DeadCodeAnalysis { /** 未使用的变量 */ unusedVariables: string[]; /** 未使用的导入 */ unusedImports: string[]; /** 不可达代码 */ unreachableCode: UnreachableCode[]; /** 常量折叠机会 */ constantFoldingOpportunities: ConstantFoldingOpportunity[]; /** 预期体积减少 */ estimatedSizeReduction: number; } /** 不可达代码 */ interface UnreachableCode { /** 位置 */ location: string; /** 原因 */ reason: string; } /** 常量折叠机会 */ interface ConstantFoldingOpportunity { /** 表达式 */ expression: string; /** 计算结果 */ result: unknown; } /** * 分析死代码 */ declare function analyzeDeadCode(source: string): DeadCodeAnalysis; /** * 执行死代码消除 */ declare function eliminateDeadCode(source: string, analysis: DeadCodeAnalysis): string; /** * AOT 编译选项 */ interface AOTOptions { /** 是否内联静态内容 */ inlineStatic?: boolean; /** 是否预计算常量表达式 */ precomputeConstants?: boolean; /** 是否生成类型定义 */ generateTypes?: boolean; /** 目标环境 */ target?: 'browser' | 'node' | 'edge'; } /** * AOT 编译结果 */ interface AOTResult { /** 编译后的代码 */ code: string; /** 类型定义 */ types?: string; /** 静态资源映射 */ staticAssets: Map; /** 编译统计 */ stats: { originalSize: number; compiledSize: number; reduction: number; }; } /** * AOT 预编译模板 */ declare function precompileTemplate(template: string, options?: AOTOptions): AOTResult; declare function createRoot(children: TemplateChildNode[], source?: string): RootNode; declare function createElement(tag: string, props?: (AttributeNode | DirectiveNode)[], children?: TemplateChildNode[], loc?: SourceLocation, tagType?: (typeof ElementTypes)[keyof typeof ElementTypes]): ElementNode; declare function createText(content: string, loc?: SourceLocation): TextNode; declare function createComment(content: string, loc?: SourceLocation): CommentNode; declare function createInterpolation(content: ExpressionNode, loc?: SourceLocation): InterpolationNode; declare function createAttribute(name: string, value?: TextNode | undefined, loc?: SourceLocation): AttributeNode; declare function createDirective(name: string, arg?: ExpressionNode | undefined, exp?: ExpressionNode | undefined, modifiers?: string[], loc?: SourceLocation): DirectiveNode; declare function createSimpleExpression(content: string, isStatic?: boolean, loc?: SourceLocation, isConstant?: boolean): SimpleExpressionNode; declare function createCompoundExpression(children: (TemplateChildNode | SimpleExpressionNode | string)[], loc?: SourceLocation): CompoundExpressionNode; declare function createVNodeCall(tag: string | VNodeCall | JSCallExpression, props?: JSObjectExpression | undefined, children?: JSChildNode | TemplateChildNode[] | string | undefined, patchFlag?: string | number | undefined, dynamicProps?: JSChildNode | undefined, directives?: JSChildNode[] | undefined, isBlock?: boolean, disableTracking?: boolean, isComponent?: boolean, loc?: SourceLocation): VNodeCall; declare function createObjectExpression(properties?: JSProperty[], loc?: SourceLocation): JSObjectExpression; declare function createObjectProperty(key: JSChildNode, value: JSChildNode, loc?: SourceLocation): JSProperty; declare function createCallExpression(callee: string | symbol, args?: (JSChildNode | string | TemplateChildNode | TemplateChildNode[])[], loc?: SourceLocation): JSCallExpression; declare function createConditionalExpression(test: JSChildNode | string, consequent: JSChildNode | TemplateChildNode | TemplateChildNode[], alternate: JSChildNode | TemplateChildNode | TemplateChildNode[] | undefined, newline?: boolean, loc?: SourceLocation): JSConditionalExpression; declare function createArrayExpression(elements?: JSChildNode[], loc?: SourceLocation): JSArrayExpression; interface SourceMapping { /** 原始源文件路径 */ source?: string; /** 原始源文件行号(从 0 开始) */ originalLine: number; /** Original source column (0-based) - 高精度列号映射 */ originalColumn: number; /** 生成代码行号(从 0 开始) */ generatedLine: number; /** 生成代码列号(从 0 开始) - 高精度列号映射 */ generatedColumn: number; /** 映射 token 的可选名称 */ name?: string; /** FIX: P2-1 原始列号精确映射,支持更细粒度的源码定位 */ originalColumnExact?: number; /** FIX: P2-1 生成列号精确映射 */ generatedColumnExact?: number; } declare class SourceMapGenerator { private file; private _sourceRoot; private sources; private sourcesContent; private names; private mappings; private _namesMap; private _sourcesMap; constructor(file?: string, sourceRoot?: string); /** * 添加从原始源码位置到生成代码位置的映射。 * FIX: P2-1 提高列精度,支持精确的原始列号映射 * * @param originalLine - Original source line (0-based) * @param originalColumn - Original source column (0-based) * @param generatedLine - Generated code line (0-based) * @param generatedColumn - Generated code column (0-based) * @param name - Optional name for the mapped token * @param originalColumnExact - Optional exact original column for high-precision mapping */ addMapping(originalLine: number, originalColumn: number, generatedLine: number, generatedColumn: number, name?: string, originalColumnExact?: number): void; /** * FIX: P2-27 多文件 source map 合并支持: * addSource 现在支持同一 source 多次调用(合并 content) * * 添加源文件。 */ addSource(source: string, content?: string): number; /** * 使用 VLQ 编码生成编码后的映射字符串。 * * 格式:每个段用 ',' 分隔;每个行组用 ';' 分隔。 * 每个段包含:[生成列, 源索引, 原始行, 原始列, 名称索引] * 所有值都是相对的(增量编码),除了每行的第一个段 * which has an absolute generated column. */ private encodeMappings; /** * 转换为 RawSourceMap 对象。 */ toJSON(): RawSourceMap; /** * Convert to base64-encoded data URI string. * Format: data:application/json;charset=utf-8;base64, * FIX: P1-31 使用 TextEncoder+btoa 替代 Buffer, * 确保在浏览器环境和 Node.js 环境中都能正常工作 * FIX: P2-19 使用 TextEncoder + 手动 base64 替代废弃的 unescape */ toBase64(): string; /** * FIX: P2-19 手动实现 base64 编码,避免使用废弃的 unescape * 使用 TextEncoder 将字符串转换为 UTF-8 字节,然后进行 base64 编码 */ private _manualBase64Encode; /** * Convert to inline source map comment format. * Format: //# sourceMappingURL=data:application/json;charset=utf-8;base64, */ toComment(): string; } interface SourceMapBuildOptions { filename?: string; sourceContent?: string; sourceRoot?: string; } /** * Create a SourceMapGenerator pre-configured for compiler use. */ declare function createSourceMapGenerator(options?: SourceMapBuildOptions): SourceMapGenerator; /** FIX: P2-22 编译警告级别可配置 */ type WarningLevel = 'silent' | 'error' | 'warn'; declare function setWarningLevel(level: WarningLevel): void; declare function getWarningLevel(): WarningLevel; /** 缓存统计信息 */ interface CacheStats { hits: number; misses: number; totalCompiles: number; totalTime: number; } /** * 清除编译缓存。用于测试或需要释放内存时。 * FIX: P2-2 同时清除内容哈希缓存 */ declare function clearCompileCache(): void; /** * 获取当前编译缓存大小。用于调试和测试。 */ declare function getCompileCacheSize(): number; /** * FIX: P2-2 获取内容哈希缓存大小(用于调试) */ declare function getContentHashCacheSize(): number; /** * 获取缓存统计信息 */ declare function getCacheStats(): CacheStats; /** * 重置缓存统计信息 */ declare function resetCacheStats(): void; declare function compile(source: string, options?: CompilerOptions): CodegenResult; export { type AOTOptions, type AOTResult, AttributeNode, type BoundaryAnalysis, type BoundaryType, type CacheStats, CodegenOptions, CodegenResult, CommentNode, CompilerOptions, type ComponentBoundary, CompoundExpressionNode, type ConstantFoldingOpportunity, type DeadCodeAnalysis, DirectiveNode, DirectiveTransform, type DynamicBinding, ElementNode, ElementTypes, ExpressionNode, InterpolationNode, JSArrayExpression, JSCallExpression, JSChildNode, JSConditionalExpression, JSObjectExpression, JSProperty, type MemoAnalysis, type MemoBoundary, ParserOptions, RawSourceMap, RootNode, type ServerComponentAnalysis, type ServerComponentOptions, type ServerComponentResult, type ServerDirective, SimpleExpressionNode, SourceMapGenerator, type SourceMapping, type SplitOptions, type SplitResult, type StaticSubtree, TemplateChildNode, TextNode, TransformContext, TransformOptions, type UnreachableCode, VNodeCall, type WarningLevel, analyzeBoundary, analyzeDeadCode, analyzeMemoNeeds, analyzeServerComponent, clearCompileCache, clientOnly, compile, compileServerComponent, createArrayExpression, createAttribute, createCallExpression, createComment, createCompoundExpression, createConditionalExpression, createDirective, createElement, createEnvironmentValue, createInterpolation, createObjectExpression, createObjectProperty, createRoot, createServerProxy, createServerReference, createSimpleExpression, createSourceMapGenerator, createText, createVNodeCall, detectServerDirective, eliminateDeadCode, generate, generateSignalOptimized, getCacheStats, getCompileCacheSize, getContentHashCacheSize, getWarningLevel, optimize, parse, precompileTemplate, resetCacheStats, runtime, serverOnly, setWarningLevel, splitClientServer, transform, transformBind, transformElement, transformFor, transformIf, transformModel, transformOn, transformOnce, transformShow, transformSlot, transformVMemo };