@seancorfield I recently wrote a post in my blog about setting up Reveal and networked REPLs, I would suggest starting there: https://vlaaad.github.io/reveal-repls-and-networking Here is an example setup (using powershell/clj on windows escaping) from that post: 1. remote process
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version ""1.10.764""}}}' -X clojure.core.server/start-server :name '"cljs"' :accept cljs.server.browser/prepl :port 7777 :server-daemon false
this runs cljs prepl, so it's impossible to have reveal there since it's a JVM program
2. reveal
clj -Sdeps '{:deps {vlaaad/reveal {:mvn/version ""1.2.188""}}}' -X clojure.core.server/start-server :name '"reveal"' :accept vlaaad.reveal/remote-prepl :args '[:port 7777]' :port 6666 :server-daemon false
this runs reveal that talks to remote process.
3. client (`nc` will do, but I'm going to use clojure repl client)
clj -Sdeps '{:deps {vlaaad/remote-repl {:mvn/version ""1.1""}}}' -X vlaaad.remote-repl/repl :port 6666
in the client process, I can then evaluate a form like js/console
, and it will output this in reveal:
js/console
=> #js {:group #object [group]
:table #object [table]
:dir #object [dir]
:warn #object [warn]
:trace #object [trace]
:time #object [time]
:profileEnd #object [profileEnd]
:timeStamp #object [timeStamp]
:debug #object [debug]
:assert #object [assert]
:groupCollapsed #object [groupCollapsed]
:countReset #object [countReset]
:count #object [count]
:info #object [info]
:timeEnd #object [timeEnd]
:timeLog #object [timeLog]
:error #object [error]
:exception #object [exception]
:dirxml #object [dirxml]
:groupEnd #object [groupEnd]
:log #object [log]
:profile #object [profile]
:clear #object [clear]}
Now, in this client process I can then evaluate {:vlaaad.reveal/command '(open-view v) :env {'v *1}}
, and cljs will return to reveal a map that will be interpreted as a command to open last evaluation (a map describing js/console
) result in a result panel instead of submitting it to output panelthat's how it will look:
Now, this is done with built-in remote prepl. If you manage Reveal window yourself, i.e. using (vlaaad.reveal/ui)
, basically what you need to support reveal commands is to ensure that values containing :vlaaad.reveal/command
keys are submitted to UI fn as is.
In built-in repls, this is done like that: https://github.com/vlaaad/reveal/blob/master/src/vlaaad/reveal/repl.clj#L26-L31
In your dev code, it looks like you are all set since you also use a built-in reveal repl: https://github.com/seancorfield/dot-clojure/blob/develop/dev.clj#L159
@vlaaad Thanks! That makes sense now. I'd read the blog post before (several times) but still couldn't apply it to the setup I was talking about -- because I was thinking about it connected the other way around... I'll try this on Monday.
Ah, I think my problem with this setup is that I need Socket REPL for VS Code/Clover to connect to, not a prepl. So it won't connect to Reveal when Reveal is using a remote-prepl
.
But you are using clover to connect to a local jvm, right? And then you use tap to submit values to Reveal? Tap can be used for submitting commands too
I'm not sure how to configure clover to go through Reveal to some remote process in a way that allows Reveal to see values instead of unrepl internals
If Reveal exposed a Socket REPL and relayed interactions via its remote-prepl to a (socket) prepl started in my legacy process, then I could connect Clover to Reveal via that Socket REPL.
(if Clover could work with a prepl that would also solve the problem -- but Mauricio says that there's quite a bit of the editor-friendly aspects of Socket REPL usage that are very hard with a prepl)
And I can't run Reveal directly in the legacy process (for various reasons -- partly because it has to run on JDK8)
hmm, maybe this is already supported with out-fn
for example, given previous setup with clojurescript prepl on port 7777:
clj -Sdeps '{:deps {vlaaad/reveal {:mvn/version ""1.2.188""}}}'
Clojure 1.10.1
user=> ((requiring-resolve 'vlaaad.reveal/remote-prepl) :port 7777 :out-fn #(-> % :val println))
js/window
#object [Window [object Window]]
would be nice if clover used 2 connections to a process, where first has to be configured in a way clover wants, and it's used for clover machinery (e.g. autocompletion), and second is configured in a way user wants, and it's used for user-submitted forms (e.g. send form to repl, switch ns to current file etc)
Maybe when I'm back at work, I'll look at making a Socket REPL server that relays to a remote prepl -- that's the missing part.