Path: blob/main/src/vs/workbench/services/environment/electron-browser/environmentService.ts
5249 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { PerformanceMark } from '../../../../base/common/performance.js';6import { IBrowserWorkbenchEnvironmentService } from '../browser/environmentService.js';7import { IColorScheme, INativeWindowConfiguration, IOSConfiguration, IPath, IPathsToWaitFor } from '../../../../platform/window/common/window.js';8import { IEnvironmentService, INativeEnvironmentService } from '../../../../platform/environment/common/environment.js';9import { refineServiceDecorator } from '../../../../platform/instantiation/common/instantiation.js';10import { AbstractNativeEnvironmentService } from '../../../../platform/environment/common/environmentService.js';11import { memoize } from '../../../../base/common/decorators.js';12import { URI } from '../../../../base/common/uri.js';13import { Schemas } from '../../../../base/common/network.js';14import { IProductService } from '../../../../platform/product/common/productService.js';15import { joinPath } from '../../../../base/common/resources.js';16import { VSBuffer } from '../../../../base/common/buffer.js';1718export const INativeWorkbenchEnvironmentService = refineServiceDecorator<IEnvironmentService, INativeWorkbenchEnvironmentService>(IEnvironmentService);1920/**21* A subclass of the `IWorkbenchEnvironmentService` to be used only in native22* environments (Windows, Linux, macOS) but not e.g. web.23*/24export interface INativeWorkbenchEnvironmentService extends IBrowserWorkbenchEnvironmentService, INativeEnvironmentService {2526// --- Window27readonly window: {28id: number;29handle?: VSBuffer;30colorScheme: IColorScheme;31maximized?: boolean;32accessibilitySupport?: boolean;33isInitialStartup?: boolean;34isCodeCaching?: boolean;35perfMarks: PerformanceMark[];36};3738// --- Main39readonly mainPid: number;40readonly os: IOSConfiguration;41readonly machineId: string;42readonly sqmId: string;43readonly devDeviceId: string;44readonly isPortable: boolean;4546// --- Paths47readonly execPath: string;48readonly backupPath?: string;4950// --- Development51readonly crashReporterDirectory?: string;52readonly crashReporterId?: string;5354// --- Editors to --wait55readonly filesToWait?: IPathsToWaitFor;56}5758export class NativeWorkbenchEnvironmentService extends AbstractNativeEnvironmentService implements INativeWorkbenchEnvironmentService {5960@memoize61get mainPid() { return this.configuration.mainPid; }6263@memoize64get machineId() { return this.configuration.machineId; }6566@memoize67get sqmId() { return this.configuration.sqmId; }6869@memoize70get devDeviceId() { return this.configuration.devDeviceId; }7172@memoize73get isPortable() { return this.configuration.isPortable; }7475@memoize76get remoteAuthority() { return this.configuration.remoteAuthority; }7778@memoize79get expectsResolverExtension() { return !!this.configuration.remoteAuthority?.includes('+'); }8081@memoize82get execPath() { return this.configuration.execPath; }8384@memoize85get backupPath() { return this.configuration.backupPath; }8687@memoize88get window() {89return {90id: this.configuration.windowId,91handle: this.configuration.handle,92colorScheme: this.configuration.colorScheme,93maximized: this.configuration.maximized,94accessibilitySupport: this.configuration.accessibilitySupport,95perfMarks: this.configuration.perfMarks,96isInitialStartup: this.configuration.isInitialStartup,97isCodeCaching: typeof this.configuration.codeCachePath === 'string'98};99}100101@memoize102get windowLogsPath(): URI { return joinPath(this.logsHome, `window${this.configuration.windowId}`); }103104@memoize105get logFile(): URI { return joinPath(this.windowLogsPath, `renderer.log`); }106107@memoize108get extHostLogsPath(): URI { return joinPath(this.windowLogsPath, 'exthost'); }109110@memoize111get webviewExternalEndpoint(): string { return `${Schemas.vscodeWebview}://{{uuid}}`; }112113@memoize114get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }115116@memoize117get skipWelcome(): boolean { return !!this.args['skip-welcome']; }118119@memoize120get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; }121122@memoize123get enableSmokeTestDriver(): boolean { return !!this.args['enable-smoke-test-driver']; }124125@memoize126get extensionEnabledProposedApi(): string[] | undefined {127if (Array.isArray(this.args['enable-proposed-api'])) {128return this.args['enable-proposed-api'];129}130131if ('enable-proposed-api' in this.args) {132return [];133}134135return undefined;136}137138@memoize139get os(): IOSConfiguration { return this.configuration.os; }140141@memoize142get filesToOpenOrCreate(): IPath[] | undefined { return this.configuration.filesToOpenOrCreate; }143144@memoize145get filesToDiff(): IPath[] | undefined { return this.configuration.filesToDiff; }146147@memoize148get filesToMerge(): IPath[] | undefined { return this.configuration.filesToMerge; }149150@memoize151get filesToWait(): IPathsToWaitFor | undefined { return this.configuration.filesToWait; }152153constructor(154private readonly configuration: INativeWindowConfiguration,155productService: IProductService156) {157super(configuration, { homeDir: configuration.homeDir, tmpDir: configuration.tmpDir, userDataDir: configuration.userDataDir }, productService);158}159}160161162