export declare const VOID_ELEMENTS: Set; import { ProgramNode } from './ast.js'; import { SourceMapGenerator } from 'source-map'; export interface GeneratedCode { code: string; source_map?: string; source_map_data_uri?: string; components: Map; } /** One sourcemap segment of a render function: generated line 1-based, columns 0-based. */ export interface RenderMapping { generated: { line: number; column: number; }; original: { line: number; column: number; }; name?: string; /** Author JavaScript copied verbatim from here on, so columns run in step. */ code?: boolean; } export interface ComponentCode { name: string; render_function: string; source_mappings: RenderMapping[]; define_position: { line: number; column: number; }; dependencies: string[]; tagName: string; defaultAttributes: Record; defineArgs?: Record; extends?: string; } export declare class CodeGenerator { private components; private current_component; private tag_depth; private lastOutput; private marks; private sourceContent?; private sourceFile?; generate(ast: ProgramNode, sourceFile?: string, sourceContent?: string): GeneratedCode; /** * Generate code with source maps using 1:1 line mapping + SourceMapGenerator */ generateWithSourceMap(ast: ProgramNode, sourceFile: string, sourceContent: string): GeneratedCode; private generate_component; /** * Parse the exact render function text that will be emitted, so invalid JS in any * template (slot-only included) fails compilation instead of failing at load time. * The text is 1:1 with the source lines, so the reported line is the source line. * A bracket the <% %> blocks leave unbalanced is reported where it is; any other * syntax error at the template column V8's caret maps back to. */ private validate_render_function; /** * The template position of a vm.Script SyntaxError. Its stack starts * "filename:LINE", then the generated line and a caret under the column. The mapping * at or before the caret gives the template position: inside author JavaScript * (copied verbatim) the offset from the mapping carries over; otherwise it is the * start of the node. Without a usable caret: the line, column 0. */ private static syntax_error_position; /** * The first bracket the definition's <% %> blocks leave unbalanced, read as one * stream of JavaScript in source order (a block may open what a later one closes). * <%= %> expressions are self-contained and not part of the stream; <%-- --%> and * HTML comments are not code. */ private find_unbalanced_code_bracket; /** * Generate the function body line by line: element N of the result is the code for * source line N (line 1 is the line itself). * * Every node is placed on the source line it starts on, and a closing tag on the * line of its , recursively - nested component content and slot bodies * included. Placement follows document order, so concatenating the lines keeps the * statements in source order, and no fragment contains a newline, so generated line * N is always source line N. Each emitted node carries a sourcemap mark (see mark()). */ private generate_function_body_1to1; /** Place one node's code (and its children's) on their source lines. */ private place_node; /** The line a node's closing code goes on: its closing tag, else its last child's line. */ private close_line; /** A mark for 1-based source `line` and `column`. */ private mark; /** A mark for where a node starts. */ private mark_node; /** * `code` with a mark before its first character and before the first character of * each later source line it was joined from (join_lines_mapped), so a position * inside a multi-line expression maps to its own source line. `name` goes on the * first mark. */ private mark_code; /** The `names` entry for an expression: an identifier or member path, else none. */ private static expression_name; /** * Merge each line's pushes, then read out and remove the marks: the render * function's text and its sourcemap segments (1-based generated line, 0-based * column within the render function). */ private finish_render; /** * Padded trim: Collapse internal whitespace but preserve leading/trailing space * Examples: * " hello " → " hello " * "hello" → "hello" * " " → " " * "\n\n \n" → " " */ private padded_trim; private generate_code_block; /** * Build the content string for a raw-content tag (