@theia/application-package 1.48.0 → 1.48.1

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.
@@ -1,264 +1,264 @@
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-only 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
- showWindowEarly: true
37
- };
38
- export interface Partial {
39
-
40
- /**
41
- * Override or add properties to the electron `windowOptions`.
42
- *
43
- * Defaults to `{}`.
44
- */
45
- readonly windowOptions?: BrowserWindowConstructorOptions;
46
-
47
- /**
48
- * Whether or not to show an empty Electron window as early as possible.
49
- *
50
- * Defaults to `true`.
51
- */
52
- readonly showWindowEarly?: boolean;
53
- }
54
- }
55
-
56
- export type DefaultTheme = string | Readonly<{ light: string, dark: string }>;
57
- export namespace DefaultTheme {
58
- export function defaultForOSTheme(theme: DefaultTheme): string {
59
- if (typeof theme === 'string') {
60
- return theme;
61
- }
62
- if (
63
- typeof window !== 'undefined' &&
64
- window.matchMedia &&
65
- window.matchMedia('(prefers-color-scheme: dark)').matches
66
- ) {
67
- return theme.dark;
68
- }
69
- return theme.light;
70
- }
71
- export function defaultBackgroundColor(dark?: boolean): string {
72
- // The default light background color is based on the `colors#editor.background` value from
73
- // `packages/monaco/data/monaco-themes/vscode/dark_vs.json` and the dark background comes from the `light_vs.json`.
74
- return dark ? '#1E1E1E' : '#FFFFFF';
75
- }
76
- }
77
-
78
- /**
79
- * Application configuration for the frontend. The following properties will be injected into the `index.html`.
80
- */
81
- export type FrontendApplicationConfig = RequiredRecursive<FrontendApplicationConfig.Partial>;
82
- export namespace FrontendApplicationConfig {
83
- export const DEFAULT: FrontendApplicationConfig = {
84
- applicationName: 'Eclipse Theia',
85
- defaultTheme: { light: 'light', dark: 'dark' },
86
- defaultIconTheme: 'theia-file-icons',
87
- electron: ElectronFrontendApplicationConfig.DEFAULT,
88
- defaultLocale: '',
89
- validatePreferencesSchema: true,
90
- reloadOnReconnect: false
91
- };
92
- export interface Partial extends ApplicationConfig {
93
-
94
- /**
95
- * The default theme for the application.
96
- *
97
- * Defaults to `dark` if the OS's theme is dark. Otherwise `light`.
98
- */
99
- readonly defaultTheme?: DefaultTheme;
100
-
101
- /**
102
- * The default icon theme for the application.
103
- *
104
- * Defaults to `none`.
105
- */
106
- readonly defaultIconTheme?: string;
107
-
108
- /**
109
- * The name of the application.
110
- *
111
- * Defaults to `Eclipse Theia`.
112
- */
113
- readonly applicationName?: string;
114
-
115
- /**
116
- * Electron specific configuration.
117
- *
118
- * Defaults to `ElectronFrontendApplicationConfig.DEFAULT`.
119
- */
120
- readonly electron?: ElectronFrontendApplicationConfig.Partial;
121
-
122
- /**
123
- * The default locale for the application.
124
- *
125
- * Defaults to "".
126
- */
127
- readonly defaultLocale?: string;
128
-
129
- /**
130
- * When `true`, the application will validate the JSON schema of the preferences on start
131
- * and log warnings to the console if the schema is not valid.
132
- *
133
- * Defaults to `true`.
134
- */
135
- readonly validatePreferencesSchema?: boolean;
136
-
137
- /**
138
- * When 'true', the window will reload in case the front end reconnects to a back-end,
139
- * but the back end does not have a connection context for this front end anymore.
140
- */
141
- readonly reloadOnReconnect?: boolean;
142
- }
143
- }
144
-
145
- /**
146
- * Application configuration for the backend.
147
- */
148
- export type BackendApplicationConfig = RequiredRecursive<BackendApplicationConfig.Partial>;
149
- export namespace BackendApplicationConfig {
150
- export const DEFAULT: BackendApplicationConfig = {
151
- singleInstance: false,
152
- frontendConnectionTimeout: 0
153
- };
154
- export interface Partial extends ApplicationConfig {
155
-
156
- /**
157
- * If true and in Electron mode, only one instance of the application is allowed to run at a time.
158
- *
159
- * Defaults to `false`.
160
- */
161
- readonly singleInstance?: boolean;
162
-
163
- /**
164
- * The time in ms the connection context will be preserved for reconnection after a front end disconnects.
165
- */
166
- readonly frontendConnectionTimeout?: number;
167
- }
168
- }
169
-
170
- /**
171
- * Configuration for the generator.
172
- */
173
- export type GeneratorConfig = RequiredRecursive<GeneratorConfig.Partial>;
174
- export namespace GeneratorConfig {
175
- export const DEFAULT: GeneratorConfig = {
176
- preloadTemplate: ''
177
- };
178
- export interface Partial {
179
-
180
- /**
181
- * Template to use for extra preload content markup (file path or HTML).
182
- *
183
- * Defaults to `''`.
184
- */
185
- readonly preloadTemplate?: string;
186
- }
187
- }
188
-
189
- export interface NpmRegistryProps {
190
-
191
- /**
192
- * Defaults to `false`.
193
- */
194
- readonly next: boolean;
195
-
196
- /**
197
- * Defaults to `https://registry.npmjs.org/`.
198
- */
199
- readonly registry: string;
200
-
201
- }
202
- export namespace NpmRegistryProps {
203
- export const DEFAULT: NpmRegistryProps = {
204
- next: false,
205
- registry: 'https://registry.npmjs.org/'
206
- };
207
- }
208
-
209
- /**
210
- * Representation of all backend and frontend related Theia extension and application properties.
211
- */
212
- export interface ApplicationProps extends NpmRegistryProps {
213
-
214
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
215
- readonly [key: string]: any;
216
-
217
- /**
218
- * Whether the extension targets the browser or electron. Defaults to `browser`.
219
- */
220
- readonly target: ApplicationProps.Target;
221
-
222
- /**
223
- * Frontend related properties.
224
- */
225
- readonly frontend: {
226
- readonly config: FrontendApplicationConfig
227
- };
228
-
229
- /**
230
- * Backend specific properties.
231
- */
232
- readonly backend: {
233
- readonly config: BackendApplicationConfig
234
- };
235
-
236
- /**
237
- * Generator specific properties.
238
- */
239
- readonly generator: {
240
- readonly config: GeneratorConfig
241
- };
242
- }
243
- export namespace ApplicationProps {
244
- export type Target = `${ApplicationTarget}`;
245
- export enum ApplicationTarget {
246
- browser = 'browser',
247
- electron = 'electron',
248
- browserOnly = 'browser-only'
249
- };
250
- export const DEFAULT: ApplicationProps = {
251
- ...NpmRegistryProps.DEFAULT,
252
- target: 'browser',
253
- backend: {
254
- config: BackendApplicationConfig.DEFAULT
255
- },
256
- frontend: {
257
- config: FrontendApplicationConfig.DEFAULT
258
- },
259
- generator: {
260
- config: GeneratorConfig.DEFAULT
261
- }
262
- };
263
-
264
- }
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-only 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
+ showWindowEarly: true
37
+ };
38
+ export interface Partial {
39
+
40
+ /**
41
+ * Override or add properties to the electron `windowOptions`.
42
+ *
43
+ * Defaults to `{}`.
44
+ */
45
+ readonly windowOptions?: BrowserWindowConstructorOptions;
46
+
47
+ /**
48
+ * Whether or not to show an empty Electron window as early as possible.
49
+ *
50
+ * Defaults to `true`.
51
+ */
52
+ readonly showWindowEarly?: boolean;
53
+ }
54
+ }
55
+
56
+ export type DefaultTheme = string | Readonly<{ light: string, dark: string }>;
57
+ export namespace DefaultTheme {
58
+ export function defaultForOSTheme(theme: DefaultTheme): string {
59
+ if (typeof theme === 'string') {
60
+ return theme;
61
+ }
62
+ if (
63
+ typeof window !== 'undefined' &&
64
+ window.matchMedia &&
65
+ window.matchMedia('(prefers-color-scheme: dark)').matches
66
+ ) {
67
+ return theme.dark;
68
+ }
69
+ return theme.light;
70
+ }
71
+ export function defaultBackgroundColor(dark?: boolean): string {
72
+ // The default light background color is based on the `colors#editor.background` value from
73
+ // `packages/monaco/data/monaco-themes/vscode/dark_vs.json` and the dark background comes from the `light_vs.json`.
74
+ return dark ? '#1E1E1E' : '#FFFFFF';
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Application configuration for the frontend. The following properties will be injected into the `index.html`.
80
+ */
81
+ export type FrontendApplicationConfig = RequiredRecursive<FrontendApplicationConfig.Partial>;
82
+ export namespace FrontendApplicationConfig {
83
+ export const DEFAULT: FrontendApplicationConfig = {
84
+ applicationName: 'Eclipse Theia',
85
+ defaultTheme: { light: 'light', dark: 'dark' },
86
+ defaultIconTheme: 'theia-file-icons',
87
+ electron: ElectronFrontendApplicationConfig.DEFAULT,
88
+ defaultLocale: '',
89
+ validatePreferencesSchema: true,
90
+ reloadOnReconnect: false
91
+ };
92
+ export interface Partial extends ApplicationConfig {
93
+
94
+ /**
95
+ * The default theme for the application.
96
+ *
97
+ * Defaults to `dark` if the OS's theme is dark. Otherwise `light`.
98
+ */
99
+ readonly defaultTheme?: DefaultTheme;
100
+
101
+ /**
102
+ * The default icon theme for the application.
103
+ *
104
+ * Defaults to `none`.
105
+ */
106
+ readonly defaultIconTheme?: string;
107
+
108
+ /**
109
+ * The name of the application.
110
+ *
111
+ * Defaults to `Eclipse Theia`.
112
+ */
113
+ readonly applicationName?: string;
114
+
115
+ /**
116
+ * Electron specific configuration.
117
+ *
118
+ * Defaults to `ElectronFrontendApplicationConfig.DEFAULT`.
119
+ */
120
+ readonly electron?: ElectronFrontendApplicationConfig.Partial;
121
+
122
+ /**
123
+ * The default locale for the application.
124
+ *
125
+ * Defaults to "".
126
+ */
127
+ readonly defaultLocale?: string;
128
+
129
+ /**
130
+ * When `true`, the application will validate the JSON schema of the preferences on start
131
+ * and log warnings to the console if the schema is not valid.
132
+ *
133
+ * Defaults to `true`.
134
+ */
135
+ readonly validatePreferencesSchema?: boolean;
136
+
137
+ /**
138
+ * When 'true', the window will reload in case the front end reconnects to a back-end,
139
+ * but the back end does not have a connection context for this front end anymore.
140
+ */
141
+ readonly reloadOnReconnect?: boolean;
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Application configuration for the backend.
147
+ */
148
+ export type BackendApplicationConfig = RequiredRecursive<BackendApplicationConfig.Partial>;
149
+ export namespace BackendApplicationConfig {
150
+ export const DEFAULT: BackendApplicationConfig = {
151
+ singleInstance: false,
152
+ frontendConnectionTimeout: 0
153
+ };
154
+ export interface Partial extends ApplicationConfig {
155
+
156
+ /**
157
+ * If true and in Electron mode, only one instance of the application is allowed to run at a time.
158
+ *
159
+ * Defaults to `false`.
160
+ */
161
+ readonly singleInstance?: boolean;
162
+
163
+ /**
164
+ * The time in ms the connection context will be preserved for reconnection after a front end disconnects.
165
+ */
166
+ readonly frontendConnectionTimeout?: number;
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Configuration for the generator.
172
+ */
173
+ export type GeneratorConfig = RequiredRecursive<GeneratorConfig.Partial>;
174
+ export namespace GeneratorConfig {
175
+ export const DEFAULT: GeneratorConfig = {
176
+ preloadTemplate: ''
177
+ };
178
+ export interface Partial {
179
+
180
+ /**
181
+ * Template to use for extra preload content markup (file path or HTML).
182
+ *
183
+ * Defaults to `''`.
184
+ */
185
+ readonly preloadTemplate?: string;
186
+ }
187
+ }
188
+
189
+ export interface NpmRegistryProps {
190
+
191
+ /**
192
+ * Defaults to `false`.
193
+ */
194
+ readonly next: boolean;
195
+
196
+ /**
197
+ * Defaults to `https://registry.npmjs.org/`.
198
+ */
199
+ readonly registry: string;
200
+
201
+ }
202
+ export namespace NpmRegistryProps {
203
+ export const DEFAULT: NpmRegistryProps = {
204
+ next: false,
205
+ registry: 'https://registry.npmjs.org/'
206
+ };
207
+ }
208
+
209
+ /**
210
+ * Representation of all backend and frontend related Theia extension and application properties.
211
+ */
212
+ export interface ApplicationProps extends NpmRegistryProps {
213
+
214
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
215
+ readonly [key: string]: any;
216
+
217
+ /**
218
+ * Whether the extension targets the browser or electron. Defaults to `browser`.
219
+ */
220
+ readonly target: ApplicationProps.Target;
221
+
222
+ /**
223
+ * Frontend related properties.
224
+ */
225
+ readonly frontend: {
226
+ readonly config: FrontendApplicationConfig
227
+ };
228
+
229
+ /**
230
+ * Backend specific properties.
231
+ */
232
+ readonly backend: {
233
+ readonly config: BackendApplicationConfig
234
+ };
235
+
236
+ /**
237
+ * Generator specific properties.
238
+ */
239
+ readonly generator: {
240
+ readonly config: GeneratorConfig
241
+ };
242
+ }
243
+ export namespace ApplicationProps {
244
+ export type Target = `${ApplicationTarget}`;
245
+ export enum ApplicationTarget {
246
+ browser = 'browser',
247
+ electron = 'electron',
248
+ browserOnly = 'browser-only'
249
+ };
250
+ export const DEFAULT: ApplicationProps = {
251
+ ...NpmRegistryProps.DEFAULT,
252
+ target: 'browser',
253
+ backend: {
254
+ config: BackendApplicationConfig.DEFAULT
255
+ },
256
+ frontend: {
257
+ config: FrontendApplicationConfig.DEFAULT
258
+ },
259
+ generator: {
260
+ config: GeneratorConfig.DEFAULT
261
+ }
262
+ };
263
+
264
+ }