/** * RelayProvider * Provides a shared WebSocket connection to the Relay service * * This provider ensures that all hooks using the Relay service * share a single WebSocket connection instead of creating multiple * independent connections. */ import React, { type ReactNode } from 'react'; interface RelayMessage { type: string; data?: unknown; topic_type?: string; topic_id?: string; [key: string]: unknown; } type TopicType = 'document' | 'user' | 'workspace' | 'system' | 'presence'; type TopicEventHandler = (payload: unknown) => void; interface Subscription { topicType: TopicType; topicId: string; subscribedAt: Date; } interface RelayContextValue { isConnected: boolean; connectionError: Error | null; subscribe: (topicType: TopicType, topicId: string) => void; unsubscribe: (topicType: TopicType, topicId: string) => void; subscriptions: Subscription[]; onTopicEvent: (topicType: TopicType, topicId: string, handler: TopicEventHandler) => () => void; send: (message: RelayMessage) => void; connect: () => void; disconnect: () => void; } export interface RelayProviderProps { children: ReactNode; /** WebSocket URL (optional, will auto-detect if not provided) */ wsUrl?: string; /** Auto-connect on mount (default: true) */ autoConnect?: boolean; /** Reconnect interval in ms (default: 3000) */ reconnectInterval?: number; /** Max reconnect attempts (default: 5) */ maxReconnectAttempts?: number; /** Called when connected */ onConnected?: () => void; /** Called when disconnected */ onDisconnected?: () => void; /** Called on error */ onError?: (error: Error) => void; } /** * Provider component that manages a single WebSocket connection to the Relay service */ export declare const RelayProvider: React.FC; /** * Hook to access the Relay connection from the provider */ export declare const useRelay: () => RelayContextValue; /** * Hook to check if we're inside a RelayProvider */ export declare const useRelayOptional: () => RelayContextValue | null; export type { TopicType, RelayMessage, RelayContextValue }; //# sourceMappingURL=RelayProvider.d.ts.map