wip
This commit is contained in:
parent
12b96602a3
commit
8c2dfee980
4 changed files with 35 additions and 11 deletions
20
bb.edn
20
bb.edn
|
|
@ -1,4 +1,8 @@
|
||||||
{:tasks
|
{:deps {io.github.babashka/sci.nrepl
|
||||||
|
#_{:local/root "../sci.nrepl"}
|
||||||
|
{:git/sha "8998f2a4fd25ff02474d7298253e91f059f482b2"}}
|
||||||
|
|
||||||
|
:tasks
|
||||||
{:requires ([babashka.fs :as fs]
|
{:requires ([babashka.fs :as fs]
|
||||||
[cheshire.core :as json]
|
[cheshire.core :as json]
|
||||||
[babashka.process :as p :refer [process]])
|
[babashka.process :as p :refer [process]])
|
||||||
|
|
@ -8,9 +12,21 @@
|
||||||
(fs/delete-tree ".cpcache")
|
(fs/delete-tree ".cpcache")
|
||||||
(fs/delete-tree ".shadow-cljs"))}
|
(fs/delete-tree ".shadow-cljs"))}
|
||||||
|
|
||||||
dev {:doc "Development build. Starts webserver and watches for changes."
|
shadow:watch {:doc "Development build. Starts webserver and watches for changes."
|
||||||
:task (clojure "-M:dev -m shadow.cljs.devtools.cli watch main")}
|
: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)))}
|
||||||
|
|
||||||
|
-dev {:depends [shadow:watch browser-nrepl]}
|
||||||
|
|
||||||
|
dev {:doc "Development build. Starts webserver and watches for changes."
|
||||||
|
:task (run '-dev {:parallel true})}
|
||||||
|
|
||||||
prod {:doc "Builds production artifacts."
|
prod {:doc "Builds production artifacts."
|
||||||
:task (clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}
|
:task (clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}
|
||||||
"-M:dev -m shadow.cljs.devtools.cli release main")}
|
"-M:dev -m shadow.cljs.devtools.cli release main")}
|
||||||
|
|
|
||||||
3
resources/public/cljs/nrepl.cljs
Normal file
3
resources/public/cljs/nrepl.cljs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
(ns nrepl)
|
||||||
|
|
||||||
|
(+ 1 2 3)
|
||||||
|
|
@ -3,7 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="js/scittle.js" type="application/javascript"></script>
|
<script src="js/scittle.js" type="application/javascript"></script>
|
||||||
|
<script>var SCITTLE_BROWSER_REPL_PROXY_PORT = 1340;</script>
|
||||||
<script src="js/scittle.nrepl.js" type="application/javascript"></script>
|
<script src="js/scittle.nrepl.js" type="application/javascript"></script>
|
||||||
|
<script type="application/x-scittle" src="cljs/nrepl.cljs"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Scittle</h1>
|
<h1>Scittle</h1>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@
|
||||||
[scittle.core :refer [!last-ns eval-string !sci-ctx]]))
|
[scittle.core :refer [!last-ns eval-string !sci-ctx]]))
|
||||||
|
|
||||||
(defn nrepl-websocket []
|
(defn nrepl-websocket []
|
||||||
(.-ws_nrepl js/window))
|
(when (.-SCITTLE_BROWSER_REPL_PROXY_PORT 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)
|
||||||
|
|
@ -30,11 +33,11 @@
|
||||||
:eval (handle-nrepl-eval msg)
|
:eval (handle-nrepl-eval msg)
|
||||||
:complete (nrepl-reply msg (completions (assoc msg :ctx @!sci-ctx)))))
|
:complete (nrepl-reply msg (completions (assoc msg :ctx @!sci-ctx)))))
|
||||||
|
|
||||||
(defn ^:export init-nrepl []
|
(when-let [ws (nrepl-websocket)]
|
||||||
(let [ws (nrepl-websocket)]
|
|
||||||
(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]
|
||||||
(js/console.log event)))))
|
(js/console.log event))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue