import { _ as RpcFunctionDefinitionAny } from "./types-BkkQ0Txg.mjs"; import { BirpcGroup, ChannelOptions } from "birpc"; import { IncomingMessage } from "node:http"; import { ServerOptions } from "node:https"; import { WebSocket, WebSocketServer } from "ws"; //#region src/rpc/transports/ws-server.d.ts interface DevframeNodeRpcSessionMeta { id: number; ws?: WebSocket; clientAuthToken?: string; isTrusted?: boolean; subscribedStates: Set; /** * Streams this session has subscribed to via * `rpc.streaming.subscribe(channel, id)`. Tracked here for O(1) cleanup * on disconnect; the wire format is `${channel}\x1F${id}`. */ subscribedStreams?: Set; /** * Inbound streams this session is currently uploading to (via * `rpc.streaming.upload(channel, id)`). Tracked for cleanup on * disconnect; same wire format as `subscribedStreams`. */ uploadingStreams?: Set; } interface WsRpcTransportOptions { /** Attach to an existing WebSocketServer. When provided, `port`, `host`, and `https` are ignored. */ wss?: WebSocketServer; /** Port for a newly-created WebSocketServer. */ port?: number; /** Host for a newly-created WebSocketServer. Defaults to `localhost`. */ host?: string; /** When set, a new https.Server is created and the WebSocketServer is attached to it. */ https?: ServerOptions; /** * RPC function definitions, used by the per-call wire serializer to * dispatch between strict-JSON and structured-clone encoding based * on each function's `jsonSerializable` flag. * * When omitted, all messages fall back to structured-clone — safe but * loses dev-time validation for `jsonSerializable: true` declarations. */ definitions?: ReadonlyMap>; onConnected?: (ws: WebSocket, req: IncomingMessage, meta: DevframeNodeRpcSessionMeta) => void; onDisconnected?: (ws: WebSocket, meta: DevframeNodeRpcSessionMeta) => void; /** Override the default per-call serializer. Most callers should leave this unset. */ serialize?: ChannelOptions['serialize']; /** Override the default per-call deserializer. Most callers should leave this unset. */ deserialize?: ChannelOptions['deserialize']; } /** * Attach a WebSocket transport to an existing RPC group. Either pass an * existing `WebSocketServer` via `wss`, or let this helper create one from * `port` / `host` / `https`. */ declare function attachWsRpcTransport(rpcGroup: BirpcGroup, options?: WsRpcTransportOptions): { wss: WebSocketServer; }; //#endregion export { WsRpcTransportOptions as n, attachWsRpcTransport as r, DevframeNodeRpcSessionMeta as t };