matrix

2023-05-08T11:21:04.470459Z

Hi @hiskennyness It seems the link for https://github.com/kennytilton/matrix/tree/main/cljs/rxtrak is broken in the introduction

πŸ™ 1
kennytilton 2023-05-08T12:28:37.055649Z

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!

2023-05-08T13:20:18.132419Z

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?

πŸ‘€ 1
kennytilton 2023-05-08T13:27:32.609439Z

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.

2023-05-08T13:30:21.287879Z

Could not find artifact com.tiltontec:matrix:jar:5.0.1

2023-05-08T13:32:29.987989Z

Running with figwheel works fine:

clojure -M -m figwheel.main --build todomvc --repl
I wonder what I messed up moving to shadow-cljs

2023-05-08T13:34:27.315349Z

I 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!

kennytilton 2023-05-08T13:38:56.074069Z

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.

kennytilton 2023-05-08T13:42:47.794759Z

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.

2023-05-08T13:44:39.346299Z

hmm project.clj use 5.0.1 which maven insists isn't there

kennytilton 2023-05-08T13:53:41.746079Z

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.

2023-05-08T13:55:35.853059Z

I started with those vers, and they had the mentioned error

kennytilton 2023-05-08T14:00:42.451139Z

But running with figwheel works?

2023-05-08T14:04:29.456119Z

yep which is super weird

kennytilton 2023-05-08T14:05:39.368279Z

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?

kennytilton 2023-05-08T14:06:21.425739Z

I am def having deja vu on this shadow vs figwheel thing.

2023-05-08T14:06:51.395589Z

just a sec

kennytilton 2023-05-08T14:10:48.352859Z

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.

2023-05-08T14:10:52.253649Z

Just cleaned it up for you from all my noise

πŸ™ 1
2023-05-08T14:11:48.840409Z

I started refactoring the requires and planed to clean that up too

kennytilton 2023-05-08T14:12:07.892389Z

What is the shadow command you use to launch?

2023-05-08T14:12:48.533939Z

yarn watch matrix or npm run watch matrix

πŸ™ 1
kennytilton 2023-05-08T14:19:27.247289Z

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?

2023-05-08T14:20:23.467969Z

you mean with the refactoring?

kennytilton 2023-05-08T14:22:35.234479Z

Yes. Or do you see anything wrong with my requires in re macros and CLJC and all that?

kennytilton 2023-05-08T14:24:36.661529Z

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.

kennytilton 2023-05-08T14:25:45.161469Z

My working premise is that figwheel.main is being nice and bailing out some unsupported thing I am doing that shadow is correctly rejecting.

kennytilton 2023-05-08T14:51:41.453459Z

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...

2023-05-08T14:56:51.619469Z

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

2023-05-08T14:58:16.697529Z

Your hypothesis is much more likely. Maybe figwheel handles some clj-cljs relation some other way than shadow. Maybe @thheller can help us out πŸ˜€

kennytilton 2023-05-08T15:31:48.098179Z

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.

thheller 2023-05-08T15:54:31.904489Z

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.

thheller 2023-05-08T15:55:25.822889Z

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.

thheller 2023-05-08T15:56:56.099499Z

so there might never be a problem, but making sure macros are properly provided just makes it safer

kennytilton 2023-05-08T16:19:52.853139Z

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.

thheller 2023-05-08T16:22:31.554619Z

hmm? maybe you misunderstood what I meant

thheller 2023-05-08T16:22:52.314919Z

YOU as the library author do (ns library.ns (:require-macros [library.ns]))

thheller 2023-05-08T16:23:00.249749Z

the USERS of the library don't care

thheller 2023-05-08T16:23:05.192069Z

they never :require-macros anything, or do anything else macro specific

thheller 2023-05-08T16:24:08.285219Z

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

thheller 2023-05-08T16:24:43.469719Z

for example in the snippet above you have [taoensso.tufte :as tufte :refer-macros [defnp p profiled profile]]

thheller 2023-05-08T16:25:17.625849Z

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

thheller 2023-05-08T16:25:58.767159Z

basically if there is a :require-macros that is not the same symbol as the ns itself thats a "bug"

kennytilton 2023-05-08T17:40:17.270959Z

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. πŸ™‚

kennytilton 2023-05-08T18:15:06.692739Z

OK, @lidorcg, I am grinding thru the reversions. I'll let you know when your project runs under shadow.

kennytilton 2023-05-08T18:52:12.796959Z

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.

2023-05-08T19:48:46.800409Z

@hiskennyness Thank you so much for your efforts πŸ™πŸΌ! And @thheller thank you for your guidance, we learned a lot

2023-05-08T19:51:42.667469Z

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 πŸ˜„

kennytilton 2023-05-08T19:53:03.269829Z

Awesome. I am hard at it now, will keep you posted.

πŸ™ 1
kennytilton 2023-05-09T00:22:11.350879Z

@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. πŸ™‚

2023-05-10T09:19:38.603639Z

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.

kennytilton 2023-05-10T12:24:40.219829Z

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.

kennytilton 2023-05-10T12:35:38.942269Z

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. 🀞

2023-05-10T12:57:22.455959Z

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]}}}}}

2023-05-10T12:59:31.790339Z

@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 shadow

2023-05-10T13:04:46.210859Z

Oh, sorry. I saw the message on the channel and failed to get the context.

kennytilton 2023-05-10T13:04:56.079859Z

Quick fix did not work. 😞 But I am pretty sure we need to do sth different kicking off a shadow version.

kennytilton 2023-05-10T16:19:15.725099Z

Progress: https://clojurians.slack.com/archives/C6N245JGG/p1683735522125549

kennytilton 2023-05-10T16:23:00.296999Z

@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.

2023-05-10T16:48:27.872519Z

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

kennytilton 2023-05-10T17:27:46.304859Z

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.

Aviv 2023-05-09T08:27:00.198359Z

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:

kennytilton 2023-05-09T08:33:21.482269Z

Thx, @aviv846, I'll get on that now. πŸ™

πŸ™ 1
kennytilton 2023-05-09T08:51:00.229419Z

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. πŸ™

πŸ‘ 1
kennytilton 2023-05-09T11:34:04.126099Z

kennytilton 2023-05-09T11:36:38.185789Z

kennytilton 2023-05-09T11:37:29.923579Z

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!

kennytilton 2023-05-09T11:43:00.657209Z

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.

2023-05-09T11:44:04.904969Z

yep, was having the same error, and I assumed the lib haven't updated yet

2023-05-09T11:54:51.752689Z

@hiskennyness thank you so much for the immediate attention and solution πŸ™

kennytilton 2023-05-09T13:33:04.903239Z

np! And thx for surfacing the issues that got me up to speed on :require-macros!