Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/environment/common/environment.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 { URI } from '../../../base/common/uri.js';
7
import { NativeParsedArgs } from './argv.js';
8
import { createDecorator, refineServiceDecorator } from '../../instantiation/common/instantiation.js';
9
10
export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService');
11
export const INativeEnvironmentService = refineServiceDecorator<IEnvironmentService, INativeEnvironmentService>(IEnvironmentService);
12
13
export interface IDebugParams {
14
port: number | null;
15
break: boolean;
16
}
17
18
export interface IExtensionHostDebugParams extends IDebugParams {
19
debugId?: string;
20
env?: Record<string, string>;
21
}
22
23
/**
24
* Type of extension.
25
*
26
* **NOTE**: This is defined in `platform/environment` because it can appear as a CLI argument.
27
*/
28
export type ExtensionKind = 'ui' | 'workspace' | 'web';
29
30
/**
31
* A basic environment service that can be used in various processes,
32
* such as main, renderer and shared process. Use subclasses of this
33
* service for specific environment.
34
*/
35
export interface IEnvironmentService {
36
37
readonly _serviceBrand: undefined;
38
39
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40
//
41
// NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE.
42
//
43
// AS SUCH:
44
// - PUT NON-WEB PROPERTIES INTO NATIVE ENVIRONMENT SERVICE
45
// - PUT WORKBENCH ONLY PROPERTIES INTO WORKBENCH ENVIRONMENT SERVICE
46
// - PUT ELECTRON-MAIN ONLY PROPERTIES INTO MAIN ENVIRONMENT SERVICE
47
//
48
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
49
50
// --- user roaming data
51
stateResource: URI;
52
userRoamingDataHome: URI;
53
keyboardLayoutResource: URI;
54
argvResource: URI;
55
56
// --- data paths
57
untitledWorkspacesHome: URI;
58
workspaceStorageHome: URI;
59
localHistoryHome: URI;
60
cacheHome: URI;
61
62
// --- settings sync
63
userDataSyncHome: URI;
64
sync: 'on' | 'off' | undefined;
65
66
// --- continue edit session
67
continueOn?: string;
68
editSessionId?: string;
69
70
// --- extension development
71
debugExtensionHost: IExtensionHostDebugParams;
72
isExtensionDevelopment: boolean;
73
disableExtensions: boolean | string[];
74
enableExtensions?: readonly string[];
75
extensionDevelopmentLocationURI?: URI[];
76
extensionDevelopmentKind?: ExtensionKind[];
77
extensionTestsLocationURI?: URI;
78
79
// --- logging
80
logsHome: URI;
81
logLevel?: string;
82
extensionLogLevel?: [string, string][];
83
verbose: boolean;
84
isBuilt: boolean;
85
86
// --- telemetry/exp
87
disableTelemetry: boolean;
88
disableExperiments: boolean;
89
serviceMachineIdResource: URI;
90
91
// --- Policy
92
policyFile?: URI;
93
94
// -- Simulation
95
isSimulation?: boolean;
96
97
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98
//
99
// NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE.
100
//
101
// AS SUCH:
102
// - PUT NON-WEB PROPERTIES INTO NATIVE ENVIRONMENT SERVICE
103
// - PUT WORKBENCH ONLY PROPERTIES INTO WORKBENCH ENVIRONMENT SERVICE
104
// - PUT ELECTRON-MAIN ONLY PROPERTIES INTO MAIN ENVIRONMENT SERVICE
105
//
106
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
107
}
108
109
/**
110
* A subclass of the `IEnvironmentService` to be used only in native
111
* environments (Windows, Linux, macOS) but not e.g. web.
112
*/
113
export interface INativeEnvironmentService extends IEnvironmentService {
114
115
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
116
//
117
// NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE.
118
//
119
// AS SUCH:
120
// - PUT WORKBENCH ONLY PROPERTIES INTO WORKBENCH ENVIRONMENT SERVICE
121
// - PUT ELECTRON-MAIN ONLY PROPERTIES INTO MAIN ENVIRONMENT SERVICE
122
//
123
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
124
125
// --- CLI Arguments
126
args: NativeParsedArgs;
127
128
// --- data paths
129
/**
130
* Root path of the JavaScript sources.
131
*
132
* Note: This is NOT the installation root
133
* directory itself but contained in it at
134
* a level that is platform dependent.
135
*/
136
appRoot: string;
137
userHome: URI;
138
appSettingsHome: URI;
139
tmpDir: URI;
140
userDataPath: string;
141
142
// --- extensions
143
extensionsPath: string;
144
extensionsDownloadLocation: URI;
145
builtinExtensionsPath: string;
146
147
// --- use in-memory Secret Storage
148
useInMemorySecretStorage?: boolean;
149
150
crossOriginIsolated?: boolean;
151
152
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
153
//
154
// NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE.
155
//
156
// AS SUCH:
157
// - PUT NON-WEB PROPERTIES INTO NATIVE ENVIRONMENT SERVICE
158
// - PUT WORKBENCH ONLY PROPERTIES INTO WORKBENCH ENVIRONMENT SERVICE
159
// - PUT ELECTRON-MAIN ONLY PROPERTIES INTO MAIN ENVIRONMENT SERVICE
160
//
161
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
162
}
163
164