Rebuild hyperscript WASM bytecode bundles (hs-*.sxbc + manifest)
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>
This commit is contained in:
@@ -99,6 +99,39 @@
|
||||
;; ── Navigation / traversal ──────────────────────────────────────
|
||||
|
||||
;; Navigate to a URL.
|
||||
(define
|
||||
hs-toggle-style-between!
|
||||
(fn
|
||||
(target prop val1 val2)
|
||||
(let
|
||||
((cur (dom-get-style target prop)))
|
||||
(if
|
||||
(= cur val1)
|
||||
(dom-set-style target prop val2)
|
||||
(dom-set-style target prop val1)))))
|
||||
|
||||
;; Find next sibling matching a selector (or any sibling).
|
||||
(define
|
||||
hs-toggle-style-cycle!
|
||||
(fn
|
||||
(target prop vals)
|
||||
(let
|
||||
((cur (dom-get-style target prop)))
|
||||
(define
|
||||
find-next
|
||||
(fn
|
||||
(remaining)
|
||||
(cond
|
||||
((empty? remaining) (first vals))
|
||||
((= cur (first remaining))
|
||||
(if
|
||||
(empty? (rest remaining))
|
||||
(first vals)
|
||||
(first (rest remaining))))
|
||||
(true (find-next (rest remaining))))))
|
||||
(dom-set-style target prop (find-next vals)))))
|
||||
|
||||
;; Find previous sibling matching a selector.
|
||||
(define
|
||||
hs-take!
|
||||
(fn
|
||||
@@ -122,20 +155,29 @@
|
||||
(dom-set-attr target name attr-val)
|
||||
(dom-set-attr target name ""))))))))
|
||||
|
||||
;; Find next sibling matching a selector (or any sibling).
|
||||
;; First element matching selector within a scope.
|
||||
(define
|
||||
hs-put!
|
||||
(fn
|
||||
(value pos target)
|
||||
(cond
|
||||
((= pos "into") (dom-set-inner-html target value))
|
||||
((= pos "into")
|
||||
(if (list? target) target (dom-set-inner-html target value)))
|
||||
((= pos "before")
|
||||
(dom-insert-adjacent-html target "beforebegin" value))
|
||||
((= pos "after") (dom-insert-adjacent-html target "afterend" value))
|
||||
((= pos "start") (dom-insert-adjacent-html target "afterbegin" value))
|
||||
((= pos "end") (dom-insert-adjacent-html target "beforeend" value)))))
|
||||
((= pos "start")
|
||||
(if
|
||||
(list? target)
|
||||
(append! target value 0)
|
||||
(dom-insert-adjacent-html target "afterbegin" value)))
|
||||
((= pos "end")
|
||||
(if
|
||||
(list? target)
|
||||
(append! target value)
|
||||
(dom-insert-adjacent-html target "beforeend" value))))))
|
||||
|
||||
;; Find previous sibling matching a selector.
|
||||
;; Last element matching selector.
|
||||
(define
|
||||
hs-add-to!
|
||||
(fn
|
||||
@@ -145,7 +187,7 @@
|
||||
(append target (list value))
|
||||
(host-call target "push" value))))
|
||||
|
||||
;; First element matching selector within a scope.
|
||||
;; First/last within a specific scope.
|
||||
(define
|
||||
hs-remove-from!
|
||||
(fn
|
||||
@@ -155,16 +197,18 @@
|
||||
(filter (fn (x) (not (= x value))) target)
|
||||
(host-call target "splice" (host-call target "indexOf" value) 1))))
|
||||
|
||||
;; Last element matching selector.
|
||||
(define
|
||||
hs-set-on!
|
||||
(fn
|
||||
(props target)
|
||||
(for-each (fn (k) (host-set! target k (get props k))) (keys props))))
|
||||
|
||||
;; First/last within a specific scope.
|
||||
;; ── Iteration ───────────────────────────────────────────────────
|
||||
|
||||
;; Repeat a thunk N times.
|
||||
(define hs-navigate! (fn (url) (perform (list (quote io-navigate) url))))
|
||||
|
||||
;; Repeat forever (until break — relies on exception/continuation).
|
||||
(define
|
||||
hs-scroll!
|
||||
(fn
|
||||
@@ -177,31 +221,41 @@
|
||||
((= position "bottom") (dict :block "end"))
|
||||
(true (dict :block "start")))))))
|
||||
|
||||
;; ── Iteration ───────────────────────────────────────────────────
|
||||
;; ── Fetch ───────────────────────────────────────────────────────
|
||||
|
||||
;; Repeat a thunk N times.
|
||||
;; Fetch a URL, parse response according to format.
|
||||
;; (hs-fetch url format) — format is "json" | "text" | "html"
|
||||
(define
|
||||
hs-halt!
|
||||
(fn
|
||||
(mode)
|
||||
(when
|
||||
event
|
||||
(host-call event "preventDefault" (list))
|
||||
(when (= mode "event") (host-call event "stopPropagation" (list))))))
|
||||
|
||||
;; Repeat forever (until break — relies on exception/continuation).
|
||||
(define hs-select! (fn (target) (host-call target "select" (list))))
|
||||
|
||||
;; ── Fetch ───────────────────────────────────────────────────────
|
||||
|
||||
;; Fetch a URL, parse response according to format.
|
||||
;; (hs-fetch url format) — format is "json" | "text" | "html"
|
||||
(define hs-reset! (fn (target) (host-call target "reset" (list))))
|
||||
(cond
|
||||
((= mode "default") (host-call event "preventDefault"))
|
||||
((= mode "bubbling") (host-call event "stopPropagation"))
|
||||
(true
|
||||
(do
|
||||
(host-call event "preventDefault")
|
||||
(host-call event "stopPropagation")))))))
|
||||
|
||||
;; ── Type coercion ───────────────────────────────────────────────
|
||||
|
||||
;; Coerce a value to a type by name.
|
||||
;; (hs-coerce value type-name) — type-name is "Int", "Float", "String", etc.
|
||||
(define hs-select! (fn (target) (host-call target "select" (list))))
|
||||
|
||||
;; ── Object creation ─────────────────────────────────────────────
|
||||
|
||||
;; Make a new object of a given type.
|
||||
;; (hs-make type-name) — creates empty object/collection
|
||||
(define hs-reset! (fn (target) (host-call target "reset" (list))))
|
||||
|
||||
;; ── Behavior installation ───────────────────────────────────────
|
||||
|
||||
;; Install a behavior on an element.
|
||||
;; A behavior is a function that takes (me ...params) and sets up features.
|
||||
;; (hs-install behavior-fn me ...args)
|
||||
(define
|
||||
hs-next
|
||||
(fn
|
||||
@@ -221,10 +275,10 @@
|
||||
(true (find-next (dom-next-sibling el))))))
|
||||
(find-next sibling)))))
|
||||
|
||||
;; ── Object creation ─────────────────────────────────────────────
|
||||
;; ── Measurement ─────────────────────────────────────────────────
|
||||
|
||||
;; Make a new object of a given type.
|
||||
;; (hs-make type-name) — creates empty object/collection
|
||||
;; Measure an element's bounding rect, store as local variables.
|
||||
;; Returns a dict with x, y, width, height, top, left, right, bottom.
|
||||
(define
|
||||
hs-previous
|
||||
(fn
|
||||
@@ -244,27 +298,18 @@
|
||||
(true (find-prev (dom-get-prop el "previousElementSibling"))))))
|
||||
(find-prev sibling)))))
|
||||
|
||||
;; ── Behavior installation ───────────────────────────────────────
|
||||
|
||||
;; Install a behavior on an element.
|
||||
;; A behavior is a function that takes (me ...params) and sets up features.
|
||||
;; (hs-install behavior-fn me ...args)
|
||||
(define
|
||||
hs-query-all
|
||||
(fn (sel) (host-call (dom-body) "querySelectorAll" sel)))
|
||||
|
||||
;; ── Measurement ─────────────────────────────────────────────────
|
||||
|
||||
;; Measure an element's bounding rect, store as local variables.
|
||||
;; Returns a dict with x, y, width, height, top, left, right, bottom.
|
||||
(define
|
||||
hs-query-first
|
||||
(fn (sel) (host-call (host-global "document") "querySelector" sel)))
|
||||
|
||||
;; ── Transition ──────────────────────────────────────────────────
|
||||
|
||||
;; Transition a CSS property to a value, optionally with duration.
|
||||
;; (hs-transition target prop value duration)
|
||||
(define
|
||||
hs-query-all
|
||||
(fn (sel) (host-call (dom-body) "querySelectorAll" sel)))
|
||||
|
||||
(define
|
||||
hs-query-first
|
||||
(fn (sel) (host-call (host-global "document") "querySelector" sel)))
|
||||
|
||||
(define
|
||||
hs-query-last
|
||||
(fn
|
||||
@@ -289,21 +334,95 @@
|
||||
(n thunk)
|
||||
(define
|
||||
do-repeat
|
||||
(fn (i) (when (< i n) (do (thunk) (do-repeat (+ i 1))))))
|
||||
(fn
|
||||
(i)
|
||||
(when
|
||||
(< i n)
|
||||
(let
|
||||
((signal (guard (e ((or (= (str e) "hs-break") (= (str e) "hs-continue")) (str e)) (true (raise e))) (do (thunk) nil))))
|
||||
(cond
|
||||
((= signal "hs-break") nil)
|
||||
((= signal "hs-continue") (do-repeat (+ i 1)))
|
||||
(true (do-repeat (+ i 1))))))))
|
||||
(do-repeat 0)))
|
||||
|
||||
(define
|
||||
hs-repeat-forever
|
||||
(fn
|
||||
(thunk)
|
||||
(define do-forever (fn () (thunk) (do-forever)))
|
||||
(define
|
||||
do-forever
|
||||
(fn
|
||||
()
|
||||
(let
|
||||
((signal (guard (e ((or (= (str e) "hs-break") (= (str e) "hs-continue")) (str e)) (true (raise e))) (do (thunk) nil))))
|
||||
(cond
|
||||
((= signal "hs-break") nil)
|
||||
((= signal "hs-continue") (do-forever))
|
||||
(true (do-forever))))))
|
||||
(do-forever)))
|
||||
|
||||
(define
|
||||
hs-repeat-while
|
||||
(fn
|
||||
(cond-fn thunk)
|
||||
(when (cond-fn) (thunk) (hs-repeat-while cond-fn thunk))))
|
||||
(when
|
||||
(cond-fn)
|
||||
(let
|
||||
((signal (guard (e ((or (= (str e) "hs-break") (= (str e) "hs-continue")) (str e)) (true (raise e))) (do (thunk) nil))))
|
||||
(cond
|
||||
((= signal "hs-break") nil)
|
||||
((= signal "hs-continue") (hs-repeat-while cond-fn thunk))
|
||||
(true (hs-repeat-while cond-fn thunk)))))))
|
||||
|
||||
(define
|
||||
hs-repeat-until
|
||||
(fn
|
||||
(cond-fn thunk)
|
||||
(let
|
||||
((signal (guard (e ((or (= (str e) "hs-break") (= (str e) "hs-continue")) (str e)) (true (raise e))) (do (thunk) nil))))
|
||||
(cond
|
||||
((= signal "hs-break") nil)
|
||||
((= signal "hs-continue")
|
||||
(if (cond-fn) nil (hs-repeat-until cond-fn thunk)))
|
||||
(true (if (cond-fn) nil (hs-repeat-until cond-fn thunk)))))))
|
||||
|
||||
(define
|
||||
hs-for-each
|
||||
(fn
|
||||
(fn-body collection)
|
||||
(let
|
||||
((items (cond ((list? collection) collection) ((dict? collection) (keys collection)) ((nil? collection) (list)) (true (list)))))
|
||||
(define
|
||||
do-loop
|
||||
(fn
|
||||
(remaining)
|
||||
(when
|
||||
(not (empty? remaining))
|
||||
(let
|
||||
((signal (guard (e ((or (= (str e) "hs-break") (= (str e) "hs-continue")) (str e)) (true (raise e))) (do (fn-body (first remaining)) nil))))
|
||||
(cond
|
||||
((= signal "hs-break") nil)
|
||||
((= signal "hs-continue") (do-loop (rest remaining)))
|
||||
(true (do-loop (rest remaining))))))))
|
||||
(do-loop items))))
|
||||
|
||||
(begin
|
||||
(define
|
||||
hs-append
|
||||
(fn
|
||||
(target value)
|
||||
(cond
|
||||
((string? target) (str target value))
|
||||
((list? target) (append target (list value)))
|
||||
(true (str target value)))))
|
||||
(define
|
||||
hs-append!
|
||||
(fn (value target) (dom-insert-adjacent-html target "beforeend" value))))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(define
|
||||
hs-fetch
|
||||
@@ -399,7 +518,8 @@
|
||||
(map (fn (k) (list k (get value k))) (keys value))
|
||||
value))
|
||||
(true value))))
|
||||
|
||||
;; ── Sandbox/test runtime additions ──────────────────────────────
|
||||
;; Property access — dot notation and .length
|
||||
(define
|
||||
hs-add
|
||||
(fn
|
||||
@@ -409,7 +529,7 @@
|
||||
((list? b) (cons a b))
|
||||
((or (string? a) (string? b)) (str a b))
|
||||
(true (+ a b)))))
|
||||
|
||||
;; DOM query stub — sandbox returns empty list
|
||||
(define
|
||||
hs-make
|
||||
(fn
|
||||
@@ -420,17 +540,15 @@
|
||||
((= type-name "Set") (list))
|
||||
((= type-name "Map") (dict))
|
||||
(true (dict)))))
|
||||
|
||||
;; Method dispatch — obj.method(args)
|
||||
(define hs-install (fn (behavior-fn) (behavior-fn me)))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;; ── 0.9.90 features ─────────────────────────────────────────────
|
||||
;; beep! — debug logging, returns value unchanged
|
||||
(define
|
||||
hs-measure
|
||||
(fn (target) (perform (list (quote io-measure) target))))
|
||||
|
||||
;; Property-based is — check obj.key truthiness
|
||||
(define
|
||||
hs-transition
|
||||
(fn
|
||||
@@ -443,8 +561,7 @@
|
||||
(str prop " " (/ duration 1000) "s")))
|
||||
(dom-set-style target prop value)
|
||||
(when duration (hs-settle target))))
|
||||
;; ── Sandbox/test runtime additions ──────────────────────────────
|
||||
;; Property access — dot notation and .length
|
||||
;; Array slicing (inclusive both ends)
|
||||
(define
|
||||
hs-transition-from
|
||||
(fn
|
||||
@@ -458,7 +575,7 @@
|
||||
(str prop " " (/ duration 1000) "s")))
|
||||
(dom-set-style target prop (str to-val))
|
||||
(when duration (hs-settle target))))
|
||||
;; DOM query stub — sandbox returns empty list
|
||||
;; Collection: sorted by
|
||||
(define
|
||||
hs-type-check
|
||||
(fn
|
||||
@@ -478,33 +595,31 @@
|
||||
(= (host-typeof value) "element")
|
||||
(= (host-typeof value) "text")))
|
||||
(true (= (host-typeof value) (downcase type-name)))))))
|
||||
;; Method dispatch — obj.method(args)
|
||||
;; Collection: sorted by descending
|
||||
(define
|
||||
hs-type-check-strict
|
||||
(fn
|
||||
(value type-name)
|
||||
(if (nil? value) false (hs-type-check value type-name))))
|
||||
|
||||
;; ── 0.9.90 features ─────────────────────────────────────────────
|
||||
;; beep! — debug logging, returns value unchanged
|
||||
;; Collection: split by
|
||||
(define
|
||||
hs-strict-eq
|
||||
(fn (a b) (and (= (type-of a) (type-of b)) (= a b))))
|
||||
;; Property-based is — check obj.key truthiness
|
||||
;; Collection: joined by
|
||||
(define
|
||||
hs-eq-ignore-case
|
||||
(fn (a b) (= (downcase (str a)) (downcase (str b)))))
|
||||
;; Array slicing (inclusive both ends)
|
||||
|
||||
(define
|
||||
hs-starts-with-ic?
|
||||
(fn (str prefix) (starts-with? (downcase str) (downcase prefix))))
|
||||
;; Collection: sorted by
|
||||
|
||||
(define
|
||||
hs-contains-ignore-case?
|
||||
(fn
|
||||
(haystack needle)
|
||||
(contains? (downcase (str haystack)) (downcase (str needle)))))
|
||||
;; Collection: sorted by descending
|
||||
|
||||
(define
|
||||
hs-falsy?
|
||||
(fn
|
||||
@@ -516,7 +631,7 @@
|
||||
((and (list? v) (= (len v) 0)) true)
|
||||
((= v 0) true)
|
||||
(true false))))
|
||||
;; Collection: split by
|
||||
|
||||
(define
|
||||
hs-matches?
|
||||
(fn
|
||||
@@ -527,7 +642,7 @@
|
||||
((= (host-typeof target) "element")
|
||||
(if (string? pattern) (host-call target "matches" pattern) false))
|
||||
(true false))))
|
||||
;; Collection: joined by
|
||||
|
||||
(define
|
||||
hs-contains?
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user