import * as react from 'react'; /** One row of the `MsgLog`: a timestamp, a category and the text to show. */ type MsgLogEntry = { /** Display timestamp (whatever format you produced). */ ts: string; /** Visual category — drives the row icon. Defaults to "msg" via CSS. */ kind?: "msg" | "sub" | "cmd" | "ok" | "fail"; /** Row text — usually the Msg tag plus a short detail. */ text: string; }; /** Props for `MsgLog`: the rows to render and an optional `className`. */ interface MsgLogProps { history: readonly MsgLogEntry[]; className?: string; } /** * React component that renders a list of `MsgLogEntry` rows as a message log. */ declare function MsgLog({ history, className }: MsgLogProps): react.JSX.Element; /** * A single differing leaf value between two states. * * - `kind: "added"` — the path exists in `actual` but not `expected` * (`expected` is `undefined`). * - `kind: "removed"` — the path exists in `expected` but not `actual` * (`actual` is `undefined`). * - `kind: "changed"` — the path exists on both sides with differing leaf * values (or differing kinds, e.g. object vs array). */ interface StateChange { /** Access path from the state root, e.g. `state.items[1].status`. */ path: string; /** How the cell differs between the two states. */ kind: "added" | "removed" | "changed"; /** The value on the `expected` side (`undefined` when `added`). */ expected: unknown; /** The value on the `actual` side (`undefined` when `removed`). */ actual: unknown; } /** * Deep-walk two states and return EVERY differing leaf value, in deterministic * pre-order (the node before its children; children in array-index order, then * sorted-union key order for objects). The empty array means the two states are * deeply equal. * * Equality + path grammar match `../trace-replay`'s `firstDivergence` exactly: * - `Object.is` leaf equality, so `NaN` equals `NaN` and `+0` ≠ `-0`. * - arrays index by `[i]`; a length mismatch is NOT reported at the array * node — instead each surplus/missing element surfaces as its own * added/removed child, which is what a devtools list wants to show. * - objects walk the sorted union of both sides' keys; a key on only one * side becomes an `added`/`removed` child. * - the root path is `"state"`. * * Scope is JSON-shaped state (the same substrate trace-replay targets): * primitives, null/undefined, arrays, plain objects. A differing kind at a node * (object vs array, number vs string) is reported as a single `changed` at that * node — the walk does not descend into mismatched kinds. */ declare function diffState(expected: unknown, actual: unknown): StateChange[]; /** * Pretty multi-line text for a {@link diffState} result. One `±`-prefixed line * per change, in the array's (pre-order, deterministic) order: * * - `~ state.total: 121.5 → 135` (changed: old → new) * - `- state.coupon: "X"` (removed: only the old value) * - `+ state.tax: 8` (added: only the new value) * * Deterministic given a deterministic `changes` array. An empty array yields * the empty string. */ declare function formatDiff(changes: StateChange[]): string; /** * Props for `StateDiff`: the `expected` and `actual` states to compare, and an * optional `className`. */ interface StateDiffProps { /** * The baseline / "before" state — what you expected. In a regression view * this is a trace's recorded `finalState`; in a time-travel view it's the * previous model. */ expected: unknown; /** * The "after" state to compare against `expected` — the recomputed or * current model. */ actual: unknown; /** Optional className appended to the container. Use to override layout. */ className?: string; } /** * Presentational diff of two states. Renders {@link diffState}'s output as a * color-coded list (added / removed / changed), reusing the devtools `tea-dt-*` * class convention so it inherits the same design tokens as `` * and `` (see ./styles.css). No state, no subscription — pass the two * states as props, exactly like the rest of /devtools. * * When the states are deeply equal the list is empty; a tiny "no changes" hint * renders so an operator can tell "equal" from "not yet computed". */ declare function StateDiff({ expected, actual, className }: StateDiffProps): react.JSX.Element; /** * Props for `StateInspector`: the `state` to show, an optional `flashKey`, and * an optional `className`. */ interface StateInspectorProps { /** * The machine state to display. Render-derived shape — pass whatever you * want surfaced to the inspector (often a hand-picked subset of the model). */ state: unknown; /** * When this number changes, the inspector flashes. Pass `model.msgCount` or * any other monotonic counter you already have. Omit to disable flashing. */ flashKey?: number; /** * Optional className appended to the container. Use to override layout. */ className?: string; } /** * React component that renders a state value as formatted JSON, and flashes * when `flashKey` changes. */ declare function StateInspector({ state, flashKey, className, }: StateInspectorProps): react.JSX.Element; /** * Wrap a `dispatch` so every Msg it sees lands in a bounded history buffer. * * `derive` lets you map a Msg to a richer entry (e.g. assign `kind: "sub"` to * subscription-triggered messages). Default: every msg becomes a `"msg"` row * tagged with `msg._tag` (or `String(msg)` if it has no `_tag`). The substrate * uses `_tag` as the Msg discriminant — using `type` here would render every * Msg as `[object Object]` in the inspector. * * `max` caps the buffer — oldest entries fall off (LIFO, newest first). * * `now` is the timestamp source for the default `derive`. Defaults to * `nowTs` (real wall-clock). Tests inject a deterministic shim so * snapshots don't drift; production code never sets it. */ declare function useMsgHistory(dispatch: (msg: M) => void | Promise, opts?: { max?: number; derive?: (msg: M) => MsgLogEntry; now?: () => string; }): readonly [readonly MsgLogEntry[], (msg: M) => void, () => void]; export { MsgLog, type MsgLogEntry, type MsgLogProps, type StateChange, StateDiff, type StateDiffProps, StateInspector, type StateInspectorProps, diffState, formatDiff, useMsgHistory };