/** * Bun WebSocket plumbing - the `websocket` dispatcher config `listen()` hands to Bun's serve when * the app has WS routes. Lives behind the `@nifrajs/core/ws` subpath (via `ws-hook.ts`) so the base * bundle of a no-WebSocket app never ships it; `server.ts` only imports the **types** from here * (erased). No `Bun.*` calls here - the runtime seam stays in `server.ts` (see runtime-boundary.test). */ import { type NifraWebSocket, type TopicRegistry, type WebSocketHandler } from "./websocket.js"; import type { BunWsHandlers } from "./ws-hook.js"; /** Per-connection state Bun's `websocket` callbacks read via `ws.data`: the matched handler, the * `upgrade()`-seeded user data, and the memoized portable {@link NifraWebSocket} wrapper. */ export interface BunWsData { readonly handler: WebSocketHandler; data: unknown; nifra?: NifraWebSocket; } /** Structural view of Bun's `ServerWebSocket` - keeps `Bun.*` types out of the public `.d.ts` * (`listen()` casts for the same reason). The real socket satisfies this. */ export interface BunSocket { send(data: string | ArrayBufferView | ArrayBuffer, compress?: boolean): number; close(code?: number, reason?: string): void; readonly readyState: number; subscribe(topic: string): void; unsubscribe(topic: string): void; readonly data: BunWsData; } /** * The shared Bun `websocket` dispatcher config for one app - each connection's `ws.data.handler` is * the matched route's handler, set by `server.upgrade`. * * `nativePubsub` (set by `listen()` when the app has no validated-send route) makes subscriptions use * Bun's own pub/sub; there the registry holds nothing and Bun auto-drops native subscriptions on * close, so the `unsubscribeAll` sweep is skipped. */ export declare function createBunWsHandlers(topics: TopicRegistry, nativePubsub?: boolean): BunWsHandlers; //# sourceMappingURL=ws-bun.d.ts.map