parent
381f3d8234
commit
1bbf579241
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
[Scittle](https://github.com/babashka/scittle): execute Clojure(Script) directly from browser script tags via SCI!
|
[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)
|
## 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))
|
- Use `window.location.hostname` for WebSocket connection instead of hardcoding `"localhost"` ([@pyrmont](https://github.com/pyrmont))
|
||||||
- Upgrade `sci.configs` to `"33bd51e53700b224b4cb5bda59eb21b62f962745"`
|
- Upgrade `sci.configs` to `"33bd51e53700b224b4cb5bda59eb21b62f962745"`
|
||||||
- Update nREPL implementation: implement `eldoc` (`info`, `lookup`) ([@benjamin-asdf](https://github.com/benjamin-asdf))
|
- Update nREPL implementation: implement `eldoc` (`info`, `lookup`) ([@benjamin-asdf](https://github.com/benjamin-asdf))
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
[sci.impl.unrestrict]
|
[sci.impl.unrestrict]
|
||||||
[scittle.impl.common :refer [cljns]]
|
[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)
|
(set! sci.impl.unrestrict/*unrestricted* true)
|
||||||
|
|
||||||
|
@ -65,15 +66,8 @@
|
||||||
|
|
||||||
(defn- eval-script-tags* [script-tags]
|
(defn- eval-script-tags* [script-tags]
|
||||||
(when-let [tag (first script-tags)]
|
(when-let [tag (first script-tags)]
|
||||||
(if-let [text (not-empty (gobject/get tag "textContent"))]
|
(if-let [src (.getAttribute tag "src")]
|
||||||
(let [scittle-id (str (gensym "scittle-tag-"))]
|
(let [req (js/XMLHttpRequest.)
|
||||||
(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.)
|
|
||||||
_ (.open req "GET" src true)
|
_ (.open req "GET" src true)
|
||||||
_ (gobject/set req "onload"
|
_ (gobject/set req "onload"
|
||||||
(fn [] (this-as this
|
(fn [] (this-as this
|
||||||
|
@ -84,7 +78,15 @@
|
||||||
(sci/binding [sci/file src]
|
(sci/binding [sci/file src]
|
||||||
(eval-string response)))
|
(eval-string response)))
|
||||||
(eval-script-tags* (rest script-tags)))))]
|
(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 []
|
(defn ^:export eval-script-tags []
|
||||||
(let [script-tags (js/document.querySelectorAll "script[type='application/x-scittle']")]
|
(let [script-tags (js/document.querySelectorAll "script[type='application/x-scittle']")]
|
||||||
|
|
Loading…
Reference in a new issue