Skip to content

ViewerUpdate

Defined in: src/types/index.ts:1160

Diagram content a running interactive viewer can swap in, without rebuilding the surrounding document. Produced by generateViewerUpdate. Hand it to the viewer whole; its fields mirror what the viewer’s content swap reads.

contentHtml: string;

Defined in: src/types/index.ts:1162

Markup for the viewer’s data-sfn="content" node.


edgeData: Record<string, ViewerEdge>;

Defined in: src/types/index.ts:1165

Viewer-facing detail for each edge, keyed by edge id.


hasCollapsedView: boolean;

Defined in: src/types/index.ts:1168

Whether contentHtml embeds a second, collapsed view behind a toggle.


mermaid?: string;

Defined in: src/types/index.ts:1180

Mermaid source for the same diagram, for the viewer toolbar’s copy button. Pass it to the viewer alongside contentHtml, or the button would go on handing out the Mermaid of the diagram that was just replaced.

generateViewerUpdate always sets it. Optional only so that adding it could not break anyone who builds a ViewerUpdate themselves - an adapter or a test double - since release-please ships this as a MINOR and a type-level break there would look like an ordinary upgrade.


metadata: object;

Defined in: src/types/index.ts:1183

Metadata about the rendered diagram (the expanded view’s, when both are shipped).

edgeCount: number;

Number of edges (transitions) in the diagram

nodeCount: number;

Number of state nodes in the diagram


relayoutModel?: unknown;

Defined in: src/types/index.ts:1192

The model for per-container collapse, present when rendered with relayout: true and the diagram has something to collapse. Opaque: pass it through unchanged alongside contentHtml, including across postMessage or JSON. Its contents are a viewer internal that can change in any release (see the compatibility policy).


stateData: Record<string, AslState>;

Defined in: src/types/index.ts:1195

Raw ASL for each state, keyed by state name.