@codingame/monaco-vscode-notebook-service-override 37.1.0 → 37.3.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 (81) hide show
  1. package/index.js +7 -2
  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 +140 -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/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +9 -9
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +24 -24
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +4 -4
  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 +5 -5
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +3 -3
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +19 -19
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +7 -7
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +9 -9
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +6 -6
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +9 -9
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.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/multicursor/notebookMulticursor.js +32 -19
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +2 -2
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +13 -13
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +4 -4
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +1 -1
  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/notebookVariables/notebookVariablesDataSource.js +1 -1
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +3 -3
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +14 -14
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +1 -1
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +30 -30
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +5 -5
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +11 -14
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +38 -38
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +30 -26
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +21 -21
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +11 -11
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +12 -12
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +1 -1
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +24 -24
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.d.ts +1 -1
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.js +7 -7
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditorInput.d.ts +1 -1
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +68 -68
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +10 -10
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +35 -35
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.js +4 -4
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditorInput.js +1 -1
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/replEditorAccessibleView.js +1 -1
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +2 -2
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +1 -1
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +8 -5
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +4 -4
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +2 -2
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +7 -7
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +15 -12
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +1 -1
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +1 -1
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +9 -9
  69. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +8 -8
  70. package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +1 -1
  71. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +26 -26
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.d.ts +87 -0
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +352 -0
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +1 -1
  75. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +3 -3
  76. package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWebWorker.js +44 -18
  77. package/vscode/src/vs/workbench/contrib/replNotebook/browser/repl.contribution.js +5 -5
  78. package/vscode/src/vs/workbench/contrib/replNotebook/browser/replEditorAccessibilityHelp.js +14 -14
  79. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +2 -2
  80. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +12 -12
  81. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +5 -5
@@ -0,0 +1,352 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { streamToBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
4
+ import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
5
+ import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
6
+ import { DisposableStore, Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
7
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
8
+ import { hasKey, assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
9
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
10
+ import { FileOperationError, FileOperationResult } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
11
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
12
+ import { EditorModel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/editorModel';
13
+ import { NotebookCellsChangeType, NotebookSetting } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
14
+ import { INotebookLoggingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookLoggingService.service';
15
+ import { SimpleNotebookProviderInfo } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService';
16
+ import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
17
+ import { IFilesConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service';
18
+ import { StoredFileWorkingCopyState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
19
+ import { WorkingCopyCapabilities } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopy';
20
+
21
+ var SimpleNotebookEditorModel_1;
22
+ let SimpleNotebookEditorModel = SimpleNotebookEditorModel_1 = class SimpleNotebookEditorModel extends EditorModel {
23
+ constructor(
24
+ resource,
25
+ _hasAssociatedFilePath,
26
+ viewType,
27
+ _workingCopyManager,
28
+ scratchpad,
29
+ _filesConfigurationService
30
+ ) {
31
+ super();
32
+ this.resource = resource;
33
+ this._hasAssociatedFilePath = _hasAssociatedFilePath;
34
+ this.viewType = viewType;
35
+ this._workingCopyManager = _workingCopyManager;
36
+ this._filesConfigurationService = _filesConfigurationService;
37
+ this._onDidChangeDirty = this._register(( new Emitter()));
38
+ this._onDidSave = this._register(( new Emitter()));
39
+ this._onDidChangeOrphaned = this._register(( new Emitter()));
40
+ this._onDidChangeReadonly = this._register(( new Emitter()));
41
+ this._onDidRevertUntitled = this._register(( new Emitter()));
42
+ this.onDidChangeDirty = this._onDidChangeDirty.event;
43
+ this.onDidSave = this._onDidSave.event;
44
+ this.onDidChangeOrphaned = this._onDidChangeOrphaned.event;
45
+ this.onDidChangeReadonly = this._onDidChangeReadonly.event;
46
+ this.onDidRevertUntitled = this._onDidRevertUntitled.event;
47
+ this._workingCopyListeners = this._register(( new DisposableStore()));
48
+ this.scratchPad = scratchpad;
49
+ }
50
+ dispose() {
51
+ this._workingCopy?.dispose();
52
+ super.dispose();
53
+ }
54
+ get notebook() {
55
+ return this._workingCopy?.model?.notebookModel;
56
+ }
57
+ isResolved() {
58
+ return Boolean(this._workingCopy?.model?.notebookModel);
59
+ }
60
+ async canDispose() {
61
+ if (!this._workingCopy) {
62
+ return true;
63
+ }
64
+ if (SimpleNotebookEditorModel_1._isStoredFileWorkingCopy(this._workingCopy)) {
65
+ return this._workingCopyManager.stored.canDispose(this._workingCopy);
66
+ } else {
67
+ return true;
68
+ }
69
+ }
70
+ isDirty() {
71
+ return this._workingCopy?.isDirty() ?? false;
72
+ }
73
+ isModified() {
74
+ return this._workingCopy?.isModified() ?? false;
75
+ }
76
+ isOrphaned() {
77
+ return SimpleNotebookEditorModel_1._isStoredFileWorkingCopy(this._workingCopy) && this._workingCopy.hasState(StoredFileWorkingCopyState.ORPHAN);
78
+ }
79
+ hasAssociatedFilePath() {
80
+ return !SimpleNotebookEditorModel_1._isStoredFileWorkingCopy(this._workingCopy) && !!this._workingCopy?.hasAssociatedFilePath;
81
+ }
82
+ isReadonly() {
83
+ if (SimpleNotebookEditorModel_1._isStoredFileWorkingCopy(this._workingCopy)) {
84
+ return this._workingCopy?.isReadonly();
85
+ } else {
86
+ return this._filesConfigurationService.isReadonly(this.resource);
87
+ }
88
+ }
89
+ get hasErrorState() {
90
+ if (this._workingCopy && hasKey(this._workingCopy, {
91
+ hasState: true
92
+ })) {
93
+ return this._workingCopy.hasState(StoredFileWorkingCopyState.ERROR);
94
+ }
95
+ return false;
96
+ }
97
+ async revert(options) {
98
+ assertType(this.isResolved());
99
+ return this._workingCopy.revert(options);
100
+ }
101
+ async save(options) {
102
+ assertType(this.isResolved());
103
+ return this._workingCopy.save(options);
104
+ }
105
+ async load(options) {
106
+ if (!this._workingCopy || !this._workingCopy.model) {
107
+ if (this.resource.scheme === Schemas.untitled) {
108
+ if (this._hasAssociatedFilePath) {
109
+ this._workingCopy = await this._workingCopyManager.resolve({
110
+ associatedResource: this.resource
111
+ });
112
+ } else {
113
+ this._workingCopy = await this._workingCopyManager.resolve({
114
+ untitledResource: this.resource,
115
+ isScratchpad: this.scratchPad
116
+ });
117
+ }
118
+ this._register(this._workingCopy.onDidRevert(() => this._onDidRevertUntitled.fire()));
119
+ } else {
120
+ this._workingCopy = await this._workingCopyManager.resolve(this.resource, {
121
+ limits: options?.limits,
122
+ reload: options?.forceReadFromFile ? {
123
+ async: false,
124
+ force: true
125
+ } : undefined
126
+ });
127
+ this._workingCopyListeners.add(this._workingCopy.onDidSave(e => this._onDidSave.fire(e)));
128
+ this._workingCopyListeners.add(
129
+ this._workingCopy.onDidChangeOrphaned(() => this._onDidChangeOrphaned.fire())
130
+ );
131
+ this._workingCopyListeners.add(
132
+ this._workingCopy.onDidChangeReadonly(() => this._onDidChangeReadonly.fire())
133
+ );
134
+ }
135
+ this._workingCopyListeners.add(
136
+ this._workingCopy.onDidChangeDirty(() => this._onDidChangeDirty.fire(), undefined)
137
+ );
138
+ this._workingCopyListeners.add(this._workingCopy.onWillDispose(() => {
139
+ this._workingCopyListeners.clear();
140
+ this._workingCopy?.model?.dispose();
141
+ }));
142
+ } else {
143
+ await this._workingCopyManager.resolve(this.resource, {
144
+ reload: {
145
+ async: !options?.forceReadFromFile,
146
+ force: options?.forceReadFromFile
147
+ },
148
+ limits: options?.limits
149
+ });
150
+ }
151
+ assertType(this.isResolved());
152
+ return this;
153
+ }
154
+ async saveAs(target) {
155
+ const newWorkingCopy = await this._workingCopyManager.saveAs(this.resource, target);
156
+ if (!newWorkingCopy) {
157
+ return undefined;
158
+ }
159
+ return {
160
+ resource: newWorkingCopy.resource
161
+ };
162
+ }
163
+ static _isStoredFileWorkingCopy(candidate) {
164
+ const isUntitled = candidate && candidate.capabilities & WorkingCopyCapabilities.Untitled;
165
+ return !isUntitled;
166
+ }
167
+ };
168
+ SimpleNotebookEditorModel = SimpleNotebookEditorModel_1 = ( __decorate([( __param(5, IFilesConfigurationService))], SimpleNotebookEditorModel));
169
+ class NotebookFileWorkingCopyModel extends Disposable {
170
+ constructor(
171
+ _notebookModel,
172
+ _notebookService,
173
+ _configurationService,
174
+ _telemetryService,
175
+ _notebookLogService
176
+ ) {
177
+ super();
178
+ this._notebookModel = _notebookModel;
179
+ this._notebookService = _notebookService;
180
+ this._configurationService = _configurationService;
181
+ this._telemetryService = _telemetryService;
182
+ this._notebookLogService = _notebookLogService;
183
+ this._onDidChangeContent = this._register(( new Emitter()));
184
+ this.onDidChangeContent = this._onDidChangeContent.event;
185
+ this.configuration = undefined;
186
+ this.onWillDispose = _notebookModel.onWillDispose.bind(_notebookModel);
187
+ this._register(_notebookModel.onDidChangeContent(e => {
188
+ for (const rawEvent of e.rawEvents) {
189
+ if (rawEvent.kind === NotebookCellsChangeType.Initialize) {
190
+ continue;
191
+ }
192
+ if (rawEvent.transient) {
193
+ continue;
194
+ }
195
+ this._onDidChangeContent.fire({
196
+ isRedoing: false,
197
+ isUndoing: false,
198
+ isInitial: false
199
+ });
200
+ break;
201
+ }
202
+ }));
203
+ const saveWithReducedCommunication = this._configurationService.getValue(NotebookSetting.remoteSaving);
204
+ if (saveWithReducedCommunication || _notebookModel.uri.scheme === Schemas.vscodeRemote) {
205
+ this.configuration = {
206
+ backupDelay: 10000
207
+ };
208
+ }
209
+ if (saveWithReducedCommunication) {
210
+ this.setSaveDelegate().catch(
211
+ error => this._notebookLogService.error("WorkingCopyModel", `Failed to set save delegate: ${error}`)
212
+ );
213
+ }
214
+ }
215
+ async setSaveDelegate() {
216
+ await this.getNotebookSerializer();
217
+ this.save = async (options, token) => {
218
+ try {
219
+ let serializer = this._notebookService.tryGetDataProviderSync(this.notebookModel.viewType)?.serializer;
220
+ if (!serializer) {
221
+ this._notebookLogService.info(
222
+ "WorkingCopyModel",
223
+ "No serializer found for notebook model, checking if provider still needs to be resolved"
224
+ );
225
+ serializer = await this.getNotebookSerializer().catch(error => {
226
+ this._notebookLogService.error("WorkingCopyModel", `Failed to get notebook serializer: ${error}`);
227
+ this.save = undefined;
228
+ throw ( new NotebookSaveError("Failed to get notebook serializer"));
229
+ });
230
+ }
231
+ if (token.isCancellationRequested) {
232
+ throw ( new CancellationError());
233
+ }
234
+ const stat = await serializer.save(this._notebookModel.uri, this._notebookModel.versionId, options, token);
235
+ return stat;
236
+ } catch (error) {
237
+ if (!token.isCancellationRequested && error.name !== "Canceled") {
238
+ const isIPynb = this._notebookModel.viewType === "jupyter-notebook" || this._notebookModel.viewType === "interactive";
239
+ const errorMessage = getSaveErrorMessage(error);
240
+ this._telemetryService.publicLogError2("notebook/SaveError", {
241
+ isRemote: this._notebookModel.uri.scheme === Schemas.vscodeRemote,
242
+ isIPyNbWorkerSerializer: isIPynb && this._configurationService.getValue("ipynb.experimental.serialization"),
243
+ error: errorMessage
244
+ });
245
+ }
246
+ throw error;
247
+ }
248
+ };
249
+ }
250
+ dispose() {
251
+ this._notebookModel.dispose();
252
+ super.dispose();
253
+ }
254
+ get notebookModel() {
255
+ return this._notebookModel;
256
+ }
257
+ async snapshot(context, token) {
258
+ return this._notebookService.createNotebookTextDocumentSnapshot(this._notebookModel.uri, context, token);
259
+ }
260
+ async update(stream, token) {
261
+ const serializer = await this.getNotebookSerializer();
262
+ const bytes = await streamToBuffer(stream);
263
+ const data = await serializer.dataToNotebook(bytes);
264
+ if (token.isCancellationRequested) {
265
+ throw ( new CancellationError());
266
+ }
267
+ this._notebookLogService.info(
268
+ "WorkingCopyModel",
269
+ "Notebook content updated from file system - " + ( this._notebookModel.uri.toString())
270
+ );
271
+ this._notebookModel.reset(data.cells, data.metadata, serializer.options);
272
+ }
273
+ async getNotebookSerializer() {
274
+ const info = await this._notebookService.withNotebookDataProvider(this.notebookModel.viewType);
275
+ if (!(info instanceof SimpleNotebookProviderInfo)) {
276
+ const message = "CANNOT open notebook with this provider";
277
+ throw ( new NotebookSaveError(message));
278
+ }
279
+ return info.serializer;
280
+ }
281
+ get versionId() {
282
+ return this._notebookModel.alternativeVersionId;
283
+ }
284
+ pushStackElement() {
285
+ this._notebookModel.pushStackElement();
286
+ }
287
+ }
288
+ let NotebookFileWorkingCopyModelFactory = class NotebookFileWorkingCopyModelFactory {
289
+ constructor(
290
+ _viewType,
291
+ _notebookService,
292
+ _configurationService,
293
+ _telemetryService,
294
+ _notebookLogService
295
+ ) {
296
+ this._viewType = _viewType;
297
+ this._notebookService = _notebookService;
298
+ this._configurationService = _configurationService;
299
+ this._telemetryService = _telemetryService;
300
+ this._notebookLogService = _notebookLogService;
301
+ }
302
+ async createModel(resource, stream, token) {
303
+ const notebookModel = this._notebookService.getNotebookTextModel(resource) ?? (await this._notebookService.createNotebookTextModel(this._viewType, resource, stream));
304
+ return ( new NotebookFileWorkingCopyModel(
305
+ notebookModel,
306
+ this._notebookService,
307
+ this._configurationService,
308
+ this._telemetryService,
309
+ this._notebookLogService
310
+ ));
311
+ }
312
+ };
313
+ NotebookFileWorkingCopyModelFactory = ( __decorate([( __param(1, INotebookService)), ( __param(2, IConfigurationService)), ( __param(3, ITelemetryService)), ( __param(4, INotebookLoggingService))], NotebookFileWorkingCopyModelFactory));
314
+ class NotebookSaveError extends Error {
315
+ constructor(message) {
316
+ super(message);
317
+ this.name = "NotebookSaveError";
318
+ }
319
+ }
320
+ function getSaveErrorMessage(error) {
321
+ if (error.name === "NotebookSaveError") {
322
+ return error.message;
323
+ } else if (error instanceof FileOperationError) {
324
+ switch (error.fileOperationResult) {
325
+ case FileOperationResult.FILE_IS_DIRECTORY:
326
+ return "File is a directory";
327
+ case FileOperationResult.FILE_NOT_FOUND:
328
+ return "File not found";
329
+ case FileOperationResult.FILE_NOT_MODIFIED_SINCE:
330
+ return "File not modified since";
331
+ case FileOperationResult.FILE_MODIFIED_SINCE:
332
+ return "File modified since";
333
+ case FileOperationResult.FILE_MOVE_CONFLICT:
334
+ return "File move conflict";
335
+ case FileOperationResult.FILE_WRITE_LOCKED:
336
+ return "File write locked";
337
+ case FileOperationResult.FILE_PERMISSION_DENIED:
338
+ return "File permission denied";
339
+ case FileOperationResult.FILE_TOO_LARGE:
340
+ return "File too large";
341
+ case FileOperationResult.FILE_INVALID_PATH:
342
+ return "File invalid path";
343
+ case FileOperationResult.FILE_NOT_DIRECTORY:
344
+ return "File not directory";
345
+ case FileOperationResult.FILE_OTHER_ERROR:
346
+ return "File other error";
347
+ }
348
+ }
349
+ return "Unknown error";
350
+ }
351
+
352
+ export { NotebookFileWorkingCopyModel, NotebookFileWorkingCopyModelFactory, SimpleNotebookEditorModel };
@@ -3,7 +3,7 @@ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib
3
3
  import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
4
4
  import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
5
5
  import { NotebookWorkingCopyTypeIdentifier, NotebookSetting, CellUri } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
6
- import { NotebookFileWorkingCopyModelFactory, SimpleNotebookEditorModel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookEditorModel';
6
+ import { NotebookFileWorkingCopyModelFactory, SimpleNotebookEditorModel } from './notebookEditorModel.js';
7
7
  import { ReferenceCollection, DisposableStore, dispose, combinedDisposable, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
8
8
  import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
9
9
  import { Emitter, AsyncEmitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
@@ -32,9 +32,9 @@ class NotebookOutputRendererInfo {
32
32
  }
33
33
  this.displayName = descriptor.displayName;
34
34
  this.mimeTypes = descriptor.mimeTypes;
35
- this.mimeTypeGlobs = ( this.mimeTypes.map(pattern => parse(pattern, {
35
+ this.mimeTypeGlobs = this.mimeTypes.map(pattern => parse(pattern, {
36
36
  ignoreCase: true
37
- })));
37
+ }));
38
38
  this.hardDependencies = ( new DependencyList(descriptor.dependencies ?? Iterable.empty()));
39
39
  this.optionalDependencies = ( new DependencyList(descriptor.optionalDependencies ?? Iterable.empty()));
40
40
  this.messaging = descriptor.requiresMessaging ?? RendererMessagingSpec.Never;
@@ -72,7 +72,7 @@ class NotebookStaticPreloadInfo {
72
72
  this.type = descriptor.type;
73
73
  this.entrypoint = joinPath(descriptor.extension.extensionLocation, descriptor.entrypoint);
74
74
  this.extensionLocation = descriptor.extension.extensionLocation;
75
- this.localResourceRoots = ( descriptor.localResourceRoots.map(root => joinPath(descriptor.extension.extensionLocation, root)));
75
+ this.localResourceRoots = descriptor.localResourceRoots.map(root => joinPath(descriptor.extension.extensionLocation, root));
76
76
  }
77
77
  }
78
78
 
@@ -10,9 +10,9 @@ import { MirrorModel } from '@codingame/monaco-vscode-api/vscode/vs/editor/commo
10
10
  import { DefaultEndOfLine } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
11
11
  import { filter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
12
12
  import { matchCellBasedOnSimilarties } from './notebookCellMatching.js';
13
- import '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
13
+ import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
14
14
  import { DiffChange } from '@codingame/monaco-vscode-api/vscode/vs/base/common/diff/diffChange';
15
- import { computeDiff } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/notebook/common/notebookDiff';
15
+ import { computeDiff } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookDiff';
16
16
 
17
17
  const PREFIX_FOR_UNMATCHED_ORIGINAL_CELLS = `unmatchedOriginalCell`;
18
18
  class MirrorCell {
@@ -65,7 +65,7 @@ class MirrorCell {
65
65
  hashValue = doHash(output.mime, hashValue);
66
66
  }
67
67
  }
68
- const digests = this.outputs.flatMap(op => ( op.outputs.map(o => hash(Array.from(o.data.buffer)))));
68
+ const digests = this.outputs.flatMap(op => op.outputs.map(o => hash(Array.from(o.data.buffer))));
69
69
  for (const digest of digests) {
70
70
  hashValue = numberHash(digest, hashValue);
71
71
  }
@@ -114,26 +114,26 @@ class MirrorNotebookDocument {
114
114
  _spliceNotebookCells(splices) {
115
115
  splices.reverse().forEach(splice => {
116
116
  const cellDtos = splice[2];
117
- const newCells = ( cellDtos.map(cell => {
117
+ const newCells = cellDtos.map(cell => {
118
118
  return ( new MirrorCell(cell.handle, ( URI.parse(cell.url)), cell.source, cell.eol, cell.versionId, cell.language, cell.cellKind, cell.outputs, cell.metadata));
119
- }));
119
+ });
120
120
  this.cells.splice(splice[0], splice[1], ...newCells);
121
121
  });
122
122
  }
123
123
  }
124
124
  class CellSequence {
125
125
  static create(textModel) {
126
- const hashValue = ( textModel.cells.map(c => c.getComparisonValue()));
126
+ const hashValue = textModel.cells.map(c => c.getComparisonValue());
127
127
  return ( new CellSequence(hashValue));
128
128
  }
129
129
  static createWithCellId(cells, includeCellContents) {
130
- const hashValue = ( cells.map(c => {
130
+ const hashValue = cells.map(c => {
131
131
  if (includeCellContents) {
132
132
  return `${doHash(c.internalMetadata?.internalId, numberHash(104579, 0))}#${c.getComparisonValue()}`;
133
133
  } else {
134
134
  return `${doHash(c.internalMetadata?.internalId, numberHash(104579, 0))}}`;
135
135
  }
136
- }));
136
+ });
137
137
  return ( new CellSequence(hashValue));
138
138
  }
139
139
  constructor(hashValue) {
@@ -150,7 +150,7 @@ class NotebookWorker {
150
150
  }
151
151
  dispose() {}
152
152
  $acceptNewModel(uri, metadata, transientDocumentMetadata, cells) {
153
- this._models[uri] = ( new MirrorNotebookDocument(( URI.parse(uri)), ( cells.map(dto => ( new MirrorCell(dto.handle, ( URI.parse(dto.url)), dto.source, dto.eol, dto.versionId, dto.language, dto.cellKind, dto.outputs, dto.metadata, dto.internalMetadata)))), metadata, transientDocumentMetadata));
153
+ this._models[uri] = ( new MirrorNotebookDocument(( URI.parse(uri)), cells.map(dto => ( new MirrorCell(dto.handle, ( URI.parse(dto.url)), dto.source, dto.eol, dto.versionId, dto.language, dto.cellKind, dto.outputs, dto.metadata, dto.internalMetadata))), metadata, transientDocumentMetadata));
154
154
  }
155
155
  $acceptModelChanged(strURL, event) {
156
156
  const model = this._models[strURL];
@@ -286,40 +286,66 @@ class NotebookWorker {
286
286
  return this.canComputeDiffWithCellInternalIds(original, modified) || this.canComputeDiffWithCellMetadataIds(original, modified);
287
287
  }
288
288
  canComputeDiffWithCellInternalIds(original, modified) {
289
- const originalCellIndexIds = ( original.cells.map((cell, index) => ({
289
+ const originalCellIndexIds = original.cells.map((cell, index) => ({
290
290
  index,
291
291
  id: (cell.internalMetadata?.internalId || "")
292
- })));
293
- const modifiedCellIndexIds = ( modified.cells.map((cell, index) => ({
292
+ }));
293
+ const modifiedCellIndexIds = modified.cells.map((cell, index) => ({
294
294
  index,
295
295
  id: (cell.internalMetadata?.internalId || "")
296
- })));
296
+ }));
297
297
  if (( originalCellIndexIds.some(c => !c.id)) || ( modifiedCellIndexIds.some(c => !c.id))) {
298
298
  return false;
299
299
  }
300
300
  return ( originalCellIndexIds.some(c => modifiedCellIndexIds.find(m => m.id === c.id)));
301
301
  }
302
302
  canComputeDiffWithCellMetadataIds(original, modified) {
303
- const originalCellIndexIds = ( original.cells.map((cell, index) => ({
303
+ const originalCellIndexIds = original.cells.map((cell, index) => ({
304
304
  index,
305
305
  id: (cell.metadata?.id || "")
306
- })));
307
- const modifiedCellIndexIds = ( modified.cells.map((cell, index) => ({
306
+ }));
307
+ const modifiedCellIndexIds = modified.cells.map((cell, index) => ({
308
308
  index,
309
309
  id: (cell.metadata?.id || "")
310
- })));
310
+ }));
311
311
  if (( originalCellIndexIds.some(c => !c.id)) || ( modifiedCellIndexIds.some(c => !c.id))) {
312
312
  return false;
313
313
  }
314
314
  if (originalCellIndexIds.every(c => !modifiedCellIndexIds.find(m => m.id === c.id))) {
315
315
  return false;
316
316
  }
317
+ original.cells.map((cell, index) => {
318
+ cell.internalMetadata = cell.internalMetadata || {};
319
+ cell.internalMetadata.internalId = cell.metadata?.id || "";
320
+ });
321
+ modified.cells.map((cell, index) => {
322
+ cell.internalMetadata = cell.internalMetadata || {};
323
+ cell.internalMetadata.internalId = cell.metadata?.id || "";
324
+ });
317
325
  return true;
318
326
  }
319
327
  isOriginalCellMatchedWithModifiedCell(originalCell) {
320
328
  return (originalCell.internalMetadata?.internalId || "").startsWith(PREFIX_FOR_UNMATCHED_ORIGINAL_CELLS);
321
329
  }
322
330
  updateCellIdsBasedOnMappings(mappings, originalCells, modifiedCells) {
331
+ const uuids = ( new Map());
332
+ originalCells.map((cell, index) => {
333
+ cell.internalMetadata = cell.internalMetadata || {
334
+ internalId: ""
335
+ };
336
+ cell.internalMetadata.internalId = `${PREFIX_FOR_UNMATCHED_ORIGINAL_CELLS}${generateUuid()}`;
337
+ const found = mappings.find(r => r.original === index);
338
+ if (found) {
339
+ cell.internalMetadata.internalId = generateUuid();
340
+ uuids.set(found.modified, cell.internalMetadata.internalId);
341
+ }
342
+ });
343
+ modifiedCells.map((cell, index) => {
344
+ cell.internalMetadata = cell.internalMetadata || {
345
+ internalId: ""
346
+ };
347
+ cell.internalMetadata.internalId = uuids.get(index) ?? generateUuid();
348
+ });
323
349
  return true;
324
350
  }
325
351
  $canPromptRecommendation(modelUrl) {
@@ -362,7 +388,7 @@ function create() {
362
388
  class NotebookTextModelFacade {
363
389
  constructor(notebook) {
364
390
  this.notebook = notebook;
365
- this.cells = ( notebook.cells.map(cell => ( new NotebookCellTextModelFacade(cell))));
391
+ this.cells = notebook.cells.map(cell => ( new NotebookCellTextModelFacade(cell)));
366
392
  }
367
393
  }
368
394
  class NotebookCellTextModelFacade {
@@ -43,9 +43,9 @@ import { REPL_EDITOR_ID, NotebookSetting, NotebookWorkingCopyTypeIdentifier, Cel
43
43
  import { MOST_RECENT_REPL_EDITOR, IS_COMPOSITE_NOTEBOOK, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_EDITOR_FOCUSED } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
44
44
  import { INotebookEditorModelResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.service';
45
45
  import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
46
- import { ReplEditor, isReplEditorControl } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/replNotebook/browser/replEditor';
46
+ import { ReplEditor, isReplEditorControl } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/replNotebook/browser/replEditor';
47
47
  import { ReplEditorInputAccessibilityHelp, ReplEditorHistoryAccessibilityHelp } from './replEditorAccessibilityHelp.js';
48
- import { ReplEditorInput } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/replNotebook/browser/replEditorInput';
48
+ import { ReplEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/replNotebook/browser/replEditorInput';
49
49
 
50
50
  class ReplEditorSerializer {
51
51
  canSerialize(input) {
@@ -232,7 +232,7 @@ registerAction2(class extends Action2 {
232
232
  constructor() {
233
233
  super({
234
234
  id: "repl.focusLastItemExecuted",
235
- title: ( localize2(15602, "Focus Most Recent REPL Execution")),
235
+ title: ( localize2(17741, "Focus Most Recent REPL Execution")),
236
236
  category: "REPL",
237
237
  menu: {
238
238
  id: MenuId.CommandPalette,
@@ -282,7 +282,7 @@ registerAction2(class extends Action2 {
282
282
  constructor() {
283
283
  super({
284
284
  id: "repl.input.focus",
285
- title: ( localize2(15603, "Focus Input Editor")),
285
+ title: ( localize2(17742, "Focus Input Editor")),
286
286
  category: "REPL",
287
287
  menu: {
288
288
  id: MenuId.CommandPalette,
@@ -327,7 +327,7 @@ registerAction2(class extends Action2 {
327
327
  constructor() {
328
328
  super({
329
329
  id: "repl.execute",
330
- title: ( localize2(15604, "Execute REPL input")),
330
+ title: ( localize2(17743, "Execute REPL input")),
331
331
  category: "REPL",
332
332
  keybinding: [{
333
333
  when: ( ContextKeyExpr.and(IS_COMPOSITE_NOTEBOOK, ( ContextKeyExpr.equals("activeEditor", "workbench.editor.repl")), ( NOTEBOOK_CELL_LIST_FOCUSED.negate()))),
@@ -19,28 +19,28 @@ class ReplEditorInputAccessibilityHelp {
19
19
  }
20
20
  function getAccessibilityInputHelpText() {
21
21
  return [( localize(
22
- 15606,
22
+ 17745,
23
23
  "You are in a REPL Editor Input box which will accept code to be executed in the REPL."
24
24
  )), ( localize(
25
- 15607,
25
+ 17746,
26
26
  "The Execute command{0} will evaluate the expression in the input box.",
27
27
  "<keybinding:repl.execute>"
28
28
  )), ( localize(
29
- 15608,
29
+ 17747,
30
30
  "The setting `accessibility.replEditor.readLastExecutionOutput` controls if output will be automatically read when execution completes."
31
31
  )), ( localize(
32
- 15609,
32
+ 17748,
33
33
  "The setting `accessibility.replEditor.autoFocusReplExecution` controls if focus will automatically move to the REPL after executing code."
34
34
  )), ( localize(
35
- 15610,
35
+ 17749,
36
36
  "The Focus Last executed command{0} will move focus to the last executed item in the REPL history.",
37
37
  "<keybinding:repl.focusLastItemExecuted>"
38
38
  )), ( localize(
39
- 15611,
39
+ 17750,
40
40
  "When you run the Open Accessbility View command{0} from this input box, the output from the last execution will be shown in the accessibility view.",
41
41
  "<keybinding:editor.action.accessibleView>"
42
42
  )), ( localize(
43
- 15612,
43
+ 17751,
44
44
  "The Focus Input Editor command{0} will bring the focus back to this editor.",
45
45
  "<keybinding:repl.input.focus>"
46
46
  ))].join("\n");
@@ -58,30 +58,30 @@ class ReplEditorHistoryAccessibilityHelp {
58
58
  }
59
59
  function getAccessibilityHistoryHelpText() {
60
60
  return [( localize(
61
- 15613,
61
+ 17752,
62
62
  "You are in a REPL History which is a list of cells that have been executed in the REPL. Each cell has an input, an output, and the cell container."
63
63
  )), ( localize(
64
- 15614,
64
+ 17753,
65
65
  "The Edit Cell command{0} will move focus to the read-only editor for the input of the cell.",
66
66
  "<keybinding:notebook.cell.edit>"
67
67
  )), ( localize(
68
- 15615,
68
+ 17754,
69
69
  "The Quit Edit command{0} will move focus to the cell container, where the up and down arrows will also move focus between cells in the history.",
70
70
  "<keybinding:notebook.cell.quitEdit>"
71
71
  )), ( localize(
72
- 15616,
72
+ 17755,
73
73
  "Run the Open Accessbility View command{0} while navigating the history for an accessible view of the item's output.",
74
74
  "<keybinding:editor.action.accessibleView>"
75
75
  )), ( localize(
76
- 15617,
76
+ 17756,
77
77
  "The Focus Output command{0} will set focus on the output when focused on a previously executed item.",
78
78
  "<keybinding:notebook.cell.focusInOutput>"
79
79
  )), ( localize(
80
- 15618,
80
+ 17757,
81
81
  "The Focus Input Editor command{0} will move focus to the REPL input box.",
82
82
  "<keybinding:repl.input.focus>"
83
83
  )), ( localize(
84
- 15610,
84
+ 17749,
85
85
  "The Focus Last executed command{0} will move focus to the last executed item in the REPL history.",
86
86
  "<keybinding:repl.focusLastItemExecuted>"
87
87
  ))].join("\n");
@@ -54,11 +54,11 @@ let BaseFileWorkingCopyManager = class BaseFileWorkingCopyManager extends Dispos
54
54
  }
55
55
  async destroy() {
56
56
  try {
57
- await Promises.settled(( this.workingCopies.map(async workingCopy => {
57
+ await Promises.settled(this.workingCopies.map(async workingCopy => {
58
58
  if (workingCopy.isDirty()) {
59
59
  await this.saveWithFallback(workingCopy);
60
60
  }
61
- })));
61
+ }));
62
62
  } catch (error) {
63
63
  this.logService.error(error);
64
64
  }