import { Worker as WorkerThread, WorkerOptions, MessagePort } from 'worker_threads'; import { Serializable, SerializableInput } from '../types'; export interface WorkerThreadOptions extends WorkerOptions { /** Data to send to the cluster. */ clusterData?: NodeJS.ProcessEnv | undefined; } export declare class Worker { private file; /** The worker process. */ process: WorkerThread | null; /** The options for the worker process. */ workerOptions: WorkerOptions; /** Type-safe listener manager */ private _listeners; /** Creates an instance of Worker. */ constructor(file: string, options: WorkerThreadOptions); /** Spawns the worker. */ spawn(): WorkerThread; /** Respawns the worker. */ respawn(): Promise; /** Kills the worker with proper cleanup. */ kill(): Promise; /** Clean up worker and listeners */ private _cleanup; /** Sends a message to the worker. */ send(message: SerializableInput | unknown): Promise; } /** Worker client class. */ export declare class WorkerClient { /** The IPC port of the worker. */ readonly ipc: MessagePort | null; /** Creates an instance of WorkerClient. */ constructor(); /** Sends a message to the worker. */ send(message: SerializableInput | unknown): Promise; }