JVM (Clojure) Fulcro Inspect connector for TUI apps.
This is the small CLJ shim that fills the only gap preventing a plain JVM Fulcro app from
connecting to the standalone Fulcro Inspect (Electron) app: a DevToolConnectionFactory
that speaks Sente over a real websocket from the JVM.
The entire inspect event-generation pipeline (transactions, network, db-changed) and the
devtools-remote transport (connection, target, resolvers) are already CLJC and ship transitively
with Fulcro 3.10.x. The only CLJS-only piece is com.fulcrologic.devtools.electron.target
(it uses goog-define and enc/get-win-loc). This namespace is a CLJ analog of that factory.
Usage (debug only):
(require '[com.fulcrologic.fulcro.tui.inspect :as tui-inspect]) (tui-inspect/install!) ; register the JVM websocket factory ONCE (tui-inspect/add-inspect! app) ; attach inspect to your TUI app
Requires the Fulcro Inspect Electron app to be running (it hosts the websocket server on localhost:8237). Also requires the inspect pipeline to be enabled in CLJ via the JVM property:
-Dcom.fulcrologic.fulcro.inspect=true
(Without that property fulcro.inspect.tool/add-fulcro-inspect! is a no-op, because its body is
wrapped in the ilet macro that only emits in CLJ when that property is "true".)
JVM (Clojure) Fulcro Inspect connector for TUI apps. This is the small CLJ shim that fills the only gap preventing a plain JVM Fulcro app from connecting to the standalone Fulcro Inspect (Electron) app: a `DevToolConnectionFactory` that speaks Sente over a real websocket from the JVM. The entire inspect event-generation pipeline (transactions, network, db-changed) and the devtools-remote transport (connection, target, resolvers) are already CLJC and ship transitively with Fulcro 3.10.x. The only CLJS-only piece is `com.fulcrologic.devtools.electron.target` (it uses `goog-define` and `enc/get-win-loc`). This namespace is a CLJ analog of that factory. Usage (debug only): (require '[com.fulcrologic.fulcro.tui.inspect :as tui-inspect]) (tui-inspect/install!) ; register the JVM websocket factory ONCE (tui-inspect/add-inspect! app) ; attach inspect to your TUI app Requires the Fulcro Inspect Electron app to be running (it hosts the websocket server on localhost:8237). Also requires the inspect pipeline to be enabled in CLJ via the JVM property: -Dcom.fulcrologic.fulcro.inspect=true (Without that property `fulcro.inspect.tool/add-fulcro-inspect!` is a no-op, because its body is wrapped in the `ilet` macro that only emits in CLJ when that property is "true".)
(add-inspect! app)Enable inspect, install the JVM websocket factory, and attach Fulcro Inspect to app. Order
matters: enable! flips the inspect gates so the body of add-fulcro-inspect! (and connect!)
actually runs; install! registers the JVM websocket transport that connect! uses; then
add-fulcro-inspect! does everything else — registers the app in the inspect registry, seeds
history, installs the state watcher that emits db-changed, and wires the connection's request
processor to the devtools Pathom parser. The parser's resolvers (transactions, network, db/history,
and the statecharts integration's :statechart/available-sessions) register themselves simply by
being loaded, and the app already loads them by using statecharts — so there is nothing to register
here. The only genuinely JVM-specific pieces are the websocket transport and transit encoding (see
inspect-write, which lets state/session payloads carry java.time.Instant etc. without being
silently dropped).
Debug-only convenience: force-enables both inspect gates so no -D flags are needed. Requires the
standalone Fulcro Inspect (Electron) app running (websocket server on localhost:8237).
Enable inspect, install the JVM websocket factory, and attach Fulcro Inspect to `app`. Order matters: `enable!` flips the inspect gates so the body of `add-fulcro-inspect!` (and `connect!`) actually runs; `install!` registers the JVM websocket transport that `connect!` uses; then `add-fulcro-inspect!` does everything else — registers the app in the inspect registry, seeds history, installs the state watcher that emits `db-changed`, and wires the connection's request processor to the devtools Pathom parser. The parser's resolvers (transactions, network, db/history, and the statecharts integration's `:statechart/available-sessions`) register themselves simply by being loaded, and the app already loads them by using statecharts — so there is nothing to register here. The only genuinely JVM-specific pieces are the websocket transport and transit encoding (see `inspect-write`, which lets state/session payloads carry `java.time.Instant` etc. without being silently dropped). Debug-only convenience: force-enables both inspect gates so no `-D` flags are needed. Requires the standalone Fulcro Inspect (Electron) app running (websocket server on localhost:8237).
(enable!)Force BOTH inspect enable-gates ON at runtime, so callers don't need JVM -D flags.
There are TWO independent gates:
com.fulcrologic.fulcro.inspect.inspect-client/INSPECT (sysprop com.fulcrologic.fulcro.inspect)
gates Fulcro's ido/ilet (including fulcro.inspect.tool/add-fulcro-inspect!).com.fulcrologic.devtools.common.target/INSPECT (sysprop com.fulcrologic.devtools.enabled)
gates target/connect! (the ido around the websocket connection itself).Both are read once at ns-load, so flipping the system property after load is not enough — we
alter-var-root the realized vars directly.
Force BOTH inspect enable-gates ON at runtime, so callers don't need JVM `-D` flags.
There are TWO independent gates:
* `com.fulcrologic.fulcro.inspect.inspect-client/INSPECT` (sysprop `com.fulcrologic.fulcro.inspect`)
gates Fulcro's `ido`/`ilet` (including `fulcro.inspect.tool/add-fulcro-inspect!`).
* `com.fulcrologic.devtools.common.target/INSPECT` (sysprop `com.fulcrologic.devtools.enabled`)
gates `target/connect!` (the `ido` around the websocket connection itself).
Both are read once at ns-load, so flipping the system property after load is not enough — we
`alter-var-root` the realized vars directly.(inspect-write x)Serializes x to a transit string for the inspect websocket. Like
com.fulcrologic.devtools.common.transit/write (strips lambdas, no metadata) but installs a
transit :default-handler so an unencodable value becomes a display marker rather than throwing
(and being silently dropped). Scoped to the inspect packer ONLY — it does not touch the global
transit registry, so the app's own client/server wire format is unaffected. Returns the string, or
nil on an unexpected failure (logged).
Serializes `x` to a transit string for the inspect websocket. Like `com.fulcrologic.devtools.common.transit/write` (strips lambdas, no metadata) but installs a transit `:default-handler` so an unencodable value becomes a display marker rather than throwing (and being silently dropped). Scoped to the inspect packer ONLY — it does not touch the global transit registry, so the app's own client/server wire format is unaffected. Returns the string, or `nil` on an unexpected failure (logged).
(install!)Register the JVM websocket DevToolConnectionFactory (call once).
Register the JVM websocket DevToolConnectionFactory (call once).
(start-ws-messaging! conn)Establish the Sente websocket client for conn and run the send/receive go-loops.
This is a CLJ port of com.fulcrologic.devtools.electron.target/start-ws-messaging!:
the only differences are (1) fixed host/port instead of goog-define, (2) no get-win-loc
browser protocol sniffing, and (3) :type :ws (the JVM Sente client supports websockets only,
not the ajax long-poll fallback).
Establish the Sente websocket client for `conn` and run the send/receive go-loops. This is a CLJ port of `com.fulcrologic.devtools.electron.target/start-ws-messaging!`: the only differences are (1) fixed host/port instead of `goog-define`, (2) no `get-win-loc` browser protocol sniffing, and (3) `:type :ws` (the JVM Sente client supports websockets only, not the ajax long-poll fallback).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |