jssm 5.153.0 → 5.155.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.
@@ -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.153.0 at 6/28/2026, 6:29:10 PM
21
+ * Generated for version 5.155.0 at 6/28/2026, 7:41:44 PM
22
22
 
23
23
  -->
24
- # jssm 5.153.0
24
+ # jssm 5.155.0
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/) ·
@@ -312,7 +312,7 @@ That decision shows up everywhere downstream:
312
312
  or run `npm run benny` against your own machine.
313
313
 
314
314
  - **More thoroughly tested than any other JavaScript state-machine
315
- library.** 7,769 tests at 100.0% line coverage
315
+ library.** 7,811 tests at 100.0% line coverage
316
316
  ([report](https://coveralls.io/github/StoneCypher/jssm)), plus
317
317
  fuzz testing via `fast-check`, with parser test data across ten natural
318
318
  languages and Emoji.
@@ -445,11 +445,11 @@ If your contribution is missing here, please open an issue.
445
445
 
446
446
  <br/>
447
447
 
448
- ***7,769 tests***, run 82,415 times.
448
+ ***7,811 tests***, run 82,853 times.
449
449
 
450
- - 7,015 specs with 100.0% coverage
451
- - 754 fuzz tests with 55.5% coverage
452
- - 9,374 TypeScript lines - 0.8 tests per line, 8.8 generated tests per line
450
+ - 7,053 specs with 100.0% coverage
451
+ - 758 fuzz tests with 54.8% coverage
452
+ - 9,666 TypeScript lines - 0.8 tests per line, 8.6 generated tests per line
453
453
 
454
454
  [![Actions Status](https://github.com/StoneCypher/jssm/workflows/Node%20CI/badge.svg)](https://github.com/StoneCypher/jssm/actions)
455
455
  [![NPM version](https://img.shields.io/npm/v/jssm.svg)](https://www.npmjs.com/package/jssm)
@@ -1,6 +1,6 @@
1
1
  declare type StateType = string;
2
2
  import { JssmGenericState, JssmGenericConfig, JssmStateConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
3
- JssmMachineInternalState, JssmAllowsOverride, JssmAllowIslands, JssmEditorConfig, JssmDefaultSize, JssmStateDeclaration, JssmStateStyleKeyList, JssmTransitionConfig, JssmGraphConfig, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslDirections, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, EverythingHookContext, EverythingHookHandler, PostEverythingHookHandler, HookPhase, HookRegistryEntry, HookQuery, JssmEventName, JssmEventDetailMap, JssmEventFilter, JssmEventHandler, JssmUnsubscribe, JssmBaseTheme, JssmGroupRegistry, JssmGroupHooks, JssmStateHooks, JssmRng } from './jssm_types.js';
3
+ JssmMachineInternalState, JssmAllowsOverride, JssmAllowIslands, JssmEditorConfig, JssmStochasticOptions, JssmStochasticRun, JssmStochasticSummary, JssmDefaultSize, JssmStateDeclaration, JssmStateStyleKeyList, JssmTransitionConfig, JssmGraphConfig, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslDirections, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, EverythingHookContext, EverythingHookHandler, PostEverythingHookHandler, HookPhase, HookRegistryEntry, HookQuery, JssmEventName, JssmEventDetailMap, JssmEventFilter, JssmEventHandler, JssmUnsubscribe, JssmBaseTheme, JssmGroupRegistry, JssmGroupHooks, JssmStateHooks, JssmRng } from './jssm_types.js';
4
4
  import { arrow_direction, arrow_left_kind, arrow_right_kind } from './jssm_arrow.js';
5
5
  import { compile, make, wrap_parse } from './jssm_compiler.js';
6
6
  import { seq, unique, find_repeated, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key, gen_splitmix32, sleep } from './jssm_util.js';
@@ -83,6 +83,10 @@ declare function transfer_state_properties(state_decl: JssmStateDeclaration): Js
83
83
  *
84
84
  */
85
85
  declare function state_style_condense(jssk: JssmStateStyleKeyList, machine?: any): JssmStateConfig;
86
+ /** Default number of independent Monte-Carlo runs when none is declared. */
87
+ export declare const STOCHASTIC_DEFAULT_RUNS = 1000;
88
+ /** Default per-run step cap (montecarlo) / walk length (steady_state). */
89
+ export declare const STOCHASTIC_DEFAULT_MAX_STEPS = 1000;
86
90
  declare class Machine<mDT> {
87
91
  _state: StateType;
88
92
  _states: Map<StateType, JssmGenericState>;
@@ -1011,6 +1015,65 @@ declare class Machine<mDT> {
1011
1015
  * @returns A `Map` from state name to visit count.
1012
1016
  */
1013
1017
  probabilistic_histo_walk(n: number): Map<StateType, number>;
1018
+ /** One non-destructive weighted-random walk over the graph from `start`.
1019
+ *
1020
+ * Reads the graph and advances the PRNG only — it never calls
1021
+ * {@link Machine.transition}, so it fires no hooks, mutates no machine
1022
+ * state, and touches no `data`. A state with no probabilistic exits
1023
+ * (a terminal, or a forced-only `~>` state) ends the walk.
1024
+ *
1025
+ * @param start - State to begin the walk from.
1026
+ * @param max_steps - Maximum transitions before the walk is step-capped.
1027
+ * @returns The {@link JssmStochasticRun} for this walk.
1028
+ */
1029
+ private _stochastic_one_walk;
1030
+ /** Lazily yield one {@link JssmStochasticRun} at a time.
1031
+ *
1032
+ * In `montecarlo` mode (default) yields `runs` independent walks from the
1033
+ * current state, each ending at a terminal or after `max_steps`. In
1034
+ * `steady_state` mode yields exactly one walk of `max_steps` steps. This
1035
+ * is the lazy engine behind {@link Machine.stochastic_summary}; the
1036
+ * fsl-stochastic panel drives it across animation frames.
1037
+ *
1038
+ * Passing `seed` reseeds the machine for reproducible runs. Unlike
1039
+ * {@link Machine.stochastic_summary}, the generator does NOT restore the
1040
+ * prior seed afterward — a direct caller's machine is left reseeded.
1041
+ *
1042
+ * @param opts - {@link JssmStochasticOptions}.
1043
+ * @returns A generator of per-run results.
1044
+ *
1045
+ * @example
1046
+ * const m = sm`a 'go' -> b 'go' -> c;`;
1047
+ * [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
1048
+ */
1049
+ stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
1050
+ /** Run many weighted-random walks and return aggregate statistics.
1051
+ *
1052
+ * Honors `%` transition probabilities (via the existing probabilistic
1053
+ * machinery). Non-destructive: the machine's current state and
1054
+ * {@link Machine.rng_seed} are restored before returning, so calling this
1055
+ * never perturbs the live machine. `montecarlo` mode (default) reports
1056
+ * per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
1057
+ * mode runs one long walk and omits those fields.
1058
+ *
1059
+ * Timing (`after`) decorations and data-guard conditions are not modeled
1060
+ * by this sampler; it walks the probabilistic graph topology.
1061
+ *
1062
+ * @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
1063
+ * machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
1064
+ * present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
1065
+ * @returns A {@link JssmStochasticSummary}.
1066
+ *
1067
+ * @see Machine.stochastic_runs
1068
+ * @see Machine.probabilistic_walk
1069
+ * @see Machine.editor_config
1070
+ *
1071
+ * @example
1072
+ * const m = sm`a 'go' -> b 'go' -> c;`;
1073
+ * const s = m.stochastic_summary({ runs: 100, seed: 1 });
1074
+ * s.terminal_reached; // => 100
1075
+ */
1076
+ stochastic_summary(opts?: JssmStochasticOptions): JssmStochasticSummary;
1014
1077
  /********
1015
1078
  *
1016
1079
  * List all actions available from this state. Please note that the order of