-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Access electron utilities using JavaScript FFI #200
Conversation
In order to set nodeIntegration=true in electron.js, the index.html file needs to load jQuery.
As commit fad91bf allowed the index.html page to load jQuery, we can now set nodeIntegration=true to allow the threepenny-gui process create menus, dialogs etc. through the JavaScript FFI.
That looks interesting! Ideally, we wouldn't need a custom I definitely want to avoid querying google for jQuery on a local app. (As said, jQuery is bundled with Threepenny, and I'm happy to make it available under different URIs.) I don't understand: Why do we need to load jQuery in order to activate node integration? (Re sidenote: A pull request adds all commits in a branch. Make a new branch and cherry pick commits that you want to be pulled.) |
Unfortunately, for some reason electron can't just use jQuery; it has to be loaded in a different way (see https://stackoverflow.com/a/37480521 and electron/electron#254 (comment) for more details).
You're right; it should be possible to figure out how to use the jQuery bundled with threepenny. |
This also allows us to remove the reference to the Google CDN.
I've figured out how to remove the reference to the Google CDN. It turned out that if I moved the reference to |
Great! I think then there is no need for a custom "index.html" anymore, we can integrate this into the default "index.html", right? |
Yes: according to this Stack Overflow question, the extra bits surrounding the call to |
This reduces setup time. The modified index.html (previously in docs/electron) allows easier Electron integration, but has no effect on normal web pages.
I have tested the custom |
The file `index.html` now loads jQuery correctly if used in the context of an Electron `BrowserWindow`. This allows us to set `nodeIntegration=true` in `electron.js` and gives access to Electron’s main process from the Browser Window.
Thanks a lot for your contribution! The pull request is a bit of a mess, though, I have squashed everything into a single commit (3d0f808) and commited it to the |
Following on from #111 and #169, I have discovered that by adding a custom
index.html
which loads jQuery, thenodeIntegration
parameter inelectron.js
can be set totrue
, allowing the electron utilities to be accessed from the JavaScript FFI. For instance:I have been working on a library which supplies Haskell function for creating menus, dialog boxes etc. Hopefully I will be able to upload it to Hackage some time in the future.
(Side note: commit
a6853b3
isn't related to the rest of the pull request, but I'm including it because I couldn't figure out how to separate it into its own PR.)