UNPKG

@stacksjs/stx

Version:

A performant UI Framework. Powered by Bun.

47 lines 1.83 kB
/** * Generate the unified hydration bootstrap script. * * This replaces the per-island inline scripts with a single runtime * that reads data-strategy attributes and sets up appropriate triggers. */ export declare function generateHydrationBootstrap(): string; /** * Generate a component manifest script block that registers * all discovered island component names with their import paths. * * @param islands - Map of component name to import path */ export declare function generateComponentManifest(islands: Map<string, string>): string; /** * Extract component name from inner content of an island. * Looks for PascalCase or kebab-case component tags. */ export declare function extractComponentName(content: string): string | null; /** * Extract bound props from component content. * Parses :prop="value" bindings. */ export declare function extractBoundProps(content: string, context: Record<string, unknown>): Record<string, unknown>; /** * Unified Hydration Runtime for Islands Architecture * * Replaces the per-strategy inline scripts with a single runtime that handles * all hydration strategies. Injected once per page when islands are present. * * The runtime: * 1. Component registry — maps names to dynamic imports * 2. hydrateIsland(element) — loads component, reads props, calls hydrate/mount * 3. Strategy dispatcher — sets up triggers per data-strategy attribute * 4. initIslands() — processes all .stx-island:not(.hydrated) on DOMContentLoaded * * @module hydration-runtime */ // ============================================================================ // Types // ============================================================================ export declare interface IslandMeta { id: string component: string strategy: string props: Record<string, unknown> }