/** * Islands: named interactive regions inside server-rendered pages. The server marks a host - * *
* 2 * *
* * - and the client registers behavior by name. `state(key, fallback)` returns a signal seeded * from the host's `data-island-state` JSON: the server's loader data becomes client signals with * zero extra serialization ceremony (the attribute IS the wire format; `@nifrajs/web-vanilla`'s * escaping makes it safe to emit). */ import { type IslandStrategy, MAX_MEDIA_QUERY_LENGTH } from "@nifrajs/island-trigger"; import { type BindableElement, type BindableRoot } from "./bind.js"; import type { Signal } from "./signals.js"; export { type IslandStrategy, MAX_MEDIA_QUERY_LENGTH }; export interface IslandContext { /** The island's host element. */ readonly root: BindableElement & BindableRoot; /** * A named signal, seeded from `data-island-state`'s value for `key` when present, else * `fallback`. Each key returns the SAME signal across calls - bindings and setup share state. */ state(key: string, fallback: T): Signal; } /** An island's setup function: read/seed state, return the event handlers the markup names. */ export type IslandSetup = (ctx: IslandContext) => Record void> | undefined; /** Register an island's behavior by name (the markup's `data-island` value). */ export declare function island(name: string, setup: IslandSetup): void; /** The host-element surface `mountIslands` needs beyond bindings. */ export interface IslandHost extends BindableElement, BindableRoot { setAttribute(name: string, value: string): void; } export interface MountIslandOptions { readonly root?: BindableRoot; } /** * Mount every registered island under `root` (default: the document). Idempotent - a host is * marked once mounted, so calling again (e.g. after a soft navigation swapped content in) only * mounts new hosts. Unregistered island names are skipped silently: markup may ship ahead of * its script, and progressive enhancement means the static content is already correct. */ export declare function mountIslands(rootOrOptions?: BindableRoot | MountIslandOptions): () => void; /** * Server-side helper: the value for a host's `data-island-state` attribute. Plain JSON - emit it * through an escaping renderer (`@nifrajs/web-vanilla`'s `html` escapes quotes in attributes), e.g. * `html\`
…\``. */ export declare function islandState(state: Record): string; //# sourceMappingURL=island.d.ts.map