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