Fix :ref callback bug in adapter-dom — Pretext island fully working

Root cause: adapter-dom.sx line 345 handled :ref by calling
(dict-set! attr-val "current" el), assuming React-style ref objects.
Callback-style refs (fn (el) ...) passed a function, not a dict,
causing dict-set! to fail with "dict key val" error.

Fix: (if (callable? attr-val) (attr-val el) (dict-set! attr-val "current" el))
Supports both callback refs and dict refs.

Pretext island now fully working:
- 3 controls: width slider, font size slider, algorithm toggle
- Knuth-Plass + greedy line breaking via bytecode-compiled library
- canvas.measureText for pixel-perfect browser font metrics
- Effect-based imperative DOM rendering (createElement + appendChild)
- Reactive: slider drag → re-measure → re-break → re-render

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 08:26:48 +00:00
parent e12ddefdff
commit e2fe070dd4
13 changed files with 171 additions and 43 deletions

View File

@@ -1422,6 +1422,21 @@
(let
((end-pos (skip-to-close 0)))
(substring src start-pos end-pos)))))
(define
parse-empty-cmd
(fn
()
(let
((target (cond ((at-end?) (list (quote sym) "me")) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end"))) (list (quote sym) "me")) (true (parse-expr)))))
(list (quote empty-target) target))))
(define
parse-swap-cmd
(fn
()
(let
((lhs (parse-expr)))
(match-kw "with")
(let ((rhs (parse-expr))) (list (quote swap!) lhs rhs)))))
(define
parse-cmd
(fn
@@ -1503,6 +1518,12 @@
(do (adv!) (parse-halt-cmd)))
((and (= typ "keyword") (= val "focus"))
(do (adv!) (parse-focus-cmd)))
((and (= typ "keyword") (= val "empty"))
(do (adv!) (parse-empty-cmd)))
((and (= typ "keyword") (= val "clear"))
(do (adv!) (parse-empty-cmd)))
((and (= typ "keyword") (= val "swap"))
(do (adv!) (parse-swap-cmd)))
(true (parse-expr))))))
(define
parse-cmd-list
@@ -1548,7 +1569,10 @@
(= v "scroll")
(= v "select")
(= v "reset")
(= v "focus"))))
(= v "focus")
(= v "empty")
(= v "clear")
(= v "swap"))))
(define
cl-collect
(fn