@codingame/monaco-vscode-extensions-service-override 4.0.0 → 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.
- package/extensions.js +6 -6
- package/package.json +9 -9
- package/_virtual/semver.js +0 -3
- package/external/vscode-semver/semver.js +0 -985
- package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +0 -8
- package/vscode/src/vs/base/common/console.js +0 -62
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagementCLI.js +0 -497
- package/vscode/src/vs/platform/extensionResourceLoader/browser/extensionResourceLoaderService.js +0 -44
- package/vscode/src/vs/platform/lifecycle/common/lifecycle.js +0 -27
- package/vscode/src/vs/platform/remote/common/managedSocket.js +0 -98
- package/vscode/src/vs/workbench/api/browser/extensionHost.contribution.js +0 -104
- package/vscode/src/vs/workbench/api/browser/mainThreadAiEmbeddingVector.js +0 -31
- package/vscode/src/vs/workbench/api/browser/mainThreadAiRelatedInformation.js +0 -35
- package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +0 -254
- package/vscode/src/vs/workbench/api/browser/mainThreadBulkEdits.js +0 -68
- package/vscode/src/vs/workbench/api/browser/mainThreadCLICommands.js +0 -103
- package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +0 -70
- package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +0 -207
- package/vscode/src/vs/workbench/api/browser/mainThreadChatVariables.js +0 -41
- package/vscode/src/vs/workbench/api/browser/mainThreadClipboard.js +0 -24
- package/vscode/src/vs/workbench/api/browser/mainThreadCodeInsets.js +0 -108
- package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +0 -98
- package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +0 -560
- package/vscode/src/vs/workbench/api/browser/mainThreadConfiguration.js +0 -80
- package/vscode/src/vs/workbench/api/browser/mainThreadConsole.js +0 -35
- package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +0 -579
- package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +0 -435
- package/vscode/src/vs/workbench/api/browser/mainThreadDecorations.js +0 -102
- package/vscode/src/vs/workbench/api/browser/mainThreadDiagnostics.js +0 -69
- package/vscode/src/vs/workbench/api/browser/mainThreadDialogs.js +0 -68
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentContentProviders.js +0 -79
- package/vscode/src/vs/workbench/api/browser/mainThreadDocuments.js +0 -253
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +0 -370
- package/vscode/src/vs/workbench/api/browser/mainThreadDownloadService.js +0 -22
- package/vscode/src/vs/workbench/api/browser/mainThreadEditSessionIdentityParticipant.js +0 -41
- package/vscode/src/vs/workbench/api/browser/mainThreadEditor.js +0 -414
- package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +0 -501
- package/vscode/src/vs/workbench/api/browser/mainThreadEditors.js +0 -227
- package/vscode/src/vs/workbench/api/browser/mainThreadErrors.js +0 -24
- package/vscode/src/vs/workbench/api/browser/mainThreadExtensionService.js +0 -317
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +0 -208
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +0 -369
- package/vscode/src/vs/workbench/api/browser/mainThreadInlineChat.js +0 -72
- package/vscode/src/vs/workbench/api/browser/mainThreadInteractive.js +0 -28
- package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +0 -50
- package/vscode/src/vs/workbench/api/browser/mainThreadLabelService.js +0 -27
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +0 -1016
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguageModels.js +0 -185
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguages.js +0 -78
- package/vscode/src/vs/workbench/api/browser/mainThreadLocalization.js +0 -35
- package/vscode/src/vs/workbench/api/browser/mainThreadLogService.js +0 -78
- package/vscode/src/vs/workbench/api/browser/mainThreadManagedSockets.js +0 -93
- package/vscode/src/vs/workbench/api/browser/mainThreadMessageService.js +0 -137
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +0 -194
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +0 -123
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +0 -188
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDto.js +0 -129
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +0 -131
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +0 -374
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +0 -25
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +0 -48
- package/vscode/src/vs/workbench/api/browser/mainThreadOutputService.js +0 -76
- package/vscode/src/vs/workbench/api/browser/mainThreadProfileContentHandlers.js +0 -38
- package/vscode/src/vs/workbench/api/browser/mainThreadProgress.js +0 -68
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickDiff.js +0 -42
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickOpen.js +0 -185
- package/vscode/src/vs/workbench/api/browser/mainThreadRemoteConnectionData.js +0 -30
- package/vscode/src/vs/workbench/api/browser/mainThreadSCM.js +0 -493
- package/vscode/src/vs/workbench/api/browser/mainThreadSaveParticipant.js +0 -49
- package/vscode/src/vs/workbench/api/browser/mainThreadSearch.js +0 -168
- package/vscode/src/vs/workbench/api/browser/mainThreadSecretState.js +0 -70
- package/vscode/src/vs/workbench/api/browser/mainThreadShare.js +0 -50
- package/vscode/src/vs/workbench/api/browser/mainThreadSpeech.js +0 -99
- package/vscode/src/vs/workbench/api/browser/mainThreadStatusBar.js +0 -53
- package/vscode/src/vs/workbench/api/browser/mainThreadStorage.js +0 -72
- package/vscode/src/vs/workbench/api/browser/mainThreadTask.js +0 -731
- package/vscode/src/vs/workbench/api/browser/mainThreadTelemetry.js +0 -53
- package/vscode/src/vs/workbench/api/browser/mainThreadTerminalService.js +0 -409
- package/vscode/src/vs/workbench/api/browser/mainThreadTerminalShellIntegration.js +0 -51
- package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +0 -219
- package/vscode/src/vs/workbench/api/browser/mainThreadTheming.js +0 -24
- package/vscode/src/vs/workbench/api/browser/mainThreadTimeline.js +0 -55
- package/vscode/src/vs/workbench/api/browser/mainThreadTreeViews.js +0 -312
- package/vscode/src/vs/workbench/api/browser/mainThreadTunnelService.js +0 -223
- package/vscode/src/vs/workbench/api/browser/mainThreadUriOpeners.js +0 -110
- package/vscode/src/vs/workbench/api/browser/mainThreadUrls.js +0 -61
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewManager.js +0 -29
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewPanels.js +0 -283
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewViews.js +0 -100
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviews.js +0 -135
- package/vscode/src/vs/workbench/api/browser/mainThreadWindow.js +0 -57
- package/vscode/src/vs/workbench/api/browser/mainThreadWorkspace.js +0 -268
- package/vscode/src/vs/workbench/api/common/shared/dataTransferCache.js +0 -35
- package/vscode/src/vs/workbench/contrib/customEditor/common/customTextEditorModel.js +0 -76
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/contributedOpeners.js +0 -83
- package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +0 -285
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +0 -276
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerFileSystemProvider.js +0 -52
- package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +0 -1149
- package/vscode/src/vs/workbench/services/extensions/common/extHostCustomers.js +0 -41
- package/vscode/src/vs/workbench/services/extensions/common/extensionDevOptions.js +0 -25
- package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +0 -512
- package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.js +0 -274
- package/vscode/src/vs/workbench/services/extensions/common/extensionStorageMigration.js +0 -58
- package/vscode/src/vs/workbench/services/extensions/common/extensionsProposedApi.js +0 -80
- package/vscode/src/vs/workbench/services/extensions/common/extensionsUtil.js +0 -64
- package/vscode/src/vs/workbench/services/extensions/common/lazyCreateExtensionHostManager.js +0 -161
- package/vscode/src/vs/workbench/services/extensions/common/remoteConsoleUtil.js +0 -49
- package/vscode/src/vs/workbench/services/extensions/common/remoteExtensionHost.js +0 -222
|
@@ -1,579 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { multibyteAwareBtoa } from 'vscode/vscode/vs/base/browser/dom';
|
|
3
|
-
import { createCancelablePromise } from 'vscode/vscode/vs/base/common/async';
|
|
4
|
-
import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
|
|
5
|
-
import { onUnexpectedError, isCancellationError } from 'vscode/vscode/vs/base/common/errors';
|
|
6
|
-
import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
|
|
7
|
-
import { Disposable, DisposableMap, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
|
-
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
9
|
-
import { basename } from 'vscode/vscode/vs/base/common/path';
|
|
10
|
-
import { isEqualOrParent, isEqual, toLocalResource } from 'vscode/vscode/vs/base/common/resources';
|
|
11
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
12
|
-
import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
|
|
13
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
14
|
-
import '../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
15
|
-
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
16
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
17
|
-
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
|
|
18
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
19
|
-
import { IUndoRedoService } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo';
|
|
20
|
-
import { reviveWebviewExtension } from './mainThreadWebviews.js';
|
|
21
|
-
import { ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
22
|
-
import { CustomEditorInput } from 'vscode/vscode/vs/workbench/contrib/customEditor/browser/customEditorInput';
|
|
23
|
-
import { ICustomEditorService } from 'vscode/vscode/vs/workbench/contrib/customEditor/common/customEditor';
|
|
24
|
-
import { CustomTextEditorModel } from '../../contrib/customEditor/common/customTextEditorModel.js';
|
|
25
|
-
import { ExtensionKeyedWebviewOriginStore } from 'vscode/vscode/vs/workbench/contrib/webview/browser/webview';
|
|
26
|
-
import { IWebviewWorkbenchService } from 'vscode/vscode/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService';
|
|
27
|
-
import { editorGroupToColumn } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupColumn';
|
|
28
|
-
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
29
|
-
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
30
|
-
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
|
|
31
|
-
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
32
|
-
import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService';
|
|
33
|
-
import { ResourceWorkingCopy } from 'vscode/vscode/vs/workbench/services/workingCopy/common/resourceWorkingCopy';
|
|
34
|
-
import { NO_TYPE_ID } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopy';
|
|
35
|
-
import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService';
|
|
36
|
-
import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
|
|
37
|
-
import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
38
|
-
|
|
39
|
-
var MainThreadCustomEditorModel_1;
|
|
40
|
-
let MainThreadCustomEditors = class MainThreadCustomEditors extends Disposable {
|
|
41
|
-
constructor(context, mainThreadWebview, mainThreadWebviewPanels, extensionService, storageService, workingCopyService, workingCopyFileService, _customEditorService, _editorGroupService, _editorService, _instantiationService, _webviewWorkbenchService) {
|
|
42
|
-
super();
|
|
43
|
-
this.mainThreadWebview = mainThreadWebview;
|
|
44
|
-
this.mainThreadWebviewPanels = mainThreadWebviewPanels;
|
|
45
|
-
this._customEditorService = _customEditorService;
|
|
46
|
-
this._editorGroupService = _editorGroupService;
|
|
47
|
-
this._editorService = _editorService;
|
|
48
|
-
this._instantiationService = _instantiationService;
|
|
49
|
-
this._webviewWorkbenchService = _webviewWorkbenchService;
|
|
50
|
-
this._editorProviders = this._register(( new DisposableMap()));
|
|
51
|
-
this._editorRenameBackups = ( new Map());
|
|
52
|
-
this._webviewOriginStore = ( new ExtensionKeyedWebviewOriginStore('mainThreadCustomEditors.origins', storageService));
|
|
53
|
-
this._proxyCustomEditors = ( context.getProxy(ExtHostContext.ExtHostCustomEditors));
|
|
54
|
-
this._register(workingCopyFileService.registerWorkingCopyProvider((editorResource) => {
|
|
55
|
-
const matchedWorkingCopies = [];
|
|
56
|
-
for (const workingCopy of workingCopyService.workingCopies) {
|
|
57
|
-
if (workingCopy instanceof MainThreadCustomEditorModel) {
|
|
58
|
-
if (isEqualOrParent(editorResource, workingCopy.editorResource)) {
|
|
59
|
-
matchedWorkingCopies.push(workingCopy);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return matchedWorkingCopies;
|
|
64
|
-
}));
|
|
65
|
-
this._register(_webviewWorkbenchService.registerResolver({
|
|
66
|
-
canResolve: (webview) => {
|
|
67
|
-
if (webview instanceof CustomEditorInput) {
|
|
68
|
-
extensionService.activateByEvent(`onCustomEditor:${webview.viewType}`);
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
|
-
},
|
|
72
|
-
resolveWebview: () => { throw new Error('not implemented'); }
|
|
73
|
-
}));
|
|
74
|
-
this._register(workingCopyFileService.onWillRunWorkingCopyFileOperation(async (e) => this.onWillRunWorkingCopyFileOperation(e)));
|
|
75
|
-
}
|
|
76
|
-
$registerTextEditorProvider(extensionData, viewType, options, capabilities, serializeBuffersForPostMessage) {
|
|
77
|
-
this.registerEditorProvider(1 , reviveWebviewExtension(extensionData), viewType, options, capabilities, true, serializeBuffersForPostMessage);
|
|
78
|
-
}
|
|
79
|
-
$registerCustomEditorProvider(extensionData, viewType, options, supportsMultipleEditorsPerDocument, serializeBuffersForPostMessage) {
|
|
80
|
-
this.registerEditorProvider(0 , reviveWebviewExtension(extensionData), viewType, options, {}, supportsMultipleEditorsPerDocument, serializeBuffersForPostMessage);
|
|
81
|
-
}
|
|
82
|
-
registerEditorProvider(modelType, extension, viewType, options, capabilities, supportsMultipleEditorsPerDocument, serializeBuffersForPostMessage) {
|
|
83
|
-
if (( this._editorProviders.has(viewType))) {
|
|
84
|
-
throw new Error(`Provider for ${viewType} already registered`);
|
|
85
|
-
}
|
|
86
|
-
const disposables = ( new DisposableStore());
|
|
87
|
-
disposables.add(this._customEditorService.registerCustomEditorCapabilities(viewType, {
|
|
88
|
-
supportsMultipleEditorsPerDocument
|
|
89
|
-
}));
|
|
90
|
-
disposables.add(this._webviewWorkbenchService.registerResolver({
|
|
91
|
-
canResolve: (webviewInput) => {
|
|
92
|
-
return webviewInput instanceof CustomEditorInput && webviewInput.viewType === viewType;
|
|
93
|
-
},
|
|
94
|
-
resolveWebview: async (webviewInput, cancellation) => {
|
|
95
|
-
const handle = generateUuid();
|
|
96
|
-
const resource = webviewInput.resource;
|
|
97
|
-
webviewInput.webview.origin = this._webviewOriginStore.getOrigin(viewType, extension.id);
|
|
98
|
-
this.mainThreadWebviewPanels.addWebviewInput(handle, webviewInput, { serializeBuffersForPostMessage });
|
|
99
|
-
webviewInput.webview.options = options;
|
|
100
|
-
webviewInput.webview.extension = extension;
|
|
101
|
-
let backupId = webviewInput.backupId;
|
|
102
|
-
if (webviewInput.oldResource && !webviewInput.backupId) {
|
|
103
|
-
const backup = this._editorRenameBackups.get(( webviewInput.oldResource.toString()));
|
|
104
|
-
backupId = backup?.backupId;
|
|
105
|
-
this._editorRenameBackups.delete(( webviewInput.oldResource.toString()));
|
|
106
|
-
}
|
|
107
|
-
let modelRef;
|
|
108
|
-
try {
|
|
109
|
-
modelRef = await this.getOrCreateCustomEditorModel(modelType, resource, viewType, { backupId }, cancellation);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
onUnexpectedError(error);
|
|
113
|
-
webviewInput.webview.setHtml(this.mainThreadWebview.getWebviewResolvedFailedContent(viewType));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (cancellation.isCancellationRequested) {
|
|
117
|
-
modelRef.dispose();
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
webviewInput.webview.onDidDispose(() => {
|
|
121
|
-
if (modelRef.object.isDirty()) {
|
|
122
|
-
const sub = modelRef.object.onDidChangeDirty(() => {
|
|
123
|
-
if (!modelRef.object.isDirty()) {
|
|
124
|
-
sub.dispose();
|
|
125
|
-
modelRef.dispose();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
modelRef.dispose();
|
|
131
|
-
});
|
|
132
|
-
if (capabilities.supportsMove) {
|
|
133
|
-
webviewInput.onMove(async (newResource) => {
|
|
134
|
-
const oldModel = modelRef;
|
|
135
|
-
modelRef = await this.getOrCreateCustomEditorModel(modelType, newResource, viewType, {}, CancellationToken.None);
|
|
136
|
-
this._proxyCustomEditors.$onMoveCustomEditor(handle, newResource, viewType);
|
|
137
|
-
oldModel.dispose();
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
await this._proxyCustomEditors.$resolveCustomEditor(resource, handle, viewType, {
|
|
142
|
-
title: webviewInput.getTitle(),
|
|
143
|
-
contentOptions: webviewInput.webview.contentOptions,
|
|
144
|
-
options: webviewInput.webview.options,
|
|
145
|
-
active: webviewInput === this._editorService.activeEditor,
|
|
146
|
-
}, editorGroupToColumn(this._editorGroupService, webviewInput.group || 0), cancellation);
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
onUnexpectedError(error);
|
|
150
|
-
webviewInput.webview.setHtml(this.mainThreadWebview.getWebviewResolvedFailedContent(viewType));
|
|
151
|
-
modelRef.dispose();
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}));
|
|
156
|
-
this._editorProviders.set(viewType, disposables);
|
|
157
|
-
}
|
|
158
|
-
$unregisterEditorProvider(viewType) {
|
|
159
|
-
if (!( this._editorProviders.has(viewType))) {
|
|
160
|
-
throw new Error(`No provider for ${viewType} registered`);
|
|
161
|
-
}
|
|
162
|
-
this._editorProviders.deleteAndDispose(viewType);
|
|
163
|
-
this._customEditorService.models.disposeAllModelsForView(viewType);
|
|
164
|
-
}
|
|
165
|
-
async getOrCreateCustomEditorModel(modelType, resource, viewType, options, cancellation) {
|
|
166
|
-
const existingModel = this._customEditorService.models.tryRetain(resource, viewType);
|
|
167
|
-
if (existingModel) {
|
|
168
|
-
return existingModel;
|
|
169
|
-
}
|
|
170
|
-
switch (modelType) {
|
|
171
|
-
case 1 :
|
|
172
|
-
{
|
|
173
|
-
const model = CustomTextEditorModel.create(this._instantiationService, viewType, resource);
|
|
174
|
-
return this._customEditorService.models.add(resource, viewType, model);
|
|
175
|
-
}
|
|
176
|
-
case 0 :
|
|
177
|
-
{
|
|
178
|
-
const model = MainThreadCustomEditorModel.create(this._instantiationService, this._proxyCustomEditors, viewType, resource, options, () => {
|
|
179
|
-
return Array.from(this.mainThreadWebviewPanels.webviewInputs)
|
|
180
|
-
.filter(editor => editor instanceof CustomEditorInput && isEqual(editor.resource, resource));
|
|
181
|
-
}, cancellation);
|
|
182
|
-
return this._customEditorService.models.add(resource, viewType, model);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async $onDidEdit(resourceComponents, viewType, editId, label) {
|
|
187
|
-
const model = await this.getCustomEditorModel(resourceComponents, viewType);
|
|
188
|
-
model.pushEdit(editId, label);
|
|
189
|
-
}
|
|
190
|
-
async $onContentChange(resourceComponents, viewType) {
|
|
191
|
-
const model = await this.getCustomEditorModel(resourceComponents, viewType);
|
|
192
|
-
model.changeContent();
|
|
193
|
-
}
|
|
194
|
-
async getCustomEditorModel(resourceComponents, viewType) {
|
|
195
|
-
const resource = URI.revive(resourceComponents);
|
|
196
|
-
const model = await this._customEditorService.models.get(resource, viewType);
|
|
197
|
-
if (!model || !(model instanceof MainThreadCustomEditorModel)) {
|
|
198
|
-
throw new Error('Could not find model for webview editor');
|
|
199
|
-
}
|
|
200
|
-
return model;
|
|
201
|
-
}
|
|
202
|
-
async onWillRunWorkingCopyFileOperation(e) {
|
|
203
|
-
if (e.operation !== 2 ) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
e.waitUntil((async () => {
|
|
207
|
-
const models = [];
|
|
208
|
-
for (const file of e.files) {
|
|
209
|
-
if (file.source) {
|
|
210
|
-
models.push(...(await this._customEditorService.models.getAllModels(file.source)));
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
for (const model of models) {
|
|
214
|
-
if (model instanceof MainThreadCustomEditorModel && model.isDirty()) {
|
|
215
|
-
const workingCopy = await model.backup(CancellationToken.None);
|
|
216
|
-
if (workingCopy.meta) {
|
|
217
|
-
this._editorRenameBackups.set(( model.editorResource.toString()), workingCopy.meta);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
})());
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
MainThreadCustomEditors = ( __decorate([
|
|
225
|
-
( __param(3, IExtensionService)),
|
|
226
|
-
( __param(4, IStorageService)),
|
|
227
|
-
( __param(5, IWorkingCopyService)),
|
|
228
|
-
( __param(6, IWorkingCopyFileService)),
|
|
229
|
-
( __param(7, ICustomEditorService)),
|
|
230
|
-
( __param(8, IEditorGroupsService)),
|
|
231
|
-
( __param(9, IEditorService)),
|
|
232
|
-
( __param(10, IInstantiationService)),
|
|
233
|
-
( __param(11, IWebviewWorkbenchService))
|
|
234
|
-
], MainThreadCustomEditors));
|
|
235
|
-
var HotExitState;
|
|
236
|
-
( (function(HotExitState) {
|
|
237
|
-
( (function(Type) {
|
|
238
|
-
Type[Type["Allowed"] = 0] = "Allowed";
|
|
239
|
-
Type[Type["NotAllowed"] = 1] = "NotAllowed";
|
|
240
|
-
Type[Type["Pending"] = 2] = "Pending";
|
|
241
|
-
})(HotExitState.Type || (HotExitState.Type = {})));
|
|
242
|
-
HotExitState.Allowed = ( Object.freeze({ type: 0 }));
|
|
243
|
-
HotExitState.NotAllowed = ( Object.freeze({ type: 1 }));
|
|
244
|
-
class Pending {
|
|
245
|
-
constructor(operation) {
|
|
246
|
-
this.operation = operation;
|
|
247
|
-
this.type = 2 ;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
HotExitState.Pending = Pending;
|
|
251
|
-
})(HotExitState || (HotExitState = {})));
|
|
252
|
-
let MainThreadCustomEditorModel = MainThreadCustomEditorModel_1 = class MainThreadCustomEditorModel extends ResourceWorkingCopy {
|
|
253
|
-
static async create(instantiationService, proxy, viewType, resource, options, getEditors, cancellation) {
|
|
254
|
-
const editors = getEditors();
|
|
255
|
-
let untitledDocumentData;
|
|
256
|
-
if (editors.length !== 0) {
|
|
257
|
-
untitledDocumentData = editors[0].untitledDocumentData;
|
|
258
|
-
}
|
|
259
|
-
const { editable } = await proxy.$createCustomDocument(resource, viewType, options.backupId, untitledDocumentData, cancellation);
|
|
260
|
-
return instantiationService.createInstance(MainThreadCustomEditorModel_1, proxy, viewType, resource, !!options.backupId, editable, !!untitledDocumentData, getEditors);
|
|
261
|
-
}
|
|
262
|
-
constructor(_proxy, _viewType, _editorResource, fromBackup, _editable, startDirty, _getEditors, _fileDialogService, fileService, _labelService, _undoService, _environmentService, workingCopyService, _pathService, extensionService) {
|
|
263
|
-
super(MainThreadCustomEditorModel_1.toWorkingCopyResource(_viewType, _editorResource), fileService);
|
|
264
|
-
this._proxy = _proxy;
|
|
265
|
-
this._viewType = _viewType;
|
|
266
|
-
this._editorResource = _editorResource;
|
|
267
|
-
this._editable = _editable;
|
|
268
|
-
this._getEditors = _getEditors;
|
|
269
|
-
this._fileDialogService = _fileDialogService;
|
|
270
|
-
this._labelService = _labelService;
|
|
271
|
-
this._undoService = _undoService;
|
|
272
|
-
this._environmentService = _environmentService;
|
|
273
|
-
this._pathService = _pathService;
|
|
274
|
-
this._fromBackup = false;
|
|
275
|
-
this._hotExitState = HotExitState.Allowed;
|
|
276
|
-
this._currentEditIndex = -1;
|
|
277
|
-
this._savePoint = -1;
|
|
278
|
-
this._edits = [];
|
|
279
|
-
this._isDirtyFromContentChange = false;
|
|
280
|
-
this.typeId = NO_TYPE_ID;
|
|
281
|
-
this._onDidChangeDirty = this._register(( new Emitter()));
|
|
282
|
-
this.onDidChangeDirty = this._onDidChangeDirty.event;
|
|
283
|
-
this._onDidChangeContent = this._register(( new Emitter()));
|
|
284
|
-
this.onDidChangeContent = this._onDidChangeContent.event;
|
|
285
|
-
this._onDidSave = this._register(( new Emitter()));
|
|
286
|
-
this.onDidSave = this._onDidSave.event;
|
|
287
|
-
this.onDidChangeReadonly = Event.None;
|
|
288
|
-
this._fromBackup = fromBackup;
|
|
289
|
-
if (_editable) {
|
|
290
|
-
this._register(workingCopyService.registerWorkingCopy(this));
|
|
291
|
-
this._register(extensionService.onWillStop(e => {
|
|
292
|
-
if (!this.isDirty()) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
e.veto((async () => {
|
|
296
|
-
const didSave = await this.save();
|
|
297
|
-
if (!didSave) {
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
return false;
|
|
301
|
-
})(), ( localizeWithPath(
|
|
302
|
-
'vs/workbench/api/browser/mainThreadCustomEditors',
|
|
303
|
-
'vetoExtHostRestart',
|
|
304
|
-
"Custom editor '{0}' could not be saved.",
|
|
305
|
-
this.name
|
|
306
|
-
)));
|
|
307
|
-
}));
|
|
308
|
-
}
|
|
309
|
-
if (startDirty) {
|
|
310
|
-
this._isDirtyFromContentChange = true;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
get editorResource() {
|
|
314
|
-
return this._editorResource;
|
|
315
|
-
}
|
|
316
|
-
dispose() {
|
|
317
|
-
if (this._editable) {
|
|
318
|
-
this._undoService.removeElements(this._editorResource);
|
|
319
|
-
}
|
|
320
|
-
this._proxy.$disposeCustomDocument(this._editorResource, this._viewType);
|
|
321
|
-
super.dispose();
|
|
322
|
-
}
|
|
323
|
-
static toWorkingCopyResource(viewType, resource) {
|
|
324
|
-
const authority = viewType.replace(/[^a-z0-9\-_]/gi, '-');
|
|
325
|
-
const path = `/${multibyteAwareBtoa(( resource.with({ query: null, fragment: null }).toString(true)))}`;
|
|
326
|
-
return ( URI.from({
|
|
327
|
-
scheme: Schemas.vscodeCustomEditor,
|
|
328
|
-
authority: authority,
|
|
329
|
-
path: path,
|
|
330
|
-
query: JSON.stringify(resource.toJSON()),
|
|
331
|
-
}));
|
|
332
|
-
}
|
|
333
|
-
get name() {
|
|
334
|
-
return basename(this._labelService.getUriLabel(this._editorResource));
|
|
335
|
-
}
|
|
336
|
-
get capabilities() {
|
|
337
|
-
return this.isUntitled() ? 2 : 0 ;
|
|
338
|
-
}
|
|
339
|
-
isDirty() {
|
|
340
|
-
if (this._isDirtyFromContentChange) {
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
if (this._edits.length > 0) {
|
|
344
|
-
return this._savePoint !== this._currentEditIndex;
|
|
345
|
-
}
|
|
346
|
-
return this._fromBackup;
|
|
347
|
-
}
|
|
348
|
-
isUntitled() {
|
|
349
|
-
return this._editorResource.scheme === Schemas.untitled;
|
|
350
|
-
}
|
|
351
|
-
isReadonly() {
|
|
352
|
-
return !this._editable;
|
|
353
|
-
}
|
|
354
|
-
get viewType() {
|
|
355
|
-
return this._viewType;
|
|
356
|
-
}
|
|
357
|
-
get backupId() {
|
|
358
|
-
return this._backupId;
|
|
359
|
-
}
|
|
360
|
-
pushEdit(editId, label) {
|
|
361
|
-
if (!this._editable) {
|
|
362
|
-
throw new Error('Document is not editable');
|
|
363
|
-
}
|
|
364
|
-
this.change(() => {
|
|
365
|
-
this.spliceEdits(editId);
|
|
366
|
-
this._currentEditIndex = this._edits.length - 1;
|
|
367
|
-
});
|
|
368
|
-
this._undoService.pushElement({
|
|
369
|
-
type: 0 ,
|
|
370
|
-
resource: this._editorResource,
|
|
371
|
-
label: label ?? ( localizeWithPath(
|
|
372
|
-
'vs/workbench/api/browser/mainThreadCustomEditors',
|
|
373
|
-
'defaultEditLabel',
|
|
374
|
-
"Edit"
|
|
375
|
-
)),
|
|
376
|
-
code: 'undoredo.customEditorEdit',
|
|
377
|
-
undo: () => this.undo(),
|
|
378
|
-
redo: () => this.redo(),
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
changeContent() {
|
|
382
|
-
this.change(() => {
|
|
383
|
-
this._isDirtyFromContentChange = true;
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
async undo() {
|
|
387
|
-
if (!this._editable) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
if (this._currentEditIndex < 0) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
const undoneEdit = this._edits[this._currentEditIndex];
|
|
394
|
-
this.change(() => {
|
|
395
|
-
--this._currentEditIndex;
|
|
396
|
-
});
|
|
397
|
-
await this._proxy.$undo(this._editorResource, this.viewType, undoneEdit, this.isDirty());
|
|
398
|
-
}
|
|
399
|
-
async redo() {
|
|
400
|
-
if (!this._editable) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
if (this._currentEditIndex >= this._edits.length - 1) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
const redoneEdit = this._edits[this._currentEditIndex + 1];
|
|
407
|
-
this.change(() => {
|
|
408
|
-
++this._currentEditIndex;
|
|
409
|
-
});
|
|
410
|
-
await this._proxy.$redo(this._editorResource, this.viewType, redoneEdit, this.isDirty());
|
|
411
|
-
}
|
|
412
|
-
spliceEdits(editToInsert) {
|
|
413
|
-
const start = this._currentEditIndex + 1;
|
|
414
|
-
const toRemove = this._edits.length - this._currentEditIndex;
|
|
415
|
-
const removedEdits = typeof editToInsert === 'number'
|
|
416
|
-
? this._edits.splice(start, toRemove, editToInsert)
|
|
417
|
-
: this._edits.splice(start, toRemove);
|
|
418
|
-
if (removedEdits.length) {
|
|
419
|
-
this._proxy.$disposeEdits(this._editorResource, this._viewType, removedEdits);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
change(makeEdit) {
|
|
423
|
-
const wasDirty = this.isDirty();
|
|
424
|
-
makeEdit();
|
|
425
|
-
this._onDidChangeContent.fire();
|
|
426
|
-
if (this.isDirty() !== wasDirty) {
|
|
427
|
-
this._onDidChangeDirty.fire();
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
async revert(options) {
|
|
431
|
-
if (!this._editable) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (this._currentEditIndex === this._savePoint && !this._isDirtyFromContentChange && !this._fromBackup) {
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
if (!options?.soft) {
|
|
438
|
-
this._proxy.$revert(this._editorResource, this.viewType, CancellationToken.None);
|
|
439
|
-
}
|
|
440
|
-
this.change(() => {
|
|
441
|
-
this._isDirtyFromContentChange = false;
|
|
442
|
-
this._fromBackup = false;
|
|
443
|
-
this._currentEditIndex = this._savePoint;
|
|
444
|
-
this.spliceEdits();
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
async save(options) {
|
|
448
|
-
const result = !!(await this.saveCustomEditor(options));
|
|
449
|
-
if (result) {
|
|
450
|
-
this._onDidSave.fire({ reason: options?.reason, source: options?.source });
|
|
451
|
-
}
|
|
452
|
-
return result;
|
|
453
|
-
}
|
|
454
|
-
async saveCustomEditor(options) {
|
|
455
|
-
if (!this._editable) {
|
|
456
|
-
return undefined;
|
|
457
|
-
}
|
|
458
|
-
if (this.isUntitled()) {
|
|
459
|
-
const targetUri = await this.suggestUntitledSavePath(options);
|
|
460
|
-
if (!targetUri) {
|
|
461
|
-
return undefined;
|
|
462
|
-
}
|
|
463
|
-
await this.saveCustomEditorAs(this._editorResource, targetUri, options);
|
|
464
|
-
return targetUri;
|
|
465
|
-
}
|
|
466
|
-
const savePromise = createCancelablePromise(token => this._proxy.$onSave(this._editorResource, this.viewType, token));
|
|
467
|
-
this._ongoingSave?.cancel();
|
|
468
|
-
this._ongoingSave = savePromise;
|
|
469
|
-
try {
|
|
470
|
-
await savePromise;
|
|
471
|
-
if (this._ongoingSave === savePromise) {
|
|
472
|
-
this.change(() => {
|
|
473
|
-
this._isDirtyFromContentChange = false;
|
|
474
|
-
this._savePoint = this._currentEditIndex;
|
|
475
|
-
this._fromBackup = false;
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
finally {
|
|
480
|
-
if (this._ongoingSave === savePromise) {
|
|
481
|
-
this._ongoingSave = undefined;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
return this._editorResource;
|
|
485
|
-
}
|
|
486
|
-
suggestUntitledSavePath(options) {
|
|
487
|
-
if (!this.isUntitled()) {
|
|
488
|
-
throw new Error('Resource is not untitled');
|
|
489
|
-
}
|
|
490
|
-
const remoteAuthority = this._environmentService.remoteAuthority;
|
|
491
|
-
const localResource = toLocalResource(this._editorResource, remoteAuthority, this._pathService.defaultUriScheme);
|
|
492
|
-
return this._fileDialogService.pickFileToSave(localResource, options?.availableFileSystems);
|
|
493
|
-
}
|
|
494
|
-
async saveCustomEditorAs(resource, targetResource, _options) {
|
|
495
|
-
if (this._editable) {
|
|
496
|
-
await createCancelablePromise(token => this._proxy.$onSaveAs(this._editorResource, this.viewType, targetResource, token));
|
|
497
|
-
this.change(() => {
|
|
498
|
-
this._savePoint = this._currentEditIndex;
|
|
499
|
-
});
|
|
500
|
-
return true;
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
await this.fileService.copy(resource, targetResource, false );
|
|
504
|
-
return true;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
get canHotExit() { return typeof this._backupId === 'string' && this._hotExitState.type === 0 ; }
|
|
508
|
-
async backup(token) {
|
|
509
|
-
const editors = this._getEditors();
|
|
510
|
-
if (!editors.length) {
|
|
511
|
-
throw new Error('No editors found for resource, cannot back up');
|
|
512
|
-
}
|
|
513
|
-
const primaryEditor = editors[0];
|
|
514
|
-
const backupMeta = {
|
|
515
|
-
viewType: this.viewType,
|
|
516
|
-
editorResource: this._editorResource,
|
|
517
|
-
backupId: '',
|
|
518
|
-
extension: primaryEditor.extension ? {
|
|
519
|
-
id: primaryEditor.extension.id.value,
|
|
520
|
-
location: primaryEditor.extension.location,
|
|
521
|
-
} : undefined,
|
|
522
|
-
webview: {
|
|
523
|
-
origin: primaryEditor.webview.origin,
|
|
524
|
-
options: primaryEditor.webview.options,
|
|
525
|
-
state: primaryEditor.webview.state,
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
const backupData = {
|
|
529
|
-
meta: backupMeta
|
|
530
|
-
};
|
|
531
|
-
if (!this._editable) {
|
|
532
|
-
return backupData;
|
|
533
|
-
}
|
|
534
|
-
if (this._hotExitState.type === 2 ) {
|
|
535
|
-
this._hotExitState.operation.cancel();
|
|
536
|
-
}
|
|
537
|
-
const pendingState = new HotExitState.Pending(createCancelablePromise(token => this._proxy.$backup(this._editorResource.toJSON(), this.viewType, token)));
|
|
538
|
-
this._hotExitState = pendingState;
|
|
539
|
-
token.onCancellationRequested(() => {
|
|
540
|
-
pendingState.operation.cancel();
|
|
541
|
-
});
|
|
542
|
-
let errorMessage = '';
|
|
543
|
-
try {
|
|
544
|
-
const backupId = await pendingState.operation;
|
|
545
|
-
if (this._hotExitState === pendingState) {
|
|
546
|
-
this._hotExitState = HotExitState.Allowed;
|
|
547
|
-
backupData.meta.backupId = backupId;
|
|
548
|
-
this._backupId = backupId;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
catch (e) {
|
|
552
|
-
if (isCancellationError(e)) {
|
|
553
|
-
throw e;
|
|
554
|
-
}
|
|
555
|
-
if (this._hotExitState === pendingState) {
|
|
556
|
-
this._hotExitState = HotExitState.NotAllowed;
|
|
557
|
-
}
|
|
558
|
-
if (e.message) {
|
|
559
|
-
errorMessage = e.message;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
if (this._hotExitState === HotExitState.Allowed) {
|
|
563
|
-
return backupData;
|
|
564
|
-
}
|
|
565
|
-
throw new Error(`Cannot backup in this state: ${errorMessage}`);
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
MainThreadCustomEditorModel = MainThreadCustomEditorModel_1 = ( __decorate([
|
|
569
|
-
( __param(7, IFileDialogService)),
|
|
570
|
-
( __param(8, IFileService)),
|
|
571
|
-
( __param(9, ILabelService)),
|
|
572
|
-
( __param(10, IUndoRedoService)),
|
|
573
|
-
( __param(11, IWorkbenchEnvironmentService)),
|
|
574
|
-
( __param(12, IWorkingCopyService)),
|
|
575
|
-
( __param(13, IPathService)),
|
|
576
|
-
( __param(14, IExtensionService))
|
|
577
|
-
], MainThreadCustomEditorModel));
|
|
578
|
-
|
|
579
|
-
export { MainThreadCustomEditors };
|