Module: lib/core/trace/format

Renders a trace as a readable causal tree.

The output is deliberately a text tree rather than a graphical inspector. A causal trace is a tree of short lines — that is its natural shape — and a tree in a terminal is diffable, pasteable into an issue, greppable, and available the moment a developer wants it.

Reading order follows causality, not time: each node is printed under the thing that caused it, so the answer to "why did this DOM node change" is always the line above it.

Source:

Members

(static, constant) REASON_DESCRIPTIONS :Object:.<string:, string:>

Human-readable explanations for each NonDeterminismReason.

These live here rather than in schema.js because they are presentation, not structure — and because schema.js is in the runtime's import graph, where a block of prose no application will ever render would be dead weight in every bundle.

Type:
  • Object:.<string:, string:>
Source:

Methods

(static) formatDeterminism(trace) → {string}

Renders a trace's determinism verdict and, when relevant, why it was downgraded.

Parameters:
Name Type Description
trace object

The trace.

Source:
Returns:

The summary.

Type
string

(static) formatNode(node) → {string}

Renders one node as a single line, without its children.

Parameters:
Name Type Description
node object

The node.

Source:
Returns:

The line.

Type
string

(static) formatTrace(trace, optionsopt) → {string}

Renders a whole trace as a causal tree, with a determinism summary.

Parameters:
Name Type Attributes Description
trace object

The trace.

options object <optional>

Rendering options.

Properties
Name Type Attributes Description
maxRoots number <optional>

How many causal roots to render.

Source:
Returns:

The rendered trace.

Type
string

(static) summarizeTrace(trace) → {Object}

Summarises a trace for a listing row.

Parameters:
Name Type Description
trace object

The trace.

Source:
Returns:
Type
Object

(inner) renderSubtree(node, children, prefix, isLast, out, seen)

Renders the subtree under a node using box-drawing connectors.

Parameters:
Name Type Description
node object

The node to render.

children Map:.<(number:|null:), Array:.<object:>>

Children keyed by parent id.

prefix string

The accumulated indent.

isLast boolean

Whether this node is its parent's last child.

out Array:.<string:>

Lines collected so far.

seen Set:.<number:>

Guards against a malformed trace with a parent cycle.

Source: