@codingame/monaco-vscode-notebook-service-override 37.0.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.
- package/index.js +5 -0
- package/package.json +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.d.ts +22 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +210 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.d.ts +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +138 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.d.ts +29 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +194 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.d.ts +27 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +149 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.d.ts +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +372 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.d.ts +10 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +26 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.d.ts +9 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +43 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +7 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +23 -23
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +8 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +10 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +9 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +14 -14
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +11 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +13 -13
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +27 -27
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +25 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +22 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +7 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +15 -15
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +22 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +64 -64
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +10 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +31 -31
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.js +9 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditorInput.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditorInput.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/replEditorAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.d.ts +87 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +352 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/replNotebook/browser/repl.contribution.js +5 -5
- package/vscode/src/vs/workbench/contrib/replNotebook/browser/replEditorAccessibilityHelp.js +14 -14
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +12 -12
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +1 -1
package/index.js
CHANGED
|
@@ -38,6 +38,11 @@ import { NotebookOutlineEntryFactory } from './vscode/src/vs/workbench/contrib/n
|
|
|
38
38
|
import { INotebookOutlineEntryFactory } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.service';
|
|
39
39
|
import './vscode/src/vs/workbench/contrib/replNotebook/browser/repl.contribution.js';
|
|
40
40
|
import './vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js';
|
|
41
|
+
import './vscode/src/vs/workbench/api/browser/mainThreadNotebook.js';
|
|
42
|
+
import './vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js';
|
|
43
|
+
import './vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js';
|
|
44
|
+
import './vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js';
|
|
45
|
+
import './vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js';
|
|
41
46
|
|
|
42
47
|
function getServiceOverride() {
|
|
43
48
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-notebook-service-override",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - notebook service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "37.
|
|
19
|
-
"@codingame/monaco-vscode-katex-common": "37.
|
|
18
|
+
"@codingame/monaco-vscode-api": "37.2.0",
|
|
19
|
+
"@codingame/monaco-vscode-katex-common": "37.2.0"
|
|
20
20
|
},
|
|
21
21
|
"main": "index.js",
|
|
22
22
|
"module": "index.js",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
2
|
+
import { INotebookCellStatusBarService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCellStatusBarService.service";
|
|
3
|
+
import { INotebookContributionData, NotebookExtensionDescription, TransientOptions } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon";
|
|
4
|
+
import { INotebookService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service";
|
|
5
|
+
import { IExtHostContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers";
|
|
6
|
+
import { MainThreadNotebookShape } from "@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol";
|
|
7
|
+
export declare class MainThreadNotebooks implements MainThreadNotebookShape {
|
|
8
|
+
private readonly _notebookService;
|
|
9
|
+
private readonly _cellStatusBarService;
|
|
10
|
+
private readonly _logService;
|
|
11
|
+
private readonly _disposables;
|
|
12
|
+
private readonly _proxy;
|
|
13
|
+
private readonly _notebookSerializer;
|
|
14
|
+
private readonly _notebookCellStatusBarRegistrations;
|
|
15
|
+
constructor(extHostContext: IExtHostContext, _notebookService: INotebookService, _cellStatusBarService: INotebookCellStatusBarService, _logService: ILogService);
|
|
16
|
+
dispose(): void;
|
|
17
|
+
$registerNotebookSerializer(handle: number, extension: NotebookExtensionDescription, viewType: string, options: TransientOptions, data: INotebookContributionData | undefined): void;
|
|
18
|
+
$unregisterNotebookSerializer(handle: number): void;
|
|
19
|
+
$emitCellStatusBarEvent(eventHandle: number): void;
|
|
20
|
+
$registerNotebookCellStatusBarItemProvider(handle: number, eventHandle: number | undefined, viewType: string): Promise<void>;
|
|
21
|
+
$unregisterNotebookCellStatusBarItemProvider(handle: number, eventHandle: number | undefined): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
4
|
+
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
5
|
+
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
6
|
+
import { DisposableStore, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import { StopWatch } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stopwatch';
|
|
8
|
+
import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
9
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
10
|
+
import { CommandsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands';
|
|
11
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
12
|
+
import { NotebookDto } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/api/browser/mainThreadNotebookDto';
|
|
13
|
+
import { INotebookCellStatusBarService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCellStatusBarService.service';
|
|
14
|
+
import { SimpleNotebookProviderInfo } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService';
|
|
15
|
+
import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
|
|
16
|
+
import { extHostNamedCustomer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers';
|
|
17
|
+
import { SerializableObjectWithBuffers } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/proxyIdentifier';
|
|
18
|
+
import { ExtHostContext, MainContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol';
|
|
19
|
+
import { revive } from '@codingame/monaco-vscode-api/vscode/vs/base/common/marshalling';
|
|
20
|
+
import { coalesce } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
21
|
+
import { FileOperationError } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
22
|
+
|
|
23
|
+
let MainThreadNotebooks = class MainThreadNotebooks {
|
|
24
|
+
constructor(extHostContext, _notebookService, _cellStatusBarService, _logService) {
|
|
25
|
+
this._notebookService = _notebookService;
|
|
26
|
+
this._cellStatusBarService = _cellStatusBarService;
|
|
27
|
+
this._logService = _logService;
|
|
28
|
+
this._disposables = ( new DisposableStore());
|
|
29
|
+
this._notebookSerializer = ( new Map());
|
|
30
|
+
this._notebookCellStatusBarRegistrations = ( new Map());
|
|
31
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebook));
|
|
32
|
+
}
|
|
33
|
+
dispose() {
|
|
34
|
+
this._disposables.dispose();
|
|
35
|
+
dispose(( this._notebookSerializer.values()));
|
|
36
|
+
dispose(( this._notebookCellStatusBarRegistrations.values()));
|
|
37
|
+
this._notebookCellStatusBarRegistrations.clear();
|
|
38
|
+
}
|
|
39
|
+
$registerNotebookSerializer(handle, extension, viewType, options, data) {
|
|
40
|
+
const disposables = ( new DisposableStore());
|
|
41
|
+
disposables.add(this._notebookService.registerNotebookSerializer(viewType, extension, {
|
|
42
|
+
options,
|
|
43
|
+
dataToNotebook: async data => {
|
|
44
|
+
const sw = ( new StopWatch());
|
|
45
|
+
let result;
|
|
46
|
+
if (data.byteLength === 0 && viewType === "interactive") {
|
|
47
|
+
result = NotebookDto.fromNotebookDataDto({
|
|
48
|
+
cells: [],
|
|
49
|
+
metadata: {}
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
const dto = await this._proxy.$dataToNotebook(handle, data, CancellationToken.None);
|
|
53
|
+
result = NotebookDto.fromNotebookDataDto(dto.value);
|
|
54
|
+
}
|
|
55
|
+
this._logService.trace(`[NotebookSerializer] dataToNotebook DONE after ${sw.elapsed()}ms`, {
|
|
56
|
+
viewType,
|
|
57
|
+
extensionId: extension.id.value
|
|
58
|
+
});
|
|
59
|
+
return result;
|
|
60
|
+
},
|
|
61
|
+
notebookToData: data => {
|
|
62
|
+
const sw = ( new StopWatch());
|
|
63
|
+
const result = this._proxy.$notebookToData(handle, ( new SerializableObjectWithBuffers(NotebookDto.toNotebookDataDto(data))), CancellationToken.None);
|
|
64
|
+
this._logService.trace(`[NotebookSerializer] notebookToData DONE after ${sw.elapsed()}`, {
|
|
65
|
+
viewType,
|
|
66
|
+
extensionId: extension.id.value
|
|
67
|
+
});
|
|
68
|
+
return result;
|
|
69
|
+
},
|
|
70
|
+
save: async (uri, versionId, options, token) => {
|
|
71
|
+
const stat = await this._proxy.$saveNotebook(handle, uri, versionId, options, token);
|
|
72
|
+
if (isFileOperationError(stat)) {
|
|
73
|
+
throw ( new FileOperationError(stat.message, stat.fileOperationResult, stat.options));
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
...stat,
|
|
77
|
+
children: undefined,
|
|
78
|
+
resource: uri
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
searchInNotebooks: async (textQuery, token, allPriorityInfo) => {
|
|
82
|
+
const contributedType = this._notebookService.getContributedNotebookType(viewType);
|
|
83
|
+
if (!contributedType) {
|
|
84
|
+
return {
|
|
85
|
+
results: [],
|
|
86
|
+
limitHit: false
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const fileNames = contributedType.selectors;
|
|
90
|
+
const includes = ( fileNames.map(selector => {
|
|
91
|
+
const globPattern = selector.include || selector;
|
|
92
|
+
return ( globPattern.toString());
|
|
93
|
+
}));
|
|
94
|
+
if (!includes.length) {
|
|
95
|
+
return {
|
|
96
|
+
results: [],
|
|
97
|
+
limitHit: false
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const thisPriorityInfo = coalesce([{
|
|
101
|
+
isFromSettings: false,
|
|
102
|
+
filenamePatterns: includes
|
|
103
|
+
}, ...(allPriorityInfo.get(viewType) ?? [])]);
|
|
104
|
+
const otherEditorsPriorityInfo = Array.from(( allPriorityInfo.keys())).flatMap(key => {
|
|
105
|
+
if (key !== viewType) {
|
|
106
|
+
return allPriorityInfo.get(key) ?? [];
|
|
107
|
+
}
|
|
108
|
+
return [];
|
|
109
|
+
});
|
|
110
|
+
const searchComplete = await this._proxy.$searchInNotebooks(handle, textQuery, thisPriorityInfo, otherEditorsPriorityInfo, token);
|
|
111
|
+
const revivedResults = ( searchComplete.results.map(result => {
|
|
112
|
+
const resource = URI.revive(result.resource);
|
|
113
|
+
return {
|
|
114
|
+
resource,
|
|
115
|
+
cellResults: ( result.cellResults.map(e => revive(e)))
|
|
116
|
+
};
|
|
117
|
+
}));
|
|
118
|
+
return {
|
|
119
|
+
results: revivedResults,
|
|
120
|
+
limitHit: searchComplete.limitHit
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
if (data) {
|
|
125
|
+
disposables.add(this._notebookService.registerContributedNotebookType(viewType, data));
|
|
126
|
+
}
|
|
127
|
+
this._notebookSerializer.set(handle, disposables);
|
|
128
|
+
this._logService.trace("[NotebookSerializer] registered notebook serializer", {
|
|
129
|
+
viewType,
|
|
130
|
+
extensionId: extension.id.value
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
$unregisterNotebookSerializer(handle) {
|
|
134
|
+
this._notebookSerializer.get(handle)?.dispose();
|
|
135
|
+
this._notebookSerializer.delete(handle);
|
|
136
|
+
}
|
|
137
|
+
$emitCellStatusBarEvent(eventHandle) {
|
|
138
|
+
const emitter = this._notebookCellStatusBarRegistrations.get(eventHandle);
|
|
139
|
+
if (emitter instanceof Emitter) {
|
|
140
|
+
emitter.fire(undefined);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async $registerNotebookCellStatusBarItemProvider(handle, eventHandle, viewType) {
|
|
144
|
+
const that = this;
|
|
145
|
+
const provider = {
|
|
146
|
+
async provideCellStatusBarItems(uri, index, token) {
|
|
147
|
+
const result = await that._proxy.$provideNotebookCellStatusBarItems(handle, uri, index, token);
|
|
148
|
+
return {
|
|
149
|
+
items: result?.items ?? [],
|
|
150
|
+
dispose() {
|
|
151
|
+
if (result) {
|
|
152
|
+
that._proxy.$releaseNotebookCellStatusBarItems(result.cacheId);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
viewType
|
|
158
|
+
};
|
|
159
|
+
if (typeof eventHandle === "number") {
|
|
160
|
+
const emitter = ( new Emitter());
|
|
161
|
+
this._notebookCellStatusBarRegistrations.set(eventHandle, emitter);
|
|
162
|
+
provider.onDidChangeStatusBarItems = emitter.event;
|
|
163
|
+
}
|
|
164
|
+
const disposable = this._cellStatusBarService.registerCellStatusBarItemProvider(provider);
|
|
165
|
+
this._notebookCellStatusBarRegistrations.set(handle, disposable);
|
|
166
|
+
}
|
|
167
|
+
async $unregisterNotebookCellStatusBarItemProvider(handle, eventHandle) {
|
|
168
|
+
const unregisterThing = handle => {
|
|
169
|
+
const entry = this._notebookCellStatusBarRegistrations.get(handle);
|
|
170
|
+
if (entry) {
|
|
171
|
+
this._notebookCellStatusBarRegistrations.get(handle)?.dispose();
|
|
172
|
+
this._notebookCellStatusBarRegistrations.delete(handle);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
unregisterThing(handle);
|
|
176
|
+
if (typeof eventHandle === "number") {
|
|
177
|
+
unregisterThing(eventHandle);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
MainThreadNotebooks = __decorate([extHostNamedCustomer(MainContext.MainThreadNotebook), ( __param(1, INotebookService)), ( __param(2, INotebookCellStatusBarService)), ( __param(3, ILogService))], MainThreadNotebooks);
|
|
182
|
+
CommandsRegistry.registerCommand("_executeDataToNotebook", async (accessor, ...args) => {
|
|
183
|
+
const [notebookType, bytes] = args;
|
|
184
|
+
assertType(typeof notebookType === "string", "string");
|
|
185
|
+
assertType(bytes instanceof VSBuffer, "VSBuffer");
|
|
186
|
+
const notebookService = accessor.get(INotebookService);
|
|
187
|
+
const info = await notebookService.withNotebookDataProvider(notebookType);
|
|
188
|
+
if (!(info instanceof SimpleNotebookProviderInfo)) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const dto = await info.serializer.dataToNotebook(bytes);
|
|
192
|
+
return ( new SerializableObjectWithBuffers(NotebookDto.toNotebookDataDto(dto)));
|
|
193
|
+
});
|
|
194
|
+
CommandsRegistry.registerCommand("_executeNotebookToData", async (accessor, notebookType, dto) => {
|
|
195
|
+
assertType(typeof notebookType === "string", "string");
|
|
196
|
+
const notebookService = accessor.get(INotebookService);
|
|
197
|
+
const info = await notebookService.withNotebookDataProvider(notebookType);
|
|
198
|
+
if (!(info instanceof SimpleNotebookProviderInfo)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const data = NotebookDto.fromNotebookDataDto(dto.value);
|
|
202
|
+
const bytes = await info.serializer.notebookToData(data);
|
|
203
|
+
return bytes;
|
|
204
|
+
});
|
|
205
|
+
function isFileOperationError(error) {
|
|
206
|
+
const candidate = error;
|
|
207
|
+
return typeof candidate?.fileOperationResult === "number" && typeof candidate?.message === "string";
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { MainThreadNotebooks };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { URI, UriComponents } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
2
|
+
import { NotebookTextModel } from "../../contrib/notebook/common/model/notebookTextModel.js";
|
|
3
|
+
import { INotebookEditorModelResolverService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.service";
|
|
4
|
+
import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
|
|
5
|
+
import { MainThreadNotebookDocumentsShape, NotebookDataDto } from "@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol";
|
|
6
|
+
import { IExtHostContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers";
|
|
7
|
+
export declare class MainThreadNotebookDocuments implements MainThreadNotebookDocumentsShape {
|
|
8
|
+
private readonly _notebookEditorModelResolverService;
|
|
9
|
+
private readonly _uriIdentityService;
|
|
10
|
+
private readonly _disposables;
|
|
11
|
+
private readonly _proxy;
|
|
12
|
+
private readonly _documentEventListenersMapping;
|
|
13
|
+
private readonly _modelReferenceCollection;
|
|
14
|
+
constructor(extHostContext: IExtHostContext, _notebookEditorModelResolverService: INotebookEditorModelResolverService, _uriIdentityService: IUriIdentityService);
|
|
15
|
+
dispose(): void;
|
|
16
|
+
handleNotebooksAdded(notebooks: readonly NotebookTextModel[]): void;
|
|
17
|
+
handleNotebooksRemoved(uris: URI[]): void;
|
|
18
|
+
$tryCreateNotebook(options: {
|
|
19
|
+
viewType: string;
|
|
20
|
+
content?: NotebookDataDto;
|
|
21
|
+
}): Promise<UriComponents>;
|
|
22
|
+
$tryOpenNotebook(uriComponents: UriComponents): Promise<URI>;
|
|
23
|
+
$trySaveNotebook(uriComponents: UriComponents): Promise<boolean>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
4
|
+
import { DisposableStore, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
6
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
7
|
+
import { BoundModelReferenceCollection } from '@codingame/monaco-vscode-api/vscode/vs/workbench/api/browser/mainThreadDocuments';
|
|
8
|
+
import { NotebookCellsChangeType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
9
|
+
import { INotebookEditorModelResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.service';
|
|
10
|
+
import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
11
|
+
import { ExtHostContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol';
|
|
12
|
+
import { NotebookDto } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/api/browser/mainThreadNotebookDto';
|
|
13
|
+
import { SerializableObjectWithBuffers } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/proxyIdentifier';
|
|
14
|
+
|
|
15
|
+
let MainThreadNotebookDocuments = class MainThreadNotebookDocuments {
|
|
16
|
+
constructor(extHostContext, _notebookEditorModelResolverService, _uriIdentityService) {
|
|
17
|
+
this._notebookEditorModelResolverService = _notebookEditorModelResolverService;
|
|
18
|
+
this._uriIdentityService = _uriIdentityService;
|
|
19
|
+
this._disposables = ( new DisposableStore());
|
|
20
|
+
this._documentEventListenersMapping = ( new ResourceMap());
|
|
21
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebookDocuments));
|
|
22
|
+
this._modelReferenceCollection = ( new BoundModelReferenceCollection(this._uriIdentityService.extUri));
|
|
23
|
+
this._disposables.add(this._notebookEditorModelResolverService.onDidChangeDirty(
|
|
24
|
+
model => this._proxy.$acceptDirtyStateChanged(model.resource, model.isDirty())
|
|
25
|
+
));
|
|
26
|
+
this._disposables.add(
|
|
27
|
+
this._notebookEditorModelResolverService.onDidSaveNotebook(e => this._proxy.$acceptModelSaved(e))
|
|
28
|
+
);
|
|
29
|
+
this._disposables.add(_notebookEditorModelResolverService.onWillFailWithConflict(e => {
|
|
30
|
+
this._modelReferenceCollection.remove(e.resource);
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
dispose() {
|
|
34
|
+
this._disposables.dispose();
|
|
35
|
+
this._modelReferenceCollection.dispose();
|
|
36
|
+
dispose(( this._documentEventListenersMapping.values()));
|
|
37
|
+
}
|
|
38
|
+
handleNotebooksAdded(notebooks) {
|
|
39
|
+
for (const textModel of notebooks) {
|
|
40
|
+
const disposableStore = ( new DisposableStore());
|
|
41
|
+
disposableStore.add(textModel.onDidChangeContent(event => {
|
|
42
|
+
const eventDto = {
|
|
43
|
+
versionId: event.versionId,
|
|
44
|
+
rawEvents: []
|
|
45
|
+
};
|
|
46
|
+
for (const e of event.rawEvents) {
|
|
47
|
+
switch (e.kind) {
|
|
48
|
+
case NotebookCellsChangeType.ModelChange:
|
|
49
|
+
eventDto.rawEvents.push({
|
|
50
|
+
kind: e.kind,
|
|
51
|
+
changes: ( e.changes.map(diff => [diff[0], diff[1], ( diff[2].map(cell => NotebookDto.toNotebookCellDto(cell)))]))
|
|
52
|
+
});
|
|
53
|
+
break;
|
|
54
|
+
case NotebookCellsChangeType.Move:
|
|
55
|
+
eventDto.rawEvents.push({
|
|
56
|
+
kind: e.kind,
|
|
57
|
+
index: e.index,
|
|
58
|
+
length: e.length,
|
|
59
|
+
newIdx: e.newIdx
|
|
60
|
+
});
|
|
61
|
+
break;
|
|
62
|
+
case NotebookCellsChangeType.Output:
|
|
63
|
+
eventDto.rawEvents.push({
|
|
64
|
+
kind: e.kind,
|
|
65
|
+
index: e.index,
|
|
66
|
+
outputs: ( e.outputs.map(NotebookDto.toNotebookOutputDto))
|
|
67
|
+
});
|
|
68
|
+
break;
|
|
69
|
+
case NotebookCellsChangeType.OutputItem:
|
|
70
|
+
eventDto.rawEvents.push({
|
|
71
|
+
kind: e.kind,
|
|
72
|
+
index: e.index,
|
|
73
|
+
outputId: e.outputId,
|
|
74
|
+
outputItems: ( e.outputItems.map(NotebookDto.toNotebookOutputItemDto)),
|
|
75
|
+
append: e.append
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
case NotebookCellsChangeType.ChangeCellLanguage:
|
|
79
|
+
case NotebookCellsChangeType.ChangeCellContent:
|
|
80
|
+
case NotebookCellsChangeType.ChangeCellMetadata:
|
|
81
|
+
case NotebookCellsChangeType.ChangeCellInternalMetadata:
|
|
82
|
+
eventDto.rawEvents.push(e);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const hasDocumentMetadataChangeEvent = event.rawEvents.find(e => e.kind === NotebookCellsChangeType.ChangeDocumentMetadata);
|
|
87
|
+
this._proxy.$acceptModelChanged(textModel.uri, ( new SerializableObjectWithBuffers(eventDto)), this._notebookEditorModelResolverService.isDirty(textModel.uri), hasDocumentMetadataChangeEvent ? textModel.metadata : undefined);
|
|
88
|
+
}));
|
|
89
|
+
this._documentEventListenersMapping.set(textModel.uri, disposableStore);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
handleNotebooksRemoved(uris) {
|
|
93
|
+
for (const uri of uris) {
|
|
94
|
+
this._documentEventListenersMapping.get(uri)?.dispose();
|
|
95
|
+
this._documentEventListenersMapping.delete(uri);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async $tryCreateNotebook(options) {
|
|
99
|
+
if (options.content) {
|
|
100
|
+
const ref = await this._notebookEditorModelResolverService.resolve({
|
|
101
|
+
untitledResource: undefined
|
|
102
|
+
}, options.viewType);
|
|
103
|
+
Event.once(ref.object.notebook.onWillDispose)(() => {
|
|
104
|
+
ref.dispose();
|
|
105
|
+
});
|
|
106
|
+
this._proxy.$acceptDirtyStateChanged(ref.object.resource, true);
|
|
107
|
+
if (options.content) {
|
|
108
|
+
const data = NotebookDto.fromNotebookDataDto(options.content);
|
|
109
|
+
ref.object.notebook.reset(data.cells, data.metadata, ref.object.notebook.transientOptions);
|
|
110
|
+
}
|
|
111
|
+
return ref.object.notebook.uri;
|
|
112
|
+
} else {
|
|
113
|
+
const notebook = await this._notebookEditorModelResolverService.createUntitledNotebookTextModel(options.viewType);
|
|
114
|
+
return notebook.uri;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async $tryOpenNotebook(uriComponents) {
|
|
118
|
+
const uri = URI.revive(uriComponents);
|
|
119
|
+
const ref = await this._notebookEditorModelResolverService.resolve(uri, undefined);
|
|
120
|
+
if (uriComponents.scheme === "untitled") {
|
|
121
|
+
ref.object.notebook.onWillDispose(() => {
|
|
122
|
+
ref.dispose();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
this._modelReferenceCollection.add(uri, ref);
|
|
126
|
+
return uri;
|
|
127
|
+
}
|
|
128
|
+
async $trySaveNotebook(uriComponents) {
|
|
129
|
+
const uri = URI.revive(uriComponents);
|
|
130
|
+
const ref = await this._notebookEditorModelResolverService.resolve(uri);
|
|
131
|
+
const saveResult = await ref.object.save();
|
|
132
|
+
ref.dispose();
|
|
133
|
+
return saveResult;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
MainThreadNotebookDocuments = ( __decorate([( __param(1, INotebookEditorModelResolverService)), ( __param(2, IUriIdentityService))], MainThreadNotebookDocuments));
|
|
137
|
+
|
|
138
|
+
export { MainThreadNotebookDocuments };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
2
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.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 { INotebookService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service";
|
|
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
|
+
export declare class MainThreadNotebooksAndEditors {
|
|
9
|
+
private readonly _notebookService;
|
|
10
|
+
private readonly _notebookEditorService;
|
|
11
|
+
private readonly _editorService;
|
|
12
|
+
private readonly _editorGroupService;
|
|
13
|
+
private readonly _logService;
|
|
14
|
+
private readonly _proxy;
|
|
15
|
+
private readonly _disposables;
|
|
16
|
+
private readonly _editorListeners;
|
|
17
|
+
private _currentState?;
|
|
18
|
+
private readonly _mainThreadNotebooks;
|
|
19
|
+
private readonly _mainThreadEditors;
|
|
20
|
+
constructor(extHostContext: IExtHostContext, instantiationService: IInstantiationService, _notebookService: INotebookService, _notebookEditorService: INotebookEditorService, _editorService: IEditorService, _editorGroupService: IEditorGroupsService, _logService: ILogService);
|
|
21
|
+
dispose(): void;
|
|
22
|
+
private _handleEditorAdd;
|
|
23
|
+
private _handleEditorRemove;
|
|
24
|
+
private _updateState;
|
|
25
|
+
private _onDelta;
|
|
26
|
+
private static _isDeltaEmpty;
|
|
27
|
+
private static _asModelAddData;
|
|
28
|
+
private _asEditorAddData;
|
|
29
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { diffSets, diffMaps } from '@codingame/monaco-vscode-api/vscode/vs/base/common/collections';
|
|
4
|
+
import { DisposableStore, DisposableMap, combinedDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
7
|
+
import { MainThreadNotebookDocuments } from './mainThreadNotebookDocuments.js';
|
|
8
|
+
import { NotebookDto } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/api/browser/mainThreadNotebookDto';
|
|
9
|
+
import { MainThreadNotebookEditors } from './mainThreadNotebookEditors.js';
|
|
10
|
+
import { extHostCustomer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extHostCustomers';
|
|
11
|
+
import { editorGroupToColumn } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupColumn';
|
|
12
|
+
import { getNotebookEditorFromEditorPane } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
13
|
+
import { INotebookEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
|
|
14
|
+
import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
|
|
15
|
+
import { IEditorGroupsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
|
|
16
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
17
|
+
import { ExtHostContext, MainContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol';
|
|
18
|
+
import { SerializableObjectWithBuffers } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/proxyIdentifier';
|
|
19
|
+
|
|
20
|
+
var MainThreadNotebooksAndEditors_1;
|
|
21
|
+
class NotebookAndEditorState {
|
|
22
|
+
static delta(before, after) {
|
|
23
|
+
if (!before) {
|
|
24
|
+
return {
|
|
25
|
+
addedDocuments: [...after.documents],
|
|
26
|
+
removedDocuments: [],
|
|
27
|
+
addedEditors: [...( after.textEditors.values())],
|
|
28
|
+
removedEditors: [],
|
|
29
|
+
visibleEditors: ( [...after.visibleEditors].map(editor => editor[0]))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const documentDelta = diffSets(before.documents, after.documents);
|
|
33
|
+
const editorDelta = diffMaps(before.textEditors, after.textEditors);
|
|
34
|
+
const newActiveEditor = before.activeEditor !== after.activeEditor ? after.activeEditor : undefined;
|
|
35
|
+
const visibleEditorDelta = diffMaps(before.visibleEditors, after.visibleEditors);
|
|
36
|
+
return {
|
|
37
|
+
addedDocuments: documentDelta.added,
|
|
38
|
+
removedDocuments: ( documentDelta.removed.map(e => e.uri)),
|
|
39
|
+
addedEditors: editorDelta.added,
|
|
40
|
+
removedEditors: ( editorDelta.removed.map(removed => removed.getId())),
|
|
41
|
+
newActiveEditor: newActiveEditor,
|
|
42
|
+
visibleEditors: visibleEditorDelta.added.length === 0 && visibleEditorDelta.removed.length === 0 ? undefined : ( [...after.visibleEditors].map(editor => editor[0]))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
constructor(documents, textEditors, activeEditor, visibleEditors) {
|
|
46
|
+
this.documents = documents;
|
|
47
|
+
this.textEditors = textEditors;
|
|
48
|
+
this.activeEditor = activeEditor;
|
|
49
|
+
this.visibleEditors = visibleEditors;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let MainThreadNotebooksAndEditors = MainThreadNotebooksAndEditors_1 = class MainThreadNotebooksAndEditors {
|
|
53
|
+
constructor(
|
|
54
|
+
extHostContext,
|
|
55
|
+
instantiationService,
|
|
56
|
+
_notebookService,
|
|
57
|
+
_notebookEditorService,
|
|
58
|
+
_editorService,
|
|
59
|
+
_editorGroupService,
|
|
60
|
+
_logService
|
|
61
|
+
) {
|
|
62
|
+
this._notebookService = _notebookService;
|
|
63
|
+
this._notebookEditorService = _notebookEditorService;
|
|
64
|
+
this._editorService = _editorService;
|
|
65
|
+
this._editorGroupService = _editorGroupService;
|
|
66
|
+
this._logService = _logService;
|
|
67
|
+
this._disposables = ( new DisposableStore());
|
|
68
|
+
this._editorListeners = ( new DisposableMap());
|
|
69
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostNotebook));
|
|
70
|
+
this._mainThreadNotebooks = instantiationService.createInstance(MainThreadNotebookDocuments, extHostContext);
|
|
71
|
+
this._mainThreadEditors = instantiationService.createInstance(MainThreadNotebookEditors, extHostContext);
|
|
72
|
+
extHostContext.set(MainContext.MainThreadNotebookDocuments, this._mainThreadNotebooks);
|
|
73
|
+
extHostContext.set(MainContext.MainThreadNotebookEditors, this._mainThreadEditors);
|
|
74
|
+
this._notebookService.onWillAddNotebookDocument(() => this._updateState(), this, this._disposables);
|
|
75
|
+
this._notebookService.onDidRemoveNotebookDocument(() => this._updateState(), this, this._disposables);
|
|
76
|
+
this._editorService.onDidActiveEditorChange(() => this._updateState(), this, this._disposables);
|
|
77
|
+
this._editorService.onDidVisibleEditorsChange(() => this._updateState(), this, this._disposables);
|
|
78
|
+
this._notebookEditorService.onDidAddNotebookEditor(this._handleEditorAdd, this, this._disposables);
|
|
79
|
+
this._notebookEditorService.onDidRemoveNotebookEditor(this._handleEditorRemove, this, this._disposables);
|
|
80
|
+
this._updateState();
|
|
81
|
+
}
|
|
82
|
+
dispose() {
|
|
83
|
+
this._mainThreadNotebooks.dispose();
|
|
84
|
+
this._mainThreadEditors.dispose();
|
|
85
|
+
this._disposables.dispose();
|
|
86
|
+
this._editorListeners.dispose();
|
|
87
|
+
}
|
|
88
|
+
_handleEditorAdd(editor) {
|
|
89
|
+
this._editorListeners.set(editor.getId(), combinedDisposable(
|
|
90
|
+
editor.onDidChangeModel(() => this._updateState()),
|
|
91
|
+
editor.onDidFocusWidget(() => this._updateState(editor))
|
|
92
|
+
));
|
|
93
|
+
this._updateState();
|
|
94
|
+
}
|
|
95
|
+
_handleEditorRemove(editor) {
|
|
96
|
+
this._editorListeners.deleteAndDispose(editor.getId());
|
|
97
|
+
this._updateState();
|
|
98
|
+
}
|
|
99
|
+
_updateState(focusedEditor) {
|
|
100
|
+
const editors = ( new Map());
|
|
101
|
+
const visibleEditorsMap = ( new Map());
|
|
102
|
+
for (const editor of this._notebookEditorService.listNotebookEditors()) {
|
|
103
|
+
if (editor.hasModel()) {
|
|
104
|
+
editors.set(editor.getId(), editor);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const activeNotebookEditor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
|
|
108
|
+
let activeEditor = null;
|
|
109
|
+
if (activeNotebookEditor) {
|
|
110
|
+
activeEditor = activeNotebookEditor.getId();
|
|
111
|
+
} else if (focusedEditor?.textModel) {
|
|
112
|
+
activeEditor = focusedEditor.getId();
|
|
113
|
+
}
|
|
114
|
+
if (activeEditor && !( editors.has(activeEditor))) {
|
|
115
|
+
this._logService.trace(
|
|
116
|
+
"MainThreadNotebooksAndEditors#_updateState: active editor is not in editors list",
|
|
117
|
+
activeEditor,
|
|
118
|
+
( editors.keys())
|
|
119
|
+
);
|
|
120
|
+
activeEditor = null;
|
|
121
|
+
}
|
|
122
|
+
for (const editorPane of this._editorService.visibleEditorPanes) {
|
|
123
|
+
const notebookEditor = getNotebookEditorFromEditorPane(editorPane);
|
|
124
|
+
if (notebookEditor?.hasModel() && ( editors.has(notebookEditor.getId()))) {
|
|
125
|
+
visibleEditorsMap.set(notebookEditor.getId(), notebookEditor);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const newState = ( new NotebookAndEditorState(( new Set(this._notebookService.listNotebookDocuments())), editors, activeEditor, visibleEditorsMap));
|
|
129
|
+
this._onDelta(NotebookAndEditorState.delta(this._currentState, newState));
|
|
130
|
+
this._currentState = newState;
|
|
131
|
+
}
|
|
132
|
+
_onDelta(delta) {
|
|
133
|
+
if (MainThreadNotebooksAndEditors_1._isDeltaEmpty(delta)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const dto = {
|
|
137
|
+
removedDocuments: delta.removedDocuments,
|
|
138
|
+
removedEditors: delta.removedEditors,
|
|
139
|
+
newActiveEditor: delta.newActiveEditor,
|
|
140
|
+
visibleEditors: delta.visibleEditors,
|
|
141
|
+
addedDocuments: ( delta.addedDocuments.map(MainThreadNotebooksAndEditors_1._asModelAddData)),
|
|
142
|
+
addedEditors: ( delta.addedEditors.map(this._asEditorAddData, this))
|
|
143
|
+
};
|
|
144
|
+
this._proxy.$acceptDocumentAndEditorsDelta(( new SerializableObjectWithBuffers(dto)));
|
|
145
|
+
this._mainThreadEditors.handleEditorsRemoved(delta.removedEditors);
|
|
146
|
+
this._mainThreadNotebooks.handleNotebooksRemoved(delta.removedDocuments);
|
|
147
|
+
this._mainThreadNotebooks.handleNotebooksAdded(delta.addedDocuments);
|
|
148
|
+
this._mainThreadEditors.handleEditorsAdded(delta.addedEditors);
|
|
149
|
+
}
|
|
150
|
+
static _isDeltaEmpty(delta) {
|
|
151
|
+
if (delta.addedDocuments !== undefined && delta.addedDocuments.length > 0) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (delta.removedDocuments !== undefined && delta.removedDocuments.length > 0) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (delta.addedEditors !== undefined && delta.addedEditors.length > 0) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
if (delta.removedEditors !== undefined && delta.removedEditors.length > 0) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if (delta.visibleEditors !== undefined && delta.visibleEditors.length > 0) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
if (delta.newActiveEditor !== undefined) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
static _asModelAddData(e) {
|
|
172
|
+
return {
|
|
173
|
+
viewType: e.viewType,
|
|
174
|
+
uri: e.uri,
|
|
175
|
+
metadata: e.metadata,
|
|
176
|
+
versionId: e.versionId,
|
|
177
|
+
cells: ( e.cells.map(NotebookDto.toNotebookCellDto))
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
_asEditorAddData(add) {
|
|
181
|
+
const pane = this._editorService.visibleEditorPanes.find(pane => getNotebookEditorFromEditorPane(pane) === add);
|
|
182
|
+
return {
|
|
183
|
+
id: add.getId(),
|
|
184
|
+
documentUri: add.textModel.uri,
|
|
185
|
+
selections: add.getSelections(),
|
|
186
|
+
visibleRanges: add.visibleRanges,
|
|
187
|
+
viewColumn: pane && editorGroupToColumn(this._editorGroupService, pane.group),
|
|
188
|
+
viewType: add.getViewModel().viewType
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
MainThreadNotebooksAndEditors = MainThreadNotebooksAndEditors_1 = __decorate([extHostCustomer, ( __param(1, IInstantiationService)), ( __param(2, INotebookService)), ( __param(3, INotebookEditorService)), ( __param(4, IEditorService)), ( __param(5, IEditorGroupsService)), ( __param(6, ILogService))], MainThreadNotebooksAndEditors);
|
|
193
|
+
|
|
194
|
+
export { MainThreadNotebooksAndEditors };
|