import { ServiceIdentifier, PluginModule, Store } from 'reactant';
import { Transport, type TransportOptions } from 'data-transport';
import type { ILastActionData } from 'reactant-last-action';
import { PortDetector } from './portDetector';
import { Storage } from './storage';
import { proxyWorkerExecuteName, syncStateName, requestSyncAllStateName, pushAllStateName } from '../constants';
import type { ProxyExecParams, SymmetricTransport } from '../interfaces';
type State = Record<string, Record<string, unknown>>;
interface Module<T> extends Function {
    new (...args: any[]): T;
}
type ProxyExecutorInteraction = {
    [proxyWorkerExecuteName]: (execParams: ProxyExecParams) => Promise<unknown>;
    [syncStateName]: (action: ILastActionData, sequence: number) => Promise<void>;
    [requestSyncAllStateName]: () => Promise<void>;
    [pushAllStateName]: (options: {
        state: State;
        sequence: number;
    }) => Promise<void>;
};
export interface ICoworkerOptions {
    /**
     * Importing the injected dependency modules.
     */
    useModules: ServiceIdentifier<unknown>[];
    /**
     *  Whether the current thread is the coworker thread.
     */
    isCoworker: boolean;
    /**
     * Specify a SharedWorker for coworker.
     */
    worker?: SharedWorker | Worker;
    /**
     * Enable transport debugger for coworker.
     */
    enableTransportDebugger?: boolean;
    /**
     * Logger for coworker.
     */
    logger?: TransportOptions['logger'];
    /**
     * coworker transports
     */
    transports?: {
        main?: Transport;
        coworker?: Transport;
    };
    /**
     * Ignore sync state key in all proxy modules on coworker and main thread.
     */
    ignoreSyncStateKeys?: string[];
    /**
     * Enable patches checker for cross-module state update on coworker.
     */
    enablePatchesChecker?: boolean;
}
export declare const CoworkerOptions: unique symbol;
export declare class Coworker extends PluginModule {
    protected portDetector: PortDetector;
    protected coworkerOptions: ICoworkerOptions;
    protected storage?: Storage | undefined;
    protected proxyModules: ServiceIdentifier<unknown>[];
    protected proxyModuleKeys: string[];
    protected ignoreSyncStateKeys: string[];
    transport?: SymmetricTransport<ProxyExecutorInteraction>;
    constructor(portDetector: PortDetector, coworkerOptions: ICoworkerOptions, storage?: Storage | undefined);
    protected createTransport(): SymmetricTransport<ProxyExecutorInteraction> | undefined;
    protected get prefix(): string;
    get name(): any;
    /**
     * Whether the current thread is the coworker thread.
     */
    get isCoworker(): boolean;
    /**
     * Whether the current thread is the main thread.
     */
    get isMain(): boolean;
    /**
     * Add proxy modules.
     */
    addProxyModules(modules: ServiceIdentifier<unknown>[]): void;
    /**
     * Add ignore sync state keys
     */
    addIgnoreSyncStateKeys(keys: string[]): void;
    protected get enablePatchesChecker(): boolean;
    afterCreateStore: (store: Store) => Store;
    protected get ref(): any;
    protected sequence: number;
    protected applyProxyState(): void;
    protected pushAllState(): void;
    protected handleSyncAllState(options: {
        state: State;
        sequence: number;
    }): void;
    protected requestSyncAllState(): void;
    protected ignoreStates(state: State, currentState: State): void;
    protected applyProxyExecute(): void;
    protected applyProxyModules(proxyModules: ServiceIdentifier<unknown>[]): void;
}
export declare const createCoworker: (name: string) => [Module<Coworker>, symbol];
export declare const getCoworker: (instance: object) => Coworker | undefined;
export {};
//# sourceMappingURL=coworker.d.ts.map