Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for master electron packages #3431

Closed
wants to merge 430 commits into from

Conversation

bogthe
Copy link
Contributor

@bogthe bogthe commented Nov 7, 2018

Signed-off-by: Bogdan Stolojan petre.stolojan@arm.com

This PR fixes: #3364
By adding a new extension method called backendMasterElectron to modules which will be required into node inside of the master electron process and enabling packages like electron-updater to work with Theia.

@thegecko
Copy link
Member

Any feedback on this PR?

@thegecko thegecko requested a review from kittaakos January 16, 2019 10:42
@bogthe
Copy link
Contributor Author

bogthe commented Jan 18, 2019

Hi @kittaakos this seems to have been floating for a while now. Any feedback on having this merged?

@@ -24,6 +24,7 @@ export interface Extension {
frontendElectron?: string;
backend?: string;
backendElectron?: string;
backendMasterElectron?: string;
Copy link
Member

@akosyakov akosyakov Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are expectations about js fie, the same as for other entry points? Does it return ContainerModule and use inversify to allow fine grained customizations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it stands it doesn't use ContainerModule or inversify.
Reason being I would like to see how the use cases for this entry point evolve and didn't want to impose any restrictions. For now each backendMasterElectron package can use it's own inversify containers but a simple js entry point would do for electron-updates (or any modules required to run from a different thread) to work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's decided to Theia to use inversify in all entry points to allow customizations. I don't think this entry point should deviate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use this entry point as a short term solution and replace it with an inversify method later?

@kittaakos
Copy link
Contributor

@bogthe, thank you for the patch! Could you please provide an example I can try?

@bogthe
Copy link
Contributor Author

bogthe commented Jan 21, 2019

Hi @kittaakos , no worries! Glad I could help.

Check this branch out, I created a small example here.

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the review, it worked as expected. 👍 Could you please tell me why did you pick the name electron master modules, maybe it is correct, I just do not see what does it do with master.

@@ -72,6 +79,12 @@ module.exports = (port, host, argv) => Promise.resolve()${this.compileBackendMod
});`;
}

protected compileElectronMaster(backendMasterModules: Map<string, string>) {
return `// @ts-check
${[...backendMasterModules.values()].map(module => `require('${module}')`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${[...backendMasterModules.values()].map(module => `require('${module}')`)
                .join('\n')}`;

should be

${[...backendMasterModules.values()].map(module => `require('${module}');`).join('\n')}`;

(You have missed the semi-colons after the require.)

}${
this.pck.targetElectronMasterModules.size > 0 ?
`
require('../backend/electronMaster.js')` : ''}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semi-colon after require('../backend/electronMaster.js'').


if (this.pck.targetElectronMasterModules.size > 0) {
await this.write(
this.pck.backend('electronMaster.js'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the preferred file naming convention.

Also, why is it called electron master modules? I do not have a better idea, but electronMaster does not sound good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry 'bout that!

I have to say it doesn't sound that good to me either but I didn't know what else to name it. They are packages which will be ran from the master process of electron not the workers, and main process would've been confusing... so went with master! ¯_(ツ)_/¯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not the master process of electron, but the main process of electron. And later, the electron main process forks the backend process, and the forked backend process will create the workers...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go with electron main (process) contributions... something like that. We can agree that the feature you want works 👍 but I would like to find a proper name for it before we merge it.

@bogthe
Copy link
Contributor Author

bogthe commented Jan 21, 2019

@kittaakos thanks for checking it! Added the changes you requested

@@ -220,6 +228,10 @@ export class ApplicationPackage {
return this.ifBrowser(this.backendModules, this.backendElectronModules);
}

get targetElectronMasterModules(): Map<string, string> {
return this.ifElectron(this.backendElectronMasterModules, new Map<string, string>());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method isn't necessary here, right? I can understand the targetFrontendModules and the targetBackendModules but not this one. I think it is sufficient to have the other method (backendElectronMasterModules), and if not electron, then return with an empty map. You do not have electron master modules in the browser, so no need to mimic a symmetric API. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'll get rid of the method.

@paul-marechal
Copy link
Member

paul-marechal commented Jan 21, 2019

Looking at this PR, it reminded me that I had been thinking about using inversify for the electron application in the same way that we do for the backend and frontend apps.

Do you think it would be worth to do sometime? Right now I really think it would be nice to have it modular like BE/FE, would allow clients have more control on the Electron feel without contributing to the generators every time.

@bogthe
Copy link
Contributor Author

bogthe commented Jan 21, 2019

@marechal-p are you referring to the way BE and FE exchange messages through JsonRpcConnectionHandler and WebSocketConnectionProvider?
As it is you can still pass messages from any FE to a backendMasterElectron package through the basic ipcRenderer / ipcMain, which I admit is not ideal 😄 because it's different from the standard way. So yeah, would like to see this evolve into something like that, but for now it looks like a nice playground for things like update mechanisms, etc.

akosyakov and others added 16 commits January 21, 2019 16:37
…view widget

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
So let's say you access the workspace /tmp/moo on server potato.com, the
URL will look like

  http(s?)://potato.com/#/tmp/moo

Changing workspace using the interface will update the path in the
fragment.  The goal is that it always the url fragment always reflect
whatever workspace you are using.  If you find a situation where it
doesn't, it's a bug.

The motivations of this change:

- We can create browser bookmarks for different workspaces on the same
  server, or access a particular workspace using the browser history.

- This makes the "reload" feature more robust.  Right now, when you
  reload, it works because Theia saves (just before exiting) the
  workspace in the front of ~/recentworkspace.json, and we happen to
  automatically open the most recent workspace at startup.  After this
  patch, it will work because we will pick up the workspace path from
  the fragment after reloading).

- I want to introduce an option for not opening the most recent
  workspace at startup (just show the welcome page which shows the list
  of recent workspaces and let me choose which one I want to open).
  Enabling this option would break reloading, since reloading relies on
  opening the most recent workspace.

- "Power user" feature: you can easily copy paste a directory path in
  the URL to open it as a workspace.

Change-Id: I73f54451fcf9312110a1f87f3c236c1e4eef7ebd
Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
…path in electron

Closes: eclipse-theia#3297
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
macOS GUI applications does not inherit the `PATH` by default.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Nigel Westbury <nigelipse@miegel.org>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
…t scopes.

`sinon.restore` ran for other tests. E.g.: `file-uri.spec` test module.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
When building a menu, we now check if the item is visible.
If not, then we do not add it to the menu.
This allow us to filter items with invisible children, but
that have children nonetheless.

Fix eclipse-theia#2669.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Casey Flynn <caseyflynn@google.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Fixes breaking import 'WidgetTracker' found in `master`

Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: elaihau <liang.huang@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Added missing mocked `CorePreferences` to the `navigator-model.spec.ts` file
which is required for the tests to successfully pass.

Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
akosyakov and others added 22 commits January 21, 2019 16:37
…ave code

The simple example is `bat` extension: https://github.com/Microsoft/vscode/blob/f9dac5925447293678b81e817fa077a5bc1b9d3c/extensions/bat/package.json#L1

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
`fireWillSaveModel` is triggering every listener at the same time, each
providing edits from the same original document, which can lead to
concurrency issues.

Changed the implementation to match what VS Code is doing when
triggering the same listeners: sequentially, and blaming listeners that
directly make modifications to the model.

Add `Emitter.sequence` to process each listener one after the other.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Vitalii Parfonov <vparfonov@redhat.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Change e4bcba5 is reverted, as it pops too many notifications especially when the auto_save is on.

Signed-off-by: elaihau <liang.huang@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
I've also added relevant mime types.

Signed-off-by: Jan Keromnes <jan.keromnes@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Josh Bradley <jgbradley1@gmail.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
…nges

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
+ load snippets async

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
An error about some `execute("return window.__coverage__")` kept
appearing in the test logs. Fixed.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
When we want to create a folder, we usually do not care if the folder
already exists or not, if we did, we could always query it using
`filesystem.exists`. Currently, `filesystem.createFolder` will fail if
it already exists.

This commit makes it so `createFolder` will not fail if the file that
exists is also a folder.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Some path returned by the filesystem was forced as non-undefined in the
code, while at runtime the value actually ended up undefined.

Hopefully improved filesystem access.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
So it is matching VSCode command as well
https://code.visualstudio.com/docs/getstarted/keybindings#_navigation

Change-Id: I2044bcfbf67c71f981cce50f7aeb363c12cfb166
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Change-Id: Id29e37f5ab62a00f8982ef049b718f49124f8cd3
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Change-Id: I15b3db94dae4d1607926d1e01d5d3e417ea037d6
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
@bogthe bogthe force-pushed the electron-master-extension branch from e194adc to 96e4408 Compare January 21, 2019 16:38
@bogthe
Copy link
Contributor Author

bogthe commented Jan 21, 2019

woops

@bogthe bogthe closed this Jan 21, 2019
@paul-marechal
Copy link
Member

@bogthe I wasn't talking about the communication FE/BE, but rather the way they are constructed using inversify's container modules, which allows for contribution providers and symbol rebinding.

Currently the only way to extend the way the electron app part feels is by changing the generators, in the main repo. Another solution would be to forget about our generators and create your own. That could be different, that's my point.

@bogthe bogthe deleted the electron-master-extension branch January 22, 2019 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Hook into electron main master process