@wandelbots/nova-js
Version:
Official JS client for the Wandelbots API
69 lines (67 loc) • 2.45 kB
text/typescript
import ReconnectingWebSocket from "reconnecting-websocket";
import { AxiosResponse, InternalAxiosRequestConfig } from "axios";
//#region src/lib/v1/mock/MockNovaInstance.d.ts
/**
* Ultra-simplified mock Nova server for testing stuff
*/
declare class MockNovaInstance$1 {
readonly connections: AutoReconnectingWebsocket[];
handleAPIRequest(config: InternalAxiosRequestConfig): Promise<AxiosResponse>;
handleWebsocketConnection(socket: AutoReconnectingWebsocket): void;
handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string): void;
}
//#endregion
//#region src/lib/v2/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 {
readonly opts: {
mock?: MockNovaInstance$1 | MockNovaInstance;
onDispose?: () => void;
};
receivedFirstMessage?: MessageEvent;
targetUrl: string;
disposed: boolean;
constructor(targetUrl: string, opts?: {
mock?: MockNovaInstance$1 | 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, MockNovaInstance$1 as r, AutoReconnectingWebsocket as t };
//# sourceMappingURL=AutoReconnectingWebsocket-Qcrbm3Kb.d.cts.map