@theia/application-manager 1.41.0 → 1.42.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.
@@ -7,10 +7,6 @@ export declare abstract class AbstractGenerator {
7
7
  protected readonly pck: ApplicationPackage;
8
8
  protected options: GeneratorOptions;
9
9
  constructor(pck: ApplicationPackage, options?: GeneratorOptions);
10
- protected compileFrontendModuleImports(modules: Map<string, string>): string;
11
- protected compileBackendModuleImports(modules: Map<string, string>): string;
12
- protected compileElectronMainModuleImports(modules?: Map<string, string>): string;
13
- protected compileModuleImports(modules: Map<string, string>, fn: 'import' | 'require'): string;
14
10
  protected ifBrowser(value: string, defaultValue?: string): string;
15
11
  protected ifElectron(value: string, defaultValue?: string): string;
16
12
  protected write(path: string, content: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-generator.d.ts","sourceRoot":"","sources":["../../src/generator/abstract-generator.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC7B,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,CAAA;IACnC,aAAa,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,8BAAsB,iBAAiB;IAG/B,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,kBAAkB;IAC1C,SAAS,CAAC,OAAO,EAAE,gBAAgB;gBADhB,GAAG,EAAE,kBAAkB,EAChC,OAAO,GAAE,gBAAqB;IAG5C,SAAS,CAAC,4BAA4B,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAK5E,SAAS,CAAC,2BAA2B,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAI3E,SAAS,CAAC,gCAAgC,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IA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,GAAE,MAAW,GAAG,MAAM;IAIrE,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,GAAE,MAAW,GAAG,MAAM;cAItD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,MAAM,EAAE,YAAY,GAAE,MAAM,MAAiB,GAAG,MAAM;IAOtF,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,EAAE,YAAY,GAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAM,GAAG,MAAM;IASvI,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAIpD"}
@@ -16,37 +16,12 @@
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.AbstractGenerator = void 0;
19
- const os = require("os");
20
19
  const fs = require("fs-extra");
21
20
  class AbstractGenerator {
22
21
  constructor(pck, options = {}) {
23
22
  this.pck = pck;
24
23
  this.options = options;
25
24
  }
26
- compileFrontendModuleImports(modules) {
27
- var _a;
28
- const splitFrontend = (_a = this.options.splitFrontend) !== null && _a !== void 0 ? _a : this.options.mode !== 'production';
29
- return this.compileModuleImports(modules, splitFrontend ? 'import' : 'require');
30
- }
31
- compileBackendModuleImports(modules) {
32
- return this.compileModuleImports(modules, 'require');
33
- }
34
- compileElectronMainModuleImports(modules) {
35
- return modules && this.compileModuleImports(modules, 'require') || '';
36
- }
37
- compileModuleImports(modules, fn) {
38
- if (modules.size === 0) {
39
- return '';
40
- }
41
- const lines = Array.from(modules.keys()).map(moduleName => {
42
- const invocation = `${fn}('${modules.get(moduleName)}')`;
43
- if (fn === 'require') {
44
- return `Promise.resolve(${invocation})`;
45
- }
46
- return invocation;
47
- }).map(statement => ` .then(function () { return ${statement}.then(load) })`);
48
- return os.EOL + lines.join(os.EOL);
49
- }
50
25
  ifBrowser(value, defaultValue = '') {
51
26
  return this.pck.ifBrowser(value, defaultValue);
52
27
  }
@@ -73,8 +48,7 @@ class AbstractGenerator {
73
48
  }
74
49
  }
75
50
  prettyStringify(object) {
76
- // eslint-disable-next-line no-null/no-null
77
- return JSON.stringify(object, null, 4);
51
+ return JSON.stringify(object, undefined, 4);
78
52
  }
79
53
  }
80
54
  exports.AbstractGenerator = AbstractGenerator;
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-generator.js","sourceRoot":"","sources":["../../src/generator/abstract-generator.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,yBAAyB;AACzB,+BAA+B;AAQ/B,MAAsB,iBAAiB;IAEnC,YACuB,GAAuB,EAChC,UAA4B,EAAE;QADrB,QAAG,GAAH,GAAG,CAAoB;QAChC,YAAO,GAAP,OAAO,CAAuB;IACxC,CAAC;IAEK,4BAA4B,CAAC,OAA4B;;QAC/D,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,aAAa,mCAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC;QACvF,OAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACpF,CAAC;IAES,2BAA2B,CAAC,OAA4B;QAC9D,OAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACzD,CAAC;IAES,gCAAgC,CAAC,OAA6B;QACpE,OAAO,OAA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CAAC,MAAc;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CAEJ;AAxCD,8CAwCC"}
@@ -1 +1 @@
1
- {"version":3,"file":"backend-generator.d.ts","sourceRoot":"","sources":["../../src/generator/backend-generator.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,qBAAa,gBAAiB,SAAQ,iBAAiB;IAE7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,SAAS,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAoEhF,SAAS,CAAC,aAAa,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAwDpE,SAAS,CAAC,WAAW,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;CAoBrE"}
1
+ {"version":3,"file":"backend-generator.d.ts","sourceRoot":"","sources":["../../src/generator/backend-generator.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,qBAAa,gBAAiB,SAAQ,iBAAiB;IAE7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,SAAS,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAsEhF,SAAS,CAAC,aAAa,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IA4DpE,SAAS,CAAC,WAAW,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;CAoBrE"}
@@ -16,6 +16,7 @@
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.BackendGenerator = void 0;
19
+ const os_1 = require("os");
19
20
  const abstract_generator_1 = require("./abstract-generator");
20
21
  class BackendGenerator extends abstract_generator_1.AbstractGenerator {
21
22
  async generate() {
@@ -27,6 +28,7 @@ class BackendGenerator extends abstract_generator_1.AbstractGenerator {
27
28
  }
28
29
  }
29
30
  compileElectronMain(electronMainModules) {
31
+ var _a;
30
32
  return `// @ts-check
31
33
 
32
34
  require('reflect-metadata');
@@ -52,45 +54,47 @@ const { Container } = require('inversify');
52
54
  const { resolve } = require('path');
53
55
  const { app } = require('electron');
54
56
 
55
- // Fix the window reloading issue, see: https://github.com/electron/electron/issues/22119
56
- app.allowRendererProcessReuse = false;
57
-
58
57
  const config = ${this.prettyStringify(this.pck.props.frontend.config)};
59
58
  const isSingleInstance = ${this.pck.props.backend.config.singleInstance === true ? 'true' : 'false'};
60
59
 
61
- if (isSingleInstance && !app.requestSingleInstanceLock()) {
62
- // There is another instance running, exit now. The other instance will request focus.
63
- app.quit();
64
- return;
65
- }
66
-
67
- const container = new Container();
68
- container.load(electronMainApplicationModule);
69
- container.bind(ElectronMainApplicationGlobals).toConstantValue({
70
- THEIA_APP_PROJECT_PATH: resolve(__dirname, '..', '..'),
71
- THEIA_BACKEND_MAIN_PATH: resolve(__dirname, 'main.js'),
72
- THEIA_FRONTEND_HTML_PATH: resolve(__dirname, '..', '..', 'lib', 'frontend', 'index.html'),
73
- });
74
-
75
- function load(raw) {
76
- return Promise.resolve(raw.default).then(module =>
77
- container.load(module)
78
- );
79
- }
80
-
81
- async function start() {
82
- const application = container.get(ElectronMainApplication);
83
- await application.start(config);
84
- }
60
+ (async () => {
61
+ if (isSingleInstance && !app.requestSingleInstanceLock()) {
62
+ // There is another instance running, exit now. The other instance will request focus.
63
+ app.quit();
64
+ return;
65
+ }
66
+
67
+ const container = new Container();
68
+ container.load(electronMainApplicationModule);
69
+ container.bind(ElectronMainApplicationGlobals).toConstantValue({
70
+ THEIA_APP_PROJECT_PATH: resolve(__dirname, '..', '..'),
71
+ THEIA_BACKEND_MAIN_PATH: resolve(__dirname, 'main.js'),
72
+ THEIA_FRONTEND_HTML_PATH: resolve(__dirname, '..', '..', 'lib', 'frontend', 'index.html'),
73
+ });
74
+
75
+ function load(raw) {
76
+ return Promise.resolve(raw.default).then(module =>
77
+ container.load(module)
78
+ );
79
+ }
80
+
81
+ async function start() {
82
+ const application = container.get(ElectronMainApplication);
83
+ await application.start(config);
84
+ }
85
85
 
86
- module.exports = Promise.resolve()${this.compileElectronMainModuleImports(electronMainModules)}
87
- .then(start).catch(reason => {
86
+ try {
87
+ ${Array.from((_a = electronMainModules === null || electronMainModules === void 0 ? void 0 : electronMainModules.values()) !== null && _a !== void 0 ? _a : [], jsModulePath => `\
88
+ await load(require('${jsModulePath}'));`).join(os_1.EOL)}
89
+ await start();
90
+ } catch (reason) {
88
91
  console.error('Failed to start the electron application.');
89
92
  if (reason) {
90
93
  console.error(reason);
91
94
  }
92
95
  app.quit();
93
- });
96
+ };
97
+ })();
94
98
  `;
95
99
  }
96
100
  compileServer(backendModules) {
@@ -125,27 +129,31 @@ function defaultServeStatic(app) {
125
129
  }
126
130
 
127
131
  function load(raw) {
128
- return Promise.resolve(raw.default).then(
129
- module => container.load(module)
132
+ return Promise.resolve(raw).then(
133
+ module => container.load(module.default)
130
134
  );
131
135
  }
132
136
 
133
- function start(port, host, argv = process.argv) {
137
+ async function start(port, host, argv = process.argv) {
134
138
  if (!container.isBound(BackendApplicationServer)) {
135
139
  container.bind(BackendApplicationServer).toConstantValue({ configure: defaultServeStatic });
136
140
  }
137
- return container.get(CliManager).initializeCli(argv).then(() => {
138
- return container.get(BackendApplication).start(port, host);
139
- });
141
+ await container.get(CliManager).initializeCli(argv);
142
+ return container.get(BackendApplication).start(port, host);
140
143
  }
141
144
 
142
- module.exports = (port, host, argv) => Promise.resolve()${this.compileBackendModuleImports(backendModules)}
143
- .then(() => start(port, host, argv)).catch(error => {
145
+ module.exports = async (port, host, argv) => {
146
+ try {
147
+ ${Array.from(backendModules.values(), jsModulePath => `\
148
+ await load(require('${jsModulePath}'));`).join(os_1.EOL)}
149
+ return await start(port, host, argv);
150
+ } catch (error) {
144
151
  console.error('Failed to start the backend application:');
145
152
  console.error(error);
146
153
  process.exitCode = 1;
147
154
  throw error;
148
- });
155
+ }
156
+ }
149
157
  `;
150
158
  }
151
159
  compileMain(backendModules) {
@@ -1 +1 @@
1
- {"version":3,"file":"backend-generator.js","sourceRoot":"","sources":["../../src/generator/backend-generator.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,6DAAyD;AAEzD,MAAa,gBAAiB,SAAQ,sCAAiB;IAEnD,KAAK,CAAC,QAAQ;QACV,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC;QACrD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;QACpF,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;QAChF,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC;SACxH;IACL,CAAC;IAES,mBAAmB,CAAC,mB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AK,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,CAAC;8BACxB,YAAY,MAAM,CAAC,CAAC,IAAI,CAAC,QAAG,CAAC;;;;;;;;;CAS1D,CAAC;IACE,CAAC;IAES,WAAW,CAAC,cAAmC;QACrD,OAAO;;;;uCAIwB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;;;;;;;;;;;;CAYzF,CAAC;IACE,CAAC;CAEJ;AAjKD,4CAiKC"}
@@ -4,10 +4,10 @@ export declare class FrontendGenerator extends AbstractGenerator {
4
4
  protected compileIndexPreload(frontendModules: Map<string, string>): string;
5
5
  protected compileIndexHtml(frontendModules: Map<string, string>): string;
6
6
  protected compileIndexHead(frontendModules: Map<string, string>): string;
7
- protected compileIndexJs(frontendModules: Map<string, string>): string;
7
+ protected compileIndexJs(frontendModules: Map<string, string>, frontendPreloadModules: Map<string, string>): string;
8
+ protected importOrRequire(): string;
8
9
  /** HTML for secondary windows that contain an extracted widget. */
9
10
  protected compileSecondaryWindowHtml(): string;
10
- protected compileSecondaryModuleImports(secondaryWindowModules: Map<string, string>): string;
11
11
  protected compileSecondaryIndexJs(secondaryWindowModules: Map<string, string>): string;
12
12
  compilePreloadJs(): string;
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"frontend-generator.d.ts","sourceRoot":"","sources":["../../src/generator/frontend-generator.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG3E,qBAAa,iBAAkB,SAAQ,iBAAiB;IAE9C,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUzD,SAAS,CAAC,mBAAmB,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAc3E,SAAS,CAAC,gBAAgB,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IAyEnH,SAAS,CAAC,eAAe,IAAI,MAAM;IAInC,mEAAmE;IACnE,SAAS,CAAC,0BAA0B,IAAI,MAAM;IA6C9C,SAAS,CAAC,uBAAuB,CAAC,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAgBtF,gBAAgB,IAAI,MAAM;CAM7B"}
@@ -17,12 +17,13 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.FrontendGenerator = void 0;
19
19
  /* eslint-disable @typescript-eslint/indent */
20
+ const os_1 = require("os");
20
21
  const abstract_generator_1 = require("./abstract-generator");
21
22
  const fs_1 = require("fs");
22
23
  class FrontendGenerator extends abstract_generator_1.AbstractGenerator {
23
24
  async generate(options) {
24
25
  await this.write(this.pck.frontend('index.html'), this.compileIndexHtml(this.pck.targetFrontendModules));
25
- await this.write(this.pck.frontend('index.js'), this.compileIndexJs(this.pck.targetFrontendModules));
26
+ await this.write(this.pck.frontend('index.js'), this.compileIndexJs(this.pck.targetFrontendModules, this.pck.frontendPreloadModules));
26
27
  await this.write(this.pck.frontend('secondary-window.html'), this.compileSecondaryWindowHtml());
27
28
  await this.write(this.pck.frontend('secondary-index.js'), this.compileSecondaryIndexJs(this.pck.secondaryWindowModules));
28
29
  if (this.pck.isElectron()) {
@@ -61,10 +62,7 @@ class FrontendGenerator extends abstract_generator_1.AbstractGenerator {
61
62
  <meta name="apple-mobile-web-app-capable" content="yes">
62
63
  <title>${this.pck.props.frontend.config.applicationName}</title>`;
63
64
  }
64
- compileIndexJs(frontendModules) {
65
- const compiledModuleImports = this.compileFrontendModuleImports(frontendModules)
66
- // fix the generated indentation
67
- .replace(/^ /g, ' ');
65
+ compileIndexJs(frontendModules, frontendPreloadModules) {
68
66
  return `\
69
67
  // @ts-check
70
68
  ${this.ifBrowser("require('es6-promise/auto');")}
@@ -82,42 +80,63 @@ self.MonacoEnvironment = {
82
80
  }
83
81
  }`)}
84
82
 
85
- const preloader = require('@theia/core/lib/browser/preloader');
83
+ function load(container, jsModule) {
84
+ return Promise.resolve(jsModule)
85
+ .then(containerModule => container.load(containerModule.default));
86
+ }
86
87
 
87
- // We need to fetch some data from the backend before the frontend starts (nls, os)
88
- module.exports = preloader.preload().then(() => {
89
- const { FrontendApplication } = require('@theia/core/lib/browser');
90
- const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
88
+ async function preload(parent) {
89
+ const container = new Container();
90
+ container.parent = parent;
91
+ try {
92
+ ${Array.from(frontendPreloadModules.values(), jsModulePath => `\
93
+ await load(container, ${this.importOrRequire()}('${jsModulePath}'));`).join(os_1.EOL)}
94
+ const { Preloader } = require('@theia/core/lib/browser/preload/preloader');
95
+ const preloader = container.get(Preloader);
96
+ await preloader.initialize();
97
+ } catch (reason) {
98
+ console.error('Failed to run preload scripts.');
99
+ if (reason) {
100
+ console.error(reason);
101
+ }
102
+ }
103
+ }
104
+
105
+ module.exports = (async () => {
91
106
  const { messagingFrontendModule } = require('@theia/core/lib/${this.pck.isBrowser()
92
107
  ? 'browser/messaging/messaging-frontend-module'
93
108
  : 'electron-browser/messaging/electron-messaging-frontend-module'}');
109
+ const container = new Container();
110
+ container.load(messagingFrontendModule);
111
+ await preload(container);
112
+ const { FrontendApplication } = require('@theia/core/lib/browser');
113
+ const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
94
114
  const { loggerFrontendModule } = require('@theia/core/lib/browser/logger-frontend-module');
95
115
 
96
- const container = new Container();
97
116
  container.load(frontendApplicationModule);
98
- container.load(messagingFrontendModule);
99
117
  container.load(loggerFrontendModule);
100
118
 
101
- return Promise.resolve()${compiledModuleImports}
102
- .then(start).catch(reason => {
103
- console.error('Failed to start the frontend application.');
104
- if (reason) {
105
- console.error(reason);
106
- }
107
- });
108
-
109
- function load(jsModule) {
110
- return Promise.resolve(jsModule.default)
111
- .then(containerModule => container.load(containerModule));
119
+ try {
120
+ ${Array.from(frontendModules.values(), jsModulePath => `\
121
+ await load(container, ${this.importOrRequire()}('${jsModulePath}'));`).join(os_1.EOL)}
122
+ await start();
123
+ } catch (reason) {
124
+ console.error('Failed to start the frontend application.');
125
+ if (reason) {
126
+ console.error(reason);
127
+ }
112
128
  }
113
129
 
114
130
  function start() {
115
131
  (window['theia'] = window['theia'] || {}).container = container;
116
132
  return container.get(FrontendApplication).start();
117
133
  }
118
- });
134
+ })();
119
135
  `;
120
136
  }
137
+ importOrRequire() {
138
+ return this.options.mode !== 'production' ? 'import' : 'require';
139
+ }
121
140
  /** HTML for secondary windows that contain an extracted widget. */
122
141
  compileSecondaryWindowHtml() {
123
142
  return `<!DOCTYPE html>
@@ -163,37 +182,25 @@ module.exports = preloader.preload().then(() => {
163
182
 
164
183
  </html>`;
165
184
  }
166
- compileSecondaryModuleImports(secondaryWindowModules) {
167
- const lines = Array.from(secondaryWindowModules.entries())
168
- .map(([moduleName, path]) => ` container.load(require('${path}').default);`);
169
- return '\n' + lines.join('\n');
170
- }
171
185
  compileSecondaryIndexJs(secondaryWindowModules) {
172
- const compiledModuleImports = this.compileSecondaryModuleImports(secondaryWindowModules)
173
- // fix the generated indentation
174
- .replace(/^ /g, ' ');
175
186
  return `\
176
187
  // @ts-check
177
188
  require('reflect-metadata');
178
189
  const { Container } = require('inversify');
179
190
 
180
- const preloader = require('@theia/core/lib/browser/preloader');
181
-
182
191
  module.exports = Promise.resolve().then(() => {
183
192
  const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
184
193
  const container = new Container();
185
194
  container.load(frontendApplicationModule);
186
- ${compiledModuleImports}
195
+ ${Array.from(secondaryWindowModules.values(), jsModulePath => `\
196
+ container.load(require('${jsModulePath}').default);`).join(os_1.EOL)}
187
197
  });
188
198
  `;
189
199
  }
190
200
  compilePreloadJs() {
191
- const lines = Array.from(this.pck.preloadModules)
192
- .map(([moduleName, path]) => `require('${path}').preload();`);
193
- const imports = '\n' + lines.join('\n');
194
201
  return `\
195
202
  // @ts-check
196
- ${imports}
203
+ ${Array.from(this.pck.preloadModules.values(), path => `require('${path}').preload();`).join(os_1.EOL)}
197
204
  `;
198
205
  }
199
206
  }
@@ -1 +1 @@
1
- {"version":3,"file":"frontend-generator.js","sourceRoot":"","sources":["../../src/generator/frontend-generator.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,8CAA8C;AAE9C,6DAA2E;AAC3E,2BAA8C;AAE9C,MAAa,iBAAkB,SAAQ,sCAAiB;IAEpD,KAAK,CAAC,QAAQ,CAAC,OAA0B;QACrC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC;QACzG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC;QACrG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,IAAI,CAAC,0BAA0B,EAAE,CAAC,CAAC;QAChG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACzH,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI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,CAAC,EAAE,CAAC;gCACvB,IAAI,CAAC,eAAe,EAAE,KAAK,YAAY,MAAM,CAAC,CAAC,IAAI,CAAC,QAAG,CAAC;;;;;;;;;;;;;;CAcvF,CAAC;IACE,CAAC;IAES,eAAe;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAED,mEAAmE;IACzD,0BAA0B;QAChC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyCP,CAAC;IACL,CAAC;IAES,uBAAuB,CAAC,sBAA2C;QACzE,OAAO;;;;;;;;;EASb,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,CAAC;8BAChC,YAAY,cAAc,CAAC,CAAC,IAAI,CAAC,QAAG,CAAC;;CAElE,CAAC;IACE,CAAC;IAED,gBAAgB;QACZ,OAAO;;EAEb,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,YAAY,IAAI,eAAe,CAAC,CAAC,IAAI,CAAC,QAAG,CAAC;CAChG,CAAC;IACE,CAAC;CACJ;AAlMD,8CAkMC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/application-manager",
3
- "version": "1.41.0",
3
+ "version": "1.42.1",
4
4
  "description": "Theia application manager API.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -33,9 +33,9 @@
33
33
  "@babel/plugin-transform-classes": "^7.10.0",
34
34
  "@babel/plugin-transform-runtime": "^7.10.0",
35
35
  "@babel/preset-env": "^7.10.0",
36
- "@theia/application-package": "1.41.0",
37
- "@theia/ffmpeg": "1.41.0",
38
- "@theia/native-webpack-plugin": "1.41.0",
36
+ "@theia/application-package": "1.42.1",
37
+ "@theia/ffmpeg": "1.42.1",
38
+ "@theia/native-webpack-plugin": "1.42.1",
39
39
  "@types/fs-extra": "^4.0.2",
40
40
  "@types/semver": "^7.5.0",
41
41
  "babel-loader": "^8.2.2",
@@ -73,11 +73,11 @@
73
73
  }
74
74
  },
75
75
  "devDependencies": {
76
- "@theia/ext-scripts": "1.41.0",
76
+ "@theia/ext-scripts": "1.42.1",
77
77
  "@types/node-abi": "*"
78
78
  },
79
79
  "nyc": {
80
80
  "extends": "../../configs/nyc.json"
81
81
  },
82
- "gitHead": "180103ad086fc0a5e4e5fc01b5fcb43f06019eb1"
82
+ "gitHead": "07502c238094ccd80bcdf3f74f7eec973fd7a4fc"
83
83
  }
@@ -14,7 +14,6 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import * as os from 'os';
18
17
  import * as fs from 'fs-extra';
19
18
  import { ApplicationPackage } from '@theia/application-package';
20
19
 
@@ -30,33 +29,6 @@ export abstract class AbstractGenerator {
30
29
  protected options: GeneratorOptions = {}
31
30
  ) { }
32
31
 
33
- protected compileFrontendModuleImports(modules: Map<string, string>): string {
34
- const splitFrontend = this.options.splitFrontend ?? this.options.mode !== 'production';
35
- return this.compileModuleImports(modules, splitFrontend ? 'import' : 'require');
36
- }
37
-
38
- protected compileBackendModuleImports(modules: Map<string, string>): string {
39
- return this.compileModuleImports(modules, 'require');
40
- }
41
-
42
- protected compileElectronMainModuleImports(modules?: Map<string, string>): string {
43
- return modules && this.compileModuleImports(modules, 'require') || '';
44
- }
45
-
46
- protected compileModuleImports(modules: Map<string, string>, fn: 'import' | 'require'): string {
47
- if (modules.size === 0) {
48
- return '';
49
- }
50
- const lines = Array.from(modules.keys()).map(moduleName => {
51
- const invocation = `${fn}('${modules.get(moduleName)}')`;
52
- if (fn === 'require') {
53
- return `Promise.resolve(${invocation})`;
54
- }
55
- return invocation;
56
- }).map(statement => ` .then(function () { return ${statement}.then(load) })`);
57
- return os.EOL + lines.join(os.EOL);
58
- }
59
-
60
32
  protected ifBrowser(value: string, defaultValue: string = ''): string {
61
33
  return this.pck.ifBrowser(value, defaultValue);
62
34
  }
@@ -87,8 +59,7 @@ export abstract class AbstractGenerator {
87
59
  }
88
60
 
89
61
  protected prettyStringify(object: object): string {
90
- // eslint-disable-next-line no-null/no-null
91
- return JSON.stringify(object, null, 4);
62
+ return JSON.stringify(object, undefined, 4);
92
63
  }
93
64
 
94
65
  }
@@ -14,6 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
+ import { EOL } from 'os';
17
18
  import { AbstractGenerator } from './abstract-generator';
18
19
 
19
20
  export class BackendGenerator extends AbstractGenerator {
@@ -53,45 +54,47 @@ const { Container } = require('inversify');
53
54
  const { resolve } = require('path');
54
55
  const { app } = require('electron');
55
56
 
56
- // Fix the window reloading issue, see: https://github.com/electron/electron/issues/22119
57
- app.allowRendererProcessReuse = false;
58
-
59
57
  const config = ${this.prettyStringify(this.pck.props.frontend.config)};
60
58
  const isSingleInstance = ${this.pck.props.backend.config.singleInstance === true ? 'true' : 'false'};
61
59
 
62
- if (isSingleInstance && !app.requestSingleInstanceLock()) {
63
- // There is another instance running, exit now. The other instance will request focus.
64
- app.quit();
65
- return;
66
- }
67
-
68
- const container = new Container();
69
- container.load(electronMainApplicationModule);
70
- container.bind(ElectronMainApplicationGlobals).toConstantValue({
71
- THEIA_APP_PROJECT_PATH: resolve(__dirname, '..', '..'),
72
- THEIA_BACKEND_MAIN_PATH: resolve(__dirname, 'main.js'),
73
- THEIA_FRONTEND_HTML_PATH: resolve(__dirname, '..', '..', 'lib', 'frontend', 'index.html'),
74
- });
75
-
76
- function load(raw) {
77
- return Promise.resolve(raw.default).then(module =>
78
- container.load(module)
79
- );
80
- }
81
-
82
- async function start() {
83
- const application = container.get(ElectronMainApplication);
84
- await application.start(config);
85
- }
60
+ (async () => {
61
+ if (isSingleInstance && !app.requestSingleInstanceLock()) {
62
+ // There is another instance running, exit now. The other instance will request focus.
63
+ app.quit();
64
+ return;
65
+ }
66
+
67
+ const container = new Container();
68
+ container.load(electronMainApplicationModule);
69
+ container.bind(ElectronMainApplicationGlobals).toConstantValue({
70
+ THEIA_APP_PROJECT_PATH: resolve(__dirname, '..', '..'),
71
+ THEIA_BACKEND_MAIN_PATH: resolve(__dirname, 'main.js'),
72
+ THEIA_FRONTEND_HTML_PATH: resolve(__dirname, '..', '..', 'lib', 'frontend', 'index.html'),
73
+ });
74
+
75
+ function load(raw) {
76
+ return Promise.resolve(raw.default).then(module =>
77
+ container.load(module)
78
+ );
79
+ }
80
+
81
+ async function start() {
82
+ const application = container.get(ElectronMainApplication);
83
+ await application.start(config);
84
+ }
86
85
 
87
- module.exports = Promise.resolve()${this.compileElectronMainModuleImports(electronMainModules)}
88
- .then(start).catch(reason => {
86
+ try {
87
+ ${Array.from(electronMainModules?.values() ?? [], jsModulePath => `\
88
+ await load(require('${jsModulePath}'));`).join(EOL)}
89
+ await start();
90
+ } catch (reason) {
89
91
  console.error('Failed to start the electron application.');
90
92
  if (reason) {
91
93
  console.error(reason);
92
94
  }
93
95
  app.quit();
94
- });
96
+ };
97
+ })();
95
98
  `;
96
99
  }
97
100
 
@@ -127,27 +130,31 @@ function defaultServeStatic(app) {
127
130
  }
128
131
 
129
132
  function load(raw) {
130
- return Promise.resolve(raw.default).then(
131
- module => container.load(module)
133
+ return Promise.resolve(raw).then(
134
+ module => container.load(module.default)
132
135
  );
133
136
  }
134
137
 
135
- function start(port, host, argv = process.argv) {
138
+ async function start(port, host, argv = process.argv) {
136
139
  if (!container.isBound(BackendApplicationServer)) {
137
140
  container.bind(BackendApplicationServer).toConstantValue({ configure: defaultServeStatic });
138
141
  }
139
- return container.get(CliManager).initializeCli(argv).then(() => {
140
- return container.get(BackendApplication).start(port, host);
141
- });
142
+ await container.get(CliManager).initializeCli(argv);
143
+ return container.get(BackendApplication).start(port, host);
142
144
  }
143
145
 
144
- module.exports = (port, host, argv) => Promise.resolve()${this.compileBackendModuleImports(backendModules)}
145
- .then(() => start(port, host, argv)).catch(error => {
146
+ module.exports = async (port, host, argv) => {
147
+ try {
148
+ ${Array.from(backendModules.values(), jsModulePath => `\
149
+ await load(require('${jsModulePath}'));`).join(EOL)}
150
+ return await start(port, host, argv);
151
+ } catch (error) {
146
152
  console.error('Failed to start the backend application:');
147
153
  console.error(error);
148
154
  process.exitCode = 1;
149
155
  throw error;
150
- });
156
+ }
157
+ }
151
158
  `;
152
159
  }
153
160
 
@@ -16,6 +16,7 @@
16
16
 
17
17
  /* eslint-disable @typescript-eslint/indent */
18
18
 
19
+ import { EOL } from 'os';
19
20
  import { AbstractGenerator, GeneratorOptions } from './abstract-generator';
20
21
  import { existsSync, readFileSync } from 'fs';
21
22
 
@@ -23,7 +24,7 @@ export class FrontendGenerator extends AbstractGenerator {
23
24
 
24
25
  async generate(options?: GeneratorOptions): Promise<void> {
25
26
  await this.write(this.pck.frontend('index.html'), this.compileIndexHtml(this.pck.targetFrontendModules));
26
- await this.write(this.pck.frontend('index.js'), this.compileIndexJs(this.pck.targetFrontendModules));
27
+ await this.write(this.pck.frontend('index.js'), this.compileIndexJs(this.pck.targetFrontendModules, this.pck.frontendPreloadModules));
27
28
  await this.write(this.pck.frontend('secondary-window.html'), this.compileSecondaryWindowHtml());
28
29
  await this.write(this.pck.frontend('secondary-index.js'), this.compileSecondaryIndexJs(this.pck.secondaryWindowModules));
29
30
  if (this.pck.isElectron()) {
@@ -68,10 +69,7 @@ export class FrontendGenerator extends AbstractGenerator {
68
69
  <title>${this.pck.props.frontend.config.applicationName}</title>`;
69
70
  }
70
71
 
71
- protected compileIndexJs(frontendModules: Map<string, string>): string {
72
- const compiledModuleImports = this.compileFrontendModuleImports(frontendModules)
73
- // fix the generated indentation
74
- .replace(/^ /g, ' ');
72
+ protected compileIndexJs(frontendModules: Map<string, string>, frontendPreloadModules: Map<string, string>): string {
75
73
  return `\
76
74
  // @ts-check
77
75
  ${this.ifBrowser("require('es6-promise/auto');")}
@@ -89,43 +87,65 @@ self.MonacoEnvironment = {
89
87
  }
90
88
  }`)}
91
89
 
92
- const preloader = require('@theia/core/lib/browser/preloader');
90
+ function load(container, jsModule) {
91
+ return Promise.resolve(jsModule)
92
+ .then(containerModule => container.load(containerModule.default));
93
+ }
93
94
 
94
- // We need to fetch some data from the backend before the frontend starts (nls, os)
95
- module.exports = preloader.preload().then(() => {
96
- const { FrontendApplication } = require('@theia/core/lib/browser');
97
- const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
95
+ async function preload(parent) {
96
+ const container = new Container();
97
+ container.parent = parent;
98
+ try {
99
+ ${Array.from(frontendPreloadModules.values(), jsModulePath => `\
100
+ await load(container, ${this.importOrRequire()}('${jsModulePath}'));`).join(EOL)}
101
+ const { Preloader } = require('@theia/core/lib/browser/preload/preloader');
102
+ const preloader = container.get(Preloader);
103
+ await preloader.initialize();
104
+ } catch (reason) {
105
+ console.error('Failed to run preload scripts.');
106
+ if (reason) {
107
+ console.error(reason);
108
+ }
109
+ }
110
+ }
111
+
112
+ module.exports = (async () => {
98
113
  const { messagingFrontendModule } = require('@theia/core/lib/${this.pck.isBrowser()
99
- ? 'browser/messaging/messaging-frontend-module'
100
- : 'electron-browser/messaging/electron-messaging-frontend-module'}');
114
+ ? 'browser/messaging/messaging-frontend-module'
115
+ : 'electron-browser/messaging/electron-messaging-frontend-module'}');
116
+ const container = new Container();
117
+ container.load(messagingFrontendModule);
118
+ await preload(container);
119
+ const { FrontendApplication } = require('@theia/core/lib/browser');
120
+ const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
101
121
  const { loggerFrontendModule } = require('@theia/core/lib/browser/logger-frontend-module');
102
122
 
103
- const container = new Container();
104
123
  container.load(frontendApplicationModule);
105
- container.load(messagingFrontendModule);
106
124
  container.load(loggerFrontendModule);
107
125
 
108
- return Promise.resolve()${compiledModuleImports}
109
- .then(start).catch(reason => {
110
- console.error('Failed to start the frontend application.');
111
- if (reason) {
112
- console.error(reason);
113
- }
114
- });
115
-
116
- function load(jsModule) {
117
- return Promise.resolve(jsModule.default)
118
- .then(containerModule => container.load(containerModule));
126
+ try {
127
+ ${Array.from(frontendModules.values(), jsModulePath => `\
128
+ await load(container, ${this.importOrRequire()}('${jsModulePath}'));`).join(EOL)}
129
+ await start();
130
+ } catch (reason) {
131
+ console.error('Failed to start the frontend application.');
132
+ if (reason) {
133
+ console.error(reason);
134
+ }
119
135
  }
120
136
 
121
137
  function start() {
122
138
  (window['theia'] = window['theia'] || {}).container = container;
123
139
  return container.get(FrontendApplication).start();
124
140
  }
125
- });
141
+ })();
126
142
  `;
127
143
  }
128
144
 
145
+ protected importOrRequire(): string {
146
+ return this.options.mode !== 'production' ? 'import' : 'require';
147
+ }
148
+
129
149
  /** HTML for secondary windows that contain an extracted widget. */
130
150
  protected compileSecondaryWindowHtml(): string {
131
151
  return `<!DOCTYPE html>
@@ -172,40 +192,26 @@ module.exports = preloader.preload().then(() => {
172
192
  </html>`;
173
193
  }
174
194
 
175
- protected compileSecondaryModuleImports(secondaryWindowModules: Map<string, string>): string {
176
- const lines = Array.from(secondaryWindowModules.entries())
177
- .map(([moduleName, path]) => ` container.load(require('${path}').default);`);
178
- return '\n' + lines.join('\n');
179
- }
180
-
181
195
  protected compileSecondaryIndexJs(secondaryWindowModules: Map<string, string>): string {
182
- const compiledModuleImports = this.compileSecondaryModuleImports(secondaryWindowModules)
183
- // fix the generated indentation
184
- .replace(/^ /g, ' ');
185
196
  return `\
186
197
  // @ts-check
187
198
  require('reflect-metadata');
188
199
  const { Container } = require('inversify');
189
200
 
190
- const preloader = require('@theia/core/lib/browser/preloader');
191
-
192
201
  module.exports = Promise.resolve().then(() => {
193
202
  const { frontendApplicationModule } = require('@theia/core/lib/browser/frontend-application-module');
194
203
  const container = new Container();
195
204
  container.load(frontendApplicationModule);
196
- ${compiledModuleImports}
205
+ ${Array.from(secondaryWindowModules.values(), jsModulePath => `\
206
+ container.load(require('${jsModulePath}').default);`).join(EOL)}
197
207
  });
198
208
  `;
199
209
  }
200
210
 
201
211
  compilePreloadJs(): string {
202
- const lines = Array.from(this.pck.preloadModules)
203
- .map(([moduleName, path]) => `require('${path}').preload();`);
204
- const imports = '\n' + lines.join('\n');
205
-
206
212
  return `\
207
213
  // @ts-check
208
- ${imports}
214
+ ${Array.from(this.pck.preloadModules.values(), path => `require('${path}').preload();`).join(EOL)}
209
215
  `;
210
216
  }
211
217
  }