diff --git a/demo/src/setup.ts b/demo/src/setup.ts index 834c64ff..15eb5e98 100644 --- a/demo/src/setup.ts +++ b/demo/src/setup.ts @@ -83,7 +83,7 @@ await Promise.all([ // Override services await initializeMonacoService({ ...getExtensionServiceOverride(toWorkerConfig(ExtensionHostWorker)), - ...getExtensionGalleryServiceOverride(), + ...getExtensionGalleryServiceOverride({ webOnly: false }), ...getModelServiceOverride(), ...getNotificationServiceOverride(), ...getDialogsServiceOverride(), diff --git a/src/service-override/extensionGallery.ts b/src/service-override/extensionGallery.ts index 924a6b88..3f261d6f 100644 --- a/src/service-override/extensionGallery.ts +++ b/src/service-override/extensionGallery.ts @@ -24,7 +24,6 @@ import { RemoteExtensionsScannerService } from 'vs/workbench/services/remote/com import { ExtensionRecommendationNotificationService } from 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService' import { ExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionTipsService' import { ExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagementService' -import { WebExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/webExtensionManagementService' import 'vs/workbench/contrib/extensions/browser/extensions.contribution' import 'vs/workbench/contrib/extensions/browser/extensions.web.contribution' import 'vs/workbench/contrib/logs/common/logs.contribution' @@ -33,11 +32,34 @@ import { ExtensionEnablementService } from 'vs/workbench/services/extensionManag import 'vs/workbench/services/extensionManagement/browser/extensionBisect' import { changeUrlDomain } from './tools/url' import { registerAssets } from '../assets' +import { IInstantiationService, ILabelService, IRemoteAgentService } from '../services' registerAssets({ 'vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html': () => changeUrlDomain(new URL('../assets/webWorkerExtensionHostIframe.html', import.meta.url).href, undefined) }) +class ExtensionManagementServerServiceOverride extends ExtensionManagementServerService { + constructor ( + private isWebOnly: boolean, + @IRemoteAgentService readonly remoteAgentService: IRemoteAgentService, + @ILabelService readonly labelService: ILabelService, + @IInstantiationService readonly instantiationService: IInstantiationService + ) { + super(remoteAgentService, labelService, instantiationService) + + if (this.isWebOnly) { + /** + * If `isWebOnly` is set to true, we explicitly set the remote extension management server to `null`, even if + * we're connected to a remote server. + */ + // Cannot override read-only property, but this is the only way we can override it to be null, + // overriding the field doesn't work and setting a getter is not allowed. + // @ts-ignore + this.remoteExtensionManagementServer = null + } + } +} + export interface ExtensionGalleryOptions { /** * Whether we should only allow for web extensions to be installed, this is generally @@ -52,16 +74,14 @@ export default function getServiceOverride (options: ExtensionGalleryOptions = { [IExtensionGalleryService.toString()]: new SyncDescriptor(ExtensionGalleryService, [], true), [IGlobalExtensionEnablementService.toString()]: new SyncDescriptor(GlobalExtensionEnablementService, [], true), [IExtensionsWorkbenchService.toString()]: new SyncDescriptor(ExtensionsWorkbenchService, [], true), - [IExtensionManagementServerService.toString()]: new SyncDescriptor(ExtensionManagementServerService, [], true), + [IExtensionManagementServerService.toString()]: new SyncDescriptor(ExtensionManagementServerServiceOverride, [options.webOnly], true), [IExtensionRecommendationsService.toString()]: new SyncDescriptor(ExtensionRecommendationsService, [], true), [IExtensionRecommendationNotificationService.toString()]: new SyncDescriptor(ExtensionRecommendationNotificationService, [], true), [IWebExtensionsScannerService.toString()]: new SyncDescriptor(WebExtensionsScannerService, [], true), [IExtensionIgnoredRecommendationsService.toString()]: new SyncDescriptor(ExtensionIgnoredRecommendationsService, [], true), [IIgnoredExtensionsManagementService.toString()]: new SyncDescriptor(IgnoredExtensionsManagementService, [], true), [IExtensionManifestPropertiesService.toString()]: new SyncDescriptor(ExtensionManifestPropertiesService, [], true), - [IExtensionManagementService.toString()]: options.webOnly - ? new SyncDescriptor(WebExtensionManagementService, [], true) - : new SyncDescriptor(ExtensionManagementService, [], true), + [IExtensionManagementService.toString()]: new SyncDescriptor(ExtensionManagementService, [], true), [IBuiltinExtensionsScannerService.toString()]: new SyncDescriptor(BuiltinExtensionsScannerService, [], true), [IWorkspaceExtensionsConfigService.toString()]: new SyncDescriptor(WorkspaceExtensionsConfigService, [], true), [IRemoteExtensionsScannerService.toString()]: new SyncDescriptor(RemoteExtensionsScannerService, [], true),