environmentService.ts 2.8 KB
Newer Older
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6
import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
7
import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
8 9 10
import { memoize } from 'vs/base/common/decorators';
import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
11
import { join } from 'vs/base/common/path';
12
import { IProductService } from 'vs/platform/product/common/productService';
13

14
export class NativeWorkbenchEnvironmentService extends NativeEnvironmentService implements INativeWorkbenchEnvironmentService {
15

16
	declare readonly _serviceBrand: undefined;
17

18
	@memoize
19 20
	get webviewExternalEndpoint(): string {
		const baseEndpoint = 'https://{{uuid}}.vscode-webview-test.com/{{commit}}';
21

22
		return baseEndpoint.replace('{{commit}}', this.productService.commit || '0d728c31ebdf03869d2687d9be0b017667c9ff37');
23 24
	}

25
	@memoize
26
	get webviewResourceRoot(): string { return `${Schemas.vscodeWebviewResource}://{{uuid}}/{{resource}}`; }
B
Benjamin Pasero 已提交
27

28
	@memoize
29
	get webviewCspSource(): string { return `${Schemas.vscodeWebviewResource}:`; }
30

31
	@memoize
32
	get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.userData }); }
33

S
Sandeep Somavarapu 已提交
34 35 36
	// Do not memoize as `backupPath` can change in configuration
	get backupWorkspaceHome(): URI | undefined { return this.configuration.backupPath ? URI.file(this.configuration.backupPath).with({ scheme: this.userRoamingDataHome.scheme }) : undefined; }

37
	@memoize
38 39 40 41
	get logFile(): URI { return URI.file(join(this.logsPath, `renderer${this.configuration.windowId}.log`)); }

	@memoize
	get extHostLogsPath(): URI { return URI.file(join(this.logsPath, `exthost${this.configuration.windowId}`)); }
42

43 44 45
	@memoize
	get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }

46 47 48
	@memoize
	get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; }

49
	@memoize
50 51 52 53 54 55 56 57 58 59 60 61
	get extensionEnabledProposedApi(): string[] | undefined {
		if (Array.isArray(this.args['enable-proposed-api'])) {
			return this.args['enable-proposed-api'];
		}

		if ('enable-proposed-api' in this.args) {
			return [];
		}

		return undefined;
	}

62 63
	readonly execPath = this.configuration.execPath;

64 65
	readonly remoteAuthority = this.configuration.remoteAuthority;

66
	constructor(
67 68
		readonly configuration: INativeWorkbenchConfiguration,
		private readonly productService: IProductService
69
	) {
70
		super(configuration);
71
	}
72
}