diff --git a/.gitignore b/.gitignore index e26d706..58fe583 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,3 @@ gh-pages/ /.clj-kondo/.cache /.clj-kondo/rewrite-clj /plugins/demo/resources/public/js/ -.portal -resources/public/test/scratch.html diff --git a/CHANGELOG.md b/CHANGELOG.md index b2fff67..0a77d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,37 +5,15 @@ - + -- [#114](https://github.com/babashka/scittle/issues/114): Enable source maps ([@jeroenvandijk](https://github.com/jeroenvandijk)) -- [#140](https://github.com/babashka/scittle/issues/140): Enable customizing the nrepl websocket port ([@PEZ](https://github.com/PEZ)) - -## v0.7.28 (2025-09-13) - -- [#137](https://github.com/babashka/scittle/issues/137): fix JS interop with reserved JS keyword (incorrectly munged) by bumping SCI - -## 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 ([@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) ) +- [#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` - [#113](https://github.com/babashka/scittle/issues/113): add `unchecked-set` and `unchecked-get` ## v0.6.22 (2024-12-19) diff --git a/README.md b/README.md index 01e1607..a276016 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,6 @@ 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: @@ -50,7 +46,6 @@ release Updates Github pages with new release build. ## Credits Idea by Arne Brasseur a.k.a [plexus](https://github.com/plexus). -Name by Alessandra Sierra (the name occurs first in [this](https://stuartsierra.com/2019/12/21/clojure-start-time-in-2019/) blog post). ## License diff --git a/bb.edn b/bb.edn index f76e437..bc4f02c 100644 --- a/bb.edn +++ b/bb.edn @@ -44,11 +44,9 @@ :depends [prod] :task (do (fs/delete-tree "dist") - (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}")))} + (fs/create-dirs "dist") + (run! (fn [f] (fs/copy f "dist")) + (fs/glob "resources/public/js" "*.js")))} bump-version {:doc "Bumps package.json and pushes new git tag" :task (do (shell "npm version patch") diff --git a/build/src/scittle/build.clj b/build/src/scittle/build.clj index 02382e5..1e17a37 100644 --- a/build/src/scittle/build.clj +++ b/build/src/scittle/build.clj @@ -69,15 +69,4 @@ * :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))) - (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))))) + (build* (format "-M -m shadow.cljs.devtools.cli --force-spawn %s main %s" action (str/join " " args)))) diff --git a/deps.edn b/deps.edn index f7a5121..96ada15 100644 --- a/deps.edn +++ b/deps.edn @@ -1,9 +1,9 @@ {:paths ["src" "resources"] :deps - {org.clojure/clojure {:mvn/version "1.12.2"} - thheller/shadow-cljs {:mvn/version "3.1.8"} + {org.clojure/clojure {:mvn/version "1.11.1"} + thheller/shadow-cljs {:mvn/version "2.20.15"} org.babashka/sci {:git/url "https://github.com/babashka/sci" - :git/sha "6758ba028da559c536a06becbbedade7b0ba6448"} + :git/sha "87fa2d2648ef809e8c8c87279c51961dca41ed4d"} #_{:local/root "../babashka/sci"} reagent/reagent {:mvn/version "1.1.1"} no.cjohansen/replicant {:mvn/version "2025.03.27"} @@ -21,9 +21,7 @@ io.github.babashka/sci.configs #_{:local/root "/Users/borkdude/dev/sci.configs"} {:git/url "https://github.com/babashka/sci.configs" - :git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1" - :exclusions [org.babashka/sci]} - binaryage/devtools {:mvn/version "1.0.7"}} + :git/sha "1ade6f94a2902211bed1f876472571da0c5e7278"}} :aliases {:dev {:extra-paths ["dev"] diff --git a/doc/dev.md b/doc/dev.md index b6bd354..2b87a64 100644 --- a/doc/dev.md +++ b/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.7.28` +- `bb replace-version 0.6.16 0.6.22` - Create Github release with updated links from `doc/links.md` - `bb gh-pages` - + - - + + - + diff --git a/doc/js-libraries.md b/doc/js-libraries.md deleted file mode 100644 index 72cafb8..0000000 --- a/doc/js-libraries.md +++ /dev/null @@ -1,49 +0,0 @@ -# Loading JS libraries - -Since `v0.7.28` scittle allows to load libraries from the global enviroment. -This means you can load a library in a ` - - - - - - -``` - -## 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 ` - - - - - - - -``` diff --git a/doc/links.md b/doc/links.md index 0b4181a..a58dd12 100644 --- a/doc/links.md +++ b/doc/links.md @@ -1,20 +1,7 @@ -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.js-interop.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.cljs-ajax.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.reagent.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.re-frame.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.replicant.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.promesa.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.pprint.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.nrepl.js - -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.js-interop.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.cljs-ajax.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.reagent.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.re-frame.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.replicant.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.promesa.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.pprint.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.nrepl.js -https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.cljs-devtools.js +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 diff --git a/doc/nrepl/README.md b/doc/nrepl/README.md index 5541357..01953ef 100644 --- a/doc/nrepl/README.md +++ b/doc/nrepl/README.md @@ -21,7 +21,7 @@ the normal routine: ``` html - + ``` Also include the CLJS file that you want to evaluate with nREPL: @@ -42,16 +42,6 @@ you should be able evaluate expressions in `playground.cljs`. See a demo Note that the nREPL server connection stays alive even after the browser window refreshes. -### Custom host address - -By default, the browser will connect to a websocket on the same host as it is loaded -from, using `window.location.hostname`. If you need something else you can specify -that setting the window variable `SCITTLE_NREPL_WEBSOCKET_HOST` like so: - -``` html - -``` - ### CIDER Choose `cider-connect-cljs`, select port `1339`, followed by the `nbb` REPL diff --git a/doc/nrepl/bb.edn b/doc/nrepl/bb.edn index fdd4518..e4cf885 100644 --- a/doc/nrepl/bb.edn +++ b/doc/nrepl/bb.edn @@ -1,6 +1,5 @@ {:deps {io.github.babashka/sci.nrepl - #_{:local/root "/Users/borkdude/dev/sci.nrepl"} - {:git/sha "4f7f6d652a71b5bdc0c110313a4908d956e7a97d"} + {:git/sha "2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23"} io.github.babashka/http-server {:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}} :tasks {http-server {:doc "Starts http server for serving static files" diff --git a/doc/nrepl/index.html b/doc/nrepl/index.html index 5890a47..d228eed 100644 --- a/doc/nrepl/index.html +++ b/doc/nrepl/index.html @@ -1,9 +1,9 @@ - + - + diff --git a/doc/serviceworker.md b/doc/serviceworker.md deleted file mode 100644 index 1048f77..0000000 --- a/doc/serviceworker.md +++ /dev/null @@ -1,26 +0,0 @@ -# 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 - -``` - -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). diff --git a/package-lock.json b/package-lock.json index e5bd260..074b6c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "react": "17.0.1", "react-dom": "17.0.1" }, - "version": "0.7.28" + "version": "0.7.23" }, "node_modules/js-tokens": { "version": "4.0.0", @@ -129,5 +129,5 @@ } } }, - "version": "0.7.28" + "version": "0.7.23" } diff --git a/package.json b/package.json index ab333e8..ac66b4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scittle", - "version": "0.7.28", + "version": "0.7.23", "files": [ "dist" ], diff --git a/plugins/datascript/deps.edn b/plugins/datascript/deps.edn index 467f4cd..1454ae1 100644 --- a/plugins/datascript/deps.edn +++ b/plugins/datascript/deps.edn @@ -1,4 +1,3 @@ {:deps {datascript/datascript {:mvn/version "1.3.12"} - io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1" - :exclusions [org.babashka/sci]}}} + io.github.babashka/sci.configs {:git/sha "33bd51e53700b224b4cb5bda59eb21b62f962745"}}} diff --git a/plugins/dataspex/deps.edn b/plugins/dataspex/deps.edn deleted file mode 100644 index badf11e..0000000 --- a/plugins/dataspex/deps.edn +++ /dev/null @@ -1,8 +0,0 @@ -{: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]}}} diff --git a/plugins/dataspex/src/scittle/dataspex.cljs b/plugins/dataspex/src/scittle/dataspex.cljs deleted file mode 100644 index 66b3908..0000000 --- a/plugins/dataspex/src/scittle/dataspex.cljs +++ /dev/null @@ -1,9 +0,0 @@ -(ns scittle.dataspex - {:no-doc true} - (:require [sci.configs.cjohansen.dataspex :refer [config]] - [scittle.core :as scittle])) - -(defn init [] - (scittle/register-plugin! - ::dataspex - config)) diff --git a/plugins/dataspex/src/scittle_plugin.edn b/plugins/dataspex/src/scittle_plugin.edn deleted file mode 100644 index af629e2..0000000 --- a/plugins/dataspex/src/scittle_plugin.edn +++ /dev/null @@ -1,8 +0,0 @@ -[{: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]}}}}] diff --git a/plugins/demo/bb.edn b/plugins/demo/bb.edn index e7486c2..86170d0 100644 --- a/plugins/demo/bb.edn +++ b/plugins/demo/bb.edn @@ -1,7 +1,6 @@ {: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 diff --git a/plugins/hoplon/deps.edn b/plugins/hoplon/deps.edn index 0eab577..e7aef52 100644 --- a/plugins/hoplon/deps.edn +++ b/plugins/hoplon/deps.edn @@ -1,4 +1,3 @@ {:deps {hoplon/hoplon {:mvn/version "7.5.0"} - io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1" - :exclusions [org.babashka/sci]}}} + io.github.babashka/sci.configs {:git/sha "08bab21643bc0c63a5b99c65193c9d24888270b7"}}} diff --git a/plugins/javelin/deps.edn b/plugins/javelin/deps.edn index f4b4533..135f602 100644 --- a/plugins/javelin/deps.edn +++ b/plugins/javelin/deps.edn @@ -1,4 +1,3 @@ {:deps {hoplon/javelin {:mvn/version "3.9.3"} - io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1" - :exclusions [org.babashka/sci]}}} + io.github.babashka/sci.configs {:git/sha "08bab21643bc0c63a5b99c65193c9d24888270b7"}}} diff --git a/resources/public/cljs/replicant_tictactoe/core.cljs b/resources/public/cljs/replicant-tictactoe/core.cljs similarity index 98% rename from resources/public/cljs/replicant_tictactoe/core.cljs rename to resources/public/cljs/replicant-tictactoe/core.cljs index b5ad81f..2897329 100644 --- a/resources/public/cljs/replicant_tictactoe/core.cljs +++ b/resources/public/cljs/replicant-tictactoe/core.cljs @@ -29,5 +29,5 @@ ;; Trigger the first render by initializing the game. (start-new-game store))) - -(main) + +(main) \ No newline at end of file diff --git a/resources/public/cljs/replicant_tictactoe/game.cljs b/resources/public/cljs/replicant-tictactoe/game.cljs similarity index 74% rename from resources/public/cljs/replicant_tictactoe/game.cljs rename to resources/public/cljs/replicant-tictactoe/game.cljs index 9296baf..3f62d7f 100644 --- a/resources/public/cljs/replicant_tictactoe/game.cljs +++ b/resources/public/cljs/replicant-tictactoe/game.cljs @@ -13,13 +13,10 @@ path)) (defn get-winning-path [{:keys [size tics]} y x] - (let [flip-y (fn [y] (- size 1 y))] - (or (winner? tics (mapv #(vector y %) (range 0 size))) - (winner? tics (mapv #(vector % x) (range 0 size))) - (when (= y x) - (winner? tics (mapv #(vector % %) (range 0 size)))) - (when (= (flip-y y) x) - (winner? tics (mapv #(vector (flip-y %) %) (range 0 size))))))) + (or (winner? tics (mapv #(vector y %) (range 0 size))) + (winner? tics (mapv #(vector % x) (range 0 size))) + (when (= y x) + (winner? tics (mapv #(vector % %) (range 0 size)))))) (defn maybe-conclude [game y x] (if-let [path (get-winning-path game y x)] diff --git a/resources/public/cljs/replicant_tictactoe/style.css b/resources/public/cljs/replicant-tictactoe/style.css similarity index 100% rename from resources/public/cljs/replicant_tictactoe/style.css rename to resources/public/cljs/replicant-tictactoe/style.css diff --git a/resources/public/cljs/replicant_tictactoe/ui.cljs b/resources/public/cljs/replicant-tictactoe/ui.cljs similarity index 100% rename from resources/public/cljs/replicant_tictactoe/ui.cljs rename to resources/public/cljs/replicant-tictactoe/ui.cljs diff --git a/resources/public/codemirror.html b/resources/public/codemirror.html index 800624b..d512ebe 100644 --- a/resources/public/codemirror.html +++ b/resources/public/codemirror.html @@ -1,13 +1,13 @@ - + - - - + + + - + + + + - + - - - - - - diff --git a/resources/public/replicant_tictactoe.html b/resources/public/replicant_tictactoe.html index 1f52895..b518841 100644 --- a/resources/public/replicant_tictactoe.html +++ b/resources/public/replicant_tictactoe.html @@ -5,9 +5,9 @@ - - - + + + @@ -25,9 +25,9 @@ from cljs/replicant_tictactoe/core.cljs using the script tag:

-<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>
 
 

@@ -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) diff --git a/script/release.clj b/script/release.clj index 4835975..f64d85d 100755 --- a/script/release.clj +++ b/script/release.clj @@ -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)) diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 4b0d654..8040d70 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -6,14 +6,7 @@ :builds {:main - {;:compiler-options {:source-map true} - ;; for dev build - #_#_ - :compiler-options {:optimizations :simple - :pretty-print true - :pseudo-names true - :source-map true} - :target :browser + {:target :browser :js-options {:resolve {"react" {:target :global :global "React"} @@ -39,6 +32,5 @@ :scittle.cljs-ajax {:entries [scittle.cljs-ajax] :depends-on #{:scittle}}} :build-hooks [(shadow.cljs.build-report/hook)] - :output-dir "resources/public/js" ;; + "/dev" for dev build - :devtools {:repl-pprint true} - }}} + :output-dir "resources/public/js" + :devtools {:repl-pprint true}}}} diff --git a/src/scittle/cljs_devtools.cljs b/src/scittle/cljs_devtools.cljs deleted file mode 100644 index cbe2082..0000000 --- a/src/scittle/cljs_devtools.cljs +++ /dev/null @@ -1,6 +0,0 @@ -(ns scittle.cljs-devtools - (:require [devtools.core :as devtools])) - -(devtools/set-pref! :disable-advanced-mode-check true) - -(devtools/install!) diff --git a/src/scittle/core.cljs b/src/scittle/core.cljs index c603d9c..ee5ec27 100644 --- a/src/scittle/core.cljs +++ b/src/scittle/core.cljs @@ -3,7 +3,6 @@ (: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] @@ -44,29 +43,20 @@ 'NaN? (sci/copy-var NaN? cljns) 'infinite? (sci/copy-var infinite? cljns) 'iteration (sci/copy-var iteration cljns) - 'abs (sci/copy-var abs cljns) - 'Cons cljs.core/Cons} + 'abs (sci/copy-var abs cljns)} 'goog.object {'set gobject/set 'get gobject/get} - 'goog.string {'format gstring/format - 'htmlEscape gstring/htmlEscape} - 'goog.string.format {} ;; For cljs compatibility + 'goog.string {'htmlEscape gstring/htmlEscape} '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} - :load-fn load-fn})) + :features #{:scittle :cljs}})) (unchecked-set js/globalThis "import" (js/eval "(x) => import(x)")) diff --git a/src/scittle/nrepl.cljs b/src/scittle/nrepl.cljs index ec4c38c..bfea685 100644 --- a/src/scittle/nrepl.cljs +++ b/src/scittle/nrepl.cljs @@ -8,11 +8,10 @@ (when-let [ws-port (.-SCITTLE_NREPL_WEBSOCKET_PORT js/window)] (set! (.-ws_nrepl js/window) - (new js/WebSocket (ws-url (or (.-SCITTLE_NREPL_WEBSOCKET_HOST js/window) - (.-hostname (.-location js/window))) - ws-port "_nrepl")))) + (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)))))