This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
I’m using chromex with shadow-cljs. When I connect to the REPL using (shadow/nrepl-select :extension)
, I appear to be connected to the browser environment within the extension. Anyone familiar with chromex to know how to get the REPL connected to the browser environment for the content-script (i.e., the actual loaded browser page)?
It sounds like it is possible to do from https://github.com/thheller/shadow-cljs/issues/279#issuecomment-549115864.
Given this output,
(shadow/repl-runtimes :extension)
=>
[{:since #inst"2020-08-15T17:10:59.182-00:00",
:proc-id "7453f221-866f-4e45-ae1a-49c489d30616",
:connection-info {:remote true, :websocket true},
:client-id 47,
:user-agent "Chrome 537.36 [MacIntel]",
:type :runtime,
:lang :cljs,
:build-id :extension,
:host :browser,
:dom true}
{:since #inst"2020-08-15T17:11:01.035-00:00",
:proc-id "7453f221-866f-4e45-ae1a-49c489d30616",
:connection-info {:remote true, :websocket true},
:client-id 48,
:user-agent "Chrome 537.36 [MacIntel]",
:type :runtime,
:lang :cljs,
:build-id :extension,
:host :browser,
:dom true}]
is the runtime-id the same as the client-id?I see this fn shadow/repl-runtime-select
. Calling it with the client-id of 48 (seen above) and then running (shadow/nrepl-select :extension)
does not result in the REPL calls getting eval’ed in the client-script environment.
This seems like it’d work. Must be missing something.
(shadow/repl-runtime-select :extension 88)
=> true
(:default-runtime-id @(:state-ref (shadow/get-worker :extension)))
=> 87
@kenny this isn't currently supported. I broke it in the 2.10 REPL updates. https://github.com/thheller/shadow-cljs/issues/776
honestly not sure how reliable it previously was. not aware of anyone ever actually using it.
doesn't have anything to do with chromex. the problem also exists when I work on the shadow-cljs UI which uses a webworker and so always has two runtimes and its kinda annoying to switch.
Chromex also necessitates 2 runtimes. Without support for runtime switching, you can only interact with 1 runtime. It seems incredibly painful to work without a repl!
Thus the conclusion previously drawn. If you’re also in the same situation, how do you switch between the different runtimes?
I don't currently. I only use the REPL via Inspect when looking at some data stuff. Otherwise just relying on hot-reload.
I barely ever use the REPL in CLJS for some reason. I use it for everything in CLJ but somehow hot-reload works better for me in CLJS
I do that often when working on our prod app at work. I’m currently messing with an old cljs code base and just wanted to explore what stuff did, immediately reaching for the repl.
Anyway, 2.9.10 with (shadow/nrepl-select :extension {:runtime-id "<id>"})
does work. One thing that is frustrating with explicitly specifying the runtime id is if you refresh your browser, the id changes.
@thheller I’m looking at @pavel.klavik’s problem with UTF in Cursive. Am I correct in thinking that that exception is when the Shadow server is reading a transit response, presumably the response from the CLJS client?
I’m not super familiar with how Shadow works, so I’m not sure where transit would be being used. My mental model of how this eval would be passed is:
Cursive nREPL client -> Shadow nREPL server -> CLJS client
But I thought that second step was usually passed as a string rather than transit/JSON.@pavel.klavik Do you have your IntelliJ configured to use UTF-8 under Settings->Editor->General->Console?
I have this there:
Changing to UTF-8 does not seem to help.
It looks like your system encoding is not set to UTF-8, which might cause this problem. I’m trying to figure out how to set that, one sec…
Ok, if you go to Help | Edit Custom VM Options and add -Dfile.encoding=UTF-8
there, then restart IntelliJ, does that help?
In the same config pane you posted above, you should then see: System Default: UTF-8
It shows now UTF-8 as System Default, but the error stays the same
Sure, thx a lot 🙂.
Also, when you eval this do you see anything in your Network pane of developer tools?
You mean in Chrome? Not sure how to display anything there from Shadow-cljs