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
3296 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
46
// --- Paths
47
readonly execPath: string;
48
readonly backupPath?: string;
49
50
// --- Development
51
readonly crashReporterDirectory?: string;
52
readonly crashReporterId?: string;
53
54
// --- Editors to --wait
55
readonly filesToWait?: IPathsToWaitFor;
56
}
57
58
export class NativeWorkbenchEnvironmentService extends AbstractNativeEnvironmentService implements INativeWorkbenchEnvironmentService {
59
60
@memoize
61
get mainPid() { return this.configuration.mainPid; }
62
63
@memoize
64
get machineId() { return this.configuration.machineId; }
65
66
@memoize
67
get sqmId() { return this.configuration.sqmId; }
68
69
@memoize
70
get devDeviceId() { return this.configuration.devDeviceId; }
71
72
@memoize
73
get remoteAuthority() { return this.configuration.remoteAuthority; }
74
75
@memoize
76
get expectsResolverExtension() { return !!this.configuration.remoteAuthority?.includes('+'); }
77
78
@memoize
79
get execPath() { return this.configuration.execPath; }
80
81
@memoize
82
get backupPath() { return this.configuration.backupPath; }
83
84
@memoize
85
get window() {
86
return {
87
id: this.configuration.windowId,
88
handle: this.configuration.handle,
89
colorScheme: this.configuration.colorScheme,
90
maximized: this.configuration.maximized,
91
accessibilitySupport: this.configuration.accessibilitySupport,
92
perfMarks: this.configuration.perfMarks,
93
isInitialStartup: this.configuration.isInitialStartup,
94
isCodeCaching: typeof this.configuration.codeCachePath === 'string'
95
};
96
}
97
98
@memoize
99
get windowLogsPath(): URI { return joinPath(this.logsHome, `window${this.configuration.windowId}`); }
100
101
@memoize
102
get logFile(): URI { return joinPath(this.windowLogsPath, `renderer.log`); }
103
104
@memoize
105
get extHostLogsPath(): URI { return joinPath(this.windowLogsPath, 'exthost'); }
106
107
@memoize
108
get webviewExternalEndpoint(): string { return `${Schemas.vscodeWebview}://{{uuid}}`; }
109
110
@memoize
111
get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }
112
113
@memoize
114
get skipWelcome(): boolean { return !!this.args['skip-welcome']; }
115
116
@memoize
117
get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; }
118
119
@memoize
120
get enableSmokeTestDriver(): boolean { return !!this.args['enable-smoke-test-driver']; }
121
122
@memoize
123
get extensionEnabledProposedApi(): string[] | undefined {
124
if (Array.isArray(this.args['enable-proposed-api'])) {
125
return this.args['enable-proposed-api'];
126
}
127
128
if ('enable-proposed-api' in this.args) {
129
return [];
130
}
131
132
return undefined;
133
}
134
135
@memoize
136
get os(): IOSConfiguration { return this.configuration.os; }
137
138
@memoize
139
get filesToOpenOrCreate(): IPath[] | undefined { return this.configuration.filesToOpenOrCreate; }
140
141
@memoize
142
get filesToDiff(): IPath[] | undefined { return this.configuration.filesToDiff; }
143
144
@memoize
145
get filesToMerge(): IPath[] | undefined { return this.configuration.filesToMerge; }
146
147
@memoize
148
get filesToWait(): IPathsToWaitFor | undefined { return this.configuration.filesToWait; }
149
150
constructor(
151
private readonly configuration: INativeWindowConfiguration,
152
productService: IProductService
153
) {
154
super(configuration, { homeDir: configuration.homeDir, tmpDir: configuration.tmpDir, userDataDir: configuration.userDataDir }, productService);
155
}
156
}
157
158