import { HiddenCloseLocation } from './errors.js'; export declare enum TokenType { TEXT = "TEXT", EXPRESSION_START = "EXPRESSION_START",// <%= EXPRESSION_UNESCAPED = "EXPRESSION_UNESCAPED",// <%!= EXPRESSION_BR = "EXPRESSION_BR",// <%br= (escaped + newlines to
) CODE_START = "CODE_START",// <% TAG_END = "TAG_END",// %> COMMENT = "COMMENT",// <%-- comment --%> DEFINE_START = "DEFINE_START",// - value is the expression text SELF_CLOSING = "SELF_CLOSING",// /> ATTR_NAME = "ATTR_NAME",// $property or regular ATTR_VALUE = "ATTR_VALUE", COLON = "COLON", SEMICOLON = "SEMICOLON", GT = "GT",// > LT = "LT",// < SLASH = "SLASH",// / EQUALS = "EQUALS",// = QUOTE = "QUOTE",// " or ' EOF = "EOF", NEWLINE = "NEWLINE", WHITESPACE = "WHITESPACE", JAVASCRIPT = "JAVASCRIPT" } export interface SourceLocation { start: { line: number; column: number; offset: number; }; end: { line: number; column: number; offset: number; }; } export interface Token { type: TokenType; value: string; line: number; column: number; start: number; end: number; loc?: SourceLocation; /** * Set on the literal text parts of an interpolated attribute value * (title="a <%= x %> b"): they are text, never a value to classify as an * identifier or expression. */ interpolation_text?: boolean; } export declare class Lexer { private input; private filename?; private position; private line; private column; private tokens; private line_starts; readonly hidden_closes: HiddenCloseLocation[]; private in_attribute_value; private savedPosition; constructor(input: string, filename?: string); /** 1-based line and column of an input offset. */ private position_at; /** * Save current position for later token creation */ private savePosition; /** * Get saved position or current position */ private getSavedPosition; /** * Replace <%-- comment --%> with equivalent number of newlines * This ensures line mapping stays accurate while removing comment content */ private preprocessComments; /** * Replace HTML comments () that appear OUTSIDE of tags * This strips documentation comments before component definitions * HTML comments INSIDE tags are preserved in the output */ private preprocessHTMLComments; /** * Preprocess code blocks: mark empty lines with a comment placeholder. * * Expressions (<%= %>, <%!= %>, <%br= %>) are left exactly as written - a * multi-line expression is joined onto one generated line by the parser, so no * newline is moved out of it into the template text. Lines that start inside a * string, template literal or block comment are part of that literal or comment * and are never touched (shared JS scanner). */ private preprocessCodeBlocks; /** * Record the suspicious %> hidden in // comments of the code region starting at * `start` of `text`. Line comments are blanked once a code block is preprocessed, * so code blocks are recorded there and expressions (and an unclosed code block) * when scanned; no region is seen with its comments twice. */ private record_hidden_closes; tokenize(): Token[]; /** * A template is compiled into JavaScript, and that JavaScript may be inlined in an * HTML