migrating to js-maker

This commit is contained in:
2026-05-28 08:17:25 +02:00
parent 325e890737
commit 231d30c561
+14 -3
View File
@@ -30,6 +30,7 @@
lru-cache
racket-self-signed-cert
simple-log
js-maker
)
(provide webview-new-context
@@ -396,6 +397,12 @@
#f))
(define-syntax with-id->el
(syntax-rules ()
((_ id el e1 ...)
(js (let ((el (send document getElementById (eval id))))
e1 ...)))))
(define-syntax with-id
(syntax-rules ()
((_ id el
@@ -765,6 +772,7 @@
(define/contract (webview-call-js wv js)
(-> wv-win? string? (or/c string? list? boolean? hash? symbol? number?))
(displayln js)
(let ((result (rkt-webview-call-js (wv-win-handle wv) js)))
(if (webview-call-js-result? result)
(if (eq? (car result) 'oke)
@@ -786,9 +794,12 @@
(-> wv-win? symbol? (or/c string? xexpr?) symbol?)
(if (string? html)
(let ((r (webview-call-js wv
(with-id id el
("el.innerHTML = '~a'; return true;"
(esc-quote html))))))
(with-id->el id el
(set! (js-dot el innerHTML) (eval html))
#t))))
;(with-id id el
; ("el.innerHTML = '~a'; return true;"
; (esc-quote html))))))
(if r 'oke 'failed))
(webview-set-innerHTML! wv id (xexpr->string html))
)