diff --git a/deps.edn b/deps.edn index 1aca18d..8d343d9 100644 --- a/deps.edn +++ b/deps.edn @@ -7,7 +7,8 @@ reagent/reagent {:mvn/version "1.0.0"} cljsjs/react {:mvn/version "17.0.2-0"} cljsjs/react-dom {:mvn/version "17.0.2-0"} - cljsjs/react-dom-server {:mvn/version "17.0.2-0"}} + cljsjs/react-dom-server {:mvn/version "17.0.2-0"} + cljs-ajax/cljs-ajax {:mvn/version "0.8.3"}} :aliases {:dev diff --git a/shadow-cljs.edn b/shadow-cljs.edn index b09b7e4..ff3946c 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -15,7 +15,9 @@ :modules {:scittle {:entries [scittle.core]} :scittle.reagent {:entries [scittle.reagent] - :depends-on #{:scittle}}} + :depends-on #{:scittle}} + :scittle.cljs-ajax {:entries [scittle.cljs-ajax] + :depends-on #{:scittle}}} :build-hooks [(shadow.cljs.build-report/hook)] :output-dir "resources/public/js" :devtools {:repl-pprint true}}}} diff --git a/src/scittle/cljs_ajax.cljs b/src/scittle/cljs_ajax.cljs new file mode 100644 index 0000000..a129e6e --- /dev/null +++ b/src/scittle/cljs_ajax.cljs @@ -0,0 +1,14 @@ +(ns scittle.cljs-ajax + (:require [ajax.core :as ajx] + [sci.core :as sci] + [scittle.core :as scittle])) + +(def ans (sci/create-ns 'ajax.core nil)) + +(def ajax-namespace + {'GET (sci/copy-var ajx/GET ans) + 'POST (sci/copy-var ajx/POST ans)}) + +(scittle/register-plugin! + ::ajax + {:namespaces {'ajax.core ajax-namespace}}) diff --git a/src/scittle/core.cljs b/src/scittle/core.cljs index bc51c59..db86965 100644 --- a/src/scittle/core.cljs +++ b/src/scittle/core.cljs @@ -3,7 +3,8 @@ (:require [goog.object :as gobject] [goog.string] [sci.core :as sci] - [scittle.impl.error :as error])) + [scittle.impl.error :as error] + [cljs.reader :refer [read-string]])) (clojure.core/defmacro time "Evaluates expr and prints the time it took. Returns the value of expr." @@ -17,13 +18,16 @@ (def stns (sci/create-ns 'sci.script-tag nil)) (def cljns (sci/create-ns 'clojure.core nil)) +(def rns (sci/create-ns 'cljs.reader nil)) (def namespaces {'clojure.core {'println println 'prn prn 'system-time system-time - 'time (sci/copy-var time cljns)} + 'time (sci/copy-var time cljns) + 'random-uuid random-uuid + 'read-string (sci/copy-var read-string rns)} 'goog.object {'set gobject/set 'get gobject/get}}) diff --git a/src/scittle/reagent.cljs b/src/scittle/reagent.cljs index 72afaad..4cf687c 100644 --- a/src/scittle/reagent.cljs +++ b/src/scittle/reagent.cljs @@ -7,7 +7,8 @@ (def rns (sci/create-ns 'reagent.core nil)) (def reagent-namespace - {'atom (sci/copy-var r/atom rns)}) + {'atom (sci/copy-var r/atom rns) + 'as-element (sci/copy-var r/as-element rns)}) (def rdns (sci/create-ns 'reagent.dom nil))