@codingame/monaco-vscode-notebook-service-override 3.2.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/notebook.js +13 -13
  2. package/package.json +2 -2
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/override/vs/platform/dialogs/common/dialogs.js +0 -8
  6. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +0 -6
  7. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +0 -389
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +0 -608
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +0 -109
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +0 -173
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +0 -488
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +0 -106
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +0 -67
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +0 -165
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +0 -67
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +0 -320
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +0 -72
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +0 -6
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +0 -168
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +0 -209
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +0 -84
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +0 -82
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +0 -67
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +0 -91
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +0 -393
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +0 -5
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +0 -97
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +0 -118
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +0 -59
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +0 -148
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +0 -383
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +0 -77
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +0 -511
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +0 -159
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +0 -56
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +0 -94
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +0 -51
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +0 -565
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +0 -31
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.js +0 -744
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +0 -707
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -351
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +0 -267
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -45
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1297
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -284
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -563
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -108
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -39
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +0 -6
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +0 -313
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -890
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -13
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -393
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -175
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +0 -1174
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +0 -159
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +0 -451
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +0 -192
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +0 -106
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +0 -509
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +0 -130
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +0 -341
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +0 -111
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +0 -28
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +0 -65
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +0 -641
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +0 -200
  69. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +0 -80
  70. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +0 -1003
  71. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +0 -103
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +0 -202
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +0 -80
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +0 -98
  75. package/vscode/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchService.js +0 -237
  76. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +0 -89
  77. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +0 -376
  78. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +0 -408
  79. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +0 -144
  80. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +0 -129
@@ -1,641 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
- import { toAction } from 'vscode/vscode/vs/base/common/actions';
4
- import { createErrorWithActions } from 'vscode/vscode/vs/base/common/errorMessage';
5
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
6
- import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
7
- import { Lazy } from 'vscode/vscode/vs/base/common/lazy';
8
- import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
9
- import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
10
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
11
- import { isEqual } from 'vscode/vscode/vs/base/common/resources';
12
- import { isDefined } from 'vscode/vscode/vs/base/common/types';
13
- import { URI } from 'vscode/vscode/vs/base/common/uri';
14
- import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
15
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
16
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
17
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
18
- import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
19
- import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
20
- import { notebooksExtensionPoint, notebookRendererExtensionPoint, notebookPreloadExtensionPoint } from '../notebookExtensionPoint.js';
21
- import { NotebookDiffEditorInput } from '../../common/notebookDiffEditorInput.js';
22
- import { NotebookTextModel } from '../../common/model/notebookTextModel.js';
23
- import { NotebookEditorPriority, NotebookSetting, RENDERER_NOT_AVAILABLE, RENDERER_EQUIVALENT_EXTENSIONS, MimeTypeDisplayOrder, ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER, NOTEBOOK_DISPLAY_ORDER, CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
24
- import { NotebookEditorInput } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
25
- import { INotebookEditorModelResolverService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService';
26
- import { NotebookOutputRendererInfo, NotebookStaticPreloadInfo } from '../../common/notebookOutputRenderer.js';
27
- import { NotebookProviderInfo } from '../../common/notebookProvider.js';
28
- import { SimpleNotebookProviderInfo } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
29
- import { RegisteredEditorPriority, IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
30
- import { isProposedApiEnabled, IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
31
- import { InstallRecommendedExtensionAction } from 'vscode/vscode/vs/workbench/contrib/extensions/browser/extensionsActions';
32
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
33
- import { INotebookDocumentService } from 'vscode/vscode/vs/workbench/services/notebook/common/notebookDocumentService';
34
-
35
- var NotebookProviderInfoStore_1, NotebookService_1;
36
- let NotebookProviderInfoStore = class NotebookProviderInfoStore extends Disposable {
37
- static { NotebookProviderInfoStore_1 = this; }
38
- static { this.CUSTOM_EDITORS_STORAGE_ID = 'notebookEditors'; }
39
- static { this.CUSTOM_EDITORS_ENTRY_ID = 'editors'; }
40
- constructor(storageService, extensionService, _editorResolverService, _configurationService, _accessibilityService, _instantiationService, _fileService, _notebookEditorModelResolverService, uriIdentService) {
41
- super();
42
- this._editorResolverService = _editorResolverService;
43
- this._configurationService = _configurationService;
44
- this._accessibilityService = _accessibilityService;
45
- this._instantiationService = _instantiationService;
46
- this._fileService = _fileService;
47
- this._notebookEditorModelResolverService = _notebookEditorModelResolverService;
48
- this.uriIdentService = uriIdentService;
49
- this._handled = false;
50
- this._contributedEditors = ( new Map());
51
- this._contributedEditorDisposables = this._register(( new DisposableStore()));
52
- this._memento = ( new Memento(NotebookProviderInfoStore_1.CUSTOM_EDITORS_STORAGE_ID, storageService));
53
- const mementoObject = this._memento.getMemento(0 , 1 );
54
- this._editorResolverService.bufferChangeEvents(() => {
55
- for (const info of (mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] || [])) {
56
- this.add(( new NotebookProviderInfo(info)));
57
- }
58
- });
59
- this._register(extensionService.onDidRegisterExtensions(() => {
60
- if (!this._handled) {
61
- this._clear();
62
- mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = [];
63
- this._memento.saveMemento();
64
- }
65
- }));
66
- notebooksExtensionPoint.setHandler(extensions => this._setupHandler(extensions));
67
- }
68
- dispose() {
69
- this._clear();
70
- super.dispose();
71
- }
72
- _setupHandler(extensions) {
73
- this._handled = true;
74
- const builtins = [...( this._contributedEditors.values())].filter(info => !info.extension);
75
- this._clear();
76
- const builtinProvidersFromCache = ( new Map());
77
- builtins.forEach(builtin => {
78
- builtinProvidersFromCache.set(builtin.id, this.add(builtin));
79
- });
80
- for (const extension of extensions) {
81
- for (const notebookContribution of extension.value) {
82
- if (!notebookContribution.type) {
83
- extension.collector.error(`Notebook does not specify type-property`);
84
- continue;
85
- }
86
- const existing = this.get(notebookContribution.type);
87
- if (existing) {
88
- if (!existing.extension && extension.description.isBuiltin && builtins.find(builtin => builtin.id === notebookContribution.type)) {
89
- builtinProvidersFromCache.get(notebookContribution.type)?.dispose();
90
- }
91
- else {
92
- extension.collector.error(`Notebook type '${notebookContribution.type}' already used`);
93
- continue;
94
- }
95
- }
96
- this.add(( new NotebookProviderInfo({
97
- extension: extension.description.identifier,
98
- id: notebookContribution.type,
99
- displayName: notebookContribution.displayName,
100
- selectors: notebookContribution.selector || [],
101
- priority: this._convertPriority(notebookContribution.priority),
102
- providerDisplayName: extension.description.displayName ?? extension.description.identifier.value,
103
- exclusive: false
104
- })));
105
- }
106
- }
107
- const mementoObject = this._memento.getMemento(0 , 1 );
108
- mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = Array.from(( this._contributedEditors.values()));
109
- this._memento.saveMemento();
110
- }
111
- clearEditorCache() {
112
- const mementoObject = this._memento.getMemento(0 , 1 );
113
- mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = [];
114
- this._memento.saveMemento();
115
- }
116
- _convertPriority(priority) {
117
- if (!priority) {
118
- return RegisteredEditorPriority.default;
119
- }
120
- if (priority === NotebookEditorPriority.default) {
121
- return RegisteredEditorPriority.default;
122
- }
123
- return RegisteredEditorPriority.option;
124
- }
125
- _registerContributionPoint(notebookProviderInfo) {
126
- const disposables = ( new DisposableStore());
127
- for (const selector of notebookProviderInfo.selectors) {
128
- const globPattern = selector.include || selector;
129
- const notebookEditorInfo = {
130
- id: notebookProviderInfo.id,
131
- label: notebookProviderInfo.displayName,
132
- detail: notebookProviderInfo.providerDisplayName,
133
- priority: notebookProviderInfo.exclusive ? RegisteredEditorPriority.exclusive : notebookProviderInfo.priority,
134
- };
135
- const notebookEditorOptions = {
136
- canHandleDiff: () => !!this._configurationService.getValue(NotebookSetting.textDiffEditorPreview) && !this._accessibilityService.isScreenReaderOptimized(),
137
- canSupportResource: (resource) => resource.scheme === Schemas.untitled || resource.scheme === Schemas.vscodeNotebookCell || this._fileService.hasProvider(resource)
138
- };
139
- const notebookEditorInputFactory = ({ resource, options }) => {
140
- const data = CellUri.parse(resource);
141
- let notebookUri;
142
- let cellOptions;
143
- let preferredResource = resource;
144
- if (data) {
145
- notebookUri = this.uriIdentService.asCanonicalUri(data.notebook);
146
- preferredResource = data.notebook;
147
- cellOptions = { resource, options };
148
- }
149
- else {
150
- notebookUri = this.uriIdentService.asCanonicalUri(resource);
151
- }
152
- if (!cellOptions) {
153
- cellOptions = options?.cellOptions;
154
- }
155
- const notebookOptions = { ...options, cellOptions };
156
- const editor = NotebookEditorInput.getOrCreate(this._instantiationService, notebookUri, preferredResource, notebookProviderInfo.id);
157
- return { editor, options: notebookOptions };
158
- };
159
- const notebookUntitledEditorFactory = async ({ resource, options }) => {
160
- const ref = await this._notebookEditorModelResolverService.resolve({ untitledResource: resource }, notebookProviderInfo.id);
161
- ref.object.notebook.onWillDispose(() => {
162
- ref.dispose();
163
- });
164
- return { editor: NotebookEditorInput.getOrCreate(this._instantiationService, ref.object.resource, undefined, notebookProviderInfo.id), options };
165
- };
166
- const notebookDiffEditorInputFactory = ({ modified, original, label, description }) => {
167
- return { editor: NotebookDiffEditorInput.create(this._instantiationService, modified.resource, label, description, original.resource, notebookProviderInfo.id) };
168
- };
169
- const notebookFactoryObject = {
170
- createEditorInput: notebookEditorInputFactory,
171
- createDiffEditorInput: notebookDiffEditorInputFactory,
172
- createUntitledEditorInput: notebookUntitledEditorFactory,
173
- };
174
- const notebookCellFactoryObject = {
175
- createEditorInput: notebookEditorInputFactory,
176
- createDiffEditorInput: notebookDiffEditorInputFactory,
177
- };
178
- disposables.add(this._configurationService.onDidChangeConfiguration(e => {
179
- if (e.affectsConfiguration(NotebookSetting.textDiffEditorPreview)) {
180
- const canHandleDiff = !!this._configurationService.getValue(NotebookSetting.textDiffEditorPreview) && !this._accessibilityService.isScreenReaderOptimized();
181
- if (canHandleDiff) {
182
- notebookFactoryObject.createDiffEditorInput = notebookDiffEditorInputFactory;
183
- notebookCellFactoryObject.createDiffEditorInput = notebookDiffEditorInputFactory;
184
- }
185
- else {
186
- notebookFactoryObject.createDiffEditorInput = undefined;
187
- notebookCellFactoryObject.createDiffEditorInput = undefined;
188
- }
189
- }
190
- }));
191
- disposables.add(this._accessibilityService.onDidChangeScreenReaderOptimized(() => {
192
- const canHandleDiff = !!this._configurationService.getValue(NotebookSetting.textDiffEditorPreview) && !this._accessibilityService.isScreenReaderOptimized();
193
- if (canHandleDiff) {
194
- notebookFactoryObject.createDiffEditorInput = notebookDiffEditorInputFactory;
195
- notebookCellFactoryObject.createDiffEditorInput = notebookDiffEditorInputFactory;
196
- }
197
- else {
198
- notebookFactoryObject.createDiffEditorInput = undefined;
199
- notebookCellFactoryObject.createDiffEditorInput = undefined;
200
- }
201
- }));
202
- disposables.add(this._editorResolverService.registerEditor(globPattern, notebookEditorInfo, notebookEditorOptions, notebookFactoryObject));
203
- disposables.add(this._editorResolverService.registerEditor(`${Schemas.vscodeNotebookCell}:/**/${globPattern}`, { ...notebookEditorInfo, priority: RegisteredEditorPriority.exclusive }, notebookEditorOptions, notebookCellFactoryObject));
204
- }
205
- return disposables;
206
- }
207
- _clear() {
208
- this._contributedEditors.clear();
209
- this._contributedEditorDisposables.clear();
210
- }
211
- get(viewType) {
212
- return this._contributedEditors.get(viewType);
213
- }
214
- add(info) {
215
- if (( this._contributedEditors.has(info.id))) {
216
- throw new Error(`notebook type '${info.id}' ALREADY EXISTS`);
217
- }
218
- this._contributedEditors.set(info.id, info);
219
- let editorRegistration;
220
- if (info.extension) {
221
- editorRegistration = this._registerContributionPoint(info);
222
- this._contributedEditorDisposables.add(editorRegistration);
223
- }
224
- const mementoObject = this._memento.getMemento(0 , 1 );
225
- mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = Array.from(( this._contributedEditors.values()));
226
- this._memento.saveMemento();
227
- return this._register(toDisposable(() => {
228
- const mementoObject = this._memento.getMemento(0 , 1 );
229
- mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = Array.from(( this._contributedEditors.values()));
230
- this._memento.saveMemento();
231
- editorRegistration?.dispose();
232
- this._contributedEditors.delete(info.id);
233
- }));
234
- }
235
- getContributedNotebook(resource) {
236
- const result = [];
237
- for (const info of ( this._contributedEditors.values())) {
238
- if (info.matches(resource)) {
239
- result.push(info);
240
- }
241
- }
242
- if (result.length === 0 && resource.scheme === Schemas.untitled) {
243
- return Array.from(( this._contributedEditors.values()));
244
- }
245
- return result;
246
- }
247
- [Symbol.iterator]() {
248
- return ( this._contributedEditors.values());
249
- }
250
- };
251
- NotebookProviderInfoStore = NotebookProviderInfoStore_1 = ( __decorate([
252
- ( __param(0, IStorageService)),
253
- ( __param(1, IExtensionService)),
254
- ( __param(2, IEditorResolverService)),
255
- ( __param(3, IConfigurationService)),
256
- ( __param(4, IAccessibilityService)),
257
- ( __param(5, IInstantiationService)),
258
- ( __param(6, IFileService)),
259
- ( __param(7, INotebookEditorModelResolverService)),
260
- ( __param(8, IUriIdentityService))
261
- ], NotebookProviderInfoStore));
262
- let NotebookOutputRendererInfoStore = class NotebookOutputRendererInfoStore {
263
- constructor(storageService) {
264
- this.contributedRenderers = ( new Map());
265
- this.preferredMimetype = ( new Lazy(
266
- () => this.preferredMimetypeMemento.getMemento(1 , 1 )
267
- ));
268
- this.preferredMimetypeMemento = ( new Memento('workbench.editor.notebook.preferredRenderer2', storageService));
269
- }
270
- clear() {
271
- this.contributedRenderers.clear();
272
- }
273
- get(rendererId) {
274
- return this.contributedRenderers.get(rendererId);
275
- }
276
- getAll() {
277
- return Array.from(( this.contributedRenderers.values()));
278
- }
279
- add(info) {
280
- if (( this.contributedRenderers.has(info.id))) {
281
- return;
282
- }
283
- this.contributedRenderers.set(info.id, info);
284
- }
285
- setPreferred(notebookProviderInfo, mimeType, rendererId) {
286
- const mementoObj = this.preferredMimetype.value;
287
- const forNotebook = mementoObj[notebookProviderInfo.id];
288
- if (forNotebook) {
289
- forNotebook[mimeType] = rendererId;
290
- }
291
- else {
292
- mementoObj[notebookProviderInfo.id] = { [mimeType]: rendererId };
293
- }
294
- this.preferredMimetypeMemento.saveMemento();
295
- }
296
- findBestRenderers(notebookProviderInfo, mimeType, kernelProvides) {
297
- const preferred = notebookProviderInfo && this.preferredMimetype.value[notebookProviderInfo.id]?.[mimeType];
298
- const notebookExtId = notebookProviderInfo?.extension?.value;
299
- const notebookId = notebookProviderInfo?.id;
300
- const renderers = ( Array.from(( this.contributedRenderers.values()))
301
- .map(renderer => {
302
- const ownScore = kernelProvides === undefined
303
- ? renderer.matchesWithoutKernel(mimeType)
304
- : renderer.matches(mimeType, kernelProvides);
305
- if (ownScore === 3 ) {
306
- return undefined;
307
- }
308
- const rendererExtId = renderer.extensionId.value;
309
- const reuseScore = preferred === renderer.id
310
- ? 256
311
- : rendererExtId === notebookExtId || RENDERER_EQUIVALENT_EXTENSIONS.get(rendererExtId)?.has(notebookId)
312
- ? 512
313
- : renderer.isBuiltin ? 1024 : 768 ;
314
- return {
315
- ordered: { mimeType, rendererId: renderer.id, isTrusted: true },
316
- score: reuseScore | ownScore,
317
- };
318
- })).filter(isDefined);
319
- if (renderers.length === 0) {
320
- return [{ mimeType, rendererId: RENDERER_NOT_AVAILABLE, isTrusted: true }];
321
- }
322
- return ( renderers.sort((a, b) => a.score - b.score).map(r => r.ordered));
323
- }
324
- };
325
- NotebookOutputRendererInfoStore = ( __decorate([
326
- ( __param(0, IStorageService))
327
- ], NotebookOutputRendererInfoStore));
328
- class ModelData {
329
- get uri() { return this.model.uri; }
330
- constructor(model, onWillDispose) {
331
- this.model = model;
332
- this._modelEventListeners = ( new DisposableStore());
333
- this._modelEventListeners.add(model.onWillDispose(() => onWillDispose(model)));
334
- }
335
- getCellIndex(cellUri) {
336
- return this.model.cells.findIndex(cell => isEqual(cell.uri, cellUri));
337
- }
338
- dispose() {
339
- this._modelEventListeners.dispose();
340
- }
341
- }
342
- let NotebookService = class NotebookService extends Disposable {
343
- static { NotebookService_1 = this; }
344
- static { this._storageNotebookViewTypeProvider = 'notebook.viewTypeProvider'; }
345
- get notebookProviderInfoStore() {
346
- if (!this._notebookProviderInfoStore) {
347
- this._notebookProviderInfoStore = this._register(this._instantiationService.createInstance(NotebookProviderInfoStore));
348
- }
349
- return this._notebookProviderInfoStore;
350
- }
351
- constructor(_extensionService, _configurationService, _accessibilityService, _instantiationService, _storageService, _notebookDocumentService) {
352
- super();
353
- this._extensionService = _extensionService;
354
- this._configurationService = _configurationService;
355
- this._accessibilityService = _accessibilityService;
356
- this._instantiationService = _instantiationService;
357
- this._storageService = _storageService;
358
- this._notebookDocumentService = _notebookDocumentService;
359
- this._notebookProviders = ( new Map());
360
- this._notebookProviderInfoStore = undefined;
361
- this._notebookRenderersInfoStore = this._instantiationService.createInstance(NotebookOutputRendererInfoStore);
362
- this._onDidChangeOutputRenderers = this._register(( new Emitter()));
363
- this.onDidChangeOutputRenderers = this._onDidChangeOutputRenderers.event;
364
- this._notebookStaticPreloadInfoStore = ( new Set());
365
- this._models = ( new ResourceMap());
366
- this._onWillAddNotebookDocument = this._register(( new Emitter()));
367
- this._onDidAddNotebookDocument = this._register(( new Emitter()));
368
- this._onWillRemoveNotebookDocument = this._register(( new Emitter()));
369
- this._onDidRemoveNotebookDocument = this._register(( new Emitter()));
370
- this.onWillAddNotebookDocument = this._onWillAddNotebookDocument.event;
371
- this.onDidAddNotebookDocument = this._onDidAddNotebookDocument.event;
372
- this.onDidRemoveNotebookDocument = this._onDidRemoveNotebookDocument.event;
373
- this.onWillRemoveNotebookDocument = this._onWillRemoveNotebookDocument.event;
374
- this._onAddViewType = this._register(( new Emitter()));
375
- this.onAddViewType = this._onAddViewType.event;
376
- this._onWillRemoveViewType = this._register(( new Emitter()));
377
- this.onWillRemoveViewType = this._onWillRemoveViewType.event;
378
- this._onDidChangeEditorTypes = this._register(( new Emitter()));
379
- this.onDidChangeEditorTypes = this._onDidChangeEditorTypes.event;
380
- this._lastClipboardIsCopy = true;
381
- notebookRendererExtensionPoint.setHandler((renderers) => {
382
- this._notebookRenderersInfoStore.clear();
383
- for (const extension of renderers) {
384
- for (const notebookContribution of extension.value) {
385
- if (!notebookContribution.entrypoint) {
386
- extension.collector.error(`Notebook renderer does not specify entry point`);
387
- continue;
388
- }
389
- const id = notebookContribution.id;
390
- if (!id) {
391
- extension.collector.error(`Notebook renderer does not specify id-property`);
392
- continue;
393
- }
394
- this._notebookRenderersInfoStore.add(( new NotebookOutputRendererInfo({
395
- id,
396
- extension: extension.description,
397
- entrypoint: notebookContribution.entrypoint,
398
- displayName: notebookContribution.displayName,
399
- mimeTypes: notebookContribution.mimeTypes || [],
400
- dependencies: notebookContribution.dependencies,
401
- optionalDependencies: notebookContribution.optionalDependencies,
402
- requiresMessaging: notebookContribution.requiresMessaging,
403
- })));
404
- }
405
- }
406
- this._onDidChangeOutputRenderers.fire();
407
- });
408
- notebookPreloadExtensionPoint.setHandler(extensions => {
409
- this._notebookStaticPreloadInfoStore.clear();
410
- for (const extension of extensions) {
411
- if (!isProposedApiEnabled(extension.description, 'contribNotebookStaticPreloads')) {
412
- continue;
413
- }
414
- for (const notebookContribution of extension.value) {
415
- if (!notebookContribution.entrypoint) {
416
- extension.collector.error(`Notebook preload does not specify entry point`);
417
- continue;
418
- }
419
- const type = notebookContribution.type;
420
- if (!type) {
421
- extension.collector.error(`Notebook preload does not specify type-property`);
422
- continue;
423
- }
424
- this._notebookStaticPreloadInfoStore.add(( new NotebookStaticPreloadInfo({
425
- type,
426
- extension: extension.description,
427
- entrypoint: notebookContribution.entrypoint,
428
- localResourceRoots: notebookContribution.localResourceRoots ?? [],
429
- })));
430
- }
431
- }
432
- });
433
- const updateOrder = () => {
434
- this._displayOrder = ( new MimeTypeDisplayOrder(
435
- this._configurationService.getValue(NotebookSetting.displayOrder) || [],
436
- this._accessibilityService.isScreenReaderOptimized()
437
- ? ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER
438
- : NOTEBOOK_DISPLAY_ORDER
439
- ));
440
- };
441
- updateOrder();
442
- this._register(this._configurationService.onDidChangeConfiguration(e => {
443
- if (e.affectsConfiguration(NotebookSetting.displayOrder)) {
444
- updateOrder();
445
- }
446
- }));
447
- this._register(this._accessibilityService.onDidChangeScreenReaderOptimized(() => {
448
- updateOrder();
449
- }));
450
- this._memento = ( new Memento(NotebookService_1._storageNotebookViewTypeProvider, this._storageService));
451
- this._viewTypeCache = this._memento.getMemento(1 , 1 );
452
- }
453
- getEditorTypes() {
454
- return ( [...this.notebookProviderInfoStore].map(info => ({
455
- id: info.id,
456
- displayName: info.displayName,
457
- providerDisplayName: info.providerDisplayName
458
- })));
459
- }
460
- clearEditorCache() {
461
- this.notebookProviderInfoStore.clearEditorCache();
462
- }
463
- _postDocumentOpenActivation(viewType) {
464
- this._extensionService.activateByEvent(`onNotebook:${viewType}`);
465
- this._extensionService.activateByEvent(`onNotebook:*`);
466
- }
467
- async canResolve(viewType) {
468
- if (( this._notebookProviders.has(viewType))) {
469
- return true;
470
- }
471
- await this._extensionService.whenInstalledExtensionsRegistered();
472
- await this._extensionService.activateByEvent(`onNotebookSerializer:${viewType}`);
473
- return ( this._notebookProviders.has(viewType));
474
- }
475
- registerContributedNotebookType(viewType, data) {
476
- const info = ( new NotebookProviderInfo({
477
- extension: data.extension,
478
- id: viewType,
479
- displayName: data.displayName,
480
- providerDisplayName: data.providerDisplayName,
481
- exclusive: data.exclusive,
482
- priority: RegisteredEditorPriority.default,
483
- selectors: []
484
- }));
485
- info.update({ selectors: data.filenamePattern });
486
- const reg = this.notebookProviderInfoStore.add(info);
487
- this._onDidChangeEditorTypes.fire();
488
- return toDisposable(() => {
489
- reg.dispose();
490
- this._onDidChangeEditorTypes.fire();
491
- });
492
- }
493
- _registerProviderData(viewType, data) {
494
- if (( this._notebookProviders.has(viewType))) {
495
- throw new Error(`notebook provider for viewtype '${viewType}' already exists`);
496
- }
497
- this._notebookProviders.set(viewType, data);
498
- this._onAddViewType.fire(viewType);
499
- return toDisposable(() => {
500
- this._onWillRemoveViewType.fire(viewType);
501
- this._notebookProviders.delete(viewType);
502
- });
503
- }
504
- registerNotebookSerializer(viewType, extensionData, serializer) {
505
- this.notebookProviderInfoStore.get(viewType)?.update({ options: serializer.options });
506
- this._viewTypeCache[viewType] = extensionData.id.value;
507
- this._persistMementos();
508
- return this._registerProviderData(viewType, ( new SimpleNotebookProviderInfo(viewType, serializer, extensionData)));
509
- }
510
- async withNotebookDataProvider(viewType) {
511
- const selected = this.notebookProviderInfoStore.get(viewType);
512
- if (!selected) {
513
- const knownProvider = this.getViewTypeProvider(viewType);
514
- const actions = knownProvider ? [
515
- toAction({
516
- id: 'workbench.notebook.action.installMissingViewType', label: ( localizeWithPath(
517
- 'vs/workbench/contrib/notebook/browser/services/notebookServiceImpl',
518
- 'notebookOpenInstallMissingViewType',
519
- "Install extension for '{0}'",
520
- viewType
521
- )), run: async () => {
522
- await this._instantiationService.createInstance(InstallRecommendedExtensionAction, knownProvider).run();
523
- }
524
- })
525
- ] : [];
526
- throw createErrorWithActions(`UNKNOWN notebook type '${viewType}'`, actions);
527
- }
528
- await this.canResolve(selected.id);
529
- const result = this._notebookProviders.get(selected.id);
530
- if (!result) {
531
- throw new Error(`NO provider registered for view type: '${selected.id}'`);
532
- }
533
- return result;
534
- }
535
- _persistMementos() {
536
- this._memento.saveMemento();
537
- }
538
- getViewTypeProvider(viewType) {
539
- return this._viewTypeCache[viewType];
540
- }
541
- getRendererInfo(rendererId) {
542
- return this._notebookRenderersInfoStore.get(rendererId);
543
- }
544
- updateMimePreferredRenderer(viewType, mimeType, rendererId, otherMimetypes) {
545
- const info = this.notebookProviderInfoStore.get(viewType);
546
- if (info) {
547
- this._notebookRenderersInfoStore.setPreferred(info, mimeType, rendererId);
548
- }
549
- this._displayOrder.prioritize(mimeType, otherMimetypes);
550
- }
551
- saveMimeDisplayOrder(target) {
552
- this._configurationService.updateValue(NotebookSetting.displayOrder, this._displayOrder.toArray(), target);
553
- }
554
- getRenderers() {
555
- return this._notebookRenderersInfoStore.getAll();
556
- }
557
- *getStaticPreloads(viewType) {
558
- for (const preload of this._notebookStaticPreloadInfoStore) {
559
- if (preload.type === viewType) {
560
- yield preload;
561
- }
562
- }
563
- }
564
- createNotebookTextModel(viewType, uri, data, transientOptions) {
565
- if (( this._models.has(uri))) {
566
- throw new Error(`notebook for ${uri} already exists`);
567
- }
568
- const notebookModel = this._instantiationService.createInstance(NotebookTextModel, viewType, uri, data.cells, data.metadata, transientOptions);
569
- const modelData = ( new ModelData(notebookModel, this._onWillDisposeDocument.bind(this)));
570
- this._models.set(uri, modelData);
571
- this._notebookDocumentService.addNotebookDocument(modelData);
572
- this._onWillAddNotebookDocument.fire(notebookModel);
573
- this._onDidAddNotebookDocument.fire(notebookModel);
574
- this._postDocumentOpenActivation(viewType);
575
- return notebookModel;
576
- }
577
- getNotebookTextModel(uri) {
578
- return this._models.get(uri)?.model;
579
- }
580
- getNotebookTextModels() {
581
- return ( Iterable.map(( this._models.values()), data => data.model));
582
- }
583
- listNotebookDocuments() {
584
- return ( [...this._models].map(e => e[1].model));
585
- }
586
- _onWillDisposeDocument(model) {
587
- const modelData = this._models.get(model.uri);
588
- if (modelData) {
589
- this._onWillRemoveNotebookDocument.fire(modelData.model);
590
- this._models.delete(model.uri);
591
- this._notebookDocumentService.removeNotebookDocument(modelData);
592
- modelData.dispose();
593
- this._onDidRemoveNotebookDocument.fire(modelData.model);
594
- }
595
- }
596
- getOutputMimeTypeInfo(textModel, kernelProvides, output) {
597
- const sorted = this._displayOrder.sort(( new Set(( output.outputs.map(op => op.mime)))));
598
- const notebookProviderInfo = this.notebookProviderInfoStore.get(textModel.viewType);
599
- return sorted
600
- .flatMap(mimeType => this._notebookRenderersInfoStore.findBestRenderers(notebookProviderInfo, mimeType, kernelProvides))
601
- .sort((a, b) => (a.rendererId === RENDERER_NOT_AVAILABLE ? 1 : 0) - (b.rendererId === RENDERER_NOT_AVAILABLE ? 1 : 0));
602
- }
603
- getContributedNotebookTypes(resource) {
604
- if (resource) {
605
- return this.notebookProviderInfoStore.getContributedNotebook(resource);
606
- }
607
- return [...this.notebookProviderInfoStore];
608
- }
609
- getContributedNotebookType(viewType) {
610
- return this.notebookProviderInfoStore.get(viewType);
611
- }
612
- getNotebookProviderResourceRoots() {
613
- const ret = [];
614
- this._notebookProviders.forEach(val => {
615
- if (val.extensionData.location) {
616
- ret.push(URI.revive(val.extensionData.location));
617
- }
618
- });
619
- return ret;
620
- }
621
- setToCopy(items, isCopy) {
622
- this._cutItems = items;
623
- this._lastClipboardIsCopy = isCopy;
624
- }
625
- getToCopy() {
626
- if (this._cutItems) {
627
- return { items: this._cutItems, isCopy: this._lastClipboardIsCopy };
628
- }
629
- return undefined;
630
- }
631
- };
632
- NotebookService = NotebookService_1 = ( __decorate([
633
- ( __param(0, IExtensionService)),
634
- ( __param(1, IConfigurationService)),
635
- ( __param(2, IAccessibilityService)),
636
- ( __param(3, IInstantiationService)),
637
- ( __param(4, IStorageService)),
638
- ( __param(5, INotebookDocumentService))
639
- ], NotebookService));
640
-
641
- export { NotebookOutputRendererInfoStore, NotebookProviderInfoStore, NotebookService };