diff --git a/demo/src/setup.common.ts b/demo/src/setup.common.ts index fdedae5f..4be2c51a 100644 --- a/demo/src/setup.common.ts +++ b/demo/src/setup.common.ts @@ -2,7 +2,7 @@ import getConfigurationServiceOverride, { IStoredWorkspace, initUserConfiguratio import getKeybindingsServiceOverride, { initUserKeybindings } from '@codingame/monaco-vscode-keybindings-service-override' import { RegisteredFileSystemProvider, RegisteredMemoryFile, RegisteredReadOnlyFile, createIndexedDBProviders, initFile, registerFileSystemOverlay } from '@codingame/monaco-vscode-files-service-override' import * as monaco from 'monaco-editor' -import { IWorkbenchConstructionOptions, LogLevel, IEditorOverrideServices, registerWorkbenchContribution, WorkbenchPhase, IStorageService, StorageScope, StorageTarget } from 'vscode/services' +import { IWorkbenchConstructionOptions, LogLevel, IEditorOverrideServices } from 'vscode/services' import * as vscode from 'vscode' import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override' import getNotificationServiceOverride from '@codingame/monaco-vscode-notifications-service-override' @@ -167,11 +167,6 @@ window.MonacoEnvironment = { } } -// Remove "account" item from activity bar -registerWorkbenchContribution('remove-accounts', accessor => { - accessor.get(IStorageService).store('workbench.activity.showAccounts', false, StorageScope.APPLICATION, StorageTarget.USER) -}, WorkbenchPhase.BlockRestore) - const params = new URL(document.location.href).searchParams export const remoteAuthority = params.get('remoteAuthority') ?? undefined export const connectionToken = params.get('connectionToken') ?? undefined @@ -284,7 +279,11 @@ export const commonServices: IEditorOverrideServices = { ...getMarkersServiceOverride(), ...getAccessibilityServiceOverride(), ...getLanguageDetectionWorkerServiceOverride(), - ...getStorageServiceOverride(), + ...getStorageServiceOverride({ + fallbackOverride: { + 'workbench.activity.showAccounts': false + } + }), ...getRemoteAgentServiceOverride({ scanRemoteExtensions: true }), ...getLifecycleServiceOverride(), ...getEnvironmentServiceOverride(), diff --git a/src/rollup-vsix-plugin.ts b/src/rollup-vsix-plugin.ts index 129f523a..d8d903e2 100644 --- a/src/rollup-vsix-plugin.ts +++ b/src/rollup-vsix-plugin.ts @@ -53,7 +53,7 @@ async function readVsix (file: string): Promise { } function getVsixPath (file: string) { - return path.relative('/', path.resolve('/', file)) + return path.posix.relative('/', path.posix.resolve('/', file)) } export default function plugin ({ diff --git a/src/service-override/extensionGallery.ts b/src/service-override/extensionGallery.ts index 9d06d6bb..2bdbccdf 100644 --- a/src/service-override/extensionGallery.ts +++ b/src/service-override/extensionGallery.ts @@ -62,7 +62,7 @@ class ExtensionManagementServerServiceOverride extends ExtensionManagementServer @ILabelService readonly labelService: ILabelService, @IInstantiationService readonly instantiationService: IInstantiationService ) { - super(isWebOnly ? remoteAgentService : new EmptyRemoteAgentService(), labelService, instantiationService) + super(isWebOnly ? new EmptyRemoteAgentService() : remoteAgentService, labelService, instantiationService) } } diff --git a/src/service-override/remoteAgent.ts b/src/service-override/remoteAgent.ts index 9034e050..2f2fddff 100644 --- a/src/service-override/remoteAgent.ts +++ b/src/service-override/remoteAgent.ts @@ -22,11 +22,14 @@ import { IRemoteUserDataProfilesService } from 'vs/workbench/services/userDataPr import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile' import { IActiveLanguagePackService } from 'vs/workbench/services/localization/common/locale' import { IExtensionDescription } from 'vs/platform/extensions/common/extensions' +import { ITunnelService } from 'vs/platform/tunnel/common/tunnel' +import { TunnelService } from 'vs/workbench/services/tunnel/browser/tunnelService' import getEnvironmentServiceOverride from './environment' import { getWorkbenchConstructionOptions } from '../workbench' import { registerServiceInitializePreParticipant } from '../lifecycle' import 'vs/workbench/contrib/remote/common/remote.contribution' import 'vs/workbench/contrib/remote/browser/remote.contribution' +import 'vs/workbench/contrib/remote/browser/remoteStartEntry.contribution' class CustomRemoteSocketFactoryService extends RemoteSocketFactoryService { constructor (@IBrowserWorkbenchEnvironmentService browserWorkbenchEnvironmentService: IBrowserWorkbenchEnvironmentService) { @@ -91,6 +94,7 @@ export default function getServiceOverride ({ scanRemoteExtensions = false }: Re [IRemoteAuthorityResolverService.toString()]: new SyncDescriptor(InjectedRemoteAuthorityResolverService, []), [IRemoteExplorerService.toString()]: new SyncDescriptor(RemoteExplorerService, [], true), [IExternalUriOpenerService.toString()]: new SyncDescriptor(ExternalUriOpenerService, [], true), - [IRemoteExtensionsScannerService.toString()]: new SyncDescriptor(CustomRemoteExtensionsScannerService, [scanRemoteExtensions], true) + [IRemoteExtensionsScannerService.toString()]: new SyncDescriptor(CustomRemoteExtensionsScannerService, [scanRemoteExtensions], true), + [ITunnelService.toString()]: new SyncDescriptor(TunnelService, [], true) } } diff --git a/src/service-override/storage.ts b/src/service-override/storage.ts index b63f3006..5ff7abfe 100644 --- a/src/service-override/storage.ts +++ b/src/service-override/storage.ts @@ -82,7 +82,7 @@ class ExternalStorageService extends AbstractStorageService { private readonly profileStorage = this._register(new ExternalStorage(StorageScope.PROFILE, this.provider)) private readonly workspaceStorage = this._register(new ExternalStorage(StorageScope.WORKSPACE, this.provider)) - constructor (protected readonly provider: IStorageProvider) { + constructor (protected readonly provider: IStorageProvider, private fallbackOverride?: Record) { super({ flushInterval: 5000 }) @@ -129,6 +129,30 @@ class ExternalStorageService extends AbstractStorageService { hasScope (_scope: IAnyWorkspaceIdentifier | IUserDataProfile): boolean { return false } + + override get(key: string, scope: VSStorageScope, fallbackValue: string): string + override get(key: string, scope: VSStorageScope): string | undefined + override get (key: string, scope: VSStorageScope, fallbackValue?: string): string | undefined { + return this.getStorage(scope).get(key, (this.fallbackOverride?.[key] as string | undefined) ?? fallbackValue) + } + + override getBoolean(key: string, scope: VSStorageScope, fallbackValue: boolean): boolean + override getBoolean(key: string, scope: VSStorageScope): boolean | undefined + override getBoolean (key: string, scope: VSStorageScope, fallbackValue?: boolean): boolean | undefined { + return this.getStorage(scope).getBoolean(key, (this.fallbackOverride?.[key] as boolean | undefined) ?? fallbackValue) + } + + override getNumber(key: string, scope: VSStorageScope, fallbackValue: number): number + override getNumber(key: string, scope: VSStorageScope): number | undefined + override getNumber (key: string, scope: VSStorageScope, fallbackValue?: number): number | undefined { + return this.getStorage(scope).getNumber(key, (this.fallbackOverride?.[key] as number | undefined) ?? fallbackValue) + } + + override getObject(key: string, scope: VSStorageScope, fallbackValue: object): object + override getObject(key: string, scope: VSStorageScope): object | undefined + override getObject (key: string, scope: VSStorageScope, fallbackValue?: object): object | undefined { + return this.getStorage(scope).getObject(key, (this.fallbackOverride?.[key] as object | undefined) ?? fallbackValue) + } } registerServiceInitializePreParticipant(async (accessor) => { @@ -147,22 +171,55 @@ registerServiceInitializePreParticipant(async (accessor) => { class InjectedBrowserStorageService extends BrowserStorageService { constructor ( + private fallbackOverride: Record | undefined, @IUserDataProfileService userDataProfileService: IUserDataProfileService, @ILogService logService: ILogService ) { super(getWorkspaceIdentifier(), userDataProfileService, logService) } + + override get(key: string, scope: VSStorageScope, fallbackValue: string): string + override get(key: string, scope: VSStorageScope): string | undefined + override get (key: string, scope: VSStorageScope, fallbackValue?: string): string | undefined { + return this.getStorage(scope)?.get(key, (this.fallbackOverride?.[key] as string | undefined) ?? fallbackValue) + } + + override getBoolean(key: string, scope: VSStorageScope, fallbackValue: boolean): boolean + override getBoolean(key: string, scope: VSStorageScope): boolean | undefined + override getBoolean (key: string, scope: VSStorageScope, fallbackValue?: boolean): boolean | undefined { + return this.getStorage(scope)?.getBoolean(key, (this.fallbackOverride?.[key] as boolean | undefined) ?? fallbackValue) + } + + override getNumber(key: string, scope: VSStorageScope, fallbackValue: number): number + override getNumber(key: string, scope: VSStorageScope): number | undefined + override getNumber (key: string, scope: VSStorageScope, fallbackValue?: number): number | undefined { + return this.getStorage(scope)?.getNumber(key, (this.fallbackOverride?.[key] as number | undefined) ?? fallbackValue) + } + + override getObject(key: string, scope: VSStorageScope, fallbackValue: object): object + override getObject(key: string, scope: VSStorageScope): object | undefined + override getObject (key: string, scope: VSStorageScope, fallbackValue?: object): object | undefined { + return this.getStorage(scope)?.getObject(key, (this.fallbackOverride?.[key] as object | undefined) ?? fallbackValue) + } +} + +interface StorageServiceParameters { + customProvider?: IStorageProvider + /** + * Allows to override the storage key default values + */ + fallbackOverride?: Record } -export default function getStorageServiceOverride (provider?: IStorageProvider): IEditorOverrideServices { - if (provider != null) { +export default function getStorageServiceOverride ({ customProvider, fallbackOverride }: StorageServiceParameters = {}): IEditorOverrideServices { + if (customProvider != null) { return { - [IStorageService.toString()]: new SyncDescriptor(ExternalStorageService, [provider], true), + [IStorageService.toString()]: new SyncDescriptor(ExternalStorageService, [customProvider, fallbackOverride], true), [IExtensionStorageService.toString()]: new SyncDescriptor(ExtensionStorageService, [], true) } } else { return { - [IStorageService.toString()]: new SyncDescriptor(InjectedBrowserStorageService, [], true), + [IStorageService.toString()]: new SyncDescriptor(InjectedBrowserStorageService, [fallbackOverride], true), [IExtensionStorageService.toString()]: new SyncDescriptor(ExtensionStorageService, [], true) } }