From 36de8d94e73a1a0ab7cff7013c0568734355308c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 23 Oct 2024 20:20:50 +0200 Subject: [PATCH] Fix #718: expose spec --- deps.edn | 2 +- render/deps.edn | 4 ++-- src/nextjournal/clerk/cljs_libs.clj | 6 +++++- src/nextjournal/clerk/sci_env.cljs | 16 ++++++++++++---- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/deps.edn b/deps.edn index 8ae93f61d..4ecc2f310 100644 --- a/deps.edn +++ b/deps.edn @@ -86,7 +86,7 @@ :exclusions [org.babashka/sci]} ;; emmy needs SCI, here we use the same version as in render: org.babashka/sci {:git/url "https://github.com/babashka/sci" - :git/sha "c556f4474303c61da72e7a07eef496dcbf66a56e"} + :git/sha "6d9380f55b3038769d5856fc67e7d7939ac981ef"} io.github.nextjournal/clerk-slideshow {:git/sha "11a83fea564da04b9d17734f2031a4921d917893"}}} :nextjournal/garden {:exec-fn nextjournal.clerk/serve! diff --git a/render/deps.edn b/render/deps.edn index 72f603c9b..927de19a5 100644 --- a/render/deps.edn +++ b/render/deps.edn @@ -3,11 +3,11 @@ binaryage/devtools {:mvn/version "1.0.3"} cider/cider-nrepl {:mvn/version "0.28.3"} org.babashka/sci {:git/url "https://github.com/babashka/sci" - :git/sha "c556f4474303c61da72e7a07eef496dcbf66a56e"} + :git/sha "6d9380f55b3038769d5856fc67e7d7939ac981ef"} org.clojure/clojurescript {:mvn/version "1.11.132"} io.github.babashka/sci.nrepl {:mvn/version "0.0.2"} reagent/reagent {:mvn/version "1.2.0"} - io.github.babashka/sci.configs {:git/sha "8253c69a537bcc82e8ff122e5f905fe9d1e303f0" + io.github.babashka/sci.configs {:git/sha "eb1fcaacf6f98c27adf22002173d40ae4f9cfcb0" :exclusions [org.babashka/sci]} io.github.nextjournal/clojure-mode {:git/sha "1f55406087814a0dda6806396aa596dbe13ea302"} thheller/shadow-cljs {:mvn/version "2.23.1"} diff --git a/src/nextjournal/clerk/cljs_libs.clj b/src/nextjournal/clerk/cljs_libs.clj index 3cc898ef1..2312e9503 100644 --- a/src/nextjournal/clerk/cljs_libs.clj +++ b/src/nextjournal/clerk/cljs_libs.clj @@ -49,7 +49,11 @@ reagent.ratom user clojure.pprint - cljs.pprint})) + cljs.pprint + clojure.spec.alpha + cljs.spec.alpha + clojure.spec.gen.alpha + cljs.spec.gen.alpha})) (defn- ns-decl? "Returns true if form is a (ns ...) declaration." diff --git a/src/nextjournal/clerk/sci_env.cljs b/src/nextjournal/clerk/sci_env.cljs index 4c8f4ac81..d34d87456 100644 --- a/src/nextjournal/clerk/sci_env.cljs +++ b/src/nextjournal/clerk/sci_env.cljs @@ -39,10 +39,12 @@ [sci.configs.applied-science.js-interop :as sci.configs.js-interop] [sci.configs.reagent.reagent :as sci.configs.reagent] [sci.configs.cljs.pprint :as sci.configs.pprint] + [sci.configs.cljs.spec.alpha :as sci.configs.spec] [sci.core :as sci] [sci.ctx-store] [sci.nrepl.server :as nrepl] - [shadow.esm])) + [shadow.esm] + [cljs.repl])) (defn ->render-fn+opts-with-*eval*-binding "Establishes the `*eval*` binding to support alternative @@ -164,7 +166,10 @@ "w3c-keyname" w3c-keyname} :ns-aliases '{clojure.math cljs.math cljs.repl clojure.repl - clojure.pprint cljs.pprint} + clojure.pprint cljs.pprint + clojure.spec.alpha cljs.spec.alpha + clojure.spec.gen.alpha cljs.spec.gen.alpha + clojure.spec.test.alpha cljs.spec.test.alpha} :namespaces (merge {'nextjournal.clerk.viewer viewer-namespace 'nextjournal.clerk viewer-namespace ;; TODO: expose cljs variant of `nextjournal.clerk` with docstrings 'nextjournal.clerk.sci-env {'load-string+ @@ -173,7 +178,9 @@ 'clojure.core {'read-string read-string 'implements? (sci/copy-var implements?* core-ns) 'time (sci/copy-var time core-ns) - 'system-time (sci/copy-var system-time core-ns)} + 'system-time (sci/copy-var system-time core-ns) + infinite? (sci/copy-var infinite? core-ns) + 'update-vals (sci/copy-var update-vals core-ns)} 'clojure.repl {'pst pst-stub}} (sci-copy-nss 'cljs.math @@ -194,7 +201,8 @@ sci.configs.js-interop/namespaces sci.configs.reagent/namespaces - sci.configs.pprint/namespaces)}) + sci.configs.pprint/namespaces + sci.configs.spec/namespaces)}) (defn ^:export eval-form [f] (sci/binding [sci/ns @last-ns]