Fix HS browser activation: host-get function sentinel, runtime symbol shadow, lazy dep chain

Three bugs fixed:
1. host-get in sx-platform.js: return true for function-valued properties
   so dom-get-attr/dom-set-attr guards pass (functions can't cross WASM boundary)
2. hs-runtime.sx: renamed host-get→hs-host-get and dom-query→hs-dom-query to
   stop shadowing platform natives when loaded as .sx source
3. compile-modules.js: HS dependency chain (integration→runtime→compiler→parser→tokenizer)
   so lazy loading pulls in all deps. Non-library modules load as .sx source
   for CEK env visibility.

Result: 8/8 elements activate, hs-on attaches listeners. Click handler needs
IO suspension support (VmSuspended in sx_browser.ml) to fire — next step.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 20:50:10 +00:00
parent 7f273dc7c2
commit c6df054957
7 changed files with 86 additions and 27 deletions

View File

@@ -49,7 +49,9 @@
;; Toggle a single class on an element.
(define
hs-toggle-class!
(fn (target cls) (host-call (host-get target "classList") "toggle" cls)))
(fn
(target cls)
(host-call (hs-host-get target "classList") "toggle" cls)))
;; Toggle between two classes — exactly one is active at a time.
(define
@@ -136,7 +138,7 @@
(find-prev sibling)))))
;; First element matching selector within a scope.
(define hs-query-first (fn (sel) (dom-query sel)))
(define hs-query-first (fn (sel) (hs-dom-query sel)))
;; Last element matching selector.
(define
@@ -466,9 +468,11 @@
d))))
;; ── Sandbox/test runtime additions ──────────────────────────────
;; Property access — dot notation and .length
(define host-get (fn (obj key) (if (= key "length") (len obj) (get obj key))))
(define
hs-host-get
(fn (obj key) (if (= key "length") (len obj) (get obj key))))
;; DOM query stub — sandbox returns empty list
(define dom-query (fn (selector) (list)))
(define hs-dom-query (fn (selector) (list)))
;; Method dispatch — obj.method(args)
(define hs-method-call (fn (obj method &rest args)
(cond
@@ -488,7 +492,7 @@
;; beep! — debug logging, returns value unchanged
(define hs-beep (fn (v) v))
;; Property-based is — check obj.key truthiness
(define hs-prop-is (fn (obj key) (not (hs-falsy? (host-get obj key)))))
(define hs-prop-is (fn (obj key) (not (hs-falsy? (hs-host-get obj key)))))
;; Array slicing (inclusive both ends)
(define hs-slice (fn (col start end)
(let ((s (if (nil? start) 0 start))