jssm 5.113.0 → 5.119.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.112.4 at 5/12/2026, 11:13:56 AM
21
+ * Generated for version 5.119.0 at 5/13/2026, 4:03:07 PM
22
22
 
23
23
  -->
24
- # jssm 5.112.4
24
+ # jssm 5.119.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/) ·
@@ -120,6 +120,30 @@ usage patterns.
120
120
 
121
121
 
122
122
 
123
+ <br/>
124
+
125
+ ## Web Components
126
+
127
+ `jssm` ships Lit-based web components for use in plain HTML or as a base for framework wrappers.
128
+
129
+ CDN one-liner (with an import map for `@viz-js/viz`):
130
+
131
+ ```html
132
+ <script type="module" src="https://cdn.jsdelivr.net/npm/jssm/dist/cdn/viz.js"></script>
133
+ <jssm-viz fsl="Off -> On -> Off;"></jssm-viz>
134
+ ```
135
+
136
+ npm one-liner:
137
+
138
+ ```ts
139
+ import 'jssm/wc/viz/define';
140
+ // then use <jssm-viz fsl="..."> anywhere
141
+ ```
142
+
143
+ Full documentation: [src/doc_md/WebComponents.md](src/doc_md/WebComponents.md).
144
+
145
+
146
+
123
147
  <br/>
124
148
 
125
149
  ## 60-second tour
@@ -198,7 +222,7 @@ That decision shows up everywhere downstream:
198
222
  or run `npm run benny` against your own machine.
199
223
 
200
224
  - **More thoroughly tested than any other JavaScript state-machine
201
- library.** 5,342 tests at 100.0% line coverage
225
+ library.** 5,809 tests at 100.0% line coverage
202
226
  ([report](https://coveralls.io/github/StoneCypher/jssm)), plus
203
227
  fuzz testing via `fast-check`, with parser test data across ten natural
204
228
  languages and Emoji.
@@ -331,11 +355,11 @@ If your contribution is missing here, please open an issue.
331
355
 
332
356
  <br/>
333
357
 
334
- ***5,342 tests***, run 14,351 times.
358
+ ***5,809 tests***, run 56,596 times.
335
359
 
336
- - 5,251 specs with 100.0% coverage
337
- - 91 fuzz tests with 62.2% coverage
338
- - 3,460 TypeScript lines - 1.5 tests per line, 4.1 generated tests per line
360
+ - 5,296 specs with 100.0% coverage
361
+ - 513 fuzz tests with 59.2% coverage
362
+ - 3,593 TypeScript lines - 1.6 tests per line, 15.8 generated tests per line
339
363
 
340
364
  [![Actions Status](https://github.com/StoneCypher/jssm/workflows/Node%20CI/badge.svg)](https://github.com/StoneCypher/jssm/actions)
341
365
  [![NPM version](https://img.shields.io/npm/v/jssm.svg)](https://www.npmjs.com/package/jssm)
@@ -5,7 +5,16 @@ import { arrow_direction, arrow_left_kind, arrow_right_kind } from './jssm_arrow
5
5
  import { compile, make, wrap_parse } from './jssm_compiler';
6
6
  import { seq, unique, find_repeated, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key, gen_splitmix32, sleep } from './jssm_util';
7
7
  import * as constants from './jssm_constants';
8
- declare const shapes: string[], gviz_shapes: string[], named_colors: string[];
8
+ declare const shapes: string[], gviz_shapes: string[], named_colors: string[], state_name_chars: readonly {
9
+ from: string;
10
+ to: string;
11
+ }[], state_name_first_chars: readonly {
12
+ from: string;
13
+ to: string;
14
+ }[], action_label_chars: readonly {
15
+ from: string;
16
+ to: string;
17
+ }[];
9
18
  import { version, build_time } from './version';
10
19
  /*********
11
20
  *
@@ -686,6 +695,49 @@ declare class Machine<mDT> {
686
695
  * @returns An array of theme name strings.
687
696
  */
688
697
  all_themes(): FslTheme[];
698
+ /** List the character ranges accepted by the FSL grammar in any but the
699
+ * first position of a state name (atom). Each entry is an inclusive
700
+ * `{from, to}` range of single Unicode characters.
701
+ *
702
+ * @returns An array of `{from, to}` inclusive character ranges.
703
+ *
704
+ * @example
705
+ * const m = sm`a -> b;`;
706
+ * m.all_state_name_chars().some(r => '+' >= r.from && '+' <= r.to); // true
707
+ */
708
+ all_state_name_chars(): ReadonlyArray<{
709
+ from: string;
710
+ to: string;
711
+ }>;
712
+ /** List the character ranges accepted by the FSL grammar in the first
713
+ * position of a state name (atom). Narrower than
714
+ * {@link all_state_name_chars}: notably omits `+`, `(`, `)`, `&`, `#`, `@`.
715
+ *
716
+ * @returns An array of `{from, to}` inclusive character ranges.
717
+ *
718
+ * @example
719
+ * const m = sm`a -> b;`;
720
+ * m.all_state_name_first_chars().some(r => '+' >= r.from && '+' <= r.to); // false
721
+ */
722
+ all_state_name_first_chars(): ReadonlyArray<{
723
+ from: string;
724
+ to: string;
725
+ }>;
726
+ /** List the character ranges accepted inside a single-quoted FSL action
727
+ * label without escaping. Space is allowed; the apostrophe `'` is
728
+ * explicitly excluded since it terminates the label.
729
+ *
730
+ * @returns An array of `{from, to}` inclusive character ranges.
731
+ *
732
+ * @example
733
+ * const m = sm`a -> b;`;
734
+ * m.all_action_label_chars().some(r => ' ' >= r.from && ' ' <= r.to); // true
735
+ * m.all_action_label_chars().some(r => "'" >= r.from && "'" <= r.to); // false
736
+ */
737
+ all_action_label_chars(): ReadonlyArray<{
738
+ from: string;
739
+ to: string;
740
+ }>;
689
741
  /** Get the active theme(s) for this machine. Always stored as an array
690
742
  * internally; the union return type exists for setter compatibility.
691
743
  * @returns The current theme or array of themes.
@@ -779,10 +831,23 @@ declare class Machine<mDT> {
779
831
  *
780
832
  */
781
833
  list_exits(whichState?: StateType): Array<StateType>;
782
- /** Get the transitions available from a state, filtered to those with
783
- * probability data. Used by the probabilistic walk system.
834
+ /** Get the transitions available from a state for use by the probabilistic
835
+ * walk system.
836
+ *
837
+ * If any exit declares a `probability`, only those probability-bearing
838
+ * exits are returned, so that non-probability peers cannot dilute the
839
+ * declared distribution. If no exit declares a `probability`, every
840
+ * legal (non-forced) exit is returned, which `weighted_rand_select`
841
+ * treats as equal weight. Forced-only exits (`~>`) are always excluded,
842
+ * since they cannot be taken by an ordinary `transition()` call.
843
+ *
844
+ * Fixes StoneCypher/fsl#1325, in which the function previously returned
845
+ * every exit unconditionally — including forced-only exits and exits
846
+ * with no `probability`, which distorted the weighted distribution.
847
+ *
784
848
  * @param whichState - The state to inspect.
785
- * @returns An array of {@link JssmTransition} edges exiting the state.
849
+ * @returns An array of {@link JssmTransition} edges exiting the state,
850
+ * filtered as described above. May be empty.
786
851
  * @throws {JssmError} If the state does not exist.
787
852
  */
788
853
  probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
@@ -1872,4 +1937,4 @@ declare function abstract_everything_hook_step<mDT>(maybe_hook: EverythingHookHa
1872
1937
  * const restored = jssm.deserialize("a -> b;", serialized);
1873
1938
  */
1874
1939
  declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
1875
- export { version, build_time, transfer_state_properties, Machine, deserialize, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind, seq, unique, find_repeated, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, gen_splitmix32, sleep, constants, shapes, gviz_shapes, named_colors, is_hook_rejection, is_hook_complex_result, abstract_hook_step, abstract_everything_hook_step, state_style_condense, FslDirections };
1940
+ export { version, build_time, transfer_state_properties, Machine, deserialize, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind, seq, unique, find_repeated, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, gen_splitmix32, sleep, constants, shapes, gviz_shapes, named_colors, state_name_chars, state_name_first_chars, action_label_chars, is_hook_rejection, is_hook_complex_result, abstract_hook_step, abstract_everything_hook_step, state_style_condense, FslDirections };