Add `_hs-config-log-all` runtime flag + captured log list. When set
via `hs-set-log-all!`, `hs-activate!` pushes "hyperscript:init" onto
`_hs-log-captured` and mirrors to console.log. Covers cluster 30.
Generator side: eval-only path now detects the logAll body pattern
(`_hyperscript.config.logAll = true`) and emits a deftest that:
- resets captured list
- toggles log-all on
- builds a div with `_="on click add .foo"` and `hs-boot-subtree!`s
- asserts `(some string-contains? "hyperscript:")` over captured logs.
hs-upstream-core/bootstrap: 19/26 -> 20/26. Smoke 0-195: 164 -> 165.
parse-trav recognises `parent` as an ident modifier after the
`closest` keyword — consumes it and re-invokes with kind
`closest-parent`, producing AST `(closest-parent "div" (me))` instead
of the generic trailing-ident-as-unit shape
`(string-postfix (closest "*" (me)) "parent")`.
Compiler translates `(closest-parent sel target)` to
`(dom-closest (host-get target "parentElement") sel)` so `me` is
skipped and only strict ancestors match. `closest-parent` also
joined the `put X into <trav>` inner-html shortcut alongside
next/previous/closest.
Suite hs-upstream-core/regressions: 10/16 → 11/16.
Smoke 0-195: 162/195 → 163/195.
Runtime gains hs-get-selection: prefers window.__test_selection stash,
falls back to real getSelection().toString(). Compiler rewrites
`(ref "selection")` to `(hs-get-selection)`. Generator detects the
createRange + setStart/setEnd + addRange block and emits a single
host-set! on __test_selection with the text slice; sidesteps the need
for a fully propagating DOM range/text-node mock.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`hs-on` now wraps each event handler in a `guard` that catches thrown
exceptions and re-dispatches them as an `exception` DOM event on the
same target with `{error: e}` as detail. The `on exception(error)`
handler, registered the same way, receives the event and destructures
`error` from the detail. Wrapping skips `exception`/`error` event
handlers to avoid infinite loops — those bubble out as before.
Suite hs-upstream-throw: 5/7 → 7/7. Smoke 0-195: 162/195 unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three parts: (a) parser `collect-transitions` recognises `style`
tokens (`*prop`) as a continuation, so
`transition *width from A to B *height from A to B` chains both
transitions instead of dropping the second. (b) Mock `El` class gets
`nextSibling`/`previousSibling` (plus `*ElementSibling` aliases) so
`transition *W of the next <span/>` can resolve the next-sibling
target via host-get. (c) Generator pattern for
`const X = await evaluate(() => { const el = document.querySelector(SEL);
el.dispatchEvent(new Event(NAME, ...)); return ... })`; optionally
prefixed by a destructuring assignment and allowing trailing
`expect(...).toBe(...)` junk because `_body_statements` only splits on
`;` at depth 0.
Remaining `can use initial to transition to original value` needs
`on click N` count-filtered events (same mock-sync block as cluster 13).
Suite hs-upstream-transition: 13/17 → 15/17. Smoke 0-195: 162/195
unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Parser `parse-toggle-cmd`: after the leading class ref, collect any
additional class refs and treat `toggle .foo .bar` as `toggle-between`
(pair-only). Recognise a `until EVENT [from SOURCE]` modifier and emit
a new `toggle-class-until` AST node. Compiler handles the new node by
emitting `(begin (hs-toggle-class! tgt cls) (hs-wait-for src ev)
(hs-toggle-class! tgt cls))` which uses the existing event-waiter
machinery to flip the class back when the specified event fires.
Remaining toggle test (`can toggle for a fixed amount of time`)
depends on the mock's sync io-sleep resuming immediately — the click
handler toggles on/off synchronously, so the pre-timeout assertion
can never see the `.foo` class present. Needs an async scheduler in
the mock to handle.
Suite hs-upstream-toggle: 22/25 → 24/25. Smoke 0-195: 162/195
unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three parts: (a) `runtime.sx` hs-hide-one!/hs-show-one! consult a new
`_hs-hide-strategies` dict (and `_hs-default-hide-strategy` override)
before falling through to the built-in display/opacity/etc. cases. The
strategy fn is called directly with (op, el, arg). New setters
`hs-set-hide-strategies!` and `hs-set-default-hide-strategy!`. (b)
`generate-sx-tests.py` `_hs_config_setup_ops` recognises
`_hyperscript.config.defaultHideShowStrategy = "X"`, `delete …default…`,
and `hideShowStrategies = { NAME: function (op, el, arg) { if …
classList.add/remove } }` with brace-matched function body extraction.
(c) Pre-setup emitter handles `__hs_config__` pseudo-name by emitting
the SX expression as-is (not a window.X = Y assignment).
Suite hs-upstream-hide: 12/16 → 15/16. Remaining test
(`hide element then show element retains original display`) needs
`on click 1 hide` / `on click 2 show` count-filtered events — separate
feature. Smoke 0-195: 162/195 unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five parts: (a) tests/hs-run-filtered.js `io-wait-event` mock now
registers a one-shot listener on the target element and resumes with
the event, instead of immediately resuming with nil. (b) Added
hs-wait-for-or runtime form carrying a timeout-ms; mock resumes
immediately when a timeout is present (0ms tests). (c) parser
parse-wait-cmd recognises `wait for EV(v1, v2)` destructure syntax,
emits :destructure list on wait-for AST. (d) compiler emit-wait-for
updated for :from/:or combos; a new `__bind-from-detail__` form
compiles to `(define v (host-get (host-get it "detail") v))`, and the
`do`-sequence handler preprocesses wait-for to splice these synthetic
bindings after the wait. (e) generator extracts `detail: ...` from
`CustomEvent` options so dispatched events carry their payload.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three-part fix: (a) emit-send now builds detail=(dict "sender" me) on
(send NAME target) and bare (send NAME) instead of nil, so the receiving
handler has access to the sending element. (b) parser parse-atom now
recognises the `sender` keyword (previously swallowed as noise) and
emits it as (sender). (c) compiler translates bare `sender` symbol and
(sender) list-head to (hs-sender event) — a new runtime helper that
reads (get (host-get event "detail") "sender").
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`\$window.foo` / `\${window.foo}` couldn't resolve. Two fixes:
(a) compiler.sx: in a dot-chain base position, known globals (window,
document, navigator, location, history, screen, localStorage,
sessionStorage, console) emit `(host-global "name")` instead of a
bare unbound symbol.
(b) generator: `eval-hs-locals` now also sets each binding on
`window.<name>` via `host-set!`, so tests that translated
`window.X = Y` as a local pair still see `window.X` at eval time.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
parse-atom emitted (not (parse-expr)) which let or/and capture the whole
RHS before `not` could bind. Also emitted SX `not` which treats only nil/
false as falsy, so `not 0` returned false.
Fix: `not` now emits `(hs-falsy? (parse-atom))` — tight binding to the
following atom, and hyperscript-style truthy/falsy (0, "", nil, false, []).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dict-set! keys iterate in scrambled order, so Values|FormEncoded and
Values|JSONString produced output in the wrong order. Fix: hs-values-absorb
now tracks insertion order in a hidden `_order` list on the dict itself.
hs-coerce FormEncoded/JSONString paths read `_order` when present and
iterate in that order (filtering the marker key out).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds hs-host-to-sx to convert raw host-handle JS objects/arrays returned by
json-parse or io-fetch into proper SX dicts/lists. hs-fetch now calls it on
the result when format is "json". Detects host handles via absence of the
internal `_type` marker, then walks Object.keys / Array items recursively.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- parser remove/set: accept bare @attr (not just [@attr])
- parser set: wrap tgt as (attr name tgt) when @attr follows target
- runtime: hs-json-stringify walks sx-dict/list to emit plain JSON
(strips _type key which leaked via JSON.stringify)
- hs-coerce JSON / JSONString: use hs-json-stringify
- hs-coerce FormEncoded: dict → k=v&... (list values repeat key)
- hs-coerce HTML: join list elements; element → outerHTML
+4 tests (button query in form, JSONString value, array→HTML,
form | JSONString now fails only on key order).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- parse-atom: 'you' and 'yourself' keywords resolve to (ref <name>) so
they look up the let-binding the tell-command installs.
- 'your <prop>' no longer aliases 'my <prop>' — it's the possessive over
the 'you' binding, mirroring 'its' over 'it'.
Unblocks 'you symbol represents the thing being told' and 'can take a class
and swap it with another via with' (via you/your in tell handlers). Net:
tell 6→7 (was 6/10).
- parse-trigger-cmd: use parse-compound-event-name so 'trigger foo:bar' and
'trigger foo.bar' preserve the full event name. Also parse an optional
detail dict '(x:42)' like parse-send-cmd.
- compiler: 3-arg (trigger NAME DETAIL TGT) emits dom-dispatch with the
detail dict. 2-arg (trigger NAME TGT) unchanged.
- emit-on event-ref bindings now use (host-get event 'detail') → the event
carries detail as a JS object, so the SX 'get' primitive returned nil
and tests checking 'on foo(x) … x' saw empty values.
Net: trigger 2→6 (100%).
Mock DOM:
- El now tracks defaultValue/defaultChecked/defaultSelected and a reset()
method that walks descendant form controls, restoring them.
- setAttribute(value|checked|selected) sets the matching default-* too, so
the initial HTML state can be restored later.
- parseHTMLFragments + _setInnerHTML capture a textarea's textContent as
its value AND defaultValue.
Generator (pw-body):
- add_action / add_assertion extract .first() / .last() / .nth(N) modifiers
into (nth (dom-query-all …) i) or a (let ((_all …)) (nth _all (- … 1)))
tail so multi-match helpers hit the right element.
Compiler:
- emit-reset! with a .<class>/.<sel> query target now compiles to hs-query-all
so 'reset .resettable' resets every matching control (not just the first).
Net: reset 1→8 (100%).
- hs-pick-first/last/random/items/slice: short-circuit nil or non-list
(strings flow through unchanged).
- New hs-pick-match / hs-pick-matches wrappers around regex-match /
regex-find-all, also nil-safe; compiler routes pick-match / pick-matches
through them. Unblocks 'pick first from null returns null' and
'pick match from null returns null' which previously looped past
step_limit.
'add .foo to my children' compiles to (dom-add-class (host-get me 'children') 'foo') where
children is a list. Fanned out via for-each inside dom-add-class/dom-remove-class rather
than calling .classList.add on the list itself. Net: add 10→13.
- tokenizer: add 'giving' as keyword so parse-take-cmd can detect it.
- parser.sx parse-take-cmd: loop over 'with <class>' / 'giving <class>' /
'from <sel>' / 'for <tgt>' clauses in any order for both the class and
attribute cases. Emits uniform (take! kind name from-sel for-tgt
attr-val with-val) 7-slot AST.
- compiler emit-take: pass with-cls for the class case through to runtime.
- runtime hs-take!: with a class 'with' replacement, toggle both classes
across scope + target. For attribute take, always strip the attr from
the scope 'others' (setting to with-val if given, otherwise removing).
- generator pw-body: translate evaluate(() => document.querySelector(s).
click()) and .dispatchEvent(new Event('name', …)) into dom-dispatch ops
so bubbling-click assertions in 'parent takes…' tests work.
- generator toHaveClass: strip JS regex word-boundaries (\\b) from the
expected class name.
- shared/static/wasm/sx/dom.sx: dom-child-list / dom-child-nodes mirror
the dom-query-all SX-list passthrough — childNodes arrives pre-SXified.
Net: take 6→15 (100%), remove 16→17, fetch 11→15.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- generate-sx-tests.py: add_action/add_assertion accept .nth(N) in PW-body
tests so 'find(sel).nth(1).dispatchEvent(...)' lands as a dispatch on
the Nth matching element, and assertions target that same element.
- shared/static/wasm/sx/dom.sx: dom-query-all hands through an already-SX
list unchanged — the bridge often pre-converts NodeLists/arrays to SX
lists, so the host-get 'length' / host-call 'item' loop was returning
empty. Guards node-list=nil and non-list types too.
- tests/hs-run-filtered.js (mock DOM): fnd() understands
':nth-of-type(N)', ':first-of-type', ':last-of-type' by matching the
stripped base selector and returning the correct-indexed sibling.
Covers upstream tests that write 'find("div:nth-of-type(2)")' to
pick the HS-owning element.
- Runtime runtime.sx: hs-sorted-by, hs-fetch format normalizer (JSON/
Object/etc.), nil-safe hs-joined-by/hs-split-by, emit-fetch chain sets
the-result when wrapped in let((it …)).
Net: take 0→6, hide 11→12, show 15→16, fetch 11→15,
collectionExpressions 13→15 (remaining are a WASM JIT bug on
{…} literals inside arrays).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Runtime (lib/hyperscript/ + shared/static/wasm/sx/hs-*.sx):
- make: parser accepts `<tag.class#id/>` selectors and `from <expr>,…`; compiler
emits via scoped-set so `called <name>` persists; `called $X` lands on
window; runtime dispatches element vs host-new constructor by type.
- Values: `x as Values` walks form inputs/selects/textareas, producing
{name: value | [value,…]}; duplicates promote to array; multi-select and
checkbox/radio handled.
- toggle *display/*visibility/*opacity: paired with sensible inline defaults
in the mock DOM so toggle flips block/visible/1 ↔ none/hidden/0.
- add/remove/put at array: emit-set paths route list mutations back through
the scoped binding; add hs-put-at! / hs-splice-at! / hs-dict-without.
- remove OBJ.KEY / KEY of OBJ: rebuild dict via hs-dict-without and reassign,
since SX dicts are copy-on-read across the bridge.
- dom-set-data: use (host-new "Object") rather than (dict) so element-local
storage actually persists between reads.
- fetch: hs-fetch normalizes JSON/Object/Text/Response format aliases;
compiler sets `the-result` when wrapping a fetch in the `let ((it …))`
chain, and __get-cmd shares one evaluation via __hs-g.
Mock DOM (tests/hs-run-filtered.js):
- parseHTMLFragments accepts void elements (<input>, <br>, …);
- setAttribute tracks name/type/checked/selected/multiple;
- select.options populated on appendChild;
- insertAdjacentHTML parses fragments and inserts real El children into the
parent so HS-activated handlers attach.
Generator (tests/playwright/generate-sx-tests.py):
- process_hs_val strips `//` / `--` line comments before newline→then
collapse, and strips spurious `then` before else/end/catch/finally.
- parse_dev_body interleaves window-setup ops and DOM resets between
actions/assertions; pre-html setups still emit up front.
- generate_test_pw compiles any `<script type=text/hyperscript>` (flattened
across JS string-concat) under guard, exposing def blocks.
- Ordered ops for `run()`-style tests check window.obj.prop via new
_js_window_expr_to_sx; add DOM-constructing evaluate + _hyperscript
pattern for `as Values` tests (result.key[i].toBe(…)).
- js_val_to_sx handles backticks and escapes embedded quotes.
Net delta across suites:
- if 16→18, make 0→8, toggle 12→21, add 9→10, remove 11→16, put 29→31,
fetch 11→15, repeat 14→26, expressions/asExpression 20→25, set 27→28,
core/scoping 12→14, when 39→39 (no regression).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Last commit's `hs-type-check` rewrite collapsed predicate and assertion
into one runtime fn that always raised on mismatch. That fixed `: Type`
but broke `is a Type` / `is not a Type` (which need a bool):
null is a String expected true, got nil (raised)
null is not a String expected false, got true (default boolean)
Restored the split. Parser now emits `(type-assert ...)` for `:` and
keeps `(type-check ...)` for `is a` / `is not a`. Runtime adds:
- `hs-type-check` — predicate, never raises (nil passes)
- `hs-type-check-strict` — predicate, false on nil
- `hs-type-assert` — value or raises
- `hs-type-assert-strict` — value or raises (also raises on nil)
Compiler maps `type-assert` / `type-assert-strict` to the new runtime fns.
comparisonOperator 74/83 → 79/83 (+5: `is a/an`, `is not a/an` four tests
plus a fifth that depended on them). typecheck stays 2/5 (no regression).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`set element x to 10` was compiling to `(set! (string-postfix (ref "element") "x") 10)`
because parse-expr greedily consumed `element x` as a string-postfix expression.
Recognise the bare `element` / `global` / `local` ident at the start of the
set target and skip it so `tgt` parses as just `x`. The variable lives in
the closure scope of the handler — close enough for handler-local use; a
real per-element store would need extra work in the compiler.
core/scoping: 9/20 → 12/20 (+3): "element scoped variables work",
"element scoped variables span features", "global scoped variables work".
The `:x` / `$x` short-syntax variants still fail because their listeners
aren't registering in the test mock — separate issue.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`'foo' : String` and `'foo' : String!` were returning `true` because
`hs-type-check` was a predicate. Per upstream hyperscript semantics,
`value : Type` is a type-asserted pass-through:
- nil passes the basic check (use `Type!` for non-null)
- mismatched type → raise "Typecheck failed!"
- match → return the original value
`hs-type-check-strict` now also raises on nil rather than returning
false, so the `String!` form actually rejects null.
hs-upstream-expressions/typecheck: 0/5 → 2/5.
asExpression unchanged (uses different `as Type` runtime path).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Parser (lib/hyperscript/parser.sx):
- parse-poss case for "(" (function call) was building (call ...) and
returning without recursing, so `f().x` lost the `.x` suffix and the
compiler emitted (let ((it (f))) (hs-query-first ".x")). Now it tail-
calls parse-poss on the constructed call so chains like f().x.y(),
obj.method().prop, etc. parse correctly.
Generator (tests/playwright/generate-sx-tests.py):
- New js_expr_to_sx: translates arrow functions ((args) => body), object
literals, simple property access / method calls / arith. Falls back
through js_val_to_sx for primitives.
- New extract_window_setups: scans `evaluate(() => { window.X = Y })`
blocks (with balanced-brace inner-body extraction) and returns
(name, sx_value) pairs.
- Pattern 1 / Pattern 2 in generate_eval_only_test merge those window
setups into the locals passed to eval-hs-locals, so HS expressions
can reference globals defined by the test prelude.
- Object literal value parsing now goes through js_expr_to_sx first,
so `{x: x, y: y}` yields `{:x x :y y}` (was `{:x "x" :y "y"}`).
Net: hs-upstream-expressions/functionCalls 0/12 → 5/12 (+5).
Smoke-checked put/set/scoping/possessiveExpression — no regressions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Generator changes (tests/playwright/generate-sx-tests.py):
- toHaveCSS regex: balance parens so `'rgb(255, 0, 0)'` is captured intact
(was truncating at first `)`)
- Map browser-computed colors `rgb(R,G,B)` back to CSS keywords
(red/green/blue/black/white) — our DOM mock returns the inline value
- js_val_to_sx now handles object literals `{a: 1, b: {c: 2}}` → `{:a 1 :b {:c 2}}`
- Pattern 2 (`var x = await run(...)`) now captures locals via balanced-brace
scan and emits `eval-hs-locals` instead of `eval-hs`
- Pattern 1 with locals: emit `eval-hs-locals` (was wrapping in `let`, which
doesn't reach the inner HS env)
- Stop collapsing `\"` → `"` in raw HTML (line 218): the backslash escapes
are legitimate in single-quoted `_='...'` HS attribute values containing
nested HS scripts
Test-framework changes (regenerated into spec/tests/test-hyperscript-behavioral.sx):
- `_hs-wrap-body`: returns expression value if non-nil, else `it`. Lets bare
expressions (`foo.foo`) and `it`-mutating scripts (`pick first 3 of arr;
set $test to it`) both round-trip through the same wrapper
- `eval-hs-locals` now injects locals via `(let ((name (quote val)) ...) sx)`
rather than `apply handler (cons nil vals)` — works around a JIT loop on
some compiled forms (e.g. `bar.doh of foo` with undefined `bar`)
Also synced lib/hyperscript/*.sx → shared/static/wasm/sx/hs-*.sx (the WASM
test runner reads from the wasm/sx/ copies).
Net per-cluster pass counts (vs prior baseline):
- put: 23 → 29 (+6)
- set: 21 → 28 (+7)
- show: 7 → 15 (+8)
- expressions/propertyAccess: 3 → 9 (+6)
- expressions/possessiveExpression: 17 → 18 (+1)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- parser `empty` no-target → (ref "me") (was bogus (sym "me"))
- parser `halt` modes distinguish: "all"/"bubbling"/"default" halt execution
(raise hs-return), "the-event"/"the event's" only stop propagation/default.
"'s" now matched as op token, not keyword.
- parser `get` cmd: dispatch + cmd-kw list + parse-get-cmd (parses expr with
optional `as TYPE`). Required for `get result as JSON` in fetch chains.
- compiler empty-target for (local X): emit (set! X (hs-empty-like X)) so
arrays/sets/maps clear the variable, not call DOM empty on the value.
- runtime hs-empty-like: container-of-same-type empty value.
- runtime hs-empty-target!: drop dead FORM branch that was short-circuiting
to innerHTML=""; the querySelectorAll-over-inputs branch now runs.
- runtime hs-halt!: take ev param (was free `event` lookup); raise hs-return
to stop execution unless mode is "the-event".
- runtime hs-reset!: type-aware — FORM → reset, INPUT/TEXTAREA → value/checked
from defaults, SELECT → defaultSelected option.
- runtime hs-open!/hs-close!: toggle `open` attribute on details elements
(not just the prop) so dom-has-attr? assertions work.
- runtime hs-coerce JSON: json-stringify dict/list (was str).
- test-runner mock: host-get on List + "length"/"size" (was only Dict);
dom-set-attr tracks defaultChecked / defaultSelected / defaultValue;
mock_query_all supports comma-separated selector groups.
- generator: emit boolean attrs (checked/selected/etc) even with null value;
drop overcautious "skip HS with bare quotes or embedded HTML" guard so
morph tests (source contains embedded <div>) emit properly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Updates the pre-bundled HS tokenizer/parser/compiler/runtime/integration
sx + sxbc pairs plus module-manifest.json in shared/static/wasm/sx/,
matching the current HS source after recent patches (call command,
event destructuring, halt/append, break/continue, CSS block syntax, etc.).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Parser:
- `add VALUE to :var` → (add-value) for array append
- `remove VALUE from :var` → (remove-value) for array removal
- `toggle .foo for 10ms` → (toggle-class-for) with duration
- `append VALUE` without `to` → implicit target (it)
- `set {obj} on target` → (set-on) for object property spread
- `repeat in` body: remove spurious nil (body at index 3→2)
- Keywords followed by `(` parsed as function calls (fixes `increment()`)
Compiler:
- Handle add-value, remove-value, toggle-class-for, set-on AST nodes
- Local variables (`set :var`) use `define` instead of `set!`
Runtime:
- hs-add-to!: append value to list
- hs-remove-from!: filter value from list
- hs-set-on!: spread dict properties onto target
- `as String` for lists: comma-join (JS Array.toString compat)
Tests:
- eval-hs/eval-hs-with-me: guard for hs-return exceptions
(return compiles to raise, needs handler to extract value)
Parse errors: 20→12 (8 fixed). Remaining: 6 embedded HTML quotes
(tokenizer), 6 transition template values `(expr)px`.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously these primitives threw Eval_error if either arg was non-string.
Now they return false, preventing crashes when DOM attributes return nil
values during element processing (e.g. htmx-boot-subtree! iterating
elements with undefined attribute names).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
orchestration.sx process-elements iterates DOM attributes and calls
starts-with? on the name. Some attributes have nil names (e.g. from
malformed elements). Added (string? name) guard before starts-with?.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The htmx-boot-subtree! function (defined in lib/hyperscript/htmx.sx)
was never loaded in the browser because hs-htmx.sx wasn't in the
bundle or compile-modules lists. Added to:
- bundle.sh: copy htmx.sx as hs-htmx.sx to dist
- compile-modules.js: compile to hs-htmx.sxbc, add to deps and lazy list
This was the root cause of "Load Content" button not working —
hx-* attributes were never activated because htmx-boot-subtree!
was undefined.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Parser: fetch command consumes {method:"POST"}, with {opts}, and
handles as-format both before and after options.
Mock: Number format case-insensitive, /test route has number field.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
guard and cek-try both create CEK frames that don't survive async
perform/resume. Instead, run-action returns nil on success and an
error string on failure. The for-each loop checks the return value
and sets fail-msg. No exceptions cross async boundaries.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The let/it wrapping changed semantics of ALL multi-command sequences,
breaking independent side-effect chains like (do (add-class) (add-class)).
Need a targeted approach — chain it only for then-separated commands.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When an error occurs during resumed VM execution (after perform/hs-wait),
resume_vm now checks the VM's handler_stack. If a handler exists (from a
compiled guard form's OP_PUSH_HANDLER), it unwinds frames and jumps to
the catch block — exactly like OP_RAISE. This enables try/catch across
async perform/resume boundaries.
The guard form compiles to OP_PUSH_HANDLER which lives on the vm struct
and survives across setTimeout-based async resume. Previously, errors
during resume escaped to the JS console as unhandled exceptions.
Also restored guard in the test runner (was cek-try which doesn't survive
async) and restored error-throwing assertions in run-action.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Compiler: do-blocks now compile to (let ((it cmd1)) (let ((it cmd2)) ...))
instead of (do cmd1 cmd2 ...). This chains the `it` variable through
command sequences, enabling `fetch X then put it into me` pattern.
Each command's result is bound to `it` for the next command.
Runtime: hs-fetch simplified to single perform (io-fetch url format)
instead of two-stage io-fetch + io-parse-text/json.
Parser: fetch URL /path handled by reading /+ident tokens.
Default fetch format changed to "text" (was "json").
Test runner: mock fetch routes with format-specific responses.
io-fetch handler returns content directly based on format param.
Fetch tests still need IO suspension to chain through let continuations.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The guard form (call/cc + handler-bind expansion) doesn't survive async
IO suspension — the CEK continuation from guard's call/cc captures frames
that become invalid after the VM resumes from hs-wait. Replacing guard
with cek-try (which compiles to VM-native OP_PUSH_HANDLER/OP_POP_HANDLER)
avoids the CEK boundary crossing.
The test runner now executes: suspends on hs-wait, resumes, runs test
actions, and test assertions fire correctly. The "Not callable: nil"
error is eliminated. Remaining: test assertion errors from iframe content
not loading fast enough (timing issue, not a framework bug).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Not callable: nil error happens on a stub VM (frames=[], sp=0) during
cek_resume with 12 CEK kont frames. The error is from a reactive signal
subscriber (reset! current ...) that triggers during run vm after resume.
The subscriber callback goes through CEK via cek_call_or_suspend and the
CEK continuation tries to call nil.
This is a reactive subscriber notification issue, not a perform/resume
frame management issue. The VM frames are correctly restored — the error
happens during a synchronous reset! call within the resumed VM execution.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Shows pending_cek, reuse_stack count, and frames count in the error.
Also transfers reuse_stack from _active_vm at VmSuspended catch sites.
Finding: the Not callable: nil happens during cek_resume (pending_cek=false,
kont=12 frames). The CEK continuation tries to call a letrec function that
is nil because letrec bindings are in VM local SLOTS, not in the CEK env.
The VM→CEK boundary crossing during suspension loses the local slot values.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bootstrap.py regenerated cek_run as a simple "raise if suspended" without
the _cek_io_resolver and _cek_io_suspend_hook checks. Also lost the
CekPerformRequest catch in cek_step_loop and step_limit checks.
This was the direct cause of "IO suspension in non-IO context" when island
click handlers called perform (via hs-wait). The CEK had no way to propagate
the suspension to the VM/JS boundary.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>