Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

References

Re-exports build_time
Re-exports version

Variables

_test: { background_color_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined); border_color_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined); color8to6: ((color8: string) => string); image_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined); node_of: ((state: string, l_states: string[]) => string); shape_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined); style_for_state: (<T>(u_jssm: Machine<T>, state: string) => string); text_color_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined); u_color8to6: ((color8?: string) => string | undefined); vc: ((col: string) => string) } = ...
internal

— test-only access to private helpers.

Type declaration

  • background_color_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined)
      • <T>(u_jssm: Machine<T>, state: string): string | undefined
      • Read the background color from a state declaration. Returns undefined if not declared.

        internal

        Type Parameters

        • T

        Parameters

        Returns string | undefined

  • border_color_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined)
      • <T>(u_jssm: Machine<T>, state: string): string | undefined
      • Read the border color from a state declaration, projecting from #RRGGBBAA to #RRGGBB. Returns undefined if not declared.

        internal

        Type Parameters

        • T

        Parameters

        Returns string | undefined

  • color8to6: ((color8: string) => string)
      • (color8: string): string
      • 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.

        internal

        Parameters

        • color8: string

        Returns string

  • image_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined)
      • <T>(u_jssm: Machine<T>, state: string): string | undefined
      • 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.

        internal

        Type Parameters

        • T

        Parameters

        Returns string | undefined

  • node_of: ((state: string, l_states: string[]) => string)
      • (state: string, l_states: string[]): string
      • Build a graphviz-safe node identifier for a state, by index.

        internal

        Parameters

        • state: string
        • l_states: string[]

        Returns string

  • shape_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined)
      • <T>(u_jssm: Machine<T>, state: string): string | undefined
      • Read the graphviz shape for a state declaration. Returns undefined if not declared.

        internal

        Type Parameters

        • T

        Parameters

        Returns string | undefined

  • style_for_state: (<T>(u_jssm: Machine<T>, state: string) => string)
      • <T>(u_jssm: Machine<T>, state: string): string
      • 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.

        internal

        Type Parameters

        • T

        Parameters

        Returns string

  • text_color_for_state: (<T>(u_jssm: Machine<T>, state: string) => string | undefined)
      • <T>(u_jssm: Machine<T>, state: string): string | undefined
      • Read the text color from a state declaration. Returns undefined if not declared.

        internal

        Type Parameters

        • T

        Parameters

        Returns string | undefined

  • u_color8to6: ((color8?: string) => string | undefined)
      • (color8?: string): string | undefined
      • Variant of color8to6 that passes undefined through.

        internal

        Parameters

        • Optional color8: string

        Returns string | undefined

  • vc: ((col: string) => string)
      • (col: string): string
      • 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).

        internal

        Parameters

        • col: string

        Returns string

Functions

  • 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;');
    throws

    {JssmError} if DOMParser is provided and is not a constructor.

    Parameters

    • opts: { DOMParser?: { prototype: <internal>.DOMParser } }

      Configuration overrides.

      • Optional DOMParser?: { prototype: <internal>.DOMParser }

        Constructor compatible with the WHATWG DOMParser interface. Used as a fallback when globalThis.DOMParser is undefined.

    Returns void

  • Deprecated, no-op compat alias retained from jssm-viz. Does nothing. Will be removed in the next major.

    deprecated

    Use machine_to_dot instead.

    Type Parameters

    • T

    Parameters

    Returns void

  • dot_to_svg(dot: string): Promise<string>
  • 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 }');
    

    Parameters

    • dot: string

      Graphviz dot source.

    Returns Promise<string>

    A promise resolving to an SVG XML string.

  • fsl_to_dot(fsl: string): string
  • Render an FSL string directly to graphviz dot source.

    import { fsl_to_dot } from 'jssm/viz';
    const dot = fsl_to_dot('a -> b;');

    Parameters

    • fsl: string

      The FSL source.

    Returns string

    A complete graphviz dot source string.

  • Render an FSL string directly to a parsed SVGSVGElement.

    throws

    {JssmError} if no DOMParser is available (Node without configure).

    Parameters

    • fsl: string

      The FSL source.

    Returns Promise<<internal>.SVGSVGElement>

    A promise resolving to a parsed SVGSVGElement.

  • fsl_to_svg_string(fsl: string): Promise<string>
  • Render an FSL string directly to SVG.

    Parameters

    • fsl: string

      The FSL source.

    Returns Promise<string>

    A promise resolving to an SVG XML string.

  • machine_to_dot<T>(u_jssm: Machine<T>): 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 { ... }'

    Type Parameters

    • T

    Parameters

    • u_jssm: Machine<T>

      The machine to render.

    Returns string

    A complete graphviz dot source string.

  • machine_to_svg_string<T>(u_jssm: Machine<T>): Promise<string>

Generated using TypeDoc