/** * Build-time support for server-defined islands. The plugin scans * `*.server.ts(x)` modules for island exports (`export const X = ilha…`), * generates a client virtual module per file that re-creates those exports as * proxies wired to tacho stubs, and rewrites client-graph import sites so * island bindings resolve to the proxy while everything else keeps flowing * through oxidejs's tacho stub replacement. */ /** Oxide RPC client key — basename without `.server.*` (oxide indexes by module name). */ export declare const serverModuleRpcKey: (spec: string) => string; /** Client repaint group key — full normalized path so same-basename files stay distinct. */ export declare const serverModuleRepaintKey: (spec: string) => string; export interface ScannedServerIsland { /** Export binding name, or `"default"` for `export default ilha…`. */ name: string; /** Slot tag from the `{ as }` option — must match what SSR emits. */ as: string; /** Stream key → referenced module export used as its transport. */ streams: Record; /** Action key → referenced module export used as its transport. */ actions: Record; } export interface ClientIslandRef { id: string; local: string; imported: string; spec: string; } /** * Replace identity `action(` wrappers of exported server actions with the * capture-aware shim on ALREADY-COMPILED module code. Must run inside the * SSR transform so upstream JSX/TS output is preserved. */ export declare const rewriteServerActions: (code: string, rpcActions: Record) => string; export interface ServerModuleScan { islands: ScannedServerIsland[]; /** All value-export names of the module (transport candidates). */ exports: string[]; /** * Exported server actions rewritten to capture-aware shims: name → the * `x:` manifest key the client proxy wires an RPC transport for. * Event closures may call these directly without wrapping in ilha's * action() — during hydration-manifest rendering the call is recorded, * not executed. */ rpcActions: Record; /** Imported JSX components that must hydrate inside the server island. */ clientRefs: ClientIslandRef[]; } export declare const clientRefPublicId: (spec: string, imported: string) => string; /** Scan a `*.server.ts(x)` module source for island exports and their * declarative wiring. Islands are `export const Name = [async] function[*]` * (and the `export default` form); stream/action transports are discovered * from calls inside each island body. */ export declare const scanServerIslands: (source: string) => ServerModuleScan; export declare const loadServerModuleScan: (filePath: string) => ServerModuleScan; /** Virtual-module id prefix for generated client proxies of server islands. * The file path rides base64url-encoded: a raw suffix like * `\0…:…/tasks.server.tsx` would end in `.server.*` and oxidejs's client-stub * loader would claim the virtual module before us. */ export declare const SERVER_ISLAND_PREFIX = "\0ilha:server-island:"; /** Virtual-module specifier serving the client proxy for one server island file. */ export declare const serverIslandVirtualSpec: (file: string) => string; /** Emit the client virtual module for one scanned server file. Plain JS — * `\0` virtual modules bypass Vite's built-in TS transform, so type-only * constructs here would reach the browser unparsed. Editor types are * unaffected: TS resolves the ORIGINAL specifier (the real server module); * this module exists only inside the client bundle. Frames are fetched from * the plugin's `/__ilha/frame` dev middleware. */ export declare const serverIslandPublicId: (spec: string, name: string) => string; export declare const generateServerIslandModule: (spec: string, scan: ServerModuleScan) => string; export interface SplitContext { /** Resolved absolute path of the imported specifier, when it's a scanned * server module carrying islands; null otherwise. */ islandNamesFor: (spec: string) => { islands: Set; hasDefault: boolean; } | null; /** Virtual module specifier that provides the island bindings. */ virtualSpecFor: (spec: string) => string; } /** * Rewrite import sites whose specifier targets a server module containing * island exports. Island bindings move to the virtual proxy module; all other * bindings stay on the original specifier (oxidejs replaces them with tacho * stubs). Returns null when no statement needed rewriting. */ export declare const splitServerImports: (code: string, ctx: SplitContext) => string | null;