import { IRPCProtocol } from '@opensumi/ide-connection';
import { Emitter, Event, IDisposable } from '@opensumi/ide-core-common';
import { ICreateContributedTerminalProfileOptions, ITerminalChildProcess, ITerminalDimensionsDto, ITerminalDimensionsOverride, ITerminalExitEvent, ITerminalInfo, ITerminalLaunchError, ITerminalLinkDto, ITerminalProfile } from '@opensumi/ide-terminal-next';
import { ISerializableEnvironmentVariableCollection } from '@opensumi/ide-terminal-next/lib/common/environmentVariable';
import { IExtension } from '../../../common';
import { IExtHostTerminal, IExtensionDescription, IMainThreadTerminal } from '../../../common/vscode';
import type vscode from 'vscode';
export declare class ExtHostTerminal implements IExtHostTerminal {
    private shell;
    private proxy;
    private changeActiveTerminalEvent;
    private closeTerminalEvent;
    private openTerminalEvent;
    private terminalStateChangeEvent;
    private onDidChangeShellEvent;
    private terminalsMap;
    private _terminalDeferreds;
    private readonly _linkProviders;
    private readonly _terminalLinkCache;
    private readonly _terminalLinkCancellationSource;
    private readonly _profileProviders;
    private _defaultProfile;
    private _defaultAutomationProfile;
    private environmentVariableCollections;
    private disposables;
    private readonly _bufferer;
    protected _terminalProcesses: Map<string, ITerminalChildProcess>;
    protected _terminalProcessDisposables: {
        [id: number]: IDisposable;
    };
    protected _extensionTerminalAwaitingStart: {
        [id: number]: {
            initialDimensions: ITerminalDimensionsDto | undefined;
        } | undefined;
    };
    private _terminalStartDeferreds;
    activeTerminal: Terminal | undefined;
    get terminals(): Terminal[];
    constructor(rpcProtocol: IRPCProtocol);
    getTerminal(id: string): Terminal | undefined;
    getTerminalShortId(id: string): string;
    /**
     * FIXME：由于前端对于 id 的拼接逻辑，需要通过 terminalsMap 是否存在对应 terminal 实例来获取真实 id
     */
    getRealTerminalId(id: string): string;
    $onDidChangeActiveTerminal(id: string): void;
    get onDidChangeActiveTerminal(): Event<Terminal | undefined>;
    $onDidCloseTerminal(e: ITerminalExitEvent): void;
    get onDidCloseTerminal(): Event<Terminal>;
    $onDidOpenTerminal(info: ITerminalInfo): void;
    $onDidTerminalTitleChange(id: string, name: string): void;
    get onDidOpenTerminal(): Event<Terminal>;
    get onDidChangeShell(): Event<string>;
    get shellPath(): string;
    get onDidChangeTerminalState(): Event<Terminal>;
    $setShell(shell: string): void;
    createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal;
    createTerminalFromOptions(options: vscode.TerminalOptions): Terminal;
    createExtensionTerminal(options: vscode.ExtensionTerminalOptions): Terminal;
    attachPtyToTerminal(id: string, pty: vscode.Pseudoterminal): void;
    $setTerminals(idList: ITerminalInfo[]): void;
    registerLinkProvider(provider: vscode.TerminalLinkProvider): IDisposable;
    $provideLinks(id: string, line: string): Promise<ITerminalLinkDto[]>;
    $activateLink(id: string, linkId: number): void;
    dispose(): void;
    registerTerminalProfileProvider(extension: IExtensionDescription, id: string, provider: vscode.TerminalProfileProvider): IDisposable;
    /**
     * @deprecated this function is useless, will removed in 2.17.0
     */
    $acceptDefaultShell(shellPath: string): void;
    $acceptDefaultProfile(profile: ITerminalProfile, automationProfile?: ITerminalProfile): void;
    $createContributedProfileTerminal(id: string, options: ICreateContributedTerminalProfileOptions): Promise<void>;
    private _getTerminalByIdEventually;
    $startExtensionTerminal(id: string, initialDimensions: ITerminalDimensionsDto | undefined): Promise<ITerminalLaunchError | undefined>;
    protected _setupExtHostProcessListeners(shortId: string, p: ITerminalChildProcess): IDisposable;
    private _onProcessExit;
    $acceptProcessInput(id: string, data: string): void;
    $acceptProcessShutdown(id: string, immediate: boolean): void;
    $acceptProcessRequestInitialCwd(id: string): void;
    $acceptProcessRequestCwd(id: string): void;
    $acceptTerminalTitleChange(terminalId: string, name: string): void;
    $acceptTerminalInteraction(terminalId: string): void;
    getEnvironmentVariableCollection(extension: IExtension, rootUri?: string): EnvironmentVariableCollection;
    private syncEnvironmentVariableCollection;
    private _setEnvironmentVariableCollection;
}
/**
 * EnvironmentVariableCollection
 * Some code copied and modified from
 * https://github.com/microsoft/vscode/blob/1.55.0/src/vs/workbench/api/common/extHostTerminalService.ts#L696
 */
export declare class EnvironmentVariableCollection implements vscode.GlobalEnvironmentVariableCollection {
    readonly map: Map<string, vscode.EnvironmentVariableMutator>;
    protected readonly _onDidChangeCollection: Emitter<void>;
    get onDidChangeCollection(): Event<void>;
    constructor(serialized?: ISerializableEnvironmentVariableCollection);
    private _persistent;
    get persistent(): boolean;
    set persistent(value: boolean);
    getScoped(_scope: vscode.EnvironmentVariableScope): vscode.EnvironmentVariableCollection;
    private _setIfDiffers;
    replace(variable: string, value: string, options?: vscode.EnvironmentVariableMutatorOptions): void;
    append(variable: string, value: string, options?: vscode.EnvironmentVariableMutatorOptions): void;
    prepend(variable: string, value: string, options?: vscode.EnvironmentVariableMutatorOptions): void;
    get(variable: string): vscode.EnvironmentVariableMutator | undefined;
    forEach(callback: (variable: string, mutator: vscode.EnvironmentVariableMutator, collection: vscode.EnvironmentVariableCollection) => any, thisArg?: any): void;
    delete(variable: string): void;
    clear(): void;
}
export declare class Terminal implements vscode.Terminal {
    private _name;
    private readonly _creationOptions;
    protected proxy: IMainThreadTerminal;
    private id;
    __id: string;
    private _exitStatus;
    private _state;
    private createdPromiseResolve;
    private when;
    constructor(_name: string | undefined, _creationOptions: vscode.TerminalOptions | vscode.ExtensionTerminalOptions, proxy: IMainThreadTerminal, id?: string);
    get name(): string;
    get state(): vscode.TerminalState;
    get exitStatus(): vscode.TerminalExitStatus | undefined;
    get processId(): Thenable<number>;
    get creationOptions(): Readonly<vscode.TerminalOptions | vscode.ExtensionTerminalOptions>;
    shellIntegration: vscode.TerminalShellIntegration | undefined;
    sendText(text: string, addNewLine?: boolean): void;
    show(preserveFocus?: boolean): void;
    hide(): void;
    /**
     * 所有插件进程的终端调用都需要指定 id
     * 该逻辑用于保障依赖 `vscode.window.onDidOpenTerminal` 获取 terminal 实例的相关逻辑
     * 让相关 terminal 的值引用一致
     * 如 vscode-js-debug 中的 https://github.com/microsoft/vscode-js-debug/blob/a201e735c94b9aeb1e13d8c586b91a1fe1ab62b3/src/ui/debugTerminalUI.ts#L198
     */
    create(options: vscode.TerminalOptions, shortId: string): Promise<void>;
    created(shortId: string): void;
    dispose(): void;
    createExtensionTerminal(id: string, iconPath?: vscode.IconPath, color?: vscode.ThemeColor): Promise<void>;
    setExitStatus(code: number | undefined, reason: vscode.TerminalExitReason): void;
    setName(name: string): void;
    setInteractedWith(): boolean;
}
export declare class ExtHostPseudoterminal implements ITerminalChildProcess {
    private readonly _pty;
    private readonly _onProcessData;
    readonly onProcessData: Event<string>;
    private readonly _onProcessExit;
    readonly onProcessExit: Event<number | undefined>;
    private readonly _onProcessReady;
    get onProcessReady(): Event<{
        pid: number;
        cwd: string;
    }>;
    private readonly _onProcessTitleChanged;
    readonly onProcessTitleChanged: Event<string>;
    private readonly _onProcessOverrideDimensions;
    get onProcessOverrideDimensions(): Event<ITerminalDimensionsOverride | undefined>;
    constructor(_pty: vscode.Pseudoterminal);
    start(): Promise<undefined>;
    shutdown(): void;
    input(data: string): void;
    resize(cols: number, rows: number): void;
    getInitialCwd(): Promise<string>;
    getCwd(): Promise<string>;
    getLatency(): Promise<number>;
    startSendingEvents(initialDimensions: ITerminalDimensionsDto | undefined): void;
}
//# sourceMappingURL=ext.host.terminal.d.ts.map