-
Notifications
You must be signed in to change notification settings - Fork 0
/
compact.cirru
114 lines (113 loc) · 4.91 KB
/
compact.cirru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{} (:package |app)
:configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) (:version |0.4.10)
:modules $ [] |memof/ |lilac/ |respo.calcit/ |respo-ui.calcit/ |phlox/ |touch-control/
:entries $ {}
:files $ {}
|app.comp.container $ %{} :FileEntry
:defs $ {}
|comp-container $ %{} :CodeEntry (:doc |)
:code $ quote
defn comp-container (store)
; println "\"Store" store $ :tab store
let
cursor $ []
states $ :states store
container ({})
text $ {} (:text "\"DEMO")
:position $ [] 100 100
:style $ {}
:fill $ hslx 0 0 80
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.container $ :require
phlox.core :refer $ g hslx rect circle text container graphics create-list >>
phlox.comp.button :refer $ comp-button
phlox.comp.drag-point :refer $ comp-drag-point
respo-ui.core :as ui
memof.alias :refer $ memof-call
|app.config $ %{} :FileEntry
:defs $ {}
|site $ %{} :CodeEntry (:doc |)
:code $ quote
def site $ {} (:dev-ui "\"http://localhost:8100/main.css") (:release-ui "\"http://cdn.tiye.me/favored-fonts/main.css") (:cdn-url "\"http://cdn.tiye.me/phlox/") (:title "\"Phlox") (:icon "\"http://cdn.tiye.me/logo/quamolit.png") (:storage-key "\"phlox")
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.config $ :require ("\"mobile-detect" :default mobile-detect)
|app.main $ %{} :FileEntry
:defs $ {}
|*store $ %{} :CodeEntry (:doc |)
:code $ quote (defatom *store schema/store)
|dispatch! $ %{} :CodeEntry (:doc |)
:code $ quote
defn dispatch! (op)
when
and dev? $ not= (nth op 0) :states
js/console.log "\"dispatch!" op
let
op-id $ nanoid
op-time $ js/Date.now
reset! *store $ updater @*store op op-id op-time
|main! $ %{} :CodeEntry (:doc |)
:code $ quote
defn main! () (; js/console.log PIXI)
if dev? $ load-console-formatter!
-> (new FontFaceObserver "\"Josefin Sans") (.!load)
.!then $ fn (event) (render-app!)
add-watch *store :change $ fn (store prev) (render-app!)
render-control!
start-control-loop! 8 on-control-event
println "\"App Started"
|reload! $ %{} :CodeEntry (:doc |)
:code $ quote
defn reload! () $ if (nil? build-errors)
do (clear-phlox-caches!) (remove-watch *store :change)
add-watch *store :change $ fn (store prev) (render-app!)
render-app!
replace-control-loop! 8 on-control-event
hud! "\"ok~" "\"Ok"
hud! "\"error" build-errors
|render-app! $ %{} :CodeEntry (:doc |)
:code $ quote
defn render-app! (? arg)
render! (comp-container @*store) dispatch! $ or arg ({})
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.main $ :require ("\"pixi.js" :as PIXI)
phlox.core :refer $ render! clear-phlox-caches! update-viewer! on-control-event
app.comp.container :refer $ comp-container
app.schema :as schema
phlox.config :refer $ dev? mobile?
"\"nanoid" :refer $ nanoid
app.updater :refer $ updater
"\"fontfaceobserver-es" :default FontFaceObserver
"\"./calcit.build-errors" :default build-errors
"\"bottom-tip" :default hud!
touch-control.core :refer $ render-control! start-control-loop! replace-control-loop!
|app.schema $ %{} :FileEntry
:defs $ {}
|store $ %{} :CodeEntry (:doc |)
:code $ quote
def store $ {} (:tab :drafts) (:x 0) (:keyboard-on? false) (:counted 0)
:states $ {}
:cursor $ []
:ns $ %{} :CodeEntry (:doc |)
:code $ quote (ns app.schema)
|app.updater $ %{} :FileEntry
:defs $ {}
|updater $ %{} :CodeEntry (:doc |)
:code $ quote
defn updater (store op op-id op-time)
tag-match op
:add-x
update store :x $ fn (x)
if (> x 10) 0 $ + x 1
(:tab t) (assoc store :tab t)
(:toggle-keyboard) (update store :keyboard-on? not)
(:counted) (update store :counted inc)
(:states cursor s) (update-states store cursor s)
(:hydrate-storage d) d
_ $ do (eprintln "\"unknown op" op) store
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.updater $ :require
[] phlox.cursor :refer $ [] update-states