Skip to content

Commit

Permalink
reval dep bump (had breaking changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Jul 1, 2024
1 parent 718f0ae commit 515f40d
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 481 deletions.
9 changes: 5 additions & 4 deletions demo/deps.edn
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{:paths ["src"
"resources"
"target/webly"]
:deps {org.pinkgorilla/goldly {:local/root ".." :deps/manifest :deps}
org.pinkgorilla/webly {:mvn/version "0.5.688"}
org.pinkgorilla/ui-repl {:mvn/version "0.1.105"}
org.pinkgorilla/ui-site {:mvn/version "0.0.30"}
:deps {org.pinkgorilla/ui-repl {:mvn/version "0.1.105"}
org.pinkgorilla/ui-site {:mvn/version "0.0.31"}
org.pinkgorilla/ui-binaryclock {:mvn/version "0.2.20"}
org.pinkgorilla/ui-tailwind {:mvn/version "0.1.8"}
;org.pinkgorilla/devtools {:mvn/version "0.0.17"}
org.pinkgorilla/clj-service {:mvn/version "0.3.18"}
org.pinkgorilla/webly {:mvn/version "0.7.693"}
org.pinkgorilla/goldly {:local/root ".." :deps/manifest :deps}
}

:aliases
Expand Down
8 changes: 4 additions & 4 deletions demo/resources/demo/notebook/lazy.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
'[(ns example2 (:require [adder]))
(adder/add 7 13)])
(async-eval
'[(ns example3 (:require [funny]))
(funny/joke)])
'[(ns example3 (:require [demo.dynamic.funny]))
(demo.dynamic.funny/joke)])
(async-eval
'[(ns example4 (:require [funny :refer [joke]]))
'[(ns example4 (:require [demo.dynamic.funny :refer [joke]]))
(joke)])
(async-eval
'[(ns example5 (:require [funny :as f]))
'[(ns example5 (:require [demo.dynamic.funny :as f]))
(f/joke)])]


Expand Down
2 changes: 1 addition & 1 deletion demo/resources/ext/pages.edn
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lazy" demo.page.lazy/lazy-page
"kernel" demo.page.kernel/kernel-page
"error" demo.page.error/error-page
"sci-interpreted" demo.page.scipage/sci-page
"sci-interpreted" demo.page.sci-page-interpreted/sci-page
}

:sci-cljs-ns [demo.cljs-libs.helper]}
8 changes: 5 additions & 3 deletions demo/resources/task-services.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
:components
{:config {:start (modular.config/load-config! (:config #ref [:modular]))}
:exts {:start (extension/discover)}

:reval {:start (reval.config/set-config!
(:reval (deref (clip/ref :config))))}

:reval {:start (reval.core/start-reval
{:config (:reval (deref (clip/ref :config)))
:clj nil
:reval-role nil})}

;
}}
22 changes: 15 additions & 7 deletions demo/resources/test-services.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@
{:config {:start (modular.config/load-config! (:config #ref [:modular]))}
:exts {:start (extension/discover)}

:permission {:start (modular.permission.core/start-permissions
{} ; empty users map. users only are needed if oauth2 module gets loaded,
; because without identity-token users cannot be "logged in"
)}

:clj-service {:start (clj-service.core/start-clj-services
(clip/ref :permission)
(clip/ref :exts))}

:reval {:start (reval.core/start-reval
{:config (:reval (deref (clip/ref :config)))
:clj (clip/ref :clj-service)
:reval-role nil})}

:webly {:start (webly.app.app/start-webly
(clip/ref :exts)
(deref (clip/ref :config))
(:profile #ref [:modular]))
:stop (webly.app.app/stop-webly this)}

:clj-service {:start (goldly.service/start-clj-services
(clip/ref :exts))}

:reval {:start (reval.config/set-config!
(:reval (deref (clip/ref :config))))}


;
}}
2 changes: 1 addition & 1 deletion demo/src/demo/cljs_libs/helper.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{:text "lazyload-test" :dispatch [:bidi/goto 'demo.page.lazy/lazy-page]}
{:text "kernel" :dispatch [:bidi/goto 'demo.page.kernel/kernel-page]}
{:text "error-test" :dispatch [:bidi/goto 'demo.page.error/error-page]}
{:text "sci-interpreted" :dispatch [:bidi/goto 'demo.page.scipage/sci-page]}]}])
{:text "sci-interpreted" :dispatch [:bidi/goto 'demo.page.sci-page-interpreted/sci-page]}]}])

(defn wrap-layout [page]
(fn [route]
Expand Down
5 changes: 5 additions & 0 deletions demo/src/demo/dynamic/animal.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns demo.dynamic.animal)

(defn favorite-animal []
(println "animal gets executed (via sci)")
"Elephant")
7 changes: 7 additions & 0 deletions demo/src/demo/dynamic/funny.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns demo.dynamic.funny)


(defn joke []
(println "joke gets executed (via sci)")
"The early bird catches the worm!"
)
150 changes: 99 additions & 51 deletions demo/src/demo/page/sci_compile.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,114 @@
[clojure.string :refer [join]]
[reagent.core :as r]
[promesa.core :as p]
[goldly.sci :refer [require-async compile-code compile-code-async requiring-resolve resolve-symbol]]
[goldly.sci :refer [require-async compile-code compile-code-async
requiring-resolve resolve-symbol]]
[demo.cljs-libs.helper :refer [wrap-layout]]))

(def code (join
"\n"
(map pr-str '[(ns example (:require ["some_js_lib" :as my-lib]))
(my-lib/libfn)])))
(defn compile-sync-test []
[:div
"sync compile result for: (+ 5 5)" (pr-str (compile-code "(+ 5 5)"))])


(defn show-result [a]
[:div
(if (nil? @a)
[:p "require pending"]
[:p "require result: " (pr-str @a)])
(when (not (nil? @a))
(let [f (resolve-symbol 'demo.funny/joke)]
(when f
[:p "joke: " (f)])))])
(defn compile-async-test []
(let [a (r/atom "not clicked yet.")
code "(+ 7 7)"
run (fn [& _]
(println "compile-async-test code: " code)
(let [rp (compile-code-async code)]
(-> rp
(p/then (fn [res]
(println "compile-code-async result: " res)
(reset! a (pr-str res))))
(p/catch (fn [err]
(println "compile-code-async error: " err)
(reset! a "error"))))))]
(fn []
[:div
[:a {:class "bg-blue-500" :on-click run} [:p.bg-green-500 "click to see add result"]]
[:div "result: " @a]])))

(defn sci-compile-page1 [_route-data]
(let [; sci-require
r-a (r/atom nil)
r-p (-> (require-async '[demo.funny :refer [joke]])
(.then (fn [d]
(println "require result received!")
(reset! r-a {:data d})))
(.catch (fn [d]
(println "require result failure!")
(reset! r-a {:err d}))))
; async-sci-compile
(defn compile-async-fail-test []
(let [code (join
"\n"
(map pr-str '[(ns example (:require ["some_js_lib" :as my-lib]))
(my-lib/libfn)]))
ca-a (r/atom "no async result")
ca-p (compile-code-async code)
; sci-requiring-resolve
rr-a (r/atom "no-favorite-animal")
ca-p (compile-code-async code)]
(-> ca-p
(p/then (fn [result]
(println "compile-async result: " result)
(reset! ca-a (pr-str result))))
(p/catch ca-p (fn [err]
(println "compile-async error: " err)
(reset! ca-a (str "error: " (pr-str err))))))
(fn []
[:div "result: " @ca-a])))



(defn require-async-test []
(let [a (r/atom "pending")
_ (-> (require-async '[demo.dynamic.funny :refer [joke]])
(p/then (fn [d]
(println "async require success! data: " d)
(if-let [f (resolve-symbol 'demo.dynamic.funny/joke)]
(reset! a (str "joke: " (f)))
(reset! a "error: cound not resolve 'demo.funny/joke)"))))
(p/catch (fn [error]
(println "require result failure! error: " error)
(reset! a "error: could not require-async demo.funny"))))]
(fn []
[:div
[:p "result: " (pr-str @a)]])))

(defn requiring-resolve-test []
(let [rr-a (r/atom "no-favorite-animal")
rr-p (requiring-resolve 'demo.dynamic.animal/favorite-animal)]
(-> rr-p
(p/then (fn [fun]
(let [animal (fun)]
(reset! rr-a animal))))
(p/catch (fn [err]
(println "animal-test error: " err)
(reset! rr-a "error"))))
(fn []
[:div "result: " @rr-a])))

(p/then ca-p (fn [result]
(reset! ca-a result)))
(p/catch ca-p (fn [result]
(reset! ca-a {:error result})))
(p/then rr-p (fn [fun]
(let [animal (fun)]
(reset! rr-a animal))))
(fn [_route-data]
[:div.bg-red-200.w-screen.h-screen.p-5
; sci-require
[:p.text-blue-500.text-xxl "sci require test."]
[:div "test for require: (require result should show up): " [show-result r-a]]
; (sync) sci-compile
[:p.text-blue-500.text-xxl "sci compile test."]
[:p "test for compilation: (+ 5 5)" (pr-str (compile-code "(+ 5 5)"))]


(defn sci-compile-page1 [_route-data]
[:div.bg-red-200.w-screen.h-screen.p-5
; (sync) sci-compile
[:p.text-blue-500.text-xxl "sci compile (sync)"]
[:div.text-red-500
[compile-sync-test]]

; async-sci-compile
[:p.text-blue-500.text-xxl "sci async-compile test."]
[:p "test for async compilation: " (pr-str @ca-a)]
[:p.bg-red-500
[:a {:on-click #(compile-code-async "(println \"hello from sci\")")}
"click to 'println' to browser console - should say [hello from sci]"]]
[:p.text-blue-500.text-xxl "sci compile (async)"]
[:div.text-red-500
[compile-async-test]]

; async-sci-compile
[:p.text-blue-500.text-xxl "sci compile (async) will fail"]
[:div.text-red-500
[compile-async-fail-test]]

; sci-requiring-resolve
[:p.text-blue-500.text-xxl "sci requiring-resolve test"]
[:p.bg-green-500
"favorite animal (no-favorite-animal is an error): " @rr-a]])))
[:p.text-blue-500.text-xxl "sci requiring-resolve test"]
[:div.text-red-500
[requiring-resolve-test]]

; sci-require
[:p.text-blue-500.text-xxl "sci require (async) test."]
[:div.text-red-500
[require-async-test]]





])

(def sci-compile-page
(wrap-layout sci-compile-page1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns demo.page.scipage
(ns demo.page.sci-page-interpreted
(:require
[demo.cljs-libs.helper :refer [wrap-layout]]))

Expand All @@ -7,6 +7,7 @@
[:div
[:p "I am interpreted by sci"]
[:p "1 + 2 = " (+ 1 2)]
[:p "please check if the addition result is correct!"]
])

(def sci-page
Expand Down
2 changes: 1 addition & 1 deletion goldly-sci/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
org.babashka/sci {:mvn/version "0.8.40"}
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"} ; sci code loading
org.pinkgorilla/ui-dialog-keybindings {:mvn/version "0.1.10"}
org.pinkgorilla/timbre {:mvn/version "0.0.6"}}
org.pinkgorilla/timbre {:mvn/version "0.0.7"}}

:aliases
{;; developer tooling
Expand Down
2 changes: 1 addition & 1 deletion reval-sci/deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{:paths ["src"
"resources" ; extension
]
:deps {org.pinkgorilla/reval {:mvn/version "0.6.159"}}
:deps {org.pinkgorilla/reval {:mvn/version "0.7.160"}}
;
}
4 changes: 3 additions & 1 deletion sci-configs/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
hoplon/javelin {:mvn/version "3.9.3"}

funcool/promesa {:mvn/version "11.0.674"}
; reagent/reagent {:mvn/version "1.1.0"}

reagent/reagent {:mvn/version "1.1.1"} ; https://github.com/reagent-project/reagent
re-frame/re-frame {:mvn/version "1.2.0"}
; re-frame/re-frame {:mvn/version "1.3.0"}

cljs-ajax/cljs-ajax {:mvn/version "0.8.4"} ; needed for re-frame/http-fx
Expand Down
31 changes: 0 additions & 31 deletions src-unused/config/build/css_theme.clj

This file was deleted.

Loading

0 comments on commit 515f40d

Please sign in to comment.