@theia/plugin-ext 1.40.1 → 1.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/collections.d.ts +4 -0
- package/lib/common/collections.d.ts.map +1 -1
- package/lib/common/collections.js +17 -1
- package/lib/common/collections.js.map +1 -1
- package/lib/common/errors.d.ts +14 -0
- package/lib/common/errors.d.ts.map +1 -1
- package/lib/common/errors.js +17 -1
- package/lib/common/errors.js.map +1 -1
- package/lib/common/plugin-api-rpc.d.ts +286 -6
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js +20 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/plugin-protocol.d.ts +27 -5
- package/lib/common/plugin-protocol.d.ts.map +1 -1
- package/lib/common/plugin-protocol.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin.d.ts +5 -2
- package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin.js +21 -12
- package/lib/hosted/browser/hosted-plugin.js.map +1 -1
- package/lib/hosted/node/hosted-plugin-deployer-handler.js +1 -1
- package/lib/hosted/node/hosted-plugin-deployer-handler.js.map +1 -1
- package/lib/hosted/node/plugin-reader.d.ts +1 -1
- package/lib/hosted/node/plugin-reader.d.ts.map +1 -1
- package/lib/hosted/node/plugin-reader.js +1 -1
- package/lib/hosted/node/plugin-reader.js.map +1 -1
- package/lib/hosted/node/scanners/grammars-reader.d.ts +1 -1
- package/lib/hosted/node/scanners/grammars-reader.d.ts.map +1 -1
- package/lib/hosted/node/scanners/grammars-reader.js +5 -5
- package/lib/hosted/node/scanners/grammars-reader.js.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.d.ts +6 -6
- package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.js +54 -41
- package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
- package/lib/main/browser/custom-editors/custom-editor-widget.d.ts +1 -1
- package/lib/main/browser/custom-editors/custom-editor-widget.d.ts.map +1 -1
- package/lib/main/browser/custom-editors/custom-editor-widget.js +1 -1
- package/lib/main/browser/custom-editors/custom-editor-widget.js.map +1 -1
- package/lib/main/browser/custom-editors/custom-editors-main.d.ts +1 -1
- package/lib/main/browser/custom-editors/custom-editors-main.d.ts.map +1 -1
- package/lib/main/browser/custom-editors/custom-editors-main.js +1 -1
- package/lib/main/browser/custom-editors/custom-editors-main.js.map +1 -1
- package/lib/main/browser/editors-and-documents-main.d.ts.map +1 -1
- package/lib/main/browser/editors-and-documents-main.js +1 -0
- package/lib/main/browser/editors-and-documents-main.js.map +1 -1
- package/lib/main/browser/languages-main.d.ts.map +1 -1
- package/lib/main/browser/languages-main.js +6 -4
- package/lib/main/browser/languages-main.js.map +1 -1
- package/lib/main/browser/main-context.d.ts.map +1 -1
- package/lib/main/browser/main-context.js +18 -0
- package/lib/main/browser/main-context.js.map +1 -1
- package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
- package/lib/main/browser/menus/menus-contribution-handler.js +6 -3
- package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts +50 -0
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts.map +1 -0
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js +189 -0
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js.map +1 -0
- package/lib/main/browser/notebooks/notebook-documents-main.d.ts +22 -0
- package/lib/main/browser/notebooks/notebook-documents-main.d.ts.map +1 -0
- package/lib/main/browser/notebooks/notebook-documents-main.js +133 -0
- package/lib/main/browser/notebooks/notebook-documents-main.js.map +1 -0
- package/lib/main/browser/notebooks/notebook-dto.d.ts +15 -0
- package/lib/main/browser/notebooks/notebook-dto.d.ts.map +1 -0
- package/lib/main/browser/notebooks/notebook-dto.js +138 -0
- package/lib/main/browser/notebooks/notebook-dto.js.map +1 -0
- package/lib/main/browser/notebooks/notebook-editors-main.d.ts +20 -0
- package/lib/main/browser/notebooks/notebook-editors-main.d.ts.map +1 -0
- package/lib/main/browser/notebooks/notebook-editors-main.js +58 -0
- package/lib/main/browser/notebooks/notebook-editors-main.js.map +1 -0
- package/lib/main/browser/notebooks/notebook-kernels-main.d.ts +42 -0
- package/lib/main/browser/notebooks/notebook-kernels-main.d.ts.map +1 -0
- package/lib/main/browser/notebooks/notebook-kernels-main.js +230 -0
- package/lib/main/browser/notebooks/notebook-kernels-main.js.map +1 -0
- package/lib/main/browser/notebooks/notebook-renderers-main.d.ts +12 -0
- package/lib/main/browser/notebooks/notebook-renderers-main.d.ts.map +1 -0
- package/lib/main/browser/notebooks/notebook-renderers-main.js +39 -0
- package/lib/main/browser/notebooks/notebook-renderers-main.js.map +1 -0
- package/lib/main/browser/notebooks/notebooks-main.d.ts +20 -0
- package/lib/main/browser/notebooks/notebooks-main.d.ts.map +1 -0
- package/lib/main/browser/notebooks/notebooks-main.js +103 -0
- package/lib/main/browser/notebooks/notebooks-main.js.map +1 -0
- package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts +35 -0
- package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts.map +1 -0
- package/lib/main/browser/notebooks/renderers/cell-output-webview.js +204 -0
- package/lib/main/browser/notebooks/renderers/cell-output-webview.js.map +1 -0
- package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts +13 -0
- package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts.map +1 -0
- package/lib/main/browser/notebooks/renderers/output-webview-internal.js +375 -0
- package/lib/main/browser/notebooks/renderers/output-webview-internal.js.map +1 -0
- package/lib/main/browser/notebooks/renderers/webview-communication.d.ts +52 -0
- package/lib/main/browser/notebooks/renderers/webview-communication.d.ts.map +1 -0
- package/{src/typings/index.d.ts → lib/main/browser/notebooks/renderers/webview-communication.js} +8 -11
- package/lib/main/browser/notebooks/renderers/webview-communication.js.map +1 -0
- package/lib/main/browser/plugin-contribution-handler.d.ts +3 -0
- package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
- package/lib/main/browser/plugin-contribution-handler.js +31 -3
- package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.js +3 -2
- package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
- package/lib/main/browser/plugin-icon-theme-service.d.ts.map +1 -1
- package/lib/main/browser/plugin-icon-theme-service.js +6 -0
- package/lib/main/browser/plugin-icon-theme-service.js.map +1 -1
- package/lib/main/browser/plugin-shared-style.d.ts.map +1 -1
- package/lib/main/browser/plugin-shared-style.js +2 -1
- package/lib/main/browser/plugin-shared-style.js.map +1 -1
- package/lib/main/browser/tasks-main.js +2 -2
- package/lib/main/browser/tasks-main.js.map +1 -1
- package/lib/main/browser/terminal-main.d.ts +2 -2
- package/lib/main/browser/terminal-main.d.ts.map +1 -1
- package/lib/main/browser/terminal-main.js +4 -4
- package/lib/main/browser/terminal-main.js.map +1 -1
- package/lib/main/browser/view/tree-view-widget.d.ts +3 -1
- package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
- package/lib/main/browser/view/tree-view-widget.js +32 -1
- package/lib/main/browser/view/tree-view-widget.js.map +1 -1
- package/lib/main/browser/view/tree-views-main.d.ts +2 -1
- package/lib/main/browser/view/tree-views-main.d.ts.map +1 -1
- package/lib/main/browser/view/tree-views-main.js +10 -0
- package/lib/main/browser/view/tree-views-main.js.map +1 -1
- package/lib/main/browser/webview/webview.d.ts +1 -0
- package/lib/main/browser/webview/webview.d.ts.map +1 -1
- package/lib/main/browser/webview/webview.js +5 -0
- package/lib/main/browser/webview/webview.js.map +1 -1
- package/lib/main/node/errors.spec.d.ts +2 -0
- package/lib/main/node/errors.spec.d.ts.map +1 -0
- package/lib/main/node/errors.spec.js +36 -0
- package/lib/main/node/errors.spec.js.map +1 -0
- package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts +5 -2
- package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts.map +1 -1
- package/lib/main/node/handlers/plugin-theia-directory-handler.js +14 -8
- package/lib/main/node/handlers/plugin-theia-directory-handler.js.map +1 -1
- package/lib/main/node/handlers/plugin-theia-file-handler.d.ts +2 -1
- package/lib/main/node/handlers/plugin-theia-file-handler.d.ts.map +1 -1
- package/lib/main/node/handlers/plugin-theia-file-handler.js +13 -5
- package/lib/main/node/handlers/plugin-theia-file-handler.js.map +1 -1
- package/lib/main/node/paths/plugin-paths-service.d.ts.map +1 -1
- package/lib/main/node/paths/plugin-paths-service.js +4 -9
- package/lib/main/node/paths/plugin-paths-service.js.map +1 -1
- package/lib/main/node/plugin-deployer-directory-handler-context-impl.js +8 -8
- package/lib/main/node/plugin-deployer-directory-handler-context-impl.js.map +1 -1
- package/lib/main/node/plugin-deployer-entry-impl.d.ts +2 -2
- package/lib/main/node/plugin-deployer-entry-impl.d.ts.map +1 -1
- package/lib/main/node/plugin-deployer-entry-impl.js +9 -7
- package/lib/main/node/plugin-deployer-entry-impl.js.map +1 -1
- package/lib/main/node/plugin-deployer-impl.d.ts +2 -2
- package/lib/main/node/plugin-deployer-impl.d.ts.map +1 -1
- package/lib/main/node/plugin-deployer-impl.js +16 -24
- package/lib/main/node/plugin-deployer-impl.js.map +1 -1
- package/lib/main/node/plugin-deployer-proxy-entry-impl.d.ts +2 -2
- package/lib/main/node/plugin-deployer-proxy-entry-impl.d.ts.map +1 -1
- package/lib/main/node/plugin-ext-backend-module.js +3 -3
- package/lib/main/node/plugin-ext-backend-module.js.map +1 -1
- package/lib/main/node/plugin-github-resolver.d.ts.map +1 -1
- package/lib/main/node/plugin-github-resolver.js +14 -6
- package/lib/main/node/plugin-github-resolver.js.map +1 -1
- package/lib/main/node/plugin-http-resolver.d.ts.map +1 -1
- package/lib/main/node/plugin-http-resolver.js +14 -6
- package/lib/main/node/plugin-http-resolver.js.map +1 -1
- package/lib/main/node/{plugin-localization-backend-contribution.d.ts → plugin-localization-server.d.ts} +3 -3
- package/lib/main/node/plugin-localization-server.d.ts.map +1 -0
- package/lib/main/node/{plugin-localization-backend-contribution.js → plugin-localization-server.js} +8 -8
- package/lib/main/node/plugin-localization-server.js.map +1 -0
- package/lib/main/node/temp-dir-util.d.ts +1 -0
- package/lib/main/node/temp-dir-util.d.ts.map +1 -1
- package/lib/main/node/temp-dir-util.js +12 -3
- package/lib/main/node/temp-dir-util.js.map +1 -1
- package/lib/plugin/editors-and-documents.d.ts +1 -1
- package/lib/plugin/editors-and-documents.d.ts.map +1 -1
- package/lib/plugin/editors-and-documents.js +1 -1
- package/lib/plugin/editors-and-documents.js.map +1 -1
- package/lib/plugin/notebook/notebook-document.d.ts +62 -0
- package/lib/plugin/notebook/notebook-document.d.ts.map +1 -0
- package/lib/plugin/notebook/notebook-document.js +373 -0
- package/lib/plugin/notebook/notebook-document.js.map +1 -0
- package/lib/plugin/notebook/notebook-documents.d.ts +17 -0
- package/lib/plugin/notebook/notebook-documents.d.ts.map +1 -0
- package/lib/plugin/notebook/notebook-documents.js +48 -0
- package/lib/plugin/notebook/notebook-documents.js.map +1 -0
- package/lib/plugin/notebook/notebook-editor.d.ts +21 -0
- package/lib/plugin/notebook/notebook-editor.d.ts.map +1 -0
- package/lib/plugin/notebook/notebook-editor.js +99 -0
- package/lib/plugin/notebook/notebook-editor.js.map +1 -0
- package/lib/plugin/notebook/notebook-editors.d.ts +14 -0
- package/lib/plugin/notebook/notebook-editors.d.ts.map +1 -0
- package/lib/plugin/notebook/notebook-editors.js +65 -0
- package/lib/plugin/notebook/notebook-editors.js.map +1 -0
- package/lib/plugin/notebook/notebook-kernels.d.ts +37 -0
- package/lib/plugin/notebook/notebook-kernels.d.ts.map +1 -0
- package/lib/plugin/notebook/notebook-kernels.js +516 -0
- package/lib/plugin/notebook/notebook-kernels.js.map +1 -0
- package/lib/plugin/notebook/notebook-renderers.d.ts +14 -0
- package/lib/plugin/notebook/notebook-renderers.d.ts.map +1 -0
- package/lib/plugin/notebook/notebook-renderers.js +63 -0
- package/lib/plugin/notebook/notebook-renderers.js.map +1 -0
- package/lib/plugin/notebook/notebooks.d.ts +57 -0
- package/lib/plugin/notebook/notebooks.d.ts.map +1 -0
- package/lib/plugin/notebook/notebooks.js +295 -0
- package/lib/plugin/notebook/notebooks.js.map +1 -0
- package/lib/plugin/plugin-context.d.ts +2 -2
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +80 -59
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/plugin-manager.d.ts +2 -0
- package/lib/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/plugin/plugin-manager.js +9 -1
- package/lib/plugin/plugin-manager.js.map +1 -1
- package/lib/plugin/quick-open.d.ts.map +1 -1
- package/lib/plugin/quick-open.js +1 -0
- package/lib/plugin/quick-open.js.map +1 -1
- package/lib/plugin/stubs/tests-api.d.ts +1 -0
- package/lib/plugin/stubs/tests-api.d.ts.map +1 -1
- package/lib/plugin/stubs/tests-api.js +3 -1
- package/lib/plugin/stubs/tests-api.js.map +1 -1
- package/lib/plugin/tasks/task-provider.d.ts +2 -2
- package/lib/plugin/tasks/task-provider.d.ts.map +1 -1
- package/lib/plugin/tasks/task-provider.js +7 -10
- package/lib/plugin/tasks/task-provider.js.map +1 -1
- package/lib/plugin/tasks/tasks.d.ts +3 -2
- package/lib/plugin/tasks/tasks.d.ts.map +1 -1
- package/lib/plugin/tasks/tasks.js +18 -13
- package/lib/plugin/tasks/tasks.js.map +1 -1
- package/lib/plugin/terminal-ext.d.ts +3 -0
- package/lib/plugin/terminal-ext.d.ts.map +1 -1
- package/lib/plugin/terminal-ext.js +11 -1
- package/lib/plugin/terminal-ext.js.map +1 -1
- package/lib/plugin/tree/tree-views.d.ts +15 -5
- package/lib/plugin/tree/tree-views.d.ts.map +1 -1
- package/lib/plugin/tree/tree-views.js +52 -3
- package/lib/plugin/tree/tree-views.js.map +1 -1
- package/lib/plugin/type-converters.d.ts +60 -0
- package/lib/plugin/type-converters.d.ts.map +1 -1
- package/lib/plugin/type-converters.js +374 -14
- package/lib/plugin/type-converters.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +68 -29
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +123 -44
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +31 -29
- package/src/common/collections.ts +17 -0
- package/src/common/errors.ts +26 -0
- package/src/common/plugin-api-rpc.ts +340 -5
- package/src/common/plugin-protocol.ts +23 -5
- package/src/hosted/browser/hosted-plugin.ts +21 -14
- package/src/hosted/node/hosted-plugin-deployer-handler.ts +1 -1
- package/src/hosted/node/plugin-reader.ts +1 -1
- package/src/hosted/node/scanners/grammars-reader.ts +6 -5
- package/src/hosted/node/scanners/scanner-theia.ts +55 -41
- package/src/main/browser/custom-editors/custom-editor-widget.ts +1 -1
- package/src/main/browser/custom-editors/custom-editors-main.ts +1 -1
- package/src/main/browser/editors-and-documents-main.ts +1 -0
- package/src/main/browser/languages-main.ts +7 -4
- package/src/main/browser/main-context.ts +19 -0
- package/src/main/browser/menus/menus-contribution-handler.ts +7 -4
- package/src/main/browser/notebooks/notebook-documents-and-editors-main.ts +238 -0
- package/src/main/browser/notebooks/notebook-documents-main.ts +166 -0
- package/src/main/browser/notebooks/notebook-dto.ts +141 -0
- package/src/main/browser/notebooks/notebook-editors-main.ts +70 -0
- package/src/main/browser/notebooks/notebook-kernels-main.ts +291 -0
- package/src/main/browser/notebooks/notebook-renderers-main.ts +47 -0
- package/src/main/browser/notebooks/notebooks-main.ts +124 -0
- package/src/main/browser/notebooks/renderers/cell-output-webview.tsx +198 -0
- package/src/main/browser/notebooks/renderers/output-webview-internal.ts +476 -0
- package/src/main/browser/notebooks/renderers/webview-communication.ts +79 -0
- package/src/main/browser/plugin-contribution-handler.ts +36 -3
- package/src/main/browser/plugin-ext-frontend-module.ts +7 -3
- package/src/main/browser/plugin-icon-theme-service.ts +6 -0
- package/src/main/browser/plugin-shared-style.ts +2 -1
- package/src/main/browser/tasks-main.ts +4 -4
- package/src/main/browser/terminal-main.ts +5 -5
- package/src/main/browser/view/tree-view-widget.tsx +36 -2
- package/src/main/browser/view/tree-views-main.ts +8 -0
- package/src/main/browser/webview/webview.ts +6 -0
- package/src/main/node/errors.spec.ts +37 -0
- package/src/main/node/handlers/plugin-theia-directory-handler.ts +18 -8
- package/src/main/node/handlers/plugin-theia-file-handler.ts +18 -6
- package/src/main/node/paths/plugin-paths-service.ts +5 -10
- package/src/main/node/plugin-deployer-directory-handler-context-impl.ts +8 -8
- package/src/main/node/plugin-deployer-entry-impl.ts +9 -7
- package/src/main/node/plugin-deployer-impl.ts +20 -28
- package/src/main/node/plugin-deployer-proxy-entry-impl.ts +2 -2
- package/src/main/node/plugin-ext-backend-module.ts +3 -3
- package/src/main/node/plugin-github-resolver.ts +15 -8
- package/src/main/node/plugin-http-resolver.ts +15 -8
- package/src/main/node/{plugin-localization-backend-contribution.ts → plugin-localization-server.ts} +2 -2
- package/src/main/node/temp-dir-util.ts +11 -2
- package/src/plugin/editors-and-documents.ts +1 -1
- package/src/plugin/notebook/notebook-document.ts +438 -0
- package/src/plugin/notebook/notebook-documents.ts +58 -0
- package/src/plugin/notebook/notebook-editor.ts +116 -0
- package/src/plugin/notebook/notebook-editors.ts +71 -0
- package/src/plugin/notebook/notebook-kernels.ts +616 -0
- package/src/plugin/notebook/notebook-renderers.ts +72 -0
- package/src/plugin/notebook/notebooks.ts +385 -0
- package/src/plugin/plugin-context.ts +80 -71
- package/src/plugin/plugin-manager.ts +9 -1
- package/src/plugin/quick-open.ts +1 -0
- package/src/plugin/stubs/tests-api.ts +4 -0
- package/src/plugin/tasks/task-provider.ts +9 -12
- package/src/plugin/tasks/tasks.ts +18 -13
- package/src/plugin/terminal-ext.ts +13 -1
- package/src/plugin/tree/tree-views.ts +57 -7
- package/src/plugin/type-converters.ts +372 -13
- package/src/plugin/types-impl.ts +162 -58
- package/lib/main/browser/custom-editors/undo-redo-service.d.ts +0 -24
- package/lib/main/browser/custom-editors/undo-redo-service.d.ts.map +0 -1
- package/lib/main/browser/custom-editors/undo-redo-service.js +0 -111
- package/lib/main/browser/custom-editors/undo-redo-service.js.map +0 -1
- package/lib/main/node/plugin-localization-backend-contribution.d.ts.map +0 -1
- package/lib/main/node/plugin-localization-backend-contribution.js.map +0 -1
- package/src/main/browser/custom-editors/undo-redo-service.ts +0 -120
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
/*---------------------------------------------------------------------------------------------
|
|
17
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
19
|
+
*--------------------------------------------------------------------------------------------*/
|
|
20
|
+
|
|
21
|
+
import { CancellationToken, Disposable, DisposableCollection, Emitter, Event, URI } from '@theia/core';
|
|
22
|
+
import { URI as TheiaURI } from '../types-impl';
|
|
23
|
+
import * as theia from '@theia/plugin';
|
|
24
|
+
import {
|
|
25
|
+
CommandRegistryExt, NotebookCellStatusBarListDto, NotebookDataDto,
|
|
26
|
+
NotebookDocumentsAndEditorsDelta, NotebookDocumentShowOptions, NotebookDocumentsMain, NotebookEditorAddData, NotebookEditorsMain, NotebooksExt, NotebooksMain, Plugin,
|
|
27
|
+
PLUGIN_RPC_CONTEXT
|
|
28
|
+
} from '../../common';
|
|
29
|
+
import { Cache } from '../../common/cache';
|
|
30
|
+
import { RPCProtocol } from '../../common/rpc-protocol';
|
|
31
|
+
import { UriComponents } from '../../common/uri-components';
|
|
32
|
+
import { CommandsConverter } from '../command-registry';
|
|
33
|
+
import * as typeConverters from '../type-converters';
|
|
34
|
+
import { BinaryBuffer } from '@theia/core/lib/common/buffer';
|
|
35
|
+
import { NotebookDocument } from './notebook-document';
|
|
36
|
+
import { NotebookEditor } from './notebook-editor';
|
|
37
|
+
import { EditorsAndDocumentsExtImpl } from '../editors-and-documents';
|
|
38
|
+
import { DocumentsExtImpl } from '../documents';
|
|
39
|
+
|
|
40
|
+
export class NotebooksExtImpl implements NotebooksExt {
|
|
41
|
+
|
|
42
|
+
private readonly notebookStatusBarItemProviders = new Map<number, theia.NotebookCellStatusBarItemProvider>();
|
|
43
|
+
private readonly commandsConverter: CommandsConverter;
|
|
44
|
+
|
|
45
|
+
private readonly onDidChangeActiveNotebookEditorEmitter = new Emitter<theia.NotebookEditor | undefined>();
|
|
46
|
+
readonly onDidChangeActiveNotebookEditor = this.onDidChangeActiveNotebookEditorEmitter.event;
|
|
47
|
+
|
|
48
|
+
private readonly onDidOpenNotebookDocumentEmitter = new Emitter<theia.NotebookDocument>();
|
|
49
|
+
onDidOpenNotebookDocument: Event<theia.NotebookDocument> = this.onDidOpenNotebookDocumentEmitter.event;
|
|
50
|
+
private readonly onDidCloseNotebookDocumentEmitter = new Emitter<theia.NotebookDocument>();
|
|
51
|
+
onDidCloseNotebookDocument: Event<theia.NotebookDocument> = this.onDidCloseNotebookDocumentEmitter.event;
|
|
52
|
+
|
|
53
|
+
private readonly onDidChangeVisibleNotebookEditorsEmitter = new Emitter<theia.NotebookEditor[]>();
|
|
54
|
+
onDidChangeVisibleNotebookEditors = this.onDidChangeVisibleNotebookEditorsEmitter.event;
|
|
55
|
+
|
|
56
|
+
private activeNotebookEditor: NotebookEditor | undefined;
|
|
57
|
+
get activeApiNotebookEditor(): theia.NotebookEditor | undefined {
|
|
58
|
+
return this.activeNotebookEditor?.apiEditor;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private visibleNotebookEditors: NotebookEditor[] = [];
|
|
62
|
+
get visibleApiNotebookEditors(): theia.NotebookEditor[] {
|
|
63
|
+
return this.visibleNotebookEditors.map(editor => editor.apiEditor);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private readonly documents = new Map<string, NotebookDocument>();
|
|
67
|
+
private readonly editors = new Map<string, NotebookEditor>();
|
|
68
|
+
private statusBarRegistry = new Cache<Disposable>('NotebookCellStatusBarCache');
|
|
69
|
+
|
|
70
|
+
private notebookProxy: NotebooksMain;
|
|
71
|
+
private notebookDocumentsProxy: NotebookDocumentsMain;
|
|
72
|
+
private notebookEditors: NotebookEditorsMain;
|
|
73
|
+
|
|
74
|
+
constructor(
|
|
75
|
+
rpc: RPCProtocol,
|
|
76
|
+
commands: CommandRegistryExt,
|
|
77
|
+
private textDocumentsAndEditors: EditorsAndDocumentsExtImpl,
|
|
78
|
+
private textDocuments: DocumentsExtImpl
|
|
79
|
+
) {
|
|
80
|
+
this.notebookProxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.NOTEBOOKS_MAIN);
|
|
81
|
+
this.notebookDocumentsProxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.NOTEBOOK_DOCUMENTS_MAIN);
|
|
82
|
+
this.notebookEditors = rpc.getProxy(PLUGIN_RPC_CONTEXT.NOTEBOOK_EDITORS_MAIN);
|
|
83
|
+
|
|
84
|
+
commands.registerArgumentProcessor({
|
|
85
|
+
processArgument: (arg: { uri: URI }) => {
|
|
86
|
+
if (arg && arg.uri && this.documents.has(arg.uri.toString())) {
|
|
87
|
+
return this.documents.get(arg.uri.toString())?.apiNotebook;
|
|
88
|
+
}
|
|
89
|
+
return arg;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async $provideNotebookCellStatusBarItems(handle: number, uri: UriComponents, index: number, token: CancellationToken): Promise<NotebookCellStatusBarListDto | undefined> {
|
|
95
|
+
const provider = this.notebookStatusBarItemProviders.get(handle);
|
|
96
|
+
const revivedUri = URI.fromComponents(uri);
|
|
97
|
+
const document = this.documents.get(revivedUri.toString());
|
|
98
|
+
if (!document || !provider) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const cell = document.getCellFromIndex(index);
|
|
103
|
+
if (!cell) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const result = await provider.provideCellStatusBarItems(cell.apiCell, token);
|
|
108
|
+
if (!result) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const disposables = new DisposableCollection();
|
|
113
|
+
const cacheId = this.statusBarRegistry.add([disposables]);
|
|
114
|
+
const resultArr = Array.isArray(result) ? result : [result];
|
|
115
|
+
const items = resultArr.map(item => typeConverters.NotebookStatusBarItem.from(item, this.commandsConverter, disposables));
|
|
116
|
+
return {
|
|
117
|
+
cacheId,
|
|
118
|
+
items
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
$releaseNotebookCellStatusBarItems(cacheId: number): void {
|
|
123
|
+
this.statusBarRegistry.delete(cacheId);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// --- serialize/deserialize
|
|
127
|
+
|
|
128
|
+
private currentSerializerHandle = 0;
|
|
129
|
+
private readonly notebookSerializer = new Map<number, theia.NotebookSerializer>();
|
|
130
|
+
|
|
131
|
+
registerNotebookSerializer(plugin: Plugin, viewType: string, serializer: theia.NotebookSerializer,
|
|
132
|
+
options?: theia.NotebookDocumentContentOptions): theia.Disposable {
|
|
133
|
+
if (!viewType || !viewType.trim()) {
|
|
134
|
+
throw new Error('viewType cannot be empty or just whitespace');
|
|
135
|
+
}
|
|
136
|
+
const handle = this.currentSerializerHandle++;
|
|
137
|
+
this.notebookSerializer.set(handle, serializer);
|
|
138
|
+
this.notebookProxy.$registerNotebookSerializer(
|
|
139
|
+
handle,
|
|
140
|
+
{ id: plugin.model.id, location: plugin.pluginUri },
|
|
141
|
+
viewType,
|
|
142
|
+
typeConverters.NotebookDocumentContentOptions.from(options),
|
|
143
|
+
);
|
|
144
|
+
return Disposable.create(() => {
|
|
145
|
+
this.notebookProxy.$unregisterNotebookSerializer(handle);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async $dataToNotebook(handle: number, bytes: BinaryBuffer, token: CancellationToken): Promise<NotebookDataDto> {
|
|
150
|
+
const serializer = this.notebookSerializer.get(handle);
|
|
151
|
+
if (!serializer) {
|
|
152
|
+
throw new Error('No serializer found');
|
|
153
|
+
}
|
|
154
|
+
const data = await serializer.deserializeNotebook(bytes.buffer, token);
|
|
155
|
+
return typeConverters.NotebookData.from(data);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async $notebookToData(handle: number, data: NotebookDataDto, token: CancellationToken): Promise<BinaryBuffer> {
|
|
159
|
+
const serializer = this.notebookSerializer.get(handle);
|
|
160
|
+
if (!serializer) {
|
|
161
|
+
throw new Error('No serializer found');
|
|
162
|
+
}
|
|
163
|
+
const bytes = await serializer.serializeNotebook(typeConverters.NotebookData.to(data), token);
|
|
164
|
+
return BinaryBuffer.wrap(bytes);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
registerNotebookCellStatusBarItemProvider(notebookType: string, provider: theia.NotebookCellStatusBarItemProvider): theia.Disposable {
|
|
168
|
+
|
|
169
|
+
const handle = this.currentSerializerHandle++;
|
|
170
|
+
const eventHandle = typeof provider.onDidChangeCellStatusBarItems === 'function' ? this.currentSerializerHandle++ : undefined;
|
|
171
|
+
|
|
172
|
+
this.notebookStatusBarItemProviders.set(handle, provider);
|
|
173
|
+
this.notebookProxy.$registerNotebookCellStatusBarItemProvider(handle, eventHandle, notebookType);
|
|
174
|
+
|
|
175
|
+
let subscription: theia.Disposable | undefined;
|
|
176
|
+
if (eventHandle !== undefined) {
|
|
177
|
+
subscription = provider.onDidChangeCellStatusBarItems!(_ => this.notebookProxy.$emitCellStatusBarEvent(eventHandle));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return Disposable.create(() => {
|
|
181
|
+
this.notebookStatusBarItemProviders.delete(handle);
|
|
182
|
+
this.notebookProxy.$unregisterNotebookCellStatusBarItemProvider(handle, eventHandle);
|
|
183
|
+
subscription?.dispose();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
getEditorById(editorId: string): NotebookEditor {
|
|
188
|
+
const editor = this.editors.get(editorId);
|
|
189
|
+
if (!editor) {
|
|
190
|
+
throw new Error(`unknown text editor: ${editorId}. known editors: ${[...this.editors.keys()]} `);
|
|
191
|
+
}
|
|
192
|
+
return editor;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
getAllApiDocuments(): theia.NotebookDocument[] {
|
|
196
|
+
return [...this.documents.values()].map(doc => doc.apiNotebook);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async $acceptDocumentsAndEditorsDelta(delta: NotebookDocumentsAndEditorsDelta): Promise<void> {
|
|
200
|
+
if (delta.removedDocuments) {
|
|
201
|
+
for (const uri of delta.removedDocuments) {
|
|
202
|
+
const revivedUri = URI.fromComponents(uri);
|
|
203
|
+
const document = this.documents.get(revivedUri.toString());
|
|
204
|
+
|
|
205
|
+
if (document) {
|
|
206
|
+
document.dispose();
|
|
207
|
+
this.documents.delete(revivedUri.toString());
|
|
208
|
+
this.onDidCloseNotebookDocumentEmitter.fire(document.apiNotebook);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
for (const editor of this.editors.values()) {
|
|
212
|
+
if (editor.notebookData.uri.toString() === revivedUri.toString()) {
|
|
213
|
+
this.editors.delete(editor.id);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (delta.addedDocuments) {
|
|
220
|
+
for (const modelData of delta.addedDocuments) {
|
|
221
|
+
const uri = TheiaURI.from(modelData.uri);
|
|
222
|
+
|
|
223
|
+
if (this.documents.has(uri.toString())) {
|
|
224
|
+
throw new Error(`adding EXISTING notebook ${uri} `);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const document = new NotebookDocument(
|
|
228
|
+
this.notebookDocumentsProxy,
|
|
229
|
+
this.textDocumentsAndEditors,
|
|
230
|
+
this.textDocuments,
|
|
231
|
+
uri,
|
|
232
|
+
modelData
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
this.documents.get(uri.toString())?.dispose();
|
|
236
|
+
this.documents.set(uri.toString(), document);
|
|
237
|
+
|
|
238
|
+
this.onDidOpenNotebookDocumentEmitter.fire(document.apiNotebook);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (delta.addedEditors) {
|
|
243
|
+
for (const editorModelData of delta.addedEditors) {
|
|
244
|
+
if (this.editors.has(editorModelData.id)) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const revivedUri = URI.fromComponents(editorModelData.documentUri);
|
|
249
|
+
const document = this.documents.get(revivedUri.toString());
|
|
250
|
+
|
|
251
|
+
if (document) {
|
|
252
|
+
this.createExtHostEditor(document, editorModelData.id, editorModelData);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const removedEditors: NotebookEditor[] = [];
|
|
258
|
+
|
|
259
|
+
if (delta.removedEditors) {
|
|
260
|
+
for (const editorId of delta.removedEditors) {
|
|
261
|
+
const editor = this.editors.get(editorId);
|
|
262
|
+
|
|
263
|
+
if (editor) {
|
|
264
|
+
this.editors.delete(editorId);
|
|
265
|
+
|
|
266
|
+
if (this.activeNotebookEditor?.id === editor.id) {
|
|
267
|
+
this.activeNotebookEditor = undefined;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
removedEditors.push(editor);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (delta.visibleEditors) {
|
|
276
|
+
this.visibleNotebookEditors = delta.visibleEditors.map(id => this.editors.get(id)!).filter(editor => !!editor) as NotebookEditor[];
|
|
277
|
+
const visibleEditorsSet = new Set<string>();
|
|
278
|
+
this.visibleNotebookEditors.forEach(editor => visibleEditorsSet.add(editor.id));
|
|
279
|
+
|
|
280
|
+
for (const editor of this.editors.values()) {
|
|
281
|
+
const newValue = visibleEditorsSet.has(editor.id);
|
|
282
|
+
editor.acceptVisibility(newValue);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
this.visibleNotebookEditors = [...this.editors.values()].map(e => e).filter(e => e.visible);
|
|
286
|
+
this.onDidChangeVisibleNotebookEditorsEmitter.fire(this.visibleApiNotebookEditors);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (delta.newActiveEditor === null) {
|
|
290
|
+
// clear active notebook as current active editor is non-notebook editor
|
|
291
|
+
this.activeNotebookEditor = undefined;
|
|
292
|
+
} else if (delta.newActiveEditor) {
|
|
293
|
+
const activeEditor = this.editors.get(delta.newActiveEditor);
|
|
294
|
+
if (!activeEditor) {
|
|
295
|
+
console.error(`FAILED to find active notebook editor ${delta.newActiveEditor}`);
|
|
296
|
+
}
|
|
297
|
+
this.activeNotebookEditor = this.editors.get(delta.newActiveEditor);
|
|
298
|
+
}
|
|
299
|
+
if (delta.newActiveEditor !== undefined) {
|
|
300
|
+
this.onDidChangeActiveNotebookEditorEmitter.fire(this.activeNotebookEditor?.apiEditor);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
getNotebookDocument(uri: TheiaURI, relaxed: true): NotebookDocument | undefined;
|
|
305
|
+
getNotebookDocument(uri: TheiaURI): NotebookDocument;
|
|
306
|
+
getNotebookDocument(uri: TheiaURI, relaxed?: true): NotebookDocument | undefined {
|
|
307
|
+
const result = this.documents.get(uri.toString());
|
|
308
|
+
if (!result && !relaxed) {
|
|
309
|
+
throw new Error(`NO notebook document for '${uri}'`);
|
|
310
|
+
}
|
|
311
|
+
return result;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
private createExtHostEditor(document: NotebookDocument, editorId: string, data: NotebookEditorAddData): void {
|
|
315
|
+
|
|
316
|
+
if (this.editors.has(editorId)) {
|
|
317
|
+
throw new Error(`editor with id ALREADY EXISTS: ${editorId}`);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const editor = new NotebookEditor(
|
|
321
|
+
editorId,
|
|
322
|
+
document,
|
|
323
|
+
data.visibleRanges.map(typeConverters.NotebookRange.to),
|
|
324
|
+
data.selections.map(typeConverters.NotebookRange.to),
|
|
325
|
+
typeof data.viewColumn === 'number' ? typeConverters.ViewColumn.to(data.viewColumn) : undefined
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
this.editors.set(editorId, editor);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async createNotebookDocument(options: { viewType: string; content?: theia.NotebookData }): Promise<TheiaURI> {
|
|
332
|
+
const canonicalUri = await this.notebookDocumentsProxy.$tryCreateNotebook({
|
|
333
|
+
viewType: options.viewType,
|
|
334
|
+
content: options.content && typeConverters.NotebookData.from(options.content)
|
|
335
|
+
});
|
|
336
|
+
return TheiaURI.from(canonicalUri);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async openNotebookDocument(uri: TheiaURI): Promise<theia.NotebookDocument> {
|
|
340
|
+
const cached = this.documents.get(uri.toString());
|
|
341
|
+
if (cached) {
|
|
342
|
+
return cached.apiNotebook;
|
|
343
|
+
}
|
|
344
|
+
const canonicalUri = await this.notebookDocumentsProxy.$tryOpenNotebook(uri);
|
|
345
|
+
const document = this.documents.get(URI.fromComponents(canonicalUri).toString());
|
|
346
|
+
return document?.apiNotebook!;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async showNotebookDocument(notebookOrUri: theia.NotebookDocument | TheiaURI, options?: theia.NotebookDocumentShowOptions): Promise<theia.NotebookEditor> {
|
|
350
|
+
|
|
351
|
+
if (URI.isUri(notebookOrUri)) {
|
|
352
|
+
notebookOrUri = await this.openNotebookDocument(notebookOrUri as TheiaURI);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const notebook = notebookOrUri as theia.NotebookDocument;
|
|
356
|
+
|
|
357
|
+
let resolvedOptions: NotebookDocumentShowOptions;
|
|
358
|
+
if (typeof options === 'object') {
|
|
359
|
+
resolvedOptions = {
|
|
360
|
+
position: typeConverters.ViewColumn.from(options.viewColumn),
|
|
361
|
+
preserveFocus: options.preserveFocus,
|
|
362
|
+
selections: options.selections && options.selections.map(typeConverters.NotebookRange.from),
|
|
363
|
+
pinned: typeof options.preview === 'boolean' ? !options.preview : undefined
|
|
364
|
+
};
|
|
365
|
+
} else {
|
|
366
|
+
resolvedOptions = {
|
|
367
|
+
preserveFocus: false
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const editorId = await this.notebookEditors.$tryShowNotebookDocument(notebook.uri, notebook.notebookType, resolvedOptions);
|
|
372
|
+
const editor = editorId && this.editors.get(editorId)?.apiEditor;
|
|
373
|
+
|
|
374
|
+
if (editor) {
|
|
375
|
+
return editor;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (editorId) {
|
|
379
|
+
throw new Error(`Could NOT open editor for "${notebook.uri.toString()}" because another editor opened in the meantime.`);
|
|
380
|
+
} else {
|
|
381
|
+
throw new Error(`Could NOT open editor for "${notebook.uri.toString()}".`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
}
|