JSSM, a JavaScript state machine - the FSM for FSL
    Preparing search index...

    Function configure

    • Inject runtime configuration for jssm/viz — a custom DOMParser constructor for the *_svg_element functions, a replacement Graphviz engine for every render path, or both.

      Each key is handled independently. Idempotent — last call wins per key; an omitted (or undefined) key leaves any earlier injection for that key in place, so neither injection can be un-set. No-op if called with no recognized keys.

      Precedence differs by key, on purpose:

      • DOMParser is a fallbackglobalThis.DOMParser (browsers, jsdom test environments) still wins when present.
      • viz is an override — once injected it is used for every render, and the default @viz-js/viz import is never even attempted. This is what lets WASM-hostile environments (strict-CSP webviews such as VS Code's markdown preview) supply an asm.js Graphviz build at runtime, without bundler aliasing. See VizEngine for the exact contract.
      // 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;');
      // strict-CSP webview, with an asm.js Graphviz:
      import { configure, fsl_to_svg_string } from 'jssm/viz';

      configure({ viz: my_asm_graphviz }); // anything with renderString(dot, opts)
      const svg = await fsl_to_svg_string('a -> b;');

      Parameters

      • opts: { DOMParser?: { prototype: DOMParser; new (): DOMParser }; viz?: VizEngine }

        Configuration overrides.

        • OptionalDOMParser?: { prototype: DOMParser; new (): DOMParser }

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

        • Optionalviz?: VizEngine

          A ready-to-use Graphviz engine implementing VizEngine (renderString(dot, opts)). Overrides the default @viz-js/viz engine for all subsequent renders.

      Returns void

      if DOMParser is provided and is not a constructor.

      if viz is provided and lacks a callable renderString.

      VizEngine