Files
atomsync/bb.edn
Florian Schroedl 86b54e1291 refactor: extract shared .cljc library with store protocol
Move core, sync, and transit from platform-specific .clj/.cljs to
shared .cljc files with reader conditionals. This enables testing
the full sync logic on the JVM and using SyncedAtom from Clojure
clients.

Key changes:
- PStore protocol (store.cljc) decouples core from storage backend
- IDB store (store/idb.cljs) and memory store (store/memory.cljc)
- SyncedAtom implements CLJ IDeref/IAtom/IRef + CLJS equivalents
- Sync client uses java.net.http on CLJ, fetch on CLJS
- SSE remains CLJS-only; JVM clients use polling
- API change: store passed explicitly instead of pb/open
- 7 new JVM tests: local ops, persistence, watches, two-client sync
- 28 tests total, 87 assertions, all passing
2026-04-16 19:42:06 +02:00

39 lines
1.9 KiB
Clojure

{:tasks
{server {:doc "Start the Pocketbook sync server (serves example app)"
:task (shell "clj" "-M:server" "--static-dir" "example/todomvc")}
cljs {:doc "Compile ClojureScript (one-shot)"
:task (shell "clj" "-M:cljs")}
cljs:clean {:doc "Remove compiled CLJS output"
:task (babashka.fs/delete-tree "example/todomvc/js")}
cljs:watch {:doc "Compile ClojureScript (watch mode)"
:depends [cljs:clean]
:task (shell "clj" "-M:cljs-dev")}
test {:doc "Run all server tests"
:task (let [expr (str "(require 'pocketbook.db-test 'pocketbook.transit-test"
" 'pocketbook.server-test 'pocketbook.core-test)"
" (let [r (clojure.test/run-all-tests #\"pocketbook\\..*\")]"
" (System/exit (if (and (zero? (:fail r)) (zero? (:error r))) 0 1)))")]
(shell "clj" "-M:dev" "-e" expr))}
dev {:doc "Start server and CLJS watch in tmux"
:task (let [dir (System/getProperty "user.dir")]
(shell {:dir dir} "tmux new-session -d -s pocketbook-dev -n server -c" dir)
(shell {:dir dir} "tmux send-keys -t pocketbook-dev:server" "bb server" "Enter")
(shell {:dir dir} "tmux new-window -t pocketbook-dev -n cljs -c" dir)
(shell {:dir dir} "tmux send-keys -t pocketbook-dev:cljs" "bb cljs:watch" "Enter")
(println "🔶 tmux session 'pocketbook-dev' started")
(println " App: http://localhost:8090")
(println " Server: http://localhost:8090/sync")
(println " Attach: tmux attach -t pocketbook-dev"))}
dev:stop {:doc "Stop the dev tmux session"
:task (shell "tmux kill-session -t pocketbook-dev")}
dev:restart {:doc "Restart the dev tmux session"
:task (do (shell {:continue true} "tmux kill-session -t pocketbook-dev")
(run 'dev))}}}