chore(vscode): update to 1.55.2
This commit is contained in:
@@ -4,357 +4,45 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import { gracefulify } from 'graceful-fs';
|
||||
import { zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows';
|
||||
import { mark } from 'vs/base/common/performance';
|
||||
import { Workbench } from 'vs/workbench/browser/workbench';
|
||||
import { NativeWindow } from 'vs/workbench/electron-sandbox/window';
|
||||
import { setZoomLevel, setZoomFactor, setFullscreen } from 'vs/base/browser/browser';
|
||||
import { domContentLoaded } from 'vs/base/browser/dom';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService';
|
||||
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, IWorkspaceInitializationPayload, reviveIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ILoggerService, ILogService } from 'vs/platform/log/common/log';
|
||||
import { NativeStorageService } from 'vs/platform/storage/node/storageService';
|
||||
import { NativeStorageService2 } from 'vs/platform/storage/electron-sandbox/storageService2';
|
||||
import { getUserDataPath } from 'vs/platform/environment/node/userDataPath';
|
||||
import { INativeWorkbenchConfiguration, NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { StorageDatabaseChannelClient } from 'vs/platform/storage/common/storageIpc';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkbenchConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { registerWindowDriver } from 'vs/platform/driver/electron-browser/driver';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/services';
|
||||
import { RemoteAuthorityResolverService } from 'vs/platform/remote/electron-sandbox/remoteAuthorityResolverService';
|
||||
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import { RemoteAgentService } from 'vs/workbench/services/remote/electron-sandbox/remoteAgentServiceImpl';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
import { FileService } from 'vs/platform/files/common/fileService';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { DiskFileSystemProvider } from 'vs/platform/files/electron-browser/diskFileSystemProvider';
|
||||
import { RemoteFileSystemProvider } from 'vs/workbench/services/remote/common/remoteAgentFileSystemChannel';
|
||||
import { ConfigurationCache } from 'vs/workbench/services/configuration/electron-sandbox/configurationCache';
|
||||
import { SignService } from 'vs/platform/sign/node/signService';
|
||||
import { ISignService } from 'vs/platform/sign/common/sign';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
import { basename } from 'vs/base/common/path';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { NativeLogService } from 'vs/workbench/services/log/electron-sandbox/logService';
|
||||
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
|
||||
import { NativeHostService } from 'vs/platform/native/electron-sandbox/nativeHostService';
|
||||
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
|
||||
import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService';
|
||||
import { KeyboardLayoutService } from 'vs/workbench/services/keybinding/electron-sandbox/nativeKeyboardLayout';
|
||||
import { IKeyboardLayoutService } from 'vs/platform/keyboardLayout/common/keyboardLayout';
|
||||
import { ElectronIPCMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
|
||||
import { LoggerChannelClient } from 'vs/platform/log/common/logIpc';
|
||||
import { productService, SharedDesktopMain } from 'vs/workbench/electron-sandbox/shared.desktop.main';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { registerWindowDriver } from 'vs/platform/driver/electron-browser/driver';
|
||||
|
||||
class DesktopMain extends Disposable {
|
||||
class DesktopMain extends SharedDesktopMain {
|
||||
|
||||
private readonly productService: IProductService = { _serviceBrand: undefined, ...product };
|
||||
private readonly environmentService = new NativeWorkbenchEnvironmentService(this.configuration, this.productService);
|
||||
|
||||
constructor(private configuration: INativeWorkbenchConfiguration) {
|
||||
super();
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
private init(): void {
|
||||
constructor(configuration: INativeWorkbenchConfiguration) {
|
||||
super(configuration, new NativeWorkbenchEnvironmentService(configuration, { homeDir: os.homedir(), tmpDir: os.tmpdir(), userDataDir: getUserDataPath(configuration) }, productService));
|
||||
|
||||
// Enable gracefulFs
|
||||
gracefulify(fs);
|
||||
|
||||
// Massage configuration file URIs
|
||||
this.reviveUris();
|
||||
|
||||
// Browser config
|
||||
const zoomLevel = this.configuration.zoomLevel || 0;
|
||||
setZoomFactor(zoomLevelToZoomFactor(zoomLevel));
|
||||
setZoomLevel(zoomLevel, true /* isTrusted */);
|
||||
setFullscreen(!!this.configuration.fullscreen);
|
||||
}
|
||||
|
||||
private reviveUris() {
|
||||
|
||||
// Workspace
|
||||
const workspace = reviveIdentifier(this.configuration.workspace);
|
||||
if (isWorkspaceIdentifier(workspace) || isSingleFolderWorkspaceIdentifier(workspace)) {
|
||||
this.configuration.workspace = workspace;
|
||||
}
|
||||
|
||||
// Files
|
||||
const filesToWait = this.configuration.filesToWait;
|
||||
const filesToWaitPaths = filesToWait?.paths;
|
||||
[filesToWaitPaths, this.configuration.filesToOpenOrCreate, this.configuration.filesToDiff].forEach(paths => {
|
||||
if (Array.isArray(paths)) {
|
||||
paths.forEach(path => {
|
||||
if (path.fileUri) {
|
||||
path.fileUri = URI.revive(path.fileUri);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (filesToWait) {
|
||||
filesToWait.waitMarkerFileUri = URI.revive(filesToWait.waitMarkerFileUri);
|
||||
}
|
||||
}
|
||||
|
||||
async open(): Promise<void> {
|
||||
const services = await this.initServices();
|
||||
|
||||
await domContentLoaded();
|
||||
mark('code/willStartWorkbench');
|
||||
|
||||
// Create Workbench
|
||||
const workbench = new Workbench(document.body, services.serviceCollection, services.logService);
|
||||
|
||||
// Listeners
|
||||
this.registerListeners(workbench, services.storageService);
|
||||
|
||||
// Startup
|
||||
const instantiationService = workbench.startup();
|
||||
|
||||
// Window
|
||||
this._register(instantiationService.createInstance(NativeWindow));
|
||||
protected joinOpen(instantiationService: IInstantiationService): void {
|
||||
|
||||
// Driver
|
||||
if (this.configuration.driver) {
|
||||
instantiationService.invokeFunction(async accessor => this._register(await registerWindowDriver(accessor, this.configuration.windowId)));
|
||||
}
|
||||
|
||||
// Logging
|
||||
services.logService.trace('workbench configuration', JSON.stringify(this.configuration));
|
||||
}
|
||||
|
||||
private registerListeners(workbench: Workbench, storageService: NativeStorageService | NativeStorageService2): void {
|
||||
|
||||
// Workbench Lifecycle
|
||||
this._register(workbench.onWillShutdown(event => event.join(storageService.close(), 'join.closeStorage')));
|
||||
this._register(workbench.onShutdown(() => this.dispose()));
|
||||
}
|
||||
|
||||
private async initServices(): Promise<{ serviceCollection: ServiceCollection, logService: ILogService, storageService: NativeStorageService | NativeStorageService2 }> {
|
||||
const serviceCollection = new ServiceCollection();
|
||||
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//
|
||||
// NOTE: Please do NOT register services here. Use `registerSingleton()`
|
||||
// from `workbench.common.main.ts` if the service is shared between
|
||||
// desktop and web or `workbench.sandbox.main.ts` if the service
|
||||
// is desktop only.
|
||||
//
|
||||
// DO NOT add services to `workbench.desktop.main.ts`, always add
|
||||
// to `workbench.sandbox.main.ts` to support our Electron sandbox
|
||||
//
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
|
||||
// Main Process
|
||||
const mainProcessService = this._register(new ElectronIPCMainProcessService(this.configuration.windowId));
|
||||
serviceCollection.set(IMainProcessService, mainProcessService);
|
||||
|
||||
// Environment
|
||||
serviceCollection.set(IWorkbenchEnvironmentService, this.environmentService);
|
||||
serviceCollection.set(INativeWorkbenchEnvironmentService, this.environmentService);
|
||||
|
||||
// Product
|
||||
serviceCollection.set(IProductService, this.productService);
|
||||
|
||||
// Logger
|
||||
const loggerService = new LoggerChannelClient(mainProcessService.getChannel('logger'));
|
||||
serviceCollection.set(ILoggerService, loggerService);
|
||||
|
||||
// Log
|
||||
const logService = this._register(new NativeLogService(`renderer${this.configuration.windowId}`, loggerService, mainProcessService, this.environmentService));
|
||||
serviceCollection.set(ILogService, logService);
|
||||
|
||||
// Remote
|
||||
const remoteAuthorityResolverService = new RemoteAuthorityResolverService();
|
||||
serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
|
||||
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//
|
||||
// NOTE: Please do NOT register services here. Use `registerSingleton()`
|
||||
// from `workbench.common.main.ts` if the service is shared between
|
||||
// desktop and web or `workbench.sandbox.main.ts` if the service
|
||||
// is desktop only.
|
||||
//
|
||||
// DO NOT add services to `workbench.desktop.main.ts`, always add
|
||||
// to `workbench.sandbox.main.ts` to support our Electron sandbox
|
||||
//
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
|
||||
// Sign
|
||||
const signService = new SignService();
|
||||
serviceCollection.set(ISignService, signService);
|
||||
|
||||
// Remote Agent
|
||||
const remoteAgentService = this._register(new RemoteAgentService(this.environmentService, this.productService, remoteAuthorityResolverService, signService, logService));
|
||||
serviceCollection.set(IRemoteAgentService, remoteAgentService);
|
||||
|
||||
// Native Host
|
||||
const nativeHostService = new NativeHostService(this.configuration.windowId, mainProcessService) as INativeHostService;
|
||||
serviceCollection.set(INativeHostService, nativeHostService);
|
||||
|
||||
// Files
|
||||
const fileService = this._register(new FileService(logService));
|
||||
serviceCollection.set(IFileService, fileService);
|
||||
protected registerFileSystemProviders(fileService: IFileService, logService: ILogService, nativeHostService: INativeHostService): void {
|
||||
|
||||
// Local Files
|
||||
const diskFileSystemProvider = this._register(new DiskFileSystemProvider(logService, nativeHostService));
|
||||
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
|
||||
|
||||
// User Data Provider
|
||||
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(Schemas.file, diskFileSystemProvider, Schemas.userData, logService));
|
||||
|
||||
// Uri Identity
|
||||
const uriIdentityService = new UriIdentityService(fileService);
|
||||
serviceCollection.set(IUriIdentityService, uriIdentityService);
|
||||
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//
|
||||
// NOTE: Please do NOT register services here. Use `registerSingleton()`
|
||||
// from `workbench.common.main.ts` if the service is shared between
|
||||
// desktop and web or `workbench.sandbox.main.ts` if the service
|
||||
// is desktop only.
|
||||
//
|
||||
// DO NOT add services to `workbench.desktop.main.ts`, always add
|
||||
// to `workbench.sandbox.main.ts` to support our Electron sandbox
|
||||
//
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
|
||||
const connection = remoteAgentService.getConnection();
|
||||
if (connection) {
|
||||
const remoteFileSystemProvider = this._register(new RemoteFileSystemProvider(remoteAgentService));
|
||||
fileService.registerProvider(Schemas.vscodeRemote, remoteFileSystemProvider);
|
||||
}
|
||||
|
||||
const payload = this.resolveWorkspaceInitializationPayload();
|
||||
|
||||
const services = await Promise.all([
|
||||
this.createWorkspaceService(payload, fileService, remoteAgentService, uriIdentityService, logService).then(service => {
|
||||
|
||||
// Workspace
|
||||
serviceCollection.set(IWorkspaceContextService, service);
|
||||
|
||||
// Configuration
|
||||
serviceCollection.set(IWorkbenchConfigurationService, service);
|
||||
|
||||
return service;
|
||||
}),
|
||||
|
||||
this.createStorageService(payload, logService, mainProcessService).then(service => {
|
||||
|
||||
// Storage
|
||||
serviceCollection.set(IStorageService, service);
|
||||
|
||||
return service;
|
||||
}),
|
||||
|
||||
this.createKeyboardLayoutService(mainProcessService).then(service => {
|
||||
|
||||
// KeyboardLayout
|
||||
serviceCollection.set(IKeyboardLayoutService, service);
|
||||
|
||||
return service;
|
||||
})
|
||||
]);
|
||||
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//
|
||||
// NOTE: Please do NOT register services here. Use `registerSingleton()`
|
||||
// from `workbench.common.main.ts` if the service is shared between
|
||||
// desktop and web or `workbench.sandbox.main.ts` if the service
|
||||
// is desktop only.
|
||||
//
|
||||
// DO NOT add services to `workbench.desktop.main.ts`, always add
|
||||
// to `workbench.sandbox.main.ts` to support our Electron sandbox
|
||||
//
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
|
||||
return { serviceCollection, logService, storageService: services[1] };
|
||||
}
|
||||
|
||||
private resolveWorkspaceInitializationPayload(): IWorkspaceInitializationPayload {
|
||||
let workspaceInitializationPayload: IWorkspaceInitializationPayload | undefined = this.configuration.workspace;
|
||||
|
||||
// Fallback to empty workspace if we have no payload yet.
|
||||
if (!workspaceInitializationPayload) {
|
||||
let id: string;
|
||||
if (this.configuration.backupPath) {
|
||||
id = basename(this.configuration.backupPath); // we know the backupPath must be a unique path so we leverage its name as workspace ID
|
||||
} else if (this.environmentService.isExtensionDevelopment) {
|
||||
id = 'ext-dev'; // extension development window never stores backups and is a singleton
|
||||
} else {
|
||||
throw new Error('Unexpected window configuration without backupPath');
|
||||
}
|
||||
|
||||
workspaceInitializationPayload = { id };
|
||||
}
|
||||
|
||||
return workspaceInitializationPayload;
|
||||
}
|
||||
|
||||
private async createWorkspaceService(payload: IWorkspaceInitializationPayload, fileService: FileService, remoteAgentService: IRemoteAgentService, uriIdentityService: IUriIdentityService, logService: ILogService): Promise<WorkspaceService> {
|
||||
const workspaceService = new WorkspaceService({ remoteAuthority: this.environmentService.remoteAuthority, configurationCache: new ConfigurationCache(URI.file(this.environmentService.userDataPath), fileService) }, this.environmentService, fileService, remoteAgentService, uriIdentityService, logService);
|
||||
|
||||
try {
|
||||
await workspaceService.initialize(payload);
|
||||
|
||||
return workspaceService;
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
|
||||
return workspaceService;
|
||||
}
|
||||
}
|
||||
|
||||
private async createStorageService(payload: IWorkspaceInitializationPayload, logService: ILogService, mainProcessService: IMainProcessService): Promise<NativeStorageService | NativeStorageService2> {
|
||||
let storageService: NativeStorageService | NativeStorageService2;
|
||||
if (this.configuration.enableExperimentalMainProcessWorkspaceStorage) {
|
||||
storageService = new NativeStorageService2(payload, mainProcessService, this.environmentService);
|
||||
} else {
|
||||
const storageDataBaseClient = new StorageDatabaseChannelClient(mainProcessService.getChannel('storage'), payload);
|
||||
storageService = new NativeStorageService(storageDataBaseClient.globalStorage, payload, logService, this.environmentService);
|
||||
}
|
||||
|
||||
try {
|
||||
await storageService.initialize();
|
||||
|
||||
return storageService;
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
|
||||
return storageService;
|
||||
}
|
||||
}
|
||||
|
||||
private async createKeyboardLayoutService(mainProcessService: IMainProcessService): Promise<KeyboardLayoutService> {
|
||||
const keyboardLayoutService = new KeyboardLayoutService(mainProcessService);
|
||||
|
||||
try {
|
||||
await keyboardLayoutService.initialize();
|
||||
|
||||
return keyboardLayoutService;
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
|
||||
return keyboardLayoutService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user