Hyperscript conformance: 372→373 — hide/show strategy, generator toEqual

Parser: hide/show handle `with opacity/visibility/display` strategy,
target detection for then-less chaining (add/remove/set/put as boundary).
Generator: inline run().toEqual([...]) pattern for eval-only tests.
Compiler: hide/show emit correct CSS property per strategy.

373/831 (45%)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-12 11:42:28 +00:00
parent 3dbbe7e1d1
commit 854ed9c027
24 changed files with 1665 additions and 469 deletions

View File

@@ -360,6 +360,25 @@ and cek_run_with_io state =
(Sx_runtime.value_to_str lib_spec));
Nil
end
| "text-measure" ->
(* Resolve locally — monospace approximation *)
let args = let a = Sx_runtime.get_val request (String "args") in
(match a with List l -> l | _ -> [a]) in
let size = match args with
| [_font; Number sz; _text] -> sz
| [_font; Number sz] -> sz
| _ -> 16.0 in
let text = match args with
| [_font; _sz; String t] -> t
| _ -> "" in
let char_width = size *. 0.6 in
let width = char_width *. (float_of_int (String.length text)) in
let d = Hashtbl.create 4 in
Hashtbl.replace d "width" (Number width);
Hashtbl.replace d "height" (Number size);
Hashtbl.replace d "ascent" (Number (size *. 0.8));
Hashtbl.replace d "descent" (Number (size *. 0.2));
Dict d
| _ ->
let args = let a = Sx_runtime.get_val request (String "args") in
(match a with List l -> l | _ -> [a]) in
@@ -1014,7 +1033,9 @@ let rec dispatch env cmd =
ignore (Sx_types.env_bind env "*current-file*" (String path));
let count = ref 0 in
List.iter (fun expr ->
ignore (eval_expr_io expr (Env env));
(try ignore (eval_expr_io expr (Env env))
with Eval_error msg ->
Printf.eprintf "[load] %s: %s\n%!" (Filename.basename path) msg);
incr count
) exprs;
(* Rebind host extension points after .sx load — evaluator.sx
@@ -1994,6 +2015,26 @@ let eval_with_io expr env =
ignore lib_name; (* import handled by _import_hook if registered *)
Nil
with _ -> Nil)
| "text-measure" ->
(* Pretext: server-side text measurement (monospace approximation).
Real otfm font-table parsing can replace this later. *)
let size = match args with
| List [_font; Number sz; _text] -> sz
| List [_font; Number sz] -> sz
| _ -> 16.0 in
let text = match args with
| List [_font; _sz; String t] -> t
| _ -> "" in
let char_width = size *. 0.6 in
let width = char_width *. (float_of_int (String.length text)) in
let ascent = size *. 0.8 in
let descent = size *. 0.2 in
let d = Hashtbl.create 4 in
Hashtbl.replace d "width" (Number width);
Hashtbl.replace d "height" (Number size);
Hashtbl.replace d "ascent" (Number ascent);
Hashtbl.replace d "descent" (Number descent);
Dict d
| _ ->
Printf.eprintf "[io] unhandled IO op: %s\n%!" op;
Nil