@evgkch/machjs
Examples
Each example is a small app built on the library: one table of rules, a context that belongs to the state rather than to the machine. Open the demo, then read the walkthrough — it goes through the same code line by line.
-
Selection rectangle
Drag to draw a rectangle, then move or resize it. Five phases, eight handles, undo. Plain HTML and TypeScript, no framework — every pointer event goes straight to the machine, and no handler tests the phase.
-
Schema review
The document under review is itself a state-machine schema. The gate is the library's own
validateandanalyze, the sign-offs are ECDSA signatures over the text, and the machine is drawn on the page by the inspector's widgets. Every button is enabled by asking the machinecan(). -
Two machines over a wire
A card terminal and a host, each a machine of its own: the terminal's Λ is the host's Σ and back again. The wire between them can be cut, slowed, or made to deliver twice — and every delivery the machine at the far end refuses is written down with the reason it gave.
-
Refreshing a token
Five callers get a 401 at once and the token is fetched exactly once — not by a flag, but because
emit refreshstands in one cell of the schema. Break the refresh and all five are refused together; none of them waits.