Inspect live BlaC instances, their state and change history — in an in-app overlay or the Chrome DevTools panel.
BlaC DevTools lets you inspect live instances, browse each instance’s state and change history, diff any change against the one before it, and follow a global log of created, changed and disposed instances. The same panel runs in an in-app overlay and in a Chrome DevTools tab.
DevTools is delivered as a plugin: once installed it observes every state container from the outside, so there is nothing to wire up per bloc. Keep it scoped to environment: 'development'.
Packages
Package
What it does
@blac/devtools-connect
The agent plugin that records instances, and the client that reads it
This is the minimum setup. The agent records recent history for every container but sends nothing — and serializes nothing — until a DevTools client attaches.
2. Add the in-app overlay (optional)
Terminal window
pnpmadd@blac/devtools-ui
import{ BlacDevtoolsUi }from'@blac/devtools-ui';
functionApp(){
return(
<>
<YourApp/>
<BlacDevtoolsUi/>
</>
);
}
<BlacDevtoolsUi /> renders a panel docked to the bottom of the page, toggled with Alt+D (or by dispatching a blac-devtools-toggle event on window). Drag its top edge to resize. The overlay connects only while it is open, and it renders in a Shadow DOM so it cannot clash with your app’s CSS.
3. Chrome extension (optional)
Install the BlaC Chrome Extension from the Chrome Web Store (or build apps/devtools-extension/). A BlaC tab appears in Chrome DevTools. It attaches to the inspected tab’s top frame, follows reloads (keeping the selected instance), and reconnects if the extension’s service worker restarts.
Agent options
createDevToolsAgent({
historySize:50,// recorded changes kept per instance
maxDisposed:100,// disposed instances kept listed
});
What you can do
Inspect instances
The Instances view lists every container grouped by class, with a text filter, a toggle for disposed instances, and a change counter that flashes when an instance updates. Select one to open the inspector:
the args that keyed the instance, so two instances of the same class are easy to tell apart;
its current state as a collapsible tree (Maps, Sets, Dates, Errors and other non-JSON values are tagged);
its history, newest first, with the paths each change touched.
State is sent only for the selected instance; everything else sends just metadata, which keeps large apps responsive.
Diff a change
Select a history entry to see its state and a Changes list — every path that was added, removed or changed compared with the previous entry, with before and after values.
Follow the log
The Log view is a bounded, global stream of created, changed and disposed events. Click an entry to jump to that instance and history entry.
Keyboard shortcut
Press Alt+D to toggle the in-app overlay.
Excluding instances from DevTools
High-frequency or internal state containers can be hidden:
Cubit<S> is a StateContainer<S> that exposes mutation publicly.
That is the whole difference, and it is a real one: on StateContaineremit / patch / update are protected, so a container mutates itself
from its own methods and callers go through the API it chooses to publish.
Cubit re-declares the three as public for the cases where a caller
legitimately drives state from outside — test helpers, devtools
time-travel, benchmarks.
Reach for StateContainer when business logic should live in the class,
and Cubit when the caller owns the transitions.
Cubit<S> is a StateContainer<S> that exposes mutation publicly.
That is the whole difference, and it is a real one: on StateContaineremit / patch / update are protected, so a container mutates itself
from its own methods and callers go through the API it chooses to publish.
Cubit re-declares the three as public for the cases where a caller
legitimately drives state from outside — test helpers, devtools
time-travel, benchmarks.
Reach for StateContainer when business logic should live in the class,
and Cubit when the caller owns the transitions.
const client =newDevToolsClient(transport);// any ClientTransport
render(<Panelclient={client}/>);
The wire protocol (@blac/devtools-connect/protocol) is versioned: every agent message carries a session and a seq, a client that sees a gap asks for a snapshot, and a protocol mismatch is reported in the panel instead of misbehaving.