@theia/application-package 1.34.3 → 1.34.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +641 -641
- package/README.md +25 -25
- package/lib/api.d.ts +5 -5
- package/lib/api.js +23 -23
- package/lib/application-package.d.ts +77 -77
- package/lib/application-package.js +233 -233
- package/lib/application-package.spec.d.ts +1 -1
- package/lib/application-package.spec.js +57 -57
- package/lib/application-props.d.ts +155 -155
- package/lib/application-props.js +86 -86
- package/lib/environment.d.ts +39 -39
- package/lib/environment.js +70 -70
- package/lib/extension-package-collector.d.ts +15 -15
- package/lib/extension-package-collector.js +76 -76
- package/lib/extension-package.d.ts +61 -61
- package/lib/extension-package.js +176 -176
- package/lib/index.d.ts +6 -6
- package/lib/index.js +33 -33
- package/lib/json-file.d.ts +3 -3
- package/lib/json-file.js +26 -26
- package/lib/npm-registry.d.ts +71 -71
- package/lib/npm-registry.js +108 -108
- package/package.json +3 -3
- package/src/api.ts +21 -21
- package/src/application-package.spec.ts +62 -62
- package/src/application-package.ts +301 -301
- package/src/application-props.ts +237 -237
- package/src/environment.ts +76 -76
- package/src/extension-package-collector.ts +83 -83
- package/src/extension-package.ts +219 -219
- package/src/index.ts +22 -22
- package/src/json-file.ts +25 -25
- package/src/npm-registry.ts +169 -169
package/src/application-props.ts
CHANGED
|
@@ -1,237 +1,237 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import type { BrowserWindowConstructorOptions } from 'electron';
|
|
18
|
-
export import deepmerge = require('deepmerge');
|
|
19
|
-
|
|
20
|
-
export type RequiredRecursive<T> = {
|
|
21
|
-
[K in keyof T]-?: T[K] extends object ? RequiredRecursive<T[K]> : T[K]
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Base configuration for the Theia application.
|
|
26
|
-
*/
|
|
27
|
-
export interface ApplicationConfig {
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
readonly [key: string]: any;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type ElectronFrontendApplicationConfig = RequiredRecursive<ElectronFrontendApplicationConfig.Partial>;
|
|
33
|
-
export namespace ElectronFrontendApplicationConfig {
|
|
34
|
-
export const DEFAULT: ElectronFrontendApplicationConfig = {
|
|
35
|
-
windowOptions: {}
|
|
36
|
-
};
|
|
37
|
-
export interface Partial {
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Override or add properties to the electron `windowOptions`.
|
|
41
|
-
*
|
|
42
|
-
* Defaults to `{}`.
|
|
43
|
-
*/
|
|
44
|
-
readonly windowOptions?: BrowserWindowConstructorOptions;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export type DefaultTheme = string | Readonly<{ light: string, dark: string }>;
|
|
49
|
-
export namespace DefaultTheme {
|
|
50
|
-
export function defaultForOSTheme(theme: DefaultTheme): string {
|
|
51
|
-
if (typeof theme === 'string') {
|
|
52
|
-
return theme;
|
|
53
|
-
}
|
|
54
|
-
if (
|
|
55
|
-
typeof window !== 'undefined' &&
|
|
56
|
-
window.matchMedia &&
|
|
57
|
-
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
58
|
-
) {
|
|
59
|
-
return theme.dark;
|
|
60
|
-
}
|
|
61
|
-
return theme.light;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Application configuration for the frontend. The following properties will be injected into the `index.html`.
|
|
67
|
-
*/
|
|
68
|
-
export type FrontendApplicationConfig = RequiredRecursive<FrontendApplicationConfig.Partial>;
|
|
69
|
-
export namespace FrontendApplicationConfig {
|
|
70
|
-
export const DEFAULT: FrontendApplicationConfig = {
|
|
71
|
-
applicationName: 'Eclipse Theia',
|
|
72
|
-
defaultTheme: { light: 'light', dark: 'dark' },
|
|
73
|
-
defaultIconTheme: 'none',
|
|
74
|
-
electron: ElectronFrontendApplicationConfig.DEFAULT,
|
|
75
|
-
defaultLocale: '',
|
|
76
|
-
validatePreferencesSchema: true
|
|
77
|
-
};
|
|
78
|
-
export interface Partial extends ApplicationConfig {
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The default theme for the application.
|
|
82
|
-
*
|
|
83
|
-
* Defaults to `dark` if the OS's theme is dark. Otherwise `light`.
|
|
84
|
-
*/
|
|
85
|
-
readonly defaultTheme?: DefaultTheme;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The default icon theme for the application.
|
|
89
|
-
*
|
|
90
|
-
* Defaults to `none`.
|
|
91
|
-
*/
|
|
92
|
-
readonly defaultIconTheme?: string;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The name of the application.
|
|
96
|
-
*
|
|
97
|
-
* Defaults to `Eclipse Theia`.
|
|
98
|
-
*/
|
|
99
|
-
readonly applicationName?: string;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Electron specific configuration.
|
|
103
|
-
*
|
|
104
|
-
* Defaults to `ElectronFrontendApplicationConfig.DEFAULT`.
|
|
105
|
-
*/
|
|
106
|
-
readonly electron?: ElectronFrontendApplicationConfig.Partial;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* The default locale for the application.
|
|
110
|
-
*
|
|
111
|
-
* Defaults to "".
|
|
112
|
-
*/
|
|
113
|
-
readonly defaultLocale?: string;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* When `true`, the application will validate the JSON schema of the preferences on start
|
|
117
|
-
* and log warnings to the console if the schema is not valid.
|
|
118
|
-
*
|
|
119
|
-
* Defaults to `true`.
|
|
120
|
-
*/
|
|
121
|
-
readonly validatePreferencesSchema?: boolean;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Application configuration for the backend.
|
|
127
|
-
*/
|
|
128
|
-
export type BackendApplicationConfig = RequiredRecursive<BackendApplicationConfig.Partial>;
|
|
129
|
-
export namespace BackendApplicationConfig {
|
|
130
|
-
export const DEFAULT: BackendApplicationConfig = {
|
|
131
|
-
singleInstance: false,
|
|
132
|
-
};
|
|
133
|
-
export interface Partial extends ApplicationConfig {
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* If true and in Electron mode, only one instance of the application is allowed to run at a time.
|
|
137
|
-
*
|
|
138
|
-
* Defaults to `false`.
|
|
139
|
-
*/
|
|
140
|
-
readonly singleInstance?: boolean;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Configuration for the generator.
|
|
146
|
-
*/
|
|
147
|
-
export type GeneratorConfig = RequiredRecursive<GeneratorConfig.Partial>;
|
|
148
|
-
export namespace GeneratorConfig {
|
|
149
|
-
export const DEFAULT: GeneratorConfig = {
|
|
150
|
-
preloadTemplate: ''
|
|
151
|
-
};
|
|
152
|
-
export interface Partial {
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Template to use for extra preload content markup (file path or HTML).
|
|
156
|
-
*
|
|
157
|
-
* Defaults to `''`.
|
|
158
|
-
*/
|
|
159
|
-
readonly preloadTemplate?: string;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export interface NpmRegistryProps {
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Defaults to `false`.
|
|
167
|
-
*/
|
|
168
|
-
readonly next: boolean;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Defaults to `https://registry.npmjs.org/`.
|
|
172
|
-
*/
|
|
173
|
-
readonly registry: string;
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
export namespace NpmRegistryProps {
|
|
177
|
-
export const DEFAULT: NpmRegistryProps = {
|
|
178
|
-
next: false,
|
|
179
|
-
registry: 'https://registry.npmjs.org/'
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Representation of all backend and frontend related Theia extension and application properties.
|
|
185
|
-
*/
|
|
186
|
-
export interface ApplicationProps extends NpmRegistryProps {
|
|
187
|
-
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
189
|
-
readonly [key: string]: any;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Whether the extension targets the browser or electron. Defaults to `browser`.
|
|
193
|
-
*/
|
|
194
|
-
readonly target: ApplicationProps.Target;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Frontend related properties.
|
|
198
|
-
*/
|
|
199
|
-
readonly frontend: {
|
|
200
|
-
readonly config: FrontendApplicationConfig
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Backend specific properties.
|
|
205
|
-
*/
|
|
206
|
-
readonly backend: {
|
|
207
|
-
readonly config: BackendApplicationConfig
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Generator specific properties.
|
|
212
|
-
*/
|
|
213
|
-
readonly generator: {
|
|
214
|
-
readonly config: GeneratorConfig
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
export namespace ApplicationProps {
|
|
218
|
-
export type Target = keyof typeof ApplicationTarget;
|
|
219
|
-
export enum ApplicationTarget {
|
|
220
|
-
browser = 'browser',
|
|
221
|
-
electron = 'electron'
|
|
222
|
-
};
|
|
223
|
-
export const DEFAULT: ApplicationProps = {
|
|
224
|
-
...NpmRegistryProps.DEFAULT,
|
|
225
|
-
target: 'browser',
|
|
226
|
-
backend: {
|
|
227
|
-
config: BackendApplicationConfig.DEFAULT
|
|
228
|
-
},
|
|
229
|
-
frontend: {
|
|
230
|
-
config: FrontendApplicationConfig.DEFAULT
|
|
231
|
-
},
|
|
232
|
-
generator: {
|
|
233
|
-
config: GeneratorConfig.DEFAULT
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import type { BrowserWindowConstructorOptions } from 'electron';
|
|
18
|
+
export import deepmerge = require('deepmerge');
|
|
19
|
+
|
|
20
|
+
export type RequiredRecursive<T> = {
|
|
21
|
+
[K in keyof T]-?: T[K] extends object ? RequiredRecursive<T[K]> : T[K]
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Base configuration for the Theia application.
|
|
26
|
+
*/
|
|
27
|
+
export interface ApplicationConfig {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
readonly [key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type ElectronFrontendApplicationConfig = RequiredRecursive<ElectronFrontendApplicationConfig.Partial>;
|
|
33
|
+
export namespace ElectronFrontendApplicationConfig {
|
|
34
|
+
export const DEFAULT: ElectronFrontendApplicationConfig = {
|
|
35
|
+
windowOptions: {}
|
|
36
|
+
};
|
|
37
|
+
export interface Partial {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Override or add properties to the electron `windowOptions`.
|
|
41
|
+
*
|
|
42
|
+
* Defaults to `{}`.
|
|
43
|
+
*/
|
|
44
|
+
readonly windowOptions?: BrowserWindowConstructorOptions;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type DefaultTheme = string | Readonly<{ light: string, dark: string }>;
|
|
49
|
+
export namespace DefaultTheme {
|
|
50
|
+
export function defaultForOSTheme(theme: DefaultTheme): string {
|
|
51
|
+
if (typeof theme === 'string') {
|
|
52
|
+
return theme;
|
|
53
|
+
}
|
|
54
|
+
if (
|
|
55
|
+
typeof window !== 'undefined' &&
|
|
56
|
+
window.matchMedia &&
|
|
57
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
58
|
+
) {
|
|
59
|
+
return theme.dark;
|
|
60
|
+
}
|
|
61
|
+
return theme.light;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Application configuration for the frontend. The following properties will be injected into the `index.html`.
|
|
67
|
+
*/
|
|
68
|
+
export type FrontendApplicationConfig = RequiredRecursive<FrontendApplicationConfig.Partial>;
|
|
69
|
+
export namespace FrontendApplicationConfig {
|
|
70
|
+
export const DEFAULT: FrontendApplicationConfig = {
|
|
71
|
+
applicationName: 'Eclipse Theia',
|
|
72
|
+
defaultTheme: { light: 'light', dark: 'dark' },
|
|
73
|
+
defaultIconTheme: 'none',
|
|
74
|
+
electron: ElectronFrontendApplicationConfig.DEFAULT,
|
|
75
|
+
defaultLocale: '',
|
|
76
|
+
validatePreferencesSchema: true
|
|
77
|
+
};
|
|
78
|
+
export interface Partial extends ApplicationConfig {
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The default theme for the application.
|
|
82
|
+
*
|
|
83
|
+
* Defaults to `dark` if the OS's theme is dark. Otherwise `light`.
|
|
84
|
+
*/
|
|
85
|
+
readonly defaultTheme?: DefaultTheme;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The default icon theme for the application.
|
|
89
|
+
*
|
|
90
|
+
* Defaults to `none`.
|
|
91
|
+
*/
|
|
92
|
+
readonly defaultIconTheme?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The name of the application.
|
|
96
|
+
*
|
|
97
|
+
* Defaults to `Eclipse Theia`.
|
|
98
|
+
*/
|
|
99
|
+
readonly applicationName?: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Electron specific configuration.
|
|
103
|
+
*
|
|
104
|
+
* Defaults to `ElectronFrontendApplicationConfig.DEFAULT`.
|
|
105
|
+
*/
|
|
106
|
+
readonly electron?: ElectronFrontendApplicationConfig.Partial;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The default locale for the application.
|
|
110
|
+
*
|
|
111
|
+
* Defaults to "".
|
|
112
|
+
*/
|
|
113
|
+
readonly defaultLocale?: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* When `true`, the application will validate the JSON schema of the preferences on start
|
|
117
|
+
* and log warnings to the console if the schema is not valid.
|
|
118
|
+
*
|
|
119
|
+
* Defaults to `true`.
|
|
120
|
+
*/
|
|
121
|
+
readonly validatePreferencesSchema?: boolean;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Application configuration for the backend.
|
|
127
|
+
*/
|
|
128
|
+
export type BackendApplicationConfig = RequiredRecursive<BackendApplicationConfig.Partial>;
|
|
129
|
+
export namespace BackendApplicationConfig {
|
|
130
|
+
export const DEFAULT: BackendApplicationConfig = {
|
|
131
|
+
singleInstance: false,
|
|
132
|
+
};
|
|
133
|
+
export interface Partial extends ApplicationConfig {
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* If true and in Electron mode, only one instance of the application is allowed to run at a time.
|
|
137
|
+
*
|
|
138
|
+
* Defaults to `false`.
|
|
139
|
+
*/
|
|
140
|
+
readonly singleInstance?: boolean;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Configuration for the generator.
|
|
146
|
+
*/
|
|
147
|
+
export type GeneratorConfig = RequiredRecursive<GeneratorConfig.Partial>;
|
|
148
|
+
export namespace GeneratorConfig {
|
|
149
|
+
export const DEFAULT: GeneratorConfig = {
|
|
150
|
+
preloadTemplate: ''
|
|
151
|
+
};
|
|
152
|
+
export interface Partial {
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Template to use for extra preload content markup (file path or HTML).
|
|
156
|
+
*
|
|
157
|
+
* Defaults to `''`.
|
|
158
|
+
*/
|
|
159
|
+
readonly preloadTemplate?: string;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface NpmRegistryProps {
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Defaults to `false`.
|
|
167
|
+
*/
|
|
168
|
+
readonly next: boolean;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Defaults to `https://registry.npmjs.org/`.
|
|
172
|
+
*/
|
|
173
|
+
readonly registry: string;
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
export namespace NpmRegistryProps {
|
|
177
|
+
export const DEFAULT: NpmRegistryProps = {
|
|
178
|
+
next: false,
|
|
179
|
+
registry: 'https://registry.npmjs.org/'
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Representation of all backend and frontend related Theia extension and application properties.
|
|
185
|
+
*/
|
|
186
|
+
export interface ApplicationProps extends NpmRegistryProps {
|
|
187
|
+
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
189
|
+
readonly [key: string]: any;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Whether the extension targets the browser or electron. Defaults to `browser`.
|
|
193
|
+
*/
|
|
194
|
+
readonly target: ApplicationProps.Target;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Frontend related properties.
|
|
198
|
+
*/
|
|
199
|
+
readonly frontend: {
|
|
200
|
+
readonly config: FrontendApplicationConfig
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Backend specific properties.
|
|
205
|
+
*/
|
|
206
|
+
readonly backend: {
|
|
207
|
+
readonly config: BackendApplicationConfig
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Generator specific properties.
|
|
212
|
+
*/
|
|
213
|
+
readonly generator: {
|
|
214
|
+
readonly config: GeneratorConfig
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
export namespace ApplicationProps {
|
|
218
|
+
export type Target = keyof typeof ApplicationTarget;
|
|
219
|
+
export enum ApplicationTarget {
|
|
220
|
+
browser = 'browser',
|
|
221
|
+
electron = 'electron'
|
|
222
|
+
};
|
|
223
|
+
export const DEFAULT: ApplicationProps = {
|
|
224
|
+
...NpmRegistryProps.DEFAULT,
|
|
225
|
+
target: 'browser',
|
|
226
|
+
backend: {
|
|
227
|
+
config: BackendApplicationConfig.DEFAULT
|
|
228
|
+
},
|
|
229
|
+
frontend: {
|
|
230
|
+
config: FrontendApplicationConfig.DEFAULT
|
|
231
|
+
},
|
|
232
|
+
generator: {
|
|
233
|
+
config: GeneratorConfig.DEFAULT
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
}
|
package/src/environment.ts
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
const isElectron: () => boolean = require('is-electron');
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The electron specific environment.
|
|
21
|
-
*/
|
|
22
|
-
class ElectronEnv {
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Environment variable that can be accessed on the `process` to check if running in electron or not.
|
|
26
|
-
*/
|
|
27
|
-
readonly THEIA_ELECTRON_VERSION = 'THEIA_ELECTRON_VERSION';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* `true` if running in electron. Otherwise, `false`.
|
|
31
|
-
*
|
|
32
|
-
* Can be called from both the `main` and the render process. Also works for forked cluster workers.
|
|
33
|
-
*/
|
|
34
|
-
is(): boolean {
|
|
35
|
-
return isElectron();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* `true` if running in Electron in development mode. Otherwise, `false`.
|
|
40
|
-
*
|
|
41
|
-
* Cannot be used from the browser. From the browser, it is always `false`.
|
|
42
|
-
*/
|
|
43
|
-
isDevMode(): boolean {
|
|
44
|
-
return this.is()
|
|
45
|
-
&& typeof process !== 'undefined'
|
|
46
|
-
// `defaultApp` does not exist on the Node.js API, but on electron (`electron.d.ts`).
|
|
47
|
-
&& ((process as any).defaultApp || /node_modules[/\\]electron[/\\]/.test(process.execPath)); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Creates and return with a new environment object which always contains the `ELECTRON_RUN_AS_NODE: 1` property pair.
|
|
52
|
-
* This should be used to `spawn` and `fork` a new Node.js process from the Node.js shipped with Electron. Otherwise, a new Electron
|
|
53
|
-
* process will be spawned which [has side-effects](https://github.com/eclipse-theia/theia/issues/5385).
|
|
54
|
-
*
|
|
55
|
-
* If called from the backend and the `env` argument is not defined, it falls back to `process.env` such as Node.js behaves
|
|
56
|
-
* with the [`SpawnOptions`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
|
|
57
|
-
* If `env` is defined, it will be shallow-copied.
|
|
58
|
-
*
|
|
59
|
-
* Calling this function from the frontend does not make any sense, hence throw an error.
|
|
60
|
-
*/
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
runAsNodeEnv(env?: any): any & { ELECTRON_RUN_AS_NODE: 1 } {
|
|
63
|
-
if (typeof process === 'undefined') {
|
|
64
|
-
throw new Error("'process' cannot be undefined.");
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
...(env === undefined ? process.env : env),
|
|
68
|
-
ELECTRON_RUN_AS_NODE: 1
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const electron = new ElectronEnv();
|
|
75
|
-
const environment: Readonly<{ electron: ElectronEnv }> = { electron };
|
|
76
|
-
export { environment };
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
const isElectron: () => boolean = require('is-electron');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The electron specific environment.
|
|
21
|
+
*/
|
|
22
|
+
class ElectronEnv {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Environment variable that can be accessed on the `process` to check if running in electron or not.
|
|
26
|
+
*/
|
|
27
|
+
readonly THEIA_ELECTRON_VERSION = 'THEIA_ELECTRON_VERSION';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `true` if running in electron. Otherwise, `false`.
|
|
31
|
+
*
|
|
32
|
+
* Can be called from both the `main` and the render process. Also works for forked cluster workers.
|
|
33
|
+
*/
|
|
34
|
+
is(): boolean {
|
|
35
|
+
return isElectron();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* `true` if running in Electron in development mode. Otherwise, `false`.
|
|
40
|
+
*
|
|
41
|
+
* Cannot be used from the browser. From the browser, it is always `false`.
|
|
42
|
+
*/
|
|
43
|
+
isDevMode(): boolean {
|
|
44
|
+
return this.is()
|
|
45
|
+
&& typeof process !== 'undefined'
|
|
46
|
+
// `defaultApp` does not exist on the Node.js API, but on electron (`electron.d.ts`).
|
|
47
|
+
&& ((process as any).defaultApp || /node_modules[/\\]electron[/\\]/.test(process.execPath)); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates and return with a new environment object which always contains the `ELECTRON_RUN_AS_NODE: 1` property pair.
|
|
52
|
+
* This should be used to `spawn` and `fork` a new Node.js process from the Node.js shipped with Electron. Otherwise, a new Electron
|
|
53
|
+
* process will be spawned which [has side-effects](https://github.com/eclipse-theia/theia/issues/5385).
|
|
54
|
+
*
|
|
55
|
+
* If called from the backend and the `env` argument is not defined, it falls back to `process.env` such as Node.js behaves
|
|
56
|
+
* with the [`SpawnOptions`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
|
|
57
|
+
* If `env` is defined, it will be shallow-copied.
|
|
58
|
+
*
|
|
59
|
+
* Calling this function from the frontend does not make any sense, hence throw an error.
|
|
60
|
+
*/
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
runAsNodeEnv(env?: any): any & { ELECTRON_RUN_AS_NODE: 1 } {
|
|
63
|
+
if (typeof process === 'undefined') {
|
|
64
|
+
throw new Error("'process' cannot be undefined.");
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...(env === undefined ? process.env : env),
|
|
68
|
+
ELECTRON_RUN_AS_NODE: 1
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const electron = new ElectronEnv();
|
|
75
|
+
const environment: Readonly<{ electron: ElectronEnv }> = { electron };
|
|
76
|
+
export { environment };
|