Commit Graph

1910 Commits

Author SHA1 Message Date
41fac7ac29 Merge branch 'hs-e40-fetch' into loops/hs
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 16s
2026-04-26 17:54:34 +00:00
4c48a8dd57 Merge branch 'hs-e37-tokenizer' into loops/hs 2026-04-26 17:54:11 +00:00
a48110417b HS: DOM ref-eq + compound selector + DOM tree fixes
- hs-id= uses JS === for DOM elements (hs-ref-eq), = for scalars
- != operator now uses hs-id= for structural correctness
- compound tag[attr=val] selector matching in test runner
- dom-query-all replaces host-call querySelectorAll
- DOM tree structure corrected in 4 generated tests (elements were
  appended to wrong parents)
2026-04-26 17:49:51 +00:00
f2993f0582 HS-plan: log Bucket F array-literal-arg fix +1; sync scoreboard
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 17s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 15:36:55 +00:00
da2e6b1bca HS Bucket F: array literal arg to JS fn fix (+1 test)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 18s
Generator emit_eval translates arr.reduce/map/filter to SX primitives
so SX list args work. host-call-fn sxToJs converts SX lists to native
JS arrays for native JS function calls. Fixes functionCalls
"can pass an array literal as an argument".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 15:36:23 +00:00
f38558fcc1 HS-plan: log Bucket F _order+assert= fix +1; sync scoreboard
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 15s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 15:23:39 +00:00
daea280837 HS Bucket F: fix hs-make-object _order + assert= for dicts (+1 test)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 20s
hs-make-object no longer appends _order to every HS object literal.
Generator emit_eval now uses assert-equal (equal?) for dict-containing
expected values instead of assert= (= reference equality).
Together these fix arrayLiteral "arrays containing objects work".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 15:22:26 +00:00
11917f1bfa HS-plan: log Bucket F empty multi-element fix +1; sync scoreboard
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 17s
2026-04-26 15:03:10 +00:00
875e9ba317 HS: empty multi-element fix (+1 test)
empty .class compiled (empty-target (query ".class")) to
(hs-empty-target! (hs-query-first ".class")) via hs-to-sx — only
emptying the first match. Fix: detect (query ...) target in the
empty-target compiler case and emit (for-each (fn (_el)
(hs-empty-target! _el)) (hs-query-all sel)) instead, mirroring the
add-class pattern. Suite hs-upstream-empty: 12/13 → 13/13.
Smoke 0-195: 175/195 unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 15:02:47 +00:00
f715d23e10 HS-plan: log Bucket F add CSS template fix +1; sync scoreboard
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 17s
2026-04-26 14:43:24 +00:00
5a76a04010 HS: add CSS template interpolation fix (+1 test)
${}{"val"} pattern in add {prop: ${}{"val"}} uses two consecutive brace
groups: empty ${} followed by {"val"} for the actual expression. The prior
fix called parse-expr when already at the brace-close of the empty group,
returning nil. New fix: detect empty ${} (brace-open then brace-close),
skip the close, then read the actual value from the following {…} block.
Also handles non-empty ${expr} directly as before.
Suite hs-upstream-add: 17/19 → 18/19. Smoke 0-195: 174/195 → 175/195.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 14:42:36 +00:00
a0bbf74c01 HS-plan: log cluster 36b done +1 (call it-binding)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 18s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 14:14:32 +00:00
35f498ec80 hs: call command binds result to it via emit-set
call X then put it into Y was emitting (hs-win-call ...) without
wrapping in emit-set, so it remained nil. Wrap call result in
emit-set(the-result) so it/the-result are updated. Fixes +1 test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 14:14:02 +00:00
037acc7998 HS-plan: log cluster 7 done +5 (put reprocessing complete)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 16s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 14:02:31 +00:00
247bd85cda hs: register promiseAString/promiseAnInt as sync test fixtures
Matches OCaml run_tests.ml which binds these as NativeFn returning
"foo"/"42" directly. hs-win-call looks up window globals; registering
them synchronously lets put/set tests exercise function-call + put
without requiring real Promise awaiting. Fixes "waits on promises" +1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 14:02:07 +00:00
b41d9d143b HS-plan: log cluster 7 partial +3 more (total +4, 1 remains)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 2m48s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 13:53:32 +00:00
d663c91f4b hs: stop event propagation after each hs-on handler fires
Prevents click events from bubbling into ancestor elements that also
have hs handlers (e.g. parent re-inserting HTML after child click).
Fixes put-reprocessing tests 1147/1149/1150 (+3 tests).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 13:52:25 +00:00
4c43918a99 HS-plan: E40 done +7; scoreboard 1310/1496 (+97)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 11:34:51 +00:00
d7244d1dc8 HS: hyperscript:beforeFetch event + runner dict format (+1 test)
- hs-fetch gains target param; dispatches hyperscript:beforeFetch before fetch
- compiler emits (quote me) as target arg
- runner io-fetch returns unified dict {_type:'dict', ok, status, _body, ...}
  so runtime (get raw :key) calls work correctly (22/23 fetch tests pass)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 11:33:04 +00:00
1b1b67c72e HS: fetch don't throw contraction (+1 test) 2026-04-26 10:15:44 +00:00
3a755947ef HS: fetch do-not-throw modifier (+1 test) 2026-04-26 10:03:06 +00:00
880503e2b6 HS E37: tokenizer-as-API 17/17 (+fixes)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 16s
- runtime.sx: fix extra ) in hs-tokens-of (parse error); add hs-eof-sentinel,
  hs-raw->api-token, hs-normalize-raw-tokens, hs-tokens-of, stream helpers,
  hs-token-type/value/op?; add \$ escape to hs-template
- tokenizer.sx: fix read-number double-dot bug (1.1.1 → 3 tokens); fix t-emit!
  eof call (3→2 args); add bare $ case to scan-template!
- compiler.sx: add \$ escape to tpl-collect template interpolation
- generate-sx-tests.py: preserve \$ in process_hs_val; add generate_tokenizer_test
- regen spec/tests/test-hyperscript-behavioral.sx: 17 tokenizer tests generated
- plans/hs-conformance-to-100.md: row 37 marked done +17

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 09:54:59 +00:00
e989ff3865 Merge branch 'hs-e39-webworker' into loops/hs 2026-04-26 07:26:25 +00:00
8e2a633b7f HS: sourceInfo (+4 tests)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 19:18:44 +00:00
cc2a296306 HS: sourceInfo API (sourceFor / lineFor / node-get) 2026-04-25 19:10:57 +00:00
9c8da50003 HS: parser attaches source spans to AST nodes 2026-04-25 19:09:04 +00:00
3003c8a069 HS E37 step 5: hs-tokenize-template + template routing in hs-tokens-of
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 12s
Add hs-tokenize-template: scans " as single STRING token, ${ ... }
as dollar+brace+inner-tokens (inner tokenized with hs-tokenize), and
} as brace-close. Update hs-tokens-of to call hs-tokenize-template
when :template keyword arg is passed. Unlocks tests 1 and 15.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 19:08:38 +00:00
8c62137d32 HS E37 step 2: extend read-string escapes + unterminated/hex errors
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Add \r \b \f \v and \xNN escape handling to read-string. Use
char-from-code for non-SX-literal chars. Throw "Unterminated string"
on EOF inside a string literal. Throw "Invalid hexadecimal escape: \x"
on bad \xNN. Add hs-hex-digit? and hs-hex-val helpers. Unlocks
tests 2, 6, 13, 14 once generator lands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 19:03:03 +00:00
573f9fa4b3 HS: E39 WebWorker plugin stub (+1 test)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 12s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:56:46 +00:00
8ac669c739 HS E37 step 1: hs-api-tokens + stream/token helpers in runtime.sx
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Add hs-eof-sentinel, hs-op-type, hs-raw->api-token, hs-tokens-of,
hs-stream-token, hs-stream-consume, hs-stream-has-more, and the
three token accessors (hs-token-type, hs-token-value, hs-token-op?).
No test delta yet — API-only, generator comes in step 6.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:56:26 +00:00
8e4bdb7216 HS E40: generator removes 7 E40 tests from skip-list; window.addEventListener handler (+1) 2026-04-25 18:55:40 +00:00
20a643806b HS: tokenizer tracks :end and :line 2026-04-25 18:54:59 +00:00
ea1bdab82c HS E40: window event-target shim + bubble relay to window listeners 2026-04-25 18:50:52 +00:00
04164aa2d4 HS E40: runner _fetchScripts map + networkError plumbing 2026-04-25 18:49:19 +00:00
912649c426 HS-plan: log in-expression filter semantics done +1
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
2026-04-25 18:35:48 +00:00
67a5f13713 HS: in-expression filter semantics (+1 test)
`1 in [1, 2, 3]` must return (list 1) not true. Root cause: in? compiled
to hs-contains? which returns boolean for scalar items. Fix: new hs-in?
returns filtered list; new in-bool? operator for is/am-in comparison
contexts so those still return boolean. Parser generates in-bool? for
`X is in Y` / `X am in Y`; plain `in` keeps in? → list return.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:35:26 +00:00
db8d7aca91 HS-plan: log cluster 22 done +1; sync scoreboard
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
- Mark cluster 22 done (+1): can refer to function in init blocks
- Scoreboard: merged 1280→1302 (+22 from stale rows 22/29/32/33/34/35)
- Fix stale rows: clusters 29 partial, 32 done, 33 partial+4, 34 partial+7, 35 done

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 17:58:31 +00:00
d31565d556 HS cluster 22: simplify win-call emit + def→window + init-blocks test (+1)
- Remove guard wrapper from hs-win-call emit (direct call is sufficient now)
- def command also registers fn on window[name] so hs-win-call finds it
- Generator: fix \"-escaped quotes in hs-compile string literal (was splitting "here" into three SX nodes)
- Hand-rolled deftest for 'can refer to function in init blocks' now passes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 17:55:32 +00:00
337c8265cd HS cluster 22: host-call-fn FFI + hs-win-call + def hoisting
- Add host-call-fn FFI primitive to test runner (calls SX lambdas or JS fns)
- Add hs-win-call runtime helper: looks up fn by name in window globals
- Compiler call case: emit guard-wrapped hs-win-call for bare (ref ...) calls
- Compiler method-call else: same guard pattern for non-dot method calls
- Compiler do case: hoist define forms before init/other forms (def hoisting)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 12:53:12 +00:00
a4538c71a8 HS-plan: log cluster 11/33 followups +2
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 12:52:37 +00:00
5ff2b7068e HS: cluster 11/33 followups (+2 tests)
Three orthogonal fixes that pick up tests now unblocked by earlier
cluster-34 (count filters) and cluster-35 (hs-method-call fallback) work:

(1) parser.sx parse-hide-cmd / parse-show-cmd — added `on` to the keyword
list that signals an implicit-`me` target. Without this, `on click 1
hide on click 2 show` silently parsed as `(hide nil)` because parse-expr
greedily started consuming `on` and returned nil. With the bail-out,
hide/show default to me when the next token is `on` (a sibling feature).

(2) runtime.sx hs-method-call fallback — when method isn't a built-in
collection op, look up obj[method] via host-get; if it's an SX-callable
(lambda) use apply, but if it's a JS-native function (e.g. cookies.clear
on the cookies Proxy) dispatch via `(apply host-call (cons obj (cons
method args)))` so the JS native receives the args correctly. SX
callable? returns false for JS-native function values, hence the split.

(3) generator hs-cleanup! — wrapped body in begin (fn body evaluates
only the last expression) and reset two pieces of mutable global runtime
state between tests: hs-set-default-hide-strategy! nil and
hs-set-log-all! false. The prior `can set default to custom strategy`
test (cluster 11) was leaking _hs-default-hide-strategy to subsequent
tests, breaking `hide element then show element retains original
display` because hs-hide-one! resolved its "display" strategy through
the leaked override.

Also added cluster-33 hand-roll for `basic clear cookie values work`
(uses the new method-call fallback to dispatch cookies.clear via
host-call).

hs-upstream-hide: 15/16 → 16/16. hs-upstream-expressions/cookies: 3/5
→ 4/5. Smoke 0-195 unchanged at 172/195.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 12:52:02 +00:00
f011d01b49 HS-plan: log cluster 35 done +3
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 12:38:02 +00:00
122053eda3 HS: namespaced def + script-tag global functions (+3 tests)
Runtime: hs-method-call gains a fallback case — when method isn't one of
the built-in collection ops (map/push/filter/join/indexOf), look up the
method name as a property on obj via host-get; if the value is callable,
invoke via apply with the call args. This makes namespaced calls like
`utils.foo()` work when utils is an SX dict whose foo entry is an SX fn.

Generator: hand-rolled deftests for the 3 cluster-35 tests:
- `is called synchronously` and `can call asynchronously`: pre-evaluate
  the script-tag def via `(eval-expr-cek (hs-to-sx (first (hs-parse
  (hs-tokenize "def foo() ... end")))))` so foo lands in the global eval
  env, then build a click div via dom-set-attr + hs-boot-subtree! and
  exercise it via dom-dispatch click.
- `functions can be namespaced`: hand-build `(define utils (dict))` then
  `(host-set! utils "foo" __utils_foo)` (the def is registered under a
  fresh sym since the parser doesn't yet support `def utils.foo()` dotted
  names), and rely on the new hs-method-call fallback to dispatch
  `utils.foo()` through host-get/apply.

Removed the 3 def entries from SKIP_TEST_NAMES.

hs-upstream-def: 24/27 → 27/27. Smoke 0-195 unchanged at 172/195.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 12:37:39 +00:00
7bbffa0401 HS-plan: log cluster 34 elsewhere done +2
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 12:27:04 +00:00
3044a16817 HS: elsewhere / from elsewhere modifier (+2 tests)
Parser: parse-on-feat now consumes `elsewhere` (or `from elsewhere`) as
a modifier between event-name and source. When matched, sets a flag and
emits :elsewhere true on parts. The `from elsewhere` form peeks one
token ahead before consuming both keywords so plain `from #x` continues
to parse as a source expression.

Compiler: scan-on threads elsewhere?; when present, target becomes
(dom-body) (so the listener attaches to body and bubbles see all clicks)
and the handler body is wrapped with `(when (not (host-call me "contains"
(host-get event "target"))) BODY)` so the handler fires only when the
click originated outside the activated element.

Generator: dropped supports "elsewhere" modifier and supports "from
elsewhere" modifier from skip-list.

hs-upstream-on: 48/70 → 50/70. Smoke 0-195 unchanged at 172/195.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 12:26:30 +00:00
a8a798c592 HS-plan: log cluster 34 done +5 (partial)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 12:09:11 +00:00
19c97989d7 HS: count-filtered events + first modifier (+5 tests)
Parser: parse-on-feat now consumes `first` keyword before event-name (sets
count-min/max to 1) and a count expression after event-name — `N` (single),
`N to M` (range), `N and on` (unbounded above). Number tokens are coerced
via parse-number. Emits :count-filter {"min" N "max" M | -1} part.

Compiler: scan-on threads count-filter-info; the handler binding wraps the
fn body in a let-bound __hs-count counter. Each event fire increments the
counter and (when count is in range) executes the original body. Each
on-clause registers an independent handler with its own counter, so
`on click 1 ... on click 2 ... on click 3` produces three handlers that
fire on their respective Nth click (mix-ranges test).

Generator: dropped 5 cluster-34 tests from skip-list — `can filter events
based on count`, `... count range`, `... unbounded count range`, `can mix
ranges`, `on first click fires only once`.

hs-upstream-on: 43/70 → 48/70. Smoke 0-195 unchanged at 172/195.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 12:08:40 +00:00
ff38499bd5 HS-plan: log cluster 29 done +2 (partial)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 11:58:45 +00:00
e01a3baa5b HS: hyperscript:before:init / :after:init events (+2 tests)
integration.sx hs-activate! now wraps the activation block in a cancelable
hyperscript:before:init event (dispatched on the el via dom-dispatch which
returns the dispatchEvent boolean — true unless preventDefault was called).
On success it dispatches hyperscript:after:init at the end. Both events
bubble so listeners on a containing wa work-area receive them. Generator
gets two hand-rolled deftests that exercise the new dispatch via
hs-boot-subtree!: one captures both events into a list, the other
preventDefaults before:init and asserts data-hyperscript-powered is absent.

hs-upstream-core/bootstrap: 20/26 → 22/26. Smoke 0-195: 170 → 172.

Remaining 4 cluster-29 tests need stricter parser error-rejection
(hs-upstream-core/parser, parse-error event); larger than a single
cluster budget — leave as untranslated for now.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 11:58:19 +00:00
484b55281b HS-plan: claim cluster 29 hyperscript init events
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 11:55:32 +00:00