Skip to content

Commit

Permalink
electron: use inversify in main process
Browse files Browse the repository at this point in the history
All the logic for the electron main process currently has to be added to
our generators, making it hard to extend without committing to Theia.

This commit re-arranges the way Electron is launched to allow people to
more easily change the behavior of their application.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
  • Loading branch information
paul-marechal committed Jun 16, 2020
1 parent 2f64828 commit c796cc7
Show file tree
Hide file tree
Showing 51 changed files with 1,227 additions and 386 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cache:
- dev-packages/application-manager/node_modules
- dev-packages/application-package/node_modules
- dev-packages/cli/node_modules
- dev-packages/electron/node_modules
- examples/api-samples/node_modules
- examples/browser/node_modules
- examples/electron/node_modules
Expand All @@ -24,6 +23,7 @@ cache:
- packages/debug/node_modules
- packages/editor-preview/node_modules
- packages/editor/node_modules
- packages/electron/node_modules
- packages/file-search/node_modules
- packages/filesystem/node_modules
- packages/getting-started/node_modules
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Breaking Changes:

- [task] Widened the scope of some methods in TaskManager and TaskConfigurations from string to TaskConfigurationScope. This is only breaking for extenders, not callers. [#7928](https://github.com/eclipse-theia/theia/pull/7928)
- [shell] `ApplicationShell.TrackableWidgetProvider.getTrackableWidgets` is sync to register child widgets in the same tick, use `ApplicationShell.TrackableWidgetProvider.onDidChangeTrackableWidgets` if child widgets are added async
- [electron] Electron applications can now be configured/extended through inversify. Added new `electronMain` theia extension points to provide inversify container modules.

## v1.2.0

Expand Down
3 changes: 3 additions & 0 deletions configs/root-compilation.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
},
{
"path": "../packages/vsx-registry/compile.tsconfig.json"
},
{
"path": "../packages/electron/compile.tsconfig.json"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export abstract class AbstractGenerator {
return this.compileModuleImports(modules, 'require');
}

protected compileElectronMainModuleImports(modules?: Map<string, string>): string {
return modules && this.compileModuleImports(modules, 'require') || '';
}

protected compileModuleImports(modules: Map<string, string>, fn: 'import' | 'require'): string {
if (modules.size === 0) {
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ function load(raw) {
)
}
function start(port, host, argv) {
async function start(port, host, argv) {
if (argv === undefined) {
argv = process.argv;
}
const cliManager = container.get(CliManager);
return cliManager.initializeCli(argv).then(function () {
const application = container.get(BackendApplication);
application.use(express.static(path.join(__dirname, '../../lib')));
application.use(express.static(path.join(__dirname, '../../lib/index.html')));
return application.start(port, host);
});
await cliManager.initializeCli(argv);
const application = container.get(BackendApplication);
application.use(express.static(path.join(__dirname, '../../lib')));
application.use(express.static(path.join(__dirname, '../../lib/index.html')));
return application.start(port, host);
}
module.exports = (port, host, argv) => Promise.resolve()${this.compileBackendModuleImports(backendModules)}
Expand Down
Loading

0 comments on commit c796cc7

Please sign in to comment.