import { SourceLocation } from './lexer.js'; export declare enum NodeType { PROGRAM = "Program", COMPONENT_DEFINITION = "ComponentDefinition", COMPONENT_INVOCATION = "ComponentInvocation", HTML_TAG = "HtmlTag", TEXT = "Text", EXPRESSION = "Expression", IF_STATEMENT = "IfStatement", FOR_STATEMENT = "ForStatement", CODE_BLOCK = "CodeBlock", FRAGMENT = "Fragment", SLOT = "Slot",// v2 slot syntax CONDITIONAL_ATTRIBUTE = "ConditionalAttribute" } /** * Where a piece of author JavaScript starts in the source, for sourcemaps: the 1-based * line and column of its first character. For code joined onto one line * (join_lines_mapped), line_starts gives where each later source line begins in the * joined text (-1 inside a literal or comment). */ export interface CodeLocation { line: number; column: number; line_starts?: number[]; } /** 1-based position of a closing tag's `; extends?: string; defineArgs?: Record; isSlotOnly?: boolean; slotNames?: string[]; } export interface TextNode extends BaseNode { type: NodeType.TEXT; content: string; } export interface ExpressionNode extends BaseNode { type: NodeType.EXPRESSION; code: string; escaped: boolean; nl2br: boolean; code_loc?: CodeLocation; } export interface IfStatementNode extends BaseNode { type: NodeType.IF_STATEMENT; condition: string; consequent: ASTNode[]; alternate: ASTNode[] | null; } export interface ForStatementNode extends BaseNode { type: NodeType.FOR_STATEMENT; iterator: string; body: ASTNode[]; } export interface CodeBlockNode extends BaseNode { type: NodeType.CODE_BLOCK; tokens?: Array<{ type: string; value: string; }>; code?: string; code_loc?: CodeLocation; } export interface ConditionalAttributeNode extends BaseNode { type: NodeType.CONDITIONAL_ATTRIBUTE; condition: string; attributes: Record; } export interface FragmentNode extends BaseNode { type: NodeType.FRAGMENT; children: ASTNode[]; } export interface SlotNode extends BaseNode { type: NodeType.SLOT; name: string; attributes?: Record; params?: string[]; children: ASTNode[]; selfClosing: boolean; close_loc?: ClosePosition; } export interface ComponentInvocationNode extends BaseNode { type: NodeType.COMPONENT_INVOCATION; name: string; dynamic?: boolean; expression?: string; expression_loc?: CodeLocation; attributes: Record; conditionalAttributes?: ConditionalAttributeNode[]; children: ASTNode[]; selfClosing: boolean; close_loc?: ClosePosition; } export interface HtmlTagNode extends BaseNode { type: NodeType.HTML_TAG; name: string; attributes: Record; conditionalAttributes?: ConditionalAttributeNode[]; children: ASTNode[]; selfClosing: boolean; preserveWhitespace?: boolean; close_loc?: ClosePosition; } export type ASTNode = ProgramNode | ComponentDefinitionNode | ComponentInvocationNode | HtmlTagNode | TextNode | ExpressionNode | IfStatementNode | ForStatementNode | CodeBlockNode | FragmentNode | SlotNode | ConditionalAttributeNode; export declare function createNode(type: T['type'], props: Omit, start: number, end: number, line: number, column: number, loc?: SourceLocation): T; //# sourceMappingURL=ast.d.ts.map