import type { WDom } from 'lithent'; import type { ActionName, ActionParams } from './actions.js'; export type SlotMode = 'static' | 'server' | 'client'; export type Capability = 'strict' | 'rich' | 'unsafe'; /** Namespaced engine attributes such as `client:idle` or `client:media="(…)"`. */ export type Directives = Record; export interface ComponentDescriptor { /** Module path relative to the project root plus export name (`components/A.tsx#default`). */ componentId: string; component: (props: any, children?: any) => unknown; /** Undefined for an empty Slot declared with `component={…}`. */ props: Record | undefined; directives: Directives; fallback?: unknown; resetKey?: string | string[]; /** `transition:persist="id"` on a direct island (DC-19). */ persist?: string; /** `transition:persist-props`: keep the previous props when the island persists. */ persistProps?: true; children: WDom[]; } /** When a client component starts; `only` skips SSR and shows the fallback until then. */ export interface Activation { timing: 'load' | 'idle' | 'visible' | 'media'; media?: string; only: boolean; } export interface SlotMarker { kind: 'slot'; name: string; /** Normalized: explicit `mode`, else `client` with a client directive, else `static`. */ mode: SlotMode; /** Present for client slots. */ activation?: Activation; directives: Directives; /** class/style/id/data-* attributes written on the `` host. */ host: Record; child: ComponentDescriptor; empty: boolean; fallback?: unknown; /** Defaults to `strict` (DC-13). */ capability: Capability; /** `capability="unsafe" sandbox="iframe"`: render into a sandboxed iframe `srcdoc`. */ sandbox?: 'iframe'; resetKey?: string | string[]; swap?: 'replace' | 'morph'; viewTransition?: boolean; /** `server:defer` (DC-21): SSR writes the fallback and the browser fetches the content. */ defer: boolean; cache?: string; /** Accepts frames from `ctx.external()`, validated by `schema` (DESIGN 8.1). */ external?: boolean; schema?: unknown; /** `transition:persist` on a client Slot: the slot name is the persist ID (DC-19). */ persist?: true; persistProps?: true; } export interface IslandMarker extends ComponentDescriptor { kind: 'island'; activation: Activation; } export interface BootMarker { kind: 'boot'; transition: string; params: Record; } /** Client navigation strategies for links (DC-20). */ export type PrefetchStrategy = 'hover' | 'tap' | 'viewport' | 'load'; /** `` options, sent to the browser in `__SURFACE__.router` (DC-18). */ export interface RouterOptions { /** Default link prefetch (`hover`); `false` turns automatic prefetch off. */ prefetch?: PrefetchStrategy | false; /** `none` swaps without the root cross-fade View Transition. */ transition?: 'fade' | 'none'; /** Also `dataLayer.push({ event: 'surface.page_view' })` on every page load. */ dataLayer?: boolean; /** Prefetch cache entries (default 20) and lifetime in ms (default 30000). */ cacheSize?: number; cacheTtl?: number; } export interface RouterMarker { kind: 'router'; options: RouterOptions; } export type SurfaceMarker = SlotMarker | IslandMarker | BootMarker | RouterMarker; export declare class SurfaceError extends Error { constructor(message: string); } export declare function readMarker(node: unknown): SurfaceMarker | undefined; export declare const SLOT_NAME: RegExp; export declare const CLIENT_DIRECTIVES: readonly ["load", "idle", "visible", "media", "only"]; export declare function assertSlotName(name: unknown): asserts name is string; /** Normalize client directives (DC-04): no timing means `load`; `only` may combine with one. */ export declare function activationOf(directives: Directives): Activation; export interface SlotProps { /** Stable transition target, unique within the page. */ name: string; mode?: SlotMode; /** Declares the component of an initially empty slot instead of a child element. */ component?: (props: any, children?: any) => unknown; fallback?: unknown; capability?: Capability; /** With `capability="unsafe"`: isolate the HTML in a sandboxed iframe. */ sandbox?: 'iframe'; resetKey?: string | string[]; /** Server slots: how `html` updates are applied (DC-03). */ swap?: 'replace' | 'morph'; /** Wrap this slot's changes (first appearance included) in a View Transition (DC-06). */ viewTransition?: boolean; /** Server slot rendered after the page (DC-21); SSR writes `fallback`. */ 'server:defer'?: boolean; /** Deferred response `Cache-Control` (default `private, no-store`). */ cache?: string; /** Accepts frames from `ctx.external()`; requires `schema`. */ external?: boolean; /** Standard Schema validating external frames for this slot. */ schema?: unknown; /** The single child component element; its props are the slot state. */ children?: unknown; class?: string; style?: string; id?: string; [attribute: `data-${string}`]: string | number | boolean | undefined; [attribute: `aria-${string}`]: string | number | boolean | undefined; } /** * Named update boundary. Its single child component element (or `component` for an empty * slot) is replaced by the build plugin with a descriptor so the engine decides when and * where the component runs. The child's props are the slot state. */ export declare function Slot(props: SlotProps, children?: WDom[]): WDom; /** * Internal descriptor emitted by the build plugin for directive islands and Slot children. * The original component is passed as `__ssComponent`, so Lithent does not run it here. */ export declare function Island(props: Record, children?: WDom[]): WDom; /** `` props (DC-18): put it in the layout head. */ export interface ClientRouterProps extends RouterOptions { } /** * Opt-in client router (DC-18). Renders nothing; pages that render it navigate between each * other without document loads, and only they load the router chunk. */ export declare function ClientRouter(props?: ClientRouterProps): WDom; export interface BootProps { /** Registered transition name started after the page loads. */ transition: Name; params?: ActionParams; } /** * Auto-run transition. Renders nothing; the engine records it in document order and runs it * with the same concurrency rules as other actions (DC-31). */ export declare function Boot(props: BootProps): WDom; /** * Public props, slot state and boot params are embedded as JSON. Values that JSON would * drop or change silently are rejected instead (undefined object properties are omitted * on both sides and therefore allowed). */ export declare function assertJsonValue(value: unknown, where: string, path?: string): void; type Renderable = WDom | string | number | bigint | boolean | null | undefined | ((...args: any[]) => unknown) | readonly Renderable[]; declare global { namespace JSX { /** Accepted on every component element; the build plugin turns them into islands. */ interface IntrinsicAttributes { key?: string | number; 'client:load'?: boolean; 'client:idle'?: boolean; 'client:visible'?: boolean; 'client:media'?: string; 'client:only'?: boolean; /** Keep this island (named) or client Slot (true) across client navigation (DC-19). */ 'transition:persist'?: string | boolean; /** With transition:persist: keep the previous props instead of the new page's. */ 'transition:persist-props'?: boolean; } /** Components run synchronously; a Promise-returning component would render nothing. */ type ElementType = string | ((props: any, children?: any) => Renderable); } } export {}; //# sourceMappingURL=surfaceTree.d.ts.map