Add host FFI primitives and web/lib DOM+browser libraries

Introduce 8 irreducible host FFI primitives that replace 40+ native DOM
and browser primitives:

  host-global    — access global object (window/document)
  host-get       — read property from host object
  host-set!      — write property on host object
  host-call      — call method on host object
  host-new       — construct host object
  host-callback  — wrap SX function as host callback
  host-typeof    — check host object type
  host-await     — await host promise

All DOM and browser operations are now expressible as SX library
functions built on these 8 primitives:

  web/lib/dom.sx     — createElement, querySelector, appendChild,
                        setAttribute, addEventListener, classList, etc.
  web/lib/browser.sx — localStorage, history, fetch, setTimeout,
                        promises, console, matchMedia, etc.

The existing native implementations remain as fallback — the library
versions shadow them in transpiled code. Incremental migration: callers
don't change, only the implementation moves from out-of-band to in-band.

JS 957+1080, Python 744, OCaml 952 — zero regressions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-16 09:22:57 +00:00
parent 4ce4762237
commit 4308591982
4 changed files with 562 additions and 0 deletions

View File

@@ -98,6 +98,17 @@
"*render-check*" "_renderCheck"
"*render-fn*" "_renderFn"
"is-else-clause?" "isElseClause"
"host-global" "hostGlobal"
"host-get" "hostGet"
"host-set!" "hostSet"
"host-call" "hostCall"
"host-new" "hostNew"
"host-callback" "hostCallback"
"host-typeof" "hostTypeof"
"host-await" "hostAwait"
"dom-document" "domDocument"
"dom-window" "domWindow"
"dom-head" "domHead"
"*batch-depth*" "_batchDepth"
"*batch-queue*" "_batchQueue"
"*store-registry*" "_storeRegistry"