/** * What a Web declaration means and what analyzing one does: the types a * `component` and an `action` publish, the four reactive declarations * (`state`, `computed`, `resource`, `action`), the module-level `import css * unsafe`, the scope prescan's answer, and the demotion an imported derived * name receives. * * D115 P4 R3c. Every one of these is reached from the analyzer's statement * seams, which stay on the root as the dispatch over statement kinds; the arms * themselves live here. `analyzeComponent` calls the same four declaration * analyzers from a component body, which is why they are a module both the root * and `components/` can call and why the import runs one way only: * `components/` reads this module, and this module never reads `components/`. */ import { type Diagnostic, type Span } from "@velarscript/compiler"; import { type Expression, type Statement, type TypeReference, type ValueType } from "@velarscript/compiler/extension"; import { type WebActionDeclaration as ActionDeclaration, type WebComponentDeclaration as ComponentDeclaration, type WebComputedDeclaration as ComputedDeclaration, type WebResourceDeclaration as ResourceDeclaration, type WebStateDeclaration as StateDeclaration, type WebUnsafeCssDeclaration as UnsafeCssDeclaration } from "../ast.ts"; import { type KeyedRebuildHost } from "./keyed-rebuild.ts"; /** * What the declaration analyzers ask of the analyzer that hosts them: the four * span tables a declaration records itself in, the module's unsafe-CSS and * resource inputs, and the base-analyzer operations declaring a name performs. * * It extends `KeyedRebuildHost` because a `computed` declaration is one of the * two places a keyed-list rebuild is recorded, so analyzing a declaration * really does need everything that advisory needs. */ export interface DeclarationAnalysisHost extends KeyedRebuildHost { /** D71 rule 182: the declaration spans of every `computed` binding in scope. */ readonly computedBindingSpans: Set; /** Local names bound to an imported `export computed`, from the Web interface. */ readonly importedComputedNames: ReadonlySet; /** The resolved spans of those imports, so a local shadow of the name is not one. */ readonly importedComputedSpans: Set; /** The project resources this compile read, which is where an external unsafe stylesheet's text comes from. */ readonly resources: ReadonlyMap; /** D114 W: the declaration spans of every `resource` in scope. */ readonly resourceBindingSpans: Set; /** Each external stylesheet already given an order position, which is how a second import of one is recognised. */ readonly unsafeCssImports: Set; /** How many synchronous reactive bodies enclose the expression being inferred; a `computed` initializer is one. */ synchronousReactiveDepth: number; readonly diagnostics: Diagnostic[]; analyzeFunctionDeclaration(statement: ActionDeclaration, className: null, method: boolean, declareSelf: boolean, forceAsynchronous: boolean, declarationKind: string): void; declareBinding(name: string, mutable: boolean, type: ValueType, declarationSpan: Span): void; inferExpression(expression: Expression, contextualType?: ValueType): ValueType; inferredFunctionResult(statement: ActionDeclaration): ValueType; isTopLevelScope(): boolean; markDeclaredBindingReactive(name: string, kind: "state" | "prop"): void; requireAssignable(actual: ValueType, expected: ValueType, valueSpan: Span): void; requireSettledCollectionElement(initializer: Expression, declared: ValueType, annotated: boolean): void; resolveAnnotation(reference: TypeReference | null): ValueType; resolveValidatedAnnotation(reference: TypeReference | null): ValueType; resolvedAsyncResult(type: ValueType): ValueType; validateTypeReference(reference: TypeReference): boolean; } export declare function componentType(host: DeclarationAnalysisHost, statement: ComponentDeclaration): ValueType; /** * A `state` declaration, at module scope and in a component body alike: the two * arms are the same eight lines, so they are written once here. */ export declare function analyzeStateDeclaration(host: DeclarationAnalysisHost, statement: StateDeclaration): void; /** * D71 rule 182: a derived value is reactive and read-only, which is exactly * the reactive identity a component prop already carries — a bare read lowers * through `.get()`, and nothing may write it. Registering that identity * rather than `state` is what keeps `bind={doubled}` and every other writable * position refusing a derived name for free. */ export declare function analyzeComputedDeclaration(host: DeclarationAnalysisHost, statement: ComputedDeclaration): void; export declare function analyzeResourceDeclaration(host: DeclarationAnalysisHost, statement: ResourceDeclaration): void; export declare function actionType(host: DeclarationAnalysisHost, statement: ActionDeclaration): ValueType; export declare function analyzeActionDeclaration(host: DeclarationAnalysisHost, statement: ActionDeclaration): void; /** * LOK-D2 / D53: unsafe CSS is a module-level ordering declaration, whether its * source is an external resource or an inline raw block. Nested inside a * component or a function it used to pass every check, build, and then appear * in no output at all. */ export declare function analyzeUnsafeCssDeclaration(host: DeclarationAnalysisHost, statement: UnsafeCssDeclaration): void; /** The three Web declarations a scope prescan has to see, so a later shadow of one is recognised. */ export declare function webScopeDeclaration(statement: Statement): { readonly name: string; readonly span: Span; } | null; /** * D71 rule 184: a cross-module `computed` travels through `reactiveExports` * so its bare read lowers through `.get()` like an exported `state` — but it * is not writable, and the imported binding must not inherit the writable * identity that carries `bind={...}` and `event => name = ...`. The Web * extension publishes which exported names are derived, so the import is * demoted to the read-only reactive identity here. * * `markCore` is the base analyzer's own registration, which only the class can * reach: this rule decides which identity the name receives and then hands the * decision back. */ export declare function markWebBindingReactive(host: DeclarationAnalysisHost, name: string, kind: "state" | "prop", markCore: (name: string, kind: "state" | "prop") => void): void; //# sourceMappingURL=declarations.d.ts.map