Open nomeata opened 5 years ago
Also I am confused about the relation between the android-activity
package and jsaddle-clib
. Do they complement each other, or do they have overlapping functionality?
The only actual use of import Language.Javascript.JSaddle.CLib
that I found using GitHub is https://github.com/obsidiansystems/cross-android/blob/develop/hs/src/Main.hs but that seems to be outdated?
Hmm, it seems that if one wants to use reflex, then reflex-dom has its own support for creating an Android Activity, that somehow revolves around https://github.com/reflex-frp/reflex-dom/blob/develop/reflex-dom/src-android/Reflex/Dom/Android/MainWidget.hsc and https://github.com/reflex-frp/reflex-dom/blob/1eb43e17c98c1fc67eb21000e2057e3b8488e446/reflex-dom/cbits/MainWidget.c and https://github.com/reflex-frp/reflex-dom/blob/1eb43e17c98c1fc67eb21000e2057e3b8488e446/reflex-dom/java/org/reflexfrp/reflexdom/MainWidget.java and hence does not use the more general purpose android-activity
package.
Or does it complement it? https://github.com/gonimo/gonimo/blob/master/front-android/app/Android.hs seems to be using both.
But I can’t find any indication on how to run my non-reflex jsaddle app properly on android (let alone my sdl application … but that’s off topic for here.)
@eskimor, are you watching this space? You seem to be the expert here :-)
More sleuthing; it seems that https://github.com/reflex-frp/reflex-dom/blob/master/reflex-dom/src-android/Reflex/Dom/Android/MainWidget.hsc isn’t actually tied to reflex. Maybe this could and should be its own package, but isn’t because nobody asked for it? There is a comment
--TODO: Find a way to eventually release this
Ugh:
src/KaleidogenAndroid.hs:12:1: error:
Could not find module ‘Reflex.Dom.Android.MainWidget’
it is a hidden module in the package ‘reflex-dom-0.5’
Use -v to see a list of the files searched for.
|
12 | import Reflex.Dom.Android.MainWidget
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
so how did gonimo
do it? Maybe an older version did export that module?
Despite not using reflex, this seems to line up in terms of types, and is the most promising variant so far:
module KaleidogenAndroid where
import MainWidget
import Reflex.Dom.Internal
main :: IO ()
main = run MainWidget.mainWidget
(where mainWidget :: JSM ()
).
If that works out I guess I’ll have to bug the reflex people to provide that functionality in a separate library… :-)
Well, (after renaming that to Main
) it built and created an android app (using nix and buildApp
from reflex-platform
), and I can start and run it. That’s progress :-)
(I’d still be interested in the original question: how to use jaddle-clib
directly)
Sorry - I am late on this, but glad you got it to work! I can't really say anything about direct usage of jsaddle-clib unfortunately. Except maybe that I think it is unlikely that it will suffice for running your Application on Android, as this also requires some integration with the Java SDK. You would need to wire it up manually with the Android WebView too.
Regarding on how Gonimo did it: I was quite liberal with patching dependencies with features I needed. In particular: https://github.com/eskimor/reflex-dom/blob/5dd733e25fd16ff628560a9bc6583b170f13dacb/reflex-dom/reflex-dom.cabal#L92-L94
Most stuff I needed however, that I did not consider too application specific got merged to master at some point.
The documentation lists
jsaddle-clib
as one of the runners to choose from. All the other runners seem to export a more or less compatiblerun
function, but notjsaddle-clib
. Some documentation on how to usejsaddle-clib
would be helpful.