{
  "id": "task_libraries:state-machine/javascript",
  "path": "/exapedia/javascript-state-machine-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "JavaScript state machine libraries",
  "answer": [
    {
      "t": "text",
      "text": "JavaScript state machine libraries model application logic as a fixed set of states and the events that move between them. A machine accepts only the transitions its definition allows rather than any combination of flags. These libraries keep checkout flows, UI components, and AI agent workflows in a known state at every step."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "JavaScript state machine libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#xstate-fsm",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F124"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F125"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F133"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F126"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#xstate",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F141"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F148"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#machina",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F156"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F163"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#robot",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F167"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F171"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F169"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#zag-js-core",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F182"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F186"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#finity",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F195"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F199"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F197"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#javascript-state-machine",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F212"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#stately-js",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F227"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "npm"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#xstate-fsm",
          "label": [
            {
              "t": "text",
              "text": "XState FSM"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F125"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Nested state models",
            "Parallel state regions"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#xstate-fsm",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F124"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F134"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F135"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#xstate",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F141"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F150"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#machina",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F156"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#robot",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F167"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#zag-js-core",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F182"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#finity",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F195"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F205"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F206"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#javascript-state-machine",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F212"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#stately-js",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F227"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F237"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F238"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "xstate-fsm",
          "name": [
            {
              "t": "fact",
              "fact": "F124"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/statelyai/xstate"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/@xstate/fsm"
            },
            {
              "label": "Docs",
              "href": "https://cdn.jsdelivr.net/npm/@xstate/fsm@2.1.0/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F131"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F125"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F133"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F127"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F126"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://cdn.jsdelivr.net/npm/@xstate/fsm@2.1.0/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F124"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F139"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F140"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/reach/reach-ui",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F139"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "const getServiceState = <\n\tTContext extends object,\n\tTEvent extends MachineEvent = MachineEvent,\n\tTState extends Typestate<TContext> = any\n>(\n\tservice: StateMachine.Service<TContext, TEvent, TState>\n): StateMachine.State<TContext, TEvent, TState> => {\n\tlet currentValue: StateMachine.State<TContext, TEvent, TState>;\n\tservice\n\t\t.subscribe((state) => {\n\t\t\tcurrentValue = state;\n\t\t})\n\t\t.unsubscribe();\n\treturn currentValue!;\n};\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/reach/reach-ui/blob/b3d94d22811db6b5c0f272b9a7e2e3c1bb4699ae/packages/machine/src/reach-machine.ts#L18-L32",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F138"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=%40xstate/fsm%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F124"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "import { createMachine } from '@xstate/fsm';\n\nconst machine = createMachine({\n  initial: 'idle',\n  states: { idle: { on: { START: 'running' } }, running: {} },\n});\nconst nextState = machine.transition(machine.initialState, 'START');\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://cdn.jsdelivr.net/npm/@xstate/fsm@2.1.0/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F129"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "xstate",
          "name": [
            {
              "t": "fact",
              "fact": "F141"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/statelyai/xstate"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/xstate"
            },
            {
              "label": "Docs",
              "href": "https://github.com/statelyai/xstate/blob/bd77717b8d33c49af1c8ee4a7e22cebb936cc8b1/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F12"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F148"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/statelyai/xstate/blob/bd77717b8d33c49af1c8ee4a7e22cebb936cc8b1/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F141"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F20"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F154"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F155"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/processone/fluux-messenger",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F154"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "typescript",
              "code": "private sendMachineEvent(event: ConnectionMachineEvent, source: string): void {\n    const before = this.getMachineState()\n    this.connectionActor.send(event)\n    const after = this.getMachineState()\n    const beforeText = JSON.stringify(before)\n    const afterText = JSON.stringify(after)\n    const message = `Machine event ${event.type} from ${source}: ${beforeText} -> ${afterText}`\n    this.logTrace(message)\n  }\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/processone/fluux-messenger/blob/583459002bde4f21cbb53a3556d81b7bf2a5b7c6/packages/fluux-sdk/src/core/modules/Connection.ts#L362-L370",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F153"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20xstate%20for%20explicit%20state%20machines%2C%20transitions%2C%20guards%20and%20asynchronous%20effects&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F141"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "typescript",
              "code": "import { createMachine, createActor } from 'xstate';\n\nconst machine = createMachine({\n  initial: 'idle',\n  states: { idle: { on: { START: 'running' } }, running: {} },\n});\nconst actor = createActor(machine).start();\nactor.send({ type: 'START' });\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/statelyai/xstate/blob/bd77717b8d33c49af1c8ee4a7e22cebb936cc8b1/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F146"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "machina",
          "name": [
            {
              "t": "fact",
              "fact": "F156"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/ifandelse/machina.js"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/machina"
            },
            {
              "label": "Docs",
              "href": "https://github.com/ifandelse/machina.js/blob/c1bb667666e81054512f2bb64458ed4b239eee99/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F37"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F163"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/ifandelse/machina.js/blob/c1bb667666e81054512f2bb64458ed4b239eee99/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F156"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F38"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F43"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F44"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F45"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "typescript",
              "code": "import { createFsm } from 'machina';\n\nconst machine = createFsm({\n  id: 'task', initialState: 'idle', context: {},\n  states: { idle: { START: 'running' }, running: {} },\n});\nmachine.handle('START');\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/ifandelse/machina.js/blob/c1bb667666e81054512f2bb64458ed4b239eee99/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20machina%20for%20explicit%20state%20machines%2C%20transitions%2C%20guards%20and%20asynchronous%20effects&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F156"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F161"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "robot",
          "name": [
            {
              "t": "fact",
              "fact": "F167"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/matthewp/robot"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/robot3"
            },
            {
              "label": "Docs",
              "href": "https://github.com/matthewp/robot/blob/4ed41e00e4c4a70d595a647e57585e44d73c83ce/docs/src/content/docs/interpret.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F63"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F169"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/matthewp/robot/blob/4ed41e00e4c4a70d595a647e57585e44d73c83ce/docs/src/content/docs/interpret.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F167"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F68"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F69"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F180"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/fal-ai/fal-js",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F180"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "typescript",
              "code": "export function createRealtimeClient({\n  config,\n}: RealtimeClientDependencies): RealtimeClient {\n  return {\n    connect<Input, Output>(\n      app: string,\n      handler: RealtimeConnectionHandler<Output>,\n    ): RealtimeConnection<Input> {\n      const {\n        // if running on React in the server, set clientOnly to true by default\n        clientOnly = isReact() && !isBrowser(),\n        connectionKey = crypto.randomUUID(),\n        maxBuffering,\n        path,\n        throttleInterval = DEFAULT_THROTTLE_INTERVAL,\n        encodeMessage: encodeMessageOverride,\n        decodeMessage: decodeMessageOverride,\n        tokenProvider,\n        tokenExpirationSeconds,\n      } = handler;\n      if (clientOnly && !isBrowser()) {\n        return NoOpConnection;\n      }\n\n      const encodeMessageFn =\n        encodeMessageOverride ?? ((input: any) => encodeRealtimeMessage(input));\n      const decodeMessageFn =\n        decodeMessageOverride ?? ((data: any) => decodeRealtimeMessage(data));\n\n      let previousState: string | undefined;\n      let latestEnqueuedMessage: any;\n      let tokenRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n      let tokenRefreshGeneration = 0;\n\n      // Although the state machine is cached so we don't open multiple connections,\n      // we still need to update the callbacks so we can call the correct references\n      // when the state machine is reused. This is needed because the callbacks\n      // are passed as part of the handler object, which can be different across\n      // different calls to `connect`.\n      connectionCallbacks.set(connectionKey, {\n        decodeMessage: decodeMessageFn,\n        onError: handler.onError,\n        onResult: handler.onResult,\n      });\n      const getCallbacks = () =>\n        connectionCallbacks.get(connectionKey) as RealtimeConnectionCallback;\n      const stateMachine = reuseInterpreter(\n        connectionKey,\n        throttleInterval,\n        ({ context, machine, send }) => {\n          const { enqueuedMessage, token, websocket } = context;\n          latestEnqueuedMessage = enqueuedMessage;\n          if (\n            machine.current === \"active\" &&\n            enqueuedMessage &&\n            websocket?.readyState === WebSocket.OPEN\n          ) {\n            send({ type: \"send\", message: enqueuedMessage });\n          }\n          if (\n            machine.current === \"authRequired\" &&\n            token === undefined &&\n            previousState !== machine.current\n          ) {\n            send({ type: \"initiateAuth\" });\n            tokenRefreshGeneration++;\n            const generation = tokenRefreshGeneration;\n            // Use custom tokenProvider if provided, otherwise use default\n            const appId = ensureEndpointIdFormat(app);\n            const resolvedPath =\n              resolveEndpointPath(app, path, \"/realtime\") ?? \"\";\n            const fetchToken = tokenProvider\n              ? () => tokenProvider(`${appId}${resolvedPath}`)\n              : () => {\n                  console.warn(\n                    \"[fal.realtime] Using the default token provider is deprecated. \" +\n                      \"Please provide a `tokenProvider` function to `fal.realtime.connect()`. \" +\n                      \"See https://docs.fal.ai/model-apis/client#client-side-usage-with-token-provider for more information.\",\n                  );\n                  return getTemporaryAuthToken(app, config);\n                };\n\n            const effectiveExpiration = tokenProvider\n              ? tokenExpirationSeconds\n              : TOKEN_EXPIRATION_SECONDS;\n\n            const scheduleTokenRefresh =\n              effectiveExpiration !== undefined\n                ? () => {\n                    clearTimeout(tokenRefreshTimer);\n                    const refreshMs = Math.round(\n                      effectiveExpiration * 0.9 * 1000,\n                    );\n                    tokenRefreshTimer = setTimeout(() => {\n                      if (generation !== tokenRefreshGeneration) {\n                        return;\n                      }\n                      fetchToken()\n                        .then((newToken) => {\n                          if (generation !== tokenRefreshGeneration) {\n                            return;\n                          }\n                          queueMicrotask(() => {\n                            send({ type: \"authenticated\", token: newToken });\n                          });\n                          scheduleTokenRefresh();\n                        })\n                        .catch(() => {\n                          if (generation !== tokenRefreshGeneration) {\n                            return;\n                          }\n                          const retryMs = Math.round(\n                            effectiveExpiration * 0.05 * 1000,\n                          );\n                          tokenRefreshTimer = setTimeout(() => {\n                            scheduleTokenRefresh();\n                          }, retryMs);\n                        });\n                    }, refreshMs);\n                  }\n                : noop;\n\n            fetchToken()\n              .then((token) => {\n                queueMicrotask(() => {\n                  send({ type: \"authenticated\", token });\n                });\n                scheduleTokenRefresh();\n              })\n              .catch((error) => {\n                queueMicrotask(() => {\n                  send({ type: \"unauthorized\", error });\n                });\n              });\n          }\n          if (\n            machine.current === \"connecting\" &&\n            previousState !== machine.current &&\n            token !== undefined\n          ) {\n            const ws = new WebSocket(\n              buildRealtimeUrl(app, { token, maxBuffering, path }),\n            );\n            ws.onopen = () => {\n              send({ type: \"connected\", websocket: ws });\n              const queued =\n                stateMachine.service.context?.enqueuedMessage ??\n                latestEnqueuedMessage;\n              if (queued) {\n                ws.send(encodeMessageFn(queued));\n                stateMachine.service.context = {\n                  ...stateMachine.service.context,\n                  enqueuedMessage: undefined,\n                };\n              }\n            };\n            ws.onclose = (event) => {\n              if (event.code !== WebSocketErrorCodes.NORMAL_CLOSURE) {\n                const { onError = noop } = getCallbacks();\n                onError(\n                  new ApiError({\n                    message: `Error closing the connection: ${event.reason}`,\n                    status: event.code,\n                  }),\n                );\n              }\n              send({ type: \"connectionClosed\", code: event.code });\n            };\n            ws.onerror = (event) => {\n              // TODO specify error protocol for identified errors\n              const { onError = noop } = getCallbacks();\n              onError(new ApiError({ message: \"Unknown error\", status: 500 }));\n            };\n            ws.onmessage = (event) => {\n              const {\n                decodeMessage = decodeMessageFn,\n                onResult,\n                onError = noop,\n              } = getCallbacks();\n\n              handleRealtimeMessage({\n                data: event.data,\n                decodeMessage,\n                onResult,\n                onError,\n                send,\n              });\n            };\n          }\n          if (previousState === \"active\" && machine.current !== \"active\") {\n            clearTimeout(tokenRefreshTimer);\n            tokenRefreshTimer = undefined;\n          }\n          previousState = machine.current;\n        },\n      );\n\n      const send = (input: Input & Partial<WithRequestId>) => {\n        // Use throttled send to avoid sending too many messages\n        stateMachine.throttledSend({\n          type: \"send\",\n          message: encodeMessageFn(input),\n        });\n      };\n\n      const close = () => {\n        stateMachine.service.send({ type: \"close\" });\n      };\n\n      return {\n        send,\n        close,\n      };\n    },\n  };\n}\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/fal-ai/fal-js/blob/153ed5697302866752d20c205a85030d929ed48c/libs/client/src/realtime.ts#L513-L728",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F179"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20robot3%20for%20explicit%20state%20machines%2C%20transitions%2C%20guards%20and%20asynchronous%20effects&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F167"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "typescript",
              "code": "import { createMachine, interpret, state, transition } from 'robot3';\n\nconst machine = createMachine({\n  idle: state(transition('START', 'running')),\n  running: state(),\n});\nconst service = interpret(machine, () => {});\nservice.send('START');\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/matthewp/robot/blob/4ed41e00e4c4a70d595a647e57585e44d73c83ce/docs/src/content/docs/interpret.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "interpret.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F172"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "zag-js-core",
          "name": [
            {
              "t": "fact",
              "fact": "F182"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/chakra-ui/zag"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/@zag-js/core"
            },
            {
              "label": "Docs",
              "href": "https://cdn.jsdelivr.net/npm/@zag-js/core@1.48.0/dist/index.d.ts"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F189"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://cdn.jsdelivr.net/npm/@zag-js/core@1.48.0/dist/index.d.ts",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F182"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "import { createMachine, findTransition } from '@zag-js/core';\n\nconst machine = createMachine({\n  initialState: () => 'idle',\n  states: { idle: { on: { START: { target: 'running' } } }, running: {} },\n});\nconst match = findTransition(machine, 'idle', 'START');\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://cdn.jsdelivr.net/npm/@zag-js/core@1.48.0/dist/index.d.ts",
                  "label": [
                    {
                      "t": "text",
                      "text": "state.d.ts"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=%40zag-js/core%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F182"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F187"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "finity",
          "name": [
            {
              "t": "fact",
              "fact": "F195"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/nickuraltsev/finity"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/finity"
            },
            {
              "label": "Docs",
              "href": "https://github.com/nickuraltsev/finity/blob/master/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F202"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F198"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F197"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/nickuraltsev/finity/blob/master/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F195"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/slackapi/node-slack-sdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F210"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "private onWebsocketMessage(data: WebSocket.RawData): void {\n  this.logger.debug(`received message on websocket: ${data.toString()}`);\n\n  // parse message into slack event\n  let event: { type: string } & Record<string, unknown>;\n  try {\n    event = JSON.parse(data.toString());\n    // biome-ignore lint/suspicious/noExplicitAny: errors can be anything\n  } catch (parseError: any) {\n    // prevent application from crashing on a bad message, but log an error to bring attention\n    this.logger.error(\n      `unable to parse incoming websocket message: ${parseError.message}\\n    message contents: \"${data}\"`,\n    );\n    return;\n  }\n\n  // internal event handlers\n  if (event.type === 'hello') {\n    this.stateMachine.handle('server hello');\n  }\n  if (event.type === 'team_migration_started') {\n    if (this.websocket !== undefined) {\n      // this will trigger the 'websocket close' event on the state machine, which transitions to clean up\n      this.websocket.close();\n    }\n  }\n\n  if (\n    this.stateMachine.getCurrentState() === 'connected' &&\n    this.stateMachine.getStateHierarchy()[1] === 'resuming' &&\n    event.reply_to !== undefined &&\n    event.reply_to === this.messageId\n  ) {\n    this.stateMachine.handle('replay finished');\n  }\n\n  // emit for event handlers\n  this.emit('slack_event', event.type, event);\n  this.emit(event.type, event);\n  if (event.subtype !== undefined) {\n    this.emit(`${event.type}::${event.subtype}`, event);\n  }\n}\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/slackapi/node-slack-sdk/blob/881ca7b345abf6ce2977931f2d26059159127e09/packages/rtm-api/src/RTMClient.ts#L663-L705",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F209"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=finity%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F195"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "import Finity from 'finity';\n\nconst machine = Finity.configure()\n  .initialState('idle').on('START').transitionTo('running')\n  .state('running').start();\nmachine.handle('START');\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/nickuraltsev/finity/blob/master/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F200"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "javascript-state-machine",
          "name": [
            {
              "t": "fact",
              "fact": "F212"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/jakesgordon/javascript-state-machine"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/javascript-state-machine"
            },
            {
              "label": "Docs",
              "href": "https://github.com/jakesgordon/javascript-state-machine/blob/0d603577423244228cebcd62e60dbbfff27c6ea3/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F86"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/jakesgordon/javascript-state-machine/blob/0d603577423244228cebcd62e60dbbfff27c6ea3/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F212"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F87"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F88"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F89"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F90"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F91"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F92"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F93"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F94"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F225"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/dashersw/brain-bits",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F225"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "typescript",
              "code": "onCountdown() {\n                    (function tick() {\n                        session._display(session.countdownMessages.shift());\n\n                        if (!session.countdown--) {\n                            session.fsm.run();\n                        } else {\n                            setTimeout(tick, 1000);\n                        }\n                    }());\n                }\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/dashersw/brain-bits/blob/2da52e7162ed844eea4a149f274a838661d1f216/src/models/session/live-session.js#L24-L34",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F224"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20javascript-state-machine%20for%20explicit%20state%20machines%2C%20transitions%2C%20guards%20and%20asynchronous%20effects&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F212"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "typescript",
              "code": "const StateMachine = require('javascript-state-machine');\n\nconst machine = new StateMachine({\n  init: 'idle',\n  transitions: [{ name: 'start', from: 'idle', to: 'running' }],\n});\nmachine.start();\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/jakesgordon/javascript-state-machine/blob/0d603577423244228cebcd62e60dbbfff27c6ea3/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F217"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "stately-js",
          "name": [
            {
              "t": "fact",
              "fact": "F227"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/fschaefer/Stately.js"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/stately.js"
            },
            {
              "label": "Docs",
              "href": "https://github.com/fschaefer/Stately.js/blob/master/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F234"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F230"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/fschaefer/Stately.js/blob/master/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F227"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F242"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F243"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/noodlefrenzy/node-amqp10",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F242"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "var detachHandler = function(frame) {\n  if (this.getMachineState() === 'ATTACHED') {\n    this.ATTACHED.sendDetach({ closed: frame.closed });\n  }\n\n  link._detached(frame);\n  return this.DETACHED;\n};\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/noodlefrenzy/node-amqp10/blob/f5c2aa570830a8dd454e89ed3f4222fc7953fcf7/lib/link.js#L16-L23",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F241"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=stately.js%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F227"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "const Stately = require('stately.js');\n\nconst machine = new Stately({\n  idle: { START: 'running' },\n  running: {},\n}, 'idle');\nmachine.START();\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/fschaefer/Stately.js/blob/master/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F232"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which JavaScript state machine library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#xstate",
          "label": [
            {
              "t": "text",
              "text": "XState"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits apps that need nested and parallel states with an actor model. "
        },
        {
          "t": "link",
          "href": "#xstate-fsm",
          "label": [
            {
              "t": "text",
              "text": "XState FSM"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits apps that need a minimal flat state machine. "
        },
        {
          "t": "link",
          "href": "#robot",
          "label": [
            {
              "t": "text",
              "text": "Robot"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits code that prefers functional, immutable machine definitions."
        }
      ]
    },
    {
      "q": "What is a state machine?",
      "a": [
        {
          "t": "text",
          "text": "A state machine is a model with a finite set of states, where each event moves the system from one state to another by a defined transition. Only one state is active at a time in a flat machine."
        }
      ]
    },
    {
      "q": "What are statecharts?",
      "a": [
        {
          "t": "text",
          "text": "Statecharts extend state machines with nested states, parallel regions, and history. "
        },
        {
          "t": "link",
          "href": "#xstate",
          "label": [
            {
              "t": "text",
              "text": "XState"
            }
          ]
        },
        {
          "t": "text",
          "text": " implements full statecharts. "
        },
        {
          "t": "link",
          "href": "#xstate-fsm",
          "label": [
            {
              "t": "text",
              "text": "XState FSM"
            }
          ]
        },
        {
          "t": "text",
          "text": " leaves those features out."
        }
      ]
    },
    {
      "q": "What is XState?",
      "a": [
        {
          "t": "link",
          "href": "#xstate",
          "label": [
            {
              "t": "text",
              "text": "XState"
            }
          ]
        },
        {
          "t": "text",
          "text": " models application logic with state machines, statecharts, and actors. It supports nested and parallel state configurations."
        }
      ]
    },
    {
      "q": "What is Zag?",
      "a": [
        {
          "t": "link",
          "href": "#zag-js-core",
          "label": [
            {
              "t": "text",
              "text": "Zag core"
            }
          ]
        },
        {
          "t": "text",
          "text": " is the state machine core behind the Zag UI component machines. It implements a minimal version of the XState FSM model for UI components."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, xstate",
      "display": "XState",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, xstate",
      "display": "30.1M",
      "asOf": "2026-11-15"
    },
    "F3": {
      "label": "License, xstate",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, xstate",
      "display": "5.33.4",
      "asOf": "2026-11-17"
    },
    "F5": {
      "label": "Undated package release, xstate",
      "display": "v5.33.4",
      "asOf": "2026-11-17"
    },
    "F6": {
      "label": "Repository stars, xstate",
      "display": "30.5K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Nested states, xstate",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Transition guards, xstate",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Awaits async work, xstate",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Change subscriptions, xstate",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "Install, xstate",
      "display": "npm install xstate",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "What it does, xstate",
      "display": "Models application logic with state machines, nested states, and actors.",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths lead, xstate",
      "display": "Groups behavior into nested states",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths, xstate",
      "display": "Use parent states to share behavior across related child states.",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths lead, xstate",
      "display": "Manages asynchronous actor lifecycles",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "strengths, xstate",
      "display": "Invoke actors when entering a state and stop them when leaving.",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations lead, xstate",
      "display": "Async actions are not awaited",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations, xstate",
      "display": "Use invoked actors when the next state depends on asynchronous work.",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations lead, xstate",
      "display": "Guards must be synchronous",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "limitations, xstate",
      "display": "Finish asynchronous checks before sending the event that tests a guard.",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Quickstart, xstate",
      "display": "import { createMachine, createActor, assign } from 'xstate';\n\n// State machine\nconst toggleMachine = createMachine({\n  id: 'toggle',\n  initial: 'inactive',\n  context: {\n    count: 0\n  },\n  states: {\n    inactive: {\n      on: {\n        TOGGLE: { target: 'active' }\n      }\n    },\n    active: {\n      entry: assign({ count: ({ context }) => context.count + 1 }),\n      on: {\n        TOGGLE: { target: 'inactive' }\n      }\n    }\n  }\n});\n\n// Actor (instance of the machine logic, like a store)\nconst toggleActor = createActor(toggleMachine);\ntoggleActor.subscribe((state) => console.log(state.value, state.context));\ntoggleActor.start();\n// => logs 'inactive', { count: 0 }\n\ntoggleActor.send({ type: 'TOGGLE' });\n// => logs 'active', { count: 1 }\n\ntoggleActor.send({ type: 'TOGGLE' });\n// => logs 'inactive', { count: 1 }\n",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project function, xstate",
      "display": "private sendMachineEvent(event: ConnectionMachineEvent, source: string): void {\n    const before = this.getMachineState()\n    this.connectionActor.send(event)\n    const after = this.getMachineState()\n    const beforeText = JSON.stringify(before)\n    const afterText = JSON.stringify(after)\n    const message = `Machine event ${event.type} from ${source}: ${beforeText} -> ${afterText}`\n    this.logTrace(message)\n  }\n",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project function reference, xstate",
      "display": "Connection.ts · sendMachineEvent()",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project repository, xstate",
      "display": "processone/fluux-messenger",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Project stars, processone/fluux-messenger",
      "display": "450",
      "asOf": "2026-11-17"
    },
    "F26": {
      "label": "Project push date, processone/fluux-messenger",
      "display": "Nov 2026",
      "asOf": "2026-11-17"
    },
    "F27": {
      "label": "Library name, machina",
      "display": "machina",
      "asOf": "2026-11-17"
    },
    "F28": {
      "label": "Monthly downloads, machina",
      "display": "13.6M",
      "asOf": "2026-11-15"
    },
    "F29": {
      "label": "License, machina",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Package release, machina",
      "display": "8.2.0",
      "asOf": "2026-11-17"
    },
    "F31": {
      "label": "Undated package release, machina",
      "display": "v8.2.0",
      "asOf": "2026-11-17"
    },
    "F32": {
      "label": "Repository stars, machina",
      "display": "2.0K",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Nested states, machina",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "Awaits async work, machina",
      "display": "Unsupported",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "Change subscriptions, machina",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "Install, machina",
      "display": "npm install machina",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "What it does, machina",
      "display": "Defines input-driven state machines and shared behaviors for independent client objects.",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "strengths lead, machina",
      "display": "Shares behavior across client objects",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths, machina",
      "display": "Use createBehavioralFsm to track each client’s state independently.",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "strengths lead, machina",
      "display": "Replays inputs after a transition",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "strengths, machina",
      "display": "Use defer() when an input arrives before the machine can handle it.",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "limitations lead, machina",
      "display": "Async work needs completion events",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "limitations, machina",
      "display": "Start asynchronous work separately, then call handle() or transition() when finished.",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "limitations lead, machina",
      "display": "Child handlers take priority",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "limitations, machina",
      "display": "Parent handlers run only when the child chain cannot handle an input.",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Quickstart, machina",
      "display": "import { createFsm } from \"machina\";\n\nconst lock = createFsm({\n    id: \"door-lock\",\n    initialState: \"locked\",\n    context: { attempts: 0 },\n    states: {\n        locked: {\n            submit({ ctx }, code: unknown) {\n                if (code === \"1234\") {\n                    ctx.attempts = 0;\n                    return \"unlocked\";\n                }\n                ctx.attempts++;\n                if (ctx.attempts >= 3) {\n                    return \"alarming\";\n                }\n            },\n        },\n        unlocked: {\n            lock: \"locked\",\n        },\n        alarming: {\n            reset({ ctx }) {\n                ctx.attempts = 0;\n                return \"locked\";\n            },\n        },\n    },\n});\n\nlock.handle(\"submit\", \"wrong\"); // stays in \"locked\"\nlock.handle(\"submit\", \"1234\"); // transitions to \"unlocked\"\nlock.handle(\"lock\"); // back to \"locked\"\n\nconsole.log(lock.currentState()); // \"locked\"\n",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Project function, machina",
      "display": "(callback) => {\n            /*Codes_SRS_NODE_COMMON_MQTT_BASE_16_033: [The `updateSharedAccessSignature` method shall disconnect and reconnect the mqtt client with the new `sharedAccessSignature`.]*/\n            /*Codes_SRS_NODE_COMMON_MQTT_BASE_16_035: [The `updateSharedAccessSignature` method shall call the `callback` argument with no parameters if the operation succeeds.]*/\n            /*Codes_SRS_NODE_COMMON_MQTT_BASE_16_036: [The `updateSharedAccessSignature` method shall call the `callback` argument with an `Error` if the operation fails.]*/\n            let switched = false;\n            /*Codes_SRS_NODE_COMMON_MQTT_BASE_41_002: [The `updateSharedAccessSignature` method shall trigger a forced disconnect if after 30 seconds the mqtt client has failed to complete a non-forced disconnect.]*/\n            /*Codes_SRS_NODE_COMMON_MQTT_BASE_41_003: [The `updateSharedAccessSignature` method shall call the `callback` argument with an `Error` if the operation fails after timing out.]*/\n            const disconnectTimeout = setTimeout(() => {\n              debugErrors('disconnecting mqtt client timed out. Force disconnecting.');\n              switched = true;\n              this._fsm.handle('forceDisconnect', callback);\n            }, 30000);\n\n            // When experiencing message loss due to high throughput, the force flag in\n            // disconnectClient can be set to true to cause messages to be properly dropped,\n            // and thus re-sent. Making this the default is under investigation.\n            debug('disconnecting mqtt client');\n            this._disconnectClient(this._options?.mqtt?.forceDisconnect ?? false, () => {\n              clearTimeout(disconnectTimeout);\n              if (!switched) {\n                debug('mqtt client disconnected - reconnecting');\n                this._connectClient((err, connack) => {\n                  if (err) {\n                    debugErrors('failed to reconnect the client: ' + err.toString());\n                    this._fsm.transition('disconnected', callback, err);\n                  } else {\n                    debug('mqtt client reconnected successfully');\n                    this._mqttTrackedListeners.addTrackedListener('error', this._errorCallback.bind(this));\n                    this._fsm.transition('connected', callback, connack);\n                  }\n                });\n              }\n            });\n          }\n",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project function reference, machina",
      "display": "mqtt_base.ts · _onEnter()",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Project repository, machina",
      "display": "Azure/azure-iot-sdk-node",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Project stars, Azure/azure-iot-sdk-node",
      "display": "267",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "Project push date, Azure/azure-iot-sdk-node",
      "display": "Nov 2026",
      "asOf": "2026-11-13"
    },
    "F52": {
      "label": "Library name, robot3",
      "display": "Robot",
      "asOf": "2026-11-17"
    },
    "F53": {
      "label": "Monthly downloads, robot3",
      "display": "9.1M",
      "asOf": "2026-11-15"
    },
    "F54": {
      "label": "License, robot3",
      "display": "BSD-2-Clause",
      "asOf": "2026-11-17"
    },
    "F55": {
      "label": "Package release, robot3",
      "display": "1.4.0",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "Undated package release, robot3",
      "display": "v1.4.0",
      "asOf": "2026-11-17"
    },
    "F57": {
      "label": "Repository stars, robot3",
      "display": "2.2K",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "Nested states, robot3",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "Transition guards, robot3",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "Awaits async work, robot3",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "Change subscriptions, robot3",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "Install, robot3",
      "display": "npm install robot3",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "What it does, robot3",
      "display": "Composes immutable state-machine definitions from state, transition, guard, and invocation functions.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "strengths lead, robot3",
      "display": "Composes nested machines through invocation",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "strengths, robot3",
      "display": "Invoke a child machine from a parent state.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "strengths lead, robot3",
      "display": "Routes promise outcomes into events",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "strengths, robot3",
      "display": "Handle done and error transitions from invoked promise-returning functions.",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "limitations lead, robot3",
      "display": "Leaving a state discards results",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "limitations, robot3",
      "display": "Results are ignored after leaving their invoking state.",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "Quickstart, robot3",
      "display": "import { createMachine, interpret, state, transition } from 'robot3';\n\nconst machine = createMachine({\n  asleep: state(\n    transition('wake', 'breakfast')\n  ),\n  breakfast: state()\n});\n\nconst service = interpret(machine, () => {\n  if(service.machine.current === 'breakfast') {\n    console.log('Wake up!');\n  }\n});\n\n// Later\nservice.send('wake'); // Wake up!\n",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "Project function, robot3",
      "display": "export function createRealtimeClient({\n  config,\n}: RealtimeClientDependencies): RealtimeClient {\n  return {\n    connect<Input, Output>(\n      app: string,\n      handler: RealtimeConnectionHandler<Output>,\n    ): RealtimeConnection<Input> {\n      const {\n        // if running on React in the server, set clientOnly to true by default\n        clientOnly = isReact() && !isBrowser(),\n        connectionKey = crypto.randomUUID(),\n        maxBuffering,\n        path,\n        throttleInterval = DEFAULT_THROTTLE_INTERVAL,\n        encodeMessage: encodeMessageOverride,\n        decodeMessage: decodeMessageOverride,\n        tokenProvider,\n        tokenExpirationSeconds,\n      } = handler;\n      if (clientOnly && !isBrowser()) {\n        return NoOpConnection;\n      }\n\n      const encodeMessageFn =\n        encodeMessageOverride ?? ((input: any) => encodeRealtimeMessage(input));\n      const decodeMessageFn =\n        decodeMessageOverride ?? ((data: any) => decodeRealtimeMessage(data));\n\n      let previousState: string | undefined;\n      let latestEnqueuedMessage: any;\n      let tokenRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n      let tokenRefreshGeneration = 0;\n\n      // Although the state machine is cached so we don't open multiple connections,\n      // we still need to update the callbacks so we can call the correct references\n      // when the state machine is reused. This is needed because the callbacks\n      // are passed as part of the handler object, which can be different across\n      // different calls to `connect`.\n      connectionCallbacks.set(connectionKey, {\n        decodeMessage: decodeMessageFn,\n        onError: handler.onError,\n        onResult: handler.onResult,\n      });\n      const getCallbacks = () =>\n        connectionCallbacks.get(connectionKey) as RealtimeConnectionCallback;\n      const stateMachine = reuseInterpreter(\n        connectionKey,\n        throttleInterval,\n        ({ context, machine, send }) => {\n          const { enqueuedMessage, token, websocket } = context;\n          latestEnqueuedMessage = enqueuedMessage;\n          if (\n            machine.current === \"active\" &&\n            enqueuedMessage &&\n            websocket?.readyState === WebSocket.OPEN\n          ) {\n            send({ type: \"send\", message: enqueuedMessage });\n          }\n          if (\n            machine.current === \"authRequired\" &&\n            token === undefined &&\n            previousState !== machine.current\n          ) {\n            send({ type: \"initiateAuth\" });\n            tokenRefreshGeneration++;\n            const generation = tokenRefreshGeneration;\n            // Use custom tokenProvider if provided, otherwise use default\n            const appId = ensureEndpointIdFormat(app);\n            const resolvedPath =\n              resolveEndpointPath(app, path, \"/realtime\") ?? \"\";\n            const fetchToken = tokenProvider\n              ? () => tokenProvider(`${appId}${resolvedPath}`)\n              : () => {\n                  console.warn(\n                    \"[fal.realtime] Using the default token provider is deprecated. \" +\n                      \"Please provide a `tokenProvider` function to `fal.realtime.connect()`. \" +\n                      \"See https://docs.fal.ai/model-apis/client#client-side-usage-with-token-provider for more information.\",\n                  );\n                  return getTemporaryAuthToken(app, config);\n                };\n\n            const effectiveExpiration = tokenProvider\n              ? tokenExpirationSeconds\n              : TOKEN_EXPIRATION_SECONDS;\n\n            const scheduleTokenRefresh =\n              effectiveExpiration !== undefined\n                ? () => {\n                    clearTimeout(tokenRefreshTimer);\n                    const refreshMs = Math.round(\n                      effectiveExpiration * 0.9 * 1000,\n                    );\n                    tokenRefreshTimer = setTimeout(() => {\n                      if (generation !== tokenRefreshGeneration) {\n                        return;\n                      }\n                      fetchToken()\n                        .then((newToken) => {\n                          if (generation !== tokenRefreshGeneration) {\n                            return;\n                          }\n                          queueMicrotask(() => {\n                            send({ type: \"authenticated\", token: newToken });\n                          });\n                          scheduleTokenRefresh();\n                        })\n                        .catch(() => {\n                          if (generation !== tokenRefreshGeneration) {\n                            return;\n                          }\n                          const retryMs = Math.round(\n                            effectiveExpiration * 0.05 * 1000,\n                          );\n                          tokenRefreshTimer = setTimeout(() => {\n                            scheduleTokenRefresh();\n                          }, retryMs);\n                        });\n                    }, refreshMs);\n                  }\n                : noop;\n\n            fetchToken()\n              .then((token) => {\n                queueMicrotask(() => {\n                  send({ type: \"authenticated\", token });\n                });\n                scheduleTokenRefresh();\n              })\n              .catch((error) => {\n                queueMicrotask(() => {\n                  send({ type: \"unauthorized\", error });\n                });\n              });\n          }\n          if (\n            machine.current === \"connecting\" &&\n            previousState !== machine.current &&\n            token !== undefined\n          ) {\n            const ws = new WebSocket(\n              buildRealtimeUrl(app, { token, maxBuffering, path }),\n            );\n            ws.onopen = () => {\n              send({ type: \"connected\", websocket: ws });\n              const queued =\n                stateMachine.service.context?.enqueuedMessage ??\n                latestEnqueuedMessage;\n              if (queued) {\n                ws.send(encodeMessageFn(queued));\n                stateMachine.service.context = {\n                  ...stateMachine.service.context,\n                  enqueuedMessage: undefined,\n                };\n              }\n            };\n            ws.onclose = (event) => {\n              if (event.code !== WebSocketErrorCodes.NORMAL_CLOSURE) {\n                const { onError = noop } = getCallbacks();\n                onError(\n                  new ApiError({\n                    message: `Error closing the connection: ${event.reason}`,\n                    status: event.code,\n                  }),\n                );\n              }\n              send({ type: \"connectionClosed\", code: event.code });\n            };\n            ws.onerror = (event) => {\n              // TODO specify error protocol for identified errors\n              const { onError = noop } = getCallbacks();\n              onError(new ApiError({ message: \"Unknown error\", status: 500 }));\n            };\n            ws.onmessage = (event) => {\n              const {\n                decodeMessage = decodeMessageFn,\n                onResult,\n                onError = noop,\n              } = getCallbacks();\n\n              handleRealtimeMessage({\n                data: event.data,\n                decodeMessage,\n                onResult,\n                onError,\n                send,\n              });\n            };\n          }\n          if (previousState === \"active\" && machine.current !== \"active\") {\n            clearTimeout(tokenRefreshTimer);\n            tokenRefreshTimer = undefined;\n          }\n          previousState = machine.current;\n        },\n      );\n\n      const send = (input: Input & Partial<WithRequestId>) => {\n        // Use throttled send to avoid sending too many messages\n        stateMachine.throttledSend({\n          type: \"send\",\n          message: encodeMessageFn(input),\n        });\n      };\n\n      const close = () => {\n        stateMachine.service.send({ type: \"close\" });\n      };\n\n      return {\n        send,\n        close,\n      };\n    },\n  };\n}\n",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Project function reference, robot3",
      "display": "realtime.ts · createRealtimeClient()",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Project repository, robot3",
      "display": "fal-ai/fal-js",
      "asOf": "2026-11-17"
    },
    "F74": {
      "label": "Project stars, fal-ai/fal-js",
      "display": "189",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Project push date, fal-ai/fal-js",
      "display": "Nov 2026",
      "asOf": "2026-11-14"
    },
    "F76": {
      "label": "Library name, javascript-state-machine",
      "display": "javascript-state-machine",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Monthly downloads, javascript-state-machine",
      "display": "1.1M",
      "asOf": "2026-11-15"
    },
    "F78": {
      "label": "License, javascript-state-machine",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "Package release, javascript-state-machine",
      "display": "3.1.0",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "Undated package release, javascript-state-machine",
      "display": "v3.1.0",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "Repository stars, javascript-state-machine",
      "display": "8.7K",
      "asOf": "2026-11-17"
    },
    "F82": {
      "label": "Transition guards, javascript-state-machine",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "Awaits async work, javascript-state-machine",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "Change subscriptions, javascript-state-machine",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "Install, javascript-state-machine",
      "display": "npm install javascript-state-machine",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "What it does, javascript-state-machine",
      "display": "Defines named states and transitions with generated transition methods and lifecycle observers.",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "strengths lead, javascript-state-machine",
      "display": "Observes transition lifecycle events",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "strengths, javascript-state-machine",
      "display": "Attach observers before transitions, during state changes, or after completion.",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "strengths lead, javascript-state-machine",
      "display": "Pauses transitions for promises",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "strengths, javascript-state-machine",
      "display": "Return a promise from a lifecycle observer to delay transition completion.",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "limitations lead, javascript-state-machine",
      "display": "Pending transitions reject overlapping triggers",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "limitations, javascript-state-machine",
      "display": "Wait for a pending transition or handle onPendingTransition explicitly.",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "limitations lead, javascript-state-machine",
      "display": "Unsettled promises block the machine",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "limitations, javascript-state-machine",
      "display": "Resolve or reject every promise returned from a transition observer.",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "Quickstart, javascript-state-machine",
      "display": "  var StateMachine = require('javascript-state-machine');\n\n  var fsm = new StateMachine({\n    init: 'solid',\n    transitions: [\n      { name: 'melt',     from: 'solid',  to: 'liquid' },\n      { name: 'freeze',   from: 'liquid', to: 'solid'  },\n      { name: 'vaporize', from: 'liquid', to: 'gas'    },\n      { name: 'condense', from: 'gas',    to: 'liquid' }\n    ],\n    methods: {\n      onMelt:     function() { console.log('I melted')    },\n      onFreeze:   function() { console.log('I froze')     },\n      onVaporize: function() { console.log('I vaporized') },\n      onCondense: function() { console.log('I condensed') }\n    }\n  });\n",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "Developer need",
      "display": "Organizing nested application states",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Why choose xstate",
      "display": "parent and child state definitions",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Developer need in introduction",
      "display": "organizing nested application states",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "Developer need",
      "display": "Waiting during transition hooks",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Why choose javascript-state-machine",
      "display": "promise-aware lifecycle observers",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Developer need in introduction",
      "display": "waiting during transition hooks",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "When to consider xstate",
      "display": "behavior needs nested parent and child states",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "Developer need",
      "display": "Invoking a child machine",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Why choose robot3",
      "display": "machine composition through invocation",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Developer need in introduction",
      "display": "invoking a child machine",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "When to consider xstate",
      "display": "actor lifecycle orchestration is needed",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Developer need",
      "display": "Sharing behavior across client objects",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "Why choose machina",
      "display": "independent per-client machine state",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "Developer need in introduction",
      "display": "sharing behavior across client objects",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "When to consider javascript-state-machine",
      "display": "transition completion must wait for a promise",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "Page introduction",
      "display": "JavaScript state machine libraries let developers model state transitions and event-driven behavior.",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "FAQ: Does an async XState action delay the next state?",
      "display": "Async actions are not awaited; use invoked actors to coordinate asynchronous completion.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: Can an XState guard perform an asynchronous check?",
      "display": "Guards are pure synchronous functions returning a Boolean; complete asynchronous work before testing its outcome.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: What happens when an invoked promise finishes after its XState state exits?",
      "display": "The result is discarded if the state exits before the promise settles.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: Can javascript-state-machine cancel a transition?",
      "display": "Returning false from supported pre-transition, leave-state or transition observers cancels subsequent lifecycle events and leaves state unchanged.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: Why does javascript-state-machine stay in a pending transition?",
      "display": "A lifecycle promise must eventually resolve or reject; an unsettled promise keeps the transition pending.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: Does Robot cancel the underlying asynchronous operation?",
      "display": "Leaving an invoke state discards its eventual result; the underlying promise operation still runs to completion or failure.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Does Robot notify subscribers when a transition returns to the same state?",
      "display": "The onChange callback is still called after a transition returning to the same state.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Does machina await a promise returned by a handler?",
      "display": "Its methods are synchronous; start asynchronous work separately and signal completion through handle or transition.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Which machina handler receives input in a nested machine?",
      "display": "The descendant chain receives input first; the parent acts as a fallback when the chain cannot handle it.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: How do machina subscriptions unsubscribe?",
      "display": "Call off on the subscription object returned by on; off(eventName, callback) is not provided.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "FAQ: Can XState restore any JavaScript value from a saved snapshot?",
      "display": "Persisted state must be JSON-serializable; functions, classes, and other non-serializable values cannot be persisted.",
      "asOf": "2026-11-17"
    },
    "F123": {
      "label": "FAQ: Can XState restore any JavaScript value from a saved snapshot?",
      "display": "Changing actor logic can make a previously saved state incompatible.",
      "asOf": "2026-11-17"
    },
    "F124": {
      "label": "Library name, @xstate/fsm",
      "display": "@xstate/fsm",
      "asOf": "2026-11-20"
    },
    "F125": {
      "label": "Monthly downloads, @xstate/fsm",
      "display": "38.7M",
      "asOf": "2026-11-20"
    },
    "F126": {
      "label": "License, @xstate/fsm",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F127": {
      "label": "Package release, @xstate/fsm",
      "display": "2.1.0",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Package release date, @xstate/fsm",
      "display": "Jun 2023",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "Install, @xstate/fsm",
      "display": "npm install @xstate/fsm",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "Quickstart, @xstate/fsm",
      "display": "import { createMachine } from '@xstate/fsm';\n\nconst machine = createMachine({\n  initial: 'idle',\n  states: { idle: { on: { START: 'running' } }, running: {} },\n});\nconst nextState = machine.transition(machine.initialState, 'START');\n",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Official description, @xstate/fsm",
      "display": "Runs minimal finite state machines with the XState model.",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Quickstart source file, @xstate/fsm",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Repository stars, @xstate/fsm",
      "display": "30.5K",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Nested state models, @xstate/fsm",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Parallel state regions, @xstate/fsm",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Model and execution role, @xstate/fsm",
      "display": "Minimal non-nested finite-state engine; official feature table explicitly excludes nested, parallel, history, and invoked-actor features supported by full XState.",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Project function, @xstate/fsm",
      "display": "const getServiceState = <\n\tTContext extends object,\n\tTEvent extends MachineEvent = MachineEvent,\n\tTState extends Typestate<TContext> = any\n>(\n\tservice: StateMachine.Service<TContext, TEvent, TState>\n): StateMachine.State<TContext, TEvent, TState> => {\n\tlet currentValue: StateMachine.State<TContext, TEvent, TState>;\n\tservice\n\t\t.subscribe((state) => {\n\t\t\tcurrentValue = state;\n\t\t})\n\t\t.unsubscribe();\n\treturn currentValue!;\n};\n",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Project source file, @xstate/fsm",
      "display": "packages/machine/src/reach-machine.ts",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Project full_name, @xstate/fsm",
      "display": "reach/reach-ui",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Project stargazers_count, @xstate/fsm",
      "display": "6.0K",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Library name, xstate",
      "display": "XState",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "Monthly downloads, xstate",
      "display": "31.2M",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "License, xstate",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Package release, xstate",
      "display": "5.33.4",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Package release date, xstate",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Install, xstate",
      "display": "npm install xstate",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Quickstart, xstate",
      "display": "import { createMachine, createActor } from 'xstate';\n\nconst machine = createMachine({\n  initial: 'idle',\n  states: { idle: { on: { START: 'running' } }, running: {} },\n});\nconst actor = createActor(machine).start();\nactor.send({ type: 'START' });\n",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Repository stars, xstate",
      "display": "30.5K",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Nested state models, xstate",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Parallel state regions, xstate",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Model and execution role, xstate",
      "display": "Full statecharts and actor model with nested/parallel state configuration; a different public API from the minimal @xstate/fsm engine.",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Project function, xstate",
      "display": "private sendMachineEvent(event: ConnectionMachineEvent, source: string): void {\n    const before = this.getMachineState()\n    this.connectionActor.send(event)\n    const after = this.getMachineState()\n    const beforeText = JSON.stringify(before)\n    const afterText = JSON.stringify(after)\n    const message = `Machine event ${event.type} from ${source}: ${beforeText} -> ${afterText}`\n    this.logTrace(message)\n  }\n",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Project source file, xstate",
      "display": "packages/fluux-sdk/src/core/modules/Connection.ts",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Project full_name, xstate",
      "display": "processone/fluux-messenger",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Project stargazers_count, xstate",
      "display": "450",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Library name, machina",
      "display": "machina",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Monthly downloads, machina",
      "display": "14.0M",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "License, machina",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Package release, machina",
      "display": "8.2.0",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Package release date, machina",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Install, machina",
      "display": "npm install machina",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Quickstart, machina",
      "display": "import { createFsm } from 'machina';\n\nconst machine = createFsm({\n  id: 'task', initialState: 'idle', context: {},\n  states: { idle: { START: 'running' }, running: {} },\n});\nmachine.handle('START');\n",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Repository stars, machina",
      "display": "2.0K",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Nested state models, machina",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Parallel state regions, machina",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Model and execution role, machina",
      "display": "Current8 input handlers, context, lifecycle events, child FSM delegation, and explicit disposal; old callback-bearing transition signatures are not current8.",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Library name, robot3",
      "display": "robot3",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Monthly downloads, robot3",
      "display": "9.4M",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "License, robot3",
      "display": "BSD-2-Clause",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Package release, robot3",
      "display": "1.4.0",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Package release date, robot3",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Install, robot3",
      "display": "npm install robot3",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Quickstart, robot3",
      "display": "import { createMachine, interpret, state, transition } from 'robot3';\n\nconst machine = createMachine({\n  idle: state(transition('START', 'running')),\n  running: state(),\n});\nconst service = interpret(machine, () => {});\nservice.send('START');\n",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "Repository stars, robot3",
      "display": "2.2K",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Nested state models, robot3",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Parallel state regions, robot3",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Model and execution role, robot3",
      "display": "Functional immutable machine definitions, interpreter services, and nested machine/promise invocation; service has one current machine state and optional child service.",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Project function, robot3",
      "display": "export function createRealtimeClient({\n  config,\n}: RealtimeClientDependencies): RealtimeClient {\n  return {\n    connect<Input, Output>(\n      app: string,\n      handler: RealtimeConnectionHandler<Output>,\n    ): RealtimeConnection<Input> {\n      const {\n        // if running on React in the server, set clientOnly to true by default\n        clientOnly = isReact() && !isBrowser(),\n        connectionKey = crypto.randomUUID(),\n        maxBuffering,\n        path,\n        throttleInterval = DEFAULT_THROTTLE_INTERVAL,\n        encodeMessage: encodeMessageOverride,\n        decodeMessage: decodeMessageOverride,\n        tokenProvider,\n        tokenExpirationSeconds,\n      } = handler;\n      if (clientOnly && !isBrowser()) {\n        return NoOpConnection;\n      }\n\n      const encodeMessageFn =\n        encodeMessageOverride ?? ((input: any) => encodeRealtimeMessage(input));\n      const decodeMessageFn =\n        decodeMessageOverride ?? ((data: any) => decodeRealtimeMessage(data));\n\n      let previousState: string | undefined;\n      let latestEnqueuedMessage: any;\n      let tokenRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n      let tokenRefreshGeneration = 0;\n\n      // Although the state machine is cached so we don't open multiple connections,\n      // we still need to update the callbacks so we can call the correct references\n      // when the state machine is reused. This is needed because the callbacks\n      // are passed as part of the handler object, which can be different across\n      // different calls to `connect`.\n      connectionCallbacks.set(connectionKey, {\n        decodeMessage: decodeMessageFn,\n        onError: handler.onError,\n        onResult: handler.onResult,\n      });\n      const getCallbacks = () =>\n        connectionCallbacks.get(connectionKey) as RealtimeConnectionCallback;\n      const stateMachine = reuseInterpreter(\n        connectionKey,\n        throttleInterval,\n        ({ context, machine, send }) => {\n          const { enqueuedMessage, token, websocket } = context;\n          latestEnqueuedMessage = enqueuedMessage;\n          if (\n            machine.current === \"active\" &&\n            enqueuedMessage &&\n            websocket?.readyState === WebSocket.OPEN\n          ) {\n            send({ type: \"send\", message: enqueuedMessage });\n          }\n          if (\n            machine.current === \"authRequired\" &&\n            token === undefined &&\n            previousState !== machine.current\n          ) {\n            send({ type: \"initiateAuth\" });\n            tokenRefreshGeneration++;\n            const generation = tokenRefreshGeneration;\n            // Use custom tokenProvider if provided, otherwise use default\n            const appId = ensureEndpointIdFormat(app);\n            const resolvedPath =\n              resolveEndpointPath(app, path, \"/realtime\") ?? \"\";\n            const fetchToken = tokenProvider\n              ? () => tokenProvider(`${appId}${resolvedPath}`)\n              : () => {\n                  console.warn(\n                    \"[fal.realtime] Using the default token provider is deprecated. \" +\n                      \"Please provide a `tokenProvider` function to `fal.realtime.connect()`. \" +\n                      \"See https://docs.fal.ai/model-apis/client#client-side-usage-with-token-provider for more information.\",\n                  );\n                  return getTemporaryAuthToken(app, config);\n                };\n\n            const effectiveExpiration = tokenProvider\n              ? tokenExpirationSeconds\n              : TOKEN_EXPIRATION_SECONDS;\n\n            const scheduleTokenRefresh =\n              effectiveExpiration !== undefined\n                ? () => {\n                    clearTimeout(tokenRefreshTimer);\n                    const refreshMs = Math.round(\n                      effectiveExpiration * 0.9 * 1000,\n                    );\n                    tokenRefreshTimer = setTimeout(() => {\n                      if (generation !== tokenRefreshGeneration) {\n                        return;\n                      }\n                      fetchToken()\n                        .then((newToken) => {\n                          if (generation !== tokenRefreshGeneration) {\n                            return;\n                          }\n                          queueMicrotask(() => {\n                            send({ type: \"authenticated\", token: newToken });\n                          });\n                          scheduleTokenRefresh();\n                        })\n                        .catch(() => {\n                          if (generation !== tokenRefreshGeneration) {\n                            return;\n                          }\n                          const retryMs = Math.round(\n                            effectiveExpiration * 0.05 * 1000,\n                          );\n                          tokenRefreshTimer = setTimeout(() => {\n                            scheduleTokenRefresh();\n                          }, retryMs);\n                        });\n                    }, refreshMs);\n                  }\n                : noop;\n\n            fetchToken()\n              .then((token) => {\n                queueMicrotask(() => {\n                  send({ type: \"authenticated\", token });\n                });\n                scheduleTokenRefresh();\n              })\n              .catch((error) => {\n                queueMicrotask(() => {\n                  send({ type: \"unauthorized\", error });\n                });\n              });\n          }\n          if (\n            machine.current === \"connecting\" &&\n            previousState !== machine.current &&\n            token !== undefined\n          ) {\n            const ws = new WebSocket(\n              buildRealtimeUrl(app, { token, maxBuffering, path }),\n            );\n            ws.onopen = () => {\n              send({ type: \"connected\", websocket: ws });\n              const queued =\n                stateMachine.service.context?.enqueuedMessage ??\n                latestEnqueuedMessage;\n              if (queued) {\n                ws.send(encodeMessageFn(queued));\n                stateMachine.service.context = {\n                  ...stateMachine.service.context,\n                  enqueuedMessage: undefined,\n                };\n              }\n            };\n            ws.onclose = (event) => {\n              if (event.code !== WebSocketErrorCodes.NORMAL_CLOSURE) {\n                const { onError = noop } = getCallbacks();\n                onError(\n                  new ApiError({\n                    message: `Error closing the connection: ${event.reason}`,\n                    status: event.code,\n                  }),\n                );\n              }\n              send({ type: \"connectionClosed\", code: event.code });\n            };\n            ws.onerror = (event) => {\n              // TODO specify error protocol for identified errors\n              const { onError = noop } = getCallbacks();\n              onError(new ApiError({ message: \"Unknown error\", status: 500 }));\n            };\n            ws.onmessage = (event) => {\n              const {\n                decodeMessage = decodeMessageFn,\n                onResult,\n                onError = noop,\n              } = getCallbacks();\n\n              handleRealtimeMessage({\n                data: event.data,\n                decodeMessage,\n                onResult,\n                onError,\n                send,\n              });\n            };\n          }\n          if (previousState === \"active\" && machine.current !== \"active\") {\n            clearTimeout(tokenRefreshTimer);\n            tokenRefreshTimer = undefined;\n          }\n          previousState = machine.current;\n        },\n      );\n\n      const send = (input: Input & Partial<WithRequestId>) => {\n        // Use throttled send to avoid sending too many messages\n        stateMachine.throttledSend({\n          type: \"send\",\n          message: encodeMessageFn(input),\n        });\n      };\n\n      const close = () => {\n        stateMachine.service.send({ type: \"close\" });\n      };\n\n      return {\n        send,\n        close,\n      };\n    },\n  };\n}\n",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Project source file, robot3",
      "display": "libs/client/src/realtime.ts",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Project full_name, robot3",
      "display": "fal-ai/fal-js",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Project stargazers_count, robot3",
      "display": "189",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Library name, @zag-js/core",
      "display": "@zag-js/core",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Monthly downloads, @zag-js/core",
      "display": "8.6M",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "License, @zag-js/core",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "Package release, @zag-js/core",
      "display": "1.48.0",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Package release date, @zag-js/core",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Install, @zag-js/core",
      "display": "npm install @zag-js/core",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Quickstart, @zag-js/core",
      "display": "import { createMachine, findTransition } from '@zag-js/core';\n\nconst machine = createMachine({\n  initialState: () => 'idle',\n  states: { idle: { on: { START: { target: 'running' } } }, running: {} },\n});\nconst match = findTransition(machine, 'idle', 'START');\n",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Official description, @zag-js/core",
      "display": "Implements a minimal XState FSM for UI machines.",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Quickstart source file, @zag-js/core",
      "display": "dist/state.d.ts",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Repository stars, @zag-js/core",
      "display": "5.3K",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Nested state models, @zag-js/core",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Parallel state regions, @zag-js/core",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Model and execution role, @zag-js/core",
      "display": "UI-oriented state-model and transition helper core. createMachine indexes/returns configuration; framework/vanilla adapters supply the running Service, send, actions, and effects.",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Library name, finity",
      "display": "Finity",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Monthly downloads, finity",
      "display": "4.2M",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "License, finity",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Package release, finity",
      "display": "0.5.4",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Package release date, finity",
      "display": "Mar 2018",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Install, finity",
      "display": "npm install finity",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Quickstart, finity",
      "display": "import Finity from 'finity';\n\nconst machine = Finity.configure()\n  .initialState('idle').on('START').transitionTo('running')\n  .state('running').start();\nmachine.handle('START');\n",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Official description, finity",
      "display": "Defines finite state machines for Node.js and the browser through a configuration DSL.",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Quickstart source file, finity",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Repository stars, finity",
      "display": "135",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Nested state models, finity",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Parallel state regions, finity",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Model and execution role, finity",
      "display": "Fluent finite/hierarchical machine DSL with event, timeout, and Promise triggers plus state-entry/exit hooks.",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Project function, finity",
      "display": "private onWebsocketMessage(data: WebSocket.RawData): void {\n  this.logger.debug(`received message on websocket: ${data.toString()}`);\n\n  // parse message into slack event\n  let event: { type: string } & Record<string, unknown>;\n  try {\n    event = JSON.parse(data.toString());\n    // biome-ignore lint/suspicious/noExplicitAny: errors can be anything\n  } catch (parseError: any) {\n    // prevent application from crashing on a bad message, but log an error to bring attention\n    this.logger.error(\n      `unable to parse incoming websocket message: ${parseError.message}\\n    message contents: \"${data}\"`,\n    );\n    return;\n  }\n\n  // internal event handlers\n  if (event.type === 'hello') {\n    this.stateMachine.handle('server hello');\n  }\n  if (event.type === 'team_migration_started') {\n    if (this.websocket !== undefined) {\n      // this will trigger the 'websocket close' event on the state machine, which transitions to clean up\n      this.websocket.close();\n    }\n  }\n\n  if (\n    this.stateMachine.getCurrentState() === 'connected' &&\n    this.stateMachine.getStateHierarchy()[1] === 'resuming' &&\n    event.reply_to !== undefined &&\n    event.reply_to === this.messageId\n  ) {\n    this.stateMachine.handle('replay finished');\n  }\n\n  // emit for event handlers\n  this.emit('slack_event', event.type, event);\n  this.emit(event.type, event);\n  if (event.subtype !== undefined) {\n    this.emit(`${event.type}::${event.subtype}`, event);\n  }\n}\n",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Project source file, finity",
      "display": "packages/rtm-api/src/RTMClient.ts",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Project full_name, finity",
      "display": "slackapi/node-slack-sdk",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Project stargazers_count, finity",
      "display": "3.4K",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Library name, javascript-state-machine",
      "display": "javascript-state-machine",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Monthly downloads, javascript-state-machine",
      "display": "1.1M",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "License, javascript-state-machine",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Package release, javascript-state-machine",
      "display": "3.1.0",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Package release date, javascript-state-machine",
      "display": "Jul 2018",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Install, javascript-state-machine",
      "display": "npm install javascript-state-machine",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Quickstart, javascript-state-machine",
      "display": "const StateMachine = require('javascript-state-machine');\n\nconst machine = new StateMachine({\n  init: 'idle',\n  transitions: [{ name: 'start', from: 'idle', to: 'running' }],\n});\nmachine.start();\n",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Repository stars, javascript-state-machine",
      "display": "8.7K",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Nested state models, javascript-state-machine",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Parallel state regions, javascript-state-machine",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Model and execution role, javascript-state-machine",
      "display": "Flat named states and generated transition methods, with configurable lifecycle callbacks and cancellation/async hooks.",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Project function, javascript-state-machine",
      "display": "onCountdown() {\n                    (function tick() {\n                        session._display(session.countdownMessages.shift());\n\n                        if (!session.countdown--) {\n                            session.fsm.run();\n                        } else {\n                            setTimeout(tick, 1000);\n                        }\n                    }());\n                }\n",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Project source file, javascript-state-machine",
      "display": "src/models/session/live-session.js",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Project full_name, javascript-state-machine",
      "display": "dashersw/brain-bits",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Project stargazers_count, javascript-state-machine",
      "display": "186",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Library name, stately.js",
      "display": "Stately.js",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Monthly downloads, stately.js",
      "display": "70.4K",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "License, stately.js",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Package release, stately.js",
      "display": "2.0.0",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Package release date, stately.js",
      "display": "Oct 2017",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Install, stately.js",
      "display": "npm install stately.js",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Quickstart, stately.js",
      "display": "const Stately = require('stately.js');\n\nconst machine = new Stately({\n  idle: { START: 'running' },\n  running: {},\n}, 'idle');\nmachine.START();\n",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Official description, stately.js",
      "display": "Runs finite state machines in Node.js and the browser.",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Quickstart source file, stately.js",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Repository stars, stately.js",
      "display": "814",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Nested state models, stately.js",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Parallel state regions, stately.js",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Model and execution role, stately.js",
      "display": "Flat state/event-table engine with generated event methods and lifecycle hooks. Current2 has no old bind() subscription API; distinct from the Stately XState project.",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Project function, stately.js",
      "display": "var detachHandler = function(frame) {\n  if (this.getMachineState() === 'ATTACHED') {\n    this.ATTACHED.sendDetach({ closed: frame.closed });\n  }\n\n  link._detached(frame);\n  return this.DETACHED;\n};\n",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Project source file, stately.js",
      "display": "lib/link.js",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Project full_name, stately.js",
      "display": "noodlefrenzy/node-amqp10",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Project stargazers_count, stately.js",
      "display": "134",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best JavaScript state machine libraries XState javascript-state-machine Robot machina code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
