@codingame/monaco-vscode-notebook-service-override 1.85.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  2. package/external/tslib/tslib.es6.js +11 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +1 -0
  5. package/notebook.d.ts +5 -0
  6. package/notebook.js +44 -0
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +32 -0
  9. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +6 -0
  10. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +387 -0
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +668 -0
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +109 -0
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +319 -0
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +58 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +173 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +485 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +106 -0
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +67 -0
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +165 -0
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +67 -0
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +238 -0
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +72 -0
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +6 -0
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +168 -0
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +317 -0
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +209 -0
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +87 -0
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +82 -0
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +67 -0
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +93 -0
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +383 -0
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +51 -0
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +46 -0
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +135 -0
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +383 -0
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +117 -0
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +511 -0
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +168 -0
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +57 -0
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +94 -0
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +51 -0
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +702 -0
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +268 -0
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +45 -0
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1297 -0
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +284 -0
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +563 -0
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +108 -0
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +39 -0
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +6 -0
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +313 -0
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +872 -0
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +13 -0
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +393 -0
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +175 -0
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +1121 -0
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +159 -0
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +339 -0
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +41 -0
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +182 -0
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +106 -0
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +509 -0
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +133 -0
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +342 -0
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +111 -0
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +28 -0
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +65 -0
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +666 -0
  69. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +200 -0
  70. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +80 -0
  71. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +1001 -0
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +103 -0
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +202 -0
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +80 -0
  75. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +98 -0
  76. package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +217 -0
  77. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +89 -0
  78. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +372 -0
  79. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopy.js +706 -0
  80. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +407 -0
  81. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +144 -0
  82. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +129 -0
  83. package/worker.js +1 -0
  84. package/workers/notebook.worker.js +9 -0
@@ -0,0 +1,407 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
3
+ import { DisposableStore, dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { Emitter, Event } from 'monaco-editor/esm/vs/base/common/event.js';
5
+ import { StoredFileWorkingCopy } from './storedFileWorkingCopy.js';
6
+ import { ResourceMap } from 'monaco-editor/esm/vs/base/common/map.js';
7
+ import { ResourceQueue, Promises } from 'monaco-editor/esm/vs/base/common/async.js';
8
+ import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
9
+ import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
10
+ import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
11
+ import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
12
+ import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
13
+ import { joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
14
+ import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService';
15
+ import { IUriIdentityService } from 'monaco-editor/esm/vs/platform/uriIdentity/common/uriIdentity.js';
16
+ import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
17
+ import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup';
18
+ import { BaseFileWorkingCopyManager } from './abstractFileWorkingCopyManager.js';
19
+ import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
20
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
21
+ import { IElevatedFileService } from 'vscode/vscode/vs/workbench/services/files/common/elevatedFileService';
22
+ import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
23
+ import { IWorkingCopyEditorService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyEditorService';
24
+ import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
25
+ import { isWeb } from 'monaco-editor/esm/vs/base/common/platform.js';
26
+ import { onUnexpectedError } from 'monaco-editor/esm/vs/base/common/errors.js';
27
+
28
+ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends BaseFileWorkingCopyManager {
29
+ constructor(workingCopyTypeId, modelFactory, fileService, lifecycleService, labelService, logService, workingCopyFileService, workingCopyBackupService, uriIdentityService, filesConfigurationService, workingCopyService, notificationService, workingCopyEditorService, editorService, elevatedFileService) {
30
+ super(fileService, logService, workingCopyBackupService);
31
+ this.workingCopyTypeId = workingCopyTypeId;
32
+ this.modelFactory = modelFactory;
33
+ this.lifecycleService = lifecycleService;
34
+ this.labelService = labelService;
35
+ this.workingCopyFileService = workingCopyFileService;
36
+ this.uriIdentityService = uriIdentityService;
37
+ this.filesConfigurationService = filesConfigurationService;
38
+ this.workingCopyService = workingCopyService;
39
+ this.notificationService = notificationService;
40
+ this.workingCopyEditorService = workingCopyEditorService;
41
+ this.editorService = editorService;
42
+ this.elevatedFileService = elevatedFileService;
43
+ this._onDidResolve = this._register(( new Emitter()));
44
+ this.onDidResolve = this._onDidResolve.event;
45
+ this._onDidChangeDirty = this._register(( new Emitter()));
46
+ this.onDidChangeDirty = this._onDidChangeDirty.event;
47
+ this._onDidChangeReadonly = this._register(( new Emitter()));
48
+ this.onDidChangeReadonly = this._onDidChangeReadonly.event;
49
+ this._onDidChangeOrphaned = this._register(( new Emitter()));
50
+ this.onDidChangeOrphaned = this._onDidChangeOrphaned.event;
51
+ this._onDidSaveError = this._register(( new Emitter()));
52
+ this.onDidSaveError = this._onDidSaveError.event;
53
+ this._onDidSave = this._register(( new Emitter()));
54
+ this.onDidSave = this._onDidSave.event;
55
+ this._onDidRevert = this._register(( new Emitter()));
56
+ this.onDidRevert = this._onDidRevert.event;
57
+ this._onDidRemove = this._register(( new Emitter()));
58
+ this.onDidRemove = this._onDidRemove.event;
59
+ this.mapResourceToWorkingCopyListeners = ( new ResourceMap());
60
+ this.mapResourceToPendingWorkingCopyResolve = ( new ResourceMap());
61
+ this.workingCopyResolveQueue = this._register(( new ResourceQueue()));
62
+ this.mapCorrelationIdToWorkingCopiesToRestore = ( new Map());
63
+ this.registerListeners();
64
+ }
65
+ registerListeners() {
66
+ this._register(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
67
+ this._register(this.fileService.onDidChangeFileSystemProviderCapabilities(e => this.onDidChangeFileSystemProviderCapabilities(e)));
68
+ this._register(this.fileService.onDidChangeFileSystemProviderRegistrations(e => this.onDidChangeFileSystemProviderRegistrations(e)));
69
+ this._register(this.workingCopyFileService.onWillRunWorkingCopyFileOperation(e => this.onWillRunWorkingCopyFileOperation(e)));
70
+ this._register(this.workingCopyFileService.onDidFailWorkingCopyFileOperation(e => this.onDidFailWorkingCopyFileOperation(e)));
71
+ this._register(this.workingCopyFileService.onDidRunWorkingCopyFileOperation(e => this.onDidRunWorkingCopyFileOperation(e)));
72
+ if (isWeb) {
73
+ this._register(this.lifecycleService.onBeforeShutdown(event => event.veto(this.onBeforeShutdownWeb(), 'veto.fileWorkingCopyManager')));
74
+ }
75
+ else {
76
+ this._register(this.lifecycleService.onWillShutdown(event => event.join(this.onWillShutdownDesktop(), { id: 'join.fileWorkingCopyManager', label: ( localizeWithPath(
77
+ 'vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager',
78
+ 'join.fileWorkingCopyManager',
79
+ "Saving working copies"
80
+ )) })));
81
+ }
82
+ }
83
+ onBeforeShutdownWeb() {
84
+ if (( this.workingCopies.some(
85
+ workingCopy => workingCopy.hasState(2 )
86
+ ))) {
87
+ return true;
88
+ }
89
+ return false;
90
+ }
91
+ async onWillShutdownDesktop() {
92
+ let pendingSavedWorkingCopies;
93
+ while ((pendingSavedWorkingCopies = this.workingCopies.filter(workingCopy => workingCopy.hasState(2 ))).length > 0) {
94
+ await Promises.settled(( pendingSavedWorkingCopies.map(
95
+ workingCopy => workingCopy.joinState(2 )
96
+ )));
97
+ }
98
+ }
99
+ onDidChangeFileSystemProviderCapabilities(e) {
100
+ this.queueWorkingCopyReloads(e.scheme);
101
+ }
102
+ onDidChangeFileSystemProviderRegistrations(e) {
103
+ if (!e.added) {
104
+ return;
105
+ }
106
+ this.queueWorkingCopyReloads(e.scheme);
107
+ }
108
+ onDidFilesChange(e) {
109
+ this.queueWorkingCopyReloads(e);
110
+ }
111
+ queueWorkingCopyReloads(schemeOrEvent) {
112
+ for (const workingCopy of this.workingCopies) {
113
+ if (workingCopy.isDirty()) {
114
+ continue;
115
+ }
116
+ let resolveWorkingCopy = false;
117
+ if (typeof schemeOrEvent === 'string') {
118
+ resolveWorkingCopy = schemeOrEvent === workingCopy.resource.scheme;
119
+ }
120
+ else {
121
+ resolveWorkingCopy = schemeOrEvent.contains(workingCopy.resource, 0 , 1 );
122
+ }
123
+ if (resolveWorkingCopy) {
124
+ this.queueWorkingCopyReload(workingCopy);
125
+ }
126
+ }
127
+ }
128
+ queueWorkingCopyReload(workingCopy) {
129
+ const queue = this.workingCopyResolveQueue.queueFor(workingCopy.resource);
130
+ if (queue.size <= 1) {
131
+ queue.queue(async () => {
132
+ try {
133
+ await this.reload(workingCopy);
134
+ }
135
+ catch (error) {
136
+ this.logService.error(error);
137
+ }
138
+ });
139
+ }
140
+ }
141
+ onWillRunWorkingCopyFileOperation(e) {
142
+ if (e.operation === 2 || e.operation === 3 ) {
143
+ e.waitUntil((async () => {
144
+ const workingCopiesToRestore = [];
145
+ for (const { source, target } of e.files) {
146
+ if (source) {
147
+ if (this.uriIdentityService.extUri.isEqual(source, target)) {
148
+ continue;
149
+ }
150
+ const sourceWorkingCopies = [];
151
+ for (const workingCopy of this.workingCopies) {
152
+ if (this.uriIdentityService.extUri.isEqualOrParent(workingCopy.resource, source)) {
153
+ sourceWorkingCopies.push(workingCopy);
154
+ }
155
+ }
156
+ for (const sourceWorkingCopy of sourceWorkingCopies) {
157
+ const sourceResource = sourceWorkingCopy.resource;
158
+ let targetResource;
159
+ if (this.uriIdentityService.extUri.isEqual(sourceResource, source)) {
160
+ targetResource = target;
161
+ }
162
+ else {
163
+ targetResource = joinPath(target, sourceResource.path.substr(source.path.length + 1));
164
+ }
165
+ workingCopiesToRestore.push({
166
+ source: sourceResource,
167
+ target: targetResource,
168
+ snapshot: sourceWorkingCopy.isDirty() ? await sourceWorkingCopy.model?.snapshot(CancellationToken.None) : undefined
169
+ });
170
+ }
171
+ }
172
+ }
173
+ this.mapCorrelationIdToWorkingCopiesToRestore.set(e.correlationId, workingCopiesToRestore);
174
+ })());
175
+ }
176
+ }
177
+ onDidFailWorkingCopyFileOperation(e) {
178
+ if (((e.operation === 2 || e.operation === 3) )) {
179
+ const workingCopiesToRestore = this.mapCorrelationIdToWorkingCopiesToRestore.get(e.correlationId);
180
+ if (workingCopiesToRestore) {
181
+ this.mapCorrelationIdToWorkingCopiesToRestore.delete(e.correlationId);
182
+ for (const workingCopy of workingCopiesToRestore) {
183
+ if (workingCopy.snapshot) {
184
+ this.get(workingCopy.source)?.markModified();
185
+ }
186
+ }
187
+ }
188
+ }
189
+ }
190
+ onDidRunWorkingCopyFileOperation(e) {
191
+ switch (e.operation) {
192
+ case 0 :
193
+ e.waitUntil((async () => {
194
+ for (const { target } of e.files) {
195
+ const workingCopy = this.get(target);
196
+ if (workingCopy && !workingCopy.isDisposed()) {
197
+ await workingCopy.revert();
198
+ }
199
+ }
200
+ })());
201
+ break;
202
+ case 2 :
203
+ case 3 :
204
+ e.waitUntil((async () => {
205
+ const workingCopiesToRestore = this.mapCorrelationIdToWorkingCopiesToRestore.get(e.correlationId);
206
+ if (workingCopiesToRestore) {
207
+ this.mapCorrelationIdToWorkingCopiesToRestore.delete(e.correlationId);
208
+ await Promises.settled(( workingCopiesToRestore.map(async (workingCopyToRestore) => {
209
+ await this.resolve(workingCopyToRestore.target, {
210
+ reload: { async: false },
211
+ contents: workingCopyToRestore.snapshot
212
+ });
213
+ })));
214
+ }
215
+ })());
216
+ break;
217
+ }
218
+ }
219
+ async reload(workingCopy) {
220
+ await this.joinPendingResolves(workingCopy.resource);
221
+ if (workingCopy.isDirty() || workingCopy.isDisposed() || !( this.has(workingCopy.resource))) {
222
+ return;
223
+ }
224
+ await this.doResolve(workingCopy, { reload: { async: false } });
225
+ }
226
+ async resolve(resource, options) {
227
+ const pendingResolve = this.joinPendingResolves(resource);
228
+ if (pendingResolve) {
229
+ await pendingResolve;
230
+ }
231
+ return this.doResolve(resource, options);
232
+ }
233
+ async doResolve(resourceOrWorkingCopy, options) {
234
+ let workingCopy;
235
+ let resource;
236
+ if (URI.isUri(resourceOrWorkingCopy)) {
237
+ resource = resourceOrWorkingCopy;
238
+ workingCopy = this.get(resource);
239
+ }
240
+ else {
241
+ resource = resourceOrWorkingCopy.resource;
242
+ workingCopy = resourceOrWorkingCopy;
243
+ }
244
+ let workingCopyResolve;
245
+ let didCreateWorkingCopy = false;
246
+ const resolveOptions = {
247
+ contents: options?.contents,
248
+ forceReadFromFile: options?.reload?.force
249
+ };
250
+ if (workingCopy) {
251
+ if (options?.contents) {
252
+ workingCopyResolve = workingCopy.resolve(resolveOptions);
253
+ }
254
+ else if (options?.reload) {
255
+ if (options.reload.async) {
256
+ workingCopyResolve = Promise.resolve();
257
+ (async () => {
258
+ try {
259
+ await workingCopy.resolve(resolveOptions);
260
+ }
261
+ catch (error) {
262
+ onUnexpectedError(error);
263
+ }
264
+ })();
265
+ }
266
+ else {
267
+ workingCopyResolve = workingCopy.resolve(resolveOptions);
268
+ }
269
+ }
270
+ else {
271
+ workingCopyResolve = Promise.resolve();
272
+ }
273
+ }
274
+ else {
275
+ didCreateWorkingCopy = true;
276
+ workingCopy = ( new StoredFileWorkingCopy(
277
+ this.workingCopyTypeId,
278
+ resource,
279
+ this.labelService.getUriBasenameLabel(resource),
280
+ this.modelFactory,
281
+ async (options) => { await this.resolve(resource, { ...options, reload: { async: false } }); },
282
+ this.fileService,
283
+ this.logService,
284
+ this.workingCopyFileService,
285
+ this.filesConfigurationService,
286
+ this.workingCopyBackupService,
287
+ this.workingCopyService,
288
+ this.notificationService,
289
+ this.workingCopyEditorService,
290
+ this.editorService,
291
+ this.elevatedFileService
292
+ ));
293
+ workingCopyResolve = workingCopy.resolve(resolveOptions);
294
+ this.registerWorkingCopy(workingCopy);
295
+ }
296
+ this.mapResourceToPendingWorkingCopyResolve.set(resource, workingCopyResolve);
297
+ this.add(resource, workingCopy);
298
+ if (didCreateWorkingCopy) {
299
+ if (workingCopy.isDirty()) {
300
+ this._onDidChangeDirty.fire(workingCopy);
301
+ }
302
+ }
303
+ try {
304
+ await workingCopyResolve;
305
+ }
306
+ catch (error) {
307
+ if (didCreateWorkingCopy) {
308
+ workingCopy.dispose();
309
+ }
310
+ throw error;
311
+ }
312
+ finally {
313
+ this.mapResourceToPendingWorkingCopyResolve.delete(resource);
314
+ }
315
+ if (didCreateWorkingCopy && workingCopy.isDirty()) {
316
+ this._onDidChangeDirty.fire(workingCopy);
317
+ }
318
+ return workingCopy;
319
+ }
320
+ joinPendingResolves(resource) {
321
+ const pendingWorkingCopyResolve = this.mapResourceToPendingWorkingCopyResolve.get(resource);
322
+ if (!pendingWorkingCopyResolve) {
323
+ return;
324
+ }
325
+ return this.doJoinPendingResolves(resource);
326
+ }
327
+ async doJoinPendingResolves(resource) {
328
+ let currentWorkingCopyResolve;
329
+ while (( this.mapResourceToPendingWorkingCopyResolve.has(resource))) {
330
+ const nextPendingWorkingCopyResolve = this.mapResourceToPendingWorkingCopyResolve.get(resource);
331
+ if (nextPendingWorkingCopyResolve === currentWorkingCopyResolve) {
332
+ return;
333
+ }
334
+ currentWorkingCopyResolve = nextPendingWorkingCopyResolve;
335
+ try {
336
+ await nextPendingWorkingCopyResolve;
337
+ }
338
+ catch (error) {
339
+ }
340
+ }
341
+ }
342
+ registerWorkingCopy(workingCopy) {
343
+ const workingCopyListeners = ( new DisposableStore());
344
+ workingCopyListeners.add(workingCopy.onDidResolve(() => this._onDidResolve.fire(workingCopy)));
345
+ workingCopyListeners.add(workingCopy.onDidChangeDirty(() => this._onDidChangeDirty.fire(workingCopy)));
346
+ workingCopyListeners.add(workingCopy.onDidChangeReadonly(() => this._onDidChangeReadonly.fire(workingCopy)));
347
+ workingCopyListeners.add(workingCopy.onDidChangeOrphaned(() => this._onDidChangeOrphaned.fire(workingCopy)));
348
+ workingCopyListeners.add(workingCopy.onDidSaveError(() => this._onDidSaveError.fire(workingCopy)));
349
+ workingCopyListeners.add(workingCopy.onDidSave(e => this._onDidSave.fire({ workingCopy, ...e })));
350
+ workingCopyListeners.add(workingCopy.onDidRevert(() => this._onDidRevert.fire(workingCopy)));
351
+ this.mapResourceToWorkingCopyListeners.set(workingCopy.resource, workingCopyListeners);
352
+ }
353
+ remove(resource) {
354
+ const removed = super.remove(resource);
355
+ const workingCopyListener = this.mapResourceToWorkingCopyListeners.get(resource);
356
+ if (workingCopyListener) {
357
+ dispose(workingCopyListener);
358
+ this.mapResourceToWorkingCopyListeners.delete(resource);
359
+ }
360
+ if (removed) {
361
+ this._onDidRemove.fire(resource);
362
+ }
363
+ return removed;
364
+ }
365
+ canDispose(workingCopy) {
366
+ if (workingCopy.isDisposed() ||
367
+ (!( this.mapResourceToPendingWorkingCopyResolve.has(workingCopy.resource)) && !workingCopy.isDirty())) {
368
+ return true;
369
+ }
370
+ return this.doCanDispose(workingCopy);
371
+ }
372
+ async doCanDispose(workingCopy) {
373
+ const pendingResolve = this.joinPendingResolves(workingCopy.resource);
374
+ if (pendingResolve) {
375
+ await pendingResolve;
376
+ return this.canDispose(workingCopy);
377
+ }
378
+ if (workingCopy.isDirty()) {
379
+ await Event.toPromise(workingCopy.onDidChangeDirty);
380
+ return this.canDispose(workingCopy);
381
+ }
382
+ return true;
383
+ }
384
+ dispose() {
385
+ super.dispose();
386
+ this.mapResourceToPendingWorkingCopyResolve.clear();
387
+ dispose(( this.mapResourceToWorkingCopyListeners.values()));
388
+ this.mapResourceToWorkingCopyListeners.clear();
389
+ }
390
+ };
391
+ StoredFileWorkingCopyManager = ( __decorate([
392
+ ( __param(2, IFileService)),
393
+ ( __param(3, ILifecycleService)),
394
+ ( __param(4, ILabelService)),
395
+ ( __param(5, ILogService)),
396
+ ( __param(6, IWorkingCopyFileService)),
397
+ ( __param(7, IWorkingCopyBackupService)),
398
+ ( __param(8, IUriIdentityService)),
399
+ ( __param(9, IFilesConfigurationService)),
400
+ ( __param(10, IWorkingCopyService)),
401
+ ( __param(11, INotificationService)),
402
+ ( __param(12, IWorkingCopyEditorService)),
403
+ ( __param(13, IEditorService)),
404
+ ( __param(14, IElevatedFileService))
405
+ ], StoredFileWorkingCopyManager));
406
+
407
+ export { StoredFileWorkingCopyManager };
@@ -0,0 +1,144 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
3
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
5
+ import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
6
+ import { raceCancellation } from 'monaco-editor/esm/vs/base/common/async.js';
7
+ import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
8
+ import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup';
9
+ import { emptyStream } from 'monaco-editor/esm/vs/base/common/stream.js';
10
+
11
+ let UntitledFileWorkingCopy = class UntitledFileWorkingCopy extends Disposable {
12
+ get model() { return this._model; }
13
+ constructor(typeId, resource, name, hasAssociatedFilePath, isScratchpad, initialContents, modelFactory, saveDelegate, workingCopyService, workingCopyBackupService, logService) {
14
+ super();
15
+ this.typeId = typeId;
16
+ this.resource = resource;
17
+ this.name = name;
18
+ this.hasAssociatedFilePath = hasAssociatedFilePath;
19
+ this.isScratchpad = isScratchpad;
20
+ this.initialContents = initialContents;
21
+ this.modelFactory = modelFactory;
22
+ this.saveDelegate = saveDelegate;
23
+ this.workingCopyBackupService = workingCopyBackupService;
24
+ this.logService = logService;
25
+ this.capabilities = this.isScratchpad ? 2 | 4 : 2 ;
26
+ this._model = undefined;
27
+ this._onDidChangeContent = this._register(( new Emitter()));
28
+ this.onDidChangeContent = this._onDidChangeContent.event;
29
+ this._onDidChangeDirty = this._register(( new Emitter()));
30
+ this.onDidChangeDirty = this._onDidChangeDirty.event;
31
+ this._onDidSave = this._register(( new Emitter()));
32
+ this.onDidSave = this._onDidSave.event;
33
+ this._onDidRevert = this._register(( new Emitter()));
34
+ this.onDidRevert = this._onDidRevert.event;
35
+ this._onWillDispose = this._register(( new Emitter()));
36
+ this.onWillDispose = this._onWillDispose.event;
37
+ this.modified = this.hasAssociatedFilePath || Boolean(this.initialContents && this.initialContents.markModified !== false);
38
+ this._register(workingCopyService.registerWorkingCopy(this));
39
+ }
40
+ isDirty() {
41
+ return this.modified && !this.isScratchpad;
42
+ }
43
+ isModified() {
44
+ return this.modified;
45
+ }
46
+ setModified(modified) {
47
+ if (this.modified === modified) {
48
+ return;
49
+ }
50
+ this.modified = modified;
51
+ if (!this.isScratchpad) {
52
+ this._onDidChangeDirty.fire();
53
+ }
54
+ }
55
+ async resolve() {
56
+ this.trace('resolve()');
57
+ if (this.isResolved()) {
58
+ this.trace('resolve() - exit (already resolved)');
59
+ return;
60
+ }
61
+ let untitledContents;
62
+ const backup = await this.workingCopyBackupService.resolve(this);
63
+ if (backup) {
64
+ this.trace('resolve() - with backup');
65
+ untitledContents = backup.value;
66
+ }
67
+ else if (this.initialContents?.value) {
68
+ this.trace('resolve() - with initial contents');
69
+ untitledContents = this.initialContents.value;
70
+ }
71
+ else {
72
+ this.trace('resolve() - empty');
73
+ untitledContents = emptyStream();
74
+ }
75
+ await this.doCreateModel(untitledContents);
76
+ this.setModified(this.hasAssociatedFilePath || !!backup || Boolean(this.initialContents && this.initialContents.markModified !== false));
77
+ if (!!backup || this.initialContents) {
78
+ this._onDidChangeContent.fire();
79
+ }
80
+ }
81
+ async doCreateModel(contents) {
82
+ this.trace('doCreateModel()');
83
+ this._model = this._register(await this.modelFactory.createModel(this.resource, contents, CancellationToken.None));
84
+ this.installModelListeners(this._model);
85
+ }
86
+ installModelListeners(model) {
87
+ this._register(model.onDidChangeContent(e => this.onModelContentChanged(e)));
88
+ this._register(model.onWillDispose(() => this.dispose()));
89
+ }
90
+ onModelContentChanged(e) {
91
+ if (!this.hasAssociatedFilePath && e.isInitial) {
92
+ this.setModified(false);
93
+ }
94
+ else {
95
+ this.setModified(true);
96
+ }
97
+ this._onDidChangeContent.fire();
98
+ }
99
+ isResolved() {
100
+ return !!this.model;
101
+ }
102
+ get backupDelay() {
103
+ return this.model?.configuration?.backupDelay;
104
+ }
105
+ async backup(token) {
106
+ let content = undefined;
107
+ if (this.isResolved()) {
108
+ content = await raceCancellation(this.model.snapshot(token), token);
109
+ }
110
+ else if (this.initialContents) {
111
+ content = this.initialContents.value;
112
+ }
113
+ return { content };
114
+ }
115
+ async save(options) {
116
+ this.trace('save()');
117
+ const result = await this.saveDelegate(this, options);
118
+ if (result) {
119
+ this._onDidSave.fire({ reason: options?.reason, source: options?.source });
120
+ }
121
+ return result;
122
+ }
123
+ async revert() {
124
+ this.trace('revert()');
125
+ this.setModified(false);
126
+ this._onDidRevert.fire();
127
+ this.dispose();
128
+ }
129
+ dispose() {
130
+ this.trace('dispose()');
131
+ this._onWillDispose.fire();
132
+ super.dispose();
133
+ }
134
+ trace(msg) {
135
+ this.logService.trace(`[untitled file working copy] ${msg}`, ( this.resource.toString()), this.typeId);
136
+ }
137
+ };
138
+ UntitledFileWorkingCopy = ( __decorate([
139
+ ( __param(8, IWorkingCopyService)),
140
+ ( __param(9, IWorkingCopyBackupService)),
141
+ ( __param(10, ILogService))
142
+ ], UntitledFileWorkingCopy));
143
+
144
+ export { UntitledFileWorkingCopy };
@@ -0,0 +1,129 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { DisposableStore, dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
3
+ import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
4
+ import { UntitledFileWorkingCopy } from './untitledFileWorkingCopy.js';
5
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
6
+ import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
7
+ import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
8
+ import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
9
+ import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
10
+ import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup';
11
+ import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
12
+ import { BaseFileWorkingCopyManager } from './abstractFileWorkingCopyManager.js';
13
+ import { ResourceMap } from 'monaco-editor/esm/vs/base/common/map.js';
14
+
15
+ let UntitledFileWorkingCopyManager = class UntitledFileWorkingCopyManager extends BaseFileWorkingCopyManager {
16
+ constructor(workingCopyTypeId, modelFactory, saveDelegate, fileService, labelService, logService, workingCopyBackupService, workingCopyService) {
17
+ super(fileService, logService, workingCopyBackupService);
18
+ this.workingCopyTypeId = workingCopyTypeId;
19
+ this.modelFactory = modelFactory;
20
+ this.saveDelegate = saveDelegate;
21
+ this.labelService = labelService;
22
+ this.workingCopyService = workingCopyService;
23
+ this._onDidChangeDirty = this._register(( new Emitter()));
24
+ this.onDidChangeDirty = this._onDidChangeDirty.event;
25
+ this._onWillDispose = this._register(( new Emitter()));
26
+ this.onWillDispose = this._onWillDispose.event;
27
+ this.mapResourceToWorkingCopyListeners = ( new ResourceMap());
28
+ }
29
+ async resolve(options) {
30
+ const workingCopy = this.doCreateOrGet(options);
31
+ await workingCopy.resolve();
32
+ return workingCopy;
33
+ }
34
+ doCreateOrGet(options = Object.create(null)) {
35
+ const massagedOptions = this.massageOptions(options);
36
+ if (massagedOptions.untitledResource) {
37
+ const existingWorkingCopy = this.get(massagedOptions.untitledResource);
38
+ if (existingWorkingCopy) {
39
+ return existingWorkingCopy;
40
+ }
41
+ }
42
+ return this.doCreate(massagedOptions);
43
+ }
44
+ massageOptions(options) {
45
+ const massagedOptions = Object.create(null);
46
+ if (options.associatedResource) {
47
+ massagedOptions.untitledResource = ( URI.from({
48
+ scheme: Schemas.untitled,
49
+ authority: options.associatedResource.authority,
50
+ fragment: options.associatedResource.fragment,
51
+ path: options.associatedResource.path,
52
+ query: options.associatedResource.query
53
+ }));
54
+ massagedOptions.associatedResource = options.associatedResource;
55
+ }
56
+ else {
57
+ if (options.untitledResource?.scheme === Schemas.untitled) {
58
+ massagedOptions.untitledResource = options.untitledResource;
59
+ }
60
+ massagedOptions.isScratchpad = options.isScratchpad;
61
+ }
62
+ massagedOptions.contents = options.contents;
63
+ return massagedOptions;
64
+ }
65
+ doCreate(options) {
66
+ let untitledResource = options.untitledResource;
67
+ if (!untitledResource) {
68
+ let counter = 1;
69
+ do {
70
+ untitledResource = ( URI.from({
71
+ scheme: Schemas.untitled,
72
+ path: options.isScratchpad ? `Scratchpad-${counter}` : `Untitled-${counter}`,
73
+ query: this.workingCopyTypeId ?
74
+ `typeId=${this.workingCopyTypeId}` :
75
+ undefined
76
+ }));
77
+ counter++;
78
+ } while (( this.has(untitledResource)));
79
+ }
80
+ const workingCopy = ( new UntitledFileWorkingCopy(
81
+ this.workingCopyTypeId,
82
+ untitledResource,
83
+ this.labelService.getUriBasenameLabel(untitledResource),
84
+ !!options.associatedResource,
85
+ !!options.isScratchpad,
86
+ options.contents,
87
+ this.modelFactory,
88
+ this.saveDelegate,
89
+ this.workingCopyService,
90
+ this.workingCopyBackupService,
91
+ this.logService
92
+ ));
93
+ this.registerWorkingCopy(workingCopy);
94
+ return workingCopy;
95
+ }
96
+ registerWorkingCopy(workingCopy) {
97
+ const workingCopyListeners = ( new DisposableStore());
98
+ workingCopyListeners.add(workingCopy.onDidChangeDirty(() => this._onDidChangeDirty.fire(workingCopy)));
99
+ workingCopyListeners.add(workingCopy.onWillDispose(() => this._onWillDispose.fire(workingCopy)));
100
+ this.mapResourceToWorkingCopyListeners.set(workingCopy.resource, workingCopyListeners);
101
+ this.add(workingCopy.resource, workingCopy);
102
+ if (workingCopy.isDirty()) {
103
+ this._onDidChangeDirty.fire(workingCopy);
104
+ }
105
+ }
106
+ remove(resource) {
107
+ const removed = super.remove(resource);
108
+ const workingCopyListener = this.mapResourceToWorkingCopyListeners.get(resource);
109
+ if (workingCopyListener) {
110
+ dispose(workingCopyListener);
111
+ this.mapResourceToWorkingCopyListeners.delete(resource);
112
+ }
113
+ return removed;
114
+ }
115
+ dispose() {
116
+ super.dispose();
117
+ dispose(( this.mapResourceToWorkingCopyListeners.values()));
118
+ this.mapResourceToWorkingCopyListeners.clear();
119
+ }
120
+ };
121
+ UntitledFileWorkingCopyManager = ( __decorate([
122
+ ( __param(3, IFileService)),
123
+ ( __param(4, ILabelService)),
124
+ ( __param(5, ILogService)),
125
+ ( __param(6, IWorkingCopyBackupService)),
126
+ ( __param(7, IWorkingCopyService))
127
+ ], UntitledFileWorkingCopyManager));
128
+
129
+ export { UntitledFileWorkingCopyManager };
package/worker.js ADDED
@@ -0,0 +1 @@
1
+ import './workers/notebook.worker.js';