Skip to content

Commit

Permalink
Added focus-target support. See fulcro.inspect.tool ns.
Browse files Browse the repository at this point in the history
  • Loading branch information
awkay committed Dec 26, 2024
1 parent f4e633b commit bf1cbf5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
org.clojure/clojure {:mvn/version "1.11.4"}
org.clojure/clojurescript {:mvn/version "1.11.132"}
org.clojure/core.async {:mvn/version "1.6.681"}
com.fulcrologic/fulcro-devtools-remote {:mvn/version "0.2.4"}
com.fulcrologic/fulcro-devtools-remote {:mvn/version "0.2.5"}
com.cognitect/transit-cljs {:mvn/version "0.8.280"}}
:aliases {:tool {:extra-paths ["src/client" "src/ui" "src/chrome" "src/electron" "resources"]
:extra-deps {com.wsscode/pathom {:mvn/version "2.4.0"}
Expand Down
2 changes: 1 addition & 1 deletion script/release-chrome
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ mkdir -p releases
rm -rf releases/chrome
cp -rf shells/chrome releases
cd releases/chrome
rm -rf icons.sketch js/extension/cljs-runtime/ js/devtool/manifest.edn manifest.edn js/content-script/cljs-runtime screenshot-*
rm -rf icons.sketch js/extension/cljs-runtime/ js/devtool/cljs-runtime js/devtool/manifest.edn manifest.edn js/content-script/cljs-runtime screenshot-*
zip -r ../fulcro-inspect-chrome-$(jq -r '.version' manifest.json).zip *
2 changes: 1 addition & 1 deletion shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:output-dir "shells/chrome/js/extension"
:asset-path "js/extension"
:runtime :custom
:modules {:service-worker {:init-fn com.fulcrologic.devtools.chrome.background-worker/init}}}
:modules {:service-worker {:entries [com.fulcrologic.devtools.chrome.background-worker]}}}
:chrome-content-script {:target :browser
:output-dir "shells/chrome/js/content-script"
:asset-path "js/content-script"
Expand Down
2 changes: 1 addition & 1 deletion shells/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
"matches":["<all_urls>"],
"run_at":"document_idle"}],
"manifest_version":3,
"version":"4.0.3"}
"version":"4.0.4"}
9 changes: 9 additions & 0 deletions src/lib/fulcro/inspect/tool.cljc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(ns fulcro.inspect.tool
(:require
[com.fulcrologic.devtools.common.protocols :as dp]
[com.fulcrologic.devtools.common.resolvers :as res]
[com.fulcrologic.devtools.common.target :as ct]
[com.fulcrologic.fulcro.inspect.devtool-api :as dapi]
[com.fulcrologic.fulcro.inspect.inspect-client
:refer [app-uuid db-changed! ilet record-history-entry! state-atom]]
[com.fulcrologic.fulcro.inspect.target-impl :refer [apps* handle-inspect-event]]
Expand Down Expand Up @@ -29,3 +31,10 @@
(record-history-entry! app @state*)
(tools/register-tool! app (partial handle-inspect-event tconn))
(add-watch state* id #(db-changed! app %3 %4))))))

(defn focus-inspector! [app-or-app-id]
(let [id (if (uuid? app-or-app-id)
app-or-app-id
(:com.fulcrologic.fulcro.application/id app-or-app-id))
conn (get @tool-connections id)]
(dp/transmit! conn id [(dapi/focus-target {:com.fulcrologic.fulcro.application/id id})])))
2 changes: 1 addition & 1 deletion src/ui/fulcro/inspect/common.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[com.fulcrologic.fulcro.mutations :as fm]
[fulcro.inspect.lib.history :as hist]
[fulcro.inspect.lib.local-storage :as storage]
[fulcro.inspect.target-api-impl]
[fulcro.inspect.devtool-api-impl]
[fulcro.inspect.ui-parser :as ui-parser]
[fulcro.inspect.ui.data-watcher :as data-watcher]
[fulcro.inspect.ui.element :as element]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
(ns fulcro.inspect.target-api-impl
(ns fulcro.inspect.devtool-api-impl
(:require
[com.fulcrologic.devtools.common.built-in-mutations :as bi]
[com.fulcrologic.devtools.common.resolvers :as dres]
[com.fulcrologic.fulcro.application :as app]
[com.fulcrologic.fulcro.components :as fp]
[com.fulcrologic.fulcro.inspect.devtool-api :as tapi]
[com.fulcrologic.fulcro.inspect.devtool-api :as dapi]
[com.wsscode.pathom.connect :as pc]
[fulcro.inspect.lib.history :as hist]
[fulcro.inspect.ui.inspector :as inspector]
[fulcro.inspect.ui.multi-inspector :as multi-inspector]
[fulcro.inspect.ui.network :as network]))

(dres/defmutation app-started [{:fulcro/keys [app]} params]
{::pc/sym `tapi/app-started}
{::pc/sym `dapi/app-started}
(fp/transact! app `[(fulcro.inspect.common/start-app ~params)])
nil)

Expand All @@ -26,19 +27,19 @@
(not connected?) (fp/transact! app [(multi-inspector/remove-all-inspectors {})])))

(dres/defmutation send-started [{:fulcro/keys [app]} params]
{::pc/sym `tapi/send-started}
{::pc/sym `dapi/send-started}
(fp/transact! app [(network/request-start params)]
{:ref [:network-history/id [:x (::app/id params)]]})
nil)

(dres/defmutation send-finished [{:fulcro/keys [app]} params]
{::pc/sym `tapi/send-finished}
{::pc/sym `dapi/send-finished}
(fp/transact! app [(network/request-finish params)]
{:ref [:network-history/id [:x (::app/id params)]]})
nil)

(dres/defmutation send-failed [{:fulcro/keys [app]} params]
{::pc/sym `tapi/send-failed}
{::pc/sym `dapi/send-failed}
(fp/transact! app [(network/request-finish params)]
{:ref [:network-history/id [:x (::app/id params)]]})
nil)
Expand All @@ -50,12 +51,18 @@
{:ref [:fulcro.inspect.ui.transactions/tx-list-id [:x id]]}))

(dres/defmutation optimistic-action [{:fulcro/keys [app]} params]
{::pc/sym `tapi/optimistic-action}
{::pc/sym `dapi/optimistic-action}
(new-client-tx app params)
nil)

(dres/defmutation update-client-db [{:fulcro/keys [app]} {::app/keys [id]
:history/keys [version value] :as history-step}]
{::pc/sym `tapi/db-changed}
{::pc/sym `dapi/db-changed}
(fp/transact! app [(hist/save-history-step history-step)])
nil)

(dres/defmutation focus-target [{:fulcro/keys [app]} {::app/keys [id]}]
{::pc/sym `dapi/focus-target}
(when id
(fp/transact! app [(multi-inspector/set-app {::inspector/id [:x id]})]))
nil)

0 comments on commit bf1cbf5

Please sign in to comment.