Hi @hiskennyness It seems the link for https://github.com/kennytilton/matrix/tree/main/cljs/rxtrak is broken in the introduction
Wow, I really shuffled things around, thx for the heads up. Instructions for running rxTrak are here: https://github.com/kennytilton/web-mx-sampler/tree/main/src/tiltontec/example The source for rxTrak is here, but no README: https://github.com/kennytilton/web-mx-sampler/tree/main/src/tiltontec/example/rxtrak So it is weird that the Matrix wiki is documenting a Web/MX project, but MX makes more sense as a UI state solution, so I will stick with that. But I should add a readme to the rxTrak source directory since I am linking to that. Thx!
I'm try to create a playground using shadow-cljs and I'm getting the following error:
------ ERROR -------------------------------------------------------------------
File: jar:file:/.../com/tiltontec/matrix/5.0.1-SNAPSHOT/matrix-5.0.1-SNAPSHOT.jar!/tiltontec/cell/integrity.cljc:1:1
--------------------------------------------------------------------------------
1 | (ns tiltontec.cell.integrity
-------^------------------------------------------------------------------------
Invalid :refer, var tiltontec.cell.base/un-stopped does not exist
--------------------------------------------------------------------------------
2 | (:require
3 | ;#?(:clj [taoensso.tufte :as tufte :refer :all]
4 | ; :cljs [taoensso.tufte :as tufte :refer-macros [defnp p profiled profile]])
5 | #?(:cljs [tiltontec.util.base
--------------------------------------------------------------------------------
The same with 5.0.0
Did anyone encouter that by any chance?Have you tried [com.tiltontec/matrix "5.0.1"]?
There was definitely stuff like that getting cleaned up as I moved to non-snapshot releases. Hmmm. Maybe I should get the hood up on those snapshots, since there is no way to delete them from Clojars.
Could not find artifact com.tiltontec:matrix:jar:5.0.1
Running with figwheel works fine:
clojure -M -m figwheel.main --build todomvc --repl
I wonder what I messed up moving to shadow-cljsI bascally copied all the files in the todomvc dir fix ns added deps:
[funcool/bide "1.7.0"]
[com.taoensso/tufte "2.4.5"]
[com.tiltontec/matrix "5.0.1-SNAPSHOT"]
[com.tiltontec/web-mx "2.0.1-SNAPSHOT"]
then pointed shadow to matrix-todo.core/atrix-build!Oy, I have been juggling TodoMVC's all over the map. Did you find the one under web-mx-sampler, or the old mxtodomvc repo? I'll see if I can find which from the deps. web-mx stable is 2.0.1, btw.
Ah, to make things worse, in web-mx-sampler I have both project.clj and deps.edn, and the latter is out of sync. This could be the problem. My apologies for that. I will fix that now.
hmm project.clj use 5.0.1 which maven insists isn't there
Hmmm. Maybe I installed locally and never on clojars. On Clojars it is def not there. tbh, I am just now adjusting to semver and stable vs snapshot and all that. the sampler is using
[com.tiltontec/matrix "5.0.1-SNAPSHOT"]
[com.tiltontec/web-mx "2.0.1-SNAPSHOT"]
[com.tiltontec/mxxhr "2.0.0-SNAPSHOT"]
I am totally screwing you up! But I have my coffee ready, so I should be able to get my head out now.I started with those vers, and they had the mentioned error
But running with figwheel works?
yep which is super weird
OK, coffee is sinking in. I thought I recognized un-stopped as sth I had tossed -- I could, in fact -- but it is still part of MX.
And it is a macro, and we are in CLJC-land, which is a dicey combo.
Do you have a little shadow set-up you can share that fails on that?
I am def having deja vu on this shadow vs figwheel thing.
just a sec
Of course we also have the issue of CLJ moving away from refer-macros, which I am glad to see what that is weird, too, I will have to remind myself on that.
Just cleaned it up for you from all my noise
I started refactoring the requires and planed to clean that up too
What is the shadow command you use to launch?
yarn watch matrix
or
npm run watch matrix
OK, I have recreated the error.
[:matrix] Build failure:
------ ERROR -------------------------------------------------------------------
File: jar:file:/Users/kennethtilton/.m2/repository/com/tiltontec/matrix/5.0.1-SNAPSHOT/matrix-5.0.1-SNAPSHOT.jar!/tiltontec/cell/integrity.cljc:1:1
--------------------------------------------------------------------------------
1 | (ns tiltontec.cell.integrity
-------^------------------------------------------------------------------------
Invalid :refer, var tiltontec.cell.base/un-stopped does not exist
--------------------------------------------------------------------------------
2 | (:require
3 | ;#?(:clj [taoensso.tufte :as tufte :refer :all]
4 | ; :cljs [taoensso.tufte :as tufte :refer-macros [defnp p profiled profile]])
5 | #?(:cljs [tiltontec.util.base
--------------------------------------------------------------------------------
What ideas are you trying on the requires?you mean with the refactoring?
Yes. Or do you see anything wrong with my requires in re macros and CLJC and all that?
This is the kind of thing I get fixed and then forget, in part because I cannot forn a mental model around it. Like when we were supposed to have X.clj and X.cljs and require one from the other.
My working premise is that figwheel.main is being nice and bailing out some unsupported thing I am doing that shadow is correctly rejecting.
Hmmm. Back in March someone persuaded me to get current with the requires in re macros. Maybe I did it wrong but figwheel handles it. And by then I was not doing shadow. Still digging...
All I was doing was cleaning unused requires and was planning on moving macros to normal refers. I don't think this is directly related to the issue at hand
Your hypothesis is much more likely. Maybe figwheel handles some clj-cljs relation some other way than shadow. Maybe @thheller can help us out π
I think I found the syntax I need:
(ns tiltontec.matrix.api
#?(:cljs
(:require-macros [tiltontec.matrix.api]))
....)
Still digging.... or I might just go back to the syntax I had.I didn't follow the whole thread but the main difference when it comes to macro is that shadow "warns" you about possibly incorrect macro setups. figwheel is not as strict. The "problem" is that macros need to be explicitely required. so, as above the :require-macros for itself. That ensures the compiler will load this namespace and provide the macros properly.
if this is not done you are relying on something else having loaded the macro namespace, which may happen by coincidence, but is not guaranteed. so if nothing required the macros, you get weird runtime errors.
so there might never be a problem, but making sure macros are properly provided just makes it safer
Ah, thx for jumping in! I was going to thrash away for a few hours before sending up a flare. Someone had suggested we could ditch the explicit require, sparing users of my library knowing which symbols were macros. I'll revert all that and go wwith explicit. Thx again, @thheller.
hmm? maybe you misunderstood what I meant
YOU as the library author do (ns library.ns (:require-macros [library.ns]))
the USERS of the library don't care
they never :require-macros anything, or do anything else macro specific
the self :require-macros in your library enable the compiler to figure out the macro stuff, it is the hint that tells the compiler "this namespace has macros". exactly so that the users don't have to specifcy whether they meant the macro or the function
for example in the snippet above you have [taoensso.tufte :as tufte :refer-macros [defnp p profiled profile]]
If taoensso.tufte sets up macros correctly (which I don't know) then this could just be :refer instead of :refer-macros, thus making it work exactly like CLJ. making the reader conditional redundant even
basically if there is a :require-macros that is not the same symbol as the ns itself thats a "bug"
https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html
Thx for the extra trouble! That ^^^ is what I got talked out of doing! π€¦ The change seemed to work so I went with it. I will revert to that as soon as I finish up this smaller brush fire. π
OK, @lidorcg, I am grinding thru the reversions. I'll let you know when your project runs under shadow.
So @lidorcg, I tried building against the versions I had in early March where the set-up was a little friendlier to shadow, but then the rest of the code you grabbed for the exercise is a problem because that assumes the overhaul I did getting things ready for a wider audience. The only way forward is to get the current MX compatible with Shadow. A good idea anyway, but I was hoping for a quick workaround. I will head over to #shadow-cljs to sort this out, since it might benefit others to have the excahnge there.
@hiskennyness Thank you so much for your efforts ππΌ! And @thheller thank you for your guidance, we learned a lot
In the meantime we'll play with the working figwheel setup, we still have some hacking to do and see if what we're aiming for is achievable through matrix. If it is, we'll focus on making the shadow setup work π
Awesome. I am hard at it now, will keep you posted.
@lidorcg, right now I am stumped on getting shadow to build MX, pending info from the Clojure standard itself, which I cannot find. π Maybe tmrw we can get that from the cognoscenti--I asked late in the day.
I did try the recommended split of macros into their own CLJ, and got past the un-stopped symbol, but on the next build failure that did not help--with a different error.
It occurs to me I have prolly only ever built with shadow on RN projects, so this may not have ever been known to work.
I like your plan of soldiering on with figwheel until you know if you even get to POC, then worrying about shadow.
Me, I will keep an eye on the issue, and go drown my sorrows in ClojureDart. π
Hi @hiskennyness I tested the shadow setup and it compiled π₯³ However I noticed a little bug: 1. When refreshing the page 2. Trying to add task 3. result in this error:
Uncaught TypeError: pdom is null
<anonymous> html.cljs:183
cljs$core$IFn$_invoke$arity$5 core.cljs:11368
cljs$core$IFn$_invoke$arity$3 watch.cljc:16
tiltontec$cell$evaluate$propagate evaluate.cljc:526
tiltontec$cell$evaluate$c_value_assume evaluate.cljc:384
tiltontec$cell$evaluate$calculate_and_set evaluate.cljc:223
propagate_to_callers evaluate.cljc:580
cljs$core$IFn$_invoke$arity$2 integrity.cljc:71
cljs$core$IFn$_invoke$arity$1 integrity.cljc:66
tiltontec$cell$integrity$finish_business integrity.cljc:80
tiltontec$cell$integrity$call_with_integrity integrity.cljc:182
tiltontec$cell$core$cset_BANG_ core.cljc:301
tiltontec$cell$core$c_reset_BANG_ core.cljc:306
tiltontec$model$core$mset_BANG_ core.cljc:89
cljs$core$IFn$_invoke$arity$variadic core.cljc:113
cljs$lang$applyTo core.cljc:112
cljs$core$IFn$_invoke$arity$5 core.cljs:3997
cljs$core$IFn$_invoke$arity$variadic api.cljc:163
todo_entry_field core.cljs:34
setProperties dom.js:549
forEach object.js:25
setProperties dom.js:531
createDom_ dom.js:925
createDom dom.js:900
cljs$core$IFn$_invoke$arity$4 core.cljs:3947
cljs$core$IFn$_invoke$arity$4 core.cljs:3989
cljs$core$IFn$_invoke$arity$2 html.cljs:110
dom html.cljs:113
2 core.cljs:4770
2 cljs.core.js:17787
sval core.cljs:3462
cljs$core$ISeqable$_seq$arity$1 core.cljs:3519
cljs$core$seq core.cljs:1236
2 core.cljs:3817
sval core.cljs:3462
cljs$core$ISeqable$_seq$arity$1 core.cljs:3519
cljs$core$seq core.cljs:1236
cljs$core$INext$_next$arity$1 core.cljs:3294
cljs$core$next_STAR_ core.cljs:3925
cljs$core$IFn$_invoke$arity$4 core.cljs:3948
cljs$core$IFn$_invoke$arity$4 core.cljs:3989
cljs$core$IFn$_invoke$arity$2 html.cljs:110
dom html.cljs:113
2 core.cljs:4770
2 cljs.core.js:17787
sval core.cljs:3462
cljs$core$ISeqable$_seq$arity$1 core.cljs:3519
cljs$core$seq core.cljs:1236
2 core.cljs:3817
sval core.cljs:3462
cljs$core$ISeqable$_seq$arity$1 core.cljs:3519
cljs$core$seq core.cljs:1236
cljs$core$IFn$_invoke$arity$4 core.cljs:3989
cljs$core$IFn$_invoke$arity$2 html.cljs:110
cljs$core$IFn$_invoke$arity$1 api.cljs:37
<anonymous> core.cljs:73
globalEval app.js:430
evalLoad app.js:1387
<anonymous> app.js:1618
html.cljs:183:25
Now I tried to investigate a bit:
#(when (= (.-key %) "Enter")
(let [raw (form/getValue (.-target %))
title (str/trim raw)]
(when-not (str/blank? title)
(mswap! (mget @matrix :todos) :items-raw conj
(make-todo {:title title})))
(form/setValue (.-target %) "")))
It seem to happen after the mswap conjis returning and before the form/setValue
So I'm guessing some "rendering on update" issue.
Another clue might be: after saving a file, causing shadow to recompile, the issue seems to disappear and only returns on the next page refresh.I think the issue now is how the shadow version is kicking off the app. I glossed over before the bit about matrix-build! being the init-fn:
:builds {:matrix {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn matrix-todo.core/matrix-build!}}
:devtools {:preloads []}
:dev {:compiler-options {:closure-defines {}}}}}}
Are you sure that is equivalent to the set up in the web-mx-sampler? I just tried that and it works fine, but maybe you can break it with a particular sequence?
Looking at the specific error, it does seem like some crucial internal state is not as expected in and around DOM vs w/mx proxies, such that hot reload is not working right.
I suspect we are not using shadow correctly and/or equivalently. Having to specify the init-fn makes me worry. Is it calling that on hot reload? The fig version wants a namespace, which it loads kicking off the top-level form that happens to call matrix-build!.
(let [root (dom/getElement "app")
app-matrix (matrix-build!)]
(set! (.-innerHTML root) nil)
(dom/appendChild root
(tag-dom-create
(mget app-matrix :mx-dom)))
(when-let [router-starter (mget app-matrix :router-starter)]
(router-starter)))
My apologies, you asked about that and I had no clue, and was worried simply about getting the thing to compile. Maybe we make that toplevel a proper function and make that the init function?
I'll see if there is a figwheel-> shadow conversion guide.Ah, got this from ChatGPT, as a way to add a shadow build alongside a fig.main build:
{:builds
{:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:entries [my.app.core]}}}}}
Trying it now. π€This is missing dependencies, there is a way to tell shadow to use dependencies from lein https://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen So your shadow-cljs.edn should be:
{:lein true
:builds
{:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:entries [my.app.core]}}}}}@mynomoto the full edn looks like this:
{:nrepl {:port 8777}
:source-paths ["src" "test"]
:dependencies [[funcool/bide "1.7.0"]
[com.taoensso/tufte "2.4.5"]
[com.tiltontec/matrix "5.0.1-SNAPSHOT"]
[com.tiltontec/web-mx "2.0.2-SNAPSHOT"]
[com.tiltontec/mxxhr "2.0.0-SNAPSHOT"]]
:dev-http {3000 "resources/public"}
:builds {:matrix {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn matrix-todo.core/matrix-build!}}
:devtools {:preloads []}
:dev {:compiler-options {:closure-defines {}}}}}}
we moved the dependencies to shadowOh, sorry. I saw the message on the channel and failed to get the context.
Quick fix did not work. π But I am pretty sure we need to do sth different kicking off a shadow version.
Progress: https://clojurians.slack.com/archives/C6N245JGG/p1683735522125549
@lidorcg, if you really need to use shadow, I suggest starting from https://github.com/shadow-cljs/quickstart-browser and moving the toplevel code into the start function, as I did over in the #shadow-cljs post. I might try it myself at some point, but not sure when I will get to it.
Thanks again @hiskennyness ππΌ I'm sure we'll be able to make this work. I'll send here once I have a fully working shadow-mx-web starter
Hey, I went ahead and gave it a shot, works fine on one of the w/mx examples. I will send you a zip shortly. btw, not seeing hot reload work. Does shadow do that? Might need more work, but we have a start.
Hey, @hiskennyness
The web-mx-sampler wonβt run, i think itβs related to the matrix commit yesterday (mxxhr cleanup).
Changing the matrix version 5.0.1-SNAPSHOT to 5.0.0-SNAPSHOT in the deps.edn file, fixed it:
Ah, I neglected to push the sampler changes that accommodated the tweak to MX 5.0.1-SNAPSHOT.
I just pushed the web-mx-sampler changes, and tested in a fresh clone after clearing out my .m2, it should be ok now. FYI, the relevant new requires:
[com.tiltontec/matrix "5.0.1-SNAPSHOT"]
[com.tiltontec/web-mx "2.0.2-SNAPSHOT"]
[com.tiltontec/mxxhr "2.0.0-SNAPSHOT"]
Thx again for the report. πThat is the src dir and shadow-cljs.edn. Had to tweak a few things once the shadow build succeeded, so check the source closely!
I'm here if you need anything.
Thx again, @thheller!
ps. I was careful to clear out my .m2 so you should be good pulling from clojars. OTOH, GitHub is having an outage so the repos themselves have not been updated.
yep, was having the same error, and I assumed the lib haven't updated yet
@hiskennyness thank you so much for the immediate attention and solution π
np! And thx for surfacing the issues that got me up to speed on :require-macros!