diff --git a/hosts/ocaml/bin/sx_server.ml b/hosts/ocaml/bin/sx_server.ml index 4689590..daa4b4b 100644 --- a/hosts/ocaml/bin/sx_server.ml +++ b/hosts/ocaml/bin/sx_server.ml @@ -184,6 +184,16 @@ let () = Sx_primitives.register "collected" (fun args -> (match stack with List items :: _ -> List items | _ -> List []) | _ -> List []) +let () = Sx_primitives.register "clear-collected!" (fun args -> + match args with + | [String name] -> + let stack = try Hashtbl.find _scope_stacks name with Not_found -> [] in + (match stack with + | _ :: rest -> Hashtbl.replace _scope_stacks name (List [] :: rest) + | [] -> Hashtbl.replace _scope_stacks name [List []]); + Nil + | _ -> Nil) + let () = Sx_primitives.register "scope-emit!" (fun args -> match args with | [String name; value] -> diff --git a/shared/sx/templates/shell.sx b/shared/sx/templates/shell.sx index 3b0c406..daf0f93 100644 --- a/shared/sx/templates/shell.sx +++ b/shared/sx/templates/shell.sx @@ -68,6 +68,8 @@ details.group{overflow:hidden}details.group>summary{list-style:none}details.grou (body :class "bg-stone-50 text-stone-900" ;; Server-rendered HTML — visible immediately before JS loads (div :id "sx-root" (raw! (or body-html ""))) + ;; Flush CSSX rules collected during island SSR + (~cssx/flush) (script :type "text/sx" :data-components true :data-hash component-hash (raw! (or component-defs ""))) (when init-sx