portal

2023-11-16T03:43:22.797609Z

I'm having an issue with sending \c char values to portal. they show up as a wrapped value something like pU {code: 40, P: 2153775104, aa: 0} in the devtools. 40 = ASCII for ( which is the character that's supposed to be. but that value does not pass char? called from a custom view. CLJS is expecting 1-length strings, (defn char? [x] (and (string? x) (== 1 (.-length x))))

djblue 2023-11-16T03:47:10.065049Z

Ohh dang, I didn't even know that was a thing in cljs 😂 https://github.com/djblue/portal/blob/master/src/portal/runtime/cson.cljc#L277-L298 is how chars are represented in cljs

djblue 2023-11-16T03:47:50.022139Z

Might need to provide a custom version of that fn for sci that can check this type and do the default thing maybe 🤔

2023-11-16T03:52:16.962159Z

is there a #?(:sci ...) form? if not I guess I could do something like #?(:cljs (and (object? x) (number? (.code x))))

djblue 2023-11-16T03:52:38.053009Z

I think I added a :portal one that might be useful here

2023-11-16T03:52:43.339209Z

that's close enough for my purposes; I'm just trying to tell apart strings, vectors, maps and chars.

2023-11-16T03:52:46.643149Z

ah, that would work.

2023-11-16T03:59:53.161479Z

there's a weird inconsistency here. if I (p/eval-str "\\c") I get "c", ie. a 1-length string in CLJS fashion.

2023-11-16T04:03:04.590649Z

I guess p/eval-str is plain CLJS, while the values sent via tap> are sci values? but that means I can't write #?(:portal ...) in a ns required by my custom viewer and then p/eval-str it; that's :cljs.

djblue 2023-11-16T04:04:01.558339Z

I see 🤔

djblue 2023-11-16T04:24:40.619839Z

Ok, I think you want (or (char? "c") (portal.ui.inspector/char? ))

2023-11-16T18:22:16.265349Z

that seems to be working behind the #?(:portal ...) conditional.

1