"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createApiFactory = createApiFactory;
const tslib_1 = require("tslib");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const const_1 = require("@opensumi/ide-core-common/lib/const");
const vscode_1 = require("../../../common/vscode"); // '../../common';
const enums_1 = require("../../../common/vscode/enums");
const extTypes = tslib_1.__importStar(require("../../../common/vscode/ext-types"));
const fileSystemTypes = tslib_1.__importStar(require("../../../common/vscode/file-system"));
const models_1 = require("../../../common/vscode/models");
const debug_1 = require("./debug");
const doc_1 = require("./doc");
const editor_host_1 = require("./editor/editor.host");
const envApiFactory_1 = require("./env/envApiFactory");
const ext_host_env_1 = require("./env/ext.host.env");
const ext_host_api_webview_1 = require("./ext.host.api.webview");
const ext_host_authentication_1 = require("./ext.host.authentication");
const ext_host_command_1 = require("./ext.host.command");
const ext_host_comments_1 = require("./ext.host.comments");
const ext_host_connection_1 = require("./ext.host.connection");
const ext_host_custom_editor_1 = require("./ext.host.custom-editor");
const ext_host_decoration_1 = require("./ext.host.decoration");
const ext_host_editor_tabs_1 = require("./ext.host.editor-tabs");
const ext_host_extensions_1 = require("./ext.host.extensions");
const ext_host_file_system_1 = require("./ext.host.file-system");
const ext_host_file_system_event_1 = require("./ext.host.file-system-event");
const ext_host_file_system_info_1 = require("./ext.host.file-system-info");
const ext_host_language_1 = require("./ext.host.language");
const ext_host_localization_1 = require("./ext.host.localization");
const ext_host_message_1 = require("./ext.host.message");
const ext_host_notebook_1 = require("./ext.host.notebook");
const ext_host_output_1 = require("./ext.host.output");
const ext_host_preference_1 = require("./ext.host.preference");
const ext_host_progress_1 = require("./ext.host.progress");
const ext_host_quickopen_1 = require("./ext.host.quickopen");
const ext_host_scm_1 = require("./ext.host.scm");
const ext_host_statusbar_1 = require("./ext.host.statusbar");
const ext_host_terminal_1 = require("./ext.host.terminal");
const ext_host_tests_1 = require("./ext.host.tests");
const ext_host_theming_1 = require("./ext.host.theming");
const ext_host_treeview_1 = require("./ext.host.treeview");
const ext_host_urls_1 = require("./ext.host.urls");
const ext_host_window_state_1 = require("./ext.host.window-state");
const ext_host_window_api_impl_1 = require("./ext.host.window.api.impl");
const ext_host_workspace_1 = require("./ext.host.workspace");
const ext_host_tasks_1 = require("./tasks/ext.host.tasks");
function createApiFactory(rpcProtocol, extensionService, appConfig) {
    const builtinCommands = appConfig.builtinCommands;
    const customDebugChildProcess = appConfig.customDebugChildProcess;
    // register addressable instances
    const extHostDocs = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostDocuments, new doc_1.ExtensionDocumentDataManagerImpl(rpcProtocol));
    rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostExtensionService, extensionService);
    const extHostNotebook = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostNotebook, new ext_host_notebook_1.ExtensionNotebookDocumentManagerImpl(rpcProtocol, extHostDocs));
    const extHostCommands = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostCommands, new ext_host_command_1.ExtHostCommands(rpcProtocol, builtinCommands));
    const extHostEditors = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostEditors, new editor_host_1.ExtensionHostEditorService(rpcProtocol, extHostDocs));
    const extHostEnv = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostEnv, new ext_host_env_1.ExtHostEnv(rpcProtocol));
    const extHostLanguages = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostLanguages, new ext_host_language_1.ExtHostLanguages(rpcProtocol, extHostDocs, extHostCommands, extensionService.logger));
    const extHostFileSystemInfo = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostFileSystemInfo, new ext_host_file_system_info_1.ExtHostFileSystemInfo());
    const extHostFileSystem = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostFileSystem, new ext_host_file_system_1.ExtHostFileSystem(rpcProtocol, extHostFileSystemInfo));
    const extHostFileSystemEvent = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostFileSystemEvent, new ext_host_file_system_event_1.ExtHostFileSystemEvent(rpcProtocol, extHostDocs));
    const extHostMessage = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostMessage, new ext_host_message_1.ExtHostMessage(rpcProtocol));
    const extHostWorkspace = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostWorkspace, new ext_host_workspace_1.ExtHostWorkspace(rpcProtocol, extHostMessage, extHostDocs));
    const extHostPreference = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostPreference, new ext_host_preference_1.ExtHostPreference(rpcProtocol, extHostWorkspace));
    const extHostTreeView = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostTreeView, new ext_host_treeview_1.ExtHostTreeViews(rpcProtocol, extHostCommands));
    const extHostWebview = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostWebview, new ext_host_api_webview_1.ExtHostWebviewService(rpcProtocol));
    const extHostWebviewView = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostWebviewView, new ext_host_api_webview_1.ExtHostWebviewViews(rpcProtocol, extHostWebview));
    const extHostSCM = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostSCM, new ext_host_scm_1.ExtHostSCM(rpcProtocol, extHostCommands));
    const extHostWindowState = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostWindowState, new ext_host_window_state_1.ExtHostWindowState(rpcProtocol));
    const extHostDecorations = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostDecorations, new ext_host_decoration_1.ExtHostDecorations(rpcProtocol));
    const extHostStatusBar = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostStatusBar, new ext_host_statusbar_1.ExtHostStatusBar(rpcProtocol));
    const extHostQuickOpen = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostQuickOpen, new ext_host_quickopen_1.ExtHostQuickOpen(rpcProtocol, extHostWorkspace));
    const extHostOutput = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostOutput, new ext_host_output_1.ExtHostOutput(rpcProtocol));
    const extHostWindow = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostWindow, new ext_host_window_api_impl_1.ExtHostWindow(rpcProtocol));
    const extHostConnection = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostConnection, new ext_host_connection_1.ExtHostConnection(rpcProtocol));
    const extHostDebug = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostDebug, new debug_1.ExtHostDebug(rpcProtocol, extHostConnection, extHostCommands, customDebugChildProcess));
    const extHostTerminal = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostTerminal, new ext_host_terminal_1.ExtHostTerminal(rpcProtocol));
    const extHostProgress = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostProgress, new ext_host_progress_1.ExtHostProgress(rpcProtocol));
    const extHostTasks = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostTasks, new ext_host_tasks_1.ExtHostTasks(rpcProtocol, extHostTerminal, extHostWorkspace));
    const extHostComments = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostComments, new ext_host_comments_1.ExtHostComments(rpcProtocol, extHostCommands, extHostDocs));
    const extHostUrls = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostUrls, new ext_host_urls_1.ExtHostUrls(rpcProtocol));
    const extHostTheming = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostTheming, new ext_host_theming_1.ExtHostTheming(rpcProtocol));
    const extHostCustomEditor = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostCustomEditor, new ext_host_custom_editor_1.ExtHostCustomEditorImpl(rpcProtocol, extHostWebview, extHostDocs));
    const extHostAuthentication = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostAuthentication, new ext_host_authentication_1.ExtHostAuthentication(rpcProtocol));
    const extHostTests = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostTests, new ext_host_tests_1.ExtHostTestsImpl(rpcProtocol));
    const extHostEditorTabs = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostEditorTabs, new ext_host_editor_tabs_1.ExtHostEditorTabs(rpcProtocol));
    const extHostLocalization = rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostLocalization, new ext_host_localization_1.ExtHostLocalization(rpcProtocol, extensionService.logger));
    rpcProtocol.set(vscode_1.ExtHostAPIIdentifier.ExtHostStorage, extensionService.storage);
    return (extension) => ({
        authentication: (0, ext_host_authentication_1.createAuthenticationApiFactory)(extension, extHostAuthentication),
        commands: (0, ext_host_command_1.createCommandsApiFactory)(extHostCommands, extHostEditors, extension),
        window: (0, ext_host_window_api_impl_1.createWindowApiFactory)(extension, extHostEditors, extHostMessage, extHostWebview, extHostWebviewView, extHostTreeView, extHostWindowState, extHostDecorations, extHostStatusBar, extHostQuickOpen, extHostOutput, extHostTerminal, extHostWindow, extHostProgress, extHostUrls, extHostTheming, extHostCustomEditor, extHostEditorTabs),
        languages: (0, ext_host_language_1.createLanguagesApiFactory)(extHostLanguages, extHostNotebook, extension),
        workspace: (0, ext_host_workspace_1.createWorkspaceApiFactory)(extHostWorkspace, extHostPreference, extHostDocs, extHostNotebook, extHostFileSystem, extHostFileSystemEvent, extHostTasks, extension),
        env: (0, envApiFactory_1.createEnvApiFactory)(rpcProtocol, extension, extHostEnv, extHostTerminal),
        debug: (0, debug_1.createDebugApiFactory)(extHostDebug),
        version: appConfig.customVSCodeEngineVersion || const_1.DEFAULT_VSCODE_ENGINE_VERSION,
        comments: (0, ext_host_comments_1.createCommentsApiFactory)(extension, extHostComments),
        extensions: (0, ext_host_extensions_1.createExtensionsApiFactory)(extensionService),
        tasks: (0, ext_host_tasks_1.createTaskApiFactory)(extHostTasks, extension),
        scm: {
            get inputBox() {
                return extHostSCM.getLastInputBox(extension); // Strict null override - Deprecated api
            },
            createSourceControl(id, label, rootUri) {
                return extHostSCM.createSourceControl(extension, id, label, rootUri);
            },
            getSourceControl(extensionId, id) {
                return extHostSCM.getSourceControl(extensionId, id);
            },
        },
        tests: {
            createTestController(controllerId, label, refreshHandler) {
                return extHostTests.createTestController(controllerId, label, refreshHandler);
            },
        },
        l10n: (0, ext_host_localization_1.createLocalizationApiFactory)(extHostLocalization, extension),
        // 类型定义
        ...extTypes,
        // https://github.com/microsoft/vscode/blob/0ba16b83267cbab5811e12e0317fb47fd774324e/src/vs/workbench/api/common/extHost.api.impl.ts#L1288
        InlineCompletionItem: extTypes.InlineSuggestion,
        InlineCompletionList: extTypes.InlineSuggestionList,
        ...fileSystemTypes,
        // 参考 VS Code，目前到 1.44 版本为临时兼容，最新版(1.50+)已去除
        Task2: extTypes.Task,
        CancellationTokenSource: ide_core_common_1.CancellationTokenSource,
        EventEmitter: ide_core_common_1.Emitter,
        Event: ide_core_common_1.Event,
        ViewColumn: enums_1.ViewColumn,
        OverviewRulerLane: models_1.OverviewRulerLane,
        TextEditorCursorStyle: vscode_1.TextEditorCursorStyle,
        TextEditorSelectionChangeKind: vscode_1.TextEditorSelectionChangeKind,
        TabInputText: extTypes.TextTabInput,
        TabInputTextDiff: extTypes.TextDiffTabInput,
        TabInputTextMerge: extTypes.TextMergeTabInput,
        TabInputCustom: extTypes.CustomEditorTabInput,
        TabInputNotebook: extTypes.NotebookEditorTabInput,
        TabInputNotebookDiff: extTypes.NotebookDiffEditorTabInput,
        TabInputWebview: extTypes.WebviewEditorTabInput,
        TabInputTerminal: extTypes.TerminalEditorTabInput,
        TabInputInteractiveWindow: extTypes.InteractiveWindowInput,
        InlineEdit: extTypes.InlineEdit,
        InlineEditTriggerKind: extTypes.InlineEditTriggerKind,
    });
}
//# sourceMappingURL=ext.host.api.impl.js.map