@codingame/monaco-vscode-notebook-service-override 1.85.1
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/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
- package/external/tslib/tslib.es6.js +11 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/notebook.d.ts +5 -0
- package/notebook.js +44 -0
- package/override/vs/platform/dialogs/common/dialogs.js +8 -0
- package/package.json +32 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +387 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +668 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +109 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +319 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +58 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +485 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +106 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +165 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +238 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +168 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +317 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +209 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +87 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +82 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +93 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +383 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +51 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +46 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +135 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +383 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +117 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +511 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +168 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +57 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +94 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +51 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +702 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +268 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +45 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1297 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +284 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +563 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +108 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +313 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +872 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +13 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +393 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +175 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +1121 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +159 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +339 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +41 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +182 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +106 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +509 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +133 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +342 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +111 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +28 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +666 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +200 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +80 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +1001 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +202 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +80 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +98 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +217 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +89 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +372 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopy.js +706 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +407 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +144 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +129 -0
- package/worker.js +1 -0
- package/workers/notebook.worker.js +9 -0
package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
3
|
+
import { Disposable, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
4
|
+
import { ResourceMap, LRUCache } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
5
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
6
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
7
|
+
import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
|
|
8
|
+
import { MenuId, IMenuService } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
9
|
+
import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
10
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
11
|
+
import { $window } from 'monaco-editor/esm/vs/base/browser/window.js';
|
|
12
|
+
import { runWhenWindowIdle } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
13
|
+
|
|
14
|
+
var NotebookKernelService_1;
|
|
15
|
+
class KernelInfo {
|
|
16
|
+
static { this._logicClock = 0; }
|
|
17
|
+
constructor(kernel) {
|
|
18
|
+
this.notebookPriorities = ( new ResourceMap());
|
|
19
|
+
this.kernel = kernel;
|
|
20
|
+
this.score = -1;
|
|
21
|
+
this.time = KernelInfo._logicClock++;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class NotebookTextModelLikeId {
|
|
25
|
+
static str(k) {
|
|
26
|
+
return `${k.viewType}/${( k.uri.toString())}`;
|
|
27
|
+
}
|
|
28
|
+
static obj(s) {
|
|
29
|
+
const idx = s.indexOf('/');
|
|
30
|
+
return {
|
|
31
|
+
viewType: s.substring(0, idx),
|
|
32
|
+
uri: ( URI.parse(s.substring(idx + 1)))
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class SourceAction extends Disposable {
|
|
37
|
+
constructor(action, model, isPrimary) {
|
|
38
|
+
super();
|
|
39
|
+
this.action = action;
|
|
40
|
+
this.model = model;
|
|
41
|
+
this.isPrimary = isPrimary;
|
|
42
|
+
this._onDidChangeState = this._register(( new Emitter()));
|
|
43
|
+
this.onDidChangeState = this._onDidChangeState.event;
|
|
44
|
+
}
|
|
45
|
+
async runAction() {
|
|
46
|
+
if (this.execution) {
|
|
47
|
+
return this.execution;
|
|
48
|
+
}
|
|
49
|
+
this.execution = this._runAction();
|
|
50
|
+
this._onDidChangeState.fire();
|
|
51
|
+
await this.execution;
|
|
52
|
+
this.execution = undefined;
|
|
53
|
+
this._onDidChangeState.fire();
|
|
54
|
+
}
|
|
55
|
+
async _runAction() {
|
|
56
|
+
try {
|
|
57
|
+
await this.action.run({
|
|
58
|
+
uri: this.model.uri,
|
|
59
|
+
$mid: 14
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.warn(`Kernel source command failed: ${error}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
let NotebookKernelService = class NotebookKernelService extends Disposable {
|
|
68
|
+
static { NotebookKernelService_1 = this; }
|
|
69
|
+
static { this._storageNotebookBinding = 'notebook.controller2NotebookBindings'; }
|
|
70
|
+
constructor(_notebookService, _storageService, _menuService, _contextKeyService) {
|
|
71
|
+
super();
|
|
72
|
+
this._notebookService = _notebookService;
|
|
73
|
+
this._storageService = _storageService;
|
|
74
|
+
this._menuService = _menuService;
|
|
75
|
+
this._contextKeyService = _contextKeyService;
|
|
76
|
+
this._kernels = ( new Map());
|
|
77
|
+
this._notebookBindings = ( new LRUCache(1000, 0.7));
|
|
78
|
+
this._onDidChangeNotebookKernelBinding = this._register(( new Emitter()));
|
|
79
|
+
this._onDidAddKernel = this._register(( new Emitter()));
|
|
80
|
+
this._onDidRemoveKernel = this._register(( new Emitter()));
|
|
81
|
+
this._onDidChangeNotebookAffinity = this._register(( new Emitter()));
|
|
82
|
+
this._onDidChangeSourceActions = this._register(( new Emitter()));
|
|
83
|
+
this._onDidNotebookVariablesChange = this._register(( new Emitter()));
|
|
84
|
+
this._kernelSources = ( new Map());
|
|
85
|
+
this._kernelSourceActionsUpdates = ( new Map());
|
|
86
|
+
this._kernelDetectionTasks = ( new Map());
|
|
87
|
+
this._onDidChangeKernelDetectionTasks = this._register(( new Emitter()));
|
|
88
|
+
this._kernelSourceActionProviders = ( new Map());
|
|
89
|
+
this.onDidChangeSelectedNotebooks = this._onDidChangeNotebookKernelBinding.event;
|
|
90
|
+
this.onDidAddKernel = this._onDidAddKernel.event;
|
|
91
|
+
this.onDidRemoveKernel = this._onDidRemoveKernel.event;
|
|
92
|
+
this.onDidChangeNotebookAffinity = this._onDidChangeNotebookAffinity.event;
|
|
93
|
+
this.onDidChangeSourceActions = this._onDidChangeSourceActions.event;
|
|
94
|
+
this.onDidChangeKernelDetectionTasks = this._onDidChangeKernelDetectionTasks.event;
|
|
95
|
+
this.onDidNotebookVariablesUpdate = this._onDidNotebookVariablesChange.event;
|
|
96
|
+
this._register(_notebookService.onDidAddNotebookDocument(this._tryAutoBindNotebook, this));
|
|
97
|
+
this._register(_notebookService.onWillRemoveNotebookDocument(notebook => {
|
|
98
|
+
const id = NotebookTextModelLikeId.str(notebook);
|
|
99
|
+
const kernelId = this._notebookBindings.get(id);
|
|
100
|
+
if (kernelId && notebook.uri.scheme === Schemas.untitled) {
|
|
101
|
+
this.selectKernelForNotebook(undefined, notebook);
|
|
102
|
+
}
|
|
103
|
+
this._kernelSourceActionsUpdates.get(id)?.dispose();
|
|
104
|
+
this._kernelSourceActionsUpdates.delete(id);
|
|
105
|
+
}));
|
|
106
|
+
try {
|
|
107
|
+
const data = JSON.parse(this._storageService.get(NotebookKernelService_1._storageNotebookBinding, 1 , '[]'));
|
|
108
|
+
this._notebookBindings.fromJSON(data);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
dispose() {
|
|
114
|
+
this._kernels.clear();
|
|
115
|
+
this._kernelSources.forEach(v => {
|
|
116
|
+
v.menu.dispose();
|
|
117
|
+
v.actions.forEach(a => a[1].dispose());
|
|
118
|
+
});
|
|
119
|
+
this._kernelSourceActionsUpdates.forEach(v => {
|
|
120
|
+
v.dispose();
|
|
121
|
+
});
|
|
122
|
+
this._kernelSourceActionsUpdates.clear();
|
|
123
|
+
super.dispose();
|
|
124
|
+
}
|
|
125
|
+
_persistMementos() {
|
|
126
|
+
this._persistSoonHandle?.dispose();
|
|
127
|
+
this._persistSoonHandle = runWhenWindowIdle($window, () => {
|
|
128
|
+
this._storageService.store(NotebookKernelService_1._storageNotebookBinding, JSON.stringify(this._notebookBindings), 1 , 1 );
|
|
129
|
+
}, 100);
|
|
130
|
+
}
|
|
131
|
+
static _score(kernel, notebook) {
|
|
132
|
+
if (kernel.viewType === '*') {
|
|
133
|
+
return 5;
|
|
134
|
+
}
|
|
135
|
+
else if (kernel.viewType === notebook.viewType) {
|
|
136
|
+
return 10;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
_tryAutoBindNotebook(notebook, onlyThisKernel) {
|
|
143
|
+
const id = this._notebookBindings.get(NotebookTextModelLikeId.str(notebook));
|
|
144
|
+
if (!id) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const existingKernel = this._kernels.get(id);
|
|
148
|
+
if (!existingKernel || !NotebookKernelService_1._score(existingKernel.kernel, notebook)) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (!onlyThisKernel || existingKernel.kernel === onlyThisKernel) {
|
|
152
|
+
this._onDidChangeNotebookKernelBinding.fire({ notebook: notebook.uri, oldKernel: undefined, newKernel: existingKernel.kernel.id });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
notifyVariablesChange(notebookUri) {
|
|
156
|
+
this._onDidNotebookVariablesChange.fire(notebookUri);
|
|
157
|
+
}
|
|
158
|
+
registerKernel(kernel) {
|
|
159
|
+
if (( this._kernels.has(kernel.id))) {
|
|
160
|
+
throw new Error(`NOTEBOOK CONTROLLER with id '${kernel.id}' already exists`);
|
|
161
|
+
}
|
|
162
|
+
this._kernels.set(kernel.id, ( new KernelInfo(kernel)));
|
|
163
|
+
this._onDidAddKernel.fire(kernel);
|
|
164
|
+
for (const notebook of this._notebookService.getNotebookTextModels()) {
|
|
165
|
+
this._tryAutoBindNotebook(notebook, kernel);
|
|
166
|
+
}
|
|
167
|
+
return toDisposable(() => {
|
|
168
|
+
if (this._kernels.delete(kernel.id)) {
|
|
169
|
+
this._onDidRemoveKernel.fire(kernel);
|
|
170
|
+
}
|
|
171
|
+
for (const [key, candidate] of Array.from(this._notebookBindings)) {
|
|
172
|
+
if (candidate === kernel.id) {
|
|
173
|
+
this._onDidChangeNotebookKernelBinding.fire({ notebook: NotebookTextModelLikeId.obj(key).uri, oldKernel: kernel.id, newKernel: undefined });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
getMatchingKernel(notebook) {
|
|
179
|
+
const kernels = [];
|
|
180
|
+
for (const info of ( this._kernels.values())) {
|
|
181
|
+
const score = NotebookKernelService_1._score(info.kernel, notebook);
|
|
182
|
+
if (score) {
|
|
183
|
+
kernels.push({
|
|
184
|
+
score,
|
|
185
|
+
kernel: info.kernel,
|
|
186
|
+
instanceAffinity: info.notebookPriorities.get(notebook.uri) ?? 1 ,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
kernels
|
|
191
|
+
.sort((a, b) => b.instanceAffinity - a.instanceAffinity || a.score - b.score || a.kernel.label.localeCompare(b.kernel.label));
|
|
192
|
+
const all = ( kernels.map(obj => obj.kernel));
|
|
193
|
+
const selectedId = this._notebookBindings.get(NotebookTextModelLikeId.str(notebook));
|
|
194
|
+
const selected = selectedId ? this._kernels.get(selectedId)?.kernel : undefined;
|
|
195
|
+
const suggestions = ( kernels.filter(item => item.instanceAffinity > 1).map(item => item.kernel));
|
|
196
|
+
const hidden = ( kernels.filter(item => item.instanceAffinity < 0).map(item => item.kernel));
|
|
197
|
+
return { all, selected, suggestions, hidden };
|
|
198
|
+
}
|
|
199
|
+
getSelectedOrSuggestedKernel(notebook) {
|
|
200
|
+
const info = this.getMatchingKernel(notebook);
|
|
201
|
+
if (info.selected) {
|
|
202
|
+
return info.selected;
|
|
203
|
+
}
|
|
204
|
+
const preferred = info.all.filter(kernel => this._kernels.get(kernel.id)?.notebookPriorities.get(notebook.uri) === 2 );
|
|
205
|
+
if (preferred.length === 1) {
|
|
206
|
+
return preferred[0];
|
|
207
|
+
}
|
|
208
|
+
return info.all.length === 1 ? info.all[0] : undefined;
|
|
209
|
+
}
|
|
210
|
+
selectKernelForNotebook(kernel, notebook) {
|
|
211
|
+
const key = NotebookTextModelLikeId.str(notebook);
|
|
212
|
+
const oldKernel = this._notebookBindings.get(key);
|
|
213
|
+
if (oldKernel !== kernel?.id) {
|
|
214
|
+
if (kernel) {
|
|
215
|
+
this._notebookBindings.set(key, kernel.id);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
this._notebookBindings.delete(key);
|
|
219
|
+
}
|
|
220
|
+
this._onDidChangeNotebookKernelBinding.fire({ notebook: notebook.uri, oldKernel, newKernel: kernel?.id });
|
|
221
|
+
this._persistMementos();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
preselectKernelForNotebook(kernel, notebook) {
|
|
225
|
+
const key = NotebookTextModelLikeId.str(notebook);
|
|
226
|
+
const oldKernel = this._notebookBindings.get(key);
|
|
227
|
+
if (oldKernel !== kernel?.id) {
|
|
228
|
+
this._notebookBindings.set(key, kernel.id);
|
|
229
|
+
this._persistMementos();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
updateKernelNotebookAffinity(kernel, notebook, preference) {
|
|
233
|
+
const info = this._kernels.get(kernel.id);
|
|
234
|
+
if (!info) {
|
|
235
|
+
throw new Error(`UNKNOWN kernel '${kernel.id}'`);
|
|
236
|
+
}
|
|
237
|
+
if (preference === undefined) {
|
|
238
|
+
info.notebookPriorities.delete(notebook);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
info.notebookPriorities.set(notebook, preference);
|
|
242
|
+
}
|
|
243
|
+
this._onDidChangeNotebookAffinity.fire();
|
|
244
|
+
}
|
|
245
|
+
getRunningSourceActions(notebook) {
|
|
246
|
+
const id = NotebookTextModelLikeId.str(notebook);
|
|
247
|
+
const existingInfo = this._kernelSources.get(id);
|
|
248
|
+
if (existingInfo) {
|
|
249
|
+
return ( existingInfo.actions.filter(action => action[0].execution).map(action => action[0]));
|
|
250
|
+
}
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
getSourceActions(notebook, contextKeyService) {
|
|
254
|
+
contextKeyService = contextKeyService ?? this._contextKeyService;
|
|
255
|
+
const id = NotebookTextModelLikeId.str(notebook);
|
|
256
|
+
const existingInfo = this._kernelSources.get(id);
|
|
257
|
+
if (existingInfo) {
|
|
258
|
+
return ( existingInfo.actions.map(a => a[0]));
|
|
259
|
+
}
|
|
260
|
+
const sourceMenu = this._register(this._menuService.createMenu(MenuId.NotebookKernelSource, contextKeyService));
|
|
261
|
+
const info = { menu: sourceMenu, actions: [] };
|
|
262
|
+
const loadActionsFromMenu = (menu, document) => {
|
|
263
|
+
const groups = menu.getActions({ shouldForwardArgs: true });
|
|
264
|
+
const sourceActions = [];
|
|
265
|
+
groups.forEach(group => {
|
|
266
|
+
const isPrimary = /^primary/.test(group[0]);
|
|
267
|
+
group[1].forEach(action => {
|
|
268
|
+
const sourceAction = ( new SourceAction(action, document, isPrimary));
|
|
269
|
+
const stateChangeListener = sourceAction.onDidChangeState(() => {
|
|
270
|
+
this._onDidChangeSourceActions.fire({
|
|
271
|
+
notebook: document.uri,
|
|
272
|
+
viewType: document.viewType,
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
sourceActions.push([sourceAction, stateChangeListener]);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
info.actions = sourceActions;
|
|
279
|
+
this._kernelSources.set(id, info);
|
|
280
|
+
this._onDidChangeSourceActions.fire({ notebook: document.uri, viewType: document.viewType });
|
|
281
|
+
};
|
|
282
|
+
this._kernelSourceActionsUpdates.get(id)?.dispose();
|
|
283
|
+
this._kernelSourceActionsUpdates.set(id, sourceMenu.onDidChange(() => {
|
|
284
|
+
loadActionsFromMenu(sourceMenu, notebook);
|
|
285
|
+
}));
|
|
286
|
+
loadActionsFromMenu(sourceMenu, notebook);
|
|
287
|
+
return ( info.actions.map(a => a[0]));
|
|
288
|
+
}
|
|
289
|
+
registerNotebookKernelDetectionTask(task) {
|
|
290
|
+
const notebookType = task.notebookType;
|
|
291
|
+
const all = this._kernelDetectionTasks.get(notebookType) ?? [];
|
|
292
|
+
all.push(task);
|
|
293
|
+
this._kernelDetectionTasks.set(notebookType, all);
|
|
294
|
+
this._onDidChangeKernelDetectionTasks.fire(notebookType);
|
|
295
|
+
return toDisposable(() => {
|
|
296
|
+
const all = this._kernelDetectionTasks.get(notebookType) ?? [];
|
|
297
|
+
const idx = all.indexOf(task);
|
|
298
|
+
if (idx >= 0) {
|
|
299
|
+
all.splice(idx, 1);
|
|
300
|
+
this._kernelDetectionTasks.set(notebookType, all);
|
|
301
|
+
this._onDidChangeKernelDetectionTasks.fire(notebookType);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
getKernelDetectionTasks(notebook) {
|
|
306
|
+
return this._kernelDetectionTasks.get(notebook.viewType) ?? [];
|
|
307
|
+
}
|
|
308
|
+
registerKernelSourceActionProvider(viewType, provider) {
|
|
309
|
+
const providers = this._kernelSourceActionProviders.get(viewType) ?? [];
|
|
310
|
+
providers.push(provider);
|
|
311
|
+
this._kernelSourceActionProviders.set(viewType, providers);
|
|
312
|
+
this._onDidChangeSourceActions.fire({ viewType: viewType });
|
|
313
|
+
const eventEmitterDisposable = provider.onDidChangeSourceActions?.(() => {
|
|
314
|
+
this._onDidChangeSourceActions.fire({ viewType: viewType });
|
|
315
|
+
});
|
|
316
|
+
return toDisposable(() => {
|
|
317
|
+
const providers = this._kernelSourceActionProviders.get(viewType) ?? [];
|
|
318
|
+
const idx = providers.indexOf(provider);
|
|
319
|
+
if (idx >= 0) {
|
|
320
|
+
providers.splice(idx, 1);
|
|
321
|
+
this._kernelSourceActionProviders.set(viewType, providers);
|
|
322
|
+
}
|
|
323
|
+
eventEmitterDisposable?.dispose();
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
getKernelSourceActions2(notebook) {
|
|
327
|
+
const viewType = notebook.viewType;
|
|
328
|
+
const providers = this._kernelSourceActionProviders.get(viewType) ?? [];
|
|
329
|
+
const promises = ( providers.map(provider => provider.provideKernelSourceActions()));
|
|
330
|
+
return Promise.all(promises).then(actions => {
|
|
331
|
+
return actions.reduce((a, b) => a.concat(b), []);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
NotebookKernelService = NotebookKernelService_1 = ( __decorate([
|
|
336
|
+
( __param(0, INotebookService)),
|
|
337
|
+
( __param(1, IStorageService)),
|
|
338
|
+
( __param(2, IMenuService)),
|
|
339
|
+
( __param(3, IContextKeyService))
|
|
340
|
+
], NotebookKernelService));
|
|
341
|
+
|
|
342
|
+
export { NotebookKernelService };
|
package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { onUnexpectedError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
3
|
+
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
4
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
5
|
+
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
6
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
7
|
+
import { Severity, INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
8
|
+
import { getInstalledExtensions } from 'vscode/vscode/vs/workbench/contrib/extensions/common/extensionsUtils';
|
|
9
|
+
import { IWorkbenchExtensionEnablementService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionManagement';
|
|
10
|
+
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
11
|
+
import { IExtensionManagementService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement';
|
|
12
|
+
import { areSameExtensions } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
|
|
13
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
14
|
+
import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
|
|
15
|
+
import { distinct } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
16
|
+
|
|
17
|
+
function onExtensionChanged(accessor) {
|
|
18
|
+
const extensionService = accessor.get(IExtensionManagementService);
|
|
19
|
+
const extensionEnablementService = accessor.get(IWorkbenchExtensionEnablementService);
|
|
20
|
+
const onDidInstallExtensions = Event.chain(extensionService.onDidInstallExtensions, $ => ( $.filter(e => ( e.some(({ operation }) => operation === 2 )))
|
|
21
|
+
.map(e => ( e.map(({ identifier }) => identifier)))));
|
|
22
|
+
return Event.debounce(Event.any(Event.any(onDidInstallExtensions, ( Event.map(extensionService.onDidUninstallExtension, e => [e.identifier]))), ( Event.map(
|
|
23
|
+
extensionEnablementService.onEnablementChanged,
|
|
24
|
+
extensions => ( extensions.map(e => e.identifier))
|
|
25
|
+
))), (result, identifiers) => {
|
|
26
|
+
result = result || (identifiers.length ? [identifiers[0]] : []);
|
|
27
|
+
for (const identifier of identifiers) {
|
|
28
|
+
if (( result.some(l => !areSameExtensions(l, identifier)))) {
|
|
29
|
+
result.push(identifier);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const hasRecommendedKeymapKey = 'hasRecommendedKeymap';
|
|
36
|
+
let NotebookKeymapService = class NotebookKeymapService extends Disposable {
|
|
37
|
+
constructor(instantiationService, extensionEnablementService, notificationService, storageService, lifecycleService) {
|
|
38
|
+
super();
|
|
39
|
+
this.instantiationService = instantiationService;
|
|
40
|
+
this.extensionEnablementService = extensionEnablementService;
|
|
41
|
+
this.notificationService = notificationService;
|
|
42
|
+
this.notebookKeymapMemento = ( new Memento('notebookKeymap', storageService));
|
|
43
|
+
this.notebookKeymap = this.notebookKeymapMemento.getMemento(0 , 0 );
|
|
44
|
+
this._register(lifecycleService.onDidShutdown(() => this.dispose()));
|
|
45
|
+
this._register(this.instantiationService.invokeFunction(onExtensionChanged)((identifiers => {
|
|
46
|
+
Promise.all(( identifiers.map(identifier => this.checkForOtherKeymaps(identifier))))
|
|
47
|
+
.then(undefined, onUnexpectedError);
|
|
48
|
+
})));
|
|
49
|
+
}
|
|
50
|
+
checkForOtherKeymaps(extensionIdentifier) {
|
|
51
|
+
return this.instantiationService.invokeFunction(getInstalledExtensions).then(extensions => {
|
|
52
|
+
const keymaps = extensions.filter(extension => isNotebookKeymapExtension(extension));
|
|
53
|
+
const extension = keymaps.find(extension => areSameExtensions(extension.identifier, extensionIdentifier));
|
|
54
|
+
if (extension && extension.globallyEnabled) {
|
|
55
|
+
this.notebookKeymap[hasRecommendedKeymapKey] = true;
|
|
56
|
+
this.notebookKeymapMemento.saveMemento();
|
|
57
|
+
const otherKeymaps = keymaps.filter(extension => !areSameExtensions(extension.identifier, extensionIdentifier) && extension.globallyEnabled);
|
|
58
|
+
if (otherKeymaps.length) {
|
|
59
|
+
return this.promptForDisablingOtherKeymaps(extension, otherKeymaps);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
promptForDisablingOtherKeymaps(newKeymap, oldKeymaps) {
|
|
66
|
+
const onPrompt = (confirmed) => {
|
|
67
|
+
if (confirmed) {
|
|
68
|
+
this.extensionEnablementService.setEnablement(( oldKeymaps.map(keymap => keymap.local)), 6 );
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
this.notificationService.prompt(Severity.Info, ( localizeWithPath(
|
|
72
|
+
'vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl',
|
|
73
|
+
'disableOtherKeymapsConfirmation',
|
|
74
|
+
"Disable other keymaps ({0}) to avoid conflicts between keybindings?",
|
|
75
|
+
( distinct(( oldKeymaps.map(k => k.local.manifest.displayName))).map(name => `'${name}'`)).join(', ')
|
|
76
|
+
)), [{
|
|
77
|
+
label: ( localizeWithPath(
|
|
78
|
+
'vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl',
|
|
79
|
+
'yes',
|
|
80
|
+
"Yes"
|
|
81
|
+
)),
|
|
82
|
+
run: () => onPrompt(true)
|
|
83
|
+
}, {
|
|
84
|
+
label: ( localizeWithPath(
|
|
85
|
+
'vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl',
|
|
86
|
+
'no',
|
|
87
|
+
"No"
|
|
88
|
+
)),
|
|
89
|
+
run: () => onPrompt(false)
|
|
90
|
+
}]);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
NotebookKeymapService = ( __decorate([
|
|
94
|
+
( __param(0, IInstantiationService)),
|
|
95
|
+
( __param(1, IWorkbenchExtensionEnablementService)),
|
|
96
|
+
( __param(2, INotificationService)),
|
|
97
|
+
( __param(3, IStorageService)),
|
|
98
|
+
( __param(4, ILifecycleService))
|
|
99
|
+
], NotebookKeymapService));
|
|
100
|
+
function isNotebookKeymapExtension(extension) {
|
|
101
|
+
if (extension.local.manifest.extensionPack) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
const keywords = extension.local.manifest.keywords;
|
|
105
|
+
if (!keywords) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return keywords.indexOf('notebook-keymap') !== -1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { NotebookKeymapService, isNotebookKeymapExtension };
|
package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
3
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
4
|
+
import { ILoggerService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
5
|
+
|
|
6
|
+
const logChannelId = 'notebook.rendering';
|
|
7
|
+
let NotebookLoggingService = class NotebookLoggingService extends Disposable {
|
|
8
|
+
static { this.ID = 'notebook'; }
|
|
9
|
+
constructor(loggerService) {
|
|
10
|
+
super();
|
|
11
|
+
this._logger = this._register(loggerService.createLogger(logChannelId, { name: ( nls.localizeWithPath(
|
|
12
|
+
'vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl',
|
|
13
|
+
'renderChannelName',
|
|
14
|
+
"Notebook rendering"
|
|
15
|
+
)) }));
|
|
16
|
+
}
|
|
17
|
+
debug(category, output) {
|
|
18
|
+
this._logger.debug(`[${category}] ${output}`);
|
|
19
|
+
}
|
|
20
|
+
info(category, output) {
|
|
21
|
+
this._logger.info(`[${category}] ${output}`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
NotebookLoggingService = ( __decorate([
|
|
25
|
+
( __param(0, ILoggerService))
|
|
26
|
+
], NotebookLoggingService));
|
|
27
|
+
|
|
28
|
+
export { NotebookLoggingService };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
3
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
4
|
+
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
5
|
+
|
|
6
|
+
let NotebookRendererMessagingService = class NotebookRendererMessagingService extends Disposable {
|
|
7
|
+
constructor(extensionService) {
|
|
8
|
+
super();
|
|
9
|
+
this.extensionService = extensionService;
|
|
10
|
+
this.activations = ( new Map());
|
|
11
|
+
this.scopedMessaging = ( new Map());
|
|
12
|
+
this.postMessageEmitter = this._register(( new Emitter()));
|
|
13
|
+
this.onShouldPostMessage = this.postMessageEmitter.event;
|
|
14
|
+
}
|
|
15
|
+
receiveMessage(editorId, rendererId, message) {
|
|
16
|
+
if (editorId === undefined) {
|
|
17
|
+
const sends = ( [...( this.scopedMessaging.values())].map(e => e.receiveMessageHandler?.(rendererId, message)));
|
|
18
|
+
return Promise.all(sends).then(s => ( s.some(s => !!s)));
|
|
19
|
+
}
|
|
20
|
+
return this.scopedMessaging.get(editorId)?.receiveMessageHandler?.(rendererId, message) ?? Promise.resolve(false);
|
|
21
|
+
}
|
|
22
|
+
prepare(rendererId) {
|
|
23
|
+
if (( this.activations.has(rendererId))) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const queue = [];
|
|
27
|
+
this.activations.set(rendererId, queue);
|
|
28
|
+
this.extensionService.activateByEvent(`onRenderer:${rendererId}`).then(() => {
|
|
29
|
+
for (const message of queue) {
|
|
30
|
+
this.postMessageEmitter.fire(message);
|
|
31
|
+
}
|
|
32
|
+
this.activations.set(rendererId, undefined);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
getScoped(editorId) {
|
|
36
|
+
const existing = this.scopedMessaging.get(editorId);
|
|
37
|
+
if (existing) {
|
|
38
|
+
return existing;
|
|
39
|
+
}
|
|
40
|
+
const messaging = {
|
|
41
|
+
postMessage: (rendererId, message) => this.postMessage(editorId, rendererId, message),
|
|
42
|
+
dispose: () => this.scopedMessaging.delete(editorId),
|
|
43
|
+
};
|
|
44
|
+
this.scopedMessaging.set(editorId, messaging);
|
|
45
|
+
return messaging;
|
|
46
|
+
}
|
|
47
|
+
postMessage(editorId, rendererId, message) {
|
|
48
|
+
if (!( this.activations.has(rendererId))) {
|
|
49
|
+
this.prepare(rendererId);
|
|
50
|
+
}
|
|
51
|
+
const activation = this.activations.get(rendererId);
|
|
52
|
+
const toSend = { rendererId, editorId, message };
|
|
53
|
+
if (activation === undefined) {
|
|
54
|
+
this.postMessageEmitter.fire(toSend);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
activation.push(toSend);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
NotebookRendererMessagingService = ( __decorate([
|
|
62
|
+
( __param(0, IExtensionService))
|
|
63
|
+
], NotebookRendererMessagingService));
|
|
64
|
+
|
|
65
|
+
export { NotebookRendererMessagingService };
|