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 7
import { EnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
import { IWorkbenchEnvironmentService, IEnvironmentConfiguration } from 'vs/workbench/services/environment/common/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 { toBackupWorkspaceResource } from 'vs/workbench/services/backup/electron-browser/backup';
12
import { join } from 'vs/base/common/path';
M
Matt Bierner 已提交
13
import product from 'vs/platform/product/common/product';
14
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
15

16
export interface INativeWorkbenchEnvironmentService extends IWorkbenchEnvironmentService, INativeEnvironmentService {
17

18
	readonly configuration: INativeEnvironmentConfiguration;
19

20
	readonly crashReporterDirectory?: string;
R
Robo 已提交
21
	readonly crashReporterId?: string;
22 23 24 25 26

	readonly cliPath: string;

	readonly log?: string;
	readonly extHostLogsPath: URI;
27 28
}

29 30
export interface INativeEnvironmentConfiguration extends IEnvironmentConfiguration, INativeWindowConfiguration { }

31
export class NativeWorkbenchEnvironmentService extends EnvironmentService implements INativeWorkbenchEnvironmentService {
32

33
	declare readonly _serviceBrand: undefined;
34

35
	@memoize
36 37
	get webviewExternalEndpoint(): string {
		const baseEndpoint = 'https://{{uuid}}.vscode-webview-test.com/{{commit}}';
38

M
Matt Bierner 已提交
39
		return baseEndpoint.replace('{{commit}}', product.commit || '0d728c31ebdf03869d2687d9be0b017667c9ff37');
40 41
	}

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

45
	@memoize
46
	get webviewCspSource(): string { return `${Schemas.vscodeWebviewResource}:`; }
47

48
	@memoize
49
	get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.userData }); }
50 51

	@memoize
52 53 54 55
	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}`)); }
56

57 58 59
	@memoize
	get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }

60
	constructor(
61
		readonly configuration: INativeEnvironmentConfiguration,
62
		execPath: string
63 64 65 66 67
	) {
		super(configuration, execPath);

		this.configuration.backupWorkspaceResource = this.configuration.backupPath ? toBackupWorkspaceResource(this.configuration.backupPath, this) : undefined;
	}
68
}