import type { WorkerConstructor } from '../worker-protocol';
/**
 * Creates a ref-counted Web Worker definition.
 *
 * The worker module should follow a specific communication protocol,
 * defined by `@reactodia/workspace/worker-protocol` module.
 *
 * **Example**:
 * ```
 * const worker = defineWorker(() => new Worker('./worker.js'), []);
 *
 * function Component() {
 *   const instance = useWorker(worker);
 *   ...
 * }
 * ```
 *
 * @category Utilities
 * @see {@link useWorker}
 */
export declare function defineWorker<T extends WorkerConstructor<unknown[], unknown>>(workerFactory: () => Worker, constructorArgs: ConstructorParameters<T>): WorkerDefinition<InstanceType<T>>;
declare const WORKER_CONSTRUCT: unique symbol;
declare const WORKER_STATE: unique symbol;
/**
 * Represents an opaque ref-counted Web Worker definition
 * created by {@link defineWorker}.
 *
 * @see {@link defineWorker}
 */
export interface WorkerDefinition<T> {
    /** @hidden */
    readonly [WORKER_CONSTRUCT]: () => RefCountedWorkerState<T>;
    /** @hidden */
    [WORKER_STATE]: RefCountedWorkerState<T> | undefined;
}
interface RefCountedWorkerState<T> {
    readonly instance: LazyWorkerProxy<T>;
    refCount: number;
}
/**
 * Gets a shared instance of the defined worker.
 *
 * The worker instance will be created on the first call and
 * disposed when the last component using the hook is unmounted.
 *
 * @category Hooks
 * @see {@link defineWorker}
 */
export declare function useWorker<T>(worker: WorkerDefinition<T>): T;
declare class LazyWorkerProxy<T> {
    private readonly workerFactory;
    private readonly constructorArgs;
    private static readonly PROXY_OWNER;
    private connectionState;
    private readonly methods;
    readonly proxy: T;
    constructor(workerFactory: () => Worker, constructorArgs: unknown[]);
    private getMethod;
    private ensureConnection;
    private connect;
    disconnect(): void;
}
export {};
//# sourceMappingURL=workers.d.ts.map