/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Environment } from "#environment/Environment.js"; import { Environmental } from "#environment/Environmental.js"; import type { HttpEndpoint } from "./HttpEndpoint.js"; /** * Environmental service for creating WebSocket client connections. * * Wraps the standard WebSocket API into {@link HttpEndpoint.WsConnection} stream pairs. Defaults to * `globalThis.WebSocket` but accepts a custom constructor for environments where it is unavailable (e.g. Node.js * without native WebSocket). */ export declare class WebSocketClient { #private; constructor(Ctor?: WebSocketClient.Constructor); /** * Open a WebSocket connection and return it as a {@link HttpEndpoint.WsConnection}. */ connect(url: string): Promise; static [Environmental.create](env: Environment): WebSocketClient; /** * Wrap an open standard WebSocket into a {@link HttpEndpoint.WsConnection}. */ static streams(ws: WebSocketClient.StandardWebSocket): HttpEndpoint.WsConnection; } export declare namespace WebSocketClient { /** * A standard WebSocket constructor. */ interface Constructor { new (url: string): StandardWebSocket; } /** * The subset of the standard WebSocket API we require. */ interface StandardWebSocket { binaryType: string; readonly readyState: number; send(data: string | ArrayBufferLike | ArrayBufferView): void; close(code?: number, reason?: string): void; addEventListener(type: string, listener: (event: any) => void): void; removeEventListener(type: string, listener: (event: any) => void): void; } } //# sourceMappingURL=WebSocketClient.d.ts.map