|
26 | 26 | (fn [props] |
27 | 27 | (let [rsc-props (aget props "rsc/props") |
28 | 28 | rsc-refs (aget props "rsc/refs") |
| 29 | + children (aget props "children") |
29 | 30 | props (uix/use-memo |
30 | | - #(walk/postwalk |
31 | | - (fn [form] |
32 | | - ;; todo: maybe use data readers? |
33 | | - (cond |
34 | | - (and (string? form) |
35 | | - (.startsWith form "$") |
36 | | - rsc-refs) |
37 | | - (let [ref (aget rsc-refs form)] |
38 | | - (when ^boolean goog/DEBUG |
39 | | - (when (nil? ref) |
40 | | - (js/console.error "server reference " ref " is not registered"))) |
41 | | - ref) |
42 | | - |
43 | | - :else form)) |
44 | | - (edn/read-string rsc-props)) |
45 | | - [rsc-props rsc-refs])] |
| 31 | + #(let [{:uix/keys [context] :as edn-props} (edn/read-string rsc-props) |
| 32 | + edn-props (walk/postwalk |
| 33 | + (fn [form] |
| 34 | + ;; todo: maybe use data readers? |
| 35 | + (cond |
| 36 | + (and (string? form) |
| 37 | + (.startsWith form "$") |
| 38 | + rsc-refs) |
| 39 | + (let [ref (aget rsc-refs form)] |
| 40 | + (when ^boolean goog/DEBUG |
| 41 | + (when (nil? ref) |
| 42 | + (js/console.error "server reference " ref " is not registered"))) |
| 43 | + ref) |
| 44 | + |
| 45 | + :else form)) |
| 46 | + (dissoc edn-props :uix/context))] |
| 47 | + (if (and context children) |
| 48 | + (assoc edn-props :children children :uix/context context) |
| 49 | + edn-props)) |
| 50 | + [rsc-props rsc-refs children])] |
46 | 51 | (uix.core/$ uix-comp props))))) |
47 | 52 |
|
48 | 53 | #?(:cljs |
|
170 | 175 | :margin-bottom 24}} |
171 | 176 | (.-message error)) |
172 | 177 | (let [{:keys [src line start-line frame-line name]} |
173 | | - (bean/bean (or js/window.__ERROR_SRC (.-digest error)))] |
| 178 | + (bean/bean (or js/window.__ERROR_SRC (.-digest error) #js {}))] |
174 | 179 | ($ :<> |
175 | 180 | ($ :div {:style {:font-size 12 |
176 | 181 | :color "#5a5a5a"}} |
177 | 182 | name) |
178 | | - ($ :pre {:style {:font-size 12 |
179 | | - :max-height 360 |
180 | | - :overflow-y :auto |
181 | | - :background-color "rgba(206, 17, 38, 0.05)" |
182 | | - :margin "16px 0" |
183 | | - :padding "8px 0" |
184 | | - :border-radius 5}} |
185 | | - ($ :code |
186 | | - (->> (str/split-lines src) |
187 | | - (map-indexed (fn [idx ln] |
188 | | - (if (= idx line) |
189 | | - ($ :div {:key idx |
190 | | - :style {:background-color "#ff000047" |
191 | | - :padding "0 8px"}} |
192 | | - (str (+ start-line idx) " ") |
193 | | - ln) |
194 | | - ($ :div {:key idx |
195 | | - :style {:padding "0 8px"}} |
196 | | - (str (+ start-line idx) " ") |
197 | | - ln))))))) |
| 183 | + (when src |
| 184 | + ($ :pre {:style {:font-size 12 |
| 185 | + :max-height 360 |
| 186 | + :overflow-y :auto |
| 187 | + :background-color "rgba(206, 17, 38, 0.05)" |
| 188 | + :margin "16px 0" |
| 189 | + :padding "8px 0" |
| 190 | + :border-radius 5}} |
| 191 | + ($ :code |
| 192 | + (->> (str/split-lines src) |
| 193 | + (map-indexed (fn [idx ln] |
| 194 | + (if (= idx line) |
| 195 | + ($ :div {:key idx |
| 196 | + :style {:background-color "#ff000047" |
| 197 | + :padding "0 8px"}} |
| 198 | + (str (+ start-line idx) " ") |
| 199 | + ln) |
| 200 | + ($ :div {:key idx |
| 201 | + :style {:padding "0 8px"}} |
| 202 | + (str (+ start-line idx) " ") |
| 203 | + ln)))))))) |
198 | 204 | ($ :pre {:style {:font-size 12 |
199 | 205 | :max-height 360 |
200 | 206 | :overflow-y :auto |
|
0 commit comments