Fix keyboard shortcuts + trigger filter + sx-on event mapping

1. parse-trigger-spec: strip [condition] from event names, store as
   "filter" modifier
2. bind-event: native SX filter for key=='X' patterns (extracts key
   char and checks event.key + not-input guard)
3. bind-event from: modifier: resolve "body"/"document"/"window" to
   direct DOM references instead of dom-query
4. sx-platform-2.js: global keyboard dispatch — WASM host-callbacks
   on document/body don't fire, so keyboard triggers with from:body
   are handled from JS, calling execute-request via K.eval
5. bind-inline-handlers: map afterSwap/beforeRequest to sx: prefix,
   eval JS bodies via Function constructor

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-01 23:19:25 +00:00
parent 235d73d837
commit 683e334546
34 changed files with 278 additions and 118 deletions

View File

@@ -453,7 +453,18 @@
((timer nil)
(last-val nil)
(listen-target
(if (get mods "from") (dom-query (get mods "from")) el)))
(let
((from-sel (get mods "from")))
(cond
(nil? from-sel)
el
(= from-sel "body")
(dom-body)
(= from-sel "document")
(dom-document)
(= from-sel "window")
(dom-window)
:else (dom-query from-sel)))))
(when
listen-target
(dom-add-listener
@@ -462,7 +473,7 @@
(fn
(e)
(let
((should-fire (if (get mods "filter") (host-call (host-call (dom-window) "Function" "event" (get mods "filter")) "call" el e) true)))
((should-fire (if (get mods "filter") (let ((f (get mods "filter"))) (let ((key-match (index-of f "key=='"))) (if (>= key-match 0) (let ((key-char (slice f (+ key-match 5) (+ key-match 6)))) (and (= (host-get e "key") key-char) (not (dom-matches? (host-get e "target") "input,textarea,select")))) true))) true)))
(when
(get mods "changed")
(let
@@ -1492,7 +1503,7 @@
verb-info
(when
(not (dom-has-attr? el "sx-disable"))
(bind-triggers el verb-info)
(do (bind-triggers el verb-info) (bind-preload-for el))
(bind-preload-for el))))))
(define