|
1 | 1 |
|
2 | 2 | {} (:package |app)
|
3 |
| - :configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) |
| 3 | + :configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) (:version |0.0.1) |
4 | 4 | :modules $ [] |respo.calcit/compact.cirru |lilac/compact.cirru |memof/compact.cirru |respo-ui.calcit/compact.cirru |respo-markdown.calcit/compact.cirru |reel.calcit/compact.cirru
|
5 |
| - :version |0.0.1 |
6 | 5 | :entries $ {}
|
7 | 6 | :files $ {}
|
8 | 7 | |app.comp.container $ {}
|
9 |
| - :ns $ quote |
10 |
| - ns app.comp.container $ :require ([] respo-ui.core :as ui) |
11 |
| - respo.util.format :refer $ hsl |
12 |
| - [] respo.core :refer $ [] defcomp defeffect <> >> div button textarea span input a body img |
13 |
| - [] respo.comp.space :refer $ [] =< |
14 |
| - [] reel.comp.reel :refer $ [] comp-reel |
15 |
| - [] respo-md.comp.md :refer $ [] comp-md comp-md-block |
16 |
| - [] app.config :refer $ [] dev? |
17 |
| - "\"cirru-color" :as cirru-color |
18 | 8 | :defs $ {}
|
| 9 | + |add-link $ quote |
| 10 | + defn add-link (title url) |
| 11 | + a $ {} (:inner-text title) (:href url) (:target "\"_blank") |
| 12 | + |comp-bg $ quote |
| 13 | + defcomp comp-bg () (println "\"@@@@@@@@@@@@@@@@\n@\n@ Well, code is not minified on purpose~\n@\n@ although it's still bundled with Vite.\n@\n@@@@@@@@@@@@@@@@") |
| 14 | + ; img $ {} (:src "\"http://cdn.tiye.me/logo/calcit.png") |
| 15 | + :style $ {} (:width "\"60vw") (:z-index -10) (:min-width "\"480px") (:position :fixed) (:opacity 0.12) (:right 0) (:top "\"10vh") |
| 16 | + div $ {} (:class-name "\"tile") |
| 17 | + :style $ {} (:width "\"100vw") (:height "\"100vh") (:z-index -10) (:position :fixed) (:opacity 0.5) |
19 | 18 | |comp-container $ quote
|
20 | 19 | defcomp comp-container (reel)
|
21 | 20 | let
|
|
50 | 49 | fn (code lang) (cirru-color/generateHtml code)
|
51 | 50 | =< nil 200
|
52 | 51 | when dev? $ comp-reel (>> states :reel) reel ({})
|
53 |
| - |add-link $ quote |
54 |
| - defn add-link (title url) |
55 |
| - a $ {} (:inner-text title) (:href url) (:target "\"_blank") |
56 |
| - |inline-content! $ quote |
57 |
| - defmacro inline-content! (path) (read-file path) |
58 | 52 | |comp-header $ quote
|
59 | 53 | defcomp comp-header () $ div
|
60 | 54 | {} $ :style
|
|
83 | 77 | =< 16 nil
|
84 | 78 | add-link "\"Guidebook" "\"http://repo.calcit-lang.org/guidebook/"
|
85 | 79 | div ({}) (add-link "\"GitHub" "\"https://github.com/calcit-lang/calcit/")
|
| 80 | + |inline-content! $ quote |
| 81 | + defmacro inline-content! (path) (read-file path) |
86 | 82 | |style-content $ quote
|
87 | 83 | def style-content $ {}
|
88 | 84 | |style-middle $ quote
|
89 | 85 | def style-middle $ {} (:margin "\"0 auto") (:max-width 1000) (:padding "\"0 40px")
|
90 |
| - |comp-bg $ quote |
91 |
| - defcomp comp-bg () (println "\"@@@@@@@@@@@@@@@@\n@\n@ Well, code is not minified on purpose~\n@\n@ although it's still bundled with Vite.\n@\n@@@@@@@@@@@@@@@@") |
92 |
| - ; img $ {} (:src "\"http://cdn.tiye.me/logo/calcit.png") |
93 |
| - :style $ {} (:width "\"60vw") (:z-index -10) (:min-width "\"480px") (:position :fixed) (:opacity 0.12) (:right 0) (:top "\"10vh") |
94 |
| - div $ {} (:class-name "\"tile") |
95 |
| - :style $ {} (:width "\"100vw") (:height "\"100vh") (:z-index -10) (:position :fixed) (:opacity 0.5) |
96 |
| - |app.schema $ {} |
97 |
| - :ns $ quote (ns app.schema) |
98 |
| - :defs $ {} |
99 |
| - |store $ quote |
100 |
| - def store $ {} |
101 |
| - :states $ {} |
102 |
| - :cursor $ [] |
103 |
| - |app.updater $ {} |
104 | 86 | :ns $ quote
|
105 |
| - ns app.updater $ :require |
106 |
| - [] respo.cursor :refer $ [] update-states |
| 87 | + ns app.comp.container $ :require ([] respo-ui.core :as ui) |
| 88 | + respo.util.format :refer $ hsl |
| 89 | + [] respo.core :refer $ [] defcomp defeffect <> >> div button textarea span input a body img |
| 90 | + [] respo.comp.space :refer $ [] =< |
| 91 | + [] reel.comp.reel :refer $ [] comp-reel |
| 92 | + [] respo-md.comp.md :refer $ [] comp-md comp-md-block |
| 93 | + [] app.config :refer $ [] dev? |
| 94 | + "\"cirru-color" :as cirru-color |
| 95 | + |app.config $ {} |
107 | 96 | :defs $ {}
|
108 |
| - |updater $ quote |
109 |
| - defn updater (store op data op-id op-time) |
110 |
| - case op |
111 |
| - :states $ update-states store data |
112 |
| - :hydrate-storage data |
113 |
| - op store |
| 97 | + |cdn? $ quote |
| 98 | + def cdn? $ cond |
| 99 | + exists? js/window |
| 100 | + , false |
| 101 | + (exists? js/process) (= "\"true" js/process.env.cdn) |
| 102 | + :else false |
| 103 | + |dev? $ quote (def dev? true) |
| 104 | + |site $ quote |
| 105 | + def site $ {} (:dev-ui "\"http://localhost:8100/main-fonts.css") (:release-ui "\"http://cdn.tiye.me/favored-fonts/main-fonts.css") (:cdn-url "\"http://cdn.tiye.me/calcit-workflow/") (:title "\"Calcit") (:icon "\"http://cdn.tiye.me/logo/mvc-works.png") (:storage-key "\"workflow") |
| 106 | + :ns $ quote (ns app.config) |
114 | 107 | |app.main $ {}
|
115 |
| - :ns $ quote |
116 |
| - ns app.main $ :require |
117 |
| - [] respo.core :refer $ [] render! clear-cache! realize-ssr! |
118 |
| - [] app.comp.container :refer $ [] comp-container |
119 |
| - [] app.updater :refer $ [] updater |
120 |
| - [] app.schema :as schema |
121 |
| - [] reel.util :refer $ [] listen-devtools! |
122 |
| - [] reel.core :refer $ [] reel-updater refresh-reel |
123 |
| - [] reel.schema :as reel-schema |
124 |
| - [] app.config :as config |
125 |
| - "\"./calcit.build-errors" :default build-errors |
126 |
| - "\"bottom-tip" :default hud! |
127 | 108 | :defs $ {}
|
128 |
| - |render-app! $ quote |
129 |
| - defn render-app! () $ render! mount-target (comp-container @*reel) dispatch! |
130 |
| - |persist-storage! $ quote |
131 |
| - defn persist-storage! () $ .setItem js/localStorage (:storage-key config/site) |
132 |
| - js/JSON.stringify $ to-cirru-edn (:store @*reel) |
133 |
| - |mount-target $ quote |
134 |
| - def mount-target $ .querySelector js/document |.app |
135 | 109 | |*reel $ quote
|
136 | 110 | defatom *reel $ -> reel-schema/reel (assoc :base schema/store) (assoc :store schema/store)
|
| 111 | + |dispatch! $ quote |
| 112 | + defn dispatch! (op) |
| 113 | + when |
| 114 | + and config/dev? $ not= (nth op 0) :states |
| 115 | + println "\"Dispatch:" op |
| 116 | + reset! *reel $ reel-updater updater @*reel op |
137 | 117 | |main! $ quote
|
138 | 118 | defn main! ()
|
139 | 119 | println "\"Running mode:" $ if config/dev? "\"dev" "\"release"
|
|
147 | 127 | when (some? raw)
|
148 | 128 | dispatch! :hydrate-storage $ extract-cirru-edn (js/JSON.parse raw)
|
149 | 129 | println "|App started."
|
150 |
| - |snippets $ quote |
151 |
| - defn snippets () $ println config/cdn? |
152 |
| - |dispatch! $ quote |
153 |
| - defn dispatch! (op op-data) |
154 |
| - when |
155 |
| - and config/dev? $ not= op :states |
156 |
| - println "\"Dispatch:" op |
157 |
| - reset! *reel $ reel-updater updater @*reel op op-data |
| 130 | + |mount-target $ quote |
| 131 | + def mount-target $ .querySelector js/document |.app |
| 132 | + |persist-storage! $ quote |
| 133 | + defn persist-storage! () $ .setItem js/localStorage (:storage-key config/site) |
| 134 | + js/JSON.stringify $ to-cirru-edn (:store @*reel) |
158 | 135 | |reload! $ quote
|
159 | 136 | defn reload! () $ if (nil? build-errors)
|
160 | 137 | do (remove-watch *reel :changes) (clear-cache!)
|
161 | 138 | add-watch *reel :changes $ fn (reel prev) (render-app!)
|
162 | 139 | reset! *reel $ refresh-reel @*reel schema/store updater
|
163 | 140 | hud! "\"ok~" "\"Ok"
|
164 | 141 | hud! "\"error" build-errors
|
| 142 | + |render-app! $ quote |
| 143 | + defn render-app! () $ render! mount-target (comp-container @*reel) dispatch! |
165 | 144 | |repeat! $ quote
|
166 | 145 | defn repeat! (duration cb)
|
167 | 146 | js/setTimeout
|
168 | 147 | fn () (cb)
|
169 | 148 | repeat! (* 1000 duration) cb
|
170 | 149 | * 1000 duration
|
171 |
| - |app.config $ {} |
172 |
| - :ns $ quote (ns app.config) |
| 150 | + |snippets $ quote |
| 151 | + defn snippets () $ println config/cdn? |
| 152 | + :ns $ quote |
| 153 | + ns app.main $ :require |
| 154 | + [] respo.core :refer $ [] render! clear-cache! realize-ssr! |
| 155 | + [] app.comp.container :refer $ [] comp-container |
| 156 | + [] app.updater :refer $ [] updater |
| 157 | + [] app.schema :as schema |
| 158 | + [] reel.util :refer $ [] listen-devtools! |
| 159 | + [] reel.core :refer $ [] reel-updater refresh-reel |
| 160 | + [] reel.schema :as reel-schema |
| 161 | + [] app.config :as config |
| 162 | + "\"./calcit.build-errors" :default build-errors |
| 163 | + "\"bottom-tip" :default hud! |
| 164 | + |app.schema $ {} |
173 | 165 | :defs $ {}
|
174 |
| - |cdn? $ quote |
175 |
| - def cdn? $ cond |
176 |
| - exists? js/window |
177 |
| - , false |
178 |
| - (exists? js/process) (= "\"true" js/process.env.cdn) |
179 |
| - :else false |
180 |
| - |dev? $ quote (def dev? true) |
181 |
| - |site $ quote |
182 |
| - def site $ {} (:dev-ui "\"http://localhost:8100/main-fonts.css") (:release-ui "\"http://cdn.tiye.me/favored-fonts/main-fonts.css") (:cdn-url "\"http://cdn.tiye.me/calcit-workflow/") (:title "\"Calcit") (:icon "\"http://cdn.tiye.me/logo/mvc-works.png") (:storage-key "\"workflow") |
| 166 | + |store $ quote |
| 167 | + def store $ {} |
| 168 | + :states $ {} |
| 169 | + :cursor $ [] |
| 170 | + :ns $ quote (ns app.schema) |
| 171 | + |app.updater $ {} |
| 172 | + :defs $ {} |
| 173 | + |updater $ quote |
| 174 | + defn updater (store op op-id op-time) |
| 175 | + tag-match op |
| 176 | + :states cursor s |
| 177 | + update-states store cursor s |
| 178 | + (:hydrate-storage d) d |
| 179 | + _ $ do (eprintln "\"Unknown op:" op) store |
| 180 | + :ns $ quote |
| 181 | + ns app.updater $ :require |
| 182 | + [] respo.cursor :refer $ [] update-states |
0 commit comments