70 lines
2.7 KiB
TypeScript
70 lines
2.7 KiB
TypeScript
/**
|
|
* src/ws — WebSocket module entry point.
|
|
*
|
|
* Public API:
|
|
* - Types: all Rust → TS type mappings via `./types`
|
|
* - Client: WsClient class (socket.io / raw-ws dual mode)
|
|
* - Hooks: React hooks for event subscription, room management, typing
|
|
* - Auth: WS token authentication
|
|
* - Constants: protocol constants
|
|
* - Bridge: Socket.IO server bridge (Node.js side)
|
|
*/
|
|
|
|
// ── Client ──────────────────────────────────────────────
|
|
export { WsClient } from './client';
|
|
export type { ConnectionStatus, WsClientConfig } from './client';
|
|
|
|
// ── Hooks ───────────────────────────────────────────────
|
|
export {
|
|
initWsClient,
|
|
getWsClient,
|
|
useWsInit,
|
|
useWsStatus,
|
|
useWsConnected,
|
|
useWsError,
|
|
useWsEvent,
|
|
useRoomSubscription,
|
|
useSubscribedRooms,
|
|
useTypingIndicator,
|
|
useNotificationCount,
|
|
useRoomSender,
|
|
} from './hooks';
|
|
export type { UseWsInitOptions, TypingUser } from './hooks';
|
|
|
|
// ── Store ───────────────────────────────────────────────
|
|
export { useWsStore } from './store';
|
|
export type { WsState, WsActions } from './store';
|
|
|
|
// ── Auth ────────────────────────────────────────────────
|
|
export { fetchWsToken, invalidateWsToken } from './auth';
|
|
export type { WsTokenResponse } from './auth';
|
|
|
|
// ── Constants ───────────────────────────────────────────
|
|
export {
|
|
HEARTBEAT_INTERVAL_MS,
|
|
HEARTBEAT_TIMEOUT_MS,
|
|
MAX_IDLE_TIMEOUT_MS,
|
|
CLIENT_PING_INTERVAL_MS,
|
|
MAX_MESSAGES_PER_SECOND,
|
|
MAX_TEXT_MESSAGE_LEN,
|
|
DEDUP_WINDOW_MS,
|
|
RECONNECT_BASE_DELAY_MS,
|
|
RECONNECT_MAX_DELAY_MS,
|
|
RECONNECT_MAX_ATTEMPTS,
|
|
DEFAULT_WS_PATH,
|
|
WS_TOKEN_ENDPOINT,
|
|
WS_TOKEN_TTL_SECONDS,
|
|
SSE_AI_STREAM_PATTERN,
|
|
} from './constants';
|
|
|
|
// ── Infrastructure ──────────────────────────────────────
|
|
export { TypedEventEmitter } from './emitter';
|
|
export { RoomSubscriptionManager } from './subscription';
|
|
export { ReconnectManager } from './reconnect';
|
|
export type { ReconnectState } from './reconnect';
|
|
export { DedupManager } from './dedup';
|
|
|
|
export { WS_PROTOCOL_VERSION } from './constants';
|
|
|
|
// ── Types ───────────────────────────────────────────────
|
|
export type * from './types'; |