🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
108 lines
3.2 KiB
TypeScript
Executable File
108 lines
3.2 KiB
TypeScript
Executable File
import { ProgramNode } from './ast.js';
|
|
export interface GeneratedCode {
|
|
code: string;
|
|
source_map?: string;
|
|
source_map_data_uri?: string;
|
|
components: Map<string, ComponentCode>;
|
|
}
|
|
export interface ComponentCode {
|
|
name: string;
|
|
render_function: string;
|
|
dependencies: string[];
|
|
tagName: string;
|
|
defaultAttributes: Record<string, any>;
|
|
defineArgs?: Record<string, any>;
|
|
extends?: string;
|
|
}
|
|
export declare class CodeGenerator {
|
|
private indent_level;
|
|
private components;
|
|
private current_component;
|
|
private in_slot;
|
|
private tag_depth;
|
|
private lastOutput;
|
|
private outputLine;
|
|
private outputColumn;
|
|
private sourceMapGenerator?;
|
|
private sourceContent?;
|
|
private sourceFile?;
|
|
private outputBuffer;
|
|
private enablePositionTracking;
|
|
private positionLog;
|
|
private currentOutputLine;
|
|
private preserveLines;
|
|
private outputLines;
|
|
private sourceLines;
|
|
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_with_mappings_TESTING;
|
|
private generate_component;
|
|
private generate_function_body;
|
|
/**
|
|
* Generate function body with true 1:1 line mapping
|
|
* Each line in the source produces exactly one line in the output
|
|
*/
|
|
private generate_function_body_1to1;
|
|
private generate_node;
|
|
/**
|
|
* Padded trim: Collapse internal whitespace but preserve leading/trailing space
|
|
* Examples:
|
|
* " hello " → " hello "
|
|
* "hello" → "hello"
|
|
* " " → " "
|
|
* "\n\n \n" → " "
|
|
*/
|
|
private padded_trim;
|
|
private generate_text;
|
|
private generate_expression;
|
|
private generate_if;
|
|
private generate_for;
|
|
private generate_code_block;
|
|
private generate_tag_open;
|
|
private generate_html_tag;
|
|
private generate_component_invocation;
|
|
private parse_attributes;
|
|
private generate_attributes_with_conditionals;
|
|
private generate_attributes_object;
|
|
private is_self_closing_tag;
|
|
private compile_interpolated_value;
|
|
private escape_string;
|
|
private indent;
|
|
private extract_slots_from_children;
|
|
/**
|
|
* Emit text and track position for source maps
|
|
*/
|
|
private emit;
|
|
/**
|
|
* Emit a line of text (adds newline)
|
|
*/
|
|
private emitLine;
|
|
/**
|
|
* Reset position tracking
|
|
*/
|
|
private resetPositionTracking;
|
|
/**
|
|
* Get position tracking log for debugging
|
|
*/
|
|
getPositionLog(): Array<{
|
|
line: number;
|
|
column: number;
|
|
text: string;
|
|
node?: string;
|
|
}>;
|
|
/**
|
|
* Enable/disable position tracking
|
|
*/
|
|
setPositionTracking(enabled: boolean): void;
|
|
/**
|
|
* Serialize attribute object with proper handling of identifiers and expressions
|
|
* Quoted values become strings, identifiers/expressions become raw JavaScript
|
|
*/
|
|
private serializeAttributeObject;
|
|
private build_module_code;
|
|
}
|
|
export declare function generate(ast: ProgramNode, sourceFile?: string, sourceContent?: string): GeneratedCode;
|
|
//# sourceMappingURL=codegen.d.ts.map
|