mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 18:22:34 -05:00
63 lines
3.1 KiB
TypeScript
63 lines
3.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { localize } from 'vs/nls';
|
|
import { IExtensionManagementServer, IExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
|
import { ExtensionManagementChannelClient } from 'vs/platform/extensionManagement/common/extensionManagementIpc';
|
|
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
|
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
|
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
|
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
|
import { ILabelService } from 'vs/platform/label/common/label';
|
|
import { isWeb } from 'vs/base/common/platform';
|
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
|
import { WebExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/webExtensionManagementService';
|
|
import { IExtension } from 'vs/platform/extensions/common/extensions';
|
|
|
|
export class ExtensionManagementServerService implements IExtensionManagementServerService {
|
|
|
|
declare readonly _serviceBrand: undefined;
|
|
|
|
readonly localExtensionManagementServer: IExtensionManagementServer | null = null;
|
|
readonly remoteExtensionManagementServer: IExtensionManagementServer | null = null;
|
|
readonly webExtensionManagementServer: IExtensionManagementServer | null = null;
|
|
|
|
constructor(
|
|
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
|
|
@ILabelService labelService: ILabelService,
|
|
@IInstantiationService instantiationService: IInstantiationService,
|
|
) {
|
|
const remoteAgentConnection = remoteAgentService.getConnection();
|
|
if (remoteAgentConnection) {
|
|
const extensionManagementService = new ExtensionManagementChannelClient(remoteAgentConnection!.getChannel<IChannel>('extensions'));
|
|
this.remoteExtensionManagementServer = {
|
|
id: 'remote',
|
|
extensionManagementService,
|
|
get label() { return labelService.getHostLabel(REMOTE_HOST_SCHEME, remoteAgentConnection!.remoteAuthority) || localize('remote', "Remote"); }
|
|
};
|
|
}
|
|
if (isWeb) {
|
|
const extensionManagementService = instantiationService.createInstance(WebExtensionManagementService);
|
|
this.webExtensionManagementServer = {
|
|
id: 'web',
|
|
extensionManagementService,
|
|
label: localize('web', "Web")
|
|
};
|
|
}
|
|
}
|
|
|
|
getExtensionManagementServer(extension: IExtension): IExtensionManagementServer {
|
|
if (extension.location.scheme === REMOTE_HOST_SCHEME) {
|
|
return this.remoteExtensionManagementServer!;
|
|
}
|
|
if (this.webExtensionManagementServer) {
|
|
return this.webExtensionManagementServer;
|
|
}
|
|
throw new Error(`Invalid Extension ${extension.location}`);
|
|
}
|
|
}
|
|
|
|
registerSingleton(IExtensionManagementServerService, ExtensionManagementServerService);
|