Fix #77: make dep on js/document optional
This commit is contained in:
parent
fcc1d1b843
commit
d8cbb5a7ee
2 changed files with 15 additions and 7 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -2,13 +2,17 @@
|
||||||
|
|
||||||
[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
|
## v0.6.17 (2024-04-30)
|
||||||
|
|
||||||
|
- [#77](https://github.com/babashka/babashka/issues/77): make dependency on browser (`js/document`) optional so scittle can run in webworkers, Node.js, etc.
|
||||||
|
|
||||||
|
## v0.6.16 (2024-04-22)
|
||||||
|
|
||||||
- [#69](https://github.com/babashka/babashka/issues/69): executing script tag with src + whitespace doesn't work
|
- [#69](https://github.com/babashka/babashka/issues/69): executing script tag with src + whitespace doesn't work
|
||||||
- [#72](https://github.com/babashka/babashka/issues/72): add clojure 1.11 functions like `update-vals`
|
- [#72](https://github.com/babashka/babashka/issues/72): add clojure 1.11 functions like `update-vals`
|
||||||
- #75: Support reader conditionals in source code
|
- [#75](https://github.com/babashka/babashka/issues/75): Support reader conditionals in source code
|
||||||
|
|
||||||
## v0.6.16 (2023-05-04)
|
## v0.6.15 (2023-05-04)
|
||||||
|
|
||||||
- [#58](https://github.com/babashka/babashka/issues/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))
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
(set! sci.impl.unrestrict/*unrestricted* true)
|
(set! sci.impl.unrestrict/*unrestricted* true)
|
||||||
|
|
||||||
|
;; make document conditional
|
||||||
|
(def ^js doc js/globalThis.document)
|
||||||
|
|
||||||
(clojure.core/defmacro time
|
(clojure.core/defmacro time
|
||||||
"Evaluates expr and prints the time it took. Returns the value of expr."
|
"Evaluates expr and prints the time it took. Returns the value of expr."
|
||||||
[expr]
|
[expr]
|
||||||
|
|
@ -101,7 +104,7 @@
|
||||||
(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 (.querySelectorAll doc "script[type='application/x-scittle']")]
|
||||||
(eval-script-tags* script-tags)))
|
(eval-script-tags* script-tags)))
|
||||||
|
|
||||||
(def auto-load-disabled? (volatile! false))
|
(def auto-load-disabled? (volatile! false))
|
||||||
|
|
@ -113,9 +116,10 @@
|
||||||
[]
|
[]
|
||||||
(vreset! auto-load-disabled? true))
|
(vreset! auto-load-disabled? true))
|
||||||
|
|
||||||
(js/document.addEventListener
|
(when doc
|
||||||
|
(.addEventListener doc
|
||||||
"DOMContentLoaded"
|
"DOMContentLoaded"
|
||||||
(fn [] (when-not @auto-load-disabled? (eval-script-tags))), false)
|
(fn [] (when-not @auto-load-disabled? (eval-script-tags))), false))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
(sci/alter-var-root sci/print-fn (constantly *print-fn*))
|
(sci/alter-var-root sci/print-fn (constantly *print-fn*))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue