sci

Sam Ritchie 2022-12-26T14:28:34.334109Z

@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 Ritchie 2022-12-26T14:30:10.299109Z

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

borkdude 2022-12-26T14:32:59.051469Z

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

borkdude 2022-12-26T14:36:42.757129Z

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

borkdude 2022-12-26T14:37:00.462199Z

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

borkdude 2022-12-26T14:37:43.329909Z

Were you using the newest SCI for this?

Sam Ritchie 2022-12-26T14:53:30.980579Z

I think so, transitively via the latest Clerk

Sam Ritchie 2022-12-26T14:53:38.154159Z

no rush!!

borkdude 2022-12-26T17:22:53.982259Z

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

Sam Ritchie 2022-12-26T17:29:28.340459Z

will do

Sam Ritchie 2022-12-26T17:37:17.680799Z

https://github.com/babashka/sci/issues/862