import { WRN_RUNTIME_TARGETS } from "./spec.ts"; import { parseApiEntries, type ApiSections } from "./api-sections.ts"; /** * Recursive-descent parser for `.wrn`, producing a small AST. * * Grammar (subset of the vision, but real): * * page { * types { } * props { : [= ] } // no default means required * state : = // type annotation is optional * view { } // plain HTML (see parseHtmlView) * seo { title = "Home" description = "..." } * ssr { api { } functions { } } * client { api { } functions { } } * style { } // zero or more, inlined with the page * functions { } // zero or more, shared helpers * api { } // zero or more * realtime { on () { } * } // zero or more * } * * The `view` block is written as ordinary HTML — nothing new to learn. Text may * contain `{expr}` interpolation, attributes may be hyphenated (`data-*`), and * `@event="..."` declares a client event binding. See `parseHtmlView`. */ import { Lexer, LexError, type Token } from "./tokenizer.ts"; import { validateTypedInitializer } from "./types.ts"; import { parseComputedDeclarations, parseOutputs, parsePersist, parseRuntimeFunctions, parseStateDeclarations, parseStoreLifecycle, parseStructuredImports, type OutputDecl, type PersistDecl, type RuntimeFunctionDecl, type StateRuntime, type StoreKind, type StoreLifecycleDecl, type StructuredImportDecl, } from "./v060.ts"; export interface StateDecl { name: string; /** Runtime visibility. Legacy declarations are shared. */ runtime: StateRuntime; /** Explicit TypeScript-style type annotation, when supplied. */ valueType?: string; /** Raw JS initializer expression, e.g. `0` or `'x'`. */ expr: string; } export interface ComputedDecl { name: string; valueType?: string; expr: string; } export interface EffectBlock { body: string; } export interface LoadBlock { mode: "server" | "client"; name?: string; dependsOn?: string[]; deferred?: boolean; body: string; } export interface ActionBlock { name: string; args: string[]; schema?: string; body: string; } export interface Attr { name: string; value: string; /** True for `@event` bindings (vs. plain HTML attributes). */ event: boolean; /** True for a valueless boolean attribute, e.g. `