@theia/application-manager 1.39.0-next.9 → 1.40.0

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 (44) hide show
  1. package/lib/application-package-manager.d.ts.map +1 -1
  2. package/lib/application-package-manager.js +24 -7
  3. package/lib/application-package-manager.js.map +1 -1
  4. package/lib/application-process.js +1 -1
  5. package/lib/application-process.js.map +1 -1
  6. package/lib/expose-loader.js +2 -2
  7. package/lib/expose-loader.js.map +1 -1
  8. package/lib/generator/abstract-generator.d.ts +1 -0
  9. package/lib/generator/abstract-generator.d.ts.map +1 -1
  10. package/lib/generator/abstract-generator.js +14 -2
  11. package/lib/generator/abstract-generator.js.map +1 -1
  12. package/lib/generator/backend-generator.d.ts +1 -0
  13. package/lib/generator/backend-generator.d.ts.map +1 -1
  14. package/lib/generator/backend-generator.js +72 -3
  15. package/lib/generator/backend-generator.js.map +1 -1
  16. package/lib/generator/frontend-generator.d.ts +0 -1
  17. package/lib/generator/frontend-generator.d.ts.map +1 -1
  18. package/lib/generator/frontend-generator.js +1 -68
  19. package/lib/generator/frontend-generator.js.map +1 -1
  20. package/lib/generator/index.js +1 -1
  21. package/lib/generator/index.js.map +1 -1
  22. package/lib/generator/webpack-generator.d.ts +2 -0
  23. package/lib/generator/webpack-generator.d.ts.map +1 -1
  24. package/lib/generator/webpack-generator.js +161 -9
  25. package/lib/generator/webpack-generator.js.map +1 -1
  26. package/lib/index.js +1 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/package.spec.js +1 -1
  29. package/lib/package.spec.js.map +1 -1
  30. package/lib/rebuild.d.ts.map +1 -1
  31. package/lib/rebuild.js +4 -1
  32. package/lib/rebuild.js.map +1 -1
  33. package/package.json +8 -6
  34. package/src/application-package-manager.ts +16 -5
  35. package/src/application-process.ts +1 -1
  36. package/src/expose-loader.ts +1 -1
  37. package/src/generator/abstract-generator.ts +14 -2
  38. package/src/generator/backend-generator.ts +73 -3
  39. package/src/generator/frontend-generator.ts +1 -69
  40. package/src/generator/index.ts +1 -1
  41. package/src/generator/webpack-generator.ts +163 -9
  42. package/src/index.ts +1 -1
  43. package/src/package.spec.ts +1 -1
  44. package/src/rebuild.ts +4 -1
@@ -11,7 +11,7 @@
11
11
  // with the GNU Classpath Exception which is available at
12
12
  // https://www.gnu.org/software/classpath/license.html.
13
13
  //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
17
  /* eslint-disable @typescript-eslint/indent */
@@ -27,7 +27,6 @@ export class FrontendGenerator extends AbstractGenerator {
27
27
  await this.write(this.pck.frontend('secondary-window.html'), this.compileSecondaryWindowHtml());
28
28
  await this.write(this.pck.frontend('secondary-index.js'), this.compileSecondaryIndexJs(this.pck.secondaryWindowModules));
29
29
  if (this.pck.isElectron()) {
30
- await this.write(this.pck.frontend('electron-main.js'), this.compileElectronMain(this.pck.targetElectronMainModules));
31
30
  await this.write(this.pck.frontend('preload.js'), this.compilePreloadJs());
32
31
  }
33
32
  }
@@ -127,73 +126,6 @@ module.exports = preloader.preload().then(() => {
127
126
  `;
128
127
  }
129
128
 
130
- protected compileElectronMain(electronMainModules?: Map<string, string>): string {
131
- return `// @ts-check
132
-
133
- require('reflect-metadata');
134
-
135
- // Useful for Electron/NW.js apps as GUI apps on macOS doesn't inherit the \`$PATH\` define
136
- // in your dotfiles (.bashrc/.bash_profile/.zshrc/etc).
137
- // https://github.com/electron/electron/issues/550#issuecomment-162037357
138
- // https://github.com/eclipse-theia/theia/pull/3534#issuecomment-439689082
139
- require('fix-path')();
140
-
141
- // Workaround for https://github.com/electron/electron/issues/9225. Chrome has an issue where
142
- // in certain locales (e.g. PL), image metrics are wrongly computed. We explicitly set the
143
- // LC_NUMERIC to prevent this from happening (selects the numeric formatting category of the
144
- // C locale, http://en.cppreference.com/w/cpp/locale/LC_categories).
145
- if (process.env.LC_ALL) {
146
- process.env.LC_ALL = 'C';
147
- }
148
- process.env.LC_NUMERIC = 'C';
149
-
150
- const { default: electronMainApplicationModule } = require('@theia/core/lib/electron-main/electron-main-application-module');
151
- const { ElectronMainApplication, ElectronMainApplicationGlobals } = require('@theia/core/lib/electron-main/electron-main-application');
152
- const { Container } = require('inversify');
153
- const { resolve } = require('path');
154
- const { app } = require('electron');
155
-
156
- // Fix the window reloading issue, see: https://github.com/electron/electron/issues/22119
157
- app.allowRendererProcessReuse = false;
158
-
159
- const config = ${this.prettyStringify(this.pck.props.frontend.config)};
160
- const isSingleInstance = ${this.pck.props.backend.config.singleInstance === true ? 'true' : 'false'};
161
-
162
- if (isSingleInstance && !app.requestSingleInstanceLock()) {
163
- // There is another instance running, exit now. The other instance will request focus.
164
- app.quit();
165
- return;
166
- }
167
-
168
- const container = new Container();
169
- container.load(electronMainApplicationModule);
170
- container.bind(ElectronMainApplicationGlobals).toConstantValue({
171
- THEIA_APP_PROJECT_PATH: resolve(__dirname, '..', '..'),
172
- THEIA_BACKEND_MAIN_PATH: resolve(__dirname, '..', 'backend', 'main.js'),
173
- THEIA_FRONTEND_HTML_PATH: resolve(__dirname, '..', '..', 'lib', 'index.html'),
174
- });
175
-
176
- function load(raw) {
177
- return Promise.resolve(raw.default).then(module =>
178
- container.load(module)
179
- );
180
- }
181
-
182
- async function start() {
183
- const application = container.get(ElectronMainApplication);
184
- await application.start(config);
185
- }
186
-
187
- module.exports = Promise.resolve()${this.compileElectronMainModuleImports(electronMainModules)}
188
- .then(start).catch(reason => {
189
- console.error('Failed to start the electron application.');
190
- if (reason) {
191
- console.error(reason);
192
- }
193
- });
194
- `;
195
- }
196
-
197
129
  /** HTML for secondary windows that contain an extracted widget. */
198
130
  protected compileSecondaryWindowHtml(): string {
199
131
  return `<!DOCTYPE html>
@@ -11,7 +11,7 @@
11
11
  // with the GNU Classpath Exception which is available at
12
12
  // https://www.gnu.org/software/classpath/license.html.
13
13
  //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
17
  export * from './webpack-generator';
@@ -11,7 +11,7 @@
11
11
  // with the GNU Classpath Exception which is available at
12
12
  // https://www.gnu.org/software/classpath/license.html.
13
13
  //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
17
  import * as paths from 'path';
@@ -22,6 +22,7 @@ export class WebpackGenerator extends AbstractGenerator {
22
22
 
23
23
  async generate(): Promise<void> {
24
24
  await this.write(this.genConfigPath, this.compileWebpackConfig());
25
+ await this.write(this.genNodeConfigPath, this.compileNodeWebpackConfig());
25
26
  if (await this.shouldGenerateUserWebpackConfig()) {
26
27
  await this.write(this.configPath, this.compileUserWebpackConfig());
27
28
  }
@@ -43,6 +44,10 @@ export class WebpackGenerator extends AbstractGenerator {
43
44
  return this.pck.path('gen-webpack.config.js');
44
45
  }
45
46
 
47
+ get genNodeConfigPath(): string {
48
+ return this.pck.path('gen-webpack.node.config.js');
49
+ }
50
+
46
51
  protected resolve(moduleName: string, path: string): string {
47
52
  return this.pck.resolveModulePath(moduleName, path).split(paths.sep).join('/');
48
53
  }
@@ -56,11 +61,12 @@ export class WebpackGenerator extends AbstractGenerator {
56
61
  const path = require('path');
57
62
  const webpack = require('webpack');
58
63
  const yargs = require('yargs');
64
+ const resolvePackagePath = require('resolve-package-path');
59
65
  const CopyWebpackPlugin = require('copy-webpack-plugin');
60
66
  const CompressionPlugin = require('compression-webpack-plugin')
61
67
  const MiniCssExtractPlugin = require('mini-css-extract-plugin')
62
68
 
63
- const outputPath = path.resolve(__dirname, 'lib');
69
+ const outputPath = path.resolve(__dirname, 'lib', 'frontend');
64
70
  const { mode, staticCompression } = yargs.option('mode', {
65
71
  description: "Mode to use",
66
72
  choices: ["development", "production"],
@@ -74,10 +80,17 @@ const development = mode === 'development';
74
80
 
75
81
  const plugins = [
76
82
  new CopyWebpackPlugin({
77
- patterns: [{
78
- // copy secondary window html file to lib folder
79
- from: path.resolve(__dirname, 'src-gen/frontend/secondary-window.html')
80
- }]
83
+ patterns: [
84
+ {
85
+ // copy secondary window html file to lib folder
86
+ from: path.resolve(__dirname, 'src-gen/frontend/secondary-window.html')
87
+ }${this.ifPackage('@theia/plugin-ext', `,
88
+ {
89
+ // copy webview files to lib folder
90
+ from: path.join(resolvePackagePath('@theia/plugin-ext', __dirname), '..', 'src', 'main', 'browser', 'webview', 'pre'),
91
+ to: path.resolve(__dirname, 'lib', 'webview', 'pre')
92
+ }`)}
93
+ ]
81
94
  }),
82
95
  new webpack.ProvidePlugin({
83
96
  // the Buffer class doesn't exist in the browser but some dependencies rely on it
@@ -305,18 +318,159 @@ module.exports = [{
305
318
  * To reset delete this file and rerun theia build again.
306
319
  */
307
320
  // @ts-check
308
- const config = require('./${paths.basename(this.genConfigPath)}');
321
+ const configs = require('./${paths.basename(this.genConfigPath)}');
322
+ const nodeConfig = require('./${paths.basename(this.genNodeConfigPath)}');
309
323
 
310
324
  /**
311
325
  * Expose bundled modules on window.theia.moduleName namespace, e.g.
312
326
  * window['theia']['@theia/core/lib/common/uri'].
313
327
  * Such syntax can be used by external code, for instance, for testing.
314
- config.module.rules.push({
328
+ configs[0].module.rules.push({
315
329
  test: /\\.js$/,
316
330
  loader: require.resolve('@theia/application-manager/lib/expose-loader')
317
331
  }); */
318
332
 
319
- module.exports = config;`;
333
+ module.exports = [
334
+ ...configs,
335
+ nodeConfig.config
336
+ ];`;
337
+ }
338
+
339
+ protected compileNodeWebpackConfig(): string {
340
+ return `/**
341
+ * Don't touch this file. It will be regenerated by theia build.
342
+ * To customize webpack configuration change ${this.configPath}
343
+ */
344
+ // @ts-check
345
+ const path = require('path');
346
+ const yargs = require('yargs');
347
+ const webpack = require('webpack');
348
+ const TerserPlugin = require('terser-webpack-plugin');
349
+ const NativeWebpackPlugin = require('@theia/native-webpack-plugin');
350
+
351
+ const { mode } = yargs.option('mode', {
352
+ description: "Mode to use",
353
+ choices: ["development", "production"],
354
+ default: "production"
355
+ }).argv;
356
+
357
+ const production = mode === 'production';
358
+
359
+ /** @type {import('webpack').EntryObject} */
360
+ const commonJsLibraries = {};
361
+ for (const [entryPointName, entryPointPath] of Object.entries({
362
+ ${this.ifPackage('@theia/plugin-ext', "'backend-init-theia': '@theia/plugin-ext/lib/hosted/node/scanners/backend-init-theia',")}
363
+ ${this.ifPackage('@theia/filesystem', "'nsfw-watcher': '@theia/filesystem/lib/node/nsfw-watcher',")}
364
+ ${this.ifPackage('@theia/plugin-ext-vscode', "'plugin-vscode-init': '@theia/plugin-ext-vscode/lib/node/plugin-vscode-init',")}
365
+ })) {
366
+ commonJsLibraries[entryPointName] = {
367
+ import: require.resolve(entryPointPath),
368
+ library: {
369
+ type: 'commonjs2',
370
+ },
371
+ };
372
+ }
373
+
374
+ const ignoredResources = new Set();
375
+
376
+ if (process.platform !== 'win32') {
377
+ ignoredResources.add('@vscode/windows-ca-certs');
378
+ ignoredResources.add('@vscode/windows-ca-certs/build/Release/crypt32.node');
379
+ }
380
+
381
+ const nativePlugin = new NativeWebpackPlugin({
382
+ out: 'native',
383
+ ripgrep: ${this.ifPackage(['@theia/search-in-workspace', '@theia/file-search'], 'true', 'false')},
384
+ pty: ${this.ifPackage('@theia/process', 'true', 'false')},
385
+ nativeBindings: {
386
+ drivelist: 'drivelist/build/Release/drivelist.node'
387
+ }
388
+ });
389
+
390
+ /** @type {import('webpack').Configuration} */
391
+ const config = {
392
+ mode,
393
+ devtool: mode === 'development' ? 'source-map' : false,
394
+ target: 'node',
395
+ node: {
396
+ global: false,
397
+ __filename: false,
398
+ __dirname: false
399
+ },
400
+ output: {
401
+ filename: '[name].js',
402
+ path: path.resolve(__dirname, 'lib', 'backend'),
403
+ devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]?[loaders]',
404
+ },${this.ifElectron(`
405
+ externals: {
406
+ electron: 'require("electron")'
407
+ },`)}
408
+ entry: {
409
+ // Main entry point of the Theia application backend:
410
+ 'main': require.resolve('./src-gen/backend/main'),
411
+ // Theia's IPC mechanism:
412
+ 'ipc-bootstrap': require.resolve('@theia/core/lib/node/messaging/ipc-bootstrap'),
413
+ ${this.ifPackage('@theia/plugin-ext', () => `// VS Code extension support:
414
+ 'plugin-host': require.resolve('@theia/plugin-ext/lib/hosted/node/plugin-host'),`)}
415
+ ${this.ifPackage('@theia/process', () => `// Make sure the node-pty thread worker can be executed:
416
+ 'worker/conoutSocketWorker': require.resolve('node-pty/lib/worker/conoutSocketWorker'),`)}
417
+ ${this.ifPackage('@theia/git', () => `// Ensure the git locator process can the started
418
+ 'git-locator-host': require.resolve('@theia/git/lib/node/git-locator/git-locator-host'),`)}
419
+ ${this.ifElectron("'electron-main': require.resolve('./src-gen/backend/electron-main'),")}
420
+ ...commonJsLibraries
421
+ },
422
+ module: {
423
+ rules: [
424
+ // Make sure we can still find and load our native addons.
425
+ {
426
+ test: /\\.node$/,
427
+ loader: 'node-loader',
428
+ options: {
429
+ name: 'native/[name].[ext]'
430
+ }
431
+ },
432
+ {
433
+ test: /\\.js$/,
434
+ enforce: 'pre',
435
+ loader: 'source-map-loader'
436
+ },
437
+ // jsonc-parser exposes its UMD implementation by default, which
438
+ // confuses Webpack leading to missing js in the bundles.
439
+ {
440
+ test: /node_modules[\\/](jsonc-parser)/,
441
+ loader: 'umd-compat-loader'
442
+ }
443
+ ]
444
+ },
445
+ plugins: [
446
+ // Some native dependencies (bindings, @vscode/ripgrep) need special code replacements
447
+ nativePlugin,
448
+ // Optional node dependencies can be safely ignored
449
+ new webpack.IgnorePlugin({
450
+ checkResource: resource => ignoredResources.has(resource)
451
+ })
452
+ ],
453
+ optimization: {
454
+ // Split and reuse code across the various entry points
455
+ splitChunks: {
456
+ chunks: 'all'
457
+ },
458
+ // Only minimize if we run webpack in production mode
459
+ minimize: production,
460
+ minimizer: [
461
+ new TerserPlugin({
462
+ exclude: /^(lib|builtins)\\//
463
+ })
464
+ ]
465
+ },
466
+ };
467
+
468
+ module.exports = {
469
+ config,
470
+ nativePlugin,
471
+ ignoredResources
472
+ };
473
+ `;
320
474
  }
321
475
 
322
476
  }
package/src/index.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  // with the GNU Classpath Exception which is available at
12
12
  // https://www.gnu.org/software/classpath/license.html.
13
13
  //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
17
  export * from './rebuild';
@@ -11,7 +11,7 @@
11
11
  // with the GNU Classpath Exception which is available at
12
12
  // https://www.gnu.org/software/classpath/license.html.
13
13
  //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
17
  /* note: this bogus test file is required so that
package/src/rebuild.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  // with the GNU Classpath Exception which is available at
12
12
  // https://www.gnu.org/software/classpath/license.html.
13
13
  //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
17
  import cp = require('child_process');
@@ -36,6 +36,9 @@ export const DEFAULT_MODULES = [
36
36
  'native-keymap',
37
37
  'find-git-repositories',
38
38
  'drivelist',
39
+ 'keytar',
40
+ 'ssh2',
41
+ 'cpu-features'
39
42
  ];
40
43
 
41
44
  export interface RebuildOptions {