Read the background color from a state declaration. Returns undefined
if not declared.
Read the border color from a state declaration, projecting from
#RRGGBBAA to #RRGGBB. Returns undefined if not declared.
Convert an 8-channel hex color (#RRGGBBAA) to a 6-channel hex color
(#RRGGBB), discarding the alpha channel. Throws if the input is not
a 9-character #-prefixed string.
Graphviz dot does not support alpha; this is a lossy projection.
Read the image filename for a state declaration. Returns undefined if
not declared. Wired into dot output via states_to_nodes_string; the
image property was added to jssm in commit a045569.
Build a graphviz-safe node identifier for a state, by index.
Read the graphviz shape for a state declaration. Returns undefined if
not declared.
Compose a graphviz style string for a state, combining corners and
line-style declarations. Returns either the empty string or a
corners,line,filled-shape string.
Read the text color from a state declaration. Returns undefined if
not declared.
Variant of color8to6 that passes undefined through.
Look up a color from the default viz palette by key, returning empty string if the key is unknown (so it disappears in feature concatenation).
Inject runtime configuration for jssm/viz. Currently only accepts a
custom DOMParser constructor for use by *_svg_element functions in
environments that do not provide one globally (e.g. Node + jsdom).
Idempotent — last call wins. No-op if called with no recognized keys.
// Node, with jsdom:
import { JSDOM } from 'jsdom';
import { configure, fsl_to_svg_element } from 'jssm/viz';
configure({ DOMParser: new JSDOM().window.DOMParser });
const el = await fsl_to_svg_element('a -> b;');
Configuration overrides.
Constructor compatible with the WHATWG DOMParser
interface. Used as a fallback when globalThis.DOMParser is undefined.
Deprecated, no-op compat alias retained from jssm-viz. Does nothing. Will be removed in the next major.
Render a graphviz dot source string to SVG using @viz-js/viz. The
underlying viz instance is lazy-initialized on first call and cached for
the lifetime of the module.
const svg = await dot_to_svg('digraph G { a -> b }');
Graphviz dot source.
A promise resolving to an SVG XML string.
Render an FSL string directly to graphviz dot source.
import { fsl_to_dot } from 'jssm/viz';
const dot = fsl_to_dot('a -> b;');
The FSL source.
A complete graphviz dot source string.
Render an FSL string directly to a parsed SVGSVGElement.
The FSL source.
A promise resolving to a parsed SVGSVGElement.
Render an FSL string directly to SVG.
The FSL source.
A promise resolving to an SVG XML string.
Render a jssm.Machine as a graphviz dot string.
import { sm } from 'jssm';
import { machine_to_dot } from 'jssm/viz';
const dot = machine_to_dot(sm`a -> b;`);
// 'digraph G { ... }'
The machine to render.
A complete graphviz dot source string.
Render a jssm.Machine to a parsed SVGSVGElement.
The machine to render.
A promise resolving to a parsed SVGSVGElement.
Render a jssm.Machine to SVG.
The machine to render.
A promise resolving to an SVG XML string.
Generated using TypeDoc
— test-only access to private helpers.