Fork me on GitHub
#sci
<
2022-12-26
>
Sam Ritchie14:12:34

@borkdude found this maybe-bug with SCI via Clerk… I built custom JS with this namespace:

(ns mathbox.clerk-ui
  (:require ["three" :as three]
            [nextjournal.clerk.sci-env]
            [sci.ctx-store]
            [sci.core :as sci]))

(def three-ns
  (-> (into {}
            (map (fn [[k v]] [(symbol k) v]))
            (.entries js/Object three))))

(sci.ctx-store/swap-ctx!
 sci/merge-opts
 {:namespaces  {'three three-ns}})
then, in my clerk viewer, I can call constructors with the new keyword:
(js/console.log (new three/Color 0xff4136))
and I see

Sam Ritchie14:12:10

but if I do (three/Color. 0xff4136) instead I get

borkdude14:12:59

It may be better to use add-class! for JS things rather than imitating a Clojure namespace See: https://github.com/babashka/sci/blob/master/doc/async.md

borkdude14:12:42

but feel free to post a SCI issue, perhaps it can be solved, maybe not

borkdude14:12:00

I've got some christmas thing today, so I'll be back tonight

borkdude14:12:43

Were you using the newest SCI for this?

Sam Ritchie14:12:30

I think so, transitively via the latest Clerk

borkdude17:12:53

No rush, but please make an issue else I’ll forget :)