import { WorkerOptions } from 'worker_threads'; export type RpcRequest = { id: number; fn: string; args: any[]; }; export type RpcResponse = { id: number; res?: any; err?: Error; }; /** * Holds promises for RPC requests and resolves them when the call completes. */ export declare class RcpResponseHandler { private nextId; private readonly handlers; createHandler(): { id: number; result: Promise; }; handleResponse(response: RpcResponse): void; /** * Handle an unexpected error by logging it and rejecting all handlers. */ handleError(err: Error): void; clear(): void; } export type RpcProxy = { [K in keyof ProxyType]: ProxyType[K] extends ((...args: infer Args) => infer R) ? (...args: Args) => Promise> : never; }; export declare function createRpcProxy(remoteCall: (name: string, args: any[]) => Promise): RpcProxy; export declare class WorkerWithRpcProxy { private readonly worker; private readonly responseHandler; readonly proxy: RpcProxy; constructor(workerPath: string, workerOptions?: WorkerOptions, host?: HostProxyType); terminate(): void; /** * Handle an unexpected error by logging it and rejecting all handlers. */ private handleError; } //# sourceMappingURL=worker.d.ts.map