/** * Shared WebSocket connection implementation. * Used by browser, Node, and Bun transport adapters. */ import { type ConnectionId } from "@sideband/protocol"; import { type CloseInfo, type CloseOptions, type ConnectionState, type TransportConnection, type TransportEndpoint } from "@sideband/transport"; import type { IoBytes, WsLimits } from "./types.js"; /** * Options for creating a WsConnection. */ export interface WsConnectionInit { /** The WebSocket instance */ ws: WebSocket; /** Connection endpoint (for diagnostics) */ endpoint: TransportEndpoint; /** Negotiated subprotocol */ subprotocol?: string; /** Connection limits */ limits?: WsLimits; } /** * Shared WebSocket connection implementation. * Implements TransportConnection interface with: * - State management with monotonic transitions * - Send ordering and backpressure (buffer_overflow on limit exceeded) * - Inbound iterator with single-consumer enforcement * - Traffic diagnostics (ioBytes) for error classification */ export declare class WsConnection implements TransportConnection { readonly id: ConnectionId; readonly endpoint: TransportEndpoint; readonly subprotocol?: string; private readonly _ws; private readonly _limits; private _state; private _ioBytes; private _closeInfo; private readonly _closedPromise; private _resolveClose; private _iteratorActive; private _inboundQueue; private _inboundBufferBytes; private _inboundResolve; private _inboundClosed; constructor(init: WsConnectionInit); get state(): ConnectionState; get closed(): Promise; get pendingSendBytes(): number; /** Traffic diagnostics for error classification */ get ioBytes(): IoBytes; get inbound(): AsyncIterable; send(bytes: Uint8Array): Promise; close(options?: CloseOptions): Promise; /** Mark connection as open (called by transport after handshake) */ _markOpen(): void; private _setupEventHandlers; private _handleClose; private _createIterator; } //# sourceMappingURL=connection.d.ts.map