UNPKG

@stacksjs/stx

Version:

A performant UI Framework. Powered by Bun.

64 lines 1.67 kB
import type { ServerWebSocket } from 'bun'; export declare function createHmrHandler(): HmrWebSocketHandler; /** * Broadcast a message to all connected clients */ export declare function broadcast(message: HmrMessage): void; /** * Notify clients of a story update */ export declare function notifyStoryUpdate(storyId: string, data?: any): void; /** * Notify clients of a new story */ export declare function notifyStoryAdd(storyId: string, data?: any): void; /** * Notify clients of a removed story */ export declare function notifyStoryRemove(storyId: string): void; /** * Notify clients of a config change */ export declare function notifyConfigChange(): void; /** * Notify clients to do a full reload */ export declare function notifyFullReload(): void; /** * Notify clients of an error */ export declare function notifyError(error: string): void; /** * Get the number of connected clients */ export declare function getClientCount(): number; /** * Get HMR client script to inject into the page */ export declare function getHmrClientScript(wsUrl: string): string; /** * HMR message structure */ export declare interface HmrMessage { type: HmrMessageType data?: any timestamp?: number } /** * Create WebSocket upgrade handler for HMR */ export declare interface HmrWebSocketHandler { open: (ws: ServerWebSocket<unknown>) => void close: (ws: ServerWebSocket<unknown>) => void message: (ws: ServerWebSocket<unknown>, message: string | ArrayBuffer) => void } /** * HMR message types */ export type HmrMessageType = | 'connected' | 'story-update' | 'story-add' | 'story-remove' | 'config-change' | 'full-reload' | 'error'