// node native import type * as http from 'http'; import type * as https from 'https'; export type { http, https }; // third party scope - ws types import type * as wsTypes from 'ws'; export namespace ws { export type WebSocket = wsTypes.WebSocket; export type WebSocketServer = wsTypes.WebSocketServer; export type RawData = wsTypes.RawData; } // smartserve compatibility interface (for setExternalServer) // This mirrors the IWebSocketPeer interface from smartserve export interface ISmartserveWebSocketPeer { id: string; url: string; readyState: 0 | 1 | 2 | 3; protocol: string; extensions: string; send(data: string): void; sendBinary(data: Uint8Array | ArrayBuffer): void; close(code?: number, reason?: string): void; ping(data?: Uint8Array): void; terminate(): void; context: any; data: Map; tags: Set; } export interface ISmartserveWebSocketMessage { type: 'text' | 'binary'; text?: string; data?: Uint8Array; size: number; } export interface ISmartserveWebSocketHooks { onOpen?: (peer: ISmartserveWebSocketPeer) => void | Promise; onMessage?: (peer: ISmartserveWebSocketPeer, message: ISmartserveWebSocketMessage) => void | Promise; onClose?: (peer: ISmartserveWebSocketPeer, code: number, reason: string) => void | Promise; onError?: (peer: ISmartserveWebSocketPeer, error: Error) => void | Promise; }