-
-
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
Use http://electron.atom.io to make standalone applications #111
Comments
I have already taken a look at Electron and very much liked what I saw. I think this is the most promising avenue for standalone applications with JavaScript. |
That's great, let me know if you would like any help. |
@jeffreyrosenbluth Since you're offering help: Writing JS driver code the Electron shell should be no problem for me, but I wonder how or if it's possible to integrate this with cabal. It would be great if we could build some kind of |
Let me see what would be involved and whether is seems do-able. |
This doesn't seem like it would be too difficult so let me see if I understand correctly what would be required. First, if we were going to do it "by hand" we would build the user's application, say app.hs, which imports the threepenny modules to a binary using cabal build. Then we would package this binary together with the JS driver code, a package.json file, and an index.html file if desired we could then use an asar archive to make this into a single app file. The package.json and index.html files would be the same for every app? If this is correct I think that cabal integration would be fairly straight forward. Much of cabal-macosx deals with handling dependencies. I don't think we would have any dependencies that are not handled by regular cabal or are included in our static js code. Let me know if you agree with this assessment and we can decide the best way to proceed. |
Yes, pretty much. Essentially, we need a post-build hook that copies the executable and the index.html and package.json files into a common directory, so that Electron can find a complete directory structure. My problem is that I don't know much about Cabal. If you could figure out how to make such a post-build hook, then that would help me a lot. |
I don't know that much about Cabal either but I think I'll be able to figure it out. |
I have successfully hooked up Threepenny-GUI to Electron. I still don't know how to offer this functionality via .cabal files, though. Electron is an external dependency, the precompiled binary weighs 30-40MB (for version 0.33) for each platform. Application bundles have to be built by copying the relevant files. |
I have to apologize, I thought I would have time to work on this, but I'm tied up on a large project for the foreseeable future. Sorry about that, I may still be able to do it, just not for a while. |
No worries, this is a completely voluntary activity, after all. 😄 |
Do you consider releasing a HOWTO for that? |
I think I've figured out how to hook up Threepenny-GUI to Electron. What you do is:
I've managed to get the sample programs distributed with threepenny-gui working using this method. |
Here's a method of doing this without custom HTML or moving an executable, it starts the app on a free port and waits until the Threepenny app is running before starting an Electron renderer process (display window).
module Main where
import System.Environment (getArgs)
import YourApp (start)
main :: IO ()
main = do
[port] <- getArgs
start (read port)
child = spawn('stack', ['exec', 'your-app-exe', `${port}`]); Now to run the whole thing: npm install
stack build
./node_modules/.bin/electron electron.js Edit: Note the only Stack specific instructions for this are: |
The reason I used the method of 'moving the executable' instead of I'm going to create a repo with all the config files in it as an example of how to integrate threepenny-gui and electron. I'm having a bit of trouble with pushing the files though so I'll do it after I fix that. |
No description provided.
The text was updated successfully, but these errors were encountered: