import type { ComponentType } from "react"; import { type ViewConfig } from "./view-config.js"; import { type ViewRuntimeTransport } from "./view-runtime.js"; /** @internal Module shape of a `view.tsx` file. */ export interface ViewModule { /** Default view component — reads data via hooks. */ default: ComponentType; /** * Optional immutable pre-render runtime configuration. * * Normalized before the guest `App` is constructed. See {@link ViewConfig}. */ viewConfig?: ViewConfig; } /** * Mount options for {@link bootstrapView}. * * @internal */ interface BootstrapViewOptions { /** DOM id of the mount container; created if missing. @defaultValue `"root"` */ rootId?: string; /** * Guest transport injected for tests. When omitted, consumes any transport * queued by `_setTransportForTesting`, otherwise uses postMessage. * * @internal */ transport?: ViewRuntimeTransport; } /** * Mount a view module into the iframe document: normalizes * {@link ViewModule.viewConfig}, creates a {@link McpAppRuntime}, starts * `connect()` (declaring `tools: { listChanged: true }` and normalized * `availableDisplayModes`), renders the default export immediately (the * component reads data via hooks while the handshake is in progress), and * wraps everything in an error boundary. * * Auto-resize is on by default. Opt out with * `viewConfig.autoResize: false` and report size via * {@link useSendSizeChanged}. * * Repeated bootstrap for the same `rootId` reuses the mounted root and * runtime (HMR) without reconnecting. A second `rootId` while one view is * mounted throws. Call {@link disposeView} to unmount and allow a fresh * bootstrap. * * @param module - The view module (`default` component and optional * `viewConfig`). * @param options - Mount options. * @throws When `viewConfig.displayModes` is empty, duplicated, missing * `"inline"`, or contains an unknown mode; also when the initial display * preference is unsupported or absent from the supported list. * @throws When a view is already mounted on a different `rootId` in this * document. * * @internal */ export declare function bootstrapView(module: ViewModule, options?: BootstrapViewOptions): void; /** * Unmount the document's view and dispose its guest MCP App runtime. * * React unmounts first so hook cleanup (e.g. {@link useViewTool} removal) can * run while the App connection still exists; then the runtime closes the App * and transport. After this resolves, the view bootstrap can create a fresh * runtime. * * No-ops when nothing is mounted. * * @example * ```ts * await disposeView(); * ``` */ export declare function disposeView(): Promise; /** * @internal Clear the document mount via {@link disposeView} between tests. */ export declare function _resetBootstrapRootsForTesting(): void; export {};