clerk 2025-04-03

The mermaid viewer in the Book of Clerk works great, but the example given uses v8, and mermaid is on v11. I haven't been able to update the version number without a syntax error or all my graphs disappearing and I don't know if that's because (1) there's a lot of caching going on here (2) v8 is the latest available in whatever magic with-d3-require represents (3) the syntax changes so much that my Mermaidification code doesn't represent a valid graph anymore Is it possible to use a fresher mermaid?

There were in fact API changes. Looks like I could upgrade to 9.3 without any change in the visibility of the graph. Then I could update to 10.9 without triggering error messages, but my graphs became invisible. Which seems more like an effect of a syntax change.

That's about all the time I have for this session; I will be trying again Monday, and hopefully I can get a nice clear report out of what errors happen in which contexts under what version/syntax conditions.

πŸ‘ 1

When I just yolo'd the change to 11.6, I saw things like

invalid module
Hide Stacktrace (1 lines)
shadow$provide[110]/</x/bb/Mb</J.onload@https://storage.clerk.garden/nextjournal/clerk-assets@2WtVkTBNZA213UdQKZmWTVuF7TUJ/viewer.js?immutable=true:2298:322
which looked cachey to me? but it's a very new version

Hey, my good friend Claude and I figured out what was going on. One thing that interfered with debugging was my problem domain happens to like dots in node names, which newer versions of Mermaid are strict about not liking. But the real issue was that in Mermaid v11, β€’ `.render` is now asynchronous and returns a Promise, not a string or callback result. Here's https://www.perplexity.ai/search/i-have-organization-problems-r-T61mCv.HSK24JAyT770tYA, which ends with a summary at the end. I'll fork Clerk and try to formulate this into a merge request. Yay!

πŸ‘ 1

I returned to this today. I've found that, β€’ {:package ["mermaid@9.4.3/dist/mermaid.js"]} can be used with no console errors or graph changes β€’ {:package ["mermaid@10.1.0/dist/mermaid.js"]} results in a console error. One reason was, the cdn serves mermaid.min.js instead of mermaid.js. But that's not the only reason.

I'm going to take a break and then see if I can twiddle the :package data to get a working request

"mermaid@10.2.0/dist/mermaid.min.js" to match https://www.jsdelivr.com/package/npm/mermaid?version=10.2.0 yields

dunno what that implies

but it appears to be the same behavior as I step through a couple of point releases. I think maybe this is where there is a syntax change

I get a different error if I leap in time to 11.6.0; I still think it's syntax change related rather than some weird caching thing

Working hypothesis is, I tested updating my syntax to a 10-compatible style, not realizing that jsdelivr also went from serving mermaid.js to mermaid.min.js

And if I update my syntax to 10/11 style, things will work

Perhaps if I knew how to use uhhhh what's it called, source mapping?, then I could say something more. But I'm stumped. It could be that that string is not actually the same graph in v9 and v11 syntax, and an LLM lied(!) to me.

At least I think I've ruled out my graph->mermaid transformer being the culprit. I cannot, offhand, think of another mermaid viewer where I could change the version to test that the test string is really simple enough to be independent of version 🀷🏻

can you get it working outside of clerk?

No problem, and this is 11.6 I see

ok, also in a js playground where you’re using the same url as you are in clerk?

I don't know how to do that. I have not used a js playground for anything.

I’ll try to find the time tomorrow

πŸ™ 1
πŸ™πŸ» 1

Everything is possible 😊 Did you check to see if there were big API changes between versions?