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