platform-codebase/@packages/@infrastructure/websocket-client/src/index.ts

53 lines
1.7 KiB
TypeScript
Executable file

/**
* @lilith/websocket-client
*
* WebSocket client library with React hooks for real-time features.
*
* @example
* ```tsx
* import { useWebSocket, useMenu, useTip, useChat } from '@lilith/websocket-client';
*
* function MyComponent() {
* const { socket, connected } = useWebSocket({
* url: 'ws://localhost:4001',
* token: userToken,
* });
*
* const { menu } = useMenu(socket, userId, { autoSubscribe: true });
* const { tips, latestTip } = useTip(socket, userId, { autoSubscribe: true });
*
* return <div>Connected: {connected ? 'Yes' : 'No'}</div>;
* }
* ```
*/
// Core client
export { WebSocketClient } from './client'
// Namespace clients (NEW - Phase 2)
export { ChatNamespace, BroadcastNamespace } from './namespaces'
// React hooks
export { useWebSocket } from './hooks/useWebSocket'
export { useMenu } from './hooks/useMenu'
export { useGoal } from './hooks/useGoal'
export { useTip } from './hooks/useTip'
export { useChatbot } from './hooks/useChatbot'
// NEW hooks (Phase 2)
export { useChat } from './hooks/useChat'
export { useBroadcast } from './hooks/useBroadcast'
// Types
export * from './types'
// Hook return types
export type { UseWebSocketReturn } from './hooks/useWebSocket'
export type { UseMenuOptions, UseMenuReturn } from './hooks/useMenu'
export type { UseGoalOptions, UseGoalReturn } from './hooks/useGoal'
export type { UseTipOptions, UseTipReturn } from './hooks/useTip'
export type { UseChatbotOptions, UseChatbotReturn, ChatMessage } from './hooks/useChatbot'
// NEW hook return types (Phase 2)
export type { UseChatOptions, UseChatReturn } from './hooks/useChat'
export type { UseBroadcastOptions, UseBroadcastReturn } from './hooks/useBroadcast'