@theia/plugin-ext 1.40.1 → 1.41.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-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/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 +79 -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/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 +372 -13
- 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-github-resolver.ts +15 -8
- package/src/main/node/plugin-http-resolver.ts +15 -8
- 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 +77 -70
- package/src/plugin/plugin-manager.ts +9 -1
- 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 +370 -12
- 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/src/main/browser/custom-editors/undo-redo-service.ts +0 -120
|
@@ -0,0 +1,476 @@
|
|
|
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
|
+
// only type imports are allowed here since this runs in an iframe. All other code is not accessible
|
|
22
|
+
import type * as webviewCommunication from './webview-communication';
|
|
23
|
+
import type * as rendererApi from 'vscode-notebook-renderer';
|
|
24
|
+
import type { Disposable, Event } from '@theia/core';
|
|
25
|
+
|
|
26
|
+
declare const acquireVsCodeApi: () => ({
|
|
27
|
+
getState(): { [key: string]: unknown };
|
|
28
|
+
setState(data: { [key: string]: unknown }): void;
|
|
29
|
+
postMessage: (msg: unknown) => void;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
declare function __import(path: string): Promise<unknown>;
|
|
33
|
+
|
|
34
|
+
interface Listener<T> { fn: (evt: T) => void; thisArg: unknown };
|
|
35
|
+
|
|
36
|
+
interface EmitterLike<T> {
|
|
37
|
+
fire(data: T): void;
|
|
38
|
+
event: Event<T>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface RendererContext extends rendererApi.RendererContext<unknown> {
|
|
42
|
+
readonly onDidChangeSettings: Event<RenderOptions>;
|
|
43
|
+
readonly settings: RenderOptions;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface NotebookRendererEntrypoint {
|
|
47
|
+
readonly path: string;
|
|
48
|
+
readonly extends?: string
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export interface RenderOptions {
|
|
52
|
+
readonly lineLimit: number;
|
|
53
|
+
readonly outputScrolling: boolean;
|
|
54
|
+
readonly outputWordWrap: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface PreloadContext {
|
|
58
|
+
readonly isWorkspaceTrusted: boolean;
|
|
59
|
+
readonly rendererData: readonly webviewCommunication.RendererMetadata[];
|
|
60
|
+
readonly renderOptions: RenderOptions;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function outputWebviewPreload(ctx: PreloadContext): Promise<void> {
|
|
64
|
+
const theia = acquireVsCodeApi();
|
|
65
|
+
const renderFallbackErrorName = 'vscode.fallbackToNextRenderer';
|
|
66
|
+
|
|
67
|
+
function createEmitter<T>(listenerChange: (listeners: Set<Listener<T>>) => void = () => undefined): EmitterLike<T> {
|
|
68
|
+
const listeners = new Set<Listener<T>>();
|
|
69
|
+
return {
|
|
70
|
+
fire(data: T): void {
|
|
71
|
+
for (const listener of [...listeners]) {
|
|
72
|
+
listener.fn.call(listener.thisArg, data);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
event(fn, thisArg, disposables): Disposable {
|
|
76
|
+
const listenerObj = { fn, thisArg };
|
|
77
|
+
const disposable: Disposable = {
|
|
78
|
+
dispose: () => {
|
|
79
|
+
listeners.delete(listenerObj);
|
|
80
|
+
listenerChange(listeners);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
listeners.add(listenerObj);
|
|
85
|
+
listenerChange(listeners);
|
|
86
|
+
|
|
87
|
+
if (disposables) {
|
|
88
|
+
if ('push' in disposables) {
|
|
89
|
+
disposables.push(disposable);
|
|
90
|
+
} else {
|
|
91
|
+
disposables.add(disposable);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return disposable;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const settingChange: EmitterLike<RenderOptions> = createEmitter<RenderOptions>();
|
|
100
|
+
|
|
101
|
+
class Output {
|
|
102
|
+
readonly outputId: string;
|
|
103
|
+
renderedItem?: rendererApi.OutputItem;
|
|
104
|
+
allItems: rendererApi.OutputItem[];
|
|
105
|
+
|
|
106
|
+
renderer: Renderer;
|
|
107
|
+
|
|
108
|
+
element: HTMLElement;
|
|
109
|
+
|
|
110
|
+
constructor(output: webviewCommunication.Output, items: rendererApi.OutputItem[]) {
|
|
111
|
+
this.element = document.createElement('div');
|
|
112
|
+
// padding for scrollbars
|
|
113
|
+
this.element.style.paddingBottom = '10px';
|
|
114
|
+
this.element.style.paddingRight = '10px';
|
|
115
|
+
this.element.id = output.id;
|
|
116
|
+
document.body.appendChild(this.element);
|
|
117
|
+
|
|
118
|
+
this.allItems = items;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
findItemToRender(preferredMimetype?: string): rendererApi.OutputItem {
|
|
122
|
+
if (preferredMimetype) {
|
|
123
|
+
const itemToRender = this.allItems.find(item => item.mime === preferredMimetype);
|
|
124
|
+
if (itemToRender) {
|
|
125
|
+
return itemToRender;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return this.renderedItem ?? this.allItems[0];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
clear(): void {
|
|
132
|
+
this.renderer?.disposeOutputItem?.(this.renderedItem?.id);
|
|
133
|
+
this.element.innerHTML = '';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const outputs = new Map</* outputId */string, Output>();
|
|
138
|
+
|
|
139
|
+
class Renderer {
|
|
140
|
+
|
|
141
|
+
entrypoint: NotebookRendererEntrypoint;
|
|
142
|
+
|
|
143
|
+
private rendererApi?: rendererApi.RendererApi;
|
|
144
|
+
|
|
145
|
+
private onMessageEvent: EmitterLike<unknown> = createEmitter();
|
|
146
|
+
|
|
147
|
+
constructor(
|
|
148
|
+
public readonly data: webviewCommunication.RendererMetadata
|
|
149
|
+
) { }
|
|
150
|
+
|
|
151
|
+
public receiveMessage(message: unknown): void {
|
|
152
|
+
this.onMessageEvent.fire(message);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public disposeOutputItem(id?: string): void {
|
|
156
|
+
this.rendererApi?.disposeOutputItem?.(id);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async getOrLoad(): Promise<rendererApi.RendererApi | undefined> {
|
|
160
|
+
if (this.rendererApi) {
|
|
161
|
+
return this.rendererApi;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const rendererModule = await __import(this.data.entrypoint.uri) as { activate: rendererApi.ActivationFunction };
|
|
165
|
+
this.rendererApi = await rendererModule.activate(this.createRendererContext());
|
|
166
|
+
return this.rendererApi;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
protected createRendererContext(): RendererContext {
|
|
170
|
+
const context: RendererContext = {
|
|
171
|
+
setState: newState => theia.setState({ ...theia.getState(), [this.data.id]: newState }),
|
|
172
|
+
getState: <T>() => {
|
|
173
|
+
const state = theia.getState();
|
|
174
|
+
return typeof state === 'object' && state ? state[this.data.id] as T : undefined;
|
|
175
|
+
},
|
|
176
|
+
getRenderer: async (id: string) => {
|
|
177
|
+
const renderer = renderers.getRenderer(id);
|
|
178
|
+
if (!renderer) {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
if (renderer.rendererApi) {
|
|
182
|
+
return renderer.rendererApi;
|
|
183
|
+
}
|
|
184
|
+
return renderer.getOrLoad();
|
|
185
|
+
},
|
|
186
|
+
workspace: {
|
|
187
|
+
get isTrusted(): boolean { return true; } // TODO use Workspace trust service
|
|
188
|
+
},
|
|
189
|
+
settings: {
|
|
190
|
+
get lineLimit(): number { return ctx.renderOptions.lineLimit; },
|
|
191
|
+
get outputScrolling(): boolean { return ctx.renderOptions.outputScrolling; },
|
|
192
|
+
get outputWordWrap(): boolean { return ctx.renderOptions.outputWordWrap; },
|
|
193
|
+
},
|
|
194
|
+
get onDidChangeSettings(): Event<RenderOptions> { return settingChange.event; },
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
if (this.data.requiresMessaging) {
|
|
198
|
+
context.onDidReceiveMessage = this.onMessageEvent.event;
|
|
199
|
+
context.postMessage = message => theia.postMessage({ type: 'customRendererMessage', rendererId: this.data.id, message });
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return Object.freeze(context);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const renderers = new class {
|
|
207
|
+
private readonly renderers = new Map</* id */ string, Renderer>();
|
|
208
|
+
|
|
209
|
+
constructor() {
|
|
210
|
+
for (const renderer of ctx.rendererData) {
|
|
211
|
+
this.addRenderer(renderer);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public getRenderer(id: string): Renderer | undefined {
|
|
216
|
+
return this.renderers.get(id);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private rendererEqual(a: webviewCommunication.RendererMetadata, b: webviewCommunication.RendererMetadata): boolean {
|
|
220
|
+
if (a.id !== b.id || a.entrypoint.uri !== b.entrypoint.uri || a.entrypoint.extends !== b.entrypoint.extends || a.requiresMessaging !== b.requiresMessaging) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (a.mimeTypes.length !== b.mimeTypes.length) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
for (let i = 0; i < a.mimeTypes.length; i++) {
|
|
229
|
+
if (a.mimeTypes[i] !== b.mimeTypes[i]) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public updateRendererData(rendererData: readonly webviewCommunication.RendererMetadata[]): void {
|
|
238
|
+
const oldKeys = new Set(this.renderers.keys());
|
|
239
|
+
const newKeys = new Set(rendererData.map(d => d.id));
|
|
240
|
+
|
|
241
|
+
for (const renderer of rendererData) {
|
|
242
|
+
const existing = this.renderers.get(renderer.id);
|
|
243
|
+
if (existing && this.rendererEqual(existing.data, renderer)) {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
this.addRenderer(renderer);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
for (const key of oldKeys) {
|
|
251
|
+
if (!newKeys.has(key)) {
|
|
252
|
+
this.renderers.delete(key);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private addRenderer(renderer: webviewCommunication.RendererMetadata): void {
|
|
258
|
+
this.renderers.set(renderer.id, new Renderer(renderer));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
public clearAll(): void {
|
|
262
|
+
for (const renderer of this.renderers.values()) {
|
|
263
|
+
renderer.disposeOutputItem();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
public clearOutput(rendererId: string, outputId: string): void {
|
|
268
|
+
// outputRunner.cancelOutput(outputId);
|
|
269
|
+
this.renderers.get(rendererId)?.disposeOutputItem(outputId);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
public async render(output: Output, preferredMimeType: string | undefined, preferredRendererId: string | undefined, signal: AbortSignal): Promise<void> {
|
|
273
|
+
const item = output.findItemToRender(preferredMimeType);
|
|
274
|
+
const primaryRenderer = this.findRenderer(preferredRendererId, item);
|
|
275
|
+
if (!primaryRenderer) {
|
|
276
|
+
this.showRenderError(item, output.element, 'No renderer found for output type.');
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Try primary renderer first
|
|
281
|
+
if (!(await this.doRender(item, output.element, primaryRenderer, signal)).continue) {
|
|
282
|
+
output.renderer = primaryRenderer;
|
|
283
|
+
this.onRenderCompleted();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Primary renderer failed in an expected way. Fallback to render the next mime types
|
|
288
|
+
for (const additionalItem of output.allItems) {
|
|
289
|
+
if (additionalItem.mime === item.mime) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (signal.aborted) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (additionalItem) {
|
|
298
|
+
const renderer = this.findRenderer(undefined, additionalItem);
|
|
299
|
+
if (renderer) {
|
|
300
|
+
if (!(await this.doRender(additionalItem, output.element, renderer, signal)).continue) {
|
|
301
|
+
output.renderer = renderer;
|
|
302
|
+
this.onRenderCompleted();
|
|
303
|
+
return; // We rendered successfully
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// All renderers have failed and there is nothing left to fallback to
|
|
310
|
+
this.showRenderError(item, output.element, 'No fallback renderers found or all fallback renderers failed.');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private onRenderCompleted(): void {
|
|
314
|
+
// we need to check for all images are loaded. Otherwise we can't determine the correct height of the output
|
|
315
|
+
const images = Array.from(document.images);
|
|
316
|
+
if (images.length > 0) {
|
|
317
|
+
Promise.all(images.filter(img => !img.complete).map(img => new Promise(resolve => { img.onload = img.onerror = resolve; }))).then(() =>
|
|
318
|
+
theia.postMessage(<webviewCommunication.OnDidRenderOutput>{ type: 'didRenderOutput', contentHeight: document.body.clientHeight }));
|
|
319
|
+
} else {
|
|
320
|
+
theia.postMessage(<webviewCommunication.OnDidRenderOutput>{ type: 'didRenderOutput', contentHeight: document.body.clientHeight });
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private async doRender(item: rendererApi.OutputItem, element: HTMLElement, renderer: Renderer, signal: AbortSignal): Promise<{ continue: boolean }> {
|
|
326
|
+
try {
|
|
327
|
+
(await renderer.getOrLoad())?.renderOutputItem(item, element, signal);
|
|
328
|
+
return { continue: false }; // We rendered successfully
|
|
329
|
+
} catch (e) {
|
|
330
|
+
if (signal.aborted) {
|
|
331
|
+
return { continue: false };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (e instanceof Error && e.name === renderFallbackErrorName) {
|
|
335
|
+
return { continue: true };
|
|
336
|
+
} else {
|
|
337
|
+
throw e; // Bail and let callers handle unknown errors
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
private findRenderer(preferredRendererId: string | undefined, info: rendererApi.OutputItem): Renderer | undefined {
|
|
343
|
+
let foundRenderer: Renderer | undefined;
|
|
344
|
+
|
|
345
|
+
if (typeof preferredRendererId === 'string') {
|
|
346
|
+
foundRenderer = Array.from(this.renderers.values())
|
|
347
|
+
.find(renderer => renderer.data.id === preferredRendererId);
|
|
348
|
+
} else {
|
|
349
|
+
const rendererList = Array.from(this.renderers.values())
|
|
350
|
+
.filter(renderer => renderer.data.mimeTypes.includes(info.mime) && !renderer.data.entrypoint.extends);
|
|
351
|
+
|
|
352
|
+
if (rendererList.length) {
|
|
353
|
+
// De-prioritize built-in renderers
|
|
354
|
+
// rendererList.sort((a, b) => +a.data.isBuiltin - +b.data.isBuiltin);
|
|
355
|
+
|
|
356
|
+
// Use first renderer we find in sorted list
|
|
357
|
+
foundRenderer = rendererList[0];
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return foundRenderer;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
private showRenderError(info: rendererApi.OutputItem, element: HTMLElement, errorMessage: string): void {
|
|
364
|
+
const errorContainer = document.createElement('div');
|
|
365
|
+
|
|
366
|
+
const error = document.createElement('div');
|
|
367
|
+
error.className = 'no-renderer-error';
|
|
368
|
+
error.innerText = errorMessage;
|
|
369
|
+
|
|
370
|
+
const cellText = document.createElement('div');
|
|
371
|
+
cellText.innerText = info.text();
|
|
372
|
+
|
|
373
|
+
errorContainer.appendChild(error);
|
|
374
|
+
errorContainer.appendChild(cellText);
|
|
375
|
+
|
|
376
|
+
element.innerText = '';
|
|
377
|
+
element.appendChild(errorContainer);
|
|
378
|
+
}
|
|
379
|
+
}();
|
|
380
|
+
|
|
381
|
+
function clearOutput(outputId: string): void {
|
|
382
|
+
outputs.get(outputId)?.clear();
|
|
383
|
+
outputs.delete(outputId);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function outputsChanged(changedEvent: webviewCommunication.OutputChangedMessage): void {
|
|
387
|
+
for (const outputId of changedEvent.deletedOutputIds ?? []) {
|
|
388
|
+
clearOutput(outputId);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
for (const outputData of changedEvent.newOutputs ?? []) {
|
|
392
|
+
const apiItems: rendererApi.OutputItem[] = outputData.items.map((item, index) => ({
|
|
393
|
+
id: `${outputData.id}-${index}`,
|
|
394
|
+
mime: item.mime,
|
|
395
|
+
metadata: outputData.metadata,
|
|
396
|
+
data(): Uint8Array {
|
|
397
|
+
return item.data;
|
|
398
|
+
},
|
|
399
|
+
text(): string {
|
|
400
|
+
return new TextDecoder().decode(this.data());
|
|
401
|
+
},
|
|
402
|
+
json(): unknown {
|
|
403
|
+
return JSON.parse(this.text());
|
|
404
|
+
},
|
|
405
|
+
blob(): Blob {
|
|
406
|
+
return new Blob([this.data()], { type: this.mime });
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
}));
|
|
410
|
+
|
|
411
|
+
const output = new Output(outputData, apiItems);
|
|
412
|
+
outputs.set(outputData.id, output);
|
|
413
|
+
|
|
414
|
+
renderers.render(output, undefined, undefined, new AbortController().signal);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function scrollParent(event: WheelEvent): boolean {
|
|
419
|
+
for (let node = event.target as Node | null; node; node = node.parentNode) {
|
|
420
|
+
if (!(node instanceof Element)) {
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// scroll up
|
|
425
|
+
if (event.deltaY < 0 && node.scrollTop > 0) {
|
|
426
|
+
// there is still some content to scroll
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// scroll down
|
|
431
|
+
if (event.deltaY > 0 && node.scrollTop + node.clientHeight < node.scrollHeight) {
|
|
432
|
+
// per https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight
|
|
433
|
+
// scrollTop is not rounded but scrollHeight and clientHeight are
|
|
434
|
+
// so we need to check if the difference is less than some threshold
|
|
435
|
+
if (node.scrollHeight - node.scrollTop - node.clientHeight > 2) {
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const handleWheel = (event: WheelEvent & { wheelDeltaX?: number; wheelDeltaY?: number; wheelDelta?: number }) => {
|
|
445
|
+
if (scrollParent(event)) {
|
|
446
|
+
theia.postMessage({
|
|
447
|
+
type: 'did-scroll-wheel',
|
|
448
|
+
deltaY: event.deltaY,
|
|
449
|
+
deltaX: event.deltaX,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
window.addEventListener('message', async rawEvent => {
|
|
455
|
+
const event = rawEvent as ({ data: webviewCommunication.ToWebviewMessage });
|
|
456
|
+
|
|
457
|
+
switch (event.data.type) {
|
|
458
|
+
case 'updateRenderers':
|
|
459
|
+
renderers.updateRendererData(event.data.rendererData);
|
|
460
|
+
break;
|
|
461
|
+
case 'outputChanged':
|
|
462
|
+
outputsChanged(event.data);
|
|
463
|
+
break;
|
|
464
|
+
case 'customRendererMessage':
|
|
465
|
+
renderers.getRenderer(event.data.rendererId)?.receiveMessage(event.data.message);
|
|
466
|
+
break;
|
|
467
|
+
case 'changePreferredMimetype':
|
|
468
|
+
clearOutput(event.data.outputId);
|
|
469
|
+
renderers.render(outputs.get(event.data.outputId)!, event.data.mimeType, undefined, new AbortController().signal);
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
window.addEventListener('wheel', handleWheel);
|
|
474
|
+
|
|
475
|
+
theia.postMessage(<webviewCommunication.WebviewInitialized>{ type: 'initialized' });
|
|
476
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
export interface RendererMetadata {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly entrypoint: { readonly uri: string, readonly extends?: string; };
|
|
24
|
+
readonly mimeTypes: readonly string[];
|
|
25
|
+
readonly requiresMessaging: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CustomRendererMessage {
|
|
29
|
+
readonly type: 'customRendererMessage';
|
|
30
|
+
readonly rendererId: string;
|
|
31
|
+
readonly message: unknown;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface UpdateRenderersMessage {
|
|
35
|
+
readonly type: 'updateRenderers';
|
|
36
|
+
readonly rendererData: readonly RendererMetadata[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface OutputChangedMessage {
|
|
40
|
+
readonly type: 'outputChanged';
|
|
41
|
+
readonly newOutputs?: Output[];
|
|
42
|
+
readonly deletedOutputIds?: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ChangePreferredMimetypeMessage {
|
|
46
|
+
readonly type: 'changePreferredMimetype';
|
|
47
|
+
readonly outputId: string;
|
|
48
|
+
readonly mimeType: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type ToWebviewMessage = UpdateRenderersMessage | OutputChangedMessage | ChangePreferredMimetypeMessage | CustomRendererMessage;
|
|
52
|
+
|
|
53
|
+
export interface WebviewInitialized {
|
|
54
|
+
readonly type: 'initialized';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface OnDidRenderOutput {
|
|
58
|
+
readonly type: 'didRenderOutput';
|
|
59
|
+
contentHeight: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface WheelMessage {
|
|
63
|
+
readonly type: 'did-scroll-wheel';
|
|
64
|
+
readonly deltaY: number;
|
|
65
|
+
readonly deltaX: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type FromWebviewMessage = WebviewInitialized | OnDidRenderOutput | WheelMessage | CustomRendererMessage;
|
|
69
|
+
|
|
70
|
+
export interface Output {
|
|
71
|
+
id: string
|
|
72
|
+
metadata?: Record<string, unknown>;
|
|
73
|
+
items: OutputItem[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface OutputItem {
|
|
77
|
+
readonly mime: string;
|
|
78
|
+
readonly data: Uint8Array;
|
|
79
|
+
}
|
|
@@ -21,13 +21,16 @@ import { TextmateRegistry, getEncodedLanguageId, MonacoTextmateService, GrammarD
|
|
|
21
21
|
import { MenusContributionPointHandler } from './menus/menus-contribution-handler';
|
|
22
22
|
import { PluginViewRegistry } from './view/plugin-view-registry';
|
|
23
23
|
import { PluginCustomEditorRegistry } from './custom-editors/plugin-custom-editor-registry';
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
PluginContribution, IndentationRules, FoldingRules, ScopeMap, DeployedPlugin,
|
|
26
|
+
GrammarsContribution, EnterAction, OnEnterRule, RegExpOptions, getPluginId
|
|
27
|
+
} from '../../common';
|
|
25
28
|
import {
|
|
26
29
|
DefaultUriLabelProviderContribution,
|
|
27
30
|
LabelProviderContribution,
|
|
28
31
|
PreferenceSchemaProvider
|
|
29
32
|
} from '@theia/core/lib/browser';
|
|
30
|
-
import { PreferenceLanguageOverrideService, PreferenceSchema, PreferenceSchemaProperties } from '@theia/core/lib/browser/preferences';
|
|
33
|
+
import { DefaultOverridesPreferenceSchemaId, PreferenceLanguageOverrideService, PreferenceSchema, PreferenceSchemaProperties } from '@theia/core/lib/browser/preferences';
|
|
31
34
|
import { KeybindingsContributionPointHandler } from './keybindings/keybindings-contribution-handler';
|
|
32
35
|
import { MonacoSnippetSuggestProvider } from '@theia/monaco/lib/browser/monaco-snippet-suggest-provider';
|
|
33
36
|
import { PluginSharedStyle } from './plugin-shared-style';
|
|
@@ -35,6 +38,7 @@ import { CommandRegistry, Command, CommandHandler } from '@theia/core/lib/common
|
|
|
35
38
|
import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
36
39
|
import { Emitter } from '@theia/core/lib/common/event';
|
|
37
40
|
import { TaskDefinitionRegistry, ProblemMatcherRegistry, ProblemPatternRegistry } from '@theia/task/lib/browser';
|
|
41
|
+
import { NotebookRendererRegistry, NotebookTypeRegistry } from '@theia/notebook/lib/browser';
|
|
38
42
|
import { PluginDebugService } from './debug/plugin-debug-service';
|
|
39
43
|
import { DebugSchemaUpdater } from '@theia/debug/lib/browser/debug-schema-updater';
|
|
40
44
|
import { MonacoThemingService } from '@theia/monaco/lib/browser/monaco-theming-service';
|
|
@@ -120,6 +124,12 @@ export class PluginContributionHandler {
|
|
|
120
124
|
@inject(ContributedTerminalProfileStore)
|
|
121
125
|
protected readonly contributedProfileStore: TerminalProfileStore;
|
|
122
126
|
|
|
127
|
+
@inject(NotebookTypeRegistry)
|
|
128
|
+
protected readonly notebookTypeRegistry: NotebookTypeRegistry;
|
|
129
|
+
|
|
130
|
+
@inject(NotebookRendererRegistry)
|
|
131
|
+
protected readonly notebookRendererRegistry: NotebookRendererRegistry;
|
|
132
|
+
|
|
123
133
|
@inject(ContributionProvider) @named(LabelProviderContribution)
|
|
124
134
|
protected readonly contributionProvider: ContributionProvider<LabelProviderContribution>;
|
|
125
135
|
|
|
@@ -395,6 +405,22 @@ export class PluginContributionHandler {
|
|
|
395
405
|
}
|
|
396
406
|
}
|
|
397
407
|
|
|
408
|
+
if (contributions.notebooks) {
|
|
409
|
+
for (const notebook of contributions.notebooks) {
|
|
410
|
+
pushContribution(`notebook.${notebook.type}`,
|
|
411
|
+
() => this.notebookTypeRegistry.registerNotebookType(notebook)
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (contributions.notebookRenderer) {
|
|
417
|
+
for (const renderer of contributions.notebookRenderer) {
|
|
418
|
+
pushContribution(`notebookRenderer.${renderer.id}`,
|
|
419
|
+
() => this.notebookRendererRegistry.registerNotebookRenderer(renderer, `/hostedPlugin/${getPluginId(plugin.metadata.model)}`)
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
398
424
|
return toDispose;
|
|
399
425
|
}
|
|
400
426
|
|
|
@@ -487,7 +513,7 @@ export class PluginContributionHandler {
|
|
|
487
513
|
|
|
488
514
|
protected updateDefaultOverridesSchema(configurationDefaults: PreferenceSchemaProperties): Disposable {
|
|
489
515
|
const defaultOverrides: PreferenceSchema = {
|
|
490
|
-
id:
|
|
516
|
+
id: DefaultOverridesPreferenceSchemaId,
|
|
491
517
|
title: 'Default Configuration Overrides',
|
|
492
518
|
properties: {}
|
|
493
519
|
};
|
|
@@ -495,11 +521,18 @@ export class PluginContributionHandler {
|
|
|
495
521
|
for (const key in configurationDefaults) {
|
|
496
522
|
const defaultValue = configurationDefaults[key];
|
|
497
523
|
if (this.preferenceOverrideService.testOverrideValue(key, defaultValue)) {
|
|
524
|
+
// language specific override
|
|
498
525
|
defaultOverrides.properties[key] = {
|
|
499
526
|
type: 'object',
|
|
500
527
|
default: defaultValue,
|
|
501
528
|
description: `Configure editor settings to be overridden for ${key} language.`
|
|
502
529
|
};
|
|
530
|
+
} else {
|
|
531
|
+
// regular configuration override
|
|
532
|
+
defaultOverrides.properties[key] = {
|
|
533
|
+
default: defaultValue,
|
|
534
|
+
description: `Configure default setting for ${key}.`
|
|
535
|
+
};
|
|
503
536
|
}
|
|
504
537
|
}
|
|
505
538
|
if (Object.keys(defaultOverrides.properties).length) {
|
|
@@ -72,7 +72,6 @@ import { PluginCustomEditorRegistry } from './custom-editors/plugin-custom-edito
|
|
|
72
72
|
import { CustomEditorWidgetFactory } from '../browser/custom-editors/custom-editor-widget-factory';
|
|
73
73
|
import { CustomEditorWidget } from './custom-editors/custom-editor-widget';
|
|
74
74
|
import { CustomEditorService } from './custom-editors/custom-editor-service';
|
|
75
|
-
import { UndoRedoService } from './custom-editors/undo-redo-service';
|
|
76
75
|
import { WebviewFrontendSecurityWarnings } from './webview/webview-frontend-security-warnings';
|
|
77
76
|
import { PluginAuthenticationServiceImpl } from './plugin-authentication-service';
|
|
78
77
|
import { AuthenticationService } from '@theia/core/lib/browser/authentication-service';
|
|
@@ -85,6 +84,9 @@ import { DnDFileContentStore } from './view/dnd-file-content-store';
|
|
|
85
84
|
import { WebviewContextKeys } from './webview/webview-context-keys';
|
|
86
85
|
import { LanguagePackService, languagePackServicePath } from '../../common/language-pack-service';
|
|
87
86
|
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
87
|
+
import { CellOutputWebviewFactory } from '@theia/notebook/lib/browser';
|
|
88
|
+
import { CellOutputWebviewImpl, createCellOutputWebviewContainer } from './notebooks/renderers/cell-output-webview';
|
|
89
|
+
import { NotebookCellModel } from '@theia/notebook/lib/browser/view-model/notebook-cell-model';
|
|
88
90
|
|
|
89
91
|
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
90
92
|
|
|
@@ -193,8 +195,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
|
193
195
|
bind(CustomEditorWidgetFactory).toDynamicValue(ctx => new CustomEditorWidgetFactory(ctx.container)).inSingletonScope();
|
|
194
196
|
bind(WidgetFactory).toService(CustomEditorWidgetFactory);
|
|
195
197
|
|
|
196
|
-
bind(UndoRedoService).toSelf().inSingletonScope();
|
|
197
|
-
|
|
198
198
|
bind(PluginViewWidget).toSelf();
|
|
199
199
|
bind(WidgetFactory).toDynamicValue(({ container }) => ({
|
|
200
200
|
id: PLUGIN_VIEW_FACTORY_ID,
|
|
@@ -257,4 +257,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
|
257
257
|
const provider = ctx.container.get(WebSocketConnectionProvider);
|
|
258
258
|
return provider.createProxy<LanguagePackService>(languagePackServicePath);
|
|
259
259
|
}).inSingletonScope();
|
|
260
|
+
|
|
261
|
+
bind(CellOutputWebviewFactory).toFactory(ctx => async (cell: NotebookCellModel) =>
|
|
262
|
+
createCellOutputWebviewContainer(ctx.container, cell).getAsync(CellOutputWebviewImpl)
|
|
263
|
+
);
|
|
260
264
|
});
|