@theia/application-manager 1.45.1 → 1.46.0-next.72

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.
Files changed (45) hide show
  1. package/README.md +25 -25
  2. package/lib/application-package-manager.d.ts +45 -39
  3. package/lib/application-package-manager.d.ts.map +1 -1
  4. package/lib/application-package-manager.js +225 -207
  5. package/lib/application-package-manager.js.map +1 -1
  6. package/lib/application-process.d.ts +19 -19
  7. package/lib/application-process.js +72 -72
  8. package/lib/expose-loader.d.ts +8 -8
  9. package/lib/expose-loader.js +69 -69
  10. package/lib/generator/abstract-generator.d.ts +17 -16
  11. package/lib/generator/abstract-generator.d.ts.map +1 -1
  12. package/lib/generator/abstract-generator.js +57 -54
  13. package/lib/generator/abstract-generator.js.map +1 -1
  14. package/lib/generator/backend-generator.d.ts +7 -7
  15. package/lib/generator/backend-generator.d.ts.map +1 -1
  16. package/lib/generator/backend-generator.js +196 -192
  17. package/lib/generator/backend-generator.js.map +1 -1
  18. package/lib/generator/frontend-generator.d.ts +13 -13
  19. package/lib/generator/frontend-generator.d.ts.map +1 -1
  20. package/lib/generator/frontend-generator.js +221 -205
  21. package/lib/generator/frontend-generator.js.map +1 -1
  22. package/lib/generator/index.d.ts +3 -3
  23. package/lib/generator/index.js +30 -30
  24. package/lib/generator/webpack-generator.d.ts +12 -12
  25. package/lib/generator/webpack-generator.d.ts.map +1 -1
  26. package/lib/generator/webpack-generator.js +506 -500
  27. package/lib/generator/webpack-generator.js.map +1 -1
  28. package/lib/index.d.ts +3 -3
  29. package/lib/index.js +30 -30
  30. package/lib/package.spec.js +25 -25
  31. package/lib/rebuild.d.ts +24 -24
  32. package/lib/rebuild.d.ts.map +1 -1
  33. package/lib/rebuild.js +309 -309
  34. package/package.json +7 -6
  35. package/src/application-package-manager.ts +263 -241
  36. package/src/application-process.ts +80 -80
  37. package/src/expose-loader.ts +80 -80
  38. package/src/generator/abstract-generator.ts +69 -65
  39. package/src/generator/backend-generator.ts +198 -194
  40. package/src/generator/frontend-generator.ts +231 -215
  41. package/src/generator/index.ts +19 -19
  42. package/src/generator/webpack-generator.ts +514 -508
  43. package/src/index.ts +19 -19
  44. package/src/package.spec.ts +28 -28
  45. package/src/rebuild.ts +345 -345
@@ -1,215 +1,231 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 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
- /* eslint-disable @typescript-eslint/indent */
18
-
19
- import { EOL } from 'os';
20
- import { AbstractGenerator, GeneratorOptions } from './abstract-generator';
21
- import { existsSync, readFileSync } from 'fs';
22
-
23
- export class FrontendGenerator extends AbstractGenerator {
24
-
25
- async generate(options?: GeneratorOptions): Promise<void> {
26
- await this.write(this.pck.frontend('index.html'), this.compileIndexHtml(this.pck.targetFrontendModules));
27
- await this.write(this.pck.frontend('index.js'), this.compileIndexJs(this.pck.targetFrontendModules, this.pck.frontendPreloadModules));
28
- await this.write(this.pck.frontend('secondary-window.html'), this.compileSecondaryWindowHtml());
29
- await this.write(this.pck.frontend('secondary-index.js'), this.compileSecondaryIndexJs(this.pck.secondaryWindowModules));
30
- if (this.pck.isElectron()) {
31
- await this.write(this.pck.frontend('preload.js'), this.compilePreloadJs());
32
- }
33
- }
34
-
35
- protected compileIndexPreload(frontendModules: Map<string, string>): string {
36
- const template = this.pck.props.generator.config.preloadTemplate;
37
- if (!template) {
38
- return '';
39
- }
40
-
41
- // Support path to html file
42
- if (existsSync(template)) {
43
- return readFileSync(template).toString();
44
- }
45
-
46
- return template;
47
- }
48
-
49
- protected compileIndexHtml(frontendModules: Map<string, string>): string {
50
- return `<!DOCTYPE html>
51
- <html lang="en">
52
-
53
- <head>${this.compileIndexHead(frontendModules)}
54
- </head>
55
-
56
- <body>
57
- <div class="theia-preload">${this.compileIndexPreload(frontendModules)}</div>
58
- <script type="text/javascript" src="./bundle.js" charset="utf-8"></script>
59
- </body>
60
-
61
- </html>`;
62
- }
63
-
64
- protected compileIndexHead(frontendModules: Map<string, string>): string {
65
- return `
66
- <meta charset="UTF-8">
67
- <meta name="viewport" content="width=device-width, initial-scale=1">
68
- <meta name="apple-mobile-web-app-capable" content="yes">
69
- <title>${this.pck.props.frontend.config.applicationName}</title>`;
70
- }
71
-
72
- protected compileIndexJs(frontendModules: Map<string, string>, frontendPreloadModules: Map<string, string>): string {
73
- return `\
74
- // @ts-check
75
- ${this.ifBrowser("require('es6-promise/auto');")}
76
- require('reflect-metadata');
77
- require('setimmediate');
78
- const { Container } = require('inversify');
79
- const { FrontendApplicationConfigProvider } = require('@theia/core/lib/browser/frontend-application-config-provider');
80
-
81
- FrontendApplicationConfigProvider.set(${this.prettyStringify(this.pck.props.frontend.config)});
82
-
83
- ${this.ifMonaco(() => `
84
- self.MonacoEnvironment = {
85
- getWorkerUrl: function (moduleId, label) {
86
- return './editor.worker.js';
87
- }
88
- }`)}
89
-
90
- function load(container, jsModule) {
91
- return Promise.resolve(jsModule)
92
- .then(containerModule => container.load(containerModule.default));
93
- }
94
-
95
- async function preload(container) {
96
- try {
97
- ${Array.from(frontendPreloadModules.values(), jsModulePath => `\
98
- await load(container, ${this.importOrRequire()}('${jsModulePath}'));`).join(EOL)}
99
- const { Preloader } = require('@theia/core/lib/browser/preload/preloader');
100
- const preloader = container.get(Preloader);
101
- await preloader.initialize();
102
- } catch (reason) {
103
- console.error('Failed to run preload scripts.');
104
- if (reason) {
105
- console.error(reason);
106
- }
107
- }
108
- }
109
-
110
- module.exports = (async () => {
111
- const { messagingFrontendModule } = require('@theia/core/lib/${this.pck.isBrowser()
112
- ? 'browser/messaging/messaging-frontend-module'
113
- : 'electron-browser/messaging/electron-messaging-frontend-module'}');
114
- const container = new Container();
115
- container.load(messagingFrontendModule);
116
- await preload(container);
117
- const { FrontendApplication } = require('@theia/core/lib/browser');
118
- const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
119
- const { loggerFrontendModule } = require('@theia/core/lib/browser/logger-frontend-module');
120
-
121
- container.load(frontendApplicationModule);
122
- container.load(loggerFrontendModule);
123
-
124
- try {
125
- ${Array.from(frontendModules.values(), jsModulePath => `\
126
- await load(container, ${this.importOrRequire()}('${jsModulePath}'));`).join(EOL)}
127
- await start();
128
- } catch (reason) {
129
- console.error('Failed to start the frontend application.');
130
- if (reason) {
131
- console.error(reason);
132
- }
133
- }
134
-
135
- function start() {
136
- (window['theia'] = window['theia'] || {}).container = container;
137
- return container.get(FrontendApplication).start();
138
- }
139
- })();
140
- `;
141
- }
142
-
143
- protected importOrRequire(): string {
144
- return this.options.mode !== 'production' ? 'import' : 'require';
145
- }
146
-
147
- /** HTML for secondary windows that contain an extracted widget. */
148
- protected compileSecondaryWindowHtml(): string {
149
- return `<!DOCTYPE html>
150
- <html lang="en">
151
-
152
- <head>
153
- <meta charset="UTF-8">
154
- <title>Theia — Secondary Window</title>
155
- <style>
156
- html, body {
157
- overflow: hidden;
158
- -ms-overflow-style: none;
159
- }
160
-
161
- body {
162
- margin: 0;
163
- }
164
-
165
- html,
166
- head,
167
- body,
168
- .secondary-widget-root,
169
- #widget-host {
170
- width: 100% !important;
171
- height: 100% !important;
172
- }
173
- </style>
174
- <link rel="stylesheet" href="./secondary-window.css">
175
- <script>
176
- window.addEventListener('message', e => {
177
- // Only process messages from Theia main window
178
- if (e.source === window.opener) {
179
- // Delegate message to iframe
180
- document.getElementsByTagName('iframe').item(0).contentWindow.postMessage({ ...e.data }, '*');
181
- }
182
- });
183
- </script>
184
- </head>
185
-
186
- <body>
187
- <div id="widget-host"></div>
188
- </body>
189
-
190
- </html>`;
191
- }
192
-
193
- protected compileSecondaryIndexJs(secondaryWindowModules: Map<string, string>): string {
194
- return `\
195
- // @ts-check
196
- require('reflect-metadata');
197
- const { Container } = require('inversify');
198
-
199
- module.exports = Promise.resolve().then(() => {
200
- const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
201
- const container = new Container();
202
- container.load(frontendApplicationModule);
203
- ${Array.from(secondaryWindowModules.values(), jsModulePath => `\
204
- container.load(require('${jsModulePath}').default);`).join(EOL)}
205
- });
206
- `;
207
- }
208
-
209
- compilePreloadJs(): string {
210
- return `\
211
- // @ts-check
212
- ${Array.from(this.pck.preloadModules.values(), path => `require('${path}').preload();`).join(EOL)}
213
- `;
214
- }
215
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 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
+ /* eslint-disable @typescript-eslint/indent */
18
+
19
+ import { EOL } from 'os';
20
+ import { AbstractGenerator, GeneratorOptions } from './abstract-generator';
21
+ import { existsSync, readFileSync } from 'fs';
22
+
23
+ export class FrontendGenerator extends AbstractGenerator {
24
+
25
+ async generate(options?: GeneratorOptions): Promise<void> {
26
+ await this.write(this.pck.frontend('index.html'), this.compileIndexHtml(this.pck.targetFrontendModules));
27
+ await this.write(this.pck.frontend('index.js'), this.compileIndexJs(this.pck.targetFrontendModules, this.pck.targetFrontendPreloadModules));
28
+ await this.write(this.pck.frontend('secondary-window.html'), this.compileSecondaryWindowHtml());
29
+ await this.write(this.pck.frontend('secondary-index.js'), this.compileSecondaryIndexJs(this.pck.secondaryWindowModules));
30
+ if (this.pck.isElectron()) {
31
+ await this.write(this.pck.frontend('preload.js'), this.compilePreloadJs());
32
+ }
33
+ }
34
+
35
+ protected compileIndexPreload(frontendModules: Map<string, string>): string {
36
+ const template = this.pck.props.generator.config.preloadTemplate;
37
+ if (!template) {
38
+ return '';
39
+ }
40
+
41
+ // Support path to html file
42
+ if (existsSync(template)) {
43
+ return readFileSync(template).toString();
44
+ }
45
+
46
+ return template;
47
+ }
48
+
49
+ protected compileIndexHtml(frontendModules: Map<string, string>): string {
50
+ return `<!DOCTYPE html>
51
+ <html lang="en">
52
+
53
+ <head>${this.compileIndexHead(frontendModules)}
54
+ </head>
55
+
56
+ <body>
57
+ <div class="theia-preload">${this.compileIndexPreload(frontendModules)}</div>
58
+ <script type="text/javascript" src="./bundle.js" charset="utf-8"></script>
59
+ </body>
60
+
61
+ </html>`;
62
+ }
63
+
64
+ protected compileIndexHead(frontendModules: Map<string, string>): string {
65
+ return `
66
+ <meta charset="UTF-8">
67
+ <meta name="viewport" content="width=device-width, initial-scale=1">
68
+ <meta name="apple-mobile-web-app-capable" content="yes">
69
+ <title>${this.pck.props.frontend.config.applicationName}</title>`;
70
+ }
71
+
72
+ protected compileIndexJs(frontendModules: Map<string, string>, frontendPreloadModules: Map<string, string>): string {
73
+ return `\
74
+ // @ts-check
75
+ ${this.ifBrowser("require('es6-promise/auto');")}
76
+ require('reflect-metadata');
77
+ require('setimmediate');
78
+ const { Container } = require('inversify');
79
+ const { FrontendApplicationConfigProvider } = require('@theia/core/lib/browser/frontend-application-config-provider');
80
+
81
+ FrontendApplicationConfigProvider.set(${this.prettyStringify(this.pck.props.frontend.config)});
82
+
83
+ ${this.ifMonaco(() => `
84
+ self.MonacoEnvironment = {
85
+ getWorkerUrl: function (moduleId, label) {
86
+ return './editor.worker.js';
87
+ }
88
+ }`)}
89
+
90
+ function load(container, jsModule) {
91
+ return Promise.resolve(jsModule)
92
+ .then(containerModule => container.load(containerModule.default));
93
+ }
94
+
95
+ async function preload(container) {
96
+ try {
97
+ ${Array.from(frontendPreloadModules.values(), jsModulePath => `\
98
+ await load(container, ${this.importOrRequire()}('${jsModulePath}'));`).join(EOL)}
99
+ const { Preloader } = require('@theia/core/lib/browser/preload/preloader');
100
+ const preloader = container.get(Preloader);
101
+ await preloader.initialize();
102
+ } catch (reason) {
103
+ console.error('Failed to run preload scripts.');
104
+ if (reason) {
105
+ console.error(reason);
106
+ }
107
+ }
108
+ }
109
+
110
+ module.exports = (async () => {
111
+ const { messagingFrontendModule } = require('@theia/core/lib/${this.pck.isBrowser()
112
+ ? 'browser/messaging/messaging-frontend-module'
113
+ : 'electron-browser/messaging/electron-messaging-frontend-module'}');
114
+ const container = new Container();
115
+ container.load(messagingFrontendModule);
116
+ ${this.ifBrowserOnly(`const { messagingFrontendOnlyModule } = require('@theia/core/lib/browser-only/messaging/messaging-frontend-only-module');
117
+ container.load(messagingFrontendOnlyModule);`)}
118
+
119
+ await preload(container);
120
+
121
+ ${this.ifMonaco(() => `
122
+ const { MonacoInit } = require('@theia/monaco/lib/browser/monaco-init');
123
+ `)};
124
+
125
+ const { FrontendApplication } = require('@theia/core/lib/browser');
126
+ const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
127
+ const { loggerFrontendModule } = require('@theia/core/lib/browser/logger-frontend-module');
128
+
129
+ container.load(frontendApplicationModule);
130
+ ${this.pck.ifBrowserOnly(`const { frontendOnlyApplicationModule } = require('@theia/core/lib/browser-only/frontend-only-application-module');
131
+ container.load(frontendOnlyApplicationModule);`)}
132
+
133
+ container.load(loggerFrontendModule);
134
+ ${this.ifBrowserOnly(`const { loggerFrontendOnlyModule } = require('@theia/core/lib/browser-only/logger-frontend-only-module');
135
+ container.load(loggerFrontendOnlyModule);`)}
136
+
137
+ try {
138
+ ${Array.from(frontendModules.values(), jsModulePath => `\
139
+ await load(container, ${this.importOrRequire()}('${jsModulePath}'));`).join(EOL)}
140
+ ${this.ifMonaco(() => `
141
+ MonacoInit.init(container);
142
+ `)};
143
+ await start();
144
+ } catch (reason) {
145
+ console.error('Failed to start the frontend application.');
146
+ if (reason) {
147
+ console.error(reason);
148
+ }
149
+ }
150
+
151
+ function start() {
152
+ (window['theia'] = window['theia'] || {}).container = container;
153
+ return container.get(FrontendApplication).start();
154
+ }
155
+ })();
156
+ `;
157
+ }
158
+
159
+ protected importOrRequire(): string {
160
+ return this.options.mode !== 'production' ? 'import' : 'require';
161
+ }
162
+
163
+ /** HTML for secondary windows that contain an extracted widget. */
164
+ protected compileSecondaryWindowHtml(): string {
165
+ return `<!DOCTYPE html>
166
+ <html lang="en">
167
+
168
+ <head>
169
+ <meta charset="UTF-8">
170
+ <title>Theia Secondary Window</title>
171
+ <style>
172
+ html, body {
173
+ overflow: hidden;
174
+ -ms-overflow-style: none;
175
+ }
176
+
177
+ body {
178
+ margin: 0;
179
+ }
180
+
181
+ html,
182
+ head,
183
+ body,
184
+ .secondary-widget-root,
185
+ #widget-host {
186
+ width: 100% !important;
187
+ height: 100% !important;
188
+ }
189
+ </style>
190
+ <link rel="stylesheet" href="./secondary-window.css">
191
+ <script>
192
+ window.addEventListener('message', e => {
193
+ // Only process messages from Theia main window
194
+ if (e.source === window.opener) {
195
+ // Delegate message to iframe
196
+ document.getElementsByTagName('iframe').item(0).contentWindow.postMessage({ ...e.data }, '*');
197
+ }
198
+ });
199
+ </script>
200
+ </head>
201
+
202
+ <body>
203
+ <div id="widget-host"></div>
204
+ </body>
205
+
206
+ </html>`;
207
+ }
208
+
209
+ protected compileSecondaryIndexJs(secondaryWindowModules: Map<string, string>): string {
210
+ return `\
211
+ // @ts-check
212
+ require('reflect-metadata');
213
+ const { Container } = require('inversify');
214
+
215
+ module.exports = Promise.resolve().then(() => {
216
+ const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
217
+ const container = new Container();
218
+ container.load(frontendApplicationModule);
219
+ ${Array.from(secondaryWindowModules.values(), jsModulePath => `\
220
+ container.load(require('${jsModulePath}').default);`).join(EOL)}
221
+ });
222
+ `;
223
+ }
224
+
225
+ compilePreloadJs(): string {
226
+ return `\
227
+ // @ts-check
228
+ ${Array.from(this.pck.preloadModules.values(), path => `require('${path}').preload();`).join(EOL)}
229
+ `;
230
+ }
231
+ }
@@ -1,19 +1,19 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 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
- export * from './webpack-generator';
18
- export * from './frontend-generator';
19
- export * from './backend-generator';
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 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
+ export * from './webpack-generator';
18
+ export * from './frontend-generator';
19
+ export * from './backend-generator';