UNPKG

@cossistant/next

Version:

Next.js-ready SDK for building AI-powered support/chat widgets. Hooks + primitives, WS-driven, TypeScript-first. Next.js-ready, Tailwind optional.

61 lines (60 loc) 1.73 kB
import React from "react"; //#region ../react/src/realtime/provider.d.ts type SubscribeHandler = (event: AnyRealtimeEvent) => void; type VisitorAuthConfig = { kind: "visitor"; visitorId: string | null; websiteId?: string | null; publicKey?: string | null; }; type SessionAuthConfig = { kind: "session"; sessionToken: string | null; websiteId?: string | null; userId?: string | null; }; type RealtimeAuthConfig = VisitorAuthConfig | SessionAuthConfig; type RealtimeProviderProps = { children: React.ReactNode; wsUrl?: string; auth: RealtimeAuthConfig | null; autoConnect?: boolean; onConnect?: () => void; onDisconnect?: () => void; onError?: (error: Error) => void; }; type RealtimeConnectionState = { isConnected: boolean; isConnecting: boolean; error: Error | null; send: (event: AnyRealtimeEvent) => void; sendRaw: (data: string) => void; subscribe: (handler: SubscribeHandler) => () => void; lastEvent: AnyRealtimeEvent | null; connectionId: string | null; reconnect: () => void; }; type RealtimeContextValue = RealtimeConnectionState & { visitorId: string | null; websiteId: string | null; userId: string | null; }; /** * Provides websocket connectivity and heartbeating logic for realtime events. */ declare function RealtimeProvider({ children, wsUrl, auth, autoConnect, onConnect, onDisconnect, onError }: RealtimeProviderProps): React.ReactElement; /** * Returns the realtime connection context. */ declare function useRealtimeConnection(): RealtimeContextValue; //#endregion export { type RealtimeAuthConfig, type RealtimeContextValue, RealtimeProvider, type RealtimeProviderProps, useRealtimeConnection }; //# sourceMappingURL=provider3.d.ts.map