import { type ReactNode } from 'react'; import { SharedWebSocket } from '../../SharedWebSocket'; import type { SharedWebSocketOptions } from '../../types'; /** * Provider props — pass URL and options as props for flexibility. * * @example * * * */ export interface SharedWebSocketProviderProps { url: string; options?: SharedWebSocketOptions; children: ReactNode; } /** * Provider component — owns one SharedWebSocket for its lifetime via an external * store. The instance is created on mount (connect runs once) and disposed on * unmount. `useSharedWebSocket()` is `null` until the instance exists. */ export declare function SharedWebSocketProvider({ url, options, children }: SharedWebSocketProviderProps): import("react").FunctionComponentElement | null>>; /** * Access the SharedWebSocket instance from context. Returns `null` until the * provider's instance is connected (first render and SSR). Feature hooks * (`useSocketEvent`, `useChannel`, …) handle the null internally; for imperative * call sites that need the instance, use {@link useSharedWebSocketOrThrow}. * * @example * const ws = useSharedWebSocket(); * if (ws) ws.send('chat.message', { text: 'Hello' }); */ export declare function useSharedWebSocket(): SharedWebSocket | null; /** * Like {@link useSharedWebSocket} but asserts the instance exists. Use only at * imperative call sites that run after the provider has mounted (event handlers, * effects) — calling it during the first render will throw, since the socket is * not created until commit. * * @example * function SendButton() { * const ws = useSharedWebSocketOrThrow(); * return ; * } */ export declare function useSharedWebSocketOrThrow(): SharedWebSocket;