Various experiments and prototype state-machine investigations.
I've been using XState a lot recently, but want to execute my state charts from Java, even though I enjoyed writing a protocol simulation in TypeScript and React. Running at CodeSandbox. View it here.
There are a couple of challenges, I think:
First: translate the XState JSON to SCXML. Although apparently XState can import SCXML it seems it cannot export it.
State-Machine-Cat has its own format and can apparently read and write SCXML (as well as drawing charts for you). It can't read XState JSON. So here is a limited experiment in reading XState JSON to output in State-Machine-Cat format.
Second: Execute the SCXML. There seem to be a couple of options.
- The Pivotal Spring SCXML machine. This has a reactive interface. It has a builder that means you don't need to do the Spring Boot magic. There is a simple example here of getting that going.
- There was an Apache Commons SCXML implementation. That seems to have got stuck and is no longer in development (since 2015 or thereabouts), though the libraries seem to be udpated regularly. I forked it and compiled it. There is a simple example here of using it.
- Run the XState TypeScript from within Java - I haven't tried that yet.
- Looks like this was an open implementation. I haven't looked at it yet.