Skip to content

generateViewerUpdate

function generateViewerUpdate(params): ViewerUpdate;

Defined in: src/html.ts:457

Render diagram content a running interactive viewer can swap in, without rebuilding the surrounding document. Counterpart to generateHtml for hosts that keep one viewer alive across re-renders (e.g. the VS Code preview) and want to patch it in place — via ViewerHandle.setContent — rather than replace the whole document on every edit.

By default the fragment carries the expanded view and, when there is something to collapse, the fully collapsed one for the toggle to swap to. With relayout: true it carries one view with per-container controls plus a relayoutModel instead — for a viewer whose document generateHtml produced for a diagram with a container, which is what ships the relayout bundle the model needs.

GenerateViewerUpdateParams

ASL definition plus the same options as generateSvg, and optionally relayout.

ViewerUpdate

Content markup plus the data ViewerHandle.setContent needs to rewire it.

import { generateViewerUpdate } from 'sfn-diagram';
const update = generateViewerUpdate({ aslDefinition: asl });
webview.postMessage({ command: 'updateContent', ...update });