From b152ddf7ea268a753903a4867af91504a6b544e3 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 17 May 2022 16:33:15 +0200 Subject: [PATCH] wip --- README.md | 16 ++++++++++++++++ bb.edn | 11 ++++------- deps.edn | 2 +- src/scittle/nrepl.cljs | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5239709..ec52c4e 100644 --- a/README.md +++ b/README.md @@ -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: + +``` + + ``` ## Tasks diff --git a/bb.edn b/bb.edn index 010d8fc..5d1e088 100644 --- a/bb.edn +++ b/bb.edn @@ -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]} diff --git a/deps.edn b/deps.edn index 644d5e2..7659ee5 100644 --- a/deps.edn +++ b/deps.edn @@ -11,7 +11,7 @@ io.github.babashka/sci.nrepl #_{:local/root "../sci.nrepl"} - {:git/sha "8998f2a4fd25ff02474d7298253e91f059f482b2"}} + {:git/sha "e83421ce9349c36df56a2eb936196dbb65b0de63"}} :aliases {:dev diff --git a/src/scittle/nrepl.cljs b/src/scittle/nrepl.cljs index dfc7591..e7fcad2 100644 --- a/src/scittle/nrepl.cljs +++ b/src/scittle/nrepl.cljs @@ -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")))