wip [skip ci]

This commit is contained in:
Michiel Borkent 2022-05-21 21:51:42 +02:00
parent 2b2dc2de89
commit 19fe9152e7
3 changed files with 20 additions and 4 deletions

View file

@ -3,8 +3,9 @@
:deps :deps
{org.clojure/clojure {:mvn/version "1.10.3"} {org.clojure/clojure {:mvn/version "1.10.3"}
org.babashka/sci #_{:mvn/version "0.3.5"} org.babashka/sci #_{:mvn/version "0.3.5"}
{:git/url "https://github.com/babashka/sci" #_{:git/url "https://github.com/babashka/sci"
:git/sha "b95519dc283bebafa3dcce01c3e9eaaa568d0fcb"} :git/sha "b95519dc283bebafa3dcce01c3e9eaaa568d0fcb"}
{:local/root "../babashka/sci"}
reagent/reagent {:mvn/version "1.1.0"} reagent/reagent {:mvn/version "1.1.0"}
cljsjs/react {:mvn/version "17.0.2-0"} cljsjs/react {:mvn/version "17.0.2-0"}
cljsjs/react-dom {:mvn/version "17.0.2-0"} cljsjs/react-dom {:mvn/version "17.0.2-0"}

View file

@ -49,7 +49,11 @@
(let [response (gobject/get req "response")] (let [response (gobject/get req "response")]
(set! (.-innerText code) response) (set! (.-innerText code) response)
(.highlightElement js/hljs code)))) (.highlightElement js/hljs code))))
(.send req))) (.send req)))
(set! (.-eval_input js/window) (fn []
(let [value (.-value (js/document.getElementById "myInput"))]
(js/scittle.core.eval_string value))))
</script> </script>
@ -118,6 +122,12 @@
Click me! Click me!
</button> </button>
<a name="eval"></a>
<h2><a href="#eval">Evaluate</a></h2>
<textarea id="myInput" type="textarea">(ns foo (:require [bar]))
</textarea>
<button onclick="eval_input()">Eval!</button>
<a name="repl"></a> <a name="repl"></a>
<h2><a href="#nrepl">REPL</a></h2> <h2><a href="#nrepl">REPL</a></h2>

View file

@ -33,8 +33,13 @@
(def !sci-ctx (atom (sci/init {:namespaces namespaces (def !sci-ctx (atom (sci/init {:namespaces namespaces
:classes {'js js/window :classes {'js js/window
:allow :all} :allow :all}
:disable-arity-checks true}))) :disable-arity-checks true
:async-load-fn (fn [{:keys [libname ctx opts]}]
(-> (js* (str "import('" libname "')"))
(.then (fn [mod]
(sci/add-class! ctx (:as opts) mod)))
(.then (fn [_]
{:handled true}))))})))
(def !last-ns (volatile! @sci/ns)) (def !last-ns (volatile! @sci/ns))