jssm 5.162.9 → 5.162.11

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.
package/jssm.es5.d.cts CHANGED
@@ -74,6 +74,27 @@ type JssmDefaultSize = {
74
74
  width?: number;
75
75
  height?: number;
76
76
  };
77
+ /**
78
+ * A parsed semantic-version breakdown, as produced by the FSL parser for
79
+ * version-valued directives (`machine_version`, `fsl_version`). `major`,
80
+ * `minor`, and `patch` are the three numeric components; `full` preserves
81
+ * the exact source text of the version. `loc` is present only when the
82
+ * source was parsed with `{ locations: true }`.
83
+ *
84
+ * ```typescript
85
+ * const m = sm`machine_version: 1.2.3; a -> b;`;
86
+ * m.machine_version(); // { major: 1, minor: 2, patch: 3, full: '1.2.3' }
87
+ * ```
88
+ * @see Machine.machine_version
89
+ * @see Machine.fsl_version
90
+ */
91
+ type JssmParsedSemver = {
92
+ major: number;
93
+ minor: number;
94
+ patch: number;
95
+ full: string;
96
+ loc?: FslSourceLocation;
97
+ };
77
98
  /**
78
99
  * Runtime-iterable list of valid `flow` directions for FSL diagrams.
79
100
  * Use this when you need to enumerate directions; for the type itself
@@ -564,10 +585,10 @@ type JssmGenericConfig<StateType, DataType> = {
564
585
  machine_language?: string;
565
586
  machine_license?: string;
566
587
  machine_name?: string;
567
- machine_version?: string;
588
+ machine_version?: JssmParsedSemver;
568
589
  npm_name?: string;
569
590
  default_size?: JssmDefaultSize;
570
- fsl_version?: string;
591
+ fsl_version?: JssmParsedSemver;
571
592
  auto_api?: boolean | string;
572
593
  instance_name?: string | undefined;
573
594
  default_state_config?: JssmStateStyleKeyList;
@@ -2009,10 +2030,10 @@ declare class Machine<mDT> {
2009
2030
  _machine_language?: string;
2010
2031
  _machine_license?: string;
2011
2032
  _machine_name?: string;
2012
- _machine_version?: string;
2033
+ _machine_version?: JssmParsedSemver;
2013
2034
  _npm_name?: string;
2014
2035
  _default_size?: JssmDefaultSize;
2015
- _fsl_version?: string;
2036
+ _fsl_version?: JssmParsedSemver;
2016
2037
  _raw_state_declaration?: Array<object>;
2017
2038
  _state_declarations: Map<StateType, JssmStateDeclaration>;
2018
2039
  _data?: mDT;
@@ -2635,10 +2656,18 @@ declare class Machine<mDT> {
2635
2656
  */
2636
2657
  default_size(): JssmDefaultSize | undefined;
2637
2658
  /**
2638
- * Get the machine's version string. Set via the FSL `machine_version` directive.
2639
- * @returns The version string.
2659
+ * Get the machine's declared version, parsed. Set via the FSL
2660
+ * `machine_version` directive, which takes a semver triple; the parser
2661
+ * breaks it into numeric `major`/`minor`/`patch` fields and keeps the
2662
+ * exact source text in `full`. Returns `undefined` when the directive
2663
+ * was not given.
2664
+ * @returns The parsed {@link JssmParsedSemver}, or `undefined` if unset.
2665
+ * @example
2666
+ * const m = sm`machine_version: 1.2.3; a -> b;`;
2667
+ * m.machine_version(); // => { major: 1, minor: 2, patch: 3, full: '1.2.3' }
2668
+ * @see fsl_version
2640
2669
  */
2641
- machine_version(): string;
2670
+ machine_version(): JssmParsedSemver | undefined;
2642
2671
  /**
2643
2672
  * Get the raw state declaration objects as parsed from the FSL source.
2644
2673
  * @returns An array of raw state declaration objects.
@@ -2656,10 +2685,18 @@ declare class Machine<mDT> {
2656
2685
  */
2657
2686
  state_declarations(): Map<StateType, JssmStateDeclaration>;
2658
2687
  /**
2659
- * Get the FSL language version this machine was compiled under.
2660
- * @returns The FSL version string.
2688
+ * Get the FSL language version this machine declares, parsed. Set via
2689
+ * the FSL `fsl_version` directive, which takes a semver triple; the
2690
+ * parser breaks it into numeric `major`/`minor`/`patch` fields and keeps
2691
+ * the exact source text in `full`. Returns `undefined` when the
2692
+ * directive was not given.
2693
+ * @returns The parsed {@link JssmParsedSemver}, or `undefined` if unset.
2694
+ * @example
2695
+ * const m = sm`fsl_version: 1.0.0; a -> b;`;
2696
+ * m.fsl_version(); // => { major: 1, minor: 0, patch: 0, full: '1.0.0' }
2697
+ * @see machine_version
2661
2698
  */
2662
- fsl_version(): string;
2699
+ fsl_version(): JssmParsedSemver | undefined;
2663
2700
  /**
2664
2701
  * Get the complete internal state of the machine as a serializable
2665
2702
  * structure. Includes actions, edges, edge map, named transitions,
@@ -2862,7 +2899,19 @@ declare class Machine<mDT> {
2862
2899
  get themes(): FslTheme | FslTheme[];
2863
2900
  /**
2864
2901
  * Set the active theme(s). Accepts a single theme name or an array.
2902
+ * Also drops every memoized static state config, so styles resolved
2903
+ * before the change re-resolve under the new theme stack.
2904
+ *
2905
+ * ```typescript
2906
+ * const m = sm`a -> b;`;
2907
+ * m.style_for('b'); // resolved under the default theme
2908
+ * m.themes = 'ocean';
2909
+ * m.style_for('b').backgroundColor; // 'cadetblue1' — ocean, not a stale default
2910
+ * ```
2911
+ *
2865
2912
  * @param to - A theme name or array of theme names to apply.
2913
+ *
2914
+ * @see resolve_state_config
2866
2915
  */
2867
2916
  set themes(to: FslTheme | FslTheme[]);
2868
2917
  /**
@@ -2972,10 +3021,34 @@ declare class Machine<mDT> {
2972
3021
  * @throws {JssmError} If the state does not exist.
2973
3022
  */
2974
3023
  probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
3024
+ /**
3025
+ * Guard for the random-selection paths ({@link Machine.probabilistic_transition},
3026
+ * {@link Machine.stochastic_runs}): rejects a candidate pool whose total
3027
+ * selectable weight is zero, because weighted selection over an all-zero
3028
+ * pool has no meaningful answer (StoneCypher/fsl#1248). Undeclared
3029
+ * probabilities count as weight 1, matching {@link weighted_rand_select}.
3030
+ * An empty pool is not this guard's concern (terminality is handled by the
3031
+ * callers) and passes through untouched.
3032
+ *
3033
+ * ```typescript
3034
+ * const m = sm`a 0% -> b; a 0% -> c;`;
3035
+ * m.probabilistic_transition(); // throws JssmError — every exit is 0%
3036
+ * ```
3037
+ * @param whichState - The state the pool exits from, named in the error.
3038
+ * @param exits - The candidate pool, as built by {@link Machine.probable_exits_for}.
3039
+ * @throws {JssmError} If the pool is non-empty and every candidate edge
3040
+ * has probability 0 — including the case where explicit `0%` edges
3041
+ * excluded their unweighted sibling edges from the candidate pool.
3042
+ * @see probable_exits_for
3043
+ */
3044
+ private _assert_selectable_exit_pool;
2975
3045
  /**
2976
3046
  * Take a single random transition from the current state, weighted by
2977
3047
  * edge probabilities.
2978
3048
  * @returns `true` if a transition was taken, `false` otherwise.
3049
+ * @throws {JssmError} If the candidate exit pool is non-empty but its
3050
+ * total weight is zero — every candidate declares `0%` — per
3051
+ * StoneCypher/fsl#1248.
2979
3052
  */
2980
3053
  probabilistic_transition(): boolean;
2981
3054
  /**
@@ -2983,6 +3056,8 @@ declare class Machine<mDT> {
2983
3056
  * of states visited (before each transition).
2984
3057
  * @param n - Number of steps to walk.
2985
3058
  * @returns An array of state names visited during the walk.
3059
+ * @throws {JssmError} If a visited state's candidate exit pool is
3060
+ * non-empty but all-zero-weight (StoneCypher/fsl#1248).
2986
3061
  */
2987
3062
  probabilistic_walk(n: number): Array<StateType>;
2988
3063
  /**
@@ -2990,6 +3065,8 @@ declare class Machine<mDT> {
2990
3065
  * each state was visited.
2991
3066
  * @param n - Number of steps to walk.
2992
3067
  * @returns A `Map` from state name to visit count.
3068
+ * @throws {JssmError} If a visited state's candidate exit pool is
3069
+ * non-empty but all-zero-weight (StoneCypher/fsl#1248).
2993
3070
  */
2994
3071
  probabilistic_histo_walk(n: number): Map<StateType, number>;
2995
3072
  /**
@@ -3009,6 +3086,9 @@ declare class Machine<mDT> {
3009
3086
  * the derived arrays — RNG draw order is untouched, so seeded walks
3010
3087
  * reproduce exactly.
3011
3088
  * @returns The {@link JssmStochasticRun} for this walk.
3089
+ * @throws {JssmError} If a visited state's candidate exit pool is
3090
+ * non-empty but all-zero-weight — see
3091
+ * {@link Machine._assert_selectable_exit_pool} (StoneCypher/fsl#1248).
3012
3092
  */
3013
3093
  private _stochastic_one_walk;
3014
3094
  /**
@@ -4175,8 +4255,12 @@ declare class Machine<mDT> {
4175
4255
  * For any state OTHER than the current one, this returns the memoized static
4176
4256
  * resolution (tiers 1–5; see `_compose_state_config`) — theme →
4177
4257
  * `default_state_config` → per-kind defaults → depth-ordered group metadata →
4178
- * per-state config. The cache is keyed by state and never invalidated, since
4179
- * those tiers do not depend on which state is current.
4258
+ * per-state config. The cache is keyed by state; those tiers do not depend
4259
+ * on which state is current, so it survives transitions, but the mutable
4260
+ * cascade inputs each clear it when they change — hook registration and
4261
+ * removal ({@link Machine.set_hook}, {@link Machine.remove_hook}; the
4262
+ * hooked layer) and theme assignment (the `themes` setter; tier 1 and the
4263
+ * per-kind theme layers).
4180
4264
  *
4181
4265
  * For the machine's CURRENTLY-occupied state the result is recomputed each
4182
4266
  * call (never cached) and additionally carries the dynamic `active_state`
package/jssm.es6.d.ts CHANGED
@@ -74,6 +74,27 @@ type JssmDefaultSize = {
74
74
  width?: number;
75
75
  height?: number;
76
76
  };
77
+ /**
78
+ * A parsed semantic-version breakdown, as produced by the FSL parser for
79
+ * version-valued directives (`machine_version`, `fsl_version`). `major`,
80
+ * `minor`, and `patch` are the three numeric components; `full` preserves
81
+ * the exact source text of the version. `loc` is present only when the
82
+ * source was parsed with `{ locations: true }`.
83
+ *
84
+ * ```typescript
85
+ * const m = sm`machine_version: 1.2.3; a -> b;`;
86
+ * m.machine_version(); // { major: 1, minor: 2, patch: 3, full: '1.2.3' }
87
+ * ```
88
+ * @see Machine.machine_version
89
+ * @see Machine.fsl_version
90
+ */
91
+ type JssmParsedSemver = {
92
+ major: number;
93
+ minor: number;
94
+ patch: number;
95
+ full: string;
96
+ loc?: FslSourceLocation;
97
+ };
77
98
  /**
78
99
  * Runtime-iterable list of valid `flow` directions for FSL diagrams.
79
100
  * Use this when you need to enumerate directions; for the type itself
@@ -564,10 +585,10 @@ type JssmGenericConfig<StateType, DataType> = {
564
585
  machine_language?: string;
565
586
  machine_license?: string;
566
587
  machine_name?: string;
567
- machine_version?: string;
588
+ machine_version?: JssmParsedSemver;
568
589
  npm_name?: string;
569
590
  default_size?: JssmDefaultSize;
570
- fsl_version?: string;
591
+ fsl_version?: JssmParsedSemver;
571
592
  auto_api?: boolean | string;
572
593
  instance_name?: string | undefined;
573
594
  default_state_config?: JssmStateStyleKeyList;
@@ -2009,10 +2030,10 @@ declare class Machine<mDT> {
2009
2030
  _machine_language?: string;
2010
2031
  _machine_license?: string;
2011
2032
  _machine_name?: string;
2012
- _machine_version?: string;
2033
+ _machine_version?: JssmParsedSemver;
2013
2034
  _npm_name?: string;
2014
2035
  _default_size?: JssmDefaultSize;
2015
- _fsl_version?: string;
2036
+ _fsl_version?: JssmParsedSemver;
2016
2037
  _raw_state_declaration?: Array<object>;
2017
2038
  _state_declarations: Map<StateType, JssmStateDeclaration>;
2018
2039
  _data?: mDT;
@@ -2635,10 +2656,18 @@ declare class Machine<mDT> {
2635
2656
  */
2636
2657
  default_size(): JssmDefaultSize | undefined;
2637
2658
  /**
2638
- * Get the machine's version string. Set via the FSL `machine_version` directive.
2639
- * @returns The version string.
2659
+ * Get the machine's declared version, parsed. Set via the FSL
2660
+ * `machine_version` directive, which takes a semver triple; the parser
2661
+ * breaks it into numeric `major`/`minor`/`patch` fields and keeps the
2662
+ * exact source text in `full`. Returns `undefined` when the directive
2663
+ * was not given.
2664
+ * @returns The parsed {@link JssmParsedSemver}, or `undefined` if unset.
2665
+ * @example
2666
+ * const m = sm`machine_version: 1.2.3; a -> b;`;
2667
+ * m.machine_version(); // => { major: 1, minor: 2, patch: 3, full: '1.2.3' }
2668
+ * @see fsl_version
2640
2669
  */
2641
- machine_version(): string;
2670
+ machine_version(): JssmParsedSemver | undefined;
2642
2671
  /**
2643
2672
  * Get the raw state declaration objects as parsed from the FSL source.
2644
2673
  * @returns An array of raw state declaration objects.
@@ -2656,10 +2685,18 @@ declare class Machine<mDT> {
2656
2685
  */
2657
2686
  state_declarations(): Map<StateType, JssmStateDeclaration>;
2658
2687
  /**
2659
- * Get the FSL language version this machine was compiled under.
2660
- * @returns The FSL version string.
2688
+ * Get the FSL language version this machine declares, parsed. Set via
2689
+ * the FSL `fsl_version` directive, which takes a semver triple; the
2690
+ * parser breaks it into numeric `major`/`minor`/`patch` fields and keeps
2691
+ * the exact source text in `full`. Returns `undefined` when the
2692
+ * directive was not given.
2693
+ * @returns The parsed {@link JssmParsedSemver}, or `undefined` if unset.
2694
+ * @example
2695
+ * const m = sm`fsl_version: 1.0.0; a -> b;`;
2696
+ * m.fsl_version(); // => { major: 1, minor: 0, patch: 0, full: '1.0.0' }
2697
+ * @see machine_version
2661
2698
  */
2662
- fsl_version(): string;
2699
+ fsl_version(): JssmParsedSemver | undefined;
2663
2700
  /**
2664
2701
  * Get the complete internal state of the machine as a serializable
2665
2702
  * structure. Includes actions, edges, edge map, named transitions,
@@ -2862,7 +2899,19 @@ declare class Machine<mDT> {
2862
2899
  get themes(): FslTheme | FslTheme[];
2863
2900
  /**
2864
2901
  * Set the active theme(s). Accepts a single theme name or an array.
2902
+ * Also drops every memoized static state config, so styles resolved
2903
+ * before the change re-resolve under the new theme stack.
2904
+ *
2905
+ * ```typescript
2906
+ * const m = sm`a -> b;`;
2907
+ * m.style_for('b'); // resolved under the default theme
2908
+ * m.themes = 'ocean';
2909
+ * m.style_for('b').backgroundColor; // 'cadetblue1' — ocean, not a stale default
2910
+ * ```
2911
+ *
2865
2912
  * @param to - A theme name or array of theme names to apply.
2913
+ *
2914
+ * @see resolve_state_config
2866
2915
  */
2867
2916
  set themes(to: FslTheme | FslTheme[]);
2868
2917
  /**
@@ -2972,10 +3021,34 @@ declare class Machine<mDT> {
2972
3021
  * @throws {JssmError} If the state does not exist.
2973
3022
  */
2974
3023
  probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
3024
+ /**
3025
+ * Guard for the random-selection paths ({@link Machine.probabilistic_transition},
3026
+ * {@link Machine.stochastic_runs}): rejects a candidate pool whose total
3027
+ * selectable weight is zero, because weighted selection over an all-zero
3028
+ * pool has no meaningful answer (StoneCypher/fsl#1248). Undeclared
3029
+ * probabilities count as weight 1, matching {@link weighted_rand_select}.
3030
+ * An empty pool is not this guard's concern (terminality is handled by the
3031
+ * callers) and passes through untouched.
3032
+ *
3033
+ * ```typescript
3034
+ * const m = sm`a 0% -> b; a 0% -> c;`;
3035
+ * m.probabilistic_transition(); // throws JssmError — every exit is 0%
3036
+ * ```
3037
+ * @param whichState - The state the pool exits from, named in the error.
3038
+ * @param exits - The candidate pool, as built by {@link Machine.probable_exits_for}.
3039
+ * @throws {JssmError} If the pool is non-empty and every candidate edge
3040
+ * has probability 0 — including the case where explicit `0%` edges
3041
+ * excluded their unweighted sibling edges from the candidate pool.
3042
+ * @see probable_exits_for
3043
+ */
3044
+ private _assert_selectable_exit_pool;
2975
3045
  /**
2976
3046
  * Take a single random transition from the current state, weighted by
2977
3047
  * edge probabilities.
2978
3048
  * @returns `true` if a transition was taken, `false` otherwise.
3049
+ * @throws {JssmError} If the candidate exit pool is non-empty but its
3050
+ * total weight is zero — every candidate declares `0%` — per
3051
+ * StoneCypher/fsl#1248.
2979
3052
  */
2980
3053
  probabilistic_transition(): boolean;
2981
3054
  /**
@@ -2983,6 +3056,8 @@ declare class Machine<mDT> {
2983
3056
  * of states visited (before each transition).
2984
3057
  * @param n - Number of steps to walk.
2985
3058
  * @returns An array of state names visited during the walk.
3059
+ * @throws {JssmError} If a visited state's candidate exit pool is
3060
+ * non-empty but all-zero-weight (StoneCypher/fsl#1248).
2986
3061
  */
2987
3062
  probabilistic_walk(n: number): Array<StateType>;
2988
3063
  /**
@@ -2990,6 +3065,8 @@ declare class Machine<mDT> {
2990
3065
  * each state was visited.
2991
3066
  * @param n - Number of steps to walk.
2992
3067
  * @returns A `Map` from state name to visit count.
3068
+ * @throws {JssmError} If a visited state's candidate exit pool is
3069
+ * non-empty but all-zero-weight (StoneCypher/fsl#1248).
2993
3070
  */
2994
3071
  probabilistic_histo_walk(n: number): Map<StateType, number>;
2995
3072
  /**
@@ -3009,6 +3086,9 @@ declare class Machine<mDT> {
3009
3086
  * the derived arrays — RNG draw order is untouched, so seeded walks
3010
3087
  * reproduce exactly.
3011
3088
  * @returns The {@link JssmStochasticRun} for this walk.
3089
+ * @throws {JssmError} If a visited state's candidate exit pool is
3090
+ * non-empty but all-zero-weight — see
3091
+ * {@link Machine._assert_selectable_exit_pool} (StoneCypher/fsl#1248).
3012
3092
  */
3013
3093
  private _stochastic_one_walk;
3014
3094
  /**
@@ -4175,8 +4255,12 @@ declare class Machine<mDT> {
4175
4255
  * For any state OTHER than the current one, this returns the memoized static
4176
4256
  * resolution (tiers 1–5; see `_compose_state_config`) — theme →
4177
4257
  * `default_state_config` → per-kind defaults → depth-ordered group metadata →
4178
- * per-state config. The cache is keyed by state and never invalidated, since
4179
- * those tiers do not depend on which state is current.
4258
+ * per-state config. The cache is keyed by state; those tiers do not depend
4259
+ * on which state is current, so it survives transitions, but the mutable
4260
+ * cascade inputs each clear it when they change — hook registration and
4261
+ * removal ({@link Machine.set_hook}, {@link Machine.remove_hook}; the
4262
+ * hooked layer) and theme assignment (the `themes` setter; tier 1 and the
4263
+ * per-kind theme layers).
4180
4264
  *
4181
4265
  * For the machine's CURRENTLY-occupied state the result is recomputed each
4182
4266
  * call (never cached) and additionally carries the dynamic `active_state`
package/jssm.fence.d.ts CHANGED
@@ -210,6 +210,27 @@ type JssmDefaultSize = {
210
210
  width?: number;
211
211
  height?: number;
212
212
  };
213
+ /**
214
+ * A parsed semantic-version breakdown, as produced by the FSL parser for
215
+ * version-valued directives (`machine_version`, `fsl_version`). `major`,
216
+ * `minor`, and `patch` are the three numeric components; `full` preserves
217
+ * the exact source text of the version. `loc` is present only when the
218
+ * source was parsed with `{ locations: true }`.
219
+ *
220
+ * ```typescript
221
+ * const m = sm`machine_version: 1.2.3; a -> b;`;
222
+ * m.machine_version(); // { major: 1, minor: 2, patch: 3, full: '1.2.3' }
223
+ * ```
224
+ * @see Machine.machine_version
225
+ * @see Machine.fsl_version
226
+ */
227
+ type JssmParsedSemver = {
228
+ major: number;
229
+ minor: number;
230
+ patch: number;
231
+ full: string;
232
+ loc?: FslSourceLocation;
233
+ };
213
234
  /**
214
235
  * Runtime-iterable list of valid `flow` directions for FSL diagrams.
215
236
  * Use this when you need to enumerate directions; for the type itself
@@ -700,10 +721,10 @@ type JssmGenericConfig<StateType, DataType> = {
700
721
  machine_language?: string;
701
722
  machine_license?: string;
702
723
  machine_name?: string;
703
- machine_version?: string;
724
+ machine_version?: JssmParsedSemver;
704
725
  npm_name?: string;
705
726
  default_size?: JssmDefaultSize;
706
- fsl_version?: string;
727
+ fsl_version?: JssmParsedSemver;
707
728
  auto_api?: boolean | string;
708
729
  instance_name?: string | undefined;
709
730
  default_state_config?: JssmStateStyleKeyList;
@@ -1352,10 +1373,10 @@ declare class Machine<mDT> {
1352
1373
  _machine_language?: string;
1353
1374
  _machine_license?: string;
1354
1375
  _machine_name?: string;
1355
- _machine_version?: string;
1376
+ _machine_version?: JssmParsedSemver;
1356
1377
  _npm_name?: string;
1357
1378
  _default_size?: JssmDefaultSize;
1358
- _fsl_version?: string;
1379
+ _fsl_version?: JssmParsedSemver;
1359
1380
  _raw_state_declaration?: Array<object>;
1360
1381
  _state_declarations: Map<StateType, JssmStateDeclaration>;
1361
1382
  _data?: mDT;
@@ -1978,10 +1999,18 @@ declare class Machine<mDT> {
1978
1999
  */
1979
2000
  default_size(): JssmDefaultSize | undefined;
1980
2001
  /**
1981
- * Get the machine's version string. Set via the FSL `machine_version` directive.
1982
- * @returns The version string.
2002
+ * Get the machine's declared version, parsed. Set via the FSL
2003
+ * `machine_version` directive, which takes a semver triple; the parser
2004
+ * breaks it into numeric `major`/`minor`/`patch` fields and keeps the
2005
+ * exact source text in `full`. Returns `undefined` when the directive
2006
+ * was not given.
2007
+ * @returns The parsed {@link JssmParsedSemver}, or `undefined` if unset.
2008
+ * @example
2009
+ * const m = sm`machine_version: 1.2.3; a -> b;`;
2010
+ * m.machine_version(); // => { major: 1, minor: 2, patch: 3, full: '1.2.3' }
2011
+ * @see fsl_version
1983
2012
  */
1984
- machine_version(): string;
2013
+ machine_version(): JssmParsedSemver | undefined;
1985
2014
  /**
1986
2015
  * Get the raw state declaration objects as parsed from the FSL source.
1987
2016
  * @returns An array of raw state declaration objects.
@@ -1999,10 +2028,18 @@ declare class Machine<mDT> {
1999
2028
  */
2000
2029
  state_declarations(): Map<StateType, JssmStateDeclaration>;
2001
2030
  /**
2002
- * Get the FSL language version this machine was compiled under.
2003
- * @returns The FSL version string.
2031
+ * Get the FSL language version this machine declares, parsed. Set via
2032
+ * the FSL `fsl_version` directive, which takes a semver triple; the
2033
+ * parser breaks it into numeric `major`/`minor`/`patch` fields and keeps
2034
+ * the exact source text in `full`. Returns `undefined` when the
2035
+ * directive was not given.
2036
+ * @returns The parsed {@link JssmParsedSemver}, or `undefined` if unset.
2037
+ * @example
2038
+ * const m = sm`fsl_version: 1.0.0; a -> b;`;
2039
+ * m.fsl_version(); // => { major: 1, minor: 0, patch: 0, full: '1.0.0' }
2040
+ * @see machine_version
2004
2041
  */
2005
- fsl_version(): string;
2042
+ fsl_version(): JssmParsedSemver | undefined;
2006
2043
  /**
2007
2044
  * Get the complete internal state of the machine as a serializable
2008
2045
  * structure. Includes actions, edges, edge map, named transitions,
@@ -2205,7 +2242,19 @@ declare class Machine<mDT> {
2205
2242
  get themes(): FslTheme | FslTheme[];
2206
2243
  /**
2207
2244
  * Set the active theme(s). Accepts a single theme name or an array.
2245
+ * Also drops every memoized static state config, so styles resolved
2246
+ * before the change re-resolve under the new theme stack.
2247
+ *
2248
+ * ```typescript
2249
+ * const m = sm`a -> b;`;
2250
+ * m.style_for('b'); // resolved under the default theme
2251
+ * m.themes = 'ocean';
2252
+ * m.style_for('b').backgroundColor; // 'cadetblue1' — ocean, not a stale default
2253
+ * ```
2254
+ *
2208
2255
  * @param to - A theme name or array of theme names to apply.
2256
+ *
2257
+ * @see resolve_state_config
2209
2258
  */
2210
2259
  set themes(to: FslTheme | FslTheme[]);
2211
2260
  /**
@@ -2315,10 +2364,34 @@ declare class Machine<mDT> {
2315
2364
  * @throws {JssmError} If the state does not exist.
2316
2365
  */
2317
2366
  probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
2367
+ /**
2368
+ * Guard for the random-selection paths ({@link Machine.probabilistic_transition},
2369
+ * {@link Machine.stochastic_runs}): rejects a candidate pool whose total
2370
+ * selectable weight is zero, because weighted selection over an all-zero
2371
+ * pool has no meaningful answer (StoneCypher/fsl#1248). Undeclared
2372
+ * probabilities count as weight 1, matching {@link weighted_rand_select}.
2373
+ * An empty pool is not this guard's concern (terminality is handled by the
2374
+ * callers) and passes through untouched.
2375
+ *
2376
+ * ```typescript
2377
+ * const m = sm`a 0% -> b; a 0% -> c;`;
2378
+ * m.probabilistic_transition(); // throws JssmError — every exit is 0%
2379
+ * ```
2380
+ * @param whichState - The state the pool exits from, named in the error.
2381
+ * @param exits - The candidate pool, as built by {@link Machine.probable_exits_for}.
2382
+ * @throws {JssmError} If the pool is non-empty and every candidate edge
2383
+ * has probability 0 — including the case where explicit `0%` edges
2384
+ * excluded their unweighted sibling edges from the candidate pool.
2385
+ * @see probable_exits_for
2386
+ */
2387
+ private _assert_selectable_exit_pool;
2318
2388
  /**
2319
2389
  * Take a single random transition from the current state, weighted by
2320
2390
  * edge probabilities.
2321
2391
  * @returns `true` if a transition was taken, `false` otherwise.
2392
+ * @throws {JssmError} If the candidate exit pool is non-empty but its
2393
+ * total weight is zero — every candidate declares `0%` — per
2394
+ * StoneCypher/fsl#1248.
2322
2395
  */
2323
2396
  probabilistic_transition(): boolean;
2324
2397
  /**
@@ -2326,6 +2399,8 @@ declare class Machine<mDT> {
2326
2399
  * of states visited (before each transition).
2327
2400
  * @param n - Number of steps to walk.
2328
2401
  * @returns An array of state names visited during the walk.
2402
+ * @throws {JssmError} If a visited state's candidate exit pool is
2403
+ * non-empty but all-zero-weight (StoneCypher/fsl#1248).
2329
2404
  */
2330
2405
  probabilistic_walk(n: number): Array<StateType>;
2331
2406
  /**
@@ -2333,6 +2408,8 @@ declare class Machine<mDT> {
2333
2408
  * each state was visited.
2334
2409
  * @param n - Number of steps to walk.
2335
2410
  * @returns A `Map` from state name to visit count.
2411
+ * @throws {JssmError} If a visited state's candidate exit pool is
2412
+ * non-empty but all-zero-weight (StoneCypher/fsl#1248).
2336
2413
  */
2337
2414
  probabilistic_histo_walk(n: number): Map<StateType, number>;
2338
2415
  /**
@@ -2352,6 +2429,9 @@ declare class Machine<mDT> {
2352
2429
  * the derived arrays — RNG draw order is untouched, so seeded walks
2353
2430
  * reproduce exactly.
2354
2431
  * @returns The {@link JssmStochasticRun} for this walk.
2432
+ * @throws {JssmError} If a visited state's candidate exit pool is
2433
+ * non-empty but all-zero-weight — see
2434
+ * {@link Machine._assert_selectable_exit_pool} (StoneCypher/fsl#1248).
2355
2435
  */
2356
2436
  private _stochastic_one_walk;
2357
2437
  /**
@@ -3518,8 +3598,12 @@ declare class Machine<mDT> {
3518
3598
  * For any state OTHER than the current one, this returns the memoized static
3519
3599
  * resolution (tiers 1–5; see `_compose_state_config`) — theme →
3520
3600
  * `default_state_config` → per-kind defaults → depth-ordered group metadata →
3521
- * per-state config. The cache is keyed by state and never invalidated, since
3522
- * those tiers do not depend on which state is current.
3601
+ * per-state config. The cache is keyed by state; those tiers do not depend
3602
+ * on which state is current, so it survives transitions, but the mutable
3603
+ * cascade inputs each clear it when they change — hook registration and
3604
+ * removal ({@link Machine.set_hook}, {@link Machine.remove_hook}; the
3605
+ * hooked layer) and theme assignment (the `themes` setter; tier 1 and the
3606
+ * per-kind theme layers).
3523
3607
  *
3524
3608
  * For the machine's CURRENTLY-occupied state the result is recomputed each
3525
3609
  * call (never cached) and additionally carries the dynamic `active_state`