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