Skip to content

@xstate/graph@1.2.0

Compare
Choose a tag to compare
@github-actions github-actions released this 11 Sep 21:03
· 3811 commits to main since this release
58d15ac

Minor Changes

  • 142f54e1 #1366 Thanks @davidkpiano! - The toDirectedGraph(...) function was added, which converts a machine into an object that can be used in many different graph-based and visualization tools:

    import { toDirectedGraph } from '@xstate/graph';
    
    const machine = createMachine({/* ... */});
    
    const digraph = toDirectedGraph(machine);
    
    // returns an object with this structure:
    {
      id: '...',
      stateNode: /* StateNode */,
      children: [
        { id: '...', children: [/* ... */], edges: [/* ... */] },
        { id: '...', /* ... */ },
        // ...
      ],
      edges: [
        { source: /* ... */, target: /* ... */, transition: /* ... */ }
        // ...
      ]
    }