DaxChen / meteor-electron-client

A boilerplate to use meteor to build desktop apps!
MIT License
60 stars 12 forks source link

Meteor build system integration #1

Open ccorcos opened 9 years ago

ccorcos commented 9 years ago

What build cycle hooks would you need to integrate this directly into the Meteor build system?

DaxChen commented 9 years ago

I'm sorry, can you explain more? Don't get you question...

DaxChen commented 9 years ago

Oh, I kind of got it now, lol. I was shocked my the build cycle hook term, haha. Under the hood, I'm using meteor-build-client to generate the index.html, minified.css and minified.js, and use gulp to copy them into a folder to build with electron.

DaxChen commented 9 years ago

During development, you can simply point electron to localhost:3000 to see the result with live reload, and if run gulp build, meteor-build-client will generate the minified html, css and js, so you'll want to point electron to the generated index.html.

So what's your goal of integrating this into meteor build system? If the goal is to be able to create a both online and offline version of desktop app, then I think there will be 2 things needed to be done.

  1. The app has to cache data subscribed from the server (both data in minimongo and images from the internet), so when the user is offline, they can still use this app with data they already have. When the user gets online, the server can diff and sync those data. Minimongo already the diff and sync part done, so we only need a storage adapter for minimongo to make this work.
  2. The second part is to update the html, css and javascript if the server has a newer version. And I think this is the problem that Cordova has, because if the user don't have internet access, they'll think the app just won't startup. Luckily with meteor-build-client, we can first get the static version, and use it to power the offline version of the app. So I think it will be awesome to have maybe a version number (or just a timestamp) of those static files, and when the app gets online, it checks if the version number is different, and prompts the user to update the app (or perhaps automatically update), then the app downloads the latest version, and updates itself.

So are you trying to build something maybe like if you meteor add-platform darwin-x64 or meteor add-platform win-x64, and meteor will generate an electron app for you? I think that won't be very hard, since electron only needs html, css and javascript to get up and running. But the problem will be to able to specify which file will be included into electron, because maybe you don't want every thing in the public/ folder to be in. So we'll need some kind of method to set some links to relative and some to absolute.

So what do you think? Thanks for asking!

Yu-Huai

ccorcos commented 9 years ago

Yeah, so I talked to Sashko at the last meteor meetup about electron and he said if we can give him very specific functions we'd need to integrate directly into the meteor build system, then he'd spend a day to build them for us. I agree there are two versions. One version will run mongo and and the server sandboxes within the app, and the other version will expect the server to be hosted elsewhere. I think we ought to support both of these. I'm not sure how we'd want to handle all the electron config stuff. It seems to me like we'd want to create a boilerplate electron.js file in the root directory of the project and let people modify it so they can set the window size, menus, etc. Then the meteor project itself should get loaded into the electron window itself.

The meteor build tool seems to accomplish a lot of this stuff already it seems. I'm not sure how cordova apps get real time updates, but thats seems pretty neccessary for the online version.

You're right on with what I was thinking though. Suppose there was a hook like function distributeDevFiles(js,css,html) so you could add those to electron and trigger a refresh or something. Do you think you can come up with a very specific list of functions you'd need to get a sweet integration like you mentioned above? online and offline, meteor add-platform, etc.