import * as react_jsx_runtime from 'react/jsx-runtime'; import { ClientSocketManagerOptions, ClientSocketManager, ClientSocketManagerStub } from '@tapsioss/client-socket-manager'; declare const ConnectionStatus: { readonly CONNECTED: "connected"; readonly DISCONNECTED: "disconnected"; readonly RECONNECTING: "reconnecting"; }; type SocketContextValue = { /** * The socket client instance. */ socket: SocketInstance | SocketInstanceStub | null; /** * The connection status of the socket instance. */ connectionStatus: ConnectionStatusValues; }; /** * Type representing the union of all possible connection status values * defined in `ConnectionStatus`. */ type StatusType = typeof ConnectionStatus; /** * All valid connection state values for the socket client. */ type ConnectionStatusValues = StatusType[keyof StatusType]; /** * The default ClientSocketManager implementation used in production. */ type SocketInstance = ClientSocketManager; /** * A stubbed version of the ClientSocketManager, typically used in * testing or server-side rendering (SSR) environments. */ type SocketInstanceStub = ClientSocketManagerStub; /** * The return type of the `useSocketClient` hook, * derived from the context value shape. */ type SocketClientHookReturnType = SocketContextValue; /** * Props for the `SocketClientProvider` component. */ type SocketClientProviderProps = { /** * React children to render within the provider. */ children: React.ReactNode; /** * The URI to connect the socket client to. */ uri: string; /** * Optional flag indicating whether to use the stubbed version of * ClientSocketManager. This is useful for SSR or tests. */ shouldUseStub?: boolean; } & Partial; /** * React provider that initializes and manages a socket connection via `ClientSocketManager`. * * It optionally uses a stubbed socket manager in server-side rendering or testing environments. * The provider ensures a singleton instance per URI and updates the connection status accordingly. * * Properties: * - `children` (`React.ReactNode`): React children to render within the provider. * - `uri` (`string`): The URI to connect the socket client to. * - `shouldUseStub?` (`boolean`): Optional flag indicating whether to use the stubbed version of `ClientSocketManager` (useful for SSR or testing). * - Additional props from `ClientSocketManagerOptions` can be provided, such as `eventHandlers`, `reconnectionDelay`, etc. * * @param props - Props for the provider, including connection URI, stub flag, and socket manager options. * @returns A context provider that supplies the socket instance and its connection status. * * @example * ```tsx * * * * ``` */ declare const SocketClientProvider: (props: SocketClientProviderProps) => react_jsx_runtime.JSX.Element; /** * A React hook that provides access to the current socket client instance and its connection status. * * This hook must be used within a ``, otherwise it will throw an error. * * @throws Will throw an error if used outside of a ``. * * @returns {SocketClientHookReturnType} An object containing the socket client instance and its connection status. * * @example * ```tsx * const { socket, connectionStatus } = useSocketClient(); * if (socket?.connected) { * socket.emit("message", { text: "Hello" }); * } * ``` */ declare const useSocketClient: () => SocketClientHookReturnType; export { ConnectionStatus, type ConnectionStatusValues, type SocketClientHookReturnType, SocketClientProvider, type SocketClientProviderProps, type SocketInstance, useSocketClient };