/** * Kern Template Engine — dynamic pattern support * * Users define reusable code patterns in .kern files with typed slots. * Templates are registered at config/CLI time, then expanded during codegen. */ import { type KernRuntime } from './runtime.js'; import type { IRNode, TemplateDefinition } from './types.js'; export declare class KernTemplateError extends Error { constructor(message: string); } /** * Register a template from a parsed 'template' IRNode. * Extracts slot definitions, import declarations, and body from children. */ export declare function registerTemplate(node: IRNode, sourceFile?: string): void; /** Check if a node type matches a registered template. */ export declare function isTemplateNode(type: string, runtime?: KernRuntime): boolean; /** Clear all registered templates (for test isolation). */ export declare function clearTemplates(): void; /** Get a registered template definition by name. */ export declare function getTemplate(name: string): TemplateDefinition | undefined; /** Get count of registered templates. */ export declare function templateCount(): number; /** * Expand a template instance node into TypeScript lines. * * Looks up the template definition by `node.type`, validates required slots against * `node.props`, replaces `{{slotName}}` placeholders, handles `{{CHILDREN}}` recursion, * and prepends import lines. * * @param node - IR node whose `type` matches a registered template name * @param _depth - Internal recursion depth counter (do not set manually) * @param runtime - Optional KernRuntime instance * @returns Array of generated TypeScript source lines * @throws {KernTemplateError} If expansion depth exceeds 10 (recursion guard) * or required slots are missing */ export declare function expandTemplateNode(node: IRNode, _depth?: number, runtime?: KernRuntime): string[];