Skip to content

Commit 47fcef1

Browse files
borkdudezampino
andauthored
Fix js-interop destructuring in SCI context (#368)
and bump SCI configs. Co-authored-by: Andrea Amantini <[email protected]>
1 parent 7f9e968 commit 47fcef1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

render/deps.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
cider/cider-nrepl {:mvn/version "0.28.3"}
55
org.babashka/sci {:mvn/version "0.6.37"}
66
reagent/reagent {:mvn/version "1.1.1"}
7-
io.github.babashka/sci.configs {:git/sha "b5335b79c237344d003f16358321197a0b0a2ac6"}
7+
io.github.babashka/sci.configs {:git/sha "0702ea5a21ad92e6d7cca6d36de84271083ea68f"}
88
io.github.nextjournal/clojure-mode {:git/sha "ac038ebf6e5da09dd2b8a31609e9ff4a65e36852"}
99
metosin/reitit-frontend {:mvn/version "0.5.15"}
1010
thheller/shadow-cljs {:mvn/version "2.20.11"}}}

src/nextjournal/clerk/sci_env.cljs

+12-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@
106106
(sci/add-import! ctx ns sub-libname r))))
107107
{:handled true})))
108108

109+
(defn ^:macro implements?* [_ _ psym x]
110+
;; hardcoded implementation of implements? for js-interop destructure which
111+
;; uses implements?
112+
(case psym
113+
cljs.core/ISeq (implements? ISeq x)
114+
cljs.core/INamed (implements? INamed x)
115+
(list 'cljs.core/instance? psym x)))
116+
117+
(def core-ns (sci/create-ns 'clojure.core nil))
118+
109119
(def initial-sci-opts
110120
{:async? true
111121
:load-fn load-fn
@@ -118,7 +128,8 @@
118128
'v 'nextjournal.clerk.viewer
119129
'p 'nextjournal.clerk.parser}
120130
:namespaces (merge {'nextjournal.clerk.viewer viewer-namespace
121-
'clojure.core {'read-string read-string}}
131+
'clojure.core {'read-string read-string
132+
'implements? (sci/copy-var implements?* core-ns)}}
122133
(sci-copy-nss
123134
'nextjournal.clerk.parser
124135
'nextjournal.clerk.render

0 commit comments

Comments
 (0)