Isomorphic SSR: server renders HTML body, client takes over with SX
Server now renders page content as HTML inside <div id="sx-root">, visible immediately before JavaScript loads. The SX source is still included in a <script data-mount="#sx-root"> tag for client hydration. SSR pipeline: after aser produces the SX wire format, parse and render-to-html it (~17ms for a 22KB page). Islands with reactive state gracefully fall back to empty — client hydrates them. Supporting changes: - Load signals.sx into OCaml kernel (reactive primitives for island SSR) - Add cek-call and context to kernel env (needed by signals/deref) - Island-aware component accessors in sx_types.ml - render-to-html handles Island values (renders as component with fallback) - Fix 431 (Request Header Fields Too Large): replace SX-Components header (full component name list) with SX-Components-Hash (12 chars) - CORS allow SX-Components-Hash header Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -125,10 +125,14 @@
|
||||
(when target-sel
|
||||
(dict-set! headers "SX-Target" target-sel)))
|
||||
|
||||
;; Loaded component names
|
||||
(when (not (empty? loaded-components))
|
||||
(dict-set! headers "SX-Components"
|
||||
(join "," loaded-components)))
|
||||
;; Send component hash instead of full name list to avoid 431
|
||||
;; (Request Header Fields Too Large) with many loaded components.
|
||||
;; Server uses hash to decide whether to send component definitions.
|
||||
(let ((comp-hash (dom-get-attr
|
||||
(dom-query "script[data-components][data-hash]")
|
||||
"data-hash")))
|
||||
(when comp-hash
|
||||
(dict-set! headers "SX-Components-Hash" comp-hash)))
|
||||
|
||||
;; CSS class hash
|
||||
(when css-hash
|
||||
|
||||
Reference in New Issue
Block a user