-
Notifications
You must be signed in to change notification settings - Fork 3
/
web_native_index.clj
94 lines (78 loc) · 2.01 KB
/
web_native_index.clj
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
(ns component.web-native-index
(:require [std.lang :as l]
[std.lib :as h]
[std.string :as str]
[net.http :as http]))
(l/script :js
{:runtime :websocket
:config {:bench true
:id :dev/web-main
:emit {:native {:suppress true}
:lang/jsx false}}
:require [[js.core :as j]
[js.react.ext-box :as ext-box]
[js.react :as r]
[js.react-native :as n :include [:fn]]
[js.lib.rn-expo :as x :include [:lib]]
[xt.lang.base-lib :as k]
[xt.lang.base-client :as client]
[xt.lang.event-box :as base-box]
[component.web-native :as web-native]]
:export [MODULE]
:file "App.js"})
(defrun.js __import__
(j/import-missing)
(j/import-set-global))
(defglobal.js Global
(base-box/make-box {:l0 "00a-native-text"}))
(defglobal.js Screens
(base-box/make-box {}))
(defrun.js ^{:rt/init true}
__screen__
(base-box/set-data
-/Screens
[]
(web-native/raw-controls)))
(defn.js AppMain
[]
(var [l0 setL0] (ext-box/useBox -/Global ["l0"]))
(var tree (ext-box/listenBox -/Screens []))
(return
[:% n/View
{:style {:position "absolute",
:top 0,
:bottom 0,
:width "100%"}}
[:% n/TreePane
{:tree tree,
:levels
[{:type "list",
:initial l0,
:setInitial setL0,
:listWidth 120,
:displayFn n/displayTarget}]}]]))
(defrun.js ^{:rt/init true}
__main__
(base-box/set-data -/Global ["Main"] -/AppMain)
(client/client-ws "localhost"
29001
{}))
(defn.js clearScratch
[]
(base-box/del-data -/Global ["Scratch"]))
(defn.js App []
(var #{Main} (ext-box/listenBox -/Global []))
(return [:% Main]))
(def.js MODULE
(x/registerRootComponent -/App))
(comment
(l/rt:restart)
(std.make/build-triggered)
(!.js
(+ 1 2 3))
(!.js
(alert "hello"))
(!.js
(console.log "blah"))
(!.js
(+ 1 2 3)))