clerk 2024-12-26

There seems to be a problem with Clerk’s sync atoms and rerendering. For context, I’m working on a notebook with a code editor backed by a Clerk sync atom, and just updated Clerk’s version to b08b7eb. Now every time I type a character in the editor the cursor jumps out of the editor and to some text above (suggesting a complete rerender). I believe the commit that first introduced this problem is https://github.com/nextjournal/clerk/commit/fb46f4159581bc3d5d30838c6b9a8c8a8da3014e`fb46f41`. To reproduce this, download and launch the example code editor notebook (https://github.com/nextjournal/clerk/blob/main/notebooks/viewers/code.clj), scroll down to the editable-code atom, and try to type in the editor. (If anyone else could help me confirm this behavior, that’d be great. Thank you.)

hi, I can confirm this

@mkvlr Commit 285c20e works. Actually, commit b08b7eb also works if I keep clerk.viewer/viewer-eval-viewer and just remove {::clerk/no-cache true}.

I think the new commit has faster recompute! time, but only by a very small margin. What’s the difference between the old viewer-eval-viewer and the new render-eval-viewer?

yes, main thing was the no-cache. render-eval-viewer is just a rename of viewer-eval-viewer and still keeping the old name around for backwards compatibility.

Thanks, that’s interesting. I wonder what changed in commit fb46f41 that made ::clerk/no-cache behave differently.

Hmm I’m coming back to Clerk after a long while, and what I wanted to play with doesn’t take off: meander.strategy.epsilon can’t be used because of a missing cljs.tagged_literals.JSValue? at least that’s my reading of the error (see 🧵)

✅ 1

please excuse the screenshot 😅

> Caused by java.lang.ClassNotFoundException > cljs.tagged_literals.JSValue

my deps.edn is

{:deps {io.github.nextjournal/clerk {:mvn/version "0.17.1102"}
    meander/epsilon {:git/url ""
                     :git/sha "74de6b1f651441092cc12d1c9012ef7086033040"}
    org.clojure/data.json {:mvn/version "2.5.1"}}}
(because the latest released version of meander didn’t work for https://github.com/noprompt/meander/commit/25e440d638896ed2d55ff67f00864234ac379011)

Seems like meander expects cljs to be on the classpath perhaps?

hmm I don’t know how to make it so 😑

huh interestingly, it seems to be related to the “reflection warning” commit linked above

huh! so yeah it looks like the latest released version works.

you can only load this code: https://github.com/noprompt/meander/blob/74de6b1f651441092cc12d1c9012ef7086033040/src/meander/util/epsilon.cljc#L12 when you have clojurescript on your classpath, else it simply won't work

thanks!

I guess I’ll try not to get scared by a warning next time 😳

> hmm I don’t know how to make it so well, just add clojurescript to your deps.edn

👍 1
1

version meander/epsilon {:mvn/version "0.0.650"} doesn't seem to have this problem?

(ns ^:no-doc meander.util.epsilon
  (:require [clojure.walk :as walk]
            [clojure.zip :as zip])
  #?(:cljs
     (:require-macros [meander.util.epsilon
                       :refer [__disj
                               __dissoc
                               __nth]])))

it's not clean to have to add clojurescript as a dependency though, so I'd file this as an issue with meander

Yeah so sorry for not giving all context clearly — I had tried the latest release first, and saw a “reflection warning” when using sync-deps; this made me look into the github repo where I found the latest commit which seemed to address that. turns out the cure is worse than the disease here, I’ll just use 0.0.650 and ignore the warning.

I'd still file it as an issue though since it's likely that they won't notice this before the next release

I can do that later as well

not now, my wife is calling me to do the dishes :)

I’m fairly sure your issue would be more on the spot than mine

OTOH I’ve already done the dishes 😄

so. I don’t want to put this on you, but I’d appreciate if you could do it — so, I’ll just check the issue tracker when I get a chance later this year (which is a short time span, after all)