parent
381f3d8234
commit
1bbf579241
|
@ -2,9 +2,13 @@
|
|||
|
||||
[Scittle](https://github.com/babashka/scittle): execute Clojure(Script) directly from browser script tags via SCI!
|
||||
|
||||
## Unreleased
|
||||
|
||||
- [#69](https://github.com/babashka/babashka/issues/69): executing script tag with src + whitespace doesn't work
|
||||
|
||||
## v0.6.15 (2023-05-04)
|
||||
|
||||
- #58: build system for creating scittle distribution with custom libraries. See [plugins/demo](plugins/demo).
|
||||
- [#58](https://github.com/babashka/babashka/issues/58): build system for creating scittle distribution with custom libraries. See [plugins/demo](plugins/demo).
|
||||
- Use `window.location.hostname` for WebSocket connection instead of hardcoding `"localhost"` ([@pyrmont](https://github.com/pyrmont))
|
||||
- Upgrade `sci.configs` to `"33bd51e53700b224b4cb5bda59eb21b62f962745"`
|
||||
- Update nREPL implementation: implement `eldoc` (`info`, `lookup`) ([@benjamin-asdf](https://github.com/benjamin-asdf))
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
[sci.core :as sci]
|
||||
[sci.impl.unrestrict]
|
||||
[scittle.impl.common :refer [cljns]]
|
||||
[scittle.impl.error :as error]))
|
||||
[scittle.impl.error :as error]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(set! sci.impl.unrestrict/*unrestricted* true)
|
||||
|
||||
|
@ -65,15 +66,8 @@
|
|||
|
||||
(defn- eval-script-tags* [script-tags]
|
||||
(when-let [tag (first script-tags)]
|
||||
(if-let [text (not-empty (gobject/get tag "textContent"))]
|
||||
(let [scittle-id (str (gensym "scittle-tag-"))]
|
||||
(gobject/set tag "scittle_id" scittle-id)
|
||||
(swap! !sci-ctx assoc-in [:src scittle-id] text)
|
||||
(sci/binding [sci/file scittle-id]
|
||||
(eval-string text))
|
||||
(eval-script-tags* (rest script-tags)))
|
||||
(let [src (.getAttribute tag "src")
|
||||
req (js/XMLHttpRequest.)
|
||||
(if-let [src (.getAttribute tag "src")]
|
||||
(let [req (js/XMLHttpRequest.)
|
||||
_ (.open req "GET" src true)
|
||||
_ (gobject/set req "onload"
|
||||
(fn [] (this-as this
|
||||
|
@ -84,7 +78,15 @@
|
|||
(sci/binding [sci/file src]
|
||||
(eval-string response)))
|
||||
(eval-script-tags* (rest script-tags)))))]
|
||||
(.send req)))))
|
||||
(.send req))
|
||||
(if-let [text (not-empty (str/trim (gobject/get tag "textContent")))]
|
||||
(let [scittle-id (str (gensym "scittle-tag-"))]
|
||||
(gobject/set tag "scittle_id" scittle-id)
|
||||
(swap! !sci-ctx assoc-in [:src scittle-id] text)
|
||||
(sci/binding [sci/file scittle-id]
|
||||
(eval-string text))
|
||||
(eval-script-tags* (rest script-tags)))
|
||||
(eval-script-tags* (rest script-tags))))))
|
||||
|
||||
(defn ^:export eval-script-tags []
|
||||
(let [script-tags (js/document.querySelectorAll "script[type='application/x-scittle']")]
|
||||
|
|
Loading…
Reference in a new issue