@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,103 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { isResourceDiffEditorInput } from 'vscode/vscode/vs/workbench/common/editor';
|
|
3
|
+
import { EditorModel } from 'vscode/vscode/vs/workbench/common/editor/editorModel';
|
|
4
|
+
import { DiffEditorInput } from 'vscode/vscode/vs/workbench/common/editor/diffEditorInput';
|
|
5
|
+
import { NotebookEditorInput } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
|
|
6
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
7
|
+
|
|
8
|
+
var NotebookDiffEditorInput_1;
|
|
9
|
+
class NotebookDiffEditorModel extends EditorModel {
|
|
10
|
+
constructor(original, modified) {
|
|
11
|
+
super();
|
|
12
|
+
this.original = original;
|
|
13
|
+
this.modified = modified;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
let NotebookDiffEditorInput = class NotebookDiffEditorInput extends DiffEditorInput {
|
|
17
|
+
static { NotebookDiffEditorInput_1 = this; }
|
|
18
|
+
static create(instantiationService, resource, name, description, originalResource, viewType) {
|
|
19
|
+
const original = NotebookEditorInput.getOrCreate(instantiationService, originalResource, undefined, viewType);
|
|
20
|
+
const modified = NotebookEditorInput.getOrCreate(instantiationService, resource, undefined, viewType);
|
|
21
|
+
return instantiationService.createInstance(NotebookDiffEditorInput_1, name, description, original, modified, viewType);
|
|
22
|
+
}
|
|
23
|
+
static { this.ID = 'workbench.input.diffNotebookInput'; }
|
|
24
|
+
get resource() {
|
|
25
|
+
return this.modified.resource;
|
|
26
|
+
}
|
|
27
|
+
get editorId() {
|
|
28
|
+
return this.viewType;
|
|
29
|
+
}
|
|
30
|
+
constructor(name, description, original, modified, viewType, editorService) {
|
|
31
|
+
super(name, description, original, modified, undefined, editorService);
|
|
32
|
+
this.original = original;
|
|
33
|
+
this.modified = modified;
|
|
34
|
+
this.viewType = viewType;
|
|
35
|
+
this._modifiedTextModel = null;
|
|
36
|
+
this._originalTextModel = null;
|
|
37
|
+
this._cachedModel = undefined;
|
|
38
|
+
}
|
|
39
|
+
get typeId() {
|
|
40
|
+
return NotebookDiffEditorInput_1.ID;
|
|
41
|
+
}
|
|
42
|
+
async resolve() {
|
|
43
|
+
const [originalEditorModel, modifiedEditorModel] = await Promise.all([
|
|
44
|
+
this.original.resolve(),
|
|
45
|
+
this.modified.resolve(),
|
|
46
|
+
]);
|
|
47
|
+
this._cachedModel?.dispose();
|
|
48
|
+
if (!modifiedEditorModel) {
|
|
49
|
+
throw new Error(`Fail to resolve modified editor model for resource ${this.modified.resource} with notebookType ${this.viewType}`);
|
|
50
|
+
}
|
|
51
|
+
if (!originalEditorModel) {
|
|
52
|
+
throw new Error(`Fail to resolve original editor model for resource ${this.original.resource} with notebookType ${this.viewType}`);
|
|
53
|
+
}
|
|
54
|
+
this._originalTextModel = originalEditorModel;
|
|
55
|
+
this._modifiedTextModel = modifiedEditorModel;
|
|
56
|
+
this._cachedModel = ( new NotebookDiffEditorModel(this._originalTextModel, this._modifiedTextModel));
|
|
57
|
+
return this._cachedModel;
|
|
58
|
+
}
|
|
59
|
+
toUntyped() {
|
|
60
|
+
const original = { resource: this.original.resource };
|
|
61
|
+
const modified = { resource: this.resource };
|
|
62
|
+
return {
|
|
63
|
+
original,
|
|
64
|
+
modified,
|
|
65
|
+
primary: modified,
|
|
66
|
+
secondary: original,
|
|
67
|
+
options: {
|
|
68
|
+
override: this.viewType
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
matches(otherInput) {
|
|
73
|
+
if (this === otherInput) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (otherInput instanceof NotebookDiffEditorInput_1) {
|
|
77
|
+
return this.modified.matches(otherInput.modified)
|
|
78
|
+
&& this.original.matches(otherInput.original)
|
|
79
|
+
&& this.viewType === otherInput.viewType;
|
|
80
|
+
}
|
|
81
|
+
if (isResourceDiffEditorInput(otherInput)) {
|
|
82
|
+
return this.modified.matches(otherInput.modified)
|
|
83
|
+
&& this.original.matches(otherInput.original)
|
|
84
|
+
&& this.editorId !== undefined
|
|
85
|
+
&& (this.editorId === otherInput.options?.override || otherInput.options?.override === undefined);
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
dispose() {
|
|
90
|
+
super.dispose();
|
|
91
|
+
this._cachedModel?.dispose();
|
|
92
|
+
this._cachedModel = undefined;
|
|
93
|
+
this.original.dispose();
|
|
94
|
+
this.modified.dispose();
|
|
95
|
+
this._originalTextModel = null;
|
|
96
|
+
this._modifiedTextModel = null;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
NotebookDiffEditorInput = NotebookDiffEditorInput_1 = ( __decorate([
|
|
100
|
+
( __param(5, IEditorService))
|
|
101
|
+
], NotebookDiffEditorInput));
|
|
102
|
+
|
|
103
|
+
export { NotebookDiffEditorInput };
|
package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
3
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
4
|
+
import { NotebookWorkingCopyTypeIdentifier, CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
5
|
+
import { NotebookFileWorkingCopyModelFactory, SimpleNotebookEditorModel } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorModel';
|
|
6
|
+
import { ReferenceCollection, DisposableStore, dispose, combinedDisposable, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
7
|
+
import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
|
|
8
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
9
|
+
import { Emitter, AsyncEmitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
10
|
+
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
11
|
+
import { IUriIdentityService } from 'monaco-editor/esm/vs/platform/uriIdentity/common/uriIdentity.js';
|
|
12
|
+
import { ResourceMap } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
13
|
+
import { FileWorkingCopyManager } from '../../../services/workingCopy/common/fileWorkingCopyManager.js';
|
|
14
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
15
|
+
import { NotebookProviderInfo } from './notebookProvider.js';
|
|
16
|
+
import { assertIsDefined } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
17
|
+
import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
|
|
18
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
19
|
+
|
|
20
|
+
let NotebookModelReferenceCollection = class NotebookModelReferenceCollection extends ReferenceCollection {
|
|
21
|
+
constructor(_instantiationService, _notebookService, _logService, _configurationService) {
|
|
22
|
+
super();
|
|
23
|
+
this._instantiationService = _instantiationService;
|
|
24
|
+
this._notebookService = _notebookService;
|
|
25
|
+
this._logService = _logService;
|
|
26
|
+
this._configurationService = _configurationService;
|
|
27
|
+
this._disposables = ( new DisposableStore());
|
|
28
|
+
this._workingCopyManagers = ( new Map());
|
|
29
|
+
this._modelListener = ( new Map());
|
|
30
|
+
this._onDidSaveNotebook = ( new Emitter());
|
|
31
|
+
this.onDidSaveNotebook = this._onDidSaveNotebook.event;
|
|
32
|
+
this._onDidChangeDirty = ( new Emitter());
|
|
33
|
+
this.onDidChangeDirty = this._onDidChangeDirty.event;
|
|
34
|
+
this._dirtyStates = ( new ResourceMap());
|
|
35
|
+
this.modelsToDispose = ( new Set());
|
|
36
|
+
}
|
|
37
|
+
dispose() {
|
|
38
|
+
this._disposables.dispose();
|
|
39
|
+
this._onDidSaveNotebook.dispose();
|
|
40
|
+
this._onDidChangeDirty.dispose();
|
|
41
|
+
dispose(( this._modelListener.values()));
|
|
42
|
+
dispose(( this._workingCopyManagers.values()));
|
|
43
|
+
}
|
|
44
|
+
isDirty(resource) {
|
|
45
|
+
return this._dirtyStates.get(resource) ?? false;
|
|
46
|
+
}
|
|
47
|
+
async createReferencedObject(key, viewType, hasAssociatedFilePath) {
|
|
48
|
+
this.modelsToDispose.delete(key);
|
|
49
|
+
const uri = ( URI.parse(key));
|
|
50
|
+
const workingCopyTypeId = NotebookWorkingCopyTypeIdentifier.create(viewType);
|
|
51
|
+
let workingCopyManager = this._workingCopyManagers.get(workingCopyTypeId);
|
|
52
|
+
if (!workingCopyManager) {
|
|
53
|
+
const factory = ( new NotebookFileWorkingCopyModelFactory(viewType, this._notebookService, this._configurationService));
|
|
54
|
+
workingCopyManager = this._instantiationService.createInstance(FileWorkingCopyManager, workingCopyTypeId, factory, factory);
|
|
55
|
+
this._workingCopyManagers.set(workingCopyTypeId, workingCopyManager);
|
|
56
|
+
}
|
|
57
|
+
const model = this._instantiationService.createInstance(SimpleNotebookEditorModel, uri, hasAssociatedFilePath, viewType, workingCopyManager);
|
|
58
|
+
const result = await model.load();
|
|
59
|
+
let onDirtyAutoReference;
|
|
60
|
+
this._modelListener.set(result, combinedDisposable(result.onDidSave(() => this._onDidSaveNotebook.fire(result.resource)), result.onDidChangeDirty(() => {
|
|
61
|
+
const isDirty = result.isDirty();
|
|
62
|
+
this._dirtyStates.set(result.resource, isDirty);
|
|
63
|
+
if (isDirty && !onDirtyAutoReference) {
|
|
64
|
+
onDirtyAutoReference = this.acquire(key, viewType);
|
|
65
|
+
}
|
|
66
|
+
else if (onDirtyAutoReference) {
|
|
67
|
+
onDirtyAutoReference.dispose();
|
|
68
|
+
onDirtyAutoReference = undefined;
|
|
69
|
+
}
|
|
70
|
+
this._onDidChangeDirty.fire(result);
|
|
71
|
+
}), toDisposable(() => onDirtyAutoReference?.dispose())));
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
destroyReferencedObject(key, object) {
|
|
75
|
+
this.modelsToDispose.add(key);
|
|
76
|
+
(async () => {
|
|
77
|
+
try {
|
|
78
|
+
const model = await object;
|
|
79
|
+
if (!( this.modelsToDispose.has(key))) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (model instanceof SimpleNotebookEditorModel) {
|
|
83
|
+
await model.canDispose();
|
|
84
|
+
}
|
|
85
|
+
if (!( this.modelsToDispose.has(key))) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this._modelListener.get(model)?.dispose();
|
|
89
|
+
this._modelListener.delete(model);
|
|
90
|
+
model.dispose();
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
this._logService.error('FAILED to destory notebook', err);
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
this.modelsToDispose.delete(key);
|
|
97
|
+
}
|
|
98
|
+
})();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
NotebookModelReferenceCollection = ( __decorate([
|
|
102
|
+
( __param(0, IInstantiationService)),
|
|
103
|
+
( __param(1, INotebookService)),
|
|
104
|
+
( __param(2, ILogService)),
|
|
105
|
+
( __param(3, IConfigurationService))
|
|
106
|
+
], NotebookModelReferenceCollection));
|
|
107
|
+
let NotebookModelResolverServiceImpl = class NotebookModelResolverServiceImpl {
|
|
108
|
+
constructor(instantiationService, _notebookService, _extensionService, _uriIdentService) {
|
|
109
|
+
this._notebookService = _notebookService;
|
|
110
|
+
this._extensionService = _extensionService;
|
|
111
|
+
this._uriIdentService = _uriIdentService;
|
|
112
|
+
this._onWillFailWithConflict = ( new AsyncEmitter());
|
|
113
|
+
this.onWillFailWithConflict = this._onWillFailWithConflict.event;
|
|
114
|
+
this._data = instantiationService.createInstance(NotebookModelReferenceCollection);
|
|
115
|
+
this.onDidSaveNotebook = this._data.onDidSaveNotebook;
|
|
116
|
+
this.onDidChangeDirty = this._data.onDidChangeDirty;
|
|
117
|
+
}
|
|
118
|
+
dispose() {
|
|
119
|
+
this._data.dispose();
|
|
120
|
+
}
|
|
121
|
+
isDirty(resource) {
|
|
122
|
+
return this._data.isDirty(resource);
|
|
123
|
+
}
|
|
124
|
+
async resolve(arg0, viewType) {
|
|
125
|
+
let resource;
|
|
126
|
+
let hasAssociatedFilePath = false;
|
|
127
|
+
if (URI.isUri(arg0)) {
|
|
128
|
+
resource = arg0;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (!arg0.untitledResource) {
|
|
132
|
+
const info = this._notebookService.getContributedNotebookType(assertIsDefined(viewType));
|
|
133
|
+
if (!info) {
|
|
134
|
+
throw new Error('UNKNOWN view type: ' + viewType);
|
|
135
|
+
}
|
|
136
|
+
const suffix = NotebookProviderInfo.possibleFileEnding(info.selectors) ?? '';
|
|
137
|
+
for (let counter = 1;; counter++) {
|
|
138
|
+
const candidate = ( URI.from(
|
|
139
|
+
{ scheme: Schemas.untitled, path: `Untitled-${counter}${suffix}`, query: viewType }
|
|
140
|
+
));
|
|
141
|
+
if (!this._notebookService.getNotebookTextModel(candidate)) {
|
|
142
|
+
resource = candidate;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (arg0.untitledResource.scheme === Schemas.untitled) {
|
|
148
|
+
resource = arg0.untitledResource;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
resource = arg0.untitledResource.with({ scheme: Schemas.untitled });
|
|
152
|
+
hasAssociatedFilePath = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (resource.scheme === CellUri.scheme) {
|
|
156
|
+
throw new Error(`CANNOT open a cell-uri as notebook. Tried with ${resource.toString()}`);
|
|
157
|
+
}
|
|
158
|
+
resource = this._uriIdentService.asCanonicalUri(resource);
|
|
159
|
+
const existingViewType = this._notebookService.getNotebookTextModel(resource)?.viewType;
|
|
160
|
+
if (!viewType) {
|
|
161
|
+
if (existingViewType) {
|
|
162
|
+
viewType = existingViewType;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
await this._extensionService.whenInstalledExtensionsRegistered();
|
|
166
|
+
const providers = this._notebookService.getContributedNotebookTypes(resource);
|
|
167
|
+
const exclusiveProvider = providers.find(provider => provider.exclusive);
|
|
168
|
+
viewType = exclusiveProvider?.id || providers[0]?.id;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (!viewType) {
|
|
172
|
+
throw new Error(`Missing viewType for '${resource}'`);
|
|
173
|
+
}
|
|
174
|
+
if (existingViewType && existingViewType !== viewType) {
|
|
175
|
+
await this._onWillFailWithConflict.fireAsync({ resource, viewType }, CancellationToken.None);
|
|
176
|
+
const existingViewType2 = this._notebookService.getNotebookTextModel(resource)?.viewType;
|
|
177
|
+
if (existingViewType2 && existingViewType2 !== viewType) {
|
|
178
|
+
throw new Error(`A notebook with view type '${existingViewType2}' already exists for '${resource}', CANNOT create another notebook with view type ${viewType}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const reference = this._data.acquire(( resource.toString()), viewType, hasAssociatedFilePath);
|
|
182
|
+
try {
|
|
183
|
+
const model = await reference.object;
|
|
184
|
+
return {
|
|
185
|
+
object: model,
|
|
186
|
+
dispose() { reference.dispose(); }
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
reference.dispose();
|
|
191
|
+
throw err;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
NotebookModelResolverServiceImpl = ( __decorate([
|
|
196
|
+
( __param(0, IInstantiationService)),
|
|
197
|
+
( __param(1, INotebookService)),
|
|
198
|
+
( __param(2, IExtensionService)),
|
|
199
|
+
( __param(3, IUriIdentityService))
|
|
200
|
+
], NotebookModelResolverServiceImpl));
|
|
201
|
+
|
|
202
|
+
export { NotebookModelResolverServiceImpl };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as glob from 'monaco-editor/esm/vs/base/common/glob.js';
|
|
2
|
+
import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
|
|
3
|
+
import { joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
4
|
+
|
|
5
|
+
class DependencyList {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
this.value = ( new Set(value));
|
|
8
|
+
this.defined = this.value.size > 0;
|
|
9
|
+
}
|
|
10
|
+
matches(available) {
|
|
11
|
+
return ( available.some(v => ( this.value.has(v))));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
class NotebookOutputRendererInfo {
|
|
15
|
+
constructor(descriptor) {
|
|
16
|
+
this.id = descriptor.id;
|
|
17
|
+
this.extensionId = descriptor.extension.identifier;
|
|
18
|
+
this.extensionLocation = descriptor.extension.extensionLocation;
|
|
19
|
+
this.isBuiltin = descriptor.extension.isBuiltin;
|
|
20
|
+
if (typeof descriptor.entrypoint === 'string') {
|
|
21
|
+
this.entrypoint = {
|
|
22
|
+
extends: undefined,
|
|
23
|
+
path: joinPath(this.extensionLocation, descriptor.entrypoint)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.entrypoint = {
|
|
28
|
+
extends: descriptor.entrypoint.extends,
|
|
29
|
+
path: joinPath(this.extensionLocation, descriptor.entrypoint.path)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
this.displayName = descriptor.displayName;
|
|
33
|
+
this.mimeTypes = descriptor.mimeTypes;
|
|
34
|
+
this.mimeTypeGlobs = ( this.mimeTypes.map(pattern => glob.parse(pattern)));
|
|
35
|
+
this.hardDependencies = ( new DependencyList(descriptor.dependencies ?? Iterable.empty()));
|
|
36
|
+
this.optionalDependencies = ( new DependencyList(descriptor.optionalDependencies ?? Iterable.empty()));
|
|
37
|
+
this.messaging = descriptor.requiresMessaging ?? "never" ;
|
|
38
|
+
}
|
|
39
|
+
matchesWithoutKernel(mimeType) {
|
|
40
|
+
if (!this.matchesMimeTypeOnly(mimeType)) {
|
|
41
|
+
return 3 ;
|
|
42
|
+
}
|
|
43
|
+
if (this.hardDependencies.defined) {
|
|
44
|
+
return 0 ;
|
|
45
|
+
}
|
|
46
|
+
if (this.optionalDependencies.defined) {
|
|
47
|
+
return 1 ;
|
|
48
|
+
}
|
|
49
|
+
return 2 ;
|
|
50
|
+
}
|
|
51
|
+
matches(mimeType, kernelProvides) {
|
|
52
|
+
if (!this.matchesMimeTypeOnly(mimeType)) {
|
|
53
|
+
return 3 ;
|
|
54
|
+
}
|
|
55
|
+
if (this.hardDependencies.defined) {
|
|
56
|
+
return this.hardDependencies.matches(kernelProvides)
|
|
57
|
+
? 0
|
|
58
|
+
: 3 ;
|
|
59
|
+
}
|
|
60
|
+
return this.optionalDependencies.matches(kernelProvides)
|
|
61
|
+
? 1
|
|
62
|
+
: 2 ;
|
|
63
|
+
}
|
|
64
|
+
matchesMimeTypeOnly(mimeType) {
|
|
65
|
+
if (this.entrypoint.extends) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return ( this.mimeTypeGlobs.some(pattern => pattern(mimeType))) || ( this.mimeTypes.some(pattern => pattern === mimeType));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
class NotebookStaticPreloadInfo {
|
|
72
|
+
constructor(descriptor) {
|
|
73
|
+
this.type = descriptor.type;
|
|
74
|
+
this.entrypoint = joinPath(descriptor.extension.extensionLocation, descriptor.entrypoint);
|
|
75
|
+
this.extensionLocation = descriptor.extension.extensionLocation;
|
|
76
|
+
this.localResourceRoots = ( descriptor.localResourceRoots.map(root => joinPath(descriptor.extension.extensionLocation, root)));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { NotebookOutputRendererInfo, NotebookStaticPreloadInfo };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as glob from 'monaco-editor/esm/vs/base/common/glob.js';
|
|
2
|
+
import { basename } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
3
|
+
import { isDocumentExcludePattern } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
4
|
+
|
|
5
|
+
class NotebookProviderInfo {
|
|
6
|
+
get selectors() {
|
|
7
|
+
return this._selectors;
|
|
8
|
+
}
|
|
9
|
+
get options() {
|
|
10
|
+
return this._options;
|
|
11
|
+
}
|
|
12
|
+
constructor(descriptor) {
|
|
13
|
+
this.extension = descriptor.extension;
|
|
14
|
+
this.id = descriptor.id;
|
|
15
|
+
this.displayName = descriptor.displayName;
|
|
16
|
+
this._selectors = descriptor.selectors?.map(selector => ({
|
|
17
|
+
include: selector.filenamePattern,
|
|
18
|
+
exclude: selector.excludeFileNamePattern || ''
|
|
19
|
+
})) || [];
|
|
20
|
+
this.priority = descriptor.priority;
|
|
21
|
+
this.providerDisplayName = descriptor.providerDisplayName;
|
|
22
|
+
this.exclusive = descriptor.exclusive;
|
|
23
|
+
this._options = {
|
|
24
|
+
transientCellMetadata: {},
|
|
25
|
+
transientDocumentMetadata: {},
|
|
26
|
+
transientOutputs: false,
|
|
27
|
+
cellContentMetadata: {}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
update(args) {
|
|
31
|
+
if (args.selectors) {
|
|
32
|
+
this._selectors = args.selectors;
|
|
33
|
+
}
|
|
34
|
+
if (args.options) {
|
|
35
|
+
this._options = args.options;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
matches(resource) {
|
|
39
|
+
return this.selectors?.some(selector => NotebookProviderInfo.selectorMatches(selector, resource));
|
|
40
|
+
}
|
|
41
|
+
static selectorMatches(selector, resource) {
|
|
42
|
+
if (typeof selector === 'string') {
|
|
43
|
+
if (glob.match(selector.toLowerCase(), basename(resource.fsPath).toLowerCase())) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (glob.isRelativePattern(selector)) {
|
|
48
|
+
if (glob.match(selector, basename(resource.fsPath).toLowerCase())) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!isDocumentExcludePattern(selector)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const filenamePattern = selector.include;
|
|
56
|
+
const excludeFilenamePattern = selector.exclude;
|
|
57
|
+
if (glob.match(filenamePattern, basename(resource.fsPath).toLowerCase())) {
|
|
58
|
+
if (excludeFilenamePattern) {
|
|
59
|
+
if (glob.match(excludeFilenamePattern, basename(resource.fsPath).toLowerCase())) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
static possibleFileEnding(selectors) {
|
|
68
|
+
for (const selector of selectors) {
|
|
69
|
+
const ending = NotebookProviderInfo._possibleFileEnding(selector);
|
|
70
|
+
if (ending) {
|
|
71
|
+
return ending;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
static _possibleFileEnding(selector) {
|
|
77
|
+
const pattern = /^.*(\.[a-zA-Z0-9_-]+)$/;
|
|
78
|
+
let candidate;
|
|
79
|
+
if (typeof selector === 'string') {
|
|
80
|
+
candidate = selector;
|
|
81
|
+
}
|
|
82
|
+
else if (glob.isRelativePattern(selector)) {
|
|
83
|
+
candidate = selector.pattern;
|
|
84
|
+
}
|
|
85
|
+
else if (selector.include) {
|
|
86
|
+
return NotebookProviderInfo._possibleFileEnding(selector.include);
|
|
87
|
+
}
|
|
88
|
+
if (candidate) {
|
|
89
|
+
const match = pattern.exec(candidate);
|
|
90
|
+
if (match) {
|
|
91
|
+
return match[1];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { NotebookProviderInfo };
|