Path: blob/main/src/vs/workbench/services/environment/electron-browser/environmentService.ts
3296 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;4445// --- Paths46readonly execPath: string;47readonly backupPath?: string;4849// --- Development50readonly crashReporterDirectory?: string;51readonly crashReporterId?: string;5253// --- Editors to --wait54readonly filesToWait?: IPathsToWaitFor;55}5657export class NativeWorkbenchEnvironmentService extends AbstractNativeEnvironmentService implements INativeWorkbenchEnvironmentService {5859@memoize60get mainPid() { return this.configuration.mainPid; }6162@memoize63get machineId() { return this.configuration.machineId; }6465@memoize66get sqmId() { return this.configuration.sqmId; }6768@memoize69get devDeviceId() { return this.configuration.devDeviceId; }7071@memoize72get remoteAuthority() { return this.configuration.remoteAuthority; }7374@memoize75get expectsResolverExtension() { return !!this.configuration.remoteAuthority?.includes('+'); }7677@memoize78get execPath() { return this.configuration.execPath; }7980@memoize81get backupPath() { return this.configuration.backupPath; }8283@memoize84get window() {85return {86id: this.configuration.windowId,87handle: this.configuration.handle,88colorScheme: this.configuration.colorScheme,89maximized: this.configuration.maximized,90accessibilitySupport: this.configuration.accessibilitySupport,91perfMarks: this.configuration.perfMarks,92isInitialStartup: this.configuration.isInitialStartup,93isCodeCaching: typeof this.configuration.codeCachePath === 'string'94};95}9697@memoize98get windowLogsPath(): URI { return joinPath(this.logsHome, `window${this.configuration.windowId}`); }99100@memoize101get logFile(): URI { return joinPath(this.windowLogsPath, `renderer.log`); }102103@memoize104get extHostLogsPath(): URI { return joinPath(this.windowLogsPath, 'exthost'); }105106@memoize107get webviewExternalEndpoint(): string { return `${Schemas.vscodeWebview}://{{uuid}}`; }108109@memoize110get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }111112@memoize113get skipWelcome(): boolean { return !!this.args['skip-welcome']; }114115@memoize116get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; }117118@memoize119get enableSmokeTestDriver(): boolean { return !!this.args['enable-smoke-test-driver']; }120121@memoize122get extensionEnabledProposedApi(): string[] | undefined {123if (Array.isArray(this.args['enable-proposed-api'])) {124return this.args['enable-proposed-api'];125}126127if ('enable-proposed-api' in this.args) {128return [];129}130131return undefined;132}133134@memoize135get os(): IOSConfiguration { return this.configuration.os; }136137@memoize138get filesToOpenOrCreate(): IPath[] | undefined { return this.configuration.filesToOpenOrCreate; }139140@memoize141get filesToDiff(): IPath[] | undefined { return this.configuration.filesToDiff; }142143@memoize144get filesToMerge(): IPath[] | undefined { return this.configuration.filesToMerge; }145146@memoize147get filesToWait(): IPathsToWaitFor | undefined { return this.configuration.filesToWait; }148149constructor(150private readonly configuration: INativeWindowConfiguration,151productService: IProductService152) {153super(configuration, { homeDir: configuration.homeDir, tmpDir: configuration.tmpDir, userDataDir: configuration.userDataDir }, productService);154}155}156157158