/**
 * WebSocket connection wrapper for the UI Bridge server.
 *
 * Manages a single WebSocket connection after the HTTP upgrade handshake,
 * handling frame-level I/O, heartbeat, and event subscriptions.
 */
import type { JsonRpcEvent } from './ws-types';
/**
 * Callback for text messages received from the client.
 * Returns a response string to send back, or null for no response.
 */
export type WebSocketMessageHandler = (connId: string, message: string) => Promise<string | null>;
export declare class WebSocketConnection {
    readonly id: string;
    readonly subscriptions: Set<string>;
    /** Heartbeat liveness flag — set false before ping, set true on pong */
    alive: boolean;
    private socket;
    private buffer;
    private fragmentBuffer;
    private fragmentOpcode;
    private closed;
    private onMessage;
    private onClose;
    constructor(id: string, socket: WebSocketConnection['socket'], onMessage: WebSocketMessageHandler, onClose: (connId: string) => void);
    /** Send a text message to the client. */
    send(message: string): void;
    /**
     * Send an event if the client is subscribed to it. Subscription patterns
     * may be exact event names, `*` (all), or glob patterns containing `*`
     * (e.g. `element:*`, `*:stateChanged`). Exact matches and `*` are checked
     * via fast Set lookups; glob patterns fall through to a regex test.
     */
    sendEvent(event: JsonRpcEvent): void;
    private matchesSubscription;
    /** Send a ping frame for heartbeat. */
    ping(): void;
    /** Close the connection gracefully. */
    close(code?: number, reason?: string): void;
    /** Forcefully destroy the connection without a close frame. */
    destroy(): void;
    /** Whether the connection is still open. */
    get isOpen(): boolean;
    private writeRaw;
    private handleData;
    private handleFrame;
}
//# sourceMappingURL=ws-connection.d.ts.map