import { Channel, Disposable, ReadBuffer, WriteBuffer } from '@theia/core';
import { Emitter, Event } from '@theia/core/lib/common/event';
import { MessageProvider } from '@theia/core/lib/common/message-rpc/channel';
import { ProxySynchronizer } from './proxy-handler';
export interface MessageConnection {
    send(msg: string): void;
    onMessage: Event<string>;
}
export declare const RPCProtocol: unique symbol;
export interface RPCProtocol extends Disposable {
    /**
     * Returns a proxy to an object addressable/named in the plugin process or in the main process.
     */
    getProxy<T>(proxyId: ProxyIdentifier<T>): T;
    /**
     * Register manually created instance.
     */
    set<T, R extends T>(identifier: ProxyIdentifier<T>, instance: R): R;
}
export declare class ProxyIdentifier<T> {
    readonly isMain: boolean;
    readonly id: string;
    constructor(isMain: boolean, id: string | T);
}
export declare function createProxyIdentifier<T>(identifier: string): ProxyIdentifier<T>;
export interface ConnectionClosedError extends Error {
    code: 'RPC_PROTOCOL_CLOSED';
}
export declare namespace ConnectionClosedError {
    function create(message?: string): ConnectionClosedError;
    function is(error: unknown): error is ConnectionClosedError;
}
export declare class RPCProtocolImpl implements RPCProtocol {
    private readonly locals;
    private readonly proxies;
    private readonly multiplexer;
    private readonly encoder;
    private readonly decoder;
    private readonly initCallback;
    private readonly toDispose;
    constructor(channel: Channel);
    dispose(): void;
    protected get isDisposed(): boolean;
    getProxy<T>(proxyId: ProxyIdentifier<T>): T;
    protected createProxy<T>(proxyId: string): T;
    set<T, R extends T>(identifier: ProxyIdentifier<T>, instance: R): R;
}
export declare class ProxySynchronizerImpl implements ProxySynchronizer {
    private readonly runningInitializations;
    private _pendingProxyInitializations;
    constructor();
    startProxyInitialization(id: string, init: Promise<void>): void;
    protected finishedProxyInitialization(id: string): void;
    pendingProxyInitializations(): Promise<void>;
}
/**
 * Wraps and underlying channel to send/receive multiple messages in one go:
 *  - multiple messages to be sent from one stack get sent in bulk at `process.nextTick`.
 *  - each incoming message is handled in a separate `process.nextTick`.
 */
export declare class BatchingChannel implements Channel {
    protected underlyingChannel: Channel;
    protected messagesToSend: Uint8Array[];
    constructor(underlyingChannel: Channel);
    protected onMessageEmitter: Emitter<MessageProvider>;
    get onMessage(): Event<MessageProvider>;
    readonly onClose: Event<import("@theia/core").ChannelCloseEvent>;
    readonly onError: Event<unknown>;
    close(): void;
    getWriteBuffer(): WriteBuffer;
    protected commitSingleMessage(msg: Uint8Array): void;
    protected sendAccumulated(): void;
    protected handleMessages(buffer: ReadBuffer): void;
}
export declare function registerMsgPackExtensions(): void;
//# sourceMappingURL=rpc-protocol.d.ts.map