From 1723808517bcef0dca2652b5672aacdf37bfec50 Mon Sep 17 00:00:00 2001 From: giles Date: Mon, 27 Apr 2026 05:18:38 +0000 Subject: [PATCH] HS: viewTransition command (+9 tests) Add 'start view transition [using EXPR] [then] BODY end' syntax. - tokenizer: add 'view' as a keyword - parser: add 'start' to cmd-kw? and dispatch to view-transition! AST node - compiler: emit hs-view-transition! call from view-transition! node Co-Authored-By: Claude Sonnet 4.6 --- lib/hyperscript/compiler.sx | 3 +++ lib/hyperscript/parser.sx | 13 ++++++++++++- lib/hyperscript/tokenizer.sx | 1 + shared/static/wasm/sx/hs-compiler.sx | 3 +++ shared/static/wasm/sx/hs-parser.sx | 13 ++++++++++++- shared/static/wasm/sx/hs-tokenizer.sx | 1 + 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/hyperscript/compiler.sx b/lib/hyperscript/compiler.sx index cf5aad15..05504731 100644 --- a/lib/hyperscript/compiler.sx +++ b/lib/hyperscript/compiler.sx @@ -1832,6 +1832,9 @@ (hs-to-sx (nth ast 2)))) ((= head (quote set-el!)) (list (quote hs-set-element!) (hs-to-sx (nth ast 1)) (hs-to-sx (nth ast 2)))) + ((= head (quote view-transition!)) + (let ((body (nth ast 2))) + (list (quote hs-view-transition!) (hs-to-sx (nth ast 1)) (if (nil? body) (quote nil) (hs-to-sx body))))) ((= head (quote put!)) (let ((val (hs-to-sx (nth ast 1))) diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index dc70ed29..0f631c2b 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -2711,6 +2711,16 @@ (do (adv!) (list (quote exit)))) ((and (= typ "keyword") (= val "js")) (do (adv!) (parse-js-block))) + ((and (= typ "keyword") (= val "start")) + (do + (adv!) + (expect-kw! "view") + (expect-kw! "transition") + (let ((using (if (match-kw "using") (parse-expr) nil))) + (match-kw "then") + (let ((body (parse-cmd-list))) + (match-kw "end") + (list (quote view-transition!) using body))))) (true (parse-expr)))))) (define parse-cmd-list @@ -2767,7 +2777,8 @@ (= v "pick") (= v "ask") (= v "answer") - (= v "js")))) + (= v "js") + (= v "start")))) (define cl-collect (fn diff --git a/lib/hyperscript/tokenizer.sx b/lib/hyperscript/tokenizer.sx index 8b3a6a80..02255e1a 100644 --- a/lib/hyperscript/tokenizer.sx +++ b/lib/hyperscript/tokenizer.sx @@ -131,6 +131,7 @@ "append" "settle" "transition" + "view" "over" "closest" "next" diff --git a/shared/static/wasm/sx/hs-compiler.sx b/shared/static/wasm/sx/hs-compiler.sx index cf5aad15..05504731 100644 --- a/shared/static/wasm/sx/hs-compiler.sx +++ b/shared/static/wasm/sx/hs-compiler.sx @@ -1832,6 +1832,9 @@ (hs-to-sx (nth ast 2)))) ((= head (quote set-el!)) (list (quote hs-set-element!) (hs-to-sx (nth ast 1)) (hs-to-sx (nth ast 2)))) + ((= head (quote view-transition!)) + (let ((body (nth ast 2))) + (list (quote hs-view-transition!) (hs-to-sx (nth ast 1)) (if (nil? body) (quote nil) (hs-to-sx body))))) ((= head (quote put!)) (let ((val (hs-to-sx (nth ast 1))) diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index dc70ed29..0f631c2b 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -2711,6 +2711,16 @@ (do (adv!) (list (quote exit)))) ((and (= typ "keyword") (= val "js")) (do (adv!) (parse-js-block))) + ((and (= typ "keyword") (= val "start")) + (do + (adv!) + (expect-kw! "view") + (expect-kw! "transition") + (let ((using (if (match-kw "using") (parse-expr) nil))) + (match-kw "then") + (let ((body (parse-cmd-list))) + (match-kw "end") + (list (quote view-transition!) using body))))) (true (parse-expr)))))) (define parse-cmd-list @@ -2767,7 +2777,8 @@ (= v "pick") (= v "ask") (= v "answer") - (= v "js")))) + (= v "js") + (= v "start")))) (define cl-collect (fn diff --git a/shared/static/wasm/sx/hs-tokenizer.sx b/shared/static/wasm/sx/hs-tokenizer.sx index 8b3a6a80..02255e1a 100644 --- a/shared/static/wasm/sx/hs-tokenizer.sx +++ b/shared/static/wasm/sx/hs-tokenizer.sx @@ -131,6 +131,7 @@ "append" "settle" "transition" + "view" "over" "closest" "next"