import { BaseTelegramClient } from '../base.js'; import { RespondFn, WorkerCustomMethods, WorkerMessageHandler } from './protocol.js'; export interface TelegramWorkerOptions { client: BaseTelegramClient; /** mtcute worker ID to disambiguate multiple clients within the same underlying worker */ workerId?: string; /** * What to do when the last connection to the worker is closed? * * - `destroy`: destroy the client, terminating the worker * - `disconnect`: disconnect the client, but keep the worker running until `forceDestroy` is called * - `nothing`: do nothing, lifecycle is managed manually * - function: call this function when the last connection is closed, then execute the action returned by the function * * @default 'nothing' */ onLastDisconnected?: 'destroy' | 'disconnect' | 'nothing' | (() => 'destroy' | 'disconnect' | 'nothing'); /** additional custom methods to expose */ customMethods?: T; } export declare abstract class TelegramWorker { readonly params: TelegramWorkerOptions; readonly client: BaseTelegramClient; broadcast: RespondFn; private _cleanup; private _heartbeatSweep; private _mounted; abstract registerWorker(handler: WorkerMessageHandler): [RespondFn, VoidFunction]; readonly activeConnections: Set; readonly connectionLastSeen: Map; readonly pendingAborts: Map>; readonly workerId: string; private _disconnecting?; private _destroying?; constructor(params: TelegramWorkerOptions); mount(): this; private getConnectionAborts; private deletePendingAbort; private touchConnection; private respondConnectionExpired; private sweepExpiredConnections; private onRelease; private disconnectSharedClient; private forceDestroy; private shouldSyncCurrentUser; private onInvoke; destroy(): void; }