@codingame/monaco-vscode-notebook-service-override 37.1.0 → 37.2.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.
Files changed (70) hide show
  1. package/index.js +5 -0
  2. package/package.json +3 -3
  3. package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.d.ts +22 -0
  4. package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +210 -0
  5. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.d.ts +24 -0
  6. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +138 -0
  7. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.d.ts +29 -0
  8. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +194 -0
  9. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.d.ts +27 -0
  10. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +149 -0
  11. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.d.ts +49 -0
  12. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +372 -0
  13. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.d.ts +10 -0
  14. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +26 -0
  15. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.d.ts +9 -0
  16. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +43 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +2 -2
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +3 -3
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +2 -2
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +2 -2
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +1 -1
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.d.ts +1 -1
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +2 -2
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +3 -3
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +1 -1
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +1 -1
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +2 -2
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +1 -1
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +1 -1
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +1 -1
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +4 -4
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +1 -1
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +1 -1
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +3 -3
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +1 -1
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.d.ts +1 -1
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +2 -2
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +1 -1
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +1 -1
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +2 -2
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +2 -2
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +3 -3
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +1 -1
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +3 -3
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +2 -2
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +1 -1
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.d.ts +1 -1
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.js +1 -1
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +5 -5
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +1 -1
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.d.ts +1 -1
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.js +6 -6
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditorInput.d.ts +1 -1
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/replEditorAccessibleView.js +1 -1
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.d.ts +1 -1
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +1 -1
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.d.ts +1 -1
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +1 -1
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.d.ts +1 -1
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +1 -1
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.d.ts +1 -1
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +1 -1
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +1 -1
  64. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.d.ts +1 -1
  65. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.d.ts +1 -1
  66. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +2 -2
  67. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.d.ts +87 -0
  68. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +352 -0
  69. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +1 -1
  70. package/vscode/src/vs/workbench/contrib/replNotebook/browser/repl.contribution.js +2 -2
@@ -0,0 +1,27 @@
1
+ import { UriComponents } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
2
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
3
+ import { INotebookEditor } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser";
4
+ import { INotebookEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service";
5
+ import { ICellRange } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookRange";
6
+ import { IEditorGroupsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service";
7
+ import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
8
+ import { IExtHostContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers";
9
+ import { INotebookDocumentShowOptions, MainThreadNotebookEditorsShape, NotebookEditorRevealType } from "@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol";
10
+ export declare class MainThreadNotebookEditors implements MainThreadNotebookEditorsShape {
11
+ private readonly _editorService;
12
+ private readonly _notebookEditorService;
13
+ private readonly _editorGroupService;
14
+ private readonly _configurationService;
15
+ private readonly _disposables;
16
+ private readonly _proxy;
17
+ private readonly _mainThreadEditors;
18
+ private _currentViewColumnInfo?;
19
+ constructor(extHostContext: IExtHostContext, _editorService: IEditorService, _notebookEditorService: INotebookEditorService, _editorGroupService: IEditorGroupsService, _configurationService: IConfigurationService);
20
+ dispose(): void;
21
+ handleEditorsAdded(editors: readonly INotebookEditor[]): void;
22
+ handleEditorsRemoved(editorIds: readonly string[]): void;
23
+ private _updateEditorViewColumns;
24
+ $tryShowNotebookDocument(resource: UriComponents, viewType: string, options: INotebookDocumentShowOptions): Promise<string>;
25
+ $tryRevealRange(id: string, range: ICellRange, revealType: NotebookEditorRevealType): Promise<void>;
26
+ $trySetSelections(id: string, ranges: ICellRange[]): void;
27
+ }
@@ -0,0 +1,149 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { DisposableStore, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
4
+ import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
5
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
6
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
7
+ import { EditorActivation } from '@codingame/monaco-vscode-api/vscode/vs/platform/editor/common/editor';
8
+ import { getNotebookEditorFromEditorPane } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
9
+ import { INotebookEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
10
+ import { editorGroupToColumn, columnToEditorGroup } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupColumn';
11
+ import { IEditorGroupsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
12
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
13
+ import { ExtHostContext, NotebookEditorRevealType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol';
14
+
15
+ class MainThreadNotebook {
16
+ constructor(editor, disposables) {
17
+ this.editor = editor;
18
+ this.disposables = disposables;
19
+ }
20
+ dispose() {
21
+ this.disposables.dispose();
22
+ }
23
+ }
24
+ let MainThreadNotebookEditors = class MainThreadNotebookEditors {
25
+ constructor(
26
+ extHostContext,
27
+ _editorService,
28
+ _notebookEditorService,
29
+ _editorGroupService,
30
+ _configurationService
31
+ ) {
32
+ this._editorService = _editorService;
33
+ this._notebookEditorService = _notebookEditorService;
34
+ this._editorGroupService = _editorGroupService;
35
+ this._configurationService = _configurationService;
36
+ this._disposables = ( new DisposableStore());
37
+ this._mainThreadEditors = ( new Map());
38
+ this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebookEditors));
39
+ this._editorService.onDidActiveEditorChange(() => this._updateEditorViewColumns(), this, this._disposables);
40
+ this._editorGroupService.onDidRemoveGroup(() => this._updateEditorViewColumns(), this, this._disposables);
41
+ this._editorGroupService.onDidMoveGroup(() => this._updateEditorViewColumns(), this, this._disposables);
42
+ }
43
+ dispose() {
44
+ this._disposables.dispose();
45
+ dispose(( this._mainThreadEditors.values()));
46
+ }
47
+ handleEditorsAdded(editors) {
48
+ for (const editor of editors) {
49
+ const editorDisposables = ( new DisposableStore());
50
+ editorDisposables.add(editor.onDidChangeVisibleRanges(() => {
51
+ this._proxy.$acceptEditorPropertiesChanged(editor.getId(), {
52
+ visibleRanges: {
53
+ ranges: editor.visibleRanges
54
+ }
55
+ });
56
+ }));
57
+ editorDisposables.add(editor.onDidChangeSelection(() => {
58
+ this._proxy.$acceptEditorPropertiesChanged(editor.getId(), {
59
+ selections: {
60
+ selections: editor.getSelections()
61
+ }
62
+ });
63
+ }));
64
+ const wrapper = ( new MainThreadNotebook(editor, editorDisposables));
65
+ this._mainThreadEditors.set(editor.getId(), wrapper);
66
+ }
67
+ }
68
+ handleEditorsRemoved(editorIds) {
69
+ for (const id of editorIds) {
70
+ this._mainThreadEditors.get(id)?.dispose();
71
+ this._mainThreadEditors.delete(id);
72
+ }
73
+ }
74
+ _updateEditorViewColumns() {
75
+ const result = Object.create(null);
76
+ for (const editorPane of this._editorService.visibleEditorPanes) {
77
+ const candidate = getNotebookEditorFromEditorPane(editorPane);
78
+ if (candidate && ( this._mainThreadEditors.has(candidate.getId()))) {
79
+ result[candidate.getId()] = editorGroupToColumn(this._editorGroupService, editorPane.group);
80
+ }
81
+ }
82
+ if (!equals(result, this._currentViewColumnInfo)) {
83
+ this._currentViewColumnInfo = result;
84
+ this._proxy.$acceptEditorViewColumns(result);
85
+ }
86
+ }
87
+ async $tryShowNotebookDocument(resource, viewType, options) {
88
+ const editorOptions = {
89
+ cellSelections: options.selections,
90
+ preserveFocus: options.preserveFocus,
91
+ pinned: options.pinned,
92
+ activation: options.preserveFocus ? EditorActivation.RESTORE : undefined,
93
+ label: options.label,
94
+ override: viewType
95
+ };
96
+ const editorPane = await this._editorService.openEditor({
97
+ resource: URI.revive(resource),
98
+ options: editorOptions
99
+ }, columnToEditorGroup(this._editorGroupService, this._configurationService, options.position));
100
+ const notebookEditor = getNotebookEditorFromEditorPane(editorPane);
101
+ if (notebookEditor) {
102
+ return notebookEditor.getId();
103
+ } else {
104
+ throw ( new Error(
105
+ `Notebook Editor creation failure for document ${JSON.stringify(resource)}`
106
+ ));
107
+ }
108
+ }
109
+ async $tryRevealRange(id, range, revealType) {
110
+ const editor = this._notebookEditorService.getNotebookEditor(id);
111
+ if (!editor) {
112
+ return;
113
+ }
114
+ const notebookEditor = editor;
115
+ if (!notebookEditor.hasModel()) {
116
+ return;
117
+ }
118
+ if (range.start >= notebookEditor.getLength()) {
119
+ return;
120
+ }
121
+ const cell = notebookEditor.cellAt(range.start);
122
+ switch (revealType) {
123
+ case NotebookEditorRevealType.Default:
124
+ return notebookEditor.revealCellRangeInView(range);
125
+ case NotebookEditorRevealType.InCenter:
126
+ return notebookEditor.revealInCenter(cell);
127
+ case NotebookEditorRevealType.InCenterIfOutsideViewport:
128
+ return notebookEditor.revealInCenterIfOutsideViewport(cell);
129
+ case NotebookEditorRevealType.AtTop:
130
+ return notebookEditor.revealInViewAtTop(cell);
131
+ }
132
+ }
133
+ $trySetSelections(id, ranges) {
134
+ const editor = this._notebookEditorService.getNotebookEditor(id);
135
+ if (!editor) {
136
+ return;
137
+ }
138
+ editor.setSelections(ranges);
139
+ if (ranges.length) {
140
+ editor.setFocus({
141
+ start: ranges[0].start,
142
+ end: ranges[0].start + 1
143
+ });
144
+ }
145
+ }
146
+ };
147
+ MainThreadNotebookEditors = ( __decorate([( __param(1, IEditorService)), ( __param(2, INotebookEditorService)), ( __param(3, IEditorGroupsService)), ( __param(4, IConfigurationService))], MainThreadNotebookEditors));
148
+
149
+ export { MainThreadNotebookEditors };
@@ -0,0 +1,49 @@
1
+ import { UriComponents } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
2
+ import { ILanguageService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service";
3
+ import { IExtHostContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers";
4
+ import { INotebookEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service";
5
+ import { INotebookExecutionStateService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service";
6
+ import { VariablesResult } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookKernelService";
7
+ import { INotebookKernelService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookKernelService.service";
8
+ import { SerializableObjectWithBuffers } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/proxyIdentifier";
9
+ import { ICellExecuteUpdateDto, ICellExecutionCompleteDto, INotebookKernelDto2, MainThreadNotebookKernelsShape } from "@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol";
10
+ import { INotebookService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service";
11
+ export declare class MainThreadNotebookKernels implements MainThreadNotebookKernelsShape {
12
+ private readonly _languageService;
13
+ private readonly _notebookKernelService;
14
+ private readonly _notebookExecutionStateService;
15
+ private readonly _notebookService;
16
+ private readonly _editors;
17
+ private readonly _disposables;
18
+ private readonly _kernels;
19
+ private readonly _kernelDetectionTasks;
20
+ private readonly _kernelSourceActionProviders;
21
+ private readonly _kernelSourceActionProvidersEventRegistrations;
22
+ private readonly _proxy;
23
+ private readonly _executions;
24
+ private readonly _notebookExecutions;
25
+ constructor(extHostContext: IExtHostContext, _languageService: ILanguageService, _notebookKernelService: INotebookKernelService, _notebookExecutionStateService: INotebookExecutionStateService, _notebookService: INotebookService, notebookEditorService: INotebookEditorService);
26
+ dispose(): void;
27
+ private _onEditorAdd;
28
+ private _onEditorRemove;
29
+ $postMessage(handle: number, editorId: string | undefined, message: unknown): Promise<boolean>;
30
+ private variableRequestIndex;
31
+ private variableRequestMap;
32
+ $receiveVariable(requestId: string, variable: VariablesResult): void;
33
+ $addKernel(handle: number, data: INotebookKernelDto2): Promise<void>;
34
+ $updateKernel(handle: number, data: Partial<INotebookKernelDto2>): void;
35
+ $removeKernel(handle: number): void;
36
+ $updateNotebookPriority(handle: number, notebook: UriComponents, value: number | undefined): void;
37
+ $createExecution(handle: number, controllerId: string, rawUri: UriComponents, cellHandle: number): void;
38
+ $updateExecution(handle: number, data: SerializableObjectWithBuffers<ICellExecuteUpdateDto[]>): void;
39
+ $completeExecution(handle: number, data: SerializableObjectWithBuffers<ICellExecutionCompleteDto>): void;
40
+ $createNotebookExecution(handle: number, controllerId: string, rawUri: UriComponents): void;
41
+ $beginNotebookExecution(handle: number): void;
42
+ $completeNotebookExecution(handle: number): void;
43
+ $addKernelDetectionTask(handle: number, notebookType: string): Promise<void>;
44
+ $removeKernelDetectionTask(handle: number): void;
45
+ $addKernelSourceActionProvider(handle: number, eventHandle: number, notebookType: string): Promise<void>;
46
+ $removeKernelSourceActionProvider(handle: number, eventHandle: number): void;
47
+ $emitNotebookKernelSourceActionsChangeEvent(eventHandle: number): void;
48
+ $variablesUpdated(notebookUri: UriComponents): void;
49
+ }
@@ -0,0 +1,372 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { isNonEmptyArray } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
4
+ import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
5
+ import { onUnexpectedError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
6
+ import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
7
+ import { DisposableMap, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
8
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
9
+ import { ILanguageService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service';
10
+ import { NotebookDto } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/api/browser/mainThreadNotebookDto';
11
+ import { extHostNamedCustomer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers';
12
+ import { INotebookEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
13
+ import { INotebookExecutionStateService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service';
14
+ import { INotebookKernelService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookKernelService.service';
15
+ import { ExtHostContext, MainContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol';
16
+ import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
17
+ import { AsyncIterableProducer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
18
+
19
+ class MainThreadKernel {
20
+ get preloadUris() {
21
+ return ( this.preloads.map(p => p.uri));
22
+ }
23
+ get preloadProvides() {
24
+ return this.preloads.flatMap(p => p.provides);
25
+ }
26
+ constructor(data, _languageService) {
27
+ this._languageService = _languageService;
28
+ this._onDidChange = ( new Emitter());
29
+ this.onDidChange = this._onDidChange.event;
30
+ this.id = data.id;
31
+ this.viewType = data.notebookType;
32
+ this.extension = data.extensionId;
33
+ this.implementsInterrupt = data.supportsInterrupt ?? false;
34
+ this.label = data.label;
35
+ this.description = data.description;
36
+ this.detail = data.detail;
37
+ this.supportedLanguages = isNonEmptyArray(data.supportedLanguages) ? data.supportedLanguages : _languageService.getRegisteredLanguageIds();
38
+ this.implementsExecutionOrder = data.supportsExecutionOrder ?? false;
39
+ this.hasVariableProvider = data.hasVariableProvider ?? false;
40
+ this.localResourceRoot = URI.revive(data.extensionLocation);
41
+ this.preloads = data.preloads?.map(u => ({
42
+ uri: URI.revive(u.uri),
43
+ provides: u.provides
44
+ })) ?? [];
45
+ }
46
+ update(data) {
47
+ const event = Object.create(null);
48
+ if (data.label !== undefined) {
49
+ this.label = data.label;
50
+ event.label = true;
51
+ }
52
+ if (data.description !== undefined) {
53
+ this.description = data.description;
54
+ event.description = true;
55
+ }
56
+ if (data.detail !== undefined) {
57
+ this.detail = data.detail;
58
+ event.detail = true;
59
+ }
60
+ if (data.supportedLanguages !== undefined) {
61
+ this.supportedLanguages = isNonEmptyArray(data.supportedLanguages) ? data.supportedLanguages : this._languageService.getRegisteredLanguageIds();
62
+ event.supportedLanguages = true;
63
+ }
64
+ if (data.supportsExecutionOrder !== undefined) {
65
+ this.implementsExecutionOrder = data.supportsExecutionOrder;
66
+ event.hasExecutionOrder = true;
67
+ }
68
+ if (data.supportsInterrupt !== undefined) {
69
+ this.implementsInterrupt = data.supportsInterrupt;
70
+ event.hasInterruptHandler = true;
71
+ }
72
+ if (data.hasVariableProvider !== undefined) {
73
+ this.hasVariableProvider = data.hasVariableProvider;
74
+ event.hasVariableProvider = true;
75
+ }
76
+ this._onDidChange.fire(event);
77
+ }
78
+ }
79
+ class MainThreadKernelDetectionTask {
80
+ constructor(notebookType) {
81
+ this.notebookType = notebookType;
82
+ }
83
+ }
84
+ let MainThreadNotebookKernels = class MainThreadNotebookKernels {
85
+ constructor(
86
+ extHostContext,
87
+ _languageService,
88
+ _notebookKernelService,
89
+ _notebookExecutionStateService,
90
+ _notebookService,
91
+ notebookEditorService
92
+ ) {
93
+ this._languageService = _languageService;
94
+ this._notebookKernelService = _notebookKernelService;
95
+ this._notebookExecutionStateService = _notebookExecutionStateService;
96
+ this._notebookService = _notebookService;
97
+ this._editors = ( new DisposableMap());
98
+ this._disposables = ( new DisposableStore());
99
+ this._kernels = ( new Map());
100
+ this._kernelDetectionTasks = ( new Map());
101
+ this._kernelSourceActionProviders = ( new Map());
102
+ this._kernelSourceActionProvidersEventRegistrations = ( new Map());
103
+ this._executions = ( new Map());
104
+ this._notebookExecutions = ( new Map());
105
+ this.variableRequestIndex = 0;
106
+ this.variableRequestMap = ( new Map());
107
+ this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebookKernels));
108
+ notebookEditorService.listNotebookEditors().forEach(this._onEditorAdd, this);
109
+ notebookEditorService.onDidAddNotebookEditor(this._onEditorAdd, this, this._disposables);
110
+ notebookEditorService.onDidRemoveNotebookEditor(this._onEditorRemove, this, this._disposables);
111
+ this._disposables.add(toDisposable(() => {
112
+ this._executions.forEach(e => {
113
+ e.complete({});
114
+ });
115
+ this._notebookExecutions.forEach(e => e.complete());
116
+ }));
117
+ this._disposables.add(this._notebookKernelService.onDidChangeSelectedNotebooks(e => {
118
+ for (const [handle, [kernel]] of this._kernels) {
119
+ if (e.oldKernel === kernel.id) {
120
+ this._proxy.$acceptNotebookAssociation(handle, e.notebook, false);
121
+ } else if (e.newKernel === kernel.id) {
122
+ this._proxy.$acceptNotebookAssociation(handle, e.notebook, true);
123
+ }
124
+ }
125
+ }));
126
+ }
127
+ dispose() {
128
+ this._disposables.dispose();
129
+ for (const [, registration] of ( this._kernels.values())) {
130
+ registration.dispose();
131
+ }
132
+ for (const [, registration] of ( this._kernelDetectionTasks.values())) {
133
+ registration.dispose();
134
+ }
135
+ for (const [, registration] of ( this._kernelSourceActionProviders.values())) {
136
+ registration.dispose();
137
+ }
138
+ this._editors.dispose();
139
+ }
140
+ _onEditorAdd(editor) {
141
+ const ipcListener = editor.onDidReceiveMessage(e => {
142
+ if (!editor.hasModel()) {
143
+ return;
144
+ }
145
+ const {
146
+ selected
147
+ } = this._notebookKernelService.getMatchingKernel(editor.textModel);
148
+ if (!selected) {
149
+ return;
150
+ }
151
+ for (const [handle, candidate] of this._kernels) {
152
+ if (candidate[0] === selected) {
153
+ this._proxy.$acceptKernelMessageFromRenderer(handle, editor.getId(), e.message);
154
+ break;
155
+ }
156
+ }
157
+ });
158
+ this._editors.set(editor, ipcListener);
159
+ }
160
+ _onEditorRemove(editor) {
161
+ this._editors.deleteAndDispose(editor);
162
+ }
163
+ async $postMessage(handle, editorId, message) {
164
+ const tuple = this._kernels.get(handle);
165
+ if (!tuple) {
166
+ throw ( new Error("kernel already disposed"));
167
+ }
168
+ const [kernel] = tuple;
169
+ let didSend = false;
170
+ for (const [editor] of this._editors) {
171
+ if (!editor.hasModel()) {
172
+ continue;
173
+ }
174
+ if (this._notebookKernelService.getMatchingKernel(editor.textModel).selected !== kernel) {
175
+ continue;
176
+ }
177
+ if (editorId === undefined) {
178
+ editor.postMessage(message);
179
+ didSend = true;
180
+ } else if (editor.getId() === editorId) {
181
+ editor.postMessage(message);
182
+ didSend = true;
183
+ break;
184
+ }
185
+ }
186
+ return didSend;
187
+ }
188
+ $receiveVariable(requestId, variable) {
189
+ const emitter = this.variableRequestMap.get(requestId);
190
+ if (emitter) {
191
+ emitter.emitOne(variable);
192
+ }
193
+ }
194
+ async $addKernel(handle, data) {
195
+ const that = this;
196
+ const kernel = new (class extends MainThreadKernel {
197
+ async executeNotebookCellsRequest(uri, handles) {
198
+ await that._proxy.$executeCells(handle, uri, handles);
199
+ }
200
+ async cancelNotebookCellExecution(uri, handles) {
201
+ await that._proxy.$cancelCells(handle, uri, handles);
202
+ }
203
+ provideVariables(notebookUri, parentId, kind, start, token) {
204
+ const requestId = `${handle}variables${that.variableRequestIndex++}`;
205
+ return new AsyncIterableProducer(async emitter => {
206
+ that.variableRequestMap.set(requestId, emitter);
207
+ try {
208
+ await that._proxy.$provideVariables(handle, requestId, notebookUri, parentId, kind, start, token);
209
+ } finally {
210
+ that.variableRequestMap.delete(requestId);
211
+ }
212
+ });
213
+ }
214
+ })(data, this._languageService);
215
+ const disposables = this._disposables.add(( new DisposableStore()));
216
+ this._kernels.set(handle, [kernel, disposables]);
217
+ disposables.add(this._notebookKernelService.registerKernel(kernel));
218
+ }
219
+ $updateKernel(handle, data) {
220
+ const tuple = this._kernels.get(handle);
221
+ if (tuple) {
222
+ tuple[0].update(data);
223
+ }
224
+ }
225
+ $removeKernel(handle) {
226
+ const tuple = this._kernels.get(handle);
227
+ if (tuple) {
228
+ tuple[1].dispose();
229
+ this._kernels.delete(handle);
230
+ }
231
+ }
232
+ $updateNotebookPriority(handle, notebook, value) {
233
+ const tuple = this._kernels.get(handle);
234
+ if (tuple) {
235
+ this._notebookKernelService.updateKernelNotebookAffinity(tuple[0], URI.revive(notebook), value);
236
+ }
237
+ }
238
+ $createExecution(handle, controllerId, rawUri, cellHandle) {
239
+ const uri = URI.revive(rawUri);
240
+ const notebook = this._notebookService.getNotebookTextModel(uri);
241
+ if (!notebook) {
242
+ throw ( new Error(`Notebook not found: ${( uri.toString())}`));
243
+ }
244
+ const kernel = this._notebookKernelService.getMatchingKernel(notebook);
245
+ if (!kernel.selected || kernel.selected.id !== controllerId) {
246
+ throw ( new Error(`Kernel is not selected: ${kernel.selected?.id} !== ${controllerId}`));
247
+ }
248
+ const execution = this._notebookExecutionStateService.createCellExecution(uri, cellHandle);
249
+ execution.confirm();
250
+ this._executions.set(handle, execution);
251
+ }
252
+ $updateExecution(handle, data) {
253
+ const updates = data.value;
254
+ try {
255
+ const execution = this._executions.get(handle);
256
+ execution?.update(( updates.map(NotebookDto.fromCellExecuteUpdateDto)));
257
+ } catch (e) {
258
+ onUnexpectedError(e);
259
+ }
260
+ }
261
+ $completeExecution(handle, data) {
262
+ try {
263
+ const execution = this._executions.get(handle);
264
+ execution?.complete(NotebookDto.fromCellExecuteCompleteDto(data.value));
265
+ } catch (e) {
266
+ onUnexpectedError(e);
267
+ } finally {
268
+ this._executions.delete(handle);
269
+ }
270
+ }
271
+ $createNotebookExecution(handle, controllerId, rawUri) {
272
+ const uri = URI.revive(rawUri);
273
+ const notebook = this._notebookService.getNotebookTextModel(uri);
274
+ if (!notebook) {
275
+ throw ( new Error(`Notebook not found: ${( uri.toString())}`));
276
+ }
277
+ const kernel = this._notebookKernelService.getMatchingKernel(notebook);
278
+ if (!kernel.selected || kernel.selected.id !== controllerId) {
279
+ throw ( new Error(`Kernel is not selected: ${kernel.selected?.id} !== ${controllerId}`));
280
+ }
281
+ const execution = this._notebookExecutionStateService.createExecution(uri);
282
+ execution.confirm();
283
+ this._notebookExecutions.set(handle, execution);
284
+ }
285
+ $beginNotebookExecution(handle) {
286
+ try {
287
+ const execution = this._notebookExecutions.get(handle);
288
+ execution?.begin();
289
+ } catch (e) {
290
+ onUnexpectedError(e);
291
+ }
292
+ }
293
+ $completeNotebookExecution(handle) {
294
+ try {
295
+ const execution = this._notebookExecutions.get(handle);
296
+ execution?.complete();
297
+ } catch (e) {
298
+ onUnexpectedError(e);
299
+ } finally {
300
+ this._notebookExecutions.delete(handle);
301
+ }
302
+ }
303
+ async $addKernelDetectionTask(handle, notebookType) {
304
+ const kernelDetectionTask = ( new MainThreadKernelDetectionTask(notebookType));
305
+ const registration = this._notebookKernelService.registerNotebookKernelDetectionTask(kernelDetectionTask);
306
+ this._kernelDetectionTasks.set(handle, [kernelDetectionTask, registration]);
307
+ }
308
+ $removeKernelDetectionTask(handle) {
309
+ const tuple = this._kernelDetectionTasks.get(handle);
310
+ if (tuple) {
311
+ tuple[1].dispose();
312
+ this._kernelDetectionTasks.delete(handle);
313
+ }
314
+ }
315
+ async $addKernelSourceActionProvider(handle, eventHandle, notebookType) {
316
+ const kernelSourceActionProvider = {
317
+ viewType: notebookType,
318
+ provideKernelSourceActions: async () => {
319
+ const actions = await this._proxy.$provideKernelSourceActions(handle, CancellationToken.None);
320
+ return ( actions.map(action => {
321
+ let documentation = action.documentation;
322
+ if (action.documentation && typeof action.documentation !== "string") {
323
+ documentation = URI.revive(action.documentation);
324
+ }
325
+ return {
326
+ label: action.label,
327
+ command: action.command,
328
+ description: action.description,
329
+ detail: action.detail,
330
+ documentation
331
+ };
332
+ }));
333
+ }
334
+ };
335
+ if (typeof eventHandle === "number") {
336
+ const emitter = ( new Emitter());
337
+ this._kernelSourceActionProvidersEventRegistrations.set(eventHandle, emitter);
338
+ kernelSourceActionProvider.onDidChangeSourceActions = emitter.event;
339
+ }
340
+ const registration = this._notebookKernelService.registerKernelSourceActionProvider(notebookType, kernelSourceActionProvider);
341
+ this._kernelSourceActionProviders.set(handle, [kernelSourceActionProvider, registration]);
342
+ }
343
+ $removeKernelSourceActionProvider(handle, eventHandle) {
344
+ const tuple = this._kernelSourceActionProviders.get(handle);
345
+ if (tuple) {
346
+ tuple[1].dispose();
347
+ this._kernelSourceActionProviders.delete(handle);
348
+ }
349
+ if (typeof eventHandle === "number") {
350
+ this._kernelSourceActionProvidersEventRegistrations.delete(eventHandle);
351
+ }
352
+ }
353
+ $emitNotebookKernelSourceActionsChangeEvent(eventHandle) {
354
+ const emitter = this._kernelSourceActionProvidersEventRegistrations.get(eventHandle);
355
+ if (emitter instanceof Emitter) {
356
+ emitter.fire(undefined);
357
+ }
358
+ }
359
+ $variablesUpdated(notebookUri) {
360
+ this._notebookKernelService.notifyVariablesChange(URI.revive(notebookUri));
361
+ }
362
+ };
363
+ MainThreadNotebookKernels = __decorate([
364
+ extHostNamedCustomer(MainContext.MainThreadNotebookKernels),
365
+ ( __param(1, ILanguageService)),
366
+ ( __param(2, INotebookKernelService)),
367
+ ( __param(3, INotebookExecutionStateService)),
368
+ ( __param(4, INotebookService)),
369
+ ( __param(5, INotebookEditorService))
370
+ ], MainThreadNotebookKernels);
371
+
372
+ export { MainThreadNotebookKernels };
@@ -0,0 +1,10 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { MainThreadNotebookRenderersShape } from "@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol";
3
+ import { IExtHostContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers";
4
+ import { INotebookRendererMessagingService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookRendererMessagingService.service";
5
+ export declare class MainThreadNotebookRenderers extends Disposable implements MainThreadNotebookRenderersShape {
6
+ private readonly messaging;
7
+ private readonly proxy;
8
+ constructor(extHostContext: IExtHostContext, messaging: INotebookRendererMessagingService);
9
+ $postMessage(editorId: string | undefined, rendererId: string, message: unknown): Promise<boolean>;
10
+ }
@@ -0,0 +1,26 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
4
+ import { ExtHostContext, MainContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol';
5
+ import { extHostNamedCustomer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers';
6
+ import { INotebookRendererMessagingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookRendererMessagingService.service';
7
+
8
+ let MainThreadNotebookRenderers = class MainThreadNotebookRenderers extends Disposable {
9
+ constructor(extHostContext, messaging) {
10
+ super();
11
+ this.messaging = messaging;
12
+ this.proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebookRenderers));
13
+ this._register(messaging.onShouldPostMessage(e => {
14
+ this.proxy.$postRendererMessage(e.editorId, e.rendererId, e.message);
15
+ }));
16
+ }
17
+ $postMessage(editorId, rendererId, message) {
18
+ return this.messaging.receiveMessage(editorId, rendererId, message);
19
+ }
20
+ };
21
+ MainThreadNotebookRenderers = __decorate([
22
+ extHostNamedCustomer(MainContext.MainThreadNotebookRenderers),
23
+ ( __param(1, INotebookRendererMessagingService))
24
+ ], MainThreadNotebookRenderers);
25
+
26
+ export { MainThreadNotebookRenderers };
@@ -0,0 +1,9 @@
1
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
2
+ import { IExtHostContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers";
3
+ import { IWorkingCopyFileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service";
4
+ export declare class SaveParticipant {
5
+ private readonly workingCopyFileService;
6
+ private _saveParticipantDisposable;
7
+ constructor(extHostContext: IExtHostContext, instantiationService: IInstantiationService, workingCopyFileService: IWorkingCopyFileService);
8
+ dispose(): void;
9
+ }