diff --git a/deps.edn b/deps.edn
index ef7dbf4..54fd4b6 100644
--- a/deps.edn
+++ b/deps.edn
@@ -3,7 +3,7 @@
{org.clojure/clojure {:mvn/version "1.11.1"}
thheller/shadow-cljs {:mvn/version "2.20.15"}
org.babashka/sci {:git/url "https://github.com/babashka/sci"
- :git/sha "8da8f44c41f507e56256b23d0a05c0172d881859"}
+ :git/sha "3e4689f5163c825ba6fd3085d08b0f95eee00c40"}
#_{:local/root "../babashka/sci"}
reagent/reagent {:mvn/version "1.1.1"}
re-frame/re-frame {:mvn/version "1.3.0"}
@@ -11,7 +11,7 @@
cljsjs/react-dom {:mvn/version "18.2.0-1"}
cljsjs/react-dom-server {:mvn/version "18.2.0-1"}
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}
- funcool/promesa {:mvn/version "10.0.575"}
+ funcool/promesa {:mvn/version "11.0.678"}
io.github.babashka/sci.nrepl
#_{:local/root "../sci.nrepl"}
{:git/url "https://github.com/babashka/sci.nrepl"
@@ -19,7 +19,7 @@
io.github.babashka/sci.configs
#_{:local/root "/Users/borkdude/dev/sci.configs"}
{:git/url "https://github.com/babashka/sci.configs"
- :git/sha "33bd51e53700b224b4cb5bda59eb21b62f962745"}}
+ :git/sha "08bab21643bc0c63a5b99c65193c9d24888270b7"}}
:aliases
{:dev
{:extra-paths ["dev"]
diff --git a/plugins/demo/bb.edn b/plugins/demo/bb.edn
index bbf3388..86170d0 100644
--- a/plugins/demo/bb.edn
+++ b/plugins/demo/bb.edn
@@ -1,6 +1,8 @@
{:deps {io.github.babashka/scittle.build {:local/root "../../build"}
;; datascript plugin
- io.github.babashka/scittle.datascript {:local/root "../../plugins/datascript"}
+ ; io.github.babashka/scittle.datascript {:local/root "../../plugins/datascript"}
+ io.github.babashka/scittle.javelin {:local/root "../../plugins/javelin"}
+ io.github.babashka/scittle.hoplon {:local/root "../../plugins/hoplon"}
io.github.babashka/http-server
{:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}}
:tasks
diff --git a/plugins/demo/resources/public/index.html b/plugins/demo/resources/public/index.html
index a48dfc4..7f328cc 100644
--- a/plugins/demo/resources/public/index.html
+++ b/plugins/demo/resources/public/index.html
@@ -1,14 +1,21 @@
-
+
-
+
+
+ Hello Hoplon!
diff --git a/plugins/hoplon/deps.edn b/plugins/hoplon/deps.edn
new file mode 100644
index 0000000..e7aef52
--- /dev/null
+++ b/plugins/hoplon/deps.edn
@@ -0,0 +1,3 @@
+{:deps
+ {hoplon/hoplon {:mvn/version "7.5.0"}
+ io.github.babashka/sci.configs {:git/sha "08bab21643bc0c63a5b99c65193c9d24888270b7"}}}
diff --git a/plugins/hoplon/src/scittle/hoplon.cljs b/plugins/hoplon/src/scittle/hoplon.cljs
new file mode 100644
index 0000000..46e5a3b
--- /dev/null
+++ b/plugins/hoplon/src/scittle/hoplon.cljs
@@ -0,0 +1,9 @@
+(ns scittle.hoplon
+ {:no-doc true}
+ (:require [sci.configs.hoplon.hoplon :refer [config]]
+ [scittle.core :as scittle]))
+
+(defn init []
+ (scittle/register-plugin!
+ ::hoplon
+ config))
diff --git a/plugins/hoplon/src/scittle/javelin.cljs b/plugins/hoplon/src/scittle/javelin.cljs
new file mode 100644
index 0000000..7334a2d
--- /dev/null
+++ b/plugins/hoplon/src/scittle/javelin.cljs
@@ -0,0 +1,9 @@
+(ns scittle.javelin
+ {:no-doc true}
+ (:require [sci.configs.hoplon.javelin :refer [config]]
+ [scittle.core :as scittle]))
+
+(defn init []
+ (scittle/register-plugin!
+ ::javelin
+ config))
diff --git a/plugins/hoplon/src/scittle_plugin.edn b/plugins/hoplon/src/scittle_plugin.edn
new file mode 100644
index 0000000..5a9f8f6
--- /dev/null
+++ b/plugins/hoplon/src/scittle_plugin.edn
@@ -0,0 +1,13 @@
+[{:name scittle/hoplon
+ :namespaces [javelin.core
+ hoplon.core
+ hoplon.dom]
+ :js "./scittle.hoplon.js"
+ :shadow-config
+ {:modules
+ {:scittle.hoplon {:init-fn scittle.hoplon/init
+ :depends-on #{:scittle :scittle.javelin}
+ :entries [hoplon.core hoplon.dom]}
+ :scittle.javelin {:init-fn scittle.javelin/init
+ :depends-on #{:scittle}
+ :entries [javelin.core]}}}}]
diff --git a/plugins/javelin/deps.edn b/plugins/javelin/deps.edn
new file mode 100644
index 0000000..135f602
--- /dev/null
+++ b/plugins/javelin/deps.edn
@@ -0,0 +1,3 @@
+{:deps
+ {hoplon/javelin {:mvn/version "3.9.3"}
+ io.github.babashka/sci.configs {:git/sha "08bab21643bc0c63a5b99c65193c9d24888270b7"}}}
diff --git a/plugins/javelin/src/scittle/javelin.cljs b/plugins/javelin/src/scittle/javelin.cljs
new file mode 100644
index 0000000..7334a2d
--- /dev/null
+++ b/plugins/javelin/src/scittle/javelin.cljs
@@ -0,0 +1,9 @@
+(ns scittle.javelin
+ {:no-doc true}
+ (:require [sci.configs.hoplon.javelin :refer [config]]
+ [scittle.core :as scittle]))
+
+(defn init []
+ (scittle/register-plugin!
+ ::javelin
+ config))
diff --git a/plugins/javelin/src/scittle_plugin.edn b/plugins/javelin/src/scittle_plugin.edn
new file mode 100644
index 0000000..c34873f
--- /dev/null
+++ b/plugins/javelin/src/scittle_plugin.edn
@@ -0,0 +1,8 @@
+[{:name scittle/javelin
+ :namespaces [javelin.core]
+ :js "./scittle.javelin.js"
+ :shadow-config
+ {:modules
+ {:scittle.javelin {:init-fn scittle.javelin/init
+ :depends-on #{:scittle}
+ :entries [javelin.core]}}}}]
diff --git a/src/scittle/core.cljs b/src/scittle/core.cljs
index e474380..948e0d1 100644
--- a/src/scittle/core.cljs
+++ b/src/scittle/core.cljs
@@ -4,6 +4,7 @@
[goog.object :as gobject]
[goog.string]
[sci.core :as sci]
+ [sci.ctx-store :as store]
[sci.impl.unrestrict]
[scittle.impl.common :refer [cljns]]
[scittle.impl.error :as error]
@@ -45,12 +46,12 @@
'sci.core {'stacktrace sci/stacktrace
'format-stacktrace sci/format-stacktrace}})
-(def !sci-ctx
- (atom (sci/init {:namespaces namespaces
- :classes {'js js/globalThis
- :allow :all
- 'Math js/Math}
- :ns-aliases {'clojure.pprint 'cljs.pprint}})))
+(store/reset-ctx!
+ (sci/init {:namespaces namespaces
+ :classes {'js js/globalThis
+ :allow :all
+ 'Math js/Math}
+ :ns-aliases {'clojure.pprint 'cljs.pprint}}))
(def !last-ns (volatile! @sci/ns))
@@ -58,21 +59,21 @@
(sci/binding [sci/ns @!last-ns]
(let [rdr (sci/reader s)]
(loop [res nil]
- (let [form (sci/parse-next @!sci-ctx rdr)]
+ (let [form (sci/parse-next (store/get-ctx) rdr)]
(if (= :sci.core/eof form)
(do
(vreset! !last-ns @sci/ns)
res)
- (recur (sci/eval-form @!sci-ctx form))))))))
+ (recur (sci/eval-form (store/get-ctx) form))))))))
(defn ^:export eval-string [s]
(try (-eval-string s)
(catch :default e
- (error/error-handler e (:src @!sci-ctx))
+ (error/error-handler e (:src (store/get-ctx)))
(throw e))))
(defn register-plugin! [_plug-in-name sci-opts]
- (swap! !sci-ctx sci/merge-opts sci-opts))
+ (store/swap-ctx! sci/merge-opts sci-opts))
(defn- eval-script-tags* [script-tags]
(when-let [tag (first script-tags)]
@@ -84,7 +85,7 @@
(let [response (gobject/get this "response")]
(gobject/set tag "scittle_id" src)
;; save source for error messages
- (swap! !sci-ctx assoc-in [:src src] response)
+ (store/swap-ctx! assoc-in [:src src] response)
(sci/binding [sci/file src]
(eval-string response)))
(eval-script-tags* (rest script-tags)))))]
@@ -92,7 +93,7 @@
(if-let [text (not-empty (str/trim (gobject/get tag "textContent")))]
(let [scittle-id (str (gensym "scittle-tag-"))]
(gobject/set tag "scittle_id" scittle-id)
- (swap! !sci-ctx assoc-in [:src scittle-id] text)
+ (store/swap-ctx! assoc-in [:src scittle-id] text)
(sci/binding [sci/file scittle-id]
(eval-string text))
(eval-script-tags* (rest script-tags)))
diff --git a/src/scittle/nrepl.cljs b/src/scittle/nrepl.cljs
index d96ed6b..d4a8463 100644
--- a/src/scittle/nrepl.cljs
+++ b/src/scittle/nrepl.cljs
@@ -1,9 +1,10 @@
(ns scittle.nrepl
(:require
[clojure.edn :as edn]
+ [sci.ctx-store :as store]
[sci.nrepl.completions :refer [completions]]
[sci.nrepl.info :refer [info]]
- [scittle.core :refer [!last-ns eval-string !sci-ctx]]))
+ [scittle.core :refer [!last-ns eval-string]]))
(defn nrepl-websocket []
(.-ws_nrepl js/window))
@@ -29,7 +30,7 @@
:status ["error" "done"]})))))
(defn handle-nrepl-info [msg]
- (let [info (info (assoc msg :ctx @!sci-ctx))]
+ (let [info (info (assoc msg :ctx (store/get-ctx)))]
(nrepl-reply msg info)))
(declare ops)
@@ -61,13 +62,13 @@
:eldoc handle-nrepl-info
:lookup handle-nrepl-info
:describe handle-describe
- :complete (fn [msg] (let [completions (completions (assoc msg :ctx @!sci-ctx))]
+ :complete (fn [msg] (let [completions (completions (assoc msg :ctx (store/get-ctx)))]
(nrepl-reply msg completions)))})
(defn handle-nrepl-message [msg]
(if-let [handler (ops (:op msg))]
(handler msg)
- (nrepl-reply (merge msg {:status ["error" "done"] :err "unkown-op"}) (assoc msg :ctx @!sci-ctx))))
+ (nrepl-reply (merge msg {:status ["error" "done"] :err "unkown-op"}) (assoc msg :ctx (store/get-ctx)))))
(defn ws-url [host port path]
(str "ws://" host ":" port "/" path))