UNPKG

@wandelbots/nova-js

Version:

Official JS client for the Wandelbots API

57 lines (56 loc) 1.93 kB
import ReconnectingWebSocket from "reconnecting-websocket"; import { AxiosResponse, InternalAxiosRequestConfig } from "axios"; //#region src/lib/mock/MockNovaInstance.d.ts /** * Ultra-simplified mock Nova server for testing stuff */ declare class MockNovaInstance { readonly connections: AutoReconnectingWebsocket[]; handleAPIRequest(config: InternalAxiosRequestConfig): Promise<AxiosResponse>; handleWebsocketConnection(socket: AutoReconnectingWebsocket): void; handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string): void; } //#endregion //#region src/lib/AutoReconnectingWebsocket.d.ts declare class AutoReconnectingWebsocket extends ReconnectingWebSocket { receivedFirstMessage?: MessageEvent; targetUrl: string; disposed: boolean; readonly opts: { mock?: MockNovaInstance; onDispose?: () => void; }; constructor(targetUrl: string, opts?: { mock?: MockNovaInstance; onDispose?: () => void; }); changeUrl(targetUrl: string): void; sendJson(data: unknown): void; /** * Permanently close this websocket and indicate that * this object should not be used again. **/ dispose(): void; /** * Returns a promise that resolves once the websocket * is in the OPEN state. */ opened(): Promise<void>; /** * Returns a promise that resolves once the websocket * is in the CLOSED state. */ closed(): Promise<void>; /** * Returns a promise that resolves when the first message * is received from the websocket. Resolves immediately if * the first message has already been received. */ firstMessage(): Promise<MessageEvent<any>>; /** * Returns a promise that resolves when the next message * is received from the websocket. */ nextMessage(): Promise<MessageEvent<any>>; } //#endregion export { MockNovaInstance as n, AutoReconnectingWebsocket as t }; //# sourceMappingURL=AutoReconnectingWebsocket-BSt-vnzX.d.mts.map