Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fulcro config #30

Merged
merged 3 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
.cpcache
cljs-test-runner-out
node_modules
www/js/
.calva/
.portal/
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ Public API:
- `js-interop-namespace`
- `namespaces`

### [com.fulcrologic/fulcro](https://github.com/fulcro/fulcro)

Namespace: `sci.configs.fulcro.fulcro`

Public API:

- `config`
- `namespaces`

### [funcool/promesa](https://github.com/funcool/promesa)

Namespace: `sci.configs.funcool.promesa`
Expand Down Expand Up @@ -141,6 +150,10 @@ New functions added to clojure.core in version 1.11

`npm install` and `bb test`

### Development

You can play with your SCI code and configs in a cljs REPL. In Calva, run Jack-in to a shadow-cljs repl and choose the `:dev` build. Elsewhere, run `bb dev` and then connect to its nrepl at port 9000. Access the web page that Shadow serves at http://localhost:8081/ and then eval your code using `development.cljs`.

## License

The configurations are licensed under the same licenses as the libraries they
Expand Down
5 changes: 4 additions & 1 deletion bb.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{:tasks
{cljs-repl (shell "clj -M:test -m cljs.main -re node")
test (clojure "-M:test:cljs-test-runner")
test:advanced (clojure "-M:test:cljs-test-runner:cljs-test-runner-advanced")}}
test:advanced (clojure "-M:test:cljs-test-runner:cljs-test-runner-advanced")
dev (clojure "-M:test:dev:shadow-cli watch dev")
dev:release (clojure "-M:test:dev:shadow-cli release dev")
dev:release:debug (clojure "-M:test:dev:shadow-cli release dev --debug")}}
6 changes: 5 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{:aliases {:test {:extra-paths ["test"]
{:aliases {:dev {:extra-paths ["dev"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.25.7"}}}
:shadow-cli {:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:test {:extra-paths ["test"]
:extra-deps {org.babashka/sci {:git/url "https://github.com/babashka/sci"
:git/sha "987910fb38fdd166865458c3fd4b468a22fb9992"}
org.clojure/clojurescript {:mvn/version "1.11.51"}
applied-science/js-interop {:mvn/version "0.3.3"}
com.fulcrologic/fulcro {:mvn/version "3.6.10"}
funcool/promesa {:git/url "https://github.com/funcool/promesa"
:git/sha "e503874b154224ce85b223144e80b697df91d18e"}
reagent/reagent {:mvn/version "1.1.0"}
Expand Down
40 changes: 40 additions & 0 deletions dev/development.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
(ns development
"Entry point for code loaded by shadow-cljs"
(:require
[sci.core :as sci]
[sci.configs.fulcro.fulcro :as fulcro-config]))

;; Necessary to avoid the error 'Attempting to call unbound fn: #'clojure.core/*print-fn*'
;; when calling `println` inside the evaluated code
(enable-console-print!)
(sci/alter-var-root sci/print-fn (constantly *print-fn*))
(sci/alter-var-root sci/print-err-fn (constantly *print-err-fn*))

(def full-ctx (doto (sci/init {})
(sci/merge-opts fulcro-config/config)))

(defn init []
(println "Init run"))

(defn reload []
(println "Reload run"))

(comment
(sci/eval-string* (sci/init {}) "(+ 1 2)")

(sci/eval-string* full-ctx "
(ns test1
(:require
[com.fulcrologic.fulcro.algorithms.denormalize :as fdn]
[com.fulcrologic.fulcro.application :as app]
[com.fulcrologic.fulcro.components :as comp :refer [defsc]]
[com.fulcrologic.fulcro.dom :as dom]))

(defsc Root [this props] (dom/h3 \"Hello from Fulcro!\"))
(defn build-ui-tree []
(let [client-db (comp/get-initial-state Root {})]
(fdn/db->tree (comp/get-query Root client-db) client-db client-db)))
(comp/with-parent-context (app/fulcro-app)
(dom/render-to-str ((comp/factory Root) (build-ui-tree))))
")
,)
12 changes: 12 additions & 0 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{:deps {:aliases [:test :dev]}
:nrepl {:port 9000}
:dev-http {8081 "www"}
:builds {:dev {:compiler-options {:output-feature-set :es8
:optimizations :advanced
:source-map true
:output-wrapper false}
:target :browser
:output-dir "www/js/dev"
:asset-path "/js/dev"
:modules {:dev {:init-fn development/init}}
:devtools {:after-load development/reload}}}}
8 changes: 8 additions & 0 deletions src/sci/configs/fulcro/algorithms/data_targeting.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns sci.configs.fulcro.algorithms.data-targeting
(:require [sci.core :as sci]
[com.fulcrologic.fulcro.algorithms.data-targeting]))

(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.data-targeting))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.algorithms.data-targeting sci-ns))

(def namespaces {'com.fulcrologic.fulcro.algorithms.data-targeting ns-def})
9 changes: 9 additions & 0 deletions src/sci/configs/fulcro/algorithms/denormalize.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns sci.configs.fulcro.algorithms.denormalize
(:require
[sci.core :as sci]
com.fulcrologic.fulcro.algorithms.denormalize))

(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.denormalize))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.algorithms.denormalize sci-ns))

(def namespaces {'com.fulcrologic.fulcro.algorithms.denormalize ns-def})
8 changes: 8 additions & 0 deletions src/sci/configs/fulcro/algorithms/form_state.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns sci.configs.fulcro.algorithms.form-state
(:require [sci.core :as sci]
com.fulcrologic.fulcro.algorithms.form-state))

(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.form-state))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.algorithms.form-state sci-ns))

(def namespaces {'com.fulcrologic.fulcro.algorithms.form-state ns-def})
9 changes: 9 additions & 0 deletions src/sci/configs/fulcro/algorithms/lookup.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns sci.configs.fulcro.algorithms.lookup
(:require [sci.core :as sci]
com.fulcrologic.fulcro.algorithms.lookup))


(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.lookup))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.algorithms.lookup sci-ns))

(def namespaces {'com.fulcrologic.fulcro.algorithms.lookup ns-def})
9 changes: 9 additions & 0 deletions src/sci/configs/fulcro/algorithms/merge.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns sci.configs.fulcro.algorithms.merge
(:require
[sci.core :as sci]
com.fulcrologic.fulcro.algorithms.merge))

(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.merge))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.algorithms.merge sci-ns))

(def namespaces {'com.fulcrologic.fulcro.algorithms.merge ns-def})
9 changes: 9 additions & 0 deletions src/sci/configs/fulcro/algorithms/normalize.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns sci.configs.fulcro.algorithms.normalize
(:require [sci.core :as sci]
com.fulcrologic.fulcro.algorithms.normalize))


(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.normalize))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.algorithms.normalize sci-ns))

(def namespaces {'com.fulcrologic.fulcro.algorithms.normalize ns-def})
8 changes: 8 additions & 0 deletions src/sci/configs/fulcro/algorithms/react_interop.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns sci.configs.fulcro.algorithms.react-interop
(:require [sci.core :as sci]
com.fulcrologic.fulcro.algorithms.react-interop))

(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.react-interop))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.algorithms.react-interop sci-ns))

(def namespaces {'com.fulcrologic.fulcro.algorithms.react-interop ns-def})
8 changes: 8 additions & 0 deletions src/sci/configs/fulcro/algorithms/tempid.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns sci.configs.fulcro.algorithms.tempid
(:require [sci.core :as sci]
com.fulcrologic.fulcro.algorithms.tempid))

(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.tempid))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.algorithms.tempid sci-ns))

(def namespaces {'com.fulcrologic.fulcro.algorithms.tempid ns-def})
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(ns sci.configs.fulcro.algorithms.tx-processing.synchronous-tx-processing
(:require [sci.core :as sci]
[com.fulcrologic.fulcro.algorithms.tx-processing.synchronous-tx-processing :as stx]))

(defn ^:sci/macro in-transaction [_&form _&env app-sym & body]
`(let [id# (:com.fulcrologic.fulcro.application/id ~app-sym)]
(swap! stx/apps-in-tx update id# conj (stx/current-thread-id))
(try
~@body
(finally
(swap! apps-in-tx update id# pop)))))

(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.algorithms.tx-processing.synchronous-tx-processing))
(def ns-def (assoc (sci/copy-ns com.fulcrologic.fulcro.algorithms.tx-processing.synchronous-tx-processing sci-ns
{:exclude [in-transaction]})
'in-transaction (sci/copy-var in-transaction sci-ns)))

(def namespaces {'com.fulcrologic.fulcro.algorithms.tx-processing.synchronous-tx-processing ns-def})
9 changes: 9 additions & 0 deletions src/sci/configs/fulcro/application.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns sci.configs.fulcro.application
(:require
[sci.core :as sci]
[com.fulcrologic.fulcro.application]))

(def sci-ns (sci/create-ns 'com.fulcrologic.fulcro.application))
(def ns-def (sci/copy-ns com.fulcrologic.fulcro.application sci-ns))

(def namespaces {'com.fulcrologic.fulcro.application ns-def})
Loading