This commit is contained in:
Michiel Borkent 2022-05-17 16:33:15 +02:00
parent de54410669
commit b152ddf7ea
4 changed files with 22 additions and 9 deletions

View file

@ -18,8 +18,24 @@ See [releases](https://github.com/babashka/scittle/releases) for links to
To connect to a Scittle REPL from your editor, scittle provides an nREPL
implementation. To run the nREPL server you need to follow these steps:
In babashka or Clojure JVM, use the
[sci.nrepl](https://github.com/babashka/sci.nrepl) dependency and run:
```
(require 'sci.nrepl.browser-server :as bp)
(bp/start! {:nrepl-port 1339 :websocket-port 1340})
```
This will run an nREPL server on port 1339 and a websocket server on port 1340.
Your editor's nREPL client will connect to port 1339 and your browser, running
scittle, will connect to port 1340.
In your scittle website, you will need to include the following, in addition to
the normal routine:
```
<script>var SCITTLE_NREPL_WEBSOCKET_PORT = 1340;</script>
<script src="js/scittle.nrepl.js" type="application/javascript"></script>
```
## Tasks

11
bb.edn
View file

@ -1,6 +1,6 @@
{:deps {io.github.babashka/sci.nrepl
;; {:local/root "../sci.nrepl"}
{:git/sha "318e39fc356652d749180f3a3efba5eb4b99d304"}}
{:local/root "../sci.nrepl"}
#_{:git/sha "318e39fc356652d749180f3a3efba5eb4b99d304"}}
:tasks
{:requires ([babashka.fs :as fs]
@ -16,11 +16,8 @@
:task (clojure "-M:dev -m shadow.cljs.devtools.cli watch main")}
browser-nrepl {:doc "Start browser nREPL"
:requires ([sci.nrepl.browser-proxy :as bp])
:task (do (bp/start-browser-nrepl! {:port 1339})
(bp/serve! {:port 1340})
(println "Started browser nREPL on port 1339")
(deref (promise)))}
:requires ([sci.nrepl.browser-server :as bp])
:task (bp/start! {})}
-dev {:depends [shadow:watch browser-nrepl]}

View file

@ -11,7 +11,7 @@
io.github.babashka/sci.nrepl
#_{:local/root "../sci.nrepl"}
{:git/sha "8998f2a4fd25ff02474d7298253e91f059f482b2"}}
{:git/sha "e83421ce9349c36df56a2eb936196dbb65b0de63"}}
:aliases
{:dev

View file

@ -31,7 +31,7 @@
:complete (let [completions (completions (assoc msg :ctx @!sci-ctx))]
(nrepl-reply msg completions))))
(when (.-SCITTLE_BROWSER_REPL_PROXY_PORT js/window)
(when (.-SCITTLE_NREPL_WEBSOCKET_PORT js/window)
(set! (.-ws_nrepl js/window)
(new js/WebSocket "ws://localhost:1340/_nrepl")))