/** * useMessageRouter Hook * TASKSET 9 Phase 8: Enhanced WebSocket hook with MessageRouter topic-based subscriptions * * Extends useWebSocket with MessageRouter-specific functionality: * - Topic-based subscriptions (document, user, workspace, system, presence) * - Type-safe message handling for Relay events * - Automatic subscription management */ type TopicType = 'document' | 'user' | 'workspace' | 'system' | 'presence'; interface Topic { type: TopicType; id: string; } interface RelayMessage { type: string; data?: unknown; topic_type?: TopicType; topic_id?: string; [key: string]: any; } type TopicEventHandler = (payload: any) => void; interface Subscription { topic: Topic; subscribedAt: Date; } interface SubscriptionError { topic: Topic; error: Error; timestamp: Date; } export interface UseMessageRouterOptions { url: string; autoConnect?: boolean; reconnectInterval?: number; maxReconnectAttempts?: number; onConnected?: () => void; onDisconnected?: () => void; onError?: (error: Error) => void; } export interface UseMessageRouterReturn { isConnected: boolean; subscribe: (topicType: TopicType, topicId: string) => void; unsubscribe: (topicType: TopicType, topicId: string) => void; subscriptions: Subscription[]; onTopicEvent: (topicType: TopicType, topicId: string, handler: TopicEventHandler) => () => void; onEvent: (eventType: string, handler: (payload: any) => void) => () => void; errors: SubscriptionError[]; clearErrors: () => void; send: (message: RelayMessage) => void; connect: () => void; disconnect: () => void; } /** * Enhanced WebSocket hook with MessageRouter topic-based subscriptions */ export declare const useMessageRouter: (options: UseMessageRouterOptions) => UseMessageRouterReturn; export {}; //# sourceMappingURL=useMessageRouter.d.ts.map