@codingame/monaco-vscode-extensions-service-override 3.2.3 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions.js +6 -87
- package/override/vs/platform/dialogs/common/dialogs.js +2 -0
- 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 -59
- 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/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 -227
- 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 -83
- package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +0 -203
- package/vscode/src/vs/workbench/api/browser/mainThreadChatProvider.js +0 -201
- 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 -107
- package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +0 -98
- package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +0 -545
- 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 -578
- package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +0 -424
- 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 -482
- 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 -374
- 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 -991
- 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/mainThreadProfilContentHandlers.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 -146
- 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 -408
- package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +0 -195
- 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 -73
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/contributedOpeners.js +0 -83
- package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +0 -284
- 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 -1138
- 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,98 +0,0 @@
|
|
|
1
|
-
import { VSBuffer, encodeBase64 } from 'vscode/vscode/vs/base/common/buffer';
|
|
2
|
-
import { PauseableEmitter, Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
3
|
-
import { DisposableStore, Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
-
import { SocketDiagnostics } from 'vscode/vscode/vs/base/parts/ipc/common/ipc.net';
|
|
5
|
-
|
|
6
|
-
const makeRawSocketHeaders = (path, query, deubgLabel) => {
|
|
7
|
-
const buffer = ( new Uint8Array(16));
|
|
8
|
-
for (let i = 0; i < 16; i++) {
|
|
9
|
-
buffer[i] = Math.round(Math.random() * 256);
|
|
10
|
-
}
|
|
11
|
-
const nonce = encodeBase64(VSBuffer.wrap(buffer));
|
|
12
|
-
const headers = [
|
|
13
|
-
`GET ws://localhost${path}?${query}&skipWebSocketFrames=true HTTP/1.1`,
|
|
14
|
-
`Connection: Upgrade`,
|
|
15
|
-
`Upgrade: websocket`,
|
|
16
|
-
`Sec-WebSocket-Key: ${nonce}`
|
|
17
|
-
];
|
|
18
|
-
return headers.join('\r\n') + '\r\n\r\n';
|
|
19
|
-
};
|
|
20
|
-
const socketRawEndHeaderSequence = VSBuffer.fromString('\r\n\r\n');
|
|
21
|
-
async function connectManagedSocket(socket, path, query, debugLabel, half) {
|
|
22
|
-
socket.write(VSBuffer.fromString(makeRawSocketHeaders(path, query)));
|
|
23
|
-
const d = ( new DisposableStore());
|
|
24
|
-
try {
|
|
25
|
-
return await ( new Promise((resolve, reject) => {
|
|
26
|
-
let dataSoFar;
|
|
27
|
-
d.add(socket.onData(d_1 => {
|
|
28
|
-
if (!dataSoFar) {
|
|
29
|
-
dataSoFar = d_1;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
dataSoFar = VSBuffer.concat([dataSoFar, d_1], dataSoFar.byteLength + d_1.byteLength);
|
|
33
|
-
}
|
|
34
|
-
const index = dataSoFar.indexOf(socketRawEndHeaderSequence);
|
|
35
|
-
if (index === -1) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
resolve(socket);
|
|
39
|
-
socket.pauseData();
|
|
40
|
-
const rest = dataSoFar.slice(index + socketRawEndHeaderSequence.byteLength);
|
|
41
|
-
if (rest.byteLength) {
|
|
42
|
-
half.onData.fire(rest);
|
|
43
|
-
}
|
|
44
|
-
}));
|
|
45
|
-
d.add(socket.onClose(err => reject(err ?? ( new Error('socket closed')))));
|
|
46
|
-
d.add(socket.onEnd(() => reject(( new Error('socket ended')))));
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
socket.dispose();
|
|
51
|
-
throw e;
|
|
52
|
-
}
|
|
53
|
-
finally {
|
|
54
|
-
d.dispose();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
class ManagedSocket extends Disposable {
|
|
58
|
-
constructor(debugLabel, half) {
|
|
59
|
-
super();
|
|
60
|
-
this.debugLabel = debugLabel;
|
|
61
|
-
this.pausableDataEmitter = this._register(( new PauseableEmitter()));
|
|
62
|
-
this.onData = (...args) => {
|
|
63
|
-
if (this.pausableDataEmitter.isPaused) {
|
|
64
|
-
queueMicrotask(() => this.pausableDataEmitter.resume());
|
|
65
|
-
}
|
|
66
|
-
return this.pausableDataEmitter.event(...args);
|
|
67
|
-
};
|
|
68
|
-
this.didDisposeEmitter = this._register(( new Emitter()));
|
|
69
|
-
this.onDidDispose = this.didDisposeEmitter.event;
|
|
70
|
-
this.ended = false;
|
|
71
|
-
this._register(half.onData);
|
|
72
|
-
this._register(half.onData.event(data => this.pausableDataEmitter.fire(data)));
|
|
73
|
-
this.onClose = this._register(half.onClose).event;
|
|
74
|
-
this.onEnd = this._register(half.onEnd).event;
|
|
75
|
-
}
|
|
76
|
-
pauseData() {
|
|
77
|
-
this.pausableDataEmitter.pause();
|
|
78
|
-
}
|
|
79
|
-
drain() {
|
|
80
|
-
return Promise.resolve();
|
|
81
|
-
}
|
|
82
|
-
end() {
|
|
83
|
-
this.ended = true;
|
|
84
|
-
this.closeRemote();
|
|
85
|
-
}
|
|
86
|
-
traceSocketEvent(type, data) {
|
|
87
|
-
SocketDiagnostics.traceSocketEvent(this, this.debugLabel, type, data);
|
|
88
|
-
}
|
|
89
|
-
dispose() {
|
|
90
|
-
if (!this.ended) {
|
|
91
|
-
this.closeRemote();
|
|
92
|
-
}
|
|
93
|
-
this.didDisposeEmitter.fire();
|
|
94
|
-
super.dispose();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export { ManagedSocket, connectManagedSocket, makeRawSocketHeaders, socketRawEndHeaderSequence };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
4
|
-
import { IAiEmbeddingVectorService } from 'vscode/vscode/vs/workbench/services/aiEmbeddingVector/common/aiEmbeddingVectorService';
|
|
5
|
-
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
6
|
-
|
|
7
|
-
let MainThreadAiEmbeddingVector = class MainThreadAiEmbeddingVector extends Disposable {
|
|
8
|
-
constructor(context, _AiEmbeddingVectorService) {
|
|
9
|
-
super();
|
|
10
|
-
this._AiEmbeddingVectorService = _AiEmbeddingVectorService;
|
|
11
|
-
this._registrations = this._register(( new DisposableMap()));
|
|
12
|
-
this._proxy = ( context.getProxy(ExtHostContext.ExtHostAiEmbeddingVector));
|
|
13
|
-
}
|
|
14
|
-
$registerAiEmbeddingVectorProvider(model, handle) {
|
|
15
|
-
const provider = {
|
|
16
|
-
provideAiEmbeddingVector: (strings, token) => {
|
|
17
|
-
return this._proxy.$provideAiEmbeddingVector(handle, strings, token);
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
this._registrations.set(handle, this._AiEmbeddingVectorService.registerAiEmbeddingVectorProvider(model, provider));
|
|
21
|
-
}
|
|
22
|
-
$unregisterAiEmbeddingVectorProvider(handle) {
|
|
23
|
-
this._registrations.deleteAndDispose(handle);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
MainThreadAiEmbeddingVector = __decorate([
|
|
27
|
-
extHostNamedCustomer(MainContext.MainThreadAiEmbeddingVector),
|
|
28
|
-
( __param(1, IAiEmbeddingVectorService))
|
|
29
|
-
], MainThreadAiEmbeddingVector);
|
|
30
|
-
|
|
31
|
-
export { MainThreadAiEmbeddingVector };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
|
|
3
|
-
import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
-
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
5
|
-
import { IAiRelatedInformationService } from 'vscode/vscode/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation';
|
|
6
|
-
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
7
|
-
|
|
8
|
-
let MainThreadAiRelatedInformation = class MainThreadAiRelatedInformation extends Disposable {
|
|
9
|
-
constructor(context, _aiRelatedInformationService) {
|
|
10
|
-
super();
|
|
11
|
-
this._aiRelatedInformationService = _aiRelatedInformationService;
|
|
12
|
-
this._registrations = this._register(( new DisposableMap()));
|
|
13
|
-
this._proxy = ( context.getProxy(ExtHostContext.ExtHostAiRelatedInformation));
|
|
14
|
-
}
|
|
15
|
-
$getAiRelatedInformation(query, types) {
|
|
16
|
-
return this._aiRelatedInformationService.getRelatedInformation(query, types, CancellationToken.None);
|
|
17
|
-
}
|
|
18
|
-
$registerAiRelatedInformationProvider(handle, type) {
|
|
19
|
-
const provider = {
|
|
20
|
-
provideAiRelatedInformation: (query, token) => {
|
|
21
|
-
return this._proxy.$provideAiRelatedInformation(handle, query, token);
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
this._registrations.set(handle, this._aiRelatedInformationService.registerAiRelatedInformationProvider(type, provider));
|
|
25
|
-
}
|
|
26
|
-
$unregisterAiRelatedInformationProvider(handle) {
|
|
27
|
-
this._registrations.deleteAndDispose(handle);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
MainThreadAiRelatedInformation = __decorate([
|
|
31
|
-
extHostNamedCustomer(MainContext.MainThreadAiRelatedInformation),
|
|
32
|
-
( __param(1, IAiRelatedInformationService))
|
|
33
|
-
], MainThreadAiRelatedInformation);
|
|
34
|
-
|
|
35
|
-
export { MainThreadAiRelatedInformation };
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
|
-
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
5
|
-
import { getAuthenticationProviderActivationEvent, addAccountUsage } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationService';
|
|
6
|
-
import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication';
|
|
7
|
-
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
8
|
-
import '../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
9
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
10
|
-
import Severity from 'vscode/vscode/vs/base/common/severity';
|
|
11
|
-
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
12
|
-
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
13
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
14
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
15
|
-
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
16
|
-
|
|
17
|
-
class MainThreadAuthenticationProvider extends Disposable {
|
|
18
|
-
constructor(_proxy, id, label, supportsMultipleAccounts, notificationService, onDidChangeSessionsEmitter) {
|
|
19
|
-
super();
|
|
20
|
-
this._proxy = _proxy;
|
|
21
|
-
this.id = id;
|
|
22
|
-
this.label = label;
|
|
23
|
-
this.supportsMultipleAccounts = supportsMultipleAccounts;
|
|
24
|
-
this.notificationService = notificationService;
|
|
25
|
-
this.onDidChangeSessions = onDidChangeSessionsEmitter.event;
|
|
26
|
-
}
|
|
27
|
-
async getSessions(scopes) {
|
|
28
|
-
return this._proxy.$getSessions(this.id, scopes);
|
|
29
|
-
}
|
|
30
|
-
createSession(scopes, options) {
|
|
31
|
-
return this._proxy.$createSession(this.id, scopes, options);
|
|
32
|
-
}
|
|
33
|
-
async removeSession(sessionId) {
|
|
34
|
-
await this._proxy.$removeSession(this.id, sessionId);
|
|
35
|
-
this.notificationService.info(( localizeWithPath(
|
|
36
|
-
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
37
|
-
'signedOut',
|
|
38
|
-
"Successfully signed out."
|
|
39
|
-
)));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
let MainThreadAuthentication = class MainThreadAuthentication extends Disposable {
|
|
43
|
-
constructor(extHostContext, authenticationService, dialogService, storageService, notificationService, extensionService, telemetryService) {
|
|
44
|
-
super();
|
|
45
|
-
this.authenticationService = authenticationService;
|
|
46
|
-
this.dialogService = dialogService;
|
|
47
|
-
this.storageService = storageService;
|
|
48
|
-
this.notificationService = notificationService;
|
|
49
|
-
this.extensionService = extensionService;
|
|
50
|
-
this.telemetryService = telemetryService;
|
|
51
|
-
this._registrations = this._register(( new DisposableMap()));
|
|
52
|
-
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostAuthentication));
|
|
53
|
-
this._register(this.authenticationService.onDidChangeSessions(e => {
|
|
54
|
-
this._proxy.$onDidChangeAuthenticationSessions(e.providerId, e.label);
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
async $registerAuthenticationProvider(id, label, supportsMultipleAccounts) {
|
|
58
|
-
const emitter = ( new Emitter());
|
|
59
|
-
this._registrations.set(id, emitter);
|
|
60
|
-
const provider = ( new MainThreadAuthenticationProvider(
|
|
61
|
-
this._proxy,
|
|
62
|
-
id,
|
|
63
|
-
label,
|
|
64
|
-
supportsMultipleAccounts,
|
|
65
|
-
this.notificationService,
|
|
66
|
-
emitter
|
|
67
|
-
));
|
|
68
|
-
this.authenticationService.registerAuthenticationProvider(id, provider);
|
|
69
|
-
}
|
|
70
|
-
$unregisterAuthenticationProvider(id) {
|
|
71
|
-
this._registrations.deleteAndDispose(id);
|
|
72
|
-
this.authenticationService.unregisterAuthenticationProvider(id);
|
|
73
|
-
}
|
|
74
|
-
async $ensureProvider(id) {
|
|
75
|
-
if (!this.authenticationService.isAuthenticationProviderRegistered(id)) {
|
|
76
|
-
return await this.extensionService.activateByEvent(getAuthenticationProviderActivationEvent(id), 1 );
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
$sendDidChangeSessions(providerId, event) {
|
|
80
|
-
const obj = this._registrations.get(providerId);
|
|
81
|
-
if (obj instanceof Emitter) {
|
|
82
|
-
obj.fire(event);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
$removeSession(providerId, sessionId) {
|
|
86
|
-
return this.authenticationService.removeSession(providerId, sessionId);
|
|
87
|
-
}
|
|
88
|
-
async loginPrompt(providerName, extensionName, recreatingSession, detail) {
|
|
89
|
-
const message = recreatingSession
|
|
90
|
-
? ( localizeWithPath(
|
|
91
|
-
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
92
|
-
'confirmRelogin',
|
|
93
|
-
"The extension '{0}' wants you to sign in again using {1}.",
|
|
94
|
-
extensionName,
|
|
95
|
-
providerName
|
|
96
|
-
))
|
|
97
|
-
: ( localizeWithPath(
|
|
98
|
-
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
99
|
-
'confirmLogin',
|
|
100
|
-
"The extension '{0}' wants to sign in using {1}.",
|
|
101
|
-
extensionName,
|
|
102
|
-
providerName
|
|
103
|
-
));
|
|
104
|
-
const { confirmed } = await this.dialogService.confirm({
|
|
105
|
-
type: Severity.Info,
|
|
106
|
-
message,
|
|
107
|
-
detail,
|
|
108
|
-
primaryButton: ( localizeWithPath(
|
|
109
|
-
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
110
|
-
{ key: 'allow', comment: ['&& denotes a mnemonic'] },
|
|
111
|
-
"&&Allow"
|
|
112
|
-
))
|
|
113
|
-
});
|
|
114
|
-
return confirmed;
|
|
115
|
-
}
|
|
116
|
-
async doGetSession(providerId, scopes, extensionId, extensionName, options) {
|
|
117
|
-
const sessions = await this.authenticationService.getSessions(providerId, scopes, true);
|
|
118
|
-
const supportsMultipleAccounts = this.authenticationService.supportsMultipleAccounts(providerId);
|
|
119
|
-
if (options.forceNewSession && options.createIfNone) {
|
|
120
|
-
throw new Error('Invalid combination of options. Please remove one of the following: forceNewSession, createIfNone');
|
|
121
|
-
}
|
|
122
|
-
if (options.forceNewSession && options.silent) {
|
|
123
|
-
throw new Error('Invalid combination of options. Please remove one of the following: forceNewSession, silent');
|
|
124
|
-
}
|
|
125
|
-
if (options.createIfNone && options.silent) {
|
|
126
|
-
throw new Error('Invalid combination of options. Please remove one of the following: createIfNone, silent');
|
|
127
|
-
}
|
|
128
|
-
if (!options.forceNewSession && sessions.length) {
|
|
129
|
-
if (supportsMultipleAccounts) {
|
|
130
|
-
if (options.clearSessionPreference) {
|
|
131
|
-
this.authenticationService.removeSessionPreference(providerId, extensionId, scopes);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
const existingSessionPreference = this.authenticationService.getSessionPreference(providerId, extensionId, scopes);
|
|
135
|
-
if (existingSessionPreference) {
|
|
136
|
-
const matchingSession = sessions.find(session => session.id === existingSessionPreference);
|
|
137
|
-
if (matchingSession && this.authenticationService.isAccessAllowed(providerId, matchingSession.account.label, extensionId)) {
|
|
138
|
-
return matchingSession;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
else if (this.authenticationService.isAccessAllowed(providerId, sessions[0].account.label, extensionId)) {
|
|
144
|
-
return sessions[0];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (options.createIfNone || options.forceNewSession) {
|
|
148
|
-
const providerName = this.authenticationService.getLabel(providerId);
|
|
149
|
-
const detail = (typeof options.forceNewSession === 'object') ? options.forceNewSession.detail : undefined;
|
|
150
|
-
const recreatingSession = !!(options.forceNewSession && sessions.length);
|
|
151
|
-
const isAllowed = await this.loginPrompt(providerName, extensionName, recreatingSession, detail);
|
|
152
|
-
if (!isAllowed) {
|
|
153
|
-
throw new Error('User did not consent to login.');
|
|
154
|
-
}
|
|
155
|
-
let session;
|
|
156
|
-
if (sessions?.length && !options.forceNewSession) {
|
|
157
|
-
session = supportsMultipleAccounts
|
|
158
|
-
? await this.authenticationService.selectSession(providerId, extensionId, extensionName, scopes, sessions)
|
|
159
|
-
: sessions[0];
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
let sessionToRecreate;
|
|
163
|
-
if (typeof options.forceNewSession === 'object' && options.forceNewSession.sessionToRecreate) {
|
|
164
|
-
sessionToRecreate = options.forceNewSession.sessionToRecreate;
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
const sessionIdToRecreate = this.authenticationService.getSessionPreference(providerId, extensionId, scopes);
|
|
168
|
-
sessionToRecreate = sessionIdToRecreate ? sessions.find(session => session.id === sessionIdToRecreate) : undefined;
|
|
169
|
-
}
|
|
170
|
-
session = await this.authenticationService.createSession(providerId, scopes, { activateImmediate: true, sessionToRecreate });
|
|
171
|
-
}
|
|
172
|
-
this.authenticationService.updateAllowedExtension(providerId, session.account.label, extensionId, extensionName, true);
|
|
173
|
-
this.authenticationService.updateSessionPreference(providerId, extensionId, session);
|
|
174
|
-
return session;
|
|
175
|
-
}
|
|
176
|
-
const validSession = sessions.find(session => this.authenticationService.isAccessAllowed(providerId, session.account.label, extensionId));
|
|
177
|
-
if (validSession) {
|
|
178
|
-
if (!this.authenticationService.getSessionPreference(providerId, extensionId, scopes)) {
|
|
179
|
-
if (this.storageService.get(`${extensionName}-${providerId}`, -1 )) {
|
|
180
|
-
this.storageService.remove(`${extensionName}-${providerId}`, -1 );
|
|
181
|
-
}
|
|
182
|
-
this.authenticationService.updateAllowedExtension(providerId, validSession.account.label, extensionId, extensionName, true);
|
|
183
|
-
this.authenticationService.updateSessionPreference(providerId, extensionId, validSession);
|
|
184
|
-
}
|
|
185
|
-
return validSession;
|
|
186
|
-
}
|
|
187
|
-
if (!options.silent) {
|
|
188
|
-
sessions.length
|
|
189
|
-
? this.authenticationService.requestSessionAccess(providerId, extensionId, extensionName, scopes, sessions)
|
|
190
|
-
: await this.authenticationService.requestNewSession(providerId, scopes, extensionId, extensionName);
|
|
191
|
-
}
|
|
192
|
-
return undefined;
|
|
193
|
-
}
|
|
194
|
-
async $getSession(providerId, scopes, extensionId, extensionName, options) {
|
|
195
|
-
const session = await this.doGetSession(providerId, scopes, extensionId, extensionName, options);
|
|
196
|
-
if (session) {
|
|
197
|
-
this.sendProviderUsageTelemetry(extensionId, providerId);
|
|
198
|
-
addAccountUsage(this.storageService, providerId, session.account.label, extensionId, extensionName);
|
|
199
|
-
}
|
|
200
|
-
return session;
|
|
201
|
-
}
|
|
202
|
-
async $getSessions(providerId, scopes, extensionId, extensionName) {
|
|
203
|
-
const sessions = await this.authenticationService.getSessions(providerId, [...scopes], true);
|
|
204
|
-
const accessibleSessions = sessions.filter(s => this.authenticationService.isAccessAllowed(providerId, s.account.label, extensionId));
|
|
205
|
-
if (accessibleSessions.length) {
|
|
206
|
-
this.sendProviderUsageTelemetry(extensionId, providerId);
|
|
207
|
-
for (const session of accessibleSessions) {
|
|
208
|
-
addAccountUsage(this.storageService, providerId, session.account.label, extensionId, extensionName);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return accessibleSessions;
|
|
212
|
-
}
|
|
213
|
-
sendProviderUsageTelemetry(extensionId, providerId) {
|
|
214
|
-
this.telemetryService.publicLog2('authentication.providerUsage', { providerId, extensionId });
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
MainThreadAuthentication = __decorate([
|
|
218
|
-
extHostNamedCustomer(MainContext.MainThreadAuthentication),
|
|
219
|
-
( __param(1, IAuthenticationService)),
|
|
220
|
-
( __param(2, IDialogService)),
|
|
221
|
-
( __param(3, IStorageService)),
|
|
222
|
-
( __param(4, INotificationService)),
|
|
223
|
-
( __param(5, IExtensionService)),
|
|
224
|
-
( __param(6, ITelemetryService))
|
|
225
|
-
], MainThreadAuthentication);
|
|
226
|
-
|
|
227
|
-
export { MainThreadAuthentication, MainThreadAuthenticationProvider };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { decodeBase64 } from 'vscode/vscode/vs/base/common/buffer';
|
|
3
|
-
import { revive } from 'vscode/vscode/vs/base/common/marshalling';
|
|
4
|
-
import { IBulkEditService, ResourceTextEdit, ResourceFileEdit } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
|
|
5
|
-
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
6
|
-
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
7
|
-
import { MainContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
8
|
-
import { ResourceNotebookCellEdit } from 'vscode/vscode/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits';
|
|
9
|
-
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
10
|
-
|
|
11
|
-
let MainThreadBulkEdits = class MainThreadBulkEdits {
|
|
12
|
-
constructor(_extHostContext, _bulkEditService, _logService, _uriIdentService) {
|
|
13
|
-
this._bulkEditService = _bulkEditService;
|
|
14
|
-
this._logService = _logService;
|
|
15
|
-
this._uriIdentService = _uriIdentService;
|
|
16
|
-
}
|
|
17
|
-
dispose() { }
|
|
18
|
-
$tryApplyWorkspaceEdit(dto, undoRedoGroupId, isRefactoring) {
|
|
19
|
-
const edits = reviveWorkspaceEditDto(dto, this._uriIdentService);
|
|
20
|
-
return this._bulkEditService.apply(edits, { undoRedoGroupId, respectAutoSaveConfig: isRefactoring }).then((res) => res.isApplied, err => {
|
|
21
|
-
this._logService.warn(`IGNORING workspace edit: ${err}`);
|
|
22
|
-
return false;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
MainThreadBulkEdits = __decorate([
|
|
27
|
-
extHostNamedCustomer(MainContext.MainThreadBulkEdits),
|
|
28
|
-
( __param(1, IBulkEditService)),
|
|
29
|
-
( __param(2, ILogService)),
|
|
30
|
-
( __param(3, IUriIdentityService))
|
|
31
|
-
], MainThreadBulkEdits);
|
|
32
|
-
function reviveWorkspaceEditDto(data, uriIdentityService, resolveDataTransferFile) {
|
|
33
|
-
if (!data || !data.edits) {
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
const result = revive(data);
|
|
37
|
-
for (const edit of result.edits) {
|
|
38
|
-
if (ResourceTextEdit.is(edit)) {
|
|
39
|
-
edit.resource = uriIdentityService.asCanonicalUri(edit.resource);
|
|
40
|
-
}
|
|
41
|
-
if (ResourceFileEdit.is(edit)) {
|
|
42
|
-
if (edit.options) {
|
|
43
|
-
const inContents = edit.options?.contents;
|
|
44
|
-
if (inContents) {
|
|
45
|
-
if (inContents.type === 'base64') {
|
|
46
|
-
edit.options.contents = Promise.resolve(decodeBase64(inContents.value));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
if (resolveDataTransferFile) {
|
|
50
|
-
edit.options.contents = resolveDataTransferFile(inContents.id);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
throw new Error('Could not revive data transfer file');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
edit.newResource = edit.newResource && uriIdentityService.asCanonicalUri(edit.newResource);
|
|
59
|
-
edit.oldResource = edit.oldResource && uriIdentityService.asCanonicalUri(edit.oldResource);
|
|
60
|
-
}
|
|
61
|
-
if (ResourceNotebookCellEdit.is(edit)) {
|
|
62
|
-
edit.resource = uriIdentityService.asCanonicalUri(edit.resource);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return data;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { MainThreadBulkEdits, reviveWorkspaceEditDto };
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
3
|
-
import { isWeb } from 'vscode/vscode/vs/base/common/platform';
|
|
4
|
-
import { isString } from 'vscode/vscode/vs/base/common/types';
|
|
5
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
6
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
7
|
-
import { CommandsRegistry, ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
8
|
-
import { IExtensionManagementService, IExtensionGalleryService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement';
|
|
9
|
-
import { ExtensionManagementCLI } from '../../../platform/extensionManagement/common/extensionManagementCLI.js';
|
|
10
|
-
import { getExtensionId } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
|
|
11
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
|
-
import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
|
|
13
|
-
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
|
|
14
|
-
import { AbstractMessageLogger } from 'vscode/vscode/vs/platform/log/common/log';
|
|
15
|
-
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
16
|
-
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
|
|
17
|
-
import { IExtensionManagementServerService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionManagement';
|
|
18
|
-
import { IExtensionManifestPropertiesService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService';
|
|
19
|
-
|
|
20
|
-
CommandsRegistry.registerCommand('_remoteCLI.openExternal', function (accessor, uri) {
|
|
21
|
-
const openerService = accessor.get(IOpenerService);
|
|
22
|
-
return openerService.open(isString(uri) ? uri : URI.revive(uri), { openExternal: true, allowTunneling: true });
|
|
23
|
-
});
|
|
24
|
-
CommandsRegistry.registerCommand('_remoteCLI.windowOpen', function (accessor, toOpen, options) {
|
|
25
|
-
const commandService = accessor.get(ICommandService);
|
|
26
|
-
if (!toOpen.length) {
|
|
27
|
-
return commandService.executeCommand('_files.newWindow', options);
|
|
28
|
-
}
|
|
29
|
-
return commandService.executeCommand('_files.windowOpen', toOpen, options);
|
|
30
|
-
});
|
|
31
|
-
CommandsRegistry.registerCommand('_remoteCLI.getSystemStatus', function (accessor) {
|
|
32
|
-
const commandService = accessor.get(ICommandService);
|
|
33
|
-
return commandService.executeCommand('_issues.getSystemStatus');
|
|
34
|
-
});
|
|
35
|
-
CommandsRegistry.registerCommand('_remoteCLI.manageExtensions', async function (accessor, args) {
|
|
36
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
37
|
-
const extensionManagementServerService = accessor.get(IExtensionManagementServerService);
|
|
38
|
-
const remoteExtensionManagementService = extensionManagementServerService.remoteExtensionManagementServer?.extensionManagementService;
|
|
39
|
-
if (!remoteExtensionManagementService) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const lines = [];
|
|
43
|
-
const logger = new (class extends AbstractMessageLogger {
|
|
44
|
-
log(level, message) {
|
|
45
|
-
lines.push(message);
|
|
46
|
-
}
|
|
47
|
-
})();
|
|
48
|
-
const cliService = instantiationService.createChild(( new ServiceCollection([IExtensionManagementService, remoteExtensionManagementService]))).createInstance(RemoteExtensionManagementCLI, logger);
|
|
49
|
-
if (args.list) {
|
|
50
|
-
await cliService.listExtensions(!!args.list.showVersions, args.list.category, undefined);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
const revive = (inputs) => ( inputs.map(input => isString(input) ? input : URI.revive(input)));
|
|
54
|
-
if (Array.isArray(args.install) && args.install.length) {
|
|
55
|
-
try {
|
|
56
|
-
await cliService.installExtensions(revive(args.install), [], { isMachineScoped: true }, !!args.force);
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
lines.push(e.message);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (Array.isArray(args.uninstall) && args.uninstall.length) {
|
|
63
|
-
try {
|
|
64
|
-
await cliService.uninstallExtensions(revive(args.uninstall), !!args.force, undefined);
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
lines.push(e.message);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return lines.join('\n');
|
|
72
|
-
});
|
|
73
|
-
let RemoteExtensionManagementCLI = class RemoteExtensionManagementCLI extends ExtensionManagementCLI {
|
|
74
|
-
constructor(logger, extensionManagementService, extensionGalleryService, labelService, envService, _extensionManifestPropertiesService) {
|
|
75
|
-
super(logger, extensionManagementService, extensionGalleryService);
|
|
76
|
-
this._extensionManifestPropertiesService = _extensionManifestPropertiesService;
|
|
77
|
-
const remoteAuthority = envService.remoteAuthority;
|
|
78
|
-
this._location = remoteAuthority ? labelService.getHostLabel(Schemas.vscodeRemote, remoteAuthority) : undefined;
|
|
79
|
-
}
|
|
80
|
-
get location() {
|
|
81
|
-
return this._location;
|
|
82
|
-
}
|
|
83
|
-
validateExtensionKind(manifest) {
|
|
84
|
-
if (!this._extensionManifestPropertiesService.canExecuteOnWorkspace(manifest)
|
|
85
|
-
&& !(isWeb && this._extensionManifestPropertiesService.canExecuteOnWeb(manifest))) {
|
|
86
|
-
this.logger.info(( localizeWithPath(
|
|
87
|
-
'vs/workbench/api/browser/mainThreadCLICommands',
|
|
88
|
-
'cannot be installed',
|
|
89
|
-
"Cannot install the '{0}' extension because it is declared to not run in this setup.",
|
|
90
|
-
getExtensionId(manifest.publisher, manifest.name)
|
|
91
|
-
)));
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
RemoteExtensionManagementCLI = ( __decorate([
|
|
98
|
-
( __param(1, IExtensionManagementService)),
|
|
99
|
-
( __param(2, IExtensionGalleryService)),
|
|
100
|
-
( __param(3, ILabelService)),
|
|
101
|
-
( __param(4, IWorkbenchEnvironmentService)),
|
|
102
|
-
( __param(5, IExtensionManifestPropertiesService))
|
|
103
|
-
], RemoteExtensionManagementCLI));
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
3
|
-
import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
5
|
-
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
6
|
-
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
7
|
-
import { IChatContributionService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContributionService';
|
|
8
|
-
import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
|
|
9
|
-
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
10
|
-
|
|
11
|
-
let MainThreadChat = class MainThreadChat extends Disposable {
|
|
12
|
-
constructor(extHostContext, _chatService, _chatWidgetService, chatContribService) {
|
|
13
|
-
super();
|
|
14
|
-
this._chatService = _chatService;
|
|
15
|
-
this._chatWidgetService = _chatWidgetService;
|
|
16
|
-
this.chatContribService = chatContribService;
|
|
17
|
-
this._providerRegistrations = this._register(( new DisposableMap()));
|
|
18
|
-
this._stateEmitters = ( new Map());
|
|
19
|
-
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostChat));
|
|
20
|
-
}
|
|
21
|
-
$transferChatSession(sessionId, toWorkspace) {
|
|
22
|
-
const sessionIdStr = this._chatService.getSessionId(sessionId);
|
|
23
|
-
if (!sessionIdStr) {
|
|
24
|
-
throw new Error(`Failed to transfer session. Unknown session provider ID: ${sessionId}`);
|
|
25
|
-
}
|
|
26
|
-
const widget = this._chatWidgetService.getWidgetBySessionId(sessionIdStr);
|
|
27
|
-
const inputValue = widget?.inputEditor.getValue() ?? '';
|
|
28
|
-
this._chatService.transferChatSession({ sessionId: sessionIdStr, inputValue: inputValue }, URI.revive(toWorkspace));
|
|
29
|
-
}
|
|
30
|
-
async $registerChatProvider(handle, id) {
|
|
31
|
-
const registration = this.chatContribService.registeredProviders.find(staticProvider => staticProvider.id === id);
|
|
32
|
-
if (!registration) {
|
|
33
|
-
throw new Error(`Provider ${id} must be declared in the package.json.`);
|
|
34
|
-
}
|
|
35
|
-
const unreg = this._chatService.registerProvider({
|
|
36
|
-
id,
|
|
37
|
-
prepareSession: async (token) => {
|
|
38
|
-
const session = await this._proxy.$prepareChat(handle, token);
|
|
39
|
-
if (!session) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
const responderAvatarIconUri = session.responderAvatarIconUri &&
|
|
43
|
-
URI.revive(session.responderAvatarIconUri);
|
|
44
|
-
const emitter = ( new Emitter());
|
|
45
|
-
this._stateEmitters.set(session.id, emitter);
|
|
46
|
-
return {
|
|
47
|
-
id: session.id,
|
|
48
|
-
requesterUsername: session.requesterUsername,
|
|
49
|
-
requesterAvatarIconUri: URI.revive(session.requesterAvatarIconUri),
|
|
50
|
-
responderUsername: session.responderUsername,
|
|
51
|
-
responderAvatarIconUri,
|
|
52
|
-
inputPlaceholder: session.inputPlaceholder,
|
|
53
|
-
dispose: () => {
|
|
54
|
-
emitter.dispose();
|
|
55
|
-
this._stateEmitters.delete(session.id);
|
|
56
|
-
this._proxy.$releaseSession(session.id);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
this._providerRegistrations.set(handle, unreg);
|
|
62
|
-
}
|
|
63
|
-
async $acceptChatState(sessionId, state) {
|
|
64
|
-
this._stateEmitters.get(sessionId)?.fire(state);
|
|
65
|
-
}
|
|
66
|
-
async $sendRequestToProvider(providerId, message) {
|
|
67
|
-
const widget = await this._chatWidgetService.revealViewForProvider(providerId);
|
|
68
|
-
if (widget && widget.viewModel) {
|
|
69
|
-
this._chatService.sendRequestToProvider(widget.viewModel.sessionId, message);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async $unregisterChatProvider(handle) {
|
|
73
|
-
this._providerRegistrations.deleteAndDispose(handle);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
MainThreadChat = __decorate([
|
|
77
|
-
extHostNamedCustomer(MainContext.MainThreadChat),
|
|
78
|
-
( __param(1, IChatService)),
|
|
79
|
-
( __param(2, IChatWidgetService)),
|
|
80
|
-
( __param(3, IChatContributionService))
|
|
81
|
-
], MainThreadChat);
|
|
82
|
-
|
|
83
|
-
export { MainThreadChat };
|