sx-http: island SSR → always placeholder, external component-defs endpoint
Islands now always emit <span data-sx-island="name"> placeholder instead of attempting SSR. Island bodies contain client-only symbols (signals, DOM refs) that cascade errors during native render. Component-defs moved to /static/sx-components.sx endpoint instead of inline <script> — avoids </script> escaping issues that broke the client-side SX parser. Remaining: client WASM kernel not loading components from external endpoint (expects inline script tag). Need to configure client boot to fetch from /static/sx-components.sx. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -258,21 +258,8 @@ and render_list_to_html head args env =
|
||||
| Component c when c.c_affinity = "client" -> "" (* skip client-only *)
|
||||
| Component _ -> render_component v args env
|
||||
| Island _i ->
|
||||
(* Islands: try SSR via the SX render-to-html from adapter-html.sx.
|
||||
It handles deref/signal/computed through the CEK correctly,
|
||||
and renders island bodies with hydration markers.
|
||||
On failure, emit a placeholder — client hydrates from SX source. *)
|
||||
(try
|
||||
let call_expr = List (Symbol name :: args) in
|
||||
let quoted = List [Symbol "quote"; call_expr] in
|
||||
let render_call = List [Symbol "render-to-html"; quoted; Env env] in
|
||||
let result = Sx_ref.eval_expr render_call (Env env) in
|
||||
(match result with
|
||||
| String s | RawHTML s -> s
|
||||
| _ -> value_to_string result)
|
||||
with _e ->
|
||||
(* Placeholder — client will hydrate this island *)
|
||||
Printf.sprintf "<span data-sx-island=\"%s\"></span>" _i.i_name)
|
||||
(* Islands are client-rendered — emit placeholder for hydration *)
|
||||
Printf.sprintf "<span data-sx-island=\"%s\"></span>" _i.i_name
|
||||
| Macro m ->
|
||||
let expanded = expand_macro m args env in
|
||||
do_render_to_html expanded env
|
||||
@@ -516,16 +503,10 @@ and render_list_buf buf head args env =
|
||||
| Component c when c.c_affinity = "client" -> ()
|
||||
| Component _ -> render_component_buf buf v args env
|
||||
| Island _i ->
|
||||
(try
|
||||
let call_expr = List (Symbol name :: args) in
|
||||
let quoted = List [Symbol "quote"; call_expr] in
|
||||
let render_call = List [Symbol "render-to-html"; quoted; Env env] in
|
||||
let result = Sx_ref.eval_expr render_call (Env env) in
|
||||
(match result with
|
||||
| String s | RawHTML s -> Buffer.add_string buf s
|
||||
| _ -> Buffer.add_string buf (value_to_string result))
|
||||
with _e ->
|
||||
Buffer.add_string buf (Printf.sprintf "<span data-sx-island=\"%s\"></span>" _i.i_name))
|
||||
(* Islands are client-rendered — emit placeholder for hydration.
|
||||
SSR of island bodies is unreliable (client-only symbols like
|
||||
signals, DOM refs) and can cascade errors. *)
|
||||
Buffer.add_string buf (Printf.sprintf "<span data-sx-island=\"%s\"></span>" _i.i_name)
|
||||
| Macro m ->
|
||||
let expanded = expand_macro m args env in
|
||||
render_to_buf buf expanded env
|
||||
|
||||
Reference in New Issue
Block a user