@storybook/react-native
Version:
A better way to develop React Native Components for your app
72 lines (68 loc) • 2.68 kB
TypeScript
import { WebSocketServer } from 'ws';
import { StoryIndex } from 'storybook/internal/types';
interface ChannelServerSecureOptions {
ca?: string | Buffer | Array<string | Buffer>;
cert?: string | Buffer | Array<string | Buffer>;
key?: string | Buffer | Array<string | Buffer>;
passphrase?: string;
}
/**
* Options for creating a channel server.
*/
interface ChannelServerOptions {
/**
* The port the server will listen on.
*/
port?: number;
/**
* The host the server will bind to.
*/
host?: string;
/**
* The path to the Storybook config folder.
*/
configPath: string;
/**
* Whether to enable MCP (Model Context Protocol) server support.
* When enabled, adds an /mcp endpoint.
*/
experimental_mcp?: boolean;
/**
* Whether to enable WebSocket support.
* When false, starts only the HTTP server endpoints.
*/
websockets?: boolean;
/**
* Whether to use HTTPS/WSS for the channel server.
* When true, valid TLS credentials must be provided via `ssl`.
*/
secured?: boolean;
/**
* TLS credentials used when `secured` is true.
*/
ssl?: ChannelServerSecureOptions;
}
/**
* Creates a channel server for syncing storybook instances and sending events.
* The server provides both WebSocket and REST endpoints:
* - WebSocket: broadcasts all received messages to all connected clients
* - POST /send-event: sends an event to all WebSocket clients
* - POST /select-story-sync/{storyId}: sets the current story and waits for a storyRendered event
* - GET /index.json: returns the story index built from story files
* - POST /mcp: MCP endpoint for AI agent integration (when experimental_mcp option is enabled)
*
* @param options - Configuration options for the channel server.
* @param options.port - The port to listen on.
* @param options.host - The host to bind to.
* @param options.configPath - The path to the Storybook config folder.
* @param options.experimental_mcp - Whether to enable MCP server support.
* @param options.websockets - Whether to enable WebSocket server support.
* @param options.secured - Whether to use HTTPS/WSS for the channel server.
* @param options.ssl - TLS credentials used when `secured` is true.
* @returns The created WebSocketServer instance, or null when websockets are disabled.
*/
declare function createChannelServer({ port, host, configPath, experimental_mcp, websockets, secured, ssl, }: ChannelServerOptions): WebSocketServer | null;
declare function buildIndex({ configPath }: {
configPath: string;
}): Promise<StoryIndex>;
export { buildIndex, createChannelServer };