Compare commits
29 commits
Author | SHA1 | Date | |
---|---|---|---|
|
f2517187bf | ||
|
76a32f63e5 | ||
|
9e1feb81af | ||
|
6b56464bd6 | ||
|
c48f9868c6 | ||
|
3129a212b3 | ||
|
7aebb5bbb0 | ||
|
ab527ad5a1 | ||
|
a0e46da91e | ||
|
64dd057f74 | ||
|
d5baa2eb30 | ||
|
30f63ba08d | ||
|
74f2c92b17 | ||
|
1857a18ee9 | ||
|
982ffadaea | ||
|
04df449d6f | ||
|
cb968d06e3 | ||
|
c57a5f9285 | ||
|
c4d7e74d2d | ||
|
e8670cb1c8 | ||
|
f92e23d8f2 | ||
|
9a83349d69 | ||
|
c039781058 | ||
|
a9c0373fe4 | ||
|
b01eb6b5eb | ||
|
31b3719920 | ||
|
2a9cea17b4 | ||
|
86a54ab37c | ||
|
3845e9962a |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -17,3 +17,5 @@ gh-pages/
|
|||
/.clj-kondo/.cache
|
||||
/.clj-kondo/rewrite-clj
|
||||
/plugins/demo/resources/public/js/
|
||||
.portal
|
||||
resources/public/test/scratch.html
|
||||
|
|
23
CHANGELOG.md
23
CHANGELOG.md
|
@ -5,15 +5,30 @@
|
|||
<!-- To create a new NPM release: -->
|
||||
|
||||
<!-- - Run `bb npm-publish`: this will compile, bump patch version, create tag and and push to npm and Github -->
|
||||
<!-- - `bb replace-version 0.6.21 0.6.22` -->
|
||||
<!-- - `bb replace-version 0.6.22 0.7.23` -->
|
||||
<!-- - Create Github release with updated links from `doc/links.md` -->
|
||||
<!-- - `bb gh-pages` -->
|
||||
|
||||
## v0.7.27 (2025-08-21)
|
||||
|
||||
- [#95](https://github.com/babashka/scittle/issues/121): support string requires
|
||||
of `globalThis` js deps ([@chr15m](https://github.com/chr15m)). See
|
||||
[docs](https://github.com/babashka/scittle/blob/main/doc/js-libraries.md).
|
||||
- Potentially breaking: `(.-foo-bar {})` now behaves as `{}.foo_bar`, i.e. the property or method name is munged.
|
||||
|
||||
## v0.7.26 (2025-08-20)
|
||||
|
||||
- [#121](https://github.com/babashka/scittle/issues/121): add `cjohansen/dataspex` plugin ([@jeroenvandijk](https://github.com/jeroenvandijk))
|
||||
- [#118](https://github.com/babashka/scittle/issues/118): add `goog.string/format` ([@jeroenvandijk](https://github.com/jeroenvandijk))
|
||||
- Support alternative `(set! #js {} -a 1)` CLJS syntax (by bumping SCI)
|
||||
- Add source maps to distribution
|
||||
- Add dev versions of all modules in the `dev` folder of the distribution + a `dev/scitte.cljs-devtools.js` module
|
||||
|
||||
## v0.7.23 (2025-06-18)
|
||||
|
||||
- [#107](https://github.com/babashka/scittle/issues/107): add `replicant` plugin
|
||||
- [#102](https://github.com/babashka/scittle/issues/102): add `applied-science/js-interop` plugin
|
||||
- [#105](https://github.com/babashka/scittle/issues/105): add `goog.string/htmlEscape`
|
||||
- [#107](https://github.com/babashka/scittle/issues/107): add `replicant` plugin ([@jeroenvandijk](https://github.com/jeroenvandijk))
|
||||
- [#102](https://github.com/babashka/scittle/issues/102): add `applied-science/js-interop` plugin ([@chr15m](https://github.com/chr15m))
|
||||
- [#105](https://github.com/babashka/scittle/issues/105): add `goog.string/htmlEscape` ([@ikappaki](https://github.com/ikappaki) )
|
||||
- [#113](https://github.com/babashka/scittle/issues/113): add `unchecked-set` and `unchecked-get`
|
||||
|
||||
## v0.6.22 (2024-12-19)
|
||||
|
|
|
@ -29,6 +29,10 @@ babashka or Clojure JVM):
|
|||
|
||||
See [doc/nrepl](doc/nrepl).
|
||||
|
||||
### Service worker
|
||||
|
||||
See [doc/serviceworker.md](doc/serviceworker.md).
|
||||
|
||||
## Tasks
|
||||
|
||||
Run `bb tasks` to see all available tasks:
|
||||
|
|
8
bb.edn
8
bb.edn
|
@ -44,9 +44,11 @@
|
|||
:depends [prod]
|
||||
:task (do
|
||||
(fs/delete-tree "dist")
|
||||
(fs/create-dirs "dist")
|
||||
(run! (fn [f] (fs/copy f "dist"))
|
||||
(fs/glob "resources/public/js" "*.js")))}
|
||||
(fs/create-dirs "dist/dev")
|
||||
(run! (fn [f] (fs/copy f "dist" {:replace-existing true}))
|
||||
(fs/glob "resources/public/js" "*.{js,js.map}"))
|
||||
(run! (fn [f] (fs/copy f "dist/dev" {:replace-existing true}))
|
||||
(fs/glob "resources/public/js/dev" "*.{js,js.map}")))}
|
||||
|
||||
bump-version {:doc "Bumps package.json and pushes new git tag"
|
||||
:task (do (shell "npm version patch")
|
||||
|
|
|
@ -69,4 +69,15 @@
|
|||
* :action - compile action, defaults to release, but may also be compile or watch"
|
||||
[{:keys [action
|
||||
args] :or {action "release"}}]
|
||||
(build* (format "-M -m shadow.cljs.devtools.cli --force-spawn %s main %s" action (str/join " " args))))
|
||||
(build* (format "-M -m shadow.cljs.devtools.cli --force-spawn %s main %s" action (str/join " " args)))
|
||||
(when (= "release" action)
|
||||
(println "Also building dev release build")
|
||||
(build* (format "-M -m shadow.cljs.devtools.cli --force-spawn %s main %s %s"
|
||||
action
|
||||
"--config-merge '{:compiler-options {:optimizations :simple
|
||||
:pretty-print true
|
||||
:pseudo-names true}
|
||||
:output-dir \"resources/public/js/dev\"
|
||||
:modules {:scittle.cljs-devtools {:entries [scittle.cljs-devtools]
|
||||
:depends-on #{:scittle}}}}'"
|
||||
(str/join " " args)))))
|
||||
|
|
8
deps.edn
8
deps.edn
|
@ -1,9 +1,9 @@
|
|||
{:paths ["src" "resources"]
|
||||
:deps
|
||||
{org.clojure/clojure {:mvn/version "1.11.1"}
|
||||
thheller/shadow-cljs {:mvn/version "2.20.15"}
|
||||
thheller/shadow-cljs {:mvn/version "3.1.8"}
|
||||
org.babashka/sci {:git/url "https://github.com/babashka/sci"
|
||||
:git/sha "87fa2d2648ef809e8c8c87279c51961dca41ed4d"}
|
||||
:git/sha "756376056b32198d96dd5b272cee8fc483db60df"}
|
||||
#_{:local/root "../babashka/sci"}
|
||||
reagent/reagent {:mvn/version "1.1.1"}
|
||||
no.cjohansen/replicant {:mvn/version "2025.03.27"}
|
||||
|
@ -21,7 +21,9 @@
|
|||
io.github.babashka/sci.configs
|
||||
#_{:local/root "/Users/borkdude/dev/sci.configs"}
|
||||
{:git/url "https://github.com/babashka/sci.configs"
|
||||
:git/sha "1ade6f94a2902211bed1f876472571da0c5e7278"}}
|
||||
:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
|
||||
:exclusions [org.babashka/sci]}
|
||||
binaryage/devtools {:mvn/version "1.0.7"}}
|
||||
:aliases
|
||||
{:dev
|
||||
{:extra-paths ["dev"]
|
||||
|
|
10
doc/dev.md
10
doc/dev.md
|
@ -90,20 +90,20 @@ To create a new NPM release:
|
|||
|
||||
- Prepare version `package.json`, except patch (if anything should change here)
|
||||
- Run `bb npm-publish`: this will compile, bump patch version, create tag and and push to npm and Github
|
||||
- `bb replace-version 0.6.16 0.6.22`
|
||||
- `bb replace-version 0.6.16 0.7.27`
|
||||
- Create Github release with updated links from `doc/links.md`
|
||||
- `bb gh-pages`
|
||||
|
||||
<!-- To upgrade examples: -->
|
||||
|
||||
<!-- ``` -->
|
||||
<!-- rg '0.0.1' --files-with-matches | xargs sed -i '' 's/0.0.6.22.1.0/g' -->
|
||||
<!-- rg '0.0.1' --files-with-matches | xargs sed -i '' 's/0.0.7.27.1.0/g' -->
|
||||
<!-- bb release -->
|
||||
<!-- cd gh-pages -->
|
||||
<!-- git checkout -b v0.6.22 -->
|
||||
<!-- git push --set-upstream origin v0.6.22 -->
|
||||
<!-- git checkout -b v0.7.27 -->
|
||||
<!-- git push --set-upstream origin v0.7.27 -->
|
||||
<!-- git checkout gh-pages -->
|
||||
<!-- cd .. -->
|
||||
<!-- ``` -->
|
||||
|
||||
<!-- Then make a new release on Github with the `v0.6.22` tag. -->
|
||||
<!-- Then make a new release on Github with the `v0.7.27` tag. -->
|
||||
|
|
49
doc/js-libraries.md
Normal file
49
doc/js-libraries.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
# Loading JS libraries
|
||||
|
||||
Since `v0.7.27` scittle allows to load libraries from the global enviroment.
|
||||
This means you can load a library in a `<script>` tag and use it via `:require` in scittle.
|
||||
|
||||
An example:
|
||||
|
||||
``` html
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/js-confetti@latest/dist/js-confetti.browser.js"></script>
|
||||
<script type="application/x-scittle">
|
||||
(require '["JSConfetti" :as confetti])
|
||||
(.addConfetti (confetti.))
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## ES modules
|
||||
|
||||
The async nature of ES modules makes them a litte bit more difficult to work
|
||||
with in scittle. You need to disable automatic evaluation of script tags first
|
||||
using `scittle.core.disable_auto_eval()`. In a `module` type `<script>` tag you
|
||||
can then load ES modules, attach them to the global object and manually invoke
|
||||
`scittle.core.eval_script_tags();` when setup is completed.
|
||||
|
||||
``` html
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
|
||||
<script>scittle.core.disable_auto_eval()</script>
|
||||
<script type="module">
|
||||
import confetti from "https://esm.sh/canvas-confetti@1.6.0"
|
||||
globalThis.JSConfetti = confetti;
|
||||
scittle.core.eval_script_tags();
|
||||
</script>
|
||||
<script type="application/x-scittle">
|
||||
(require '["JSConfetti" :as confetti])
|
||||
(confetti)
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
```
|
27
doc/links.md
27
doc/links.md
|
@ -1,7 +1,20 @@
|
|||
https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.cljs-ajax.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.reagent.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.re-frame.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.promesa.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.pprint.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.nrepl.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js-interop.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.cljs-ajax.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.reagent.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.re-frame.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.replicant.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.promesa.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.pprint.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.nrepl.js
|
||||
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.js-interop.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.cljs-ajax.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.reagent.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.re-frame.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.replicant.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.promesa.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.pprint.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.nrepl.js
|
||||
https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/dev/scittle.cljs-devtools.js
|
||||
|
|
|
@ -21,7 +21,7 @@ the normal routine:
|
|||
|
||||
``` html
|
||||
<script>var SCITTLE_NREPL_WEBSOCKET_PORT = 1340;</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.nrepl.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.nrepl.js" type="application/javascript"></script>
|
||||
```
|
||||
|
||||
Also include the CLJS file that you want to evaluate with nREPL:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{:deps {io.github.babashka/sci.nrepl
|
||||
{:git/sha "2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23"}
|
||||
#_{:local/root "/Users/borkdude/dev/sci.nrepl"}
|
||||
{:git/sha "4f7f6d652a71b5bdc0c110313a4908d956e7a97d"}
|
||||
io.github.babashka/http-server
|
||||
{:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}}
|
||||
:tasks {http-server {:doc "Starts http server for serving static files"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
|
||||
<script>var SCITTLE_NREPL_WEBSOCKET_PORT = 1340;</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.nrepl.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.nrepl.js" type="application/javascript"></script>
|
||||
<script type="application/x-scittle" src="playground.cljs"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
26
doc/serviceworker.md
Normal file
26
doc/serviceworker.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Scittle in a service worker
|
||||
|
||||
You can use Scittle to bootstrap a ClojureScript based service worker.
|
||||
|
||||
Put the following code into e.g. `scittle-sw.js` to create a JavaScript based service worker, load Scittle, then fetch your script and eval it.
|
||||
|
||||
```javascript
|
||||
importScripts("scittle.min.js");
|
||||
|
||||
const request = await fetch("sw.cljs");
|
||||
const text = await request.text();
|
||||
const result = scittle.core.eval_string(text);
|
||||
```
|
||||
|
||||
Then load `scittle-sw.js` in your HTML:
|
||||
|
||||
```html
|
||||
<script>
|
||||
if('serviceWorker' in navigator)
|
||||
navigator.serviceWorker.register('scittle-sw.js');
|
||||
</script>
|
||||
```
|
||||
|
||||
This will load `sw.cljs` and eval it in the context of the service worker.
|
||||
|
||||
A ready-made example can be found at [chr15m/scittle-template-serviceworker](https://github.com/chr15m/scittle-template-serviceworker).
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -8,7 +8,7 @@
|
|||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1"
|
||||
},
|
||||
"version": "0.7.23"
|
||||
"version": "0.7.27"
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "4.0.0",
|
||||
|
@ -129,5 +129,5 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"version": "0.7.23"
|
||||
"version": "0.7.27"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "scittle",
|
||||
"version": "0.7.23",
|
||||
"version": "0.7.27",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{:deps
|
||||
{datascript/datascript {:mvn/version "1.3.12"}
|
||||
io.github.babashka/sci.configs {:git/sha "33bd51e53700b224b4cb5bda59eb21b62f962745"}}}
|
||||
io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
|
||||
:exclusions [org.babashka/sci]}}}
|
||||
|
|
8
plugins/dataspex/deps.edn
Normal file
8
plugins/dataspex/deps.edn
Normal file
|
@ -0,0 +1,8 @@
|
|||
{:deps
|
||||
{no.cjohansen/dataspex {:git/url "https://github.com/cjohansen/dataspex"
|
||||
:git/sha "02112200651c2bd932907bb69fba1ff50b881741"
|
||||
:exclusions [ring/ring-core
|
||||
ring/ring-jetty-adapter
|
||||
com.cognitect/transit-clj]}
|
||||
io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
|
||||
:exclusions [org.babashka/sci]}}}
|
9
plugins/dataspex/src/scittle/dataspex.cljs
Normal file
9
plugins/dataspex/src/scittle/dataspex.cljs
Normal file
|
@ -0,0 +1,9 @@
|
|||
(ns scittle.dataspex
|
||||
{:no-doc true}
|
||||
(:require [sci.configs.cjohansen.dataspex :refer [config]]
|
||||
[scittle.core :as scittle]))
|
||||
|
||||
(defn init []
|
||||
(scittle/register-plugin!
|
||||
::dataspex
|
||||
config))
|
8
plugins/dataspex/src/scittle_plugin.edn
Normal file
8
plugins/dataspex/src/scittle_plugin.edn
Normal file
|
@ -0,0 +1,8 @@
|
|||
[{:name scittle/dataspex
|
||||
:namespaces [dataspex.core]
|
||||
:js "./scittle.dataspex.js"
|
||||
:shadow-config
|
||||
{:modules
|
||||
{:scittle.dataspex {:init-fn scittle.dataspex/init
|
||||
:depends-on #{:scittle :scittle.datascript}
|
||||
:entries [dataspex.core]}}}}]
|
|
@ -1,6 +1,7 @@
|
|||
{:deps {io.github.babashka/scittle.build {:local/root "../../build"}
|
||||
;; datascript plugin
|
||||
; io.github.babashka/scittle.datascript {:local/root "../../plugins/datascript"}
|
||||
io.github.babashka/scittle.dataspex {:local/root "../../plugins/dataspex"}
|
||||
io.github.babashka/scittle.javelin {:local/root "../../plugins/javelin"}
|
||||
io.github.babashka/scittle.hoplon {:local/root "../../plugins/hoplon"}
|
||||
io.github.babashka/http-server
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{:deps
|
||||
{hoplon/hoplon {:mvn/version "7.5.0"}
|
||||
io.github.babashka/sci.configs {:git/sha "08bab21643bc0c63a5b99c65193c9d24888270b7"}}}
|
||||
io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
|
||||
:exclusions [org.babashka/sci]}}}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{:deps
|
||||
{hoplon/javelin {:mvn/version "3.9.3"}
|
||||
io.github.babashka/sci.configs {:git/sha "08bab21643bc0c63a5b99c65193c9d24888270b7"}}}
|
||||
io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
|
||||
:exclusions [org.babashka/sci]}}}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
|
||||
;; Trigger the first render by initializing the game.
|
||||
(start-new-game store)))
|
||||
|
||||
(main)
|
||||
|
||||
(main)
|
|
@ -1,13 +1,13 @@
|
|||
<html>
|
||||
<head>
|
||||
<script async src="https://ga.jspm.io/npm:es-module-shims@1.6.1/dist/es-module-shims.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js"></script>
|
||||
<script>scittle.core.disable_auto_eval();</script>
|
||||
<script crossorigin src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script>
|
||||
<script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.reagent.js"> </script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.re-frame.js"> </script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.promesa.js"> </script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.reagent.js"> </script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.re-frame.js"> </script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.promesa.js"> </script>
|
||||
|
||||
<script type="importmap">
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.cljs-ajax.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.cljs-ajax.js" type="application/javascript"></script>
|
||||
<script type="application/x-scittle">
|
||||
(require '[ajax.core :refer [GET]])
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
|
||||
<script type="application/x-scittle">
|
||||
(defn my-alert []
|
||||
(js/alert "You clicked!"))
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
|
||||
<script crossorigin src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script>
|
||||
<script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.6.22/dist/scittle.reagent.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.reagent.js" type="application/javascript"></script>
|
||||
<script type="application/x-scittle">
|
||||
(require '[reagent.core :as r]
|
||||
'[reagent.dom :as rdom])
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
|
||||
To embed scittle in your website, it is recommended to use the links
|
||||
published to
|
||||
the <a href="https://github.com/babashka/scittle/releases/tag/v0.6.22">releases
|
||||
the <a href="https://github.com/babashka/scittle/releases/tag/v0.7.27">releases
|
||||
page</a>.
|
||||
|
||||
Include <tt>scittle.js</tt> and write a <tt>script</tt> tag
|
||||
|
@ -160,6 +160,12 @@
|
|||
(js/console.log "In cljs"))
|
||||
</code></pre>
|
||||
|
||||
<a name="JS libraries"></a>
|
||||
<h2><a href="#js-libraries">JS libraries</a></h2>
|
||||
|
||||
To use JavaScript libraries with Scittle,
|
||||
see <a href="https://github.com/babashka/scittle/blob/main/doc/js-libraries.md">README.md</a>
|
||||
|
||||
<a name="repl"></a>
|
||||
<h2><a href="#nrepl">REPL</a></h2>
|
||||
|
||||
|
|
13
resources/public/index_text.html
Normal file
13
resources/public/index_text.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="js/scittle.js" type="application/javascript"></script>
|
||||
<script src="js/scittle.cljs-devtools.js" type="application/javascript"></script>
|
||||
<script type="application/x-scittle">
|
||||
(js/console.log {:a 1})
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -5,9 +5,9 @@
|
|||
<script src="js/scittle.js" type="application/javascript"></script>
|
||||
<script src="js/scittle.replicant.js" type="application/javascript"></script>
|
||||
|
||||
<script type="application/x-scittle" src="cljs/replicant-tictactoe/ui.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant-tictactoe/game.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant-tictactoe/core.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant_tictactoe/ui.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant_tictactoe/game.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant_tictactoe/core.cljs"></script>
|
||||
<link rel="stylesheet" href="cljs/replicant-tictactoe/style.css">
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js" type="text/javascript"></script>
|
||||
|
@ -25,9 +25,9 @@
|
|||
from <a href="cljs/replicant_tictactoe/core.cljs"><tt>cljs/replicant_tictactoe/core.cljs</tt></a> using the
|
||||
script tag:
|
||||
<pre><code class="html">
|
||||
<script type="application/x-scittle" src="cljs/replicant-tictactoe/ui.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant-tictactoe/game.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant-tictactoe/core.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant_tictactoe/ui.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant_tictactoe/game.cljs"></script>
|
||||
<script type="application/x-scittle" src="cljs/replicant_tictactoe/core.cljs"></script>
|
||||
|
||||
</code></pre>
|
||||
</p>
|
||||
|
@ -39,7 +39,7 @@
|
|||
(.highlightAll js/hljs)))
|
||||
(def oreq (js/XMLHttpRequest.))
|
||||
(.addEventListener oreq "load" set-text)
|
||||
(.open oreq "GET" "cljs/replicant-tictactoe/core.cljs")
|
||||
(.open oreq "GET" "cljs/replicant_tictactoe/core.cljs")
|
||||
(.send oreq)
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
(fs/copy "resources/public/codemirror.html" "gh-pages"
|
||||
{:replace-existing true})
|
||||
|
||||
|
||||
(fs/copy "resources/public/replicant_tictactoe.html" "gh-pages"
|
||||
{:replace-existing true})
|
||||
|
||||
|
@ -65,8 +65,8 @@
|
|||
{:replace-existing true}))
|
||||
(fs/glob cljs-source-dir "*.cljs"))
|
||||
|
||||
(println "Copying dir resources/public/cljs/replicant-tictactoe")
|
||||
(fs/copy-tree (fs/file cljs-source-dir "replicant-tictactoe") (fs/file cljs-target-dir "replicant-tictactoe") {:replace-existing true})
|
||||
(println "Copying dir resources/public/cljs/replicant_tictactoe")
|
||||
(fs/copy-tree (fs/file cljs-source-dir "replicant_tictactoe") (fs/file cljs-target-dir "replicant_tictactoe") {:replace-existing true})
|
||||
|
||||
(run! (fn [f]
|
||||
(println "Copying" (str f))
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
:builds
|
||||
{:main
|
||||
{:target :browser
|
||||
{;; for dev build
|
||||
#_#_:compiler-options {:optimizations :simple
|
||||
:pretty-print true
|
||||
:pseudo-names true}
|
||||
:target :browser
|
||||
:js-options
|
||||
{:resolve {"react" {:target :global
|
||||
:global "React"}
|
||||
|
@ -32,5 +36,5 @@
|
|||
:scittle.cljs-ajax {:entries [scittle.cljs-ajax]
|
||||
:depends-on #{:scittle}}}
|
||||
:build-hooks [(shadow.cljs.build-report/hook)]
|
||||
:output-dir "resources/public/js"
|
||||
:output-dir "resources/public/js" ;; + "/dev" for dev build
|
||||
:devtools {:repl-pprint true}}}}
|
||||
|
|
6
src/scittle/cljs_devtools.cljs
Normal file
6
src/scittle/cljs_devtools.cljs
Normal file
|
@ -0,0 +1,6 @@
|
|||
(ns scittle.cljs-devtools
|
||||
(:require [devtools.core :as devtools]))
|
||||
|
||||
(devtools/set-pref! :disable-advanced-mode-check true)
|
||||
|
||||
(devtools/install!)
|
|
@ -3,6 +3,7 @@
|
|||
(:require [cljs.reader :refer [read-string]]
|
||||
[goog.object :as gobject]
|
||||
[goog.string :as gstring]
|
||||
[goog.string.format]
|
||||
[sci.core :as sci]
|
||||
[sci.ctx-store :as store]
|
||||
[sci.impl.unrestrict]
|
||||
|
@ -46,17 +47,25 @@
|
|||
'abs (sci/copy-var abs cljns)}
|
||||
'goog.object {'set gobject/set
|
||||
'get gobject/get}
|
||||
'goog.string {'htmlEscape gstring/htmlEscape}
|
||||
'goog.string {'format gstring/format
|
||||
'htmlEscape gstring/htmlEscape}
|
||||
'goog.string.format {} ;; For cljs compatibility
|
||||
'sci.core {'stacktrace sci/stacktrace
|
||||
'format-stacktrace sci/format-stacktrace}})
|
||||
|
||||
(defn load-fn [{:keys [ctx] :as opts}]
|
||||
(when-let [lib (and (string? (:namespace opts))
|
||||
(gobject/get js/globalThis (:namespace opts)))]
|
||||
(sci/add-js-lib! ctx (:namespace opts) lib)))
|
||||
|
||||
(store/reset-ctx!
|
||||
(sci/init {:namespaces namespaces
|
||||
:classes {'js js/globalThis
|
||||
:allow :all
|
||||
'Math js/Math}
|
||||
:ns-aliases {'clojure.pprint 'cljs.pprint}
|
||||
:features #{:scittle :cljs}}))
|
||||
:features #{:scittle :cljs}
|
||||
:load-fn load-fn}))
|
||||
|
||||
(unchecked-set js/globalThis "import" (js/eval "(x) => import(x)"))
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
(new js/WebSocket (ws-url (.-hostname (.-location js/window)) ws-port "_nrepl"))))
|
||||
|
||||
(when-let [ws (nrepl-server/nrepl-websocket)]
|
||||
(prn :ws ws)
|
||||
(set! (.-onmessage ws)
|
||||
(fn [event]
|
||||
(nrepl-server/handle-nrepl-message (edn/read-string (.-data event)))))
|
||||
|
|
Loading…
Reference in a new issue