Engine: trigger filter support, sx-on event mapping, JS inline handlers

1. parse-trigger-spec: strip [condition] from event names, store as
   "filter" modifier (e.g. keyup[key=='s'] → event="keyup", filter=...)
2. bind-event: evaluate filter conditions via JS Function constructor
   when filter modifier is present
3. bind-inline-handlers: map afterSwap/beforeRequest etc. to sx:*
   event names (matching what the engine dispatches)
4. bind-inline-handlers: detect JS syntax in body (contains ".") and
   eval via Function instead of SX parse — enables this.reset() etc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-01 22:56:24 +00:00
parent 13eb701518
commit 235d73d837
6 changed files with 98 additions and 36 deletions

View File

@@ -63,7 +63,26 @@
(starts-with? tok "from:")
(dict-set! mods "from" (slice tok 5))))
(rest tokens))
(dict "event" (first tokens) "modifiers" mods))))))
(let
((raw-event (first tokens)))
(let
((bracket-idx (index-of raw-event "[")))
(if
(>= bracket-idx 0)
(do
(dict-set!
mods
"filter"
(slice
raw-event
(+ bracket-idx 1)
(- (len raw-event) 1)))
(dict
"event"
(slice raw-event 0 bracket-idx)
"modifiers"
mods))
(dict "event" raw-event "modifiers" mods)))))))))
raw-parts))))))
(define