UNPKG

histoire

Version:

A fast story book powered by Vite

45 lines • 2.36 kB
import type { TerminalEvents } from '@histoire/cli/protocol/index'; import type { RuntimeEvent, RuntimeReply } from '@histoire/dev-proxy/protocol'; import type { ExecutionService } from '../execution-service.js'; import type { ProjectRuntimeHandle } from '../types.js'; import type { TerminalCommandHandler } from './registry.js'; /** Inputs of the child-side terminal adapter. */ export interface TerminalAdapterOptions { /** Proxy generation this process serves; commands for any other are ignored. */ generation: string; /** Sends a frame to the parent over IPC; returns false when nothing was sent (disconnected). */ send: (message: RuntimeReply | RuntimeEvent) => boolean; /** Session execution lane the terminal-scoped owner is created over. */ execution: () => ExecutionService; /** Handler set; defaults to the shared list in `handlers/index.ts`. */ handlers?: readonly TerminalCommandHandler[]; } /** * Creates the child-side terminal adapter. It attaches through the existing * generation lifecycle callbacks (`onGeneration`/`onBeforeRelease`), validates * `runtime-command` frames, and dispatches through the handler registry only. * It never creates a second server, collector, queue or listener. * @param options Wiring supplied by `dev-child`. */ export declare function createTerminalAdapter(options: TerminalAdapterOptions): { /** Operation names currently served. */ operations: () => string[]; /** Pass as (part of) `onGeneration`; opens the generation scope. */ onGeneration(handle: ProjectRuntimeHandle): void; /** * Pass as (part of) `onBeforeRelease`: stop admission first, then join * confirmed cleanup of terminal-owned work. */ onBeforeRelease(handle: ProjectRuntimeHandle): Promise<void>; /** * Handles one raw IPC message. * @returns Whether it was a command for this generation (and was taken). */ receive(raw: unknown): boolean; emit: <K extends keyof TerminalEvents & string>(event: K, data: TerminalEvents[K]) => boolean; /** Stops all replies/events; hooks already installed elsewhere are restored by their owners. */ close(): void; }; /** Type of the adapter returned by {@link createTerminalAdapter}. */ export type TerminalAdapter = ReturnType<typeof createTerminalAdapter>; //# sourceMappingURL=adapter.d.ts.map