portal

nate 2023-10-27T18:03:51.785489Z

I'm working on a custom viewer and I'm hitting an issue.

nate 2023-10-27T18:04:06.002859Z

Here's the custom viewer:

(ns data-viewer
  (:require [portal.ui.api :as p]))

(defn data?
  [v]
  (and (map? v)
       (contains? v :duration)))

(defn view-data []
  (fn [data]
    [:<>
     [:h1 "Duration"]
     [:portal.viewer/inspector
      {:portal.viewer/default :portal.viewer/duration-ms}
      (:duration data)]]))

(p/register-viewer!
 {:name ::viewer
  :predicate data?
  :component view-data})

nate 2023-10-27T18:04:44.816479Z

When I tap this:

(tap> (with-meta {:duration 39847} {:portal.viewer/default :data-viewer/viewer}))

djblue 2023-10-27T18:06:21.020129Z

Ohh, yeah, when migrating hiccup to reagent, the viewers do need to be resolved manually.

nate 2023-10-27T18:06:33.838679Z

ah

djblue 2023-10-27T18:07:28.400889Z

You can pull in [portal.ui.inspector :as ins] and wrap the value with the ins/inspector component.

nate 2023-10-27T18:07:32.897659Z

heh, you beat me to the screen shot

nate 2023-10-27T18:07:42.330279Z

for the record, it shows up like this

1
nate 2023-10-27T18:09:00.003229Z

that did it!

djblue 2023-10-27T18:09:00.480119Z

Ohh, wait, it's still not wrapping the value with the duration-ms viewer?

nate 2023-10-27T18:09:08.138999Z

that was the before

👌 1
nate 2023-10-27T18:09:30.121629Z

now it does the right thing:

💯 1
nate 2023-10-27T18:11:01.113089Z

related issue, I tried to require portal.viewer in my custom viewer and it threw Could not resolve symbol: implements? when I ran (p/eval-str (slurp "data_viewer.cljs"))

djblue 2023-10-27T18:11:19.858789Z

Ohh, I might need to expose it in sci 👌

nate 2023-10-27T18:11:28.977869Z

I'm using HEAD on master, not the released version

nate 2023-10-27T18:11:32.695139Z

if that helps

nate 2023-10-27T18:11:42.410009Z

oh, right

nate 2023-10-27T18:11:47.091619Z

I forgot that sci was the runtime

djblue 2023-10-27T18:12:18.409529Z

https://github.com/djblue/portal/blob/master/src/portal/ui/sci/libs.cljs#L62 if you want to edit it locally

nate 2023-10-27T18:13:17.411849Z

trying that

nate 2023-10-27T18:18:19.805729Z

diff --git a/src/portal/ui/sci/libs.cljs b/src/portal/ui/sci/libs.cljs
index a4c7e77..12d2bf3 100644
--- a/src/portal/ui/sci/libs.cljs
+++ b/src/portal/ui/sci/libs.cljs
@@ -96,6 +96,7 @@ (def namespaces
     portal.ui.viewer.vega-lite)
    (sci-import/import
     cljs.core/random-uuid
+    cljs.core/implements?
     cljs.core/tap>
     cljs.reader/read-string)
    {'reagent.core
hm, didn't seem to like that:
❯ clojure -X:build prep
=> Generating docs
=> clojure -M:cljs:shadow -m shadow.cljs.devtools.cli release client
[:client] Compiling ...
------ ERROR -------------------------------------------------------------------                                                                                                    File: /home/nate/projects/portal/src/portal/ui/sci/libs.cljs:98:4
--------------------------------------------------------------------------------
  95 |     portal.ui.viewer.tree
  96 |     portal.ui.viewer.vega
  97 |     portal.ui.viewer.vega-lite)
  98 |    (sci-import/import
----------^---------------------------------------------------------------------
null
Unable to resolve var: implements? in this context at line 98 portal/ui/sci/libs.cljs
--------------------------------------------------------------------------------
  99 |     cljs.core/random-uuid
 100 |     cljs.core/implements?
 101 |     cljs.core/tap>
 102 |     cljs.reader/read-string)
--------------------------------------------------------------------------------

-> 17.783 seconds (exit: 1)
Execution error (ExceptionInfo) at tasks.tools/sh* (tools.clj:58).
Non-zero exit code: clojure -M:cljs:shadow -m shadow.cljs.devtools.cli release client

Full report at:
/tmp/clojure-17926749571961529956.edn
perhaps because it's a macro?

djblue 2023-10-27T18:19:35.494809Z

Maybe https://cljs.github.io/api/cljs.core/satisfiesQMARK instead?

nate 2023-10-27T18:20:16.012209Z

macro too

😂 1
nate 2023-10-27T18:22:04.246829Z

if I add another function (like update-keys), the prep works

nate 2023-10-27T18:22:09.126869Z

something about it being a macro

nate 2023-10-27T18:22:58.597449Z

tried a (:require-macros cljs.core) at the top too, no work

Jason Whitlark 2023-10-27T20:10:06.191339Z

When working with portal and devcontainers, I keep running into issues with the config file missing. (vs-code.edn file). But it seems to be complicated by the difference between normal operation and working in a devcontainer, and it seems to be intermittent. Has anyone else run into this?

Jason Whitlark 2023-10-30T13:29:19.943049Z

Thank you. I'll take another look. This seems to be a slightly different issue, I want to say the container creation process is copying the directory, but not the contents. It is certainly related, though. I think I'll have to set up a controlled experiment to narrow down what's going wrong.

Jason Whitlark 2023-10-30T14:36:04.364869Z

Oh, in my repo, someone accidentally merged a change that set portal to an old version. That'll probably be it. Sorry for the confusion.

seancorfield 2023-10-27T20:24:03.514939Z

Yes, and Chris showed me how to solve it... just a sec...

seancorfield 2023-10-27T20:26:08.970729Z

https://github.com/seancorfield/vscode-calva-setup/blob/develop/joyride/src/remote_repl.cljs -- this is how I connect to QA/production REPLs -- in particular, see https://github.com/seancorfield/vscode-calva-setup/blob/develop/joyride/src/remote_repl.cljs#L33 which takes the current Portal config (host/port etc) and sends it to the server to write out locally so that you can open Portal (in my case, into my local VS Code)