@theia/notebook 1.53.0-next.55 → 1.53.0-next.64
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/README.md +30 -30
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +1 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/notebook-frontend-module.d.ts.map +1 -1
- package/lib/browser/notebook-frontend-module.js +2 -0
- package/lib/browser/notebook-frontend-module.js.map +1 -1
- package/lib/browser/service/notebook-cell-editor-service.d.ts +16 -0
- package/lib/browser/service/notebook-cell-editor-service.d.ts.map +1 -0
- package/lib/browser/service/notebook-cell-editor-service.js +53 -0
- package/lib/browser/service/notebook-cell-editor-service.js.map +1 -0
- package/lib/browser/view/notebook-cell-editor.d.ts +2 -0
- package/lib/browser/view/notebook-cell-editor.d.ts.map +1 -1
- package/lib/browser/view/notebook-cell-editor.js +12 -1
- package/lib/browser/view/notebook-cell-editor.js.map +1 -1
- package/lib/browser/view/notebook-code-cell-view.d.ts +2 -0
- package/lib/browser/view/notebook-code-cell-view.d.ts.map +1 -1
- package/lib/browser/view/notebook-code-cell-view.js +6 -1
- package/lib/browser/view/notebook-code-cell-view.js.map +1 -1
- package/lib/browser/view/notebook-markdown-cell-view.d.ts +2 -0
- package/lib/browser/view/notebook-markdown-cell-view.d.ts.map +1 -1
- package/lib/browser/view/notebook-markdown-cell-view.js +8 -3
- package/lib/browser/view/notebook-markdown-cell-view.js.map +1 -1
- package/package.json +7 -7
- package/src/browser/contributions/cell-operations.ts +44 -44
- package/src/browser/contributions/notebook-actions-contribution.ts +379 -379
- package/src/browser/contributions/notebook-cell-actions-contribution.ts +525 -525
- package/src/browser/contributions/notebook-color-contribution.ts +268 -268
- package/src/browser/contributions/notebook-context-keys.ts +113 -113
- package/src/browser/contributions/notebook-label-provider-contribution.ts +85 -85
- package/src/browser/contributions/notebook-outline-contribution.ts +114 -114
- package/src/browser/contributions/notebook-output-action-contribution.ts +82 -82
- package/src/browser/contributions/notebook-preferences.ts +92 -92
- package/src/browser/contributions/notebook-status-bar-contribution.ts +77 -77
- package/src/browser/contributions/notebook-undo-redo-handler.ts +41 -41
- package/src/browser/index.ts +28 -27
- package/src/browser/notebook-cell-resource-resolver.ts +130 -130
- package/src/browser/notebook-editor-widget-factory.ts +82 -82
- package/src/browser/notebook-editor-widget.tsx +330 -330
- package/src/browser/notebook-frontend-module.ts +121 -119
- package/src/browser/notebook-open-handler.ts +120 -120
- package/src/browser/notebook-output-utils.ts +119 -119
- package/src/browser/notebook-renderer-registry.ts +85 -85
- package/src/browser/notebook-type-registry.ts +54 -54
- package/src/browser/notebook-types.ts +186 -186
- package/src/browser/renderers/cell-output-webview.ts +33 -33
- package/src/browser/service/notebook-cell-editor-service.ts +56 -0
- package/src/browser/service/notebook-clipboard-service.ts +43 -43
- package/src/browser/service/notebook-context-manager.ts +162 -162
- package/src/browser/service/notebook-editor-widget-service.ts +101 -101
- package/src/browser/service/notebook-execution-service.ts +139 -139
- package/src/browser/service/notebook-execution-state-service.ts +311 -311
- package/src/browser/service/notebook-kernel-history-service.ts +124 -124
- package/src/browser/service/notebook-kernel-quick-pick-service.ts +479 -479
- package/src/browser/service/notebook-kernel-service.ts +357 -357
- package/src/browser/service/notebook-model-resolver-service.ts +160 -160
- package/src/browser/service/notebook-monaco-text-model-service.ts +48 -48
- package/src/browser/service/notebook-options.ts +155 -155
- package/src/browser/service/notebook-renderer-messaging-service.ts +121 -121
- package/src/browser/service/notebook-service.ts +215 -215
- package/src/browser/style/index.css +484 -483
- package/src/browser/view/notebook-cell-editor.tsx +276 -263
- package/src/browser/view/notebook-cell-list-view.tsx +279 -279
- package/src/browser/view/notebook-cell-toolbar-factory.tsx +102 -102
- package/src/browser/view/notebook-cell-toolbar.tsx +74 -74
- package/src/browser/view/notebook-code-cell-view.tsx +355 -350
- package/src/browser/view/notebook-find-widget.tsx +335 -335
- package/src/browser/view/notebook-main-toolbar.tsx +235 -235
- package/src/browser/view/notebook-markdown-cell-view.tsx +215 -208
- package/src/browser/view/notebook-viewport-service.ts +61 -61
- package/src/browser/view-model/notebook-cell-model.ts +473 -473
- package/src/browser/view-model/notebook-cell-output-model.ts +100 -100
- package/src/browser/view-model/notebook-model.ts +550 -550
- package/src/common/index.ts +18 -18
- package/src/common/notebook-common.ts +337 -337
- package/src/common/notebook-protocol.ts +35 -35
- package/src/common/notebook-range.ts +30 -30
|
@@ -1,139 +1,139 @@
|
|
|
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 { inject, injectable } from '@theia/core/shared/inversify';
|
|
22
|
-
import { CellExecution, NotebookExecutionStateService } from '../service/notebook-execution-state-service';
|
|
23
|
-
import { CellKind, NotebookCellExecutionState } from '../../common';
|
|
24
|
-
import { NotebookCellModel } from '../view-model/notebook-cell-model';
|
|
25
|
-
import { NotebookModel } from '../view-model/notebook-model';
|
|
26
|
-
import { NotebookKernelService } from './notebook-kernel-service';
|
|
27
|
-
import { CommandService, Disposable } from '@theia/core';
|
|
28
|
-
import { NotebookKernelQuickPickService } from './notebook-kernel-quick-pick-service';
|
|
29
|
-
import { NotebookKernelHistoryService } from './notebook-kernel-history-service';
|
|
30
|
-
|
|
31
|
-
export interface CellExecutionParticipant {
|
|
32
|
-
onWillExecuteCell(executions: CellExecution[]): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@injectable()
|
|
36
|
-
export class NotebookExecutionService {
|
|
37
|
-
|
|
38
|
-
@inject(NotebookExecutionStateService)
|
|
39
|
-
protected notebookExecutionStateService: NotebookExecutionStateService;
|
|
40
|
-
|
|
41
|
-
@inject(NotebookKernelService)
|
|
42
|
-
protected notebookKernelService: NotebookKernelService;
|
|
43
|
-
|
|
44
|
-
@inject(NotebookKernelHistoryService)
|
|
45
|
-
protected notebookKernelHistoryService: NotebookKernelHistoryService;
|
|
46
|
-
|
|
47
|
-
@inject(CommandService)
|
|
48
|
-
protected commandService: CommandService;
|
|
49
|
-
|
|
50
|
-
@inject(NotebookKernelQuickPickService)
|
|
51
|
-
protected notebookKernelQuickPickService: NotebookKernelQuickPickService;
|
|
52
|
-
|
|
53
|
-
protected readonly cellExecutionParticipants = new Set<CellExecutionParticipant>();
|
|
54
|
-
|
|
55
|
-
async executeNotebookCells(notebook: NotebookModel, cells: Iterable<NotebookCellModel>): Promise<void> {
|
|
56
|
-
const cellsArr = Array.from(cells)
|
|
57
|
-
.filter(c => c.cellKind === CellKind.Code);
|
|
58
|
-
if (!cellsArr.length) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// create cell executions
|
|
63
|
-
const cellExecutions: [NotebookCellModel, CellExecution][] = [];
|
|
64
|
-
for (const cell of cellsArr) {
|
|
65
|
-
const cellExe = this.notebookExecutionStateService.getCellExecution(cell.uri);
|
|
66
|
-
if (!cellExe) {
|
|
67
|
-
cellExecutions.push([cell, this.notebookExecutionStateService.getOrCreateCellExecution(notebook.uri, cell.handle)]);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const kernel = await this.notebookKernelHistoryService.resolveSelectedKernel(notebook);
|
|
72
|
-
|
|
73
|
-
if (!kernel) {
|
|
74
|
-
// clear all pending cell executions
|
|
75
|
-
cellExecutions.forEach(cellExe => cellExe[1].complete({}));
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// filter cell executions based on selected kernel
|
|
80
|
-
const validCellExecutions: CellExecution[] = [];
|
|
81
|
-
for (const [cell, cellExecution] of cellExecutions) {
|
|
82
|
-
if (!kernel.supportedLanguages.includes(cell.language)) {
|
|
83
|
-
cellExecution.complete({});
|
|
84
|
-
} else {
|
|
85
|
-
validCellExecutions.push(cellExecution);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// request execution
|
|
90
|
-
if (validCellExecutions.length > 0) {
|
|
91
|
-
const cellRemoveListener = notebook.onDidAddOrRemoveCell(e => {
|
|
92
|
-
if (e.rawEvent.changes.some(c => c.deleteCount > 0)) {
|
|
93
|
-
const executionsToCancel = validCellExecutions.filter(exec => !notebook.cells.find(cell => cell.handle === exec.cellHandle));
|
|
94
|
-
if (executionsToCancel.length > 0) {
|
|
95
|
-
kernel.cancelNotebookCellExecution(notebook.uri, executionsToCancel.map(c => c.cellHandle));
|
|
96
|
-
executionsToCancel.forEach(exec => exec.complete({}));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
await this.runExecutionParticipants(validCellExecutions);
|
|
101
|
-
|
|
102
|
-
this.notebookKernelService.selectKernelForNotebook(kernel, notebook);
|
|
103
|
-
await kernel.executeNotebookCellsRequest(notebook.uri, validCellExecutions.map(c => c.cellHandle));
|
|
104
|
-
// the connecting state can change before the kernel resolves executeNotebookCellsRequest
|
|
105
|
-
const unconfirmed = validCellExecutions.filter(exe => exe.state === NotebookCellExecutionState.Unconfirmed);
|
|
106
|
-
if (unconfirmed.length) {
|
|
107
|
-
unconfirmed.forEach(exe => exe.complete({}));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
cellRemoveListener.dispose();
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
registerExecutionParticipant(participant: CellExecutionParticipant): Disposable {
|
|
116
|
-
this.cellExecutionParticipants.add(participant);
|
|
117
|
-
return Disposable.create(() => this.cellExecutionParticipants.delete(participant));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
protected async runExecutionParticipants(executions: CellExecution[]): Promise<void> {
|
|
121
|
-
for (const participant of this.cellExecutionParticipants) {
|
|
122
|
-
await participant.onWillExecuteCell(executions);
|
|
123
|
-
}
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async cancelNotebookCellHandles(notebook: NotebookModel, cells: Iterable<number>): Promise<void> {
|
|
128
|
-
const cellsArr = Array.from(cells);
|
|
129
|
-
const kernel = this.notebookKernelService.getSelectedOrSuggestedKernel(notebook);
|
|
130
|
-
if (kernel) {
|
|
131
|
-
await kernel.cancelNotebookCellExecution(notebook.uri, cellsArr);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async cancelNotebookCells(notebook: NotebookModel, cells: Iterable<NotebookCellModel>): Promise<void> {
|
|
136
|
-
this.cancelNotebookCellHandles(notebook, Array.from(cells, cell => cell.handle));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
}
|
|
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 { inject, injectable } from '@theia/core/shared/inversify';
|
|
22
|
+
import { CellExecution, NotebookExecutionStateService } from '../service/notebook-execution-state-service';
|
|
23
|
+
import { CellKind, NotebookCellExecutionState } from '../../common';
|
|
24
|
+
import { NotebookCellModel } from '../view-model/notebook-cell-model';
|
|
25
|
+
import { NotebookModel } from '../view-model/notebook-model';
|
|
26
|
+
import { NotebookKernelService } from './notebook-kernel-service';
|
|
27
|
+
import { CommandService, Disposable } from '@theia/core';
|
|
28
|
+
import { NotebookKernelQuickPickService } from './notebook-kernel-quick-pick-service';
|
|
29
|
+
import { NotebookKernelHistoryService } from './notebook-kernel-history-service';
|
|
30
|
+
|
|
31
|
+
export interface CellExecutionParticipant {
|
|
32
|
+
onWillExecuteCell(executions: CellExecution[]): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@injectable()
|
|
36
|
+
export class NotebookExecutionService {
|
|
37
|
+
|
|
38
|
+
@inject(NotebookExecutionStateService)
|
|
39
|
+
protected notebookExecutionStateService: NotebookExecutionStateService;
|
|
40
|
+
|
|
41
|
+
@inject(NotebookKernelService)
|
|
42
|
+
protected notebookKernelService: NotebookKernelService;
|
|
43
|
+
|
|
44
|
+
@inject(NotebookKernelHistoryService)
|
|
45
|
+
protected notebookKernelHistoryService: NotebookKernelHistoryService;
|
|
46
|
+
|
|
47
|
+
@inject(CommandService)
|
|
48
|
+
protected commandService: CommandService;
|
|
49
|
+
|
|
50
|
+
@inject(NotebookKernelQuickPickService)
|
|
51
|
+
protected notebookKernelQuickPickService: NotebookKernelQuickPickService;
|
|
52
|
+
|
|
53
|
+
protected readonly cellExecutionParticipants = new Set<CellExecutionParticipant>();
|
|
54
|
+
|
|
55
|
+
async executeNotebookCells(notebook: NotebookModel, cells: Iterable<NotebookCellModel>): Promise<void> {
|
|
56
|
+
const cellsArr = Array.from(cells)
|
|
57
|
+
.filter(c => c.cellKind === CellKind.Code);
|
|
58
|
+
if (!cellsArr.length) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// create cell executions
|
|
63
|
+
const cellExecutions: [NotebookCellModel, CellExecution][] = [];
|
|
64
|
+
for (const cell of cellsArr) {
|
|
65
|
+
const cellExe = this.notebookExecutionStateService.getCellExecution(cell.uri);
|
|
66
|
+
if (!cellExe) {
|
|
67
|
+
cellExecutions.push([cell, this.notebookExecutionStateService.getOrCreateCellExecution(notebook.uri, cell.handle)]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const kernel = await this.notebookKernelHistoryService.resolveSelectedKernel(notebook);
|
|
72
|
+
|
|
73
|
+
if (!kernel) {
|
|
74
|
+
// clear all pending cell executions
|
|
75
|
+
cellExecutions.forEach(cellExe => cellExe[1].complete({}));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// filter cell executions based on selected kernel
|
|
80
|
+
const validCellExecutions: CellExecution[] = [];
|
|
81
|
+
for (const [cell, cellExecution] of cellExecutions) {
|
|
82
|
+
if (!kernel.supportedLanguages.includes(cell.language)) {
|
|
83
|
+
cellExecution.complete({});
|
|
84
|
+
} else {
|
|
85
|
+
validCellExecutions.push(cellExecution);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// request execution
|
|
90
|
+
if (validCellExecutions.length > 0) {
|
|
91
|
+
const cellRemoveListener = notebook.onDidAddOrRemoveCell(e => {
|
|
92
|
+
if (e.rawEvent.changes.some(c => c.deleteCount > 0)) {
|
|
93
|
+
const executionsToCancel = validCellExecutions.filter(exec => !notebook.cells.find(cell => cell.handle === exec.cellHandle));
|
|
94
|
+
if (executionsToCancel.length > 0) {
|
|
95
|
+
kernel.cancelNotebookCellExecution(notebook.uri, executionsToCancel.map(c => c.cellHandle));
|
|
96
|
+
executionsToCancel.forEach(exec => exec.complete({}));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
await this.runExecutionParticipants(validCellExecutions);
|
|
101
|
+
|
|
102
|
+
this.notebookKernelService.selectKernelForNotebook(kernel, notebook);
|
|
103
|
+
await kernel.executeNotebookCellsRequest(notebook.uri, validCellExecutions.map(c => c.cellHandle));
|
|
104
|
+
// the connecting state can change before the kernel resolves executeNotebookCellsRequest
|
|
105
|
+
const unconfirmed = validCellExecutions.filter(exe => exe.state === NotebookCellExecutionState.Unconfirmed);
|
|
106
|
+
if (unconfirmed.length) {
|
|
107
|
+
unconfirmed.forEach(exe => exe.complete({}));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
cellRemoveListener.dispose();
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
registerExecutionParticipant(participant: CellExecutionParticipant): Disposable {
|
|
116
|
+
this.cellExecutionParticipants.add(participant);
|
|
117
|
+
return Disposable.create(() => this.cellExecutionParticipants.delete(participant));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
protected async runExecutionParticipants(executions: CellExecution[]): Promise<void> {
|
|
121
|
+
for (const participant of this.cellExecutionParticipants) {
|
|
122
|
+
await participant.onWillExecuteCell(executions);
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async cancelNotebookCellHandles(notebook: NotebookModel, cells: Iterable<number>): Promise<void> {
|
|
128
|
+
const cellsArr = Array.from(cells);
|
|
129
|
+
const kernel = this.notebookKernelService.getSelectedOrSuggestedKernel(notebook);
|
|
130
|
+
if (kernel) {
|
|
131
|
+
await kernel.cancelNotebookCellExecution(notebook.uri, cellsArr);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async cancelNotebookCells(notebook: NotebookModel, cells: Iterable<NotebookCellModel>): Promise<void> {
|
|
136
|
+
this.cancelNotebookCellHandles(notebook, Array.from(cells, cell => cell.handle));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
}
|