import type { Observable } from "rxjs"; export type Fn = (...params: Params) => Return; /** * Mapped type that transforms a worker configuration into a client-side API. * * @remarks * This type recursively maps the worker's configuration. Functions are transformed * to return Promises (for one-off results) or Observables (for streams). * * @template Config - The worker configuration type. */ export type RpcClient = { [Key in keyof Config]: Config[Key] extends (...args: any[]) => any ? Config[Key] extends Fn ? R extends Observable ? Fn : Fn>> : never : RpcClient; }; export type PostMessage = (message: any, transfer: Transferable[]) => void;