/**
 * WebSocket Handler
 *
 * Handles WebSocket connections, message parsing, and subscription management.
 */
import type { SubscriptionChannel, ServerMessage } from '@stoneforge/shared-routes';
import { type EventListener } from './broadcaster.js';
/**
 * Runtime-agnostic ServerWebSocket type (replaces bun's ServerWebSocket)
 */
type ServerWebSocket<T> = {
    data: T;
    send(data: string | ArrayBuffer): void;
    close(): void;
    readyState: number;
};
/**
 * Client data stored with each WebSocket connection
 */
export interface ClientData {
    id: string;
    subscriptions: Set<SubscriptionChannel>;
    eventListener: EventListener;
}
/**
 * Handle a new WebSocket connection
 */
export declare function handleOpen(ws: ServerWebSocket<ClientData>): void;
/**
 * Handle WebSocket message from client
 */
export declare function handleMessage(ws: ServerWebSocket<ClientData>, data: string | Buffer): void;
/**
 * Handle WebSocket connection close
 */
export declare function handleClose(ws: ServerWebSocket<ClientData>): void;
/**
 * Handle WebSocket error
 */
export declare function handleError(ws: ServerWebSocket<ClientData>, error: Error): void;
/**
 * Get the number of connected clients
 */
export declare function getClientCount(): number;
/**
 * Broadcast a message to all connected clients
 */
export declare function broadcastToAll(message: ServerMessage): void;
/**
 * Broadcast an inbox event to subscribed clients
 * Sends to clients subscribed to 'inbox', 'inbox:${recipientId}', or '*'
 */
export declare function broadcastInboxEvent(itemId: string, recipientId: string, eventType: 'created' | 'updated' | 'deleted', oldValue: Record<string, unknown> | null, newValue: Record<string, unknown> | null, actor?: string): void;
export {};
//# sourceMappingURL=handler.d.ts.map