type FN = (...args: any[]) => any; type MessageExec = { type: 'exec'; method: string; args: unknown[]; }; type MessageLog = { type: 'log'; value: string; }; type MessageReady = { type: 'ready'; }; type MessageResultSuccess = { type: 'result'; value: unknown; }; type MessageResultError = { type: 'result'; error: { name: string; message: string; stack: string; }; }; type MessageResult = MessageResultSuccess | MessageResultError; type Message = MessageExec | MessageLog | MessageReady | MessageResult; type Methods = Record; type MethodsNames = keyof T extends string ? keyof T : never; type MethodsFunctions = T[keyof T]; type MethodsProxied = { [K in Exclude]: (...args: Parameters) => Promise>>; }; type MethodFunction> = T[U]; type MethodArguments> = Parameters>; type MethodReturn> = ReturnType>; type MethodProxied = (...args: Parameters) => Promise>>; type Env = Partial<{ [key: string]: string; }>; type ExecOptions = { signal?: AbortSignal; timeout?: number; transfer?: Transferable[]; }; type Options = { pool?: { name?: string; size?: number; }; worker: { autoAbort?: number; autoInstantiate?: boolean; autoTerminate?: number; env?: Env; methods: T | URL | string; }; }; type Stats = { tasks: { busy: number; idle: number; total: number; }; workers: { busy: number; idle: number; total: number; }; }; type Task = MethodsNames> = { method: U; args: MethodArguments; signal?: AbortSignal; timeout: number; transfer?: Transferable[]; promise: Promise>>; resolve: (result: MethodReturn) => void; reject: (error: Error) => void; }; export type { MessageExec, MessageLog, MessageReady, MessageResult, Message }; export type { Methods, MethodsNames, MethodsFunctions, MethodsProxied, MethodFunction, MethodArguments, MethodReturn, MethodProxied }; export type { Env, ExecOptions, Options, Stats, Task };