shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
mkvlr 2020-11-25T07:47:38.238600Z

good morning, we are using :repl {:runtime-select :latest} in our project and like it. Now I’ve added an iframe that also runs a cljs target that’s built with shadow. Is there a way to opt out of shadow considering this iframe for the repl? I’d like shadow to use the latest main window for the repl…

mkvlr 2020-11-25T07:53:20.238900Z

both of these use the same build but a different module.

mkvlr 2020-11-25T08:02:16.240200Z

trying to switch this manually with shadow.cljs.devtools.api I noticed that my repl-runtimes are missing the :runtime-id key that’s needed for me to switch this or am I misunderstanding the api?

(repl-runtimes :website)
;; => [{:since #inst "2020-11-25T07:44:05.319-00:00", :proc-id "68613cad-86ad-44ea-a950-32dac30914ec", :connection-info {:remote true, :websocket true}, :client-id 45, :user-agent "Chrome 537.36 [MacIntel]", :type :runtime, :lang :cljs, :build-id :website, :host :browser, :dom true} {:since #inst "2020-11-25T07:44:07.842-00:00", :proc-id "68613cad-86ad-44ea-a950-32dac30914ec", :connection-info {:remote true, :websocket true}, :client-id 46, :user-agent "Chrome 537.36 [MacIntel]", :type :runtime, :lang :cljs, :build-id :website, :host :browser, :dom true}]

thheller 2020-11-25T08:25:44.241Z

@mkvlr switching that way is currently not supported. https://github.com/thheller/shadow-cljs/issues/776

thheller 2020-11-25T08:26:35.241900Z

I'll see about fixing that. not many people use it so I forgot 🙂

mkvlr 2020-11-25T08:26:48.242100Z

cool, thanks a lot!

mkvlr 2020-11-25T08:31:46.243200Z

do you think adding a flag to not consider a certain frame from becoming the active repl might also make sense?

mkvlr 2020-11-25T08:32:38.243800Z

not likely that a lot of people run into this problem though…

thheller 2020-11-25T08:32:50.244100Z

the problem is that there is no easy way to identify something

thheller 2020-11-25T08:33:03.244400Z

and iframe looks just like any other normal document

mkvlr 2020-11-25T08:33:23.245100Z

sure, maybe a js global to opt out?

thheller 2020-11-25T08:33:23.245200Z

it does identify workers but even with multiple workers it can't identify between them

thheller 2020-11-25T08:34:24.245800Z

sure that would work. must be something coming out of the document loading the JS

mkvlr 2020-11-25T08:34:40.246Z

that would work for our case

thheller 2020-11-25T09:19:17.246800Z

@mkvlr in 2.11.8 you can set <script>var SHADOW_CONFIG = { repl: false };</script> in the HTML (before the actual script) to opt-out of the REPL for that page

thheller 2020-11-25T09:20:46.247600Z

the actual manual REPL select logic I'll need to think about for a bit

mkvlr 2020-11-25T09:24:45.248300Z

@thheller wow, thanks so much!

william 2020-11-25T10:22:38.249400Z

hey, I'm new to clojurescript, could you guide me in the process of adding the cytoscape-cola library to a project using shadowjs?

william 2020-11-25T10:23:03.249600Z

Here's what I know: I can't use cljsjs because shadow-clj doesn't support that, so I think I have to install the library via npm install cytoscape-cola

william 2020-11-25T10:27:34.249900Z

Then I added (:require ["cytoscape-cola" :as cyto])

william 2020-11-25T10:50:24.250100Z

I seem to have solved my problem now, thanks 🙂