//#region src/types.d.ts /** Transport modes that a channel definition can opt into. */ type ChannelDefinitionTransport = "ws"; /** Shape of a message as published by app code. */ interface ChannelPublishInput { /** Application-defined message kind (e.g. `"chat.send"`). */ type: string; /** Message payload. */ data: T; } /** Persisted channel message with server-assigned id and channel name. */ interface ChannelMessage extends ChannelPublishInput { /** Server-assigned monotonic message id. */ id: string; /** The exact channel the message was published on. */ channel: string; } /** Common HTTP-shaped options for channel requests. */ interface ChannelRequestOptions { /** Override the base URL. Required outside the browser. */ baseUrl?: string; /** Extra headers to send. */ headers?: Record; /** AbortSignal to cancel the request. */ signal?: AbortSignal; } /** Init argument accepted by a custom {@link ChannelSubscribeOptions.eventSourceFactory}. */ interface EventSourceFactoryInit { /** Extra headers to apply to the SSE request (factory permitting). */ headers?: Record; /** Last seen message id to resume from. */ lastEventId?: string; } /** Options for {@link import("./channels").Channel.subscribe}. */ interface ChannelSubscribeOptions { /** Override the base URL. Required outside the browser. */ baseUrl?: string; /** Extra headers to send on the SSE request. */ headers?: Record; /** Last seen message id — triggers replay from that point. */ lastEventId?: string; /** Inject a custom `EventSource` implementation (e.g. for Node, tests). */ eventSourceFactory?: (url: string, init?: EventSourceFactoryInit) => unknown; } /** Options for {@link import("./channels").Channel.connect}. */ interface ChannelConnectOptions { /** Override the base URL. Required outside the browser. */ baseUrl?: string; /** Extra headers to send on the upgrade request (factory permitting). */ headers?: Record; /** Last seen message id — replays missed frames before live traffic. */ lastMessageId?: string; /** Inject a custom `WebSocket` implementation (e.g. for Node, tests). */ webSocketFactory?: (url: string) => unknown; } /** Options for {@link import("./channels").Channel.publish}. */ interface ChannelPublishOptions extends ChannelRequestOptions {} /** Handle returned by {@link import("./channels").Channel.subscribe}. */ interface ChannelSubscription { /** Always `"sse"` — subscriptions are server-sent events. */ transport: "sse"; /** The underlying `EventSource` (or factory result). Escape hatch for advanced callers. */ raw: unknown; /** End the subscription. */ close: () => void; } /** Handle returned by {@link import("./channels").Channel.connect}. */ interface ChannelSocket { /** Always `"ws"` — sockets are WebSockets. */ transport: "ws"; /** The underlying `WebSocket` (or factory result). Escape hatch for advanced callers. */ raw: unknown; /** Close the socket with an optional code/reason. */ close: (code?: number, reason?: string) => void; /** Send a payload. Objects are JSON-stringified; binary types are passed through. */ send: (data: unknown) => void; } //#endregion export { ChannelPublishOptions as a, ChannelSubscribeOptions as c, ChannelPublishInput as i, ChannelSubscription as l, ChannelDefinitionTransport as n, ChannelRequestOptions as o, ChannelMessage as r, ChannelSocket as s, ChannelConnectOptions as t, EventSourceFactoryInit as u }; //# sourceMappingURL=types-RpdjJLPg.d.ts.map