Hello, newbie w\o an appropriate education (i.e. software development or computer science) here, writing some tools just for fun for myself. I found a way here because of the following promise:
`shadow-cljs` provides 100% full interop between JavaScript and ClojureScript.
My current task is to find out how to connect my CJLS REPL on PC to a embedded WebView browser runtime on a USB-connected Android device, inside the running application. Before writing here I searched and stumbled upon some examples mentioning things such as expo or ReactNative, but I just want a plain raw (CL)JS for now.
I know that Google Chrome browser can provide access to JS console for a real-time running Android application w\ embedded WebView (which is really the same Chromium under the hood as GoogleChrome, but cropped) via:
So I know it's possible in principle, but I don't know how to connect to it as I usually do with shadow-cljs watch :build-name for a usual browser on a PC. Ideally, the solution should even bypass a GoogleChrome completely.
Can somebody tell me which keywords to use in search engines and LLMs, to read about the techniques of how such task can be solved? Some directions of where to look and what to learn, thanks in advance.shadow-cljs builds in dev mode include code that tries to open the port to the shadow-cljs server so they can be linked to the REPL and receive hot code reloads. that means: • if the code running in the Webview is a dev mode build from shadow-cljs • and it's configured with the right hostname and port for your shadow server running on your host machine • and network firewalls etc. permit that connection then it should work
if your host and Android device are sharing the same wi-fi etc. then I think the only broken link will be that it defaults to which is wrong because the Android device isn't where the shadow server is.
so check out https://shadow-cljs.github.io/docs/UsersGuide.html#http and set the :host "192.168.1.30" or whatever so it can find your host machine
oh I also realized from the docs that I should have said watch build, not just dev mode. but naturally, if there's going to be a REPL to connect to, you'll be running shadow-cljs watch.
correct. basically all that is needed is the ability of the runtime (your webview) to connect back to the shadow-cljs instance on your pc using websockets. webviews typically support websockets just fine, but sometimes they use some strange local addressing so that some of the "defaults" may not work
one of those defaults is that it tries to use the location of the document to figure out what host to connect to. so in javascript terms that is document.location.host. for regular websites that works, but webviews sometimes don't. so if it doesnt you could try setting :devtools {:use-document-host false} in the build config to override that default and just try localhost