wip
This commit is contained in:
parent
8c2dfee980
commit
a488900e23
3 changed files with 20 additions and 8 deletions
4
bb.edn
4
bb.edn
|
|
@ -1,6 +1,6 @@
|
||||||
{:deps {io.github.babashka/sci.nrepl
|
{:deps {io.github.babashka/sci.nrepl
|
||||||
#_{:local/root "../sci.nrepl"}
|
{:local/root "../sci.nrepl"}
|
||||||
{:git/sha "8998f2a4fd25ff02474d7298253e91f059f482b2"}}
|
#_{:git/sha "8998f2a4fd25ff02474d7298253e91f059f482b2"}}
|
||||||
|
|
||||||
:tasks
|
:tasks
|
||||||
{:requires ([babashka.fs :as fs]
|
{:requires ([babashka.fs :as fs]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
(ns nrepl)
|
(ns nrepl)
|
||||||
|
|
||||||
(+ 1 2 3)
|
(+ 1 2 3)
|
||||||
|
|
||||||
|
(->
|
||||||
|
(js/document.getElementsByTagName "body")
|
||||||
|
first
|
||||||
|
(.append
|
||||||
|
(doto (js/document.createElement "p")
|
||||||
|
(.append
|
||||||
|
(js/document.createTextNode "there")))))
|
||||||
|
|
||||||
|
(js/alert "Isn't this cool? :)")
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,7 @@
|
||||||
[scittle.core :refer [!last-ns eval-string !sci-ctx]]))
|
[scittle.core :refer [!last-ns eval-string !sci-ctx]]))
|
||||||
|
|
||||||
(defn nrepl-websocket []
|
(defn nrepl-websocket []
|
||||||
(when (.-SCITTLE_BROWSER_REPL_PROXY_PORT js/window)
|
(.-ws_nrepl js/window))
|
||||||
(set! (.-ws_nrepl js/window)
|
|
||||||
(new js/WebSocket "ws://localhost:1340/_nrepl"))
|
|
||||||
(.-ws_nrepl js/window)))
|
|
||||||
|
|
||||||
(defn nrepl-reply [{:keys [id session]} payload]
|
(defn nrepl-reply [{:keys [id session]} payload]
|
||||||
(.send (nrepl-websocket)
|
(.send (nrepl-websocket)
|
||||||
|
|
@ -31,12 +28,17 @@
|
||||||
(defn handle-nrepl-message [msg]
|
(defn handle-nrepl-message [msg]
|
||||||
(case (:op msg)
|
(case (:op msg)
|
||||||
:eval (handle-nrepl-eval msg)
|
:eval (handle-nrepl-eval msg)
|
||||||
:complete (nrepl-reply msg (completions (assoc msg :ctx @!sci-ctx)))))
|
:complete (let [completions (completions (assoc msg :ctx @!sci-ctx))]
|
||||||
|
(nrepl-reply msg completions))))
|
||||||
|
|
||||||
|
(when (.-SCITTLE_BROWSER_REPL_PROXY_PORT js/window)
|
||||||
|
(set! (.-ws_nrepl js/window)
|
||||||
|
(new js/WebSocket "ws://localhost:1340/_nrepl")))
|
||||||
|
|
||||||
(when-let [ws (nrepl-websocket)]
|
(when-let [ws (nrepl-websocket)]
|
||||||
|
(prn :ws ws)
|
||||||
(set! (.-onmessage ws)
|
(set! (.-onmessage ws)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(prn :event event)
|
|
||||||
(handle-nrepl-message (edn/read-string (.-data event)))))
|
(handle-nrepl-message (edn/read-string (.-data event)))))
|
||||||
(set! (.-onerror ws)
|
(set! (.-onerror ws)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue