42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
type callModule = typeof import("libkmodule").callModule;
|
|
type connectModule = typeof import("libkmodule").connectModule;
|
|
type logErr = typeof import("libkmodule").logErr;
|
|
type log = typeof import("libkmodule").log;
|
|
import type { ErrTuple, DataFn } from "@siaweb/libweb";
|
|
import EventEmitter from "eventemitter3";
|
|
type callModuleBound = (method: string, data?: any) => Promise<ErrTuple>;
|
|
type connectModuleBound = (method: string, data: any, receiveUpdate: DataFn) => [sendUpdate: DataFn, response: Promise<ErrTuple>];
|
|
declare let callModule: callModule;
|
|
declare let connectModule: connectModule;
|
|
declare let log: log;
|
|
declare let logErr: logErr;
|
|
export interface ModuleBag {
|
|
callModule: callModule;
|
|
connectModule: connectModule;
|
|
log: log;
|
|
logErr: logErr;
|
|
}
|
|
export interface ModuleBagBound extends ModuleBag {
|
|
callModule: callModuleBound;
|
|
connectModule: connectModuleBound;
|
|
}
|
|
export declare abstract class Client extends EventEmitter {
|
|
private _callModule?;
|
|
get callModule(): callModuleBound;
|
|
private _log?;
|
|
get log(): log;
|
|
private _logErr?;
|
|
get logErr(): logErr;
|
|
private _connectModule?;
|
|
get connectModule(): connectModuleBound;
|
|
loadLibs(module: string): Promise<void>;
|
|
loadBound(module: string): Promise<ModuleBagBound>;
|
|
protected handleError(ret: ErrTuple): void;
|
|
protected handleErrorOrReturn(ret: ErrTuple): any;
|
|
protected callModuleReturn(method: string, data?: any): Promise<any>;
|
|
}
|
|
export declare function load(module?: string): Promise<ModuleBag | ModuleBagBound>;
|
|
type ClientConstructor<U> = new (...args: any[]) => U;
|
|
export declare const factory: <T extends Client = Client>(type: ClientConstructor<T>, module: string) => (...args: any) => T;
|
|
export {};
|
|
//# sourceMappingURL=index.d.ts.map
|