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>
This commit is contained in:
@@ -874,12 +874,15 @@
|
||||
(define
|
||||
hs-fetch
|
||||
(fn
|
||||
(url format do-not-throw)
|
||||
(url format do-not-throw target)
|
||||
(let
|
||||
((fmt (cond ((nil? format) "text") ((or (= format "json") (= format "JSON") (= format "Object")) "json") ((or (= format "html") (= format "HTML")) "html") ((or (= format "response") (= format "Response")) "response") ((or (= format "text") (= format "Text")) "text") ((or (= format "number") (= format "Number")) "number") (true format))))
|
||||
(let
|
||||
((raw (perform (list "io-fetch" url "response" (dict)))))
|
||||
(do
|
||||
(do
|
||||
(when (not (nil? target))
|
||||
(dom-dispatch target "hyperscript:beforeFetch" nil))
|
||||
(let
|
||||
((raw (perform (list "io-fetch" url "response" (dict)))))
|
||||
(do
|
||||
(when (get raw :_network-error) (raise {:response raw :message "Network error" :_hs-error "FetchError"}))
|
||||
(when
|
||||
(and (not (get raw :ok)) (not (= fmt "response")) (not do-not-throw))
|
||||
@@ -897,7 +900,7 @@
|
||||
(parse-number (get raw :_number))
|
||||
(parse-number (get raw :_body))
|
||||
0))
|
||||
(true (get raw :_body))))))))
|
||||
(true (get raw :_body)))))))))
|
||||
|
||||
(define
|
||||
hs-json-escape
|
||||
|
||||
Reference in New Issue
Block a user