-
Notifications
You must be signed in to change notification settings - Fork 28k
/
environmentService.ts
158 lines (122 loc) · 5.21 KB
/
environmentService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { PerformanceMark } from 'vs/base/common/performance';
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
import { IColorScheme, INativeWindowConfiguration, IOSConfiguration, IPath, IPathsToWaitFor } from 'vs/platform/window/common/window';
import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment';
import { refineServiceDecorator } from 'vs/platform/instantiation/common/instantiation';
import { AbstractNativeEnvironmentService } from 'vs/platform/environment/common/environmentService';
import { memoize } from 'vs/base/common/decorators';
import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
import { IProductService } from 'vs/platform/product/common/productService';
import { joinPath } from 'vs/base/common/resources';
export const INativeWorkbenchEnvironmentService = refineServiceDecorator<IEnvironmentService, INativeWorkbenchEnvironmentService>(IEnvironmentService);
/**
* A subclass of the `IWorkbenchEnvironmentService` to be used only in native
* environments (Windows, Linux, macOS) but not e.g. web.
*/
export interface INativeWorkbenchEnvironmentService extends IBrowserWorkbenchEnvironmentService, INativeEnvironmentService {
// --- Window
readonly window: {
id: number;
colorScheme: IColorScheme;
maximized?: boolean;
accessibilitySupport?: boolean;
isInitialStartup?: boolean;
isCodeCaching?: boolean;
perfMarks: PerformanceMark[];
};
// --- Main
readonly mainPid: number;
readonly os: IOSConfiguration;
readonly machineId: string;
readonly sqmId: string;
readonly vsDeviceId: string;
// --- Paths
readonly execPath: string;
readonly backupPath?: string;
// --- Development
readonly crashReporterDirectory?: string;
readonly crashReporterId?: string;
// --- Editors to --wait
readonly filesToWait?: IPathsToWaitFor;
}
export class NativeWorkbenchEnvironmentService extends AbstractNativeEnvironmentService implements INativeWorkbenchEnvironmentService {
@memoize
get mainPid() { return this.configuration.mainPid; }
@memoize
get machineId() { return this.configuration.machineId; }
@memoize
get sqmId() { return this.configuration.sqmId; }
@memoize
get vsDeviceId() { return this.configuration.vsDeviceId; }
@memoize
get remoteAuthority() { return this.configuration.remoteAuthority; }
@memoize
get expectsResolverExtension() { return !!this.configuration.remoteAuthority?.includes('+'); }
@memoize
get execPath() { return this.configuration.execPath; }
@memoize
get backupPath() { return this.configuration.backupPath; }
@memoize
get window() {
return {
id: this.configuration.windowId,
colorScheme: this.configuration.colorScheme,
maximized: this.configuration.maximized,
accessibilitySupport: this.configuration.accessibilitySupport,
perfMarks: this.configuration.perfMarks,
isInitialStartup: this.configuration.isInitialStartup,
isCodeCaching: typeof this.configuration.codeCachePath === 'string'
};
}
@memoize
get windowLogsPath(): URI { return joinPath(this.logsHome, `window${this.configuration.windowId}`); }
@memoize
get logFile(): URI { return joinPath(this.windowLogsPath, `renderer.log`); }
@memoize
get extHostLogsPath(): URI { return joinPath(this.windowLogsPath, 'exthost'); }
@memoize
get extHostTelemetryLogFile(): URI {
return joinPath(this.extHostLogsPath, 'extensionTelemetry.log');
}
@memoize
get webviewExternalEndpoint(): string { return `${Schemas.vscodeWebview}://{{uuid}}`; }
@memoize
get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }
@memoize
get skipWelcome(): boolean { return !!this.args['skip-welcome']; }
@memoize
get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; }
@memoize
get enableSmokeTestDriver(): boolean { return !!this.args['enable-smoke-test-driver']; }
@memoize
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;
}
@memoize
get os(): IOSConfiguration { return this.configuration.os; }
@memoize
get filesToOpenOrCreate(): IPath[] | undefined { return this.configuration.filesToOpenOrCreate; }
@memoize
get filesToDiff(): IPath[] | undefined { return this.configuration.filesToDiff; }
@memoize
get filesToMerge(): IPath[] | undefined { return this.configuration.filesToMerge; }
@memoize
get filesToWait(): IPathsToWaitFor | undefined { return this.configuration.filesToWait; }
constructor(
private readonly configuration: INativeWindowConfiguration,
productService: IProductService
) {
super(configuration, { homeDir: configuration.homeDir, tmpDir: configuration.tmpDir, userDataDir: configuration.userDataDir }, productService);
}
}