hexops / vecty

Vecty lets you build responsive and dynamic web frontends in Go using WebAssembly, competing with modern web frameworks like React & VueJS.
BSD 3-Clause "New" or "Revised" License
2.81k stars 144 forks source link

wrapping for embedding in mobile and desktop apps #126

Open joeblew99 opened 7 years ago

joeblew99 commented 7 years ago

i know this is very high level but figured it was worth bring up here.

I have been looking into how we can make Desktop and Mobile apps and sign them too. There are a few libs around to help, but no one has really brought it together yet.

I there any interest in this or idea how best to do it ?

My current thinking is... Golang backend (on mobile):

Native webview (a bit of ios and android code):

Golang frontend:

It could be that protobufs are a perfect solution here because its binary and because there are very good code generators around it. Its probably too early to tell though.

Has anyone else looked into this ?

slimsag commented 7 years ago

I can imagine a world in which Vecty might provide easy integration with a separate project that handles all of the difficult bits (i.e. a project that handles setting up a webview using Android/iOS/Electron APIs). This would primarily be some sort of 'vecty' CLI tool which would manage compiling go to js, packaging assets, etc.

As far as getting an actual cross-platform webview on android/ios/desktop.. that's obviously outside the scope of vecty itself. And I cannot imagine why such a project would be inherently tied to vecty, after all it should work with any HTML/JS/CSS code.

joeblew99 commented 7 years ago

@slimsag your right - it should not be tied to vecty at all.

The Vecty CLi is a good way of putting it. Most of the code can be generated. This is because you want a DB down there and need data flowing between the UI and DB layer. That code is almost all boilerplate that can be generated.

The other thing is just holding the webview. At the moment i am getting good success with Ebiten. This is a 2D game engine but has good infrastructure for bring up and signing n all Desktops and Mobiles right now. Adding a Webview and the boiler plate signalling is a definite smart move.

Alul3D also might be good. you work on that. Does it have a good infra setup fro mobile and desktop ?

slimsag commented 6 years ago

@joeblew99 I have a feeling any game engine and web app in general will have very different setup requirements. I'm also not aware of any game engine in Go today that has a good mobile story (including gomobile, although that isn't really a game engine).

Today I was trying to achieve something like this issue with a Vecty app of my own, and what I considered is that having something which could:

  1. Take a Vecty / GopherJS application as input and (2)
  2. Produce a truly-cross-platform (Windows, Mac & Linux via Electron, Android & iOS via their native WebView's)

Would be quite nice. The tricky part is how to actually do that. The Mac and iOS parts introduce the most complexity, mainly because you must have a mac to develop for those generally. It'd be great if that wasn't the case.

I think what we could do is one of two things:

  1. Ask for users to download the mac installer from the app store, and then start and control a mac virtual machine on their own hardware via qemu with KVM extension, inside of a docker container so there would be basically no work involved. https://github.com/Cleafy/sxkdvm is one such project which does this (we would just need to write the actual application packaging on top of this).
  2. Easier, if we can get away with it in all aspects, offer a Docker image which could package for each OS respectively. This would mean:
    1. Windows/Mac/Linux would be packaged via https://www.npmjs.com/package/electron-packager inside the Docker image.
    2. Because Docker only runs Linux, we would have to try getting https://github.com/saucelabs/isign to work with signing the Mac & iOS applications.
    3. For Android and iOS, we would build an application which would essentially just be a webview + packaged up index.html and bundle.js file (+ maybe other assets?), and would expose whatever APIs we wanted (e.g. to create notifications). We would then save this as an apk or app file, and the Docker image itself would only open this file, replace the relevant information (settings files regarding app name & author info etc, and data files like index.html and bundle.js) and then sign the file once again using the relevant certificate.

In theory what this would be like is essentially having a user install Docker first and then run:

vecty package ./my/go/package

And it producing an app file for every important desktop + mobile OS.

Nothing concrete here, maybe there are obvious issues I am missing, but if we could get that to work I think it'd be a great thing to include in a Vecty CLI tool in the long run.