jssm 5.162.6 → 5.162.8

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 (53) hide show
  1. package/README.md +7 -7
  2. package/custom-elements.json +47 -47
  3. package/dist/cdn/instance.js +5 -3
  4. package/dist/cdn/viz.js +1 -1
  5. package/dist/cli/fsl-export-system-prompt.cjs +27 -24
  6. package/dist/cli/fsl-render.cjs +1 -1
  7. package/dist/cli/fsl.cjs +1 -1
  8. package/dist/cli/lib.cjs +1 -1
  9. package/dist/cli/lib.mjs +1 -1
  10. package/dist/cm6/fsl_language.js +10 -14
  11. package/dist/deno/README.md +7 -7
  12. package/dist/deno/fence.d.ts +0 -1
  13. package/dist/deno/fsl_fence_highlight.d.ts +0 -4
  14. package/dist/deno/fsl_fence_render.d.ts +0 -8
  15. package/dist/deno/fsl_gif.d.ts +0 -8
  16. package/dist/deno/fsl_markdown_fence.d.ts +0 -5
  17. package/dist/deno/fsl_svg_patch.d.ts +0 -6
  18. package/dist/deno/fsl_walk.d.ts +0 -2
  19. package/dist/deno/jssm.d.ts +214 -503
  20. package/dist/deno/jssm.js +1 -1
  21. package/dist/deno/jssm_compiler.d.ts +1 -1
  22. package/dist/deno/jssm_constants.d.ts +0 -3
  23. package/dist/deno/jssm_intern.d.ts +0 -15
  24. package/dist/deno/jssm_theme.d.ts +2 -2
  25. package/dist/deno/jssm_types.d.ts +13 -34
  26. package/dist/deno/jssm_util.d.ts +20 -6
  27. package/dist/deno/jssm_viz.d.ts +5 -51
  28. package/dist/es6/cm6/fsl_language.d.ts +0 -2
  29. package/dist/fence/fence.js +1664 -1830
  30. package/dist/jssm.es5.cjs +1 -1
  31. package/dist/jssm.es5.iife.js +1 -1
  32. package/dist/jssm.es6.mjs +1 -1
  33. package/dist/jssm_viz.cjs +1 -1
  34. package/dist/jssm_viz.iife.cjs +1 -1
  35. package/dist/jssm_viz.mjs +1 -1
  36. package/dist/wc/docs.define.js +0 -5
  37. package/dist/wc/docs.js +79 -43
  38. package/dist/wc/editor.define.js +0 -5
  39. package/dist/wc/editor.js +1 -7
  40. package/dist/wc/instance.define.js +0 -6
  41. package/dist/wc/instance.js +93 -115
  42. package/dist/wc/viz.define.js +0 -6
  43. package/dist/wc/viz.js +22 -36
  44. package/dist/wc/widgets.define.js +0 -5
  45. package/dist/wc/widgets.js +117 -95
  46. package/jssm.cli.d.cts +0 -8
  47. package/jssm.cli.d.ts +0 -8
  48. package/jssm.es5.d.cts +449 -808
  49. package/jssm.es6.d.ts +449 -808
  50. package/jssm.fence.d.ts +213 -508
  51. package/jssm_viz.es5.d.cts +216 -529
  52. package/jssm_viz.es6.d.ts +216 -529
  53. package/package.json +16 -10
package/jssm.fence.d.ts CHANGED
@@ -11,12 +11,10 @@ interface FenceRenderOptions {
11
11
  * editor-parity code highlighting whose state names carry the diagram's own
12
12
  * node colors. Invalid FSL renders a visible error box — this function
13
13
  * never throws for bad machine source.
14
- *
15
14
  * @param source - The FSL machine source (fence body).
16
15
  * @param info - The fence info string (e.g. `'fsl image code width=300'`).
17
16
  * @param opts.inline_colors - Whether code spans carry inline diagram colors (default true).
18
17
  * @returns The rendered `<div class="fsl-fence">…</div>` markup.
19
- *
20
18
  * @example
21
19
  * await render_fence_html('Red => Green => Red;', 'fsl');
22
20
  * // '<div class="fsl-fence" …><svg…/svg><pre class="fsl-code">…</pre></div>'
@@ -28,11 +26,9 @@ declare function render_fence_html(source: string, info: string, opts?: FenceRen
28
26
  * Each fence is isolated — a broken machine becomes its own error box and
29
27
  * the rest of the document still renders. Backtick fences of length ≥3
30
28
  * are recognized; tilde fences are out of scope (v1, spec §9).
31
- *
32
29
  * @param markdown - The full Markdown document source.
33
30
  * @param opts.inline_colors - Whether code spans carry inline diagram colors (default true).
34
31
  * @returns The document with every `fsl`/`jssm` fence replaced by rendered HTML.
35
- *
36
32
  * @example
37
33
  * await transform_markdown('# Doc\n\n```fsl\na -> b;\n```\n');
38
34
  * // '# Doc\n\n<div class="fsl-fence">…</div>\n'
@@ -57,7 +53,6 @@ interface GifRenderOptions {
57
53
  * every-edge tour. Graphviz lays the machine out ONCE; each frame patches
58
54
  * one state's fill in the SVG string and rasterizes — identical geometry
59
55
  * across frames, no layout jitter.
60
- *
61
56
  * @param source - The FSL machine source.
62
57
  * @param opts.delay_cs - Per-frame delay in centiseconds (default 70).
63
58
  * @param opts.loop - Netscape loop count, 0 = forever (default 0).
@@ -65,14 +60,11 @@ interface GifRenderOptions {
65
60
  * @param opts.scale - Raster zoom percentage, 100 = 3× natural size (default 100).
66
61
  * @param opts.highlight_fill - Fill painted on the walked state (default '#ff9930').
67
62
  * @returns The encoded GIF89a bytes.
68
- *
69
63
  * @throws {JssmError} on invalid FSL (programmatic callers want exceptions;
70
64
  * the HTML renderers catch and box instead).
71
- *
72
65
  * @example
73
66
  * const gif = await render_fence_gif('Red => Green => Yellow => Red;');
74
67
  * // Uint8Array starting "GIF89a", three frames, looping forever
75
- *
76
68
  * @see plan_walk
77
69
  * @see encode_gif
78
70
  */
@@ -94,16 +86,13 @@ interface Quantized {
94
86
  * `max_colors` or fewer distinct colors they are preserved exactly;
95
87
  * otherwise a median-cut partition supplies the palette and each pixel maps
96
88
  * to its box's weighted-average color.
97
- *
98
89
  * @param rgba - Straight RGBA bytes; length must be a multiple of 4.
99
90
  * @param max_colors - Palette ceiling, 2..256.
100
- *
101
91
  * @throws {JssmError} when `rgba.length` is not a multiple of 4.
102
92
  * @throws {JssmError} when `max_colors` is outside 2..256 — above 256 the
103
93
  * palette index no longer fits the `Uint8Array` indices this module packs
104
94
  * into GIF codes (silent index corruption instead of a clear failure);
105
95
  * below 2 there is no palette to quantize into.
106
- *
107
96
  * @example
108
97
  * const q = quantize(new Uint8Array([255,0,0,255, 0,255,0,255]));
109
98
  * q.palette_count; // 2
@@ -114,10 +103,8 @@ declare function quantize(rgba: Uint8Array, max_colors?: number): Quantized;
114
103
  * from `min_code_size + 1` up to the format's 12-bit ceiling, resets the
115
104
  * dictionary when full, terminates with EOI, and packs codes LSB-first.
116
105
  * Returns raw compressed bytes; the caller wraps them in GIF data sub-blocks.
117
- *
118
106
  * @param indices - Palette indices, each `< 2^min_code_size`.
119
107
  * @param min_code_size - Bits needed for the palette (2..8 for GIF).
120
- *
121
108
  * @example
122
109
  * lzw_encode(new Uint8Array([0, 0, 1]), 2); // Uint8Array of packed codes
123
110
  */
@@ -142,14 +129,11 @@ interface GifOptions {
142
129
  * palette, so every frame is pixel-exact while the union stays within 256
143
130
  * distinct colors. Frames must share dimensions. No transparency,
144
131
  * full-frame disposal — simple and correct first.
145
- *
146
132
  * @param frames - At least one frame; all with identical width/height and
147
133
  * `rgba.length === 4 · width · height`.
148
- *
149
134
  * @throws {JssmError} on zero frames, a zero-width or zero-height frame,
150
135
  * mismatched dimensions, or an rgba buffer whose length contradicts its
151
136
  * stated dimensions.
152
- *
153
137
  * @example
154
138
  * const red = { rgba: new Uint8Array([255,0,0,255]), width: 1, height: 1 };
155
139
  * const gif = encode_gif([red], { delay_cs: 50 });
@@ -220,7 +204,6 @@ type JssmAllowIslands = true | false | 'with_start';
220
204
  * - `{ height }` — height-only form (`default_size: height 600;`)
221
205
  *
222
206
  * This is a *hint*, not a hard constraint. Renderers may ignore it.
223
- *
224
207
  * @see Machine.default_size
225
208
  */
226
209
  type JssmDefaultSize = {
@@ -255,8 +238,7 @@ type FslTheme = typeof FslThemes[number];
255
238
  * and consumed by {@link jssm!deserialize}. Carries the current state, the
256
239
  * associated machine data, the recent history (subject to the configured
257
240
  * capacity), and metadata to detect version-skew on rehydration.
258
- *
259
- * @typeParam DataType - The type of the user-supplied data payload (`mDT`).
241
+ * @template DataType - The type of the user-supplied data payload (`mDT`).
260
242
  */
261
243
  type JssmSerialization<DataType> = {
262
244
  jssm_version: string;
@@ -282,7 +264,6 @@ type JssmSerialization<DataType> = {
282
264
  * // [ { kind: 'group', name: 'inner', mode: 'nest' },
283
265
  * // { kind: 'state', name: 'x' } ]
284
266
  * ```
285
- *
286
267
  * @see JssmGroupRef
287
268
  * @see JssmGroupRegistry
288
269
  */
@@ -309,7 +290,6 @@ type JssmGroupMemberRef = {
309
290
  * // registry.get('outer') === [ { kind:'group', name:'inner', mode:'nest' },
310
291
  * // { kind:'state', name:'c' } ]
311
292
  * ```
312
- *
313
293
  * @see JssmGroupMemberRef
314
294
  */
315
295
  type JssmGroupRegistry = Map<string, JssmGroupMemberRef[]>;
@@ -319,7 +299,6 @@ type JssmGroupRegistry = Map<string, JssmGroupMemberRef[]>;
319
299
  * Each is optional so a subject may declare only one direction; the compiler
320
300
  * merges an `enter` and an `exit` declaration for the same subject into one
321
301
  * of these.
322
- *
323
302
  * @see JssmHookDeclaration
324
303
  */
325
304
  type JssmBoundaryHooks = {
@@ -330,7 +309,6 @@ type JssmBoundaryHooks = {
330
309
  * Maps each group name that has at least one boundary hook to its merged
331
310
  * {@link JssmBoundaryHooks}. Carried on {@link JssmGenericConfig} for the
332
311
  * runtime to consume; depth-aware firing is a later task.
333
- *
334
312
  * @see JssmHookDeclaration
335
313
  */
336
314
  type JssmGroupHooks = Map<string, JssmBoundaryHooks>;
@@ -338,7 +316,6 @@ type JssmGroupHooks = Map<string, JssmBoundaryHooks>;
338
316
  * Maps each plain state name that has at least one boundary hook to its
339
317
  * merged {@link JssmBoundaryHooks}. The state-subject analogue of
340
318
  * {@link JssmGroupHooks}.
341
- *
342
319
  * @see JssmHookDeclaration
343
320
  */
344
321
  type JssmStateHooks = Map<string, JssmBoundaryHooks>;
@@ -370,9 +347,8 @@ type JssmTransitionPermitterMaybeArray<DataType> = JssmTransitionPermitter<DataT
370
347
  * per-edge `name`, an action label, a guard `check`, a transition
371
348
  * `probability` for stochastic models, and an `after_time` for timed
372
349
  * transitions.
373
- *
374
- * @typeParam StateType - The state-name type (usually `string`).
375
- * @typeParam DataType - The machine's data payload type (`mDT`).
350
+ * @template StateType - The state-name type (usually `string`).
351
+ * @template DataType - The machine's data payload type (`mDT`).
376
352
  */
377
353
  type JssmTransition<StateType, DataType> = {
378
354
  from: StateType;
@@ -556,7 +532,6 @@ type JssmGraphDefaultEdgeColor = {
556
532
  * reuses the per-state style items (so `color: red;` works inside a
557
533
  * `transition:` block exactly as inside a `state:` block) plus the
558
534
  * edge-scoped {@link JssmGraphDefaultEdgeColor} default.
559
- *
560
535
  * @see JssmTransitionConfig
561
536
  */
562
537
  type JssmTransitionStyleKey = JssmStateStyleKey | JssmGraphDefaultEdgeColor;
@@ -571,7 +546,6 @@ type JssmTransitionStyleKey = JssmStateStyleKey | JssmGraphDefaultEdgeColor;
571
546
  * const cfg = compile(parse('a -> b; transition: { color: red; };'));
572
547
  * // cfg.default_transition_config === [ { key: 'color', value: '#ff0000ff' } ]
573
548
  * ```
574
- *
575
549
  * @see JssmGraphConfig
576
550
  */
577
551
  type JssmTransitionConfig = JssmTransitionStyleKey[];
@@ -582,7 +556,7 @@ type JssmTransitionConfig = JssmTransitionStyleKey[];
582
556
  * default) into the consolidated `graph: {}` config. Each carries the
583
557
  * legacy parse key so downstream consumers can disambiguate.
584
558
  */
585
- type JssmGraphAliasKey = {
559
+ type JssmGraphAliasKey = JssmGraphDefaultEdgeColor | {
586
560
  key: 'graph_layout';
587
561
  value: JssmLayout;
588
562
  } | {
@@ -597,13 +571,12 @@ type JssmGraphAliasKey = {
597
571
  } | {
598
572
  key: 'flow';
599
573
  value: FslDirection;
600
- } | JssmGraphDefaultEdgeColor;
574
+ };
601
575
  /**
602
576
  * A single item inside a `graph: {}` default-config block. For v1 this
603
577
  * reuses the per-state style items plus the graph-scope alias items
604
578
  * ({@link JssmGraphAliasKey}) folded in from the deprecated top-level
605
579
  * graph keywords.
606
- *
607
580
  * @see JssmGraphConfig
608
581
  */
609
582
  type JssmGraphStyleKey = JssmStateStyleKey | JssmGraphAliasKey;
@@ -620,40 +593,9 @@ type JssmGraphStyleKey = JssmStateStyleKey | JssmGraphAliasKey;
620
593
  * // `background-color` item, so:
621
594
  * // cfg.default_graph_config includes { key: 'background-color', value: '#ffffffff' }
622
595
  * ```
623
- *
624
596
  * @see JssmTransitionConfig
625
597
  */
626
598
  type JssmGraphConfig = JssmGraphStyleKey[];
627
- /**
628
- * Complete shape of a jssm-viz theme. A theme provides a style block for
629
- * each kind of state (`state`, `hooked`, `start`, `end`, `terminal`) as
630
- * well as a matching `active_*` variant used while that state is current.
631
- *
632
- * The `graph`, `legal`, `main`, `forced`, `action`, and `title` slots are
633
- * reserved for future use and currently typed as `undefined`.
634
- *
635
- * Most user-defined themes should be typed as {@link JssmTheme} (the
636
- * `Partial` of this) so that omitted fields fall back to the base theme.
637
- */
638
- type JssmBaseTheme = {
639
- name: string;
640
- state: JssmStateConfig;
641
- hooked: JssmStateConfig;
642
- start: JssmStateConfig;
643
- end: JssmStateConfig;
644
- terminal: JssmStateConfig;
645
- active: JssmStateConfig;
646
- active_hooked: JssmStateConfig;
647
- active_start: JssmStateConfig;
648
- active_end: JssmStateConfig;
649
- active_terminal: JssmStateConfig;
650
- graph: undefined;
651
- legal: undefined;
652
- main: undefined;
653
- forced: undefined;
654
- action: undefined;
655
- title: undefined;
656
- };
657
599
  /**
658
600
  * Full configuration object accepted by the {@link jssm!Machine} constructor and
659
601
  * by {@link from}. Carries the transition list and the optional knobs
@@ -663,9 +605,8 @@ type JssmBaseTheme = {
663
605
  *
664
606
  * Most users never construct one of these directly — the `sm` tagged
665
607
  * template literal and {@link from} produce one from FSL source.
666
- *
667
- * @typeParam StateType - The state-name type (usually `string`).
668
- * @typeParam DataType - The user-supplied data payload type (`mDT`).
608
+ * @template StateType - The state-name type (usually `string`).
609
+ * @template DataType - The user-supplied data payload type (`mDT`).
669
610
  */
670
611
  /**
671
612
  * Editor/panel defaults an FSL machine declares in an `editor: {}` block
@@ -725,7 +666,6 @@ type JssmGenericConfig<StateType, DataType> = {
725
666
  *
726
667
  * Defaults to `100`. Raise it for legitimate pipelines that genuinely nest
727
668
  * more than 100 transitions via boundary hooks.
728
- *
729
669
  * @see Machine._boundary_depth_limit
730
670
  * @see Machine._fire_boundary_actions
731
671
  */
@@ -745,7 +685,7 @@ type JssmGenericConfig<StateType, DataType> = {
745
685
  failed_outputs?: Array<StateType>;
746
686
  initial_state?: StateType;
747
687
  start_states_no_enforce?: boolean;
748
- state_declaration?: Object[];
688
+ state_declaration?: object[];
749
689
  property_definition?: JssmPropertyDefinition[];
750
690
  state_property?: JssmPropertyDefinition[];
751
691
  arrange_declaration?: Array<Array<StateType>>;
@@ -809,7 +749,6 @@ type JssmGenericConfig<StateType, DataType> = {
809
749
  * arrow with optional per-direction action labels, probabilities, and
810
750
  * after-times. The recursive `se` field allows the parser to chain
811
751
  * arrows of the form `A -> B -> C`. Not intended for end-user code.
812
- *
813
752
  * @internal
814
753
  */
815
754
  type JssmCompileSe<StateType, mDT> = {
@@ -1118,7 +1057,6 @@ type JssmRng = () => number;
1118
1057
  * All event names that {@link jssm!Machine.on} accepts. These are observation
1119
1058
  * events fired by the machine in addition to (not in place of) the hook
1120
1059
  * system. Hooks intercept; events observe.
1121
- *
1122
1060
  * @see Machine.on
1123
1061
  */
1124
1062
  type JssmEventName = 'transition' | 'rejection' | 'action' | 'entry' | 'exit' | 'terminal' | 'complete' | 'error' | 'data-change' | 'override' | 'timeout' | 'hook-registration' | 'hook-removal';
@@ -1212,7 +1150,7 @@ type JssmErrorEventDetail = {
1212
1150
  error: unknown;
1213
1151
  source_event: JssmEventName;
1214
1152
  source_detail: unknown;
1215
- handler: Function;
1153
+ handler: JssmEventHandler<unknown, JssmEventName>;
1216
1154
  };
1217
1155
  /**
1218
1156
  * Detail payload fired with a `data-change` event. Fires whenever the
@@ -1307,15 +1245,15 @@ type JssmEventFilterMap<mDT> = {
1307
1245
  /**
1308
1246
  * Per-event filter object (as passed to {@link jssm!Machine.on}). Use
1309
1247
  * `JssmEventDetailMap<mDT>[Ev]` to find the matching detail type.
1310
- * @typeParam mDT The type of the machine data member.
1311
- * @typeParam Ev The event name.
1248
+ * @template mDT The type of the machine data member.
1249
+ * @template Ev The event name.
1312
1250
  */
1313
1251
  type JssmEventFilter<mDT, Ev extends JssmEventName> = JssmEventFilterMap<mDT>[Ev];
1314
1252
  /**
1315
1253
  * Per-event handler signature. Receives a detail object typed by event
1316
1254
  * name, so `e.action` (etc.) only exist where they're meaningful.
1317
- * @typeParam mDT The type of the machine data member.
1318
- * @typeParam Ev The event name.
1255
+ * @template mDT The type of the machine data member.
1256
+ * @template Ev The event name.
1319
1257
  */
1320
1258
  type JssmEventHandler<mDT, Ev extends JssmEventName> = (detail: JssmEventDetailMap<mDT>[Ev]) => void;
1321
1259
  /**
@@ -1332,7 +1270,6 @@ type JssmUnsubscribe = () => void;
1332
1270
  * (integer hashing) instead of repeated string-keyed lookups. Internal
1333
1271
  * machinery only — deliberately not re-exported from the `jssm` public
1334
1272
  * surface, so the public API is unchanged.
1335
- *
1336
1273
  * @internal
1337
1274
  */
1338
1275
  /**
@@ -1341,7 +1278,6 @@ type JssmUnsubscribe = () => void;
1341
1278
  * no removal, matching machine semantics (states and actions are fixed
1342
1279
  * after construction; late interning only happens for never-matching
1343
1280
  * lookups such as hook registrations naming unknown states).
1344
- *
1345
1281
  * @example
1346
1282
  * const i = new Interner();
1347
1283
  * i.intern('red'); // 0
@@ -1349,7 +1285,6 @@ type JssmUnsubscribe = () => void;
1349
1285
  * i.intern('red'); // 0 (idempotent)
1350
1286
  * i.id_of('green'); // 1
1351
1287
  * i.name_of(0); // 'red'
1352
- *
1353
1288
  * @see pair_key
1354
1289
  */
1355
1290
  declare class Interner {
@@ -1359,10 +1294,8 @@ declare class Interner {
1359
1294
  /**
1360
1295
  * Return the id for `name`, assigning the next dense id if the name has
1361
1296
  * not been seen before.
1362
- *
1363
1297
  * @param name - The string to intern.
1364
1298
  * @returns The (possibly newly assigned) integer id.
1365
- *
1366
1299
  * @example
1367
1300
  * interner.intern('red'); // 0 on first call, 0 on every later call
1368
1301
  */
@@ -1371,18 +1304,14 @@ declare class Interner {
1371
1304
  * Return the id for `name` without interning, or `undefined` when the
1372
1305
  * name has never been interned. This is the hot-path probe for
1373
1306
  * user-supplied names.
1374
- *
1375
1307
  * @param name - The string to look up.
1376
- *
1377
1308
  * @example
1378
1309
  * interner.id_of('mauve'); // undefined — never interned
1379
1310
  */
1380
1311
  id_of(name: string): number | undefined;
1381
1312
  /**
1382
1313
  * Return the name for `id`, or `undefined` for an id never assigned.
1383
- *
1384
1314
  * @param id - The integer id to invert.
1385
- *
1386
1315
  * @example
1387
1316
  * interner.name_of(0); // 'red'
1388
1317
  */
@@ -1397,7 +1326,6 @@ type StateType = string;
1397
1326
  * Internal record holding a single registered event subscription: the
1398
1327
  * handler, its optional filter, and a flag for `once` semantics. Not
1399
1328
  * exported.
1400
- *
1401
1329
  * @internal
1402
1330
  */
1403
1331
  type JssmEventEntry<mDT, Ev extends JssmEventName> = {
@@ -1406,15 +1334,8 @@ type JssmEventEntry<mDT, Ev extends JssmEventName> = {
1406
1334
  once: boolean;
1407
1335
  };
1408
1336
  declare class Machine<mDT> {
1337
+ #private;
1409
1338
  _state: StateType;
1410
- _states: Map<StateType, JssmGenericState>;
1411
- _edges: Array<JssmTransition<StateType, mDT>>;
1412
- _edge_map: Map<StateType, Map<StateType, number>>;
1413
- _outbound_edge_ids: Map<StateType, Array<number>>;
1414
- _named_transitions: Map<StateType, number>;
1415
- _actions: Map<StateType, Map<StateType, number>>;
1416
- _reverse_actions: Map<StateType, Map<StateType, number>>;
1417
- _reverse_action_targets: Map<StateType, Map<StateType, number>>;
1418
1339
  _state_interner: Interner;
1419
1340
  _action_interner: Interner;
1420
1341
  _state_id: number;
@@ -1435,7 +1356,7 @@ declare class Machine<mDT> {
1435
1356
  _npm_name?: string;
1436
1357
  _default_size?: JssmDefaultSize;
1437
1358
  _fsl_version?: string;
1438
- _raw_state_declaration?: Array<Object>;
1359
+ _raw_state_declaration?: Array<object>;
1439
1360
  _state_declarations: Map<StateType, JssmStateDeclaration>;
1440
1361
  _data?: mDT;
1441
1362
  _instance_name: string;
@@ -1523,8 +1444,8 @@ declare class Machine<mDT> {
1523
1444
  _create_started: number;
1524
1445
  _created: number;
1525
1446
  _after_mapping: Map<string, [string, number]>;
1526
- _timeout_source: (Function: any, number: any) => number;
1527
- _clear_timeout_source: (h: any) => void;
1447
+ _timeout_source: (f: () => void, a: number) => number;
1448
+ _clear_timeout_source: (h: number) => void;
1528
1449
  _timeout_handle: number | undefined;
1529
1450
  _timeout_target: string | undefined;
1530
1451
  _timeout_target_time: number | undefined;
@@ -1677,9 +1598,7 @@ declare class Machine<mDT> {
1677
1598
  * const m = jssm.from('on <=> off;', { data: { a: { b: 1 } } });
1678
1599
  * m._data_ref().a.b; // 1, zero-copy
1679
1600
  * ```
1680
- *
1681
1601
  * @returns The live data value; treat as read-only.
1682
- *
1683
1602
  * @see Machine.data
1684
1603
  * @internal
1685
1604
  */
@@ -1937,18 +1856,21 @@ declare class Machine<mDT> {
1937
1856
  * current state, data, and timestamp.
1938
1857
  *
1939
1858
  */
1940
- serialize(comment?: string | undefined): JssmSerialization<mDT>;
1941
- /** Get the graph layout direction (e.g. `'LR'`, `'TB'`). Set via the
1859
+ serialize(comment?: string): JssmSerialization<mDT>;
1860
+ /**
1861
+ * Get the graph layout direction (e.g. `'LR'`, `'TB'`). Set via the
1942
1862
  * FSL `graph_layout` directive.
1943
1863
  * @returns The layout string, or the default if not set.
1944
1864
  */
1945
1865
  graph_layout(): string;
1946
- /** Get the Graphviz DOT preamble string, injected before the graph body
1866
+ /**
1867
+ * Get the Graphviz DOT preamble string, injected before the graph body
1947
1868
  * during visualization. Set via the FSL `dot_preamble` directive.
1948
1869
  * @returns The preamble string.
1949
1870
  */
1950
1871
  dot_preamble(): string;
1951
- /** Get the consolidated `transition: {}` default-config block: the ordered,
1872
+ /**
1873
+ * Get the consolidated `transition: {}` default-config block: the ordered,
1952
1874
  * de-duplicated `{ key, value }[]` list of edge-default style items compiled
1953
1875
  * from a `transition: {}` block (e.g. `transition: { color: blue; }`). The
1954
1876
  * viz layer projects this onto a Graphviz `edge [ … ]` default statement so
@@ -1959,13 +1881,13 @@ declare class Machine<mDT> {
1959
1881
  * sm`a -> b; transition: { color: blue; };`.default_transition_config();
1960
1882
  * // [ { key: 'color', value: '#0000ffff' } ]
1961
1883
  * ```
1962
- *
1963
1884
  * @returns The transition-config item list, or `undefined` if the machine
1964
1885
  * declared no `transition: {}` block.
1965
1886
  * @see default_graph_config
1966
1887
  */
1967
1888
  default_transition_config(): JssmTransitionConfig | undefined;
1968
- /** Get the consolidated `graph: {}` default-config block: the ordered,
1889
+ /**
1890
+ * Get the consolidated `graph: {}` default-config block: the ordered,
1969
1891
  * de-duplicated `{ key, value }[]` list of graph-scope style items. The
1970
1892
  * compiler folds the deprecated top-level graph keywords
1971
1893
  * (`graph_bg_color` → `background-color`, plus `graph_layout`, `theme`,
@@ -1979,29 +1901,33 @@ declare class Machine<mDT> {
1979
1901
  * sm`a -> b; graph: { background-color: #ffffff; };`.default_graph_config();
1980
1902
  * // [ { key: 'background-color', value: '#ffffffff' } ]
1981
1903
  * ```
1982
- *
1983
1904
  * @returns The graph-config item list, or `undefined` if the machine has no
1984
1905
  * graph config (no `graph: {}` block and no deprecated graph keyword).
1985
1906
  * @see default_transition_config
1986
1907
  */
1987
1908
  default_graph_config(): JssmGraphConfig | undefined;
1988
- /** Get the machine's author list. Set via the FSL `machine_author` directive.
1909
+ /**
1910
+ * Get the machine's author list. Set via the FSL `machine_author` directive.
1989
1911
  * @returns An array of author name strings.
1990
1912
  */
1991
1913
  machine_author(): Array<string>;
1992
- /** Get the machine's comment string. Set via the FSL `machine_comment` directive.
1914
+ /**
1915
+ * Get the machine's comment string. Set via the FSL `machine_comment` directive.
1993
1916
  * @returns The comment string.
1994
1917
  */
1995
1918
  machine_comment(): string;
1996
- /** Get the machine's contributor list. Set via the FSL `machine_contributor` directive.
1919
+ /**
1920
+ * Get the machine's contributor list. Set via the FSL `machine_contributor` directive.
1997
1921
  * @returns An array of contributor name strings.
1998
1922
  */
1999
1923
  machine_contributor(): Array<string>;
2000
- /** Get the machine's definition string. Set via the FSL `machine_definition` directive.
1924
+ /**
1925
+ * Get the machine's definition string. Set via the FSL `machine_definition` directive.
2001
1926
  * @returns The definition string.
2002
1927
  */
2003
1928
  machine_definition(): string;
2004
- /** Get the machine's natural language as an ISO 639-1 code. Set via the FSL
1929
+ /**
1930
+ * Get the machine's natural language as an ISO 639-1 code. Set via the FSL
2005
1931
  * `machine_language` directive, which accepts a language name or code, or a
2006
1932
  * BCP-47 tag whose region subtag is dropped (`en-us` -> `en`). Unrecognized
2007
1933
  * values resolve to `undefined`.
@@ -2009,32 +1935,35 @@ declare class Machine<mDT> {
2009
1935
  * supplied value did not resolve to a known language.
2010
1936
  */
2011
1937
  machine_language(): string;
2012
- /** Get the machine's license string. Set via the FSL `machine_license` directive.
1938
+ /**
1939
+ * Get the machine's license string. Set via the FSL `machine_license` directive.
2013
1940
  * @returns The license string.
2014
1941
  */
2015
1942
  machine_license(): string;
2016
- /** Get the machine's name. Set via the FSL `machine_name` directive.
1943
+ /**
1944
+ * Get the machine's name. Set via the FSL `machine_name` directive.
2017
1945
  * @returns The machine name string.
2018
1946
  */
2019
1947
  machine_name(): string;
2020
- /** The editor/panel defaults declared in the FSL `editor: {}` block, or
1948
+ /**
1949
+ * The editor/panel defaults declared in the FSL `editor: {}` block, or
2021
1950
  * `undefined` when none was given. Read by the all-widgets web control
2022
1951
  * (fsl#1334) — `panels` drives `request` panel mode.
2023
- *
2024
1952
  * @returns `{ stochastic_run_count?, panels? }`, or `undefined`.
2025
- *
2026
1953
  * @example
2027
1954
  * const m = sm`editor: { panels: [history]; }; a -> b;`;
2028
1955
  * m.editor_config(); // => { panels: ['history'] }
2029
1956
  */
2030
1957
  editor_config(): JssmEditorConfig | undefined;
2031
- /** Get the npm package name associated with the machine. Set via the FSL `npm_name` directive.
1958
+ /**
1959
+ * Get the npm package name associated with the machine. Set via the FSL `npm_name` directive.
2032
1960
  * Returns `undefined` when not present.
2033
1961
  * @returns The npm package name string, or `undefined`.
2034
1962
  * @see machine_name
2035
1963
  */
2036
1964
  npm_name(): string;
2037
- /** Get the render-size hint for the machine's visualization. Set via the
1965
+ /**
1966
+ * Get the render-size hint for the machine's visualization. Set via the
2038
1967
  * FSL `default_size` directive. Returns `undefined` when not present.
2039
1968
  *
2040
1969
  * The three FSL forms each produce a different subset of fields:
@@ -2044,33 +1973,38 @@ declare class Machine<mDT> {
2044
1973
  * - `default_size: height 600;` → `{ height: 600 }`
2045
1974
  *
2046
1975
  * This is a hint, not a hard constraint. Renderers may ignore it.
2047
- *
2048
1976
  * @returns The size-hint object, or `undefined` if not set.
2049
1977
  * @see npm_name
2050
1978
  */
2051
1979
  default_size(): JssmDefaultSize | undefined;
2052
- /** Get the machine's version string. Set via the FSL `machine_version` directive.
1980
+ /**
1981
+ * Get the machine's version string. Set via the FSL `machine_version` directive.
2053
1982
  * @returns The version string.
2054
1983
  */
2055
1984
  machine_version(): string;
2056
- /** Get the raw state declaration objects as parsed from the FSL source.
1985
+ /**
1986
+ * Get the raw state declaration objects as parsed from the FSL source.
2057
1987
  * @returns An array of raw state declaration objects.
2058
1988
  */
2059
- raw_state_declarations(): Array<Object>;
2060
- /** Get the processed state declaration for a specific state.
1989
+ raw_state_declarations(): Array<object>;
1990
+ /**
1991
+ * Get the processed state declaration for a specific state.
2061
1992
  * @param which - The state to look up.
2062
1993
  * @returns The {@link JssmStateDeclaration} for the given state.
2063
1994
  */
2064
1995
  state_declaration(which: StateType): JssmStateDeclaration;
2065
- /** Get all processed state declarations as a Map.
1996
+ /**
1997
+ * Get all processed state declarations as a Map.
2066
1998
  * @returns A `Map` from state name to {@link JssmStateDeclaration}.
2067
1999
  */
2068
2000
  state_declarations(): Map<StateType, JssmStateDeclaration>;
2069
- /** Get the FSL language version this machine was compiled under.
2001
+ /**
2002
+ * Get the FSL language version this machine was compiled under.
2070
2003
  * @returns The FSL version string.
2071
2004
  */
2072
2005
  fsl_version(): string;
2073
- /** Get the complete internal state of the machine as a serializable
2006
+ /**
2007
+ * Get the complete internal state of the machine as a serializable
2074
2008
  * structure. Includes actions, edges, edge map, named transitions,
2075
2009
  * reverse actions, current state, and states map.
2076
2010
  * @returns A {@link JssmMachineInternalState} snapshot.
@@ -2094,7 +2028,8 @@ declare class Machine<mDT> {
2094
2028
  *
2095
2029
  */
2096
2030
  states(): Array<StateType>;
2097
- /** Get the internal state descriptor for a given state name.
2031
+ /**
2032
+ * Get the internal state descriptor for a given state name.
2098
2033
  * @param whichState - The state to look up.
2099
2034
  * @returns The {@link JssmGenericState} descriptor.
2100
2035
  * @throws {JssmError} If the state does not exist.
@@ -2157,19 +2092,23 @@ declare class Machine<mDT> {
2157
2092
  *
2158
2093
  */
2159
2094
  list_edges(): Array<JssmTransition<StateType, mDT>>;
2160
- /** Get the map of named transitions (transitions with explicit names).
2095
+ /**
2096
+ * Get the map of named transitions (transitions with explicit names).
2161
2097
  * @returns A `Map` from transition name to edge index.
2162
2098
  */
2163
2099
  list_named_transitions(): Map<StateType, number>;
2164
- /** List all distinct action names defined anywhere in the machine.
2100
+ /**
2101
+ * List all distinct action names defined anywhere in the machine.
2165
2102
  * @returns An array of action name strings.
2166
2103
  */
2167
2104
  list_actions(): Array<StateType>;
2168
- /** Whether any actions are defined on this machine.
2105
+ /**
2106
+ * Whether any actions are defined on this machine.
2169
2107
  * @returns `true` if the machine has at least one action.
2170
2108
  */
2171
2109
  get uses_actions(): boolean;
2172
- /** Whether any forced (`~>`) transitions exist in this machine.
2110
+ /**
2111
+ * Whether any forced (`~>`) transitions exist in this machine.
2173
2112
  * @returns `true` if at least one forced transition is defined.
2174
2113
  */
2175
2114
  get uses_forced_transitions(): boolean;
@@ -2210,16 +2149,16 @@ declare class Machine<mDT> {
2210
2149
  *
2211
2150
  */
2212
2151
  get allow_islands(): JssmAllowIslands;
2213
- /** List all available theme names.
2152
+ /**
2153
+ * List all available theme names.
2214
2154
  * @returns An array of theme name strings.
2215
2155
  */
2216
2156
  all_themes(): FslTheme[];
2217
- /** List the character ranges accepted by the FSL grammar in any but the
2157
+ /**
2158
+ * List the character ranges accepted by the FSL grammar in any but the
2218
2159
  * first position of a state name (atom). Each entry is an inclusive
2219
2160
  * `{from, to}` range of single Unicode characters.
2220
- *
2221
2161
  * @returns An array of `{from, to}` inclusive character ranges.
2222
- *
2223
2162
  * @example
2224
2163
  * import { sm } from 'jssm';
2225
2164
  * const m = sm`a -> b;`;
@@ -2229,12 +2168,11 @@ declare class Machine<mDT> {
2229
2168
  from: string;
2230
2169
  to: string;
2231
2170
  }>;
2232
- /** List the character ranges accepted by the FSL grammar in the first
2171
+ /**
2172
+ * List the character ranges accepted by the FSL grammar in the first
2233
2173
  * position of a state name (atom). Narrower than
2234
2174
  * {@link all_state_name_chars}: notably omits `+`, `(`, `)`, `&`, `#`, `@`.
2235
- *
2236
2175
  * @returns An array of `{from, to}` inclusive character ranges.
2237
- *
2238
2176
  * @example
2239
2177
  * import { sm } from 'jssm';
2240
2178
  * const m = sm`a -> b;`;
@@ -2244,12 +2182,11 @@ declare class Machine<mDT> {
2244
2182
  from: string;
2245
2183
  to: string;
2246
2184
  }>;
2247
- /** List the character ranges accepted inside a single-quoted FSL action
2185
+ /**
2186
+ * List the character ranges accepted inside a single-quoted FSL action
2248
2187
  * label without escaping. Space is allowed; the apostrophe `'` is
2249
2188
  * explicitly excluded since it terminates the label.
2250
- *
2251
2189
  * @returns An array of `{from, to}` inclusive character ranges.
2252
- *
2253
2190
  * @example
2254
2191
  * import { sm } from 'jssm';
2255
2192
  * const m = sm`a -> b;`;
@@ -2260,28 +2197,33 @@ declare class Machine<mDT> {
2260
2197
  from: string;
2261
2198
  to: string;
2262
2199
  }>;
2263
- /** Get the active theme(s) for this machine. Always stored as an array
2200
+ /**
2201
+ * Get the active theme(s) for this machine. Always stored as an array
2264
2202
  * internally; the union return type exists for setter compatibility.
2265
2203
  * @returns The current theme or array of themes.
2266
2204
  */
2267
2205
  get themes(): FslTheme | FslTheme[];
2268
- /** Set the active theme(s). Accepts a single theme name or an array.
2206
+ /**
2207
+ * Set the active theme(s). Accepts a single theme name or an array.
2269
2208
  * @param to - A theme name or array of theme names to apply.
2270
2209
  */
2271
2210
  set themes(to: FslTheme | FslTheme[]);
2272
- /** Get the flow direction for graph layout (e.g. `'right'`, `'down'`).
2211
+ /**
2212
+ * Get the flow direction for graph layout (e.g. `'right'`, `'down'`).
2273
2213
  * Set via the FSL `flow` directive.
2274
2214
  * @returns The current flow direction.
2275
2215
  */
2276
2216
  flow(): FslDirection;
2277
- /** Look up a transition's edge index by source and target state names.
2217
+ /**
2218
+ * Look up a transition's edge index by source and target state names.
2278
2219
  * @param from - Source state name.
2279
2220
  * @param to - Target state name.
2280
2221
  * @returns The edge index in the edges array, or `undefined` if no
2281
2222
  * such transition exists.
2282
2223
  */
2283
2224
  get_transition_by_state_names(from: StateType, to: StateType): number;
2284
- /** Look up the full transition object for a given source→target pair.
2225
+ /**
2226
+ * Look up the full transition object for a given source→target pair.
2285
2227
  * @param from - Source state name.
2286
2228
  * @param to - Target state name.
2287
2229
  * @returns The {@link JssmTransition} object, or `undefined` if none exists.
@@ -2353,7 +2295,8 @@ declare class Machine<mDT> {
2353
2295
  *
2354
2296
  */
2355
2297
  list_exits(whichState?: StateType): Array<StateType>;
2356
- /** Get the transitions available from a state for use by the probabilistic
2298
+ /**
2299
+ * Get the transitions available from a state for use by the probabilistic
2357
2300
  * walk system.
2358
2301
  *
2359
2302
  * If any exit declares a `probability`, only those probability-bearing
@@ -2366,37 +2309,39 @@ declare class Machine<mDT> {
2366
2309
  * Fixes StoneCypher/fsl#1325, in which the function previously returned
2367
2310
  * every exit unconditionally — including forced-only exits and exits
2368
2311
  * with no `probability`, which distorted the weighted distribution.
2369
- *
2370
2312
  * @param whichState - The state to inspect.
2371
2313
  * @returns An array of {@link JssmTransition} edges exiting the state,
2372
2314
  * filtered as described above. May be empty.
2373
2315
  * @throws {JssmError} If the state does not exist.
2374
2316
  */
2375
2317
  probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
2376
- /** Take a single random transition from the current state, weighted by
2318
+ /**
2319
+ * Take a single random transition from the current state, weighted by
2377
2320
  * edge probabilities.
2378
2321
  * @returns `true` if a transition was taken, `false` otherwise.
2379
2322
  */
2380
2323
  probabilistic_transition(): boolean;
2381
- /** Take `n` consecutive probabilistic transitions and return the sequence
2324
+ /**
2325
+ * Take `n` consecutive probabilistic transitions and return the sequence
2382
2326
  * of states visited (before each transition).
2383
2327
  * @param n - Number of steps to walk.
2384
2328
  * @returns An array of state names visited during the walk.
2385
2329
  */
2386
2330
  probabilistic_walk(n: number): Array<StateType>;
2387
- /** Take `n` probabilistic steps and return a histograph of how many times
2331
+ /**
2332
+ * Take `n` probabilistic steps and return a histograph of how many times
2388
2333
  * each state was visited.
2389
2334
  * @param n - Number of steps to walk.
2390
2335
  * @returns A `Map` from state name to visit count.
2391
2336
  */
2392
2337
  probabilistic_histo_walk(n: number): Map<StateType, number>;
2393
- /** One non-destructive weighted-random walk over the graph from `start`.
2338
+ /**
2339
+ * One non-destructive weighted-random walk over the graph from `start`.
2394
2340
  *
2395
2341
  * Reads the graph and advances the PRNG only — it never calls
2396
2342
  * {@link Machine.transition}, so it fires no hooks, mutates no machine
2397
2343
  * state, and touches no `data`. A state with no probabilistic exits
2398
2344
  * (a terminal, or a forced-only `~>` state) ends the walk.
2399
- *
2400
2345
  * @param start - State to begin the walk from.
2401
2346
  * @param max_steps - Maximum transitions before the walk is step-capped.
2402
2347
  * @param exit_memo - Per-run-set cache of {@link Machine.probable_exits_for}
@@ -2409,7 +2354,8 @@ declare class Machine<mDT> {
2409
2354
  * @returns The {@link JssmStochasticRun} for this walk.
2410
2355
  */
2411
2356
  private _stochastic_one_walk;
2412
- /** Lazily yield one {@link JssmStochasticRun} at a time.
2357
+ /**
2358
+ * Lazily yield one {@link JssmStochasticRun} at a time.
2413
2359
  *
2414
2360
  * In `montecarlo` mode (default) yields `runs` independent walks from the
2415
2361
  * current state, each ending at a terminal or after `max_steps`. In
@@ -2420,16 +2366,16 @@ declare class Machine<mDT> {
2420
2366
  * Passing `seed` reseeds the machine for reproducible runs. Unlike
2421
2367
  * {@link Machine.stochastic_summary}, the generator does NOT restore the
2422
2368
  * prior seed afterward — a direct caller's machine is left reseeded.
2423
- *
2424
2369
  * @param opts - {@link JssmStochasticOptions}.
2370
+ * @yields One {@link JssmStochasticRun} per completed walk.
2425
2371
  * @returns A generator of per-run results.
2426
- *
2427
2372
  * @example
2428
2373
  * const m = sm`a 'go' -> b 'go' -> c;`;
2429
2374
  * [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
2430
2375
  */
2431
2376
  stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
2432
- /** Run many weighted-random walks and return aggregate statistics.
2377
+ /**
2378
+ * Run many weighted-random walks and return aggregate statistics.
2433
2379
  *
2434
2380
  * Honors `%` transition probabilities (via the existing probabilistic
2435
2381
  * machinery). Non-destructive: the machine's current state and
@@ -2440,16 +2386,13 @@ declare class Machine<mDT> {
2440
2386
  *
2441
2387
  * Timing (`after`) decorations and data-guard conditions are not modeled
2442
2388
  * by this sampler; it walks the probabilistic graph topology.
2443
- *
2444
2389
  * @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
2445
2390
  * machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
2446
2391
  * present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
2447
2392
  * @returns A {@link JssmStochasticSummary}.
2448
- *
2449
2393
  * @see Machine.stochastic_runs
2450
2394
  * @see Machine.probabilistic_walk
2451
2395
  * @see Machine.editor_config
2452
- *
2453
2396
  * @example
2454
2397
  * const m = sm`a 'go' -> b 'go' -> c;`;
2455
2398
  * const s = m.stochastic_summary({ runs: 100, seed: 1 });
@@ -2517,17 +2460,16 @@ declare class Machine<mDT> {
2517
2460
  *
2518
2461
  */
2519
2462
  list_states_having_action(whichState: StateType): Array<StateType>;
2520
- /** List all action names available as exits from a given state.
2463
+ /**
2464
+ * List all action names available as exits from a given state.
2521
2465
  *
2522
2466
  * Returns the empty array (does not throw) when `whichState` exists but has
2523
2467
  * no action-named exits — including terminal states, states whose only
2524
2468
  * exits are plain `->` transitions, and states in machines that use no
2525
2469
  * actions at all. Only nonexistent states cause a throw.
2526
- *
2527
2470
  * @param whichState - The state to inspect. Defaults to the current state.
2528
2471
  * @returns An array of action name strings, possibly empty.
2529
2472
  * @throws {JssmError} If the state does not exist.
2530
- *
2531
2473
  * @example
2532
2474
  * const m = sm`a 'go' -> b; b -> c;`;
2533
2475
  * m.list_exit_actions('a'); // => ['go']
@@ -2536,33 +2478,39 @@ declare class Machine<mDT> {
2536
2478
  * expect(() => m.list_exit_actions('z')).toThrow();
2537
2479
  */
2538
2480
  list_exit_actions(whichState?: StateType): Array<StateType>;
2539
- /** List all action exits from a state with their probabilities.
2481
+ /**
2482
+ * List all action exits from a state with their probabilities.
2540
2483
  * @param whichState - The state to inspect. Defaults to the current state.
2541
2484
  * @returns An array of `{ action, probability }` objects.
2542
2485
  * @throws {JssmError} If the state does not exist.
2543
2486
  */
2544
2487
  probable_action_exits(whichState?: StateType): Array<any>;
2545
- /** Check whether a state has no incoming transitions (unreachable after start).
2488
+ /**
2489
+ * Check whether a state has no incoming transitions (unreachable after start).
2546
2490
  * @param whichState - The state to check.
2547
2491
  * @returns `true` if the state has zero entrances.
2548
2492
  * @throws {JssmError} If the state does not exist.
2549
2493
  */
2550
2494
  is_unenterable(whichState: StateType): boolean;
2551
- /** Check whether any state in the machine is unenterable.
2495
+ /**
2496
+ * Check whether any state in the machine is unenterable.
2552
2497
  * @returns `true` if at least one state has no incoming transitions.
2553
2498
  */
2554
2499
  has_unenterables(): boolean;
2555
- /** Check whether the current state is terminal (has no exits).
2500
+ /**
2501
+ * Check whether the current state is terminal (has no exits).
2556
2502
  * @returns `true` if the current state has zero exits.
2557
2503
  */
2558
2504
  is_terminal(): boolean;
2559
- /** Check whether a specific state is terminal (has no exits).
2505
+ /**
2506
+ * Check whether a specific state is terminal (has no exits).
2560
2507
  * @param whichState - The state to check.
2561
2508
  * @returns `true` if the state has zero exits.
2562
2509
  * @throws {JssmError} If the state does not exist.
2563
2510
  */
2564
2511
  state_is_terminal(whichState: StateType): boolean;
2565
- /** Check whether any state in the machine is terminal.
2512
+ /**
2513
+ * Check whether any state in the machine is terminal.
2566
2514
  * @returns `true` if at least one state has no exits.
2567
2515
  */
2568
2516
  has_terminals(): boolean;
@@ -2674,17 +2622,20 @@ declare class Machine<mDT> {
2674
2622
  *
2675
2623
  */
2676
2624
  statesIn(groupName: string): Array<StateType>;
2677
- /** Check whether the current state is complete (every exit has an action).
2625
+ /**
2626
+ * Check whether the current state is complete (every exit has an action).
2678
2627
  * @returns `true` if the current state is complete.
2679
2628
  */
2680
2629
  is_complete(): boolean;
2681
- /** Check whether a specific state is complete (every exit has an action).
2630
+ /**
2631
+ * Check whether a specific state is complete (every exit has an action).
2682
2632
  * @param whichState - The state to check.
2683
2633
  * @returns `true` if the state is complete.
2684
2634
  * @throws {JssmError} If the state does not exist.
2685
2635
  */
2686
2636
  state_is_complete(whichState: StateType): boolean;
2687
- /** Check whether any state in the machine is complete.
2637
+ /**
2638
+ * Check whether any state in the machine is complete.
2688
2639
  * @returns `true` if at least one state is complete.
2689
2640
  */
2690
2641
  has_completes(): boolean;
@@ -2708,14 +2659,12 @@ declare class Machine<mDT> {
2708
2659
  * const off = m.on('transition', () => {});
2709
2660
  * off(); // unsubscribe
2710
2661
  * ```
2711
- *
2712
- * @typeParam Ev The event name (drives the detail type).
2662
+ * @template Ev The event name (drives the detail type).
2713
2663
  * @param name The event name to subscribe to.
2714
2664
  * @param handler The handler invoked on each matching delivery. The
2715
2665
  * three-argument `(name, filter, handler)` form inserts a
2716
2666
  * filter object before the handler (see the example above).
2717
2667
  * @returns A function that unsubscribes when called.
2718
- *
2719
2668
  * @see Machine.off
2720
2669
  * @see Machine.once
2721
2670
  */
@@ -2729,15 +2678,13 @@ declare class Machine<mDT> {
2729
2678
  * ```typescript
2730
2679
  * m.once('terminal', e => console.log(`done at ${e.state}`));
2731
2680
  * ```
2732
- *
2733
- * @typeParam Ev The event name.
2681
+ * @template Ev The event name.
2734
2682
  * @param name The event name.
2735
2683
  * @param handler The handler invoked on the first matching delivery. The
2736
2684
  * three-argument `(name, filter, handler)` form inserts a
2737
2685
  * filter object before the handler (same shapes as `on`).
2738
2686
  * @returns A function that unsubscribes early if called before the
2739
2687
  * handler has fired.
2740
- *
2741
2688
  * @see Machine.on
2742
2689
  * @see Machine.off
2743
2690
  */
@@ -2755,112 +2702,11 @@ declare class Machine<mDT> {
2755
2702
  * m.off('transition', fn); // true
2756
2703
  * m.off('transition', fn); // false
2757
2704
  * ```
2758
- *
2759
2705
  * @param name The event name.
2760
2706
  * @param handler The handler reference to remove.
2761
2707
  * @returns `true` if removed, `false` if no match was registered.
2762
2708
  */
2763
2709
  off<Ev extends JssmEventName>(name: Ev, handler: JssmEventHandler<mDT, Ev>): boolean;
2764
- /**
2765
- * Remove one event-subscription entry from its set and keep
2766
- * {@link Machine._event_listener_count} in sync. The count is decremented
2767
- * only when the entry was actually present, so calling a stale unsubscribe
2768
- * closure (or removing an already-fired `once` entry) is idempotent and
2769
- * cannot drive the count negative.
2770
- *
2771
- * @param set The per-event-name subscription set.
2772
- * @param entry The entry to remove.
2773
- * @internal
2774
- */
2775
- _unsubscribe_entry(set: Set<JssmEventEntry<any, any>>, entry: JssmEventEntry<any, any>): void;
2776
- /**
2777
- * Shared registration core used by {@link Machine.on} and
2778
- * {@link Machine.once}. Normalizes the optional filter argument and
2779
- * installs the entry into the per-event subscription set.
2780
- *
2781
- * @internal
2782
- */
2783
- _subscribe<Ev extends JssmEventName>(name: Ev, filterOrFn: JssmEventFilter<mDT, Ev> | JssmEventHandler<mDT, Ev>, maybeFn: JssmEventHandler<mDT, Ev> | undefined, once: boolean): JssmUnsubscribe;
2784
- /**
2785
- * Invoke a single event-handler entry, respecting its filter, once-removal
2786
- * semantics, and the error re-fire / recursion-guard logic. Extracted so
2787
- * {@link _fire} can share identical behavior between the size-1 fast-path
2788
- * and the general snapshotted loop.
2789
- *
2790
- * @param entry - The subscriber descriptor to invoke.
2791
- * @param set - The live Set that owns `entry`; needed for once-removal.
2792
- * @param name - The event name being dispatched (used in error re-fires).
2793
- * @param detail - The event payload forwarded to the handler.
2794
- *
2795
- * @internal
2796
- */
2797
- _fire_one<Ev extends JssmEventName>(entry: JssmEventEntry<mDT, Ev>, set: Set<JssmEventEntry<any, any>>, name: Ev, detail: JssmEventDetailMap<mDT>[Ev]): void;
2798
- /**
2799
- * Dispatch an event to every registered subscriber in registration
2800
- * order. Filters are checked first; non-matching handlers are skipped
2801
- * without invoking the handler. Exceptions thrown by a handler are
2802
- * caught and re-emitted as an `error` event so subsequent handlers
2803
- * still run.
2804
- *
2805
- * Re-entry into the `error` event itself is guarded — if an `error`
2806
- * handler throws, the new exception is swallowed rather than rebroadcast
2807
- * to avoid an infinite loop.
2808
- *
2809
- * When exactly one subscriber is registered the common case avoids the
2810
- * `Array.from(set)` snapshot allocation by capturing the lone entry into a
2811
- * local first — equivalent to a 1-element snapshot but allocation-free.
2812
- * The general path still snapshots for re-entrancy safety.
2813
- *
2814
- * @internal
2815
- */
2816
- /**
2817
- * Whether at least one live subscriber is registered for `name`. Used by
2818
- * the transition-commit observation block to skip building a detail
2819
- * literal that {@link Machine._fire} would immediately discard — a panel
2820
- * listening only to `'transition'` (fsl-bind, fsl-viz, fsl-info-panel)
2821
- * previously paid for the exit/entry/data-change detail allocations on
2822
- * every transition. Read at fire time, so a listener installed by a
2823
- * pre-hook is still seen (#671).
2824
- *
2825
- * @param name The event name to probe.
2826
- * @returns `true` when a subsequent `_fire(name, ...)` would reach at
2827
- * least one handler.
2828
- *
2829
- * ```typescript
2830
- * machine.on('transition', () => {});
2831
- * machine._has_subscribers('transition'); // true
2832
- * machine._has_subscribers('exit'); // false
2833
- * ```
2834
- *
2835
- * @see Machine._fire
2836
- * @internal
2837
- */
2838
- _has_subscribers(name: JssmEventName): boolean;
2839
- _fire<Ev extends JssmEventName>(name: Ev, detail: JssmEventDetailMap<mDT>[Ev]): void;
2840
- /** Low-level hook registration. Installs a handler described by a
2841
- * {@link HookDescription} into the appropriate internal map. Prefer the
2842
- * convenience wrappers ({@link hook}, {@link hook_entry}, etc.) over
2843
- * calling this directly.
2844
- * @param HookDesc - A hook descriptor specifying kind, states, and handler.
2845
- */
2846
- /**
2847
- * Validate a {@link HookDescription} before registration. Every hook needs
2848
- * a `handler` function, and each kind's identifying spatial fields
2849
- * (`from`/`to`/`action`) must be exactly those `set_hook` reads for that
2850
- * kind — present when required, absent otherwise. This turns a mis-shaped
2851
- * descriptor into a thrown error instead of a silently dead hook keyed on
2852
- * `undefined` (e.g. an `exit` hook handed `to` instead of `from`, #734).
2853
- *
2854
- * @param HookDesc - The descriptor about to be registered.
2855
- * @throws JssmError if the kind is unknown, the handler is not a function, a
2856
- * required field is missing, or an inapplicable field is present.
2857
- *
2858
- * @example
2859
- * const m = sm`a -> b;`;
2860
- * // an exit hook is keyed by `from`, so supplying `to` is rejected:
2861
- * expect(() => m.set_hook({ kind: 'exit', to: 'a', handler: () => true })).toThrow();
2862
- */
2863
- _validate_hook_description(HookDesc: HookDescription<mDT>): void;
2864
2710
  set_hook(HookDesc: HookDescription<mDT>): void;
2865
2711
  /**
2866
2712
  * Remove a previously-registered hook described by a
@@ -2879,12 +2725,12 @@ declare class Machine<mDT> {
2879
2725
  * m.set_hook({ kind: 'hook', from: 'a', to: 'b', handler: fn });
2880
2726
  * m.remove_hook({ kind: 'hook', from: 'a', to: 'b', handler: fn });
2881
2727
  * ```
2882
- *
2883
2728
  * @param HookDesc - A hook descriptor identifying the hook to remove.
2884
2729
  * @returns `true` if a hook was removed, `false` otherwise.
2885
2730
  */
2886
2731
  remove_hook(HookDesc: HookDescription<mDT>): boolean;
2887
- /** Register a pre-transition hook on a specific edge. Fires before
2732
+ /**
2733
+ * Register a pre-transition hook on a specific edge. Fires before
2888
2734
  * transitioning from `from` to `to`. If the handler returns `false`, the
2889
2735
  * transition is blocked.
2890
2736
  *
@@ -2892,14 +2738,14 @@ declare class Machine<mDT> {
2892
2738
  * const m = sm`a -> b -> c;`;
2893
2739
  * m.hook('a', 'b', () => console.log('a->b'));
2894
2740
  * ```
2895
- *
2896
2741
  * @param from - Source state name.
2897
2742
  * @param to - Target state name.
2898
2743
  * @param handler - Callback invoked before the transition.
2899
2744
  * @returns `this` for chaining.
2900
2745
  */
2901
2746
  hook(from: string, to: string, handler: HookHandler<mDT>): Machine<mDT>;
2902
- /** Register a pre-transition hook on a specific action-labeled edge.
2747
+ /**
2748
+ * Register a pre-transition hook on a specific action-labeled edge.
2903
2749
  * @param from - Source state name.
2904
2750
  * @param to - Target state name.
2905
2751
  * @param action - The action label that triggers this hook.
@@ -2907,50 +2753,59 @@ declare class Machine<mDT> {
2907
2753
  * @returns `this` for chaining.
2908
2754
  */
2909
2755
  hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>;
2910
- /** Register a pre-transition hook on any edge triggered by a specific action.
2756
+ /**
2757
+ * Register a pre-transition hook on any edge triggered by a specific action.
2911
2758
  * @param action - The action name to hook.
2912
2759
  * @param handler - Callback invoked before any transition with this action.
2913
2760
  * @returns `this` for chaining.
2914
2761
  */
2915
2762
  hook_global_action(action: string, handler: HookHandler<mDT>): Machine<mDT>;
2916
- /** Register a pre-transition hook on any action-driven transition.
2763
+ /**
2764
+ * Register a pre-transition hook on any action-driven transition.
2917
2765
  * @param handler - Callback invoked before any action transition.
2918
2766
  * @returns `this` for chaining.
2919
2767
  */
2920
2768
  hook_any_action(handler: HookHandler<mDT>): Machine<mDT>;
2921
- /** Register a pre-transition hook on any standard (`->`) transition.
2769
+ /**
2770
+ * Register a pre-transition hook on any standard (`->`) transition.
2922
2771
  * @param handler - Callback invoked before any legal transition.
2923
2772
  * @returns `this` for chaining.
2924
2773
  */
2925
2774
  hook_standard_transition(handler: HookHandler<mDT>): Machine<mDT>;
2926
- /** Register a pre-transition hook on any main-path (`=>`) transition.
2775
+ /**
2776
+ * Register a pre-transition hook on any main-path (`=>`) transition.
2927
2777
  * @param handler - Callback invoked before any main transition.
2928
2778
  * @returns `this` for chaining.
2929
2779
  */
2930
2780
  hook_main_transition(handler: HookHandler<mDT>): Machine<mDT>;
2931
- /** Register a pre-transition hook on any forced (`~>`) transition.
2781
+ /**
2782
+ * Register a pre-transition hook on any forced (`~>`) transition.
2932
2783
  * @param handler - Callback invoked before any forced transition.
2933
2784
  * @returns `this` for chaining.
2934
2785
  */
2935
2786
  hook_forced_transition(handler: HookHandler<mDT>): Machine<mDT>;
2936
- /** Register a pre-transition hook on any transition regardless of kind.
2787
+ /**
2788
+ * Register a pre-transition hook on any transition regardless of kind.
2937
2789
  * @param handler - Callback invoked before every transition.
2938
2790
  * @returns `this` for chaining.
2939
2791
  */
2940
2792
  hook_any_transition(handler: HookHandler<mDT>): Machine<mDT>;
2941
- /** Register a hook that fires when entering a specific state.
2793
+ /**
2794
+ * Register a hook that fires when entering a specific state.
2942
2795
  * @param to - The state being entered.
2943
2796
  * @param handler - Callback invoked on entry.
2944
2797
  * @returns `this` for chaining.
2945
2798
  */
2946
2799
  hook_entry(to: string, handler: HookHandler<mDT>): Machine<mDT>;
2947
- /** Register a hook that fires when leaving a specific state.
2800
+ /**
2801
+ * Register a hook that fires when leaving a specific state.
2948
2802
  * @param from - The state being exited.
2949
2803
  * @param handler - Callback invoked on exit.
2950
2804
  * @returns `this` for chaining.
2951
2805
  */
2952
2806
  hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
2953
- /** Register a hook that fires when a state's `after` timer elapses — the
2807
+ /**
2808
+ * Register a hook that fires when a state's `after` timer elapses — the
2954
2809
  * delay-over companion to `a after 5s -> b;` style time transitions. It
2955
2810
  * does NOT fire when the state is entered or left by ordinary dispatch;
2956
2811
  * use {@link hook_entry} / {@link hook_exit} for those. (Versions through
@@ -2961,7 +2816,6 @@ declare class Machine<mDT> {
2961
2816
  * timed transition is taken; informational — its outcome
2962
2817
  * cannot reject the transition.
2963
2818
  * @returns `this` for chaining.
2964
- *
2965
2819
  * @example
2966
2820
  * const m = sm`a after 1000 -> b; a -> c; c -> a;`;
2967
2821
  * let calls = 0;
@@ -2971,13 +2825,13 @@ declare class Machine<mDT> {
2971
2825
  * // ordinary dispatch never fires it; only the timer elapsing does:
2972
2826
  * calls; // => 0
2973
2827
  * m.clear_state_timeout();
2974
- *
2975
2828
  * @see hook_entry
2976
2829
  * @see hook_exit
2977
2830
  * @see set_state_timeout
2978
2831
  */
2979
2832
  hook_after(from: string, handler: HookHandler<mDT>): Machine<mDT>;
2980
- /** Register a hook that fires when ANY state's `after` timer elapses — the
2833
+ /**
2834
+ * Register a hook that fires when ANY state's `after` timer elapses — the
2981
2835
  * whole-machine companion to {@link hook_after}, mirroring how
2982
2836
  * {@link hook_any_transition} companions {@link hook}. When the elapsing
2983
2837
  * state also has a specific {@link hook_after}, the specific hook fires
@@ -2988,7 +2842,6 @@ declare class Machine<mDT> {
2988
2842
  * @param handler - Callback invoked whenever any `after` timer fires, just
2989
2843
  * before the timed transition is taken.
2990
2844
  * @returns `this` for chaining.
2991
- *
2992
2845
  * @example
2993
2846
  * const m = sm`a after 1000 -> b; a -> c; c -> a;`;
2994
2847
  * let calls = 0;
@@ -2998,13 +2851,13 @@ declare class Machine<mDT> {
2998
2851
  * // ordinary dispatch never fires it; only a timer elapsing does:
2999
2852
  * calls; // => 0
3000
2853
  * m.clear_state_timeout();
3001
- *
3002
2854
  * @see hook_after
3003
2855
  * @see hook_any_transition
3004
2856
  * @see set_state_timeout
3005
2857
  */
3006
2858
  hook_after_any(handler: HookHandler<mDT>): Machine<mDT>;
3007
- /** Post-transition hook on a specific edge. Fires after the transition
2859
+ /**
2860
+ * Post-transition hook on a specific edge. Fires after the transition
3008
2861
  * from `from` to `to` has completed. Cannot block the transition.
3009
2862
  * @param from - Source state name.
3010
2863
  * @param to - Target state name.
@@ -3012,7 +2865,8 @@ declare class Machine<mDT> {
3012
2865
  * @returns `this` for chaining.
3013
2866
  */
3014
2867
  post_hook(from: string, to: string, handler: HookHandler<mDT>): Machine<mDT>;
3015
- /** Post-transition hook on a specific action-labeled edge.
2868
+ /**
2869
+ * Post-transition hook on a specific action-labeled edge.
3016
2870
  * @param from - Source state name.
3017
2871
  * @param to - Target state name.
3018
2872
  * @param action - The action label.
@@ -3020,50 +2874,59 @@ declare class Machine<mDT> {
3020
2874
  * @returns `this` for chaining.
3021
2875
  */
3022
2876
  post_hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>;
3023
- /** Post-transition hook on any edge triggered by a specific action.
2877
+ /**
2878
+ * Post-transition hook on any edge triggered by a specific action.
3024
2879
  * @param action - The action name.
3025
2880
  * @param handler - Callback invoked after any transition with this action.
3026
2881
  * @returns `this` for chaining.
3027
2882
  */
3028
2883
  post_hook_global_action(action: string, handler: HookHandler<mDT>): Machine<mDT>;
3029
- /** Post-transition hook on any action-driven transition.
2884
+ /**
2885
+ * Post-transition hook on any action-driven transition.
3030
2886
  * @param handler - Callback invoked after any action transition.
3031
2887
  * @returns `this` for chaining.
3032
2888
  */
3033
2889
  post_hook_any_action(handler: HookHandler<mDT>): Machine<mDT>;
3034
- /** Post-transition hook on any standard (`->`) transition.
2890
+ /**
2891
+ * Post-transition hook on any standard (`->`) transition.
3035
2892
  * @param handler - Callback invoked after any legal transition.
3036
2893
  * @returns `this` for chaining.
3037
2894
  */
3038
2895
  post_hook_standard_transition(handler: HookHandler<mDT>): Machine<mDT>;
3039
- /** Post-transition hook on any main-path (`=>`) transition.
2896
+ /**
2897
+ * Post-transition hook on any main-path (`=>`) transition.
3040
2898
  * @param handler - Callback invoked after any main transition.
3041
2899
  * @returns `this` for chaining.
3042
2900
  */
3043
2901
  post_hook_main_transition(handler: HookHandler<mDT>): Machine<mDT>;
3044
- /** Post-transition hook on any forced (`~>`) transition.
2902
+ /**
2903
+ * Post-transition hook on any forced (`~>`) transition.
3045
2904
  * @param handler - Callback invoked after any forced transition.
3046
2905
  * @returns `this` for chaining.
3047
2906
  */
3048
2907
  post_hook_forced_transition(handler: HookHandler<mDT>): Machine<mDT>;
3049
- /** Post-transition hook on any transition regardless of kind.
2908
+ /**
2909
+ * Post-transition hook on any transition regardless of kind.
3050
2910
  * @param handler - Callback invoked after every transition.
3051
2911
  * @returns `this` for chaining.
3052
2912
  */
3053
2913
  post_hook_any_transition(handler: HookHandler<mDT>): Machine<mDT>;
3054
- /** Post-transition hook that fires after entering a specific state.
2914
+ /**
2915
+ * Post-transition hook that fires after entering a specific state.
3055
2916
  * @param to - The state that was entered.
3056
2917
  * @param handler - Callback invoked after entry.
3057
2918
  * @returns `this` for chaining.
3058
2919
  */
3059
2920
  post_hook_entry(to: string, handler: HookHandler<mDT>): Machine<mDT>;
3060
- /** Post-transition hook that fires after leaving a specific state.
2921
+ /**
2922
+ * Post-transition hook that fires after leaving a specific state.
3061
2923
  * @param from - The state that was exited.
3062
2924
  * @param handler - Callback invoked after exit.
3063
2925
  * @returns `this` for chaining.
3064
2926
  */
3065
2927
  post_hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
3066
- /** Register a pre-transition hook that fires **before** all other pre-hooks
2928
+ /**
2929
+ * Register a pre-transition hook that fires **before** all other pre-hooks
3067
2930
  * on every transition. If the handler returns `false`, the transition is
3068
2931
  * blocked. The handler receives an {@link EverythingHookContext} whose
3069
2932
  * `hook_name` is `'pre everything'`.
@@ -3075,12 +2938,12 @@ declare class Machine<mDT> {
3075
2938
  * return true;
3076
2939
  * });
3077
2940
  * ```
3078
- *
3079
2941
  * @param handler - Callback invoked before all other pre-hooks.
3080
2942
  * @returns `this` for chaining.
3081
2943
  */
3082
2944
  hook_pre_everything(handler: EverythingHookHandler<mDT>): Machine<mDT>;
3083
- /** Register a pre-transition hook that fires **after** all other pre-hooks
2945
+ /**
2946
+ * Register a pre-transition hook that fires **after** all other pre-hooks
3084
2947
  * on every transition. If the handler returns `false`, the transition is
3085
2948
  * blocked. The handler receives an {@link EverythingHookContext} whose
3086
2949
  * `hook_name` is `'everything'`.
@@ -3092,12 +2955,12 @@ declare class Machine<mDT> {
3092
2955
  * return true;
3093
2956
  * });
3094
2957
  * ```
3095
- *
3096
2958
  * @param handler - Callback invoked after all other pre-hooks.
3097
2959
  * @returns `this` for chaining.
3098
2960
  */
3099
2961
  hook_everything(handler: EverythingHookHandler<mDT>): Machine<mDT>;
3100
- /** Register a post-transition hook that fires **after** all other
2962
+ /**
2963
+ * Register a post-transition hook that fires **after** all other
3101
2964
  * post-hooks on every transition. Cannot block the transition. The
3102
2965
  * handler receives an {@link EverythingHookContext} whose `hook_name` is
3103
2966
  * `'post everything'`.
@@ -3108,12 +2971,12 @@ declare class Machine<mDT> {
3108
2971
  * console.log(`${hook_name} fired`);
3109
2972
  * });
3110
2973
  * ```
3111
- *
3112
2974
  * @param handler - Callback invoked after all other post-hooks.
3113
2975
  * @returns `this` for chaining.
3114
2976
  */
3115
2977
  hook_post_everything(handler: PostEverythingHookHandler<mDT>): Machine<mDT>;
3116
- /** Register a post-transition hook that fires **before** all other
2978
+ /**
2979
+ * Register a post-transition hook that fires **before** all other
3117
2980
  * post-hooks on every transition. Cannot block the transition. The
3118
2981
  * handler receives an {@link EverythingHookContext} whose `hook_name` is
3119
2982
  * `'pre post everything'`.
@@ -3124,22 +2987,24 @@ declare class Machine<mDT> {
3124
2987
  * console.log(`${hook_name} fired`);
3125
2988
  * });
3126
2989
  * ```
3127
- *
3128
2990
  * @param handler - Callback invoked before all other post-hooks.
3129
2991
  * @returns `this` for chaining.
3130
2992
  */
3131
2993
  hook_pre_post_everything(handler: PostEverythingHookHandler<mDT>): Machine<mDT>;
3132
- /** Get the current RNG seed used for probabilistic transitions.
2994
+ /**
2995
+ * Get the current RNG seed used for probabilistic transitions.
3133
2996
  * @returns The numeric seed value.
3134
2997
  */
3135
2998
  get rng_seed(): number;
3136
- /** Set the RNG seed. Pass `undefined` to reseed from the current time.
2999
+ /**
3000
+ * Set the RNG seed. Pass `undefined` to reseed from the current time.
3137
3001
  * Resets the internal PRNG so subsequent probabilistic operations use the
3138
3002
  * new seed.
3139
3003
  * @param to - The seed value, or `undefined` for time-based seeding.
3140
3004
  */
3141
3005
  set rng_seed(to: number | undefined);
3142
- /** Get all edges between two states (there can be multiple with
3006
+ /**
3007
+ * Get all edges between two states (there can be multiple with
3143
3008
  * different actions).
3144
3009
  * @param from - Source state name.
3145
3010
  * @param to - Target state name.
@@ -3181,82 +3046,7 @@ declare class Machine<mDT> {
3181
3046
  * @see set_data
3182
3047
  *
3183
3048
  */
3184
- override(newState: StateType, newData?: mDT | undefined): void;
3185
- /*********
3186
- *
3187
- * Fire a `'rejection'` event caused by a hook vetoing a pending transition.
3188
- * Extracted from the per-call closures inside {@link transition_impl} so
3189
- * that it is allocated once at class-definition time rather than on every
3190
- * hooked transition.
3191
- *
3192
- * @param hook_name Name of the hook that rejected (e.g. `'exit'`).
3193
- * @param fromState State the machine was in when the transition was
3194
- * attempted; used as the `from` field of the rejection event.
3195
- * @param newState State that would have been entered had the hook
3196
- * passed; used as the `to` field of the rejection event.
3197
- * @param fromAction Action name when the transition was initiated by an
3198
- * action call; `undefined` for plain state transitions.
3199
- * @param oldData Machine data at the moment the transition was
3200
- * attempted, before any hook mutations.
3201
- * @param newData The `next_data` value passed to the transition call.
3202
- * @param wasForced Whether the transition was attempted via
3203
- * `force_transition`.
3204
- *
3205
- * @see transition_impl
3206
- * @see _fire
3207
- *
3208
- * @internal
3209
- *
3210
- */
3211
- _fire_hook_rejection(hook_name: string, fromState: StateType, newState: StateType, fromAction: StateType | undefined, oldData: mDT, newData: mDT | undefined, wasForced: boolean): void;
3212
- /*********
3213
- *
3214
- * Fire the FSL boundary-hook actions for a single, already-committed state
3215
- * change. In FSL, `do` is a synonym for `action`, so `on enter &g do 'X';`
3216
- * means "when the machine crosses INTO group `g`, dispatch machine action
3217
- * `X`" — and likewise `on exit` / plain-state subjects. This is the runtime
3218
- * that fires those parked hooks.
3219
- *
3220
- * Crossing semantics (statechart convention — exits before enters):
3221
- *
3222
- * 1. `prev_groups` / `next_groups` are the deep (transitive) group sets of
3223
- * the old and new states, from `_state_to_groups`.
3224
- * 2. **Exits** fire first: every group in `prev_groups \ next_groups` with an
3225
- * `onExit`, plus the plain `prev_state`'s `onExit` (when the state name
3226
- * actually changed).
3227
- * 3. **Enters** fire next: every group in `next_groups \ prev_groups` with an
3228
- * `onEnter`, plus the plain `next_state`'s `onEnter` (when the state name
3229
- * changed).
3230
- * 4. A group present in BOTH sets is a transition *within* that group and
3231
- * fires neither of its boundary hooks. `prev_state === next_state` fires
3232
- * nothing at all.
3233
- * 5. "Fire its action" is `this.action(label)`. If that action is not valid
3234
- * from the current state, `action` is a safe no-op (returns `false`) — an
3235
- * inapplicable boundary action never throws.
3236
- * 6. Multi-membership and nesting both fan out naturally: a state in groups
3237
- * A and B fires both; crossing an inner and an outer boundary fires both
3238
- * levels.
3239
- *
3240
- * Because firing an action can drive a further transition (which crosses
3241
- * more boundaries, which fires more actions), this is a bounded
3242
- * run-to-completion: `_boundary_depth` tracks the live cascade depth and a
3243
- * cascade deeper than `_boundary_depth_limit` throws a {@link JssmError}
3244
- * rather than overflowing the stack or hanging. The limit defaults to 100
3245
- * and is configurable via the `boundary_depth_limit` constructor option.
3246
- *
3247
- * @param prev_state The state the machine was in before this commit.
3248
- * @param next_state The state the machine is in now (already committed).
3249
- *
3250
- * @throws {JssmError} If cascaded boundary firing exceeds `_boundary_depth_limit`
3251
- * (a probable infinite loop).
3252
- *
3253
- * @see action
3254
- * @see transition_impl
3255
- *
3256
- * @internal
3257
- *
3258
- */
3259
- _fire_boundary_actions(prev_state: StateType, next_state: StateType): void;
3049
+ override(newState: StateType, newData?: mDT): void;
3260
3050
  /*********
3261
3051
  *
3262
3052
  * Shared transition core used by {@link transition}, {@link force_transition},
@@ -3308,7 +3098,8 @@ declare class Machine<mDT> {
3308
3098
  *
3309
3099
  */
3310
3100
  transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean, dataProvided?: boolean): boolean;
3311
- /** If the current state has an `after` timeout configured, schedule it.
3101
+ /**
3102
+ * If the current state has an `after` timeout configured, schedule it.
3312
3103
  * Called internally after each transition.
3313
3104
  */
3314
3105
  auto_set_state_timeout(): void;
@@ -3719,94 +3510,6 @@ declare class Machine<mDT> {
3719
3510
  *
3720
3511
  */
3721
3512
  state_has_hooks(state: StateType): boolean;
3722
- /********
3723
- *
3724
- * Returns the list of resolved theme implementations for this machine, in
3725
- * the order they should layer (outer/base-most first). Each declared theme
3726
- * name is mapped through {@link theme_mapping}; unknown names are skipped.
3727
- *
3728
- * The list is reversed relative to declaration order to match the historical
3729
- * layering of {@link style_for}: a later-declared theme layers under an
3730
- * earlier-declared one.
3731
- *
3732
- * @returns The resolved {@link JssmBaseTheme} stack, base-most first.
3733
- *
3734
- * @internal
3735
- *
3736
- */
3737
- _resolved_themes(): JssmBaseTheme[];
3738
- /********
3739
- *
3740
- * Reads the condensed per-state style fields (`color`, `shape`, …) out of a
3741
- * state's declaration into a fresh {@link JssmStateConfig} — the tier-5
3742
- * "`state foo : { … }`" contribution of the config cascade. A state with no
3743
- * declaration yields an all-`undefined` config (which contributes nothing
3744
- * once folded with `merge_state_config`).
3745
- *
3746
- * @param state The state whose per-state declared style is wanted.
3747
- *
3748
- * @returns The per-state style config (fields may be `undefined`).
3749
- *
3750
- * @internal
3751
- *
3752
- */
3753
- _individual_state_config(state: StateType): JssmStateConfig;
3754
- /********
3755
- *
3756
- * Orders the groups a state belongs to by nesting depth for the config
3757
- * cascade — outermost first, innermost last — so that, folded in order,
3758
- * the innermost (nearest / smallest {@link membership_distance}) group's
3759
- * metadata wins. Equal-distance groups are ordered by group declaration
3760
- * order, so a later-declared group of the same depth wins the tie.
3761
- *
3762
- * Concretely: groups are sorted by descending membership distance (largest
3763
- * distance applied first / wins least), and for equal distances by
3764
- * ascending declaration index (later index applied last / wins most).
3765
- *
3766
- * @param state The state whose containing groups are being ordered.
3767
- *
3768
- * @returns The containing group names, ordered for outer→inner folding
3769
- * (the last entry wins).
3770
- *
3771
- * @internal
3772
- *
3773
- */
3774
- _groups_by_depth(state: StateType): string[];
3775
- /********
3776
- *
3777
- * Folds the static tiers 1–5 of the unified config cascade for a state, plus
3778
- * — when `active` is set — the active-state THEME layers, which historically
3779
- * sit just below the per-state config so that a `state foo : { … }` block
3780
- * still overrides a theme's `active` styling. The user `active_state : { … }`
3781
- * overlay (tier 6) is NOT applied here; it is layered on top by
3782
- * {@link resolve_state_config} so it wins over per-state config.
3783
- *
3784
- * Tiers, folded least-specific → most-specific with `merge_state_config`
3785
- * (later wins, never throwing on a cross-tier key collision):
3786
- *
3787
- * 1. theme defaults — `base_theme.state`, then each selected theme's
3788
- * `.state` block.
3789
- * 2. `default_state_config` (the implicit `state : { … }` root over every
3790
- * state).
3791
- * 3. static per-kind defaults selected by structural kind — terminal,
3792
- * then start, then end — each contributing its `base_theme.<kind>`,
3793
- * selected themes' `.<kind>`, and the machine's `default_<kind>_state_config`.
3794
- * When `active`, the active-state theme layers (`base_theme.active` and
3795
- * each selected theme's `.active`) are folded here too.
3796
- * 4. group metadata, depth-ordered outer→inner (see {@link _groups_by_depth}),
3797
- * each group's RAW `{ declarations }` already condensed at construction.
3798
- * 5. the per-state `state foo : { … }` config.
3799
- *
3800
- * @param state The state to resolve config for.
3801
- * @param active Whether to include the active-state theme layers (true only
3802
- * for the machine's currently-occupied state).
3803
- *
3804
- * @returns The composited tiers-1–5 {@link JssmStateConfig} for the state.
3805
- *
3806
- * @internal
3807
- *
3808
- */
3809
- _compose_state_config(state: StateType, active: boolean): JssmStateConfig;
3810
3513
  /********
3811
3514
  *
3812
3515
  * Resolves the full unified style/config cascade for a state — the runtime
@@ -3981,76 +3684,90 @@ declare class Machine<mDT> {
3981
3684
  *
3982
3685
  */
3983
3686
  force_transition(newState: StateType, newData?: mDT): boolean;
3984
- /** Get the edge index for an action from the current state.
3687
+ /**
3688
+ * Get the edge index for an action from the current state.
3985
3689
  * Interned dispatch: resolves via the numeric (action, from) index —
3986
3690
  * unknown action names miss without throwing.
3987
3691
  * @param action - The action name.
3988
3692
  * @returns The edge index, or `undefined` if the action is not available.
3989
3693
  */
3990
3694
  current_action_for(action: StateType): number;
3991
- /** Get the full transition object for an action from the current state.
3695
+ /**
3696
+ * Get the full transition object for an action from the current state.
3992
3697
  * @param action - The action name.
3993
3698
  * @returns The {@link JssmTransition} object.
3994
3699
  * @throws {JssmError} If the action is not available from the current state.
3995
3700
  */
3996
3701
  current_action_edge_for(action: StateType): JssmTransition<StateType, mDT>;
3997
- /** Check whether an action is available from the current state.
3702
+ /**
3703
+ * Check whether an action is available from the current state.
3998
3704
  * @param action - The action name to check.
3999
3705
  * @param _newData - Reserved for future data validation.
4000
3706
  * @returns `true` if the action can be taken.
4001
3707
  */
4002
3708
  valid_action(action: StateType, _newData?: mDT): boolean;
4003
- /** Check whether a transition to a given state is legal (non-forced) from
3709
+ /**
3710
+ * Check whether a transition to a given state is legal (non-forced) from
4004
3711
  * the current state.
4005
3712
  * @param newState - The target state.
4006
3713
  * @param _newData - Reserved for future data validation.
4007
3714
  * @returns `true` if the transition is legal.
4008
3715
  */
4009
3716
  valid_transition(newState: StateType, _newData?: mDT): boolean;
4010
- /** Check whether a forced transition to a given state exists from the
3717
+ /**
3718
+ * Check whether a forced transition to a given state exists from the
4011
3719
  * current state.
4012
3720
  * @param newState - The target state.
4013
3721
  * @param _newData - Reserved for future data validation.
4014
3722
  * @returns `true` if a forced (or any) transition exists.
4015
3723
  */
4016
3724
  valid_force_transition(newState: StateType, _newData?: mDT): boolean;
4017
- /** Get the instance name of this machine, if one was assigned at creation.
3725
+ /**
3726
+ * Get the instance name of this machine, if one was assigned at creation.
4018
3727
  * @returns The instance name string, or `undefined`.
4019
3728
  */
4020
3729
  instance_name(): string | undefined;
4021
- /** Get the creation date of this machine as a `Date` object.
3730
+ /**
3731
+ * Get the creation date of this machine as a `Date` object.
4022
3732
  * @returns A `Date` representing when the machine was created.
4023
3733
  */
4024
3734
  get creation_date(): Date;
4025
- /** Get the creation timestamp (milliseconds since epoch).
3735
+ /**
3736
+ * Get the creation timestamp (milliseconds since epoch).
4026
3737
  * @returns The timestamp as a number.
4027
3738
  */
4028
3739
  get creation_timestamp(): number;
4029
- /** Get the timestamp when construction began (before parsing).
3740
+ /**
3741
+ * Get the timestamp when construction began (before parsing).
4030
3742
  * @returns The start-of-construction timestamp as a number.
4031
3743
  */
4032
3744
  get create_start_time(): number;
4033
- /** Schedule an automatic transition to `next_state` after `after_time`
3745
+ /**
3746
+ * Schedule an automatic transition to `next_state` after `after_time`
4034
3747
  * milliseconds. Only one timeout may be active at a time.
4035
3748
  * @param next_state - The state to transition to when the timer fires.
4036
3749
  * @param after_time - Delay in milliseconds.
4037
3750
  * @throws {JssmError} If a timeout is already pending.
4038
3751
  */
4039
3752
  set_state_timeout(next_state: StateType, after_time: number): void;
4040
- /** Cancel any pending state timeout. Safe to call when no timeout is active.
3753
+ /**
3754
+ Cancel any pending state timeout. Safe to call when no timeout is active.
4041
3755
  */
4042
3756
  clear_state_timeout(): void;
4043
- /** Get the configured `after` timeout for a given state, if any.
3757
+ /**
3758
+ * Get the configured `after` timeout for a given state, if any.
4044
3759
  * @param which_state - The state to look up.
4045
3760
  * @returns A `[targetState, delayMs]` tuple, or `undefined` if no timeout
4046
3761
  * is configured for that state.
4047
3762
  */
4048
3763
  state_timeout_for(which_state: StateType): [StateType, number] | undefined;
4049
- /** Get the configured `after` timeout for the current state, if any.
3764
+ /**
3765
+ * Get the configured `after` timeout for the current state, if any.
4050
3766
  * @returns A `[targetState, delayMs]` tuple, or `undefined`.
4051
3767
  */
4052
3768
  current_state_timeout(): [StateType, number] | undefined;
4053
- /** Convenience method to create a new machine from a tagged template literal.
3769
+ /**
3770
+ * Convenience method to create a new machine from a tagged template literal.
4054
3771
  * Equivalent to calling the top-level `sm` function.
4055
3772
  * @param template_strings - The template string array.
4056
3773
  * @param remainder - Interpolated values.
@@ -4072,10 +3789,8 @@ declare class Machine<mDT> {
4072
3789
  *
4073
3790
  * This is presentation, not simulation — a tour's consecutive entries need
4074
3791
  * not be legal transitions, and no machine state is mutated.
4075
- *
4076
3792
  * @example
4077
3793
  * plan_walk(sm`Red => Green => Yellow => Red;`); // ['Red', 'Green', 'Yellow']
4078
- *
4079
3794
  * @see encode_gif
4080
3795
  */
4081
3796
  declare function plan_walk(machine: Machine<unknown>): string[];
@@ -4104,10 +3819,8 @@ interface HighlightRun {
4104
3819
  *
4105
3820
  * This is the parity guarantee: there is no third tokenizer, so static
4106
3821
  * output can never disagree with the editor.
4107
- *
4108
3822
  * @param source FSL source text to classify.
4109
3823
  * @returns Flat, gap-free, order-preserving runs; `runs.map(r => r.text).join('')` is `source`.
4110
- *
4111
3824
  * @example
4112
3825
  * highlight_fsl_runs('Red -> Green;').find(r => r.state === 'Red');
4113
3826
  * // { text: 'Red', classes: 'fsl-tok-variableName fsl-sem-state', state: 'Red' }
@@ -4119,12 +3832,10 @@ declare function highlight_fsl_runs(source: string): HighlightRun[];
4119
3832
  * `data-state`; when `inline_colors` (default true) and the state appears in
4120
3833
  * `state_colors`, an inline `style="color:…"` ties the code block's state
4121
3834
  * names to the diagram's node colors with zero host CSS.
4122
- *
4123
3835
  * @param source FSL source text to render.
4124
3836
  * @param opts.state_colors Maps a state name to its diagram fill color (e.g. from `extract_state_fills`).
4125
3837
  * @param opts.inline_colors Whether to emit inline `style="color:…"` for matched states. Defaults to `true`.
4126
3838
  * @returns HTML markup for the highlighted source; unclassed runs are emitted as escaped text with no wrapping span.
4127
- *
4128
3839
  * @example
4129
3840
  * highlight_fsl_html('Red -> Green;', { state_colors: new Map([['Red', '#a00']]) });
4130
3841
  * // '…<span class="… fsl-sem-state" data-state="Red" style="color:#a00">Red</span>…'
@@ -4138,12 +3849,9 @@ declare function highlight_fsl_html(source: string, opts?: {
4138
3849
  * Read each state's current fill color out of a graphviz-rendered machine
4139
3850
  * SVG, keyed by state name. States whose shape carries no `fill` attribute
4140
3851
  * are omitted.
4141
- *
4142
3852
  * @param svg - SVG markup from the jssm viz pipeline (`fsl_to_svg_string`).
4143
- *
4144
3853
  * @example
4145
3854
  * extract_state_fills(await fsl_to_svg_string('A -> B;')); // Map { 'A' => '#…', 'B' => '#…' }
4146
- *
4147
3855
  * @see patch_state_fill
4148
3856
  */
4149
3857
  declare function extract_state_fills(svg: string): Map<string, string>;
@@ -4151,14 +3859,11 @@ declare function extract_state_fills(svg: string): Map<string, string>;
4151
3859
  * Return a copy of the SVG with the named state's first shape fill replaced.
4152
3860
  * The unmatched-state case returns the input unchanged (walk truncation and
4153
3861
  * render races surface as a missing highlight, never a throw).
4154
- *
4155
3862
  * @param svg - SVG markup from the jssm viz pipeline.
4156
3863
  * @param state - State name as written in FSL (unescaped).
4157
3864
  * @param fill - Any SVG paint value, e.g. `'#ff9930'`.
4158
- *
4159
3865
  * @example
4160
3866
  * patch_state_fill(svg, 'Red', '#ff9930'); // Red's node now renders orange
4161
- *
4162
3867
  * @see extract_state_fills
4163
3868
  */
4164
3869
  declare function patch_state_fill(svg: string, state: string, fill: string): string;