jssm 5.112.3 → 5.113.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +3 -3
  2. package/dist/deno/README.md +347 -0
  3. package/dist/deno/jssm.js +1 -0
  4. package/dist/{es6 → deno}/jssm_constants.d.ts +5 -0
  5. package/dist/{es6 → deno}/jssm_types.d.ts +298 -5
  6. package/dist/jssm.es5.cjs +1 -1
  7. package/dist/jssm.es5.iife.js +1 -1
  8. package/dist/jssm.es6.mjs +1 -1
  9. package/dist/jssm_viz.cjs +1 -1
  10. package/dist/jssm_viz.iife.cjs +1 -1
  11. package/dist/jssm_viz.mjs +1 -1
  12. package/jssm.es5.d.cts +241 -2
  13. package/jssm.es6.d.ts +241 -2
  14. package/jssm_viz.es5.d.cts +216 -2
  15. package/jssm_viz.es6.d.ts +216 -2
  16. package/package.json +18 -2
  17. package/.clocignore +0 -1
  18. package/.codeclimate.yml +0 -22
  19. package/.editorconfig +0 -12
  20. package/.eslintrc +0 -20
  21. package/.gitattributes +0 -17
  22. package/.log-progress.json +0 -9
  23. package/.nycrc +0 -6
  24. package/.travis.yml +0 -9
  25. package/CHANGELOG.md +0 -263
  26. package/CLAUDE.md +0 -11
  27. package/dist/es6/fsl_parser.js +0 -1
  28. package/dist/es6/jssm.js +0 -3320
  29. package/dist/es6/jssm_arrow.js +0 -211
  30. package/dist/es6/jssm_compiler.js +0 -380
  31. package/dist/es6/jssm_constants.js +0 -121
  32. package/dist/es6/jssm_error.js +0 -47
  33. package/dist/es6/jssm_theme.js +0 -24
  34. package/dist/es6/jssm_types.js +0 -3
  35. package/dist/es6/jssm_util.js +0 -337
  36. package/dist/es6/jssm_viz.js +0 -560
  37. package/dist/es6/jssm_viz_colors.js +0 -63
  38. package/dist/es6/themes/jssm_base_stylesheet.d.ts +0 -11
  39. package/dist/es6/themes/jssm_base_stylesheet.js +0 -58
  40. package/dist/es6/themes/jssm_theme_bold.d.ts +0 -11
  41. package/dist/es6/themes/jssm_theme_bold.js +0 -58
  42. package/dist/es6/themes/jssm_theme_default.d.ts +0 -11
  43. package/dist/es6/themes/jssm_theme_default.js +0 -58
  44. package/dist/es6/themes/jssm_theme_modern.d.ts +0 -11
  45. package/dist/es6/themes/jssm_theme_modern.js +0 -58
  46. package/dist/es6/themes/jssm_theme_ocean.d.ts +0 -11
  47. package/dist/es6/themes/jssm_theme_ocean.js +0 -56
  48. package/dist/es6/themes/jssm_theme_plain.d.ts +0 -11
  49. package/dist/es6/themes/jssm_theme_plain.js +0 -70
  50. package/dist/es6/version.js +0 -2
  51. package/dist/jssm.es5.nonmin.cjs +0 -24506
  52. package/dist/jssm.es6.nonmin.cjs +0 -24473
  53. package/dist/jssm_viz.es5.iife.nonmin.cjs +0 -24679
  54. package/dist/jssm_viz.es5.nonmin.cjs +0 -24674
  55. package/dist/jssm_viz.es6.nonmin.cjs +0 -24661
  56. package/jest-dragon.config.cjs +0 -36
  57. package/jest-spec.config.cjs +0 -36
  58. package/jest-stoch.config.cjs +0 -36
  59. package/jest-unicode.config.cjs +0 -36
  60. package/log-progress.data.json +0 -28
  61. package/rollup.config.deno.js +0 -44
  62. package/rollup.config.es5.js +0 -52
  63. package/rollup.config.es6.js +0 -55
  64. package/rollup.config.viz.es5.js +0 -46
  65. package/rollup.config.viz.es6.js +0 -46
  66. package/rollup.config.viz.iife.js +0 -36
  67. package/tutorial_learn_testing.md +0 -168
  68. package/typedoc-options.cjs +0 -69
  69. /package/dist/{es6 → deno}/fsl_parser.d.ts +0 -0
  70. /package/dist/{es6 → deno}/jssm.d.ts +0 -0
  71. /package/dist/{es6 → deno}/jssm_arrow.d.ts +0 -0
  72. /package/dist/{es6 → deno}/jssm_compiler.d.ts +0 -0
  73. /package/dist/{es6 → deno}/jssm_error.d.ts +0 -0
  74. /package/dist/{es6 → deno}/jssm_theme.d.ts +0 -0
  75. /package/dist/{es6 → deno}/jssm_util.d.ts +0 -0
  76. /package/dist/{es6 → deno}/jssm_viz.d.ts +0 -0
  77. /package/dist/{es6 → deno}/jssm_viz_colors.d.ts +0 -0
  78. /package/dist/{es6 → deno}/version.d.ts +0 -0
package/README.md CHANGED
@@ -18,10 +18,10 @@ Please edit the file it's derived from, instead: `./src/md/readme_base.md`
18
18
 
19
19
 
20
20
 
21
- * Generated for version 5.112.3 at 5/12/2026, 7:48:34 AM
21
+ * Generated for version 5.112.4 at 5/12/2026, 11:13:56 AM
22
22
 
23
23
  -->
24
- # jssm 5.112.3
24
+ # jssm 5.112.4
25
25
 
26
26
  [**Try the live editor**](https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html) ·
27
27
  [Documentation](https://stonecypher.github.io/jssm/docs/) ·
@@ -334,7 +334,7 @@ If your contribution is missing here, please open an issue.
334
334
  ***5,342 tests***, run 14,351 times.
335
335
 
336
336
  - 5,251 specs with 100.0% coverage
337
- - 91 fuzz tests with 60.8% coverage
337
+ - 91 fuzz tests with 62.2% coverage
338
338
  - 3,460 TypeScript lines - 1.5 tests per line, 4.1 generated tests per line
339
339
 
340
340
  [![Actions Status](https://github.com/StoneCypher/jssm/workflows/Node%20CI/badge.svg)](https://github.com/StoneCypher/jssm/actions)
@@ -0,0 +1,347 @@
1
+ <!--
2
+
3
+ I8, 8 ,8I 88
4
+ `8b d8b d8' ""
5
+ "8, ,8"8, ,8"
6
+ Y8 8P Y8 8P ,adPPYYba, 8b,dPPYba, 8b,dPPYba, 88 8b,dPPYba, ,adPPYb,d8
7
+ `8b d8' `8b d8' "" `Y8 88P' "Y8 88P' `"8a 88 88P' `"8a a8" `Y88
8
+ `8a a8' `8a a8' ,adPPPPP88 88 88 88 88 88 88 8b 88
9
+ `8a8' `8a8' 88, ,88 88 88 88 88 88 88 "8a, ,d88
10
+ `8' `8' `"8bbdP"Y8 88 88 88 88 88 88 `"YbbdP"Y8
11
+ aa, ,88
12
+ "Y8bbdP"
13
+
14
+ This file is generated. If you edit it, the edits ***will be lost***.
15
+ ----------------------
16
+
17
+ Please edit the file it's derived from, instead: `./src/md/readme_base.md`
18
+
19
+
20
+
21
+ * Generated for version 5.112.4 at 5/12/2026, 11:13:56 AM
22
+
23
+ -->
24
+ # jssm 5.112.4
25
+
26
+ [**Try the live editor**](https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html) ·
27
+ [Documentation](https://stonecypher.github.io/jssm/docs/) ·
28
+ [Discord](https://discord.gg/9P95USqnMK) ·
29
+ [Issues](https://github.com/StoneCypher/fsl/issues)
30
+
31
+ **Easy.** Tiny. Fast. Finite state machines as one-liner strings, for
32
+ TypeScript and JavaScript. Renders to PNG, SVG, and JPEG. Runs in Node,
33
+ browsers, and Deno. MIT licensed.
34
+
35
+ ```javascript
36
+ import { sm } from 'jssm';
37
+
38
+ const TrafficLight = sm`Red -> Green -> Yellow -> Red;`;
39
+ ```
40
+
41
+ That's it. Using it is equally easy:
42
+
43
+ ```javascript
44
+ TrafficLight.state(); // 'Red'
45
+ TrafficLight.go('Green'); // true
46
+ TrafficLight.state(); // 'Green'
47
+ ```
48
+
49
+ The point of a state machine is to refuse to do things that aren't correct:
50
+
51
+ ```javascript
52
+ TrafficLight.go('Red'); // false - Green doesn't go to Red, only Yellow
53
+ TrafficLight.go('Blue'); // throws - Blue doesn't exist at all
54
+ ```
55
+
56
+ A more involved machine, with main paths, forced paths, and per-state
57
+ styling, renders to:
58
+
59
+ <img src="https://raw.githubusercontent.com/StoneCypher/jssm/main/src/assets/doc%20light%20styled.png" alt="A styled four-state traffic light"/>
60
+
61
+ ```javascript
62
+ const TrafficLightWithOff = sm`
63
+ Red 'next' => Green 'next' => Yellow 'next' => Red;
64
+ [Red Yellow Green] ~> Off -> Red;
65
+
66
+ flow: left;
67
+
68
+ state Red : { background-color: pink; corners: rounded; };
69
+ state Yellow : { background-color: lightyellow; corners: rounded; };
70
+ state Green : { background-color: lightgreen; corners: rounded; };
71
+
72
+ state Off : {
73
+ background-color : steelblue;
74
+ text-color : white;
75
+ shape : octagon;
76
+ linestyle : dashed;
77
+ };
78
+ `;
79
+ ```
80
+
81
+ The same string is the runtime and the diagram. They cannot drift apart.
82
+
83
+ [**Try it in the live editor**](https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html) ·
84
+ [Documentation](https://stonecypher.github.io/jssm/docs/) ·
85
+ [Discord](https://discord.gg/9P95USqnMK) ·
86
+ [Issues](https://github.com/StoneCypher/fsl/issues)
87
+
88
+
89
+
90
+ <br/>
91
+
92
+ ## Install
93
+
94
+ ```
95
+ npm install jssm
96
+ ```
97
+
98
+ The package ships pure ES6, a CommonJS ES5 bundle, an IIFE for browsers,
99
+ and TypeScript typings. A Deno build is included. Node 10 or newer.
100
+
101
+
102
+
103
+ <br/>
104
+
105
+ ## Visualization
106
+
107
+ `jssm` ships with a visualization subpath that renders state machines to
108
+ SVG using Graphviz (via [`@viz-js/viz`](https://www.npmjs.com/package/@viz-js/viz)).
109
+
110
+ ```typescript
111
+ import { sm } from 'jssm';
112
+ import { fsl_to_svg_string } from 'jssm/viz';
113
+
114
+ const svg = await fsl_to_svg_string('a -> b;');
115
+ ```
116
+
117
+ The viz subpath is opt-in - importing only from `jssm` does not pull in
118
+ `@viz-js/viz`. See the Visualization doc page for browser, ESM, and IIFE
119
+ usage patterns.
120
+
121
+
122
+
123
+ <br/>
124
+
125
+ ## 60-second tour
126
+
127
+ **Actions** let a machine advance without the caller knowing the next state:
128
+
129
+ ```javascript
130
+ const Light = sm`Red 'next' -> Green 'next' -> Yellow 'next' -> Red;`;
131
+
132
+ Light.action('next'); // true
133
+ Light.state(); // 'Green'
134
+ Light.action('next'); // true
135
+ Light.state(); // 'Yellow'
136
+ ```
137
+
138
+ **Three arrow types** distinguish kinds of transition:
139
+
140
+ ```javascript
141
+ const Light = sm`
142
+ Red => Green => Yellow => Red; // => main path
143
+ [Red Yellow Green] ~> Off -> Red; // ~> forced, -> legal
144
+ `;
145
+ ```
146
+
147
+ `->` is a legal transition. `=>` is a legal transition that is also part of
148
+ the main path. `~>` is a transition that requires `force_transition` -
149
+ useful for emergency stops, resets, and other rarities.
150
+
151
+ **Hooks** observe and gate transitions:
152
+
153
+ ```javascript
154
+ const m = sm`Red 'next' -> Green 'next' -> Yellow 'next' -> Red;`
155
+ .hook('Red', 'Green', () => console.log('GO')) // specific edge
156
+ .hook_entry('Red', () => console.log('STOP')) // entering a state
157
+ .hook_action('Yellow', 'Red', 'next', () => allowed()); // gate a specific action; return false to block
158
+ ```
159
+
160
+ Pre-hooks fire before the state changes and may return `false` to refuse the
161
+ transition. Post-hooks fire after. Four `*_everything` hooks
162
+ (`hook_pre_everything`, `hook_everything`, `hook_pre_post_everything`,
163
+ `hook_post_everything`) bracket the entire pipeline if you want a single
164
+ observation point.
165
+
166
+ **Refusals and errors are deliberately different.** An illegal transition
167
+ returns `false`. An unknown state throws. Branching code can rely on the
168
+ distinction.
169
+
170
+
171
+
172
+ <br/>
173
+
174
+ ## Why jssm
175
+
176
+ **The big win: most state-machine libraries make you write a gargantuan
177
+ JSON document, or call a builder API a few dozen times, to define a single
178
+ machine. jssm machines are short, readable, arrow-driven strings - so they
179
+ are easy to write, easy to read, easy to debug, and easy to share.**
180
+
181
+ That decision shows up everywhere downstream:
182
+
183
+ - **A DSL with features other state-machine libraries don't have.** Three
184
+ arrow types distinguish legal, main-path, and forced transitions. Array
185
+ notation collapses repeated edges - `[Red Yellow Green] ~> Off` replaces
186
+ three lines. Named actions, per-state styling, named edges, validators,
187
+ and live visualization all live in the same string the runtime parses.
188
+
189
+ - **Definition strings stay tiny, which makes machines easy to debug.**
190
+ The traffic light is one line; the [full eight-step ATM walkthrough](https://github.com/StoneCypher/jssm/blob/main/src/doc_md/Tutorial_ATM.md)
191
+ is thirty. Small enough to read top-to-bottom, diff in code review,
192
+ paste into a bug report, or drop into the
193
+ [live editor](https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html)
194
+ for a rendered diagram you can step through.
195
+
196
+ - **Fast.** Tens of millions of transitions per second on commodity
197
+ hardware. See [`src/buildjs/benchmark.cjs`](https://github.com/StoneCypher/jssm/blob/main/src/buildjs/benchmark.cjs)
198
+ or run `npm run benny` against your own machine.
199
+
200
+ - **More thoroughly tested than any other JavaScript state-machine
201
+ library.** 5,342 tests at 100.0% line coverage
202
+ ([report](https://coveralls.io/github/StoneCypher/jssm)), plus
203
+ fuzz testing via `fast-check`, with parser test data across ten natural
204
+ languages and Emoji.
205
+
206
+
207
+
208
+ <br/>
209
+
210
+ ## Documentation
211
+
212
+ - [What are state machines?](https://github.com/StoneCypher/jssm/blob/main/src/doc_md/WhatAreStateMachines.md) - conceptual intro for newcomers
213
+ - [Getting started](https://github.com/StoneCypher/jssm/blob/main/src/doc_md/GettingStarted.md) - install and use the library across Node, browser, Deno, ES5/ES6, CDN, and TypeScript
214
+ - [Tutorial: a four-state traffic light](https://github.com/StoneCypher/jssm/blob/main/src/doc_md/Tutorial_TrafficLight.md) - short walkthrough that introduces the three arrow types
215
+ - [Tutorial: building an ATM state machine](https://github.com/StoneCypher/jssm/blob/main/src/doc_md/Tutorial_ATM.md) - longer walkthrough that builds a real-world machine in nine incremental steps
216
+ - [Language reference](https://github.com/StoneCypher/jssm/blob/main/src/doc_md/LanguageReference.md) - DSL reference for people already comfortable with state machines
217
+ - [Catalog of example machines](https://github.com/StoneCypher/jssm/blob/main/src/doc_md/ExampleMachines.md) - comparison table of worked examples (light switch, traffic light, intersection, vending machine, more)
218
+ - [Generated API reference](https://stonecypher.github.io/jssm/docs/) - full surface, generated from the TypeScript source
219
+
220
+
221
+
222
+ <br/>
223
+
224
+ ## API at a glance
225
+
226
+ | Method | Purpose |
227
+ |---|---|
228
+ | `` sm`...` `` | Build a machine from DSL |
229
+ | `.state()` | The current state |
230
+ | `.transition(state)` | Move to a state. Returns `false` if illegal, throws if unknown. |
231
+ | `.force_transition(state)` | Move to a state across a `~>` forced edge |
232
+ | `.action(name)` | Trigger a named action. The next state is derived from the current state. |
233
+ | `.valid_transition(state)` · `.valid_action(name)` | Test whether a transition or action is legal from the current state, without taking it |
234
+ | `.hook(from, to, fn)` | Run on a specific edge. Pre-hook; return `false` to block. |
235
+ | `.hook_entry(state, fn)` · `.hook_exit(state, fn)` | Run when entering or leaving a state |
236
+ | `.hook_action(from, to, action, fn)` | Run when a named action causes a specific edge |
237
+ | `.hook_pre_everything(fn)` · `.hook_everything(fn)` | Bracket the pre-hook pipeline |
238
+ | `.hook_pre_post_everything(fn)` · `.hook_post_everything(fn)` | Bracket the post-hook pipeline |
239
+
240
+ The full surface - including history, validators, factories, data, and the
241
+ graph-introspection methods - is in the [generated API
242
+ docs](https://stonecypher.github.io/jssm/docs/).
243
+
244
+
245
+
246
+ <br/>
247
+
248
+ ## Status
249
+
250
+ In production use since May 2017. Current series is 5.x and the DSL is
251
+ stable; the runtime API has been additive for several years. MIT licensed
252
+ end to end. Test data and parser cases are included for English, German,
253
+ French, Spanish, Hebrew, Russian, Ukrainian, Belarusian, Bengali,
254
+ Portuguese, and Emoji.
255
+
256
+
257
+
258
+ <br/>
259
+
260
+ ## Community
261
+
262
+ <a href="https://discord.gg/9P95USqnMK">![Discord community](https://discordapp.com/api/guilds/899910109642235924/widget.png?style=banner1)</a>
263
+
264
+ Questions, design discussions, bug reports, and "what would you do for X?"
265
+ are all welcome on Discord. Issues that need a paper trail go in the
266
+ [issue tracker](https://github.com/StoneCypher/fsl/issues).
267
+
268
+
269
+
270
+ <br/>
271
+
272
+ ## Comparisons
273
+
274
+ A direct, head-to-head comparison with the other actively-maintained JS state
275
+ machine libraries - XState, Stately.js, Finity, machina.js, and others - is
276
+ in progress and will live in
277
+ [FeatureComparison.md](https://github.com/StoneCypher/jssm/blob/main/src/doc_md/FeatureComparison.md).
278
+
279
+ A list of related projects, without commentary, is at the bottom of that
280
+ file.
281
+
282
+
283
+
284
+ <br/>
285
+
286
+ ## Contributing
287
+
288
+ Issues and PRs are welcome. The cheapest useful contribution is a language
289
+ test case: open a PR with
290
+ [`english.json`](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/english.json)
291
+ translated into your language. Translating
292
+ [`traffic_light.fsl`](https://github.com/StoneCypher/fsl_traffic_light/blob/master/traffic_light.fsl)
293
+ into a separate repo and publishing it goes a step further.
294
+
295
+
296
+
297
+ <br/>
298
+
299
+ ## Acknowledgements
300
+
301
+ [Michael Morgan](https://github.com/msmorgan/) has debated significant
302
+ sections of the notation, invented several concepts and operators, helped
303
+ with the parser and system nomenclature, and published the first non-author
304
+ `FSL` machine. [Vat Raghavan](https://github.com/MachinShin) participated
305
+ extensively in language design and implemented several features. [Forest
306
+ Belton](https://github.com/forestbelton) provided guidance, bugfixes, and
307
+ parser commentary. [Jordan
308
+ Harbrand](https://github.com/ljharb) suggested two interesting features and
309
+ gave strong feedback on the initial tutorial draft.
310
+
311
+ Translation contributors:
312
+
313
+ - [Mykhaylo Les](https://github.com/miles91) - [Ukrainian](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/ukrainian.json), [Belarusian](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/belarussian.json), [Russian](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/russian.json)
314
+ - [Tanvir Islam](https://github.com/tanvirrb) - [Bengali](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/bengali.json) (also published the first non-English `FSL` machine)
315
+ - [Francisco Junior](https://github.com/fcojr) - [Portuguese](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/portuguese.json)
316
+ - [Jeff Katz](https://github.com/kraln) - [German](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/german.json)
317
+ - [Alex Cresswell](https://github.com/technophile77) - [Spanish](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/spanish.json)
318
+ - [Dvir Cohen](https://github.com/cohendvir) - [Hebrew](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/hebrew.json)
319
+ - [David de la Peña](https://github.com/daviddelapena) - [French](https://github.com/StoneCypher/jssm/blob/main/src/ts/tests/language_data/french.json)
320
+
321
+ If your contribution is missing here, please open an issue.
322
+
323
+
324
+
325
+ <br/>
326
+
327
+ ---
328
+
329
+ <details>
330
+ <summary>Stats, coverage, and badges</summary>
331
+
332
+ <br/>
333
+
334
+ ***5,342 tests***, run 14,351 times.
335
+
336
+ - 5,251 specs with 100.0% coverage
337
+ - 91 fuzz tests with 62.2% coverage
338
+ - 3,460 TypeScript lines - 1.5 tests per line, 4.1 generated tests per line
339
+
340
+ [![Actions Status](https://github.com/StoneCypher/jssm/workflows/Node%20CI/badge.svg)](https://github.com/StoneCypher/jssm/actions)
341
+ [![NPM version](https://img.shields.io/npm/v/jssm.svg)](https://www.npmjs.com/package/jssm)
342
+ [![NPM downloads](https://img.shields.io/npm/dt/jssm.svg)](https://www.npmjs.com/package/jssm)
343
+ [![License](https://img.shields.io/npm/l/jssm.svg)](https://github.com/StoneCypher/jssm/blob/main/LICENSE.md)
344
+ [![Coveralls status](https://img.shields.io/coveralls/StoneCypher/jssm.svg)](https://coveralls.io/github/StoneCypher/jssm)
345
+ [![Open issues](https://img.shields.io/github/issues/StoneCypher/fsl.svg)](https://github.com/StoneCypher/fsl/issues)
346
+
347
+ </details>