type WebsocketSettings = { protocols?: string | Array; url: string; }; type Communication = { message: string; answer: string; }; type Options = { // Websocket related settings (https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket) ws: WebsocketSettings; com: Communication; pingTimeout: number; pingInterval: number; retryInterval: number; }; declare class GracefulWebSocket { static readonly version: string; /** * I could extend / use EventTarget because it's best practice and made for * exactly this purpose. ES6 classes are nearly 5 years old so the extend * syntax + super() should work right? Nope, Safari is insanely stupid and * doesn't even follow the very basic RFC's regarding extending EventTarget. * Just because of this single browser doing whatever it wants and giving a shit about developers * (not everyone wants to buy a god damn mac) we have to take care about event-handling by ourself. * See https://stackoverflow.com/questions/36675693/eventtarget-interface-in-safari?noredirect=1&lq=1 */ private readonly _eventProxy; addEventListener: WebSocket['addEventListener']; dispatchEvent: WebSocket['dispatchEvent']; removeEventListener: WebSocket['removeEventListener']; private readonly _options; private _closed; private _websocket; private _connected; private _disconnectionTimeoutId; private _pingingTimeoutId; private _retryIntervalId; constructor(url: (Partial & { ws: WebsocketSettings; }) | string, ...protocols: Array); get pingInterval(): number; set pingInterval(value: number); get pingTimeout(): number; set pingTimeout(value: number); get retryInterval(): number; set retryInterval(value: number); get binaryType(): BinaryType | null; get bufferedAmount(): number | null; get extensions(): string | null; get protocol(): string | null; get readyState(): number | null; get url(): string | null; get connected(): boolean; send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void; close(code?: number, reason?: string): void; private start; private restart; } export { GracefulWebSocket as default };