import { c as ChannelSubscribeOptions, r as ChannelMessage, t as ChannelConnectOptions } from "./types-RpdjJLPg.js"; //#region src/react.d.ts type Status = "connecting" | "open"; type MessageHandler = (msg: ChannelMessage) => void; interface ChannelConnection { /** All messages received since mount or the last `clear()`, capped at 500. */ readonly messages: ChannelMessage[]; /** `"connecting"` before the first open or while reconnecting; `"open"` otherwise. */ readonly status: Status; /** Last error seen (parse failure or transport error). Cleared on successful reconnect. */ readonly error: Error | null; /** Empty the message buffer. */ clear(): void; /** Send a payload over the underlying WebSocket. Present only when `transport: "ws"`. */ send?(data: unknown): void; } interface BaseHookOptions { /** Typed channel params serialized into the channel query string. */ params?: Record; /** * Called for each incoming message. The latest handler is always used — * you do not need to memoize it. */ onMessage?: MessageHandler; } /** * Options for {@link useChannel}. * * Discriminated on `transport`. The default is `"sse"`, which accepts the * {@link ChannelSubscribeOptions} surface; `"ws"` accepts * {@link ChannelConnectOptions} instead and exposes `send()` on the result. */ type UseChannelOptions = (BaseHookOptions & { transport?: "sse"; } & ChannelSubscribeOptions) | (BaseHookOptions & { transport: "ws"; } & ChannelConnectOptions); /** * Subscribe a React component to a Tako channel. * * Returns a live {@link ChannelConnection} whose `messages` buffer updates as * frames arrive (capped at the last 500). The hook reconnects automatically * with exponential backoff + jitter on transport errors, and the latest * `onMessage` handler is always invoked — no memoization needed. * * With `transport: "ws"` the returned object additionally has a `send(data)` * method for pushing to the server. * * @typeParam T - The message payload type. * @param name - The exact channel name to subscribe to (e.g. `"chat:room-1"`). * @param options - Transport selection, an `onMessage` handler, and transport-specific options. * @returns A {@link ChannelConnection} reflecting current state. */ declare function useChannel(name: string, options?: BaseHookOptions & { transport?: "sse"; } & ChannelSubscribeOptions): ChannelConnection; declare function useChannel(name: string, options: BaseHookOptions & { transport: "ws"; } & ChannelConnectOptions): ChannelConnection & { send(data: unknown): void; }; //#endregion export { ChannelConnection, UseChannelOptions, useChannel }; //# sourceMappingURL=react.d.ts.map