dom.sx and browser.sx are library source (not transpiled into the bundle), so their functions need explicit PRIMITIVES registration for runtime-eval'd SX code (islands, data-init scripts). Restore registrations for all dom/ browser functions used at runtime. Revert bootstrap.py transpilation of dom-lib/browser-lib which overrode native platform implementations that have essential runtime integration (cekCall wrapping, post-render hooks). Add Playwright regression test for [object Object] nav link issue. Replace console-log calls with log-info in init-client.sx.txt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
44 lines
2.0 KiB
Plaintext
44 lines
2.0 KiB
Plaintext
;; ---------------------------------------------------------------------------
|
|
;; SX app boot — styles, behaviors, and post-render hooks
|
|
;;
|
|
;; Replaces inline_css and init_sx from Python app config.
|
|
;; Called as a data-init script on every page.
|
|
;; ---------------------------------------------------------------------------
|
|
|
|
;; Framework styles — request indicators + link jiggle
|
|
(collect! "cssx" ".sx-indicator{display:none}")
|
|
(collect! "cssx" ".sx-request .sx-indicator{display:inline-flex}")
|
|
(collect! "cssx" "@keyframes sxJiggle{0%,100%{transform:translateX(0)}25%{transform:translateX(-.5px)}75%{transform:translateX(.5px)}}")
|
|
(collect! "cssx" "a.sx-request{animation:sxJiggle .3s ease-in-out infinite}")
|
|
|
|
;; CSSX flush hook — inject collected CSS rules into a <style> tag.
|
|
;; The spec calls (run-post-render-hooks) after hydration/swap/mount.
|
|
;; This is the application's CSS injection strategy.
|
|
(log-info (str "init-client: registering cssx flush hook, type:" (type-of (fn () nil))))
|
|
(register-post-render-hook
|
|
(fn ()
|
|
(log-info (str "cssx flush: running, rules:" (len (collected "cssx"))))
|
|
(let ((rules (collected "cssx")))
|
|
(when (not (empty? rules))
|
|
(let ((style (or (dom-query "[data-cssx]")
|
|
(let ((s (dom-create-element "style" nil)))
|
|
(dom-set-attr s "data-cssx" "")
|
|
(dom-append-to-head s)
|
|
s))))
|
|
(dom-set-prop style "textContent"
|
|
(str (or (dom-get-prop style "textContent") "")
|
|
(join "" rules))))
|
|
(clear-collected! "cssx")))))
|
|
|
|
;; Nav link aria-selected update on client-side routing
|
|
(dom-listen (dom-body) "sx:clientRoute"
|
|
(fn (e)
|
|
(let ((p (get (event-detail e) "pathname")))
|
|
(when p
|
|
(for-each
|
|
(fn (a) (dom-set-attr a "aria-selected" "false"))
|
|
(dom-query-all "nav a[aria-selected]"))
|
|
(for-each
|
|
(fn (a) (dom-set-attr a "aria-selected" "true"))
|
|
(dom-query-all (str "nav a[href=\"" p "\"]")))))))
|