jssm 5.112.3 → 5.113.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +3 -3
  2. package/dist/deno/README.md +347 -0
  3. package/dist/deno/jssm.js +1 -0
  4. package/dist/{es6 → deno}/jssm_constants.d.ts +5 -0
  5. package/dist/{es6 → deno}/jssm_types.d.ts +298 -5
  6. package/dist/jssm.es5.cjs +1 -1
  7. package/dist/jssm.es5.iife.js +1 -1
  8. package/dist/jssm.es6.mjs +1 -1
  9. package/dist/jssm_viz.cjs +1 -1
  10. package/dist/jssm_viz.iife.cjs +1 -1
  11. package/dist/jssm_viz.mjs +1 -1
  12. package/jssm.es5.d.cts +241 -2
  13. package/jssm.es6.d.ts +241 -2
  14. package/jssm_viz.es5.d.cts +216 -2
  15. package/jssm_viz.es6.d.ts +216 -2
  16. package/package.json +18 -2
  17. package/.clocignore +0 -1
  18. package/.codeclimate.yml +0 -22
  19. package/.editorconfig +0 -12
  20. package/.eslintrc +0 -20
  21. package/.gitattributes +0 -17
  22. package/.log-progress.json +0 -9
  23. package/.nycrc +0 -6
  24. package/.travis.yml +0 -9
  25. package/CHANGELOG.md +0 -263
  26. package/CLAUDE.md +0 -11
  27. package/dist/es6/fsl_parser.js +0 -1
  28. package/dist/es6/jssm.js +0 -3320
  29. package/dist/es6/jssm_arrow.js +0 -211
  30. package/dist/es6/jssm_compiler.js +0 -380
  31. package/dist/es6/jssm_constants.js +0 -121
  32. package/dist/es6/jssm_error.js +0 -47
  33. package/dist/es6/jssm_theme.js +0 -24
  34. package/dist/es6/jssm_types.js +0 -3
  35. package/dist/es6/jssm_util.js +0 -337
  36. package/dist/es6/jssm_viz.js +0 -560
  37. package/dist/es6/jssm_viz_colors.js +0 -63
  38. package/dist/es6/themes/jssm_base_stylesheet.d.ts +0 -11
  39. package/dist/es6/themes/jssm_base_stylesheet.js +0 -58
  40. package/dist/es6/themes/jssm_theme_bold.d.ts +0 -11
  41. package/dist/es6/themes/jssm_theme_bold.js +0 -58
  42. package/dist/es6/themes/jssm_theme_default.d.ts +0 -11
  43. package/dist/es6/themes/jssm_theme_default.js +0 -58
  44. package/dist/es6/themes/jssm_theme_modern.d.ts +0 -11
  45. package/dist/es6/themes/jssm_theme_modern.js +0 -58
  46. package/dist/es6/themes/jssm_theme_ocean.d.ts +0 -11
  47. package/dist/es6/themes/jssm_theme_ocean.js +0 -56
  48. package/dist/es6/themes/jssm_theme_plain.d.ts +0 -11
  49. package/dist/es6/themes/jssm_theme_plain.js +0 -70
  50. package/dist/es6/version.js +0 -2
  51. package/dist/jssm.es5.nonmin.cjs +0 -24506
  52. package/dist/jssm.es6.nonmin.cjs +0 -24473
  53. package/dist/jssm_viz.es5.iife.nonmin.cjs +0 -24679
  54. package/dist/jssm_viz.es5.nonmin.cjs +0 -24674
  55. package/dist/jssm_viz.es6.nonmin.cjs +0 -24661
  56. package/jest-dragon.config.cjs +0 -36
  57. package/jest-spec.config.cjs +0 -36
  58. package/jest-stoch.config.cjs +0 -36
  59. package/jest-unicode.config.cjs +0 -36
  60. package/log-progress.data.json +0 -28
  61. package/rollup.config.deno.js +0 -44
  62. package/rollup.config.es5.js +0 -52
  63. package/rollup.config.es6.js +0 -55
  64. package/rollup.config.viz.es5.js +0 -46
  65. package/rollup.config.viz.es6.js +0 -46
  66. package/rollup.config.viz.iife.js +0 -36
  67. package/tutorial_learn_testing.md +0 -168
  68. package/typedoc-options.cjs +0 -69
  69. /package/dist/{es6 → deno}/fsl_parser.d.ts +0 -0
  70. /package/dist/{es6 → deno}/jssm.d.ts +0 -0
  71. /package/dist/{es6 → deno}/jssm_arrow.d.ts +0 -0
  72. /package/dist/{es6 → deno}/jssm_compiler.d.ts +0 -0
  73. /package/dist/{es6 → deno}/jssm_error.d.ts +0 -0
  74. /package/dist/{es6 → deno}/jssm_theme.d.ts +0 -0
  75. /package/dist/{es6 → deno}/jssm_util.d.ts +0 -0
  76. /package/dist/{es6 → deno}/jssm_viz.d.ts +0 -0
  77. /package/dist/{es6 → deno}/jssm_viz_colors.d.ts +0 -0
  78. /package/dist/{es6 → deno}/version.d.ts +0 -0
@@ -1,22 +1,82 @@
1
1
  import { circular_buffer } from 'circular_buffer_js';
2
2
 
3
- declare type StateType$1 = string; /** Composite type composing whether or not a result was successful */
3
+ declare type StateType$1 = string;
4
+ /**
5
+ * A color value accepted by jssm-viz for state and arrow styling. Currently
6
+ * any string, validated downstream by Graphviz / the named-colors list.
7
+ * Intended to be narrowed to `#RRGGBB` / `#RRGGBBAA` and CSS named colors
8
+ * in a future release.
9
+ */
4
10
  declare type JssmColor = string;
11
+ /**
12
+ * Three-state policy flag: `'required'`, `'disallowed'`, or `'optional'`.
13
+ * Used by machine configuration where a default-permissive middle ground
14
+ * is meaningful (for example, the `actions` config key).
15
+ */
5
16
  declare type JssmPermittedOpt = 'required' | 'disallowed' | 'optional';
17
+ /**
18
+ * The set of ASCII arrow tokens recognized by the FSL grammar. Each arrow
19
+ * encodes a direction (one-way left/right, or two-way) and a "kind" for
20
+ * each direction (`-` legal, `=` main path, `~` forced-only). See the
21
+ * Language Reference docs for the full semantic table.
22
+ */
6
23
  declare type JssmArrow = '->' | '<-' | '<->' | '<=->' | '<~->' | '=>' | '<=' | '<=>' | '<-=>' | '<~=>' | '~>' | '<~' | '<~>' | '<-~>' | '<=~>';
7
24
  /**
8
25
  * A type teaching Typescript the various supported shapes for nodes, mostly inherited from GraphViz
9
26
  */
10
27
  declare type JssmShape = "box" | "polygon" | "ellipse" | "oval" | "circle" | "point" | "egg" | "triangle" | "plaintext" | "plain" | "diamond" | "trapezium" | "parallelogram" | "house" | "pentagon" | "hexagon" | "septagon" | "octagon" | "doublecircle" | "doubleoctagon" | "tripleoctagon" | "invtriangle" | "invtrapezium" | "invhouse" | "Mdiamond" | "Msquare" | "Mcircle" | "rect" | "rectangle" | "square" | "star" | "none" | "underline" | "cylinder" | "note" | "tab" | "folder" | "box3d" | "component" | "promoter" | "cds" | "terminator" | "utr" | "primersite" | "restrictionsite" | "fivepoverhang" | "threepoverhang" | "noverhang" | "assembly" | "signature" | "insulator" | "ribosite" | "rnastab" | "proteasesite" | "proteinstab" | "rpromoter" | "rarrow" | "larrow" | "lpromoter" | "record";
28
+ /**
29
+ * Semantic category of an arrow's transition. `'legal'` is a normal
30
+ * transition, `'main'` is part of the machine's primary path, `'forced'`
31
+ * may only be taken via {@link Machine.force_transition}, and `'none'`
32
+ * means no transition exists in that direction.
33
+ */
11
34
  declare type JssmArrowKind = 'none' | 'legal' | 'main' | 'forced';
35
+ /**
36
+ * Graphviz layout engine selector. Controls how jssm-viz lays out the
37
+ * rendered diagram; `'dot'` is the default and most useful for state
38
+ * machines. See the Graphviz documentation for the differences.
39
+ */
12
40
  declare type JssmLayout = 'dot' | 'circo' | 'twopi' | 'fdp' | 'neato';
13
41
  declare type JssmCorner = 'regular' | 'rounded' | 'lined';
14
42
  declare type JssmLineStyle = 'solid' | 'dashed' | 'dotted';
43
+ /**
44
+ * Tristate flag for whether a property may be overridden at runtime.
45
+ * `true` permits overrides, `false` forbids them, and `undefined` defers
46
+ * the decision to the surrounding configuration's default.
47
+ */
15
48
  declare type JssmAllowsOverride = true | false | undefined;
49
+ /**
50
+ * Runtime-iterable list of valid `flow` directions for FSL diagrams.
51
+ * Use this when you need to enumerate directions; for the type itself
52
+ * see {@link FslDirection}.
53
+ */
16
54
  declare const FslDirections: readonly ["up", "right", "down", "left"];
55
+ /**
56
+ * String literal type of the four supported FSL flow directions. This is
57
+ * the type of the `flow` config key on a machine.
58
+ */
17
59
  declare type FslDirection = typeof FslDirections[number];
60
+ /**
61
+ * Runtime-iterable list of the built-in theme names that ship with jssm-viz.
62
+ * Use this when you need to enumerate themes; for the type itself see
63
+ * {@link FslTheme}.
64
+ */
18
65
  declare const FslThemes: readonly ["default", "ocean", "modern", "plain", "bold"];
66
+ /**
67
+ * String literal type of the built-in theme names. This is the element
68
+ * type of the `theme` config key (which accepts an array so that themes
69
+ * can be layered).
70
+ */
19
71
  declare type FslTheme = typeof FslThemes[number];
72
+ /**
73
+ * Persistable snapshot of a Machine produced by {@link Machine.serialize}
74
+ * and consumed by {@link deserialize}. Carries the current state, the
75
+ * associated machine data, the recent history (subject to the configured
76
+ * capacity), and metadata to detect version-skew on rehydration.
77
+ *
78
+ * @typeParam DataType - The type of the user-supplied data payload (`mDT`).
79
+ */
20
80
  declare type JssmSerialization<DataType> = {
21
81
  jssm_version: string;
22
82
  timestamp: number;
@@ -26,6 +86,11 @@ declare type JssmSerialization<DataType> = {
26
86
  history_capacity: number;
27
87
  data: DataType;
28
88
  };
89
+ /**
90
+ * Declaration of a named property that a machine's states may carry.
91
+ * Set `required: true` to force every state to define the property, or
92
+ * provide `default_value` to fall back when the state does not specify it.
93
+ */
29
94
  declare type JssmPropertyDefinition = {
30
95
  name: string;
31
96
  default_value?: any;
@@ -33,6 +98,17 @@ declare type JssmPropertyDefinition = {
33
98
  };
34
99
  declare type JssmTransitionPermitter<DataType> = (OldState: StateType$1, NewState: StateType$1, OldData: DataType, NewData: DataType) => boolean;
35
100
  declare type JssmTransitionPermitterMaybeArray<DataType> = JssmTransitionPermitter<DataType> | Array<JssmTransitionPermitter<DataType>>;
101
+ /**
102
+ * A single directed transition (edge) within a state machine. Captures
103
+ * both the topology (`from` / `to`), the FSL semantics (`kind`,
104
+ * `forced_only`, `main_path`), and any optional metadata such as a
105
+ * per-edge `name`, an action label, a guard `check`, a transition
106
+ * `probability` for stochastic models, and an `after_time` for timed
107
+ * transitions.
108
+ *
109
+ * @typeParam StateType - The state-name type (usually `string`).
110
+ * @typeParam DataType - The machine's data payload type (`mDT`).
111
+ */
36
112
  declare type JssmTransition<StateType, DataType> = {
37
113
  from: StateType;
38
114
  to: StateType;
@@ -46,17 +122,34 @@ declare type JssmTransition<StateType, DataType> = {
46
122
  forced_only: boolean;
47
123
  main_path: boolean;
48
124
  };
125
+ /** A list of {@link JssmTransition}s — the edge set of a machine. */
49
126
  declare type JssmTransitions<StateType, DataType> = JssmTransition<StateType, DataType>[];
127
+ /**
128
+ * The set of states that can immediately precede or follow a given state.
129
+ * Returned by jssm helpers that report a state's connectivity in the graph.
130
+ */
50
131
  declare type JssmTransitionList = {
51
132
  entrances: Array<StateType$1>;
52
133
  exits: Array<StateType$1>;
53
134
  };
135
+ /**
136
+ * Topology record for one node in a compiled machine: its name, the set of
137
+ * states it can be reached from, the set of states it can transition to,
138
+ * and whether reaching it constitutes "completing" the machine.
139
+ */
54
140
  declare type JssmGenericState = {
55
141
  from: Array<StateType$1>;
56
142
  name: StateType$1;
57
143
  to: Array<StateType$1>;
58
144
  complete: boolean;
59
145
  };
146
+ /**
147
+ * The full internal bookkeeping snapshot of a {@link Machine}, exposed for
148
+ * advanced introspection. Contains the current state, the state map, the
149
+ * edge map and reverse-action map, and the original edge list. The
150
+ * `internal_state_impl_version` field exists so that consumers can detect
151
+ * shape changes if this representation evolves.
152
+ */
60
153
  declare type JssmMachineInternalState<DataType> = {
61
154
  internal_state_impl_version: 1;
62
155
  state: StateType$1;
@@ -69,11 +162,21 @@ declare type JssmMachineInternalState<DataType> = {
69
162
  };
70
163
  declare type JssmStatePermitter<DataType> = (OldState: StateType$1, NewState: StateType$1, OldData: DataType, NewData: DataType) => boolean;
71
164
  declare type JssmStatePermitterMaybeArray<DataType> = JssmStatePermitter<DataType> | Array<JssmStatePermitter<DataType>>;
165
+ /**
166
+ * A single key/value pair from an FSL `state X: { ... };` block, in the
167
+ * raw form produced by the parser before being condensed into a
168
+ * {@link JssmStateDeclaration}.
169
+ */
72
170
  declare type JssmStateDeclarationRule = {
73
171
  key: string;
74
172
  value: any;
75
173
  name?: string;
76
174
  };
175
+ /**
176
+ * The fully-condensed declaration for a single state, including its raw
177
+ * rule list (`declarations`) and the well-known styling fields jssm-viz
178
+ * understands. Returned by {@link Machine.state_declaration}.
179
+ */
77
180
  declare type JssmStateDeclaration = {
78
181
  declarations: Array<JssmStateDeclarationRule>;
79
182
  shape?: JssmShape;
@@ -91,6 +194,11 @@ declare type JssmStateDeclaration = {
91
194
  value: unknown;
92
195
  };
93
196
  };
197
+ /**
198
+ * A loosened version of {@link JssmStateDeclaration} where every field is
199
+ * optional. Used as the value type for theme entries and for default
200
+ * state configuration where most fields will be inherited or merged.
201
+ */
94
202
  declare type JssmStateConfig = Partial<JssmStateDeclaration>;
95
203
  declare type JssmStateStyleShape = {
96
204
  key: 'shape';
@@ -128,8 +236,31 @@ declare type JssmStateStyleImage = {
128
236
  key: 'image';
129
237
  value: string;
130
238
  };
239
+ /**
240
+ * Tagged union of all individual style key/value pairs that may appear in
241
+ * a state's style configuration. The `key` discriminator selects which
242
+ * member, and the `value` is typed accordingly.
243
+ */
131
244
  declare type JssmStateStyleKey = JssmStateStyleShape | JssmStateStyleColor | JssmStateStyleTextColor | JssmStateStyleCorners | JssmStateStyleLineStyle | JssmStateStyleBackgroundColor | JssmStateStyleStateLabel | JssmStateStyleBorderColor | JssmStateStyleImage;
245
+ /**
246
+ * An ordered list of {@link JssmStateStyleKey} entries. Used by the
247
+ * `default_*_state_config` machine config options to provide a fallback
248
+ * style stack.
249
+ */
132
250
  declare type JssmStateStyleKeyList = JssmStateStyleKey[];
251
+ /**
252
+ * Full configuration object accepted by the {@link Machine} constructor and
253
+ * by {@link from}. Carries the transition list and the optional knobs
254
+ * governing layout, theming, history, start/end states, property
255
+ * definitions, machine metadata (author, license, version, ...) and the
256
+ * runtime hook surfaces (`time_source`, `timeout_source`, ...).
257
+ *
258
+ * Most users never construct one of these directly — the `sm` tagged
259
+ * template literal and {@link from} produce one from FSL source.
260
+ *
261
+ * @typeParam StateType - The state-name type (usually `string`).
262
+ * @typeParam DataType - The user-supplied data payload type (`mDT`).
263
+ */
133
264
  declare type JssmGenericConfig<StateType, DataType> = {
134
265
  graph_layout?: JssmLayout;
135
266
  complete?: Array<StateType>;
@@ -182,6 +313,15 @@ declare type JssmGenericConfig<StateType, DataType> = {
182
313
  timeout_source?: (Function: any, number: any) => number;
183
314
  clear_timeout_source?: (number: any) => void;
184
315
  };
316
+ /**
317
+ * Internal compiler intermediate: one link in a chained transition
318
+ * expression (an "s-expression" segment). Carries both directions of an
319
+ * arrow with optional per-direction action labels, probabilities, and
320
+ * after-times. The recursive `se` field allows the parser to chain
321
+ * arrows of the form `A -> B -> C`. Not intended for end-user code.
322
+ *
323
+ * @internal
324
+ */
185
325
  declare type JssmCompileSe<StateType, mDT> = {
186
326
  to: StateType;
187
327
  se?: JssmCompileSe<StateType, mDT>;
@@ -310,26 +450,100 @@ declare type PostEverythingHook<mDT> = {
310
450
  kind: 'post everything';
311
451
  handler: PostEverythingHookHandler<mDT>;
312
452
  };
453
+ /**
454
+ * Discriminated union of every kind of hook registration jssm understands,
455
+ * pre-transition and post-transition. The `kind` field selects the
456
+ * variant; remaining fields describe which transitions / states / actions
457
+ * the hook is bound to and supply the {@link HookHandler} or
458
+ * {@link PostHookHandler} to invoke.
459
+ *
460
+ * Pre-transition variants (`'hook'`, `'named'`, `'standard transition'`,
461
+ * `'main transition'`, `'forced transition'`, `'any transition'`,
462
+ * `'global action'`, `'any action'`, `'entry'`, `'exit'`, `'after'`)
463
+ * may return a falsy value to veto a transition. Post-transition
464
+ * variants (`'post *'`) cannot veto and are invoked only after a
465
+ * successful transition.
466
+ */
313
467
  declare type HookDescription<mDT> = BasicHookDescription<mDT> | HookDescriptionWithAction<mDT> | GlobalActionHook<mDT> | AnyActionHook<mDT> | StandardTransitionHook<mDT> | MainTransitionHook<mDT> | ForcedTransitionHook<mDT> | AnyTransitionHook<mDT> | EntryHook<mDT> | ExitHook<mDT> | AfterHook<mDT> | PostBasicHookDescription<mDT> | PostHookDescriptionWithAction<mDT> | PostGlobalActionHook<mDT> | PostAnyActionHook<mDT> | PostStandardTransitionHook<mDT> | PostMainTransitionHook<mDT> | PostForcedTransitionHook<mDT> | PostAnyTransitionHook<mDT> | PostEntryHook<mDT> | PostExitHook<mDT> | PreEverythingHook<mDT> | EverythingHook<mDT> | PrePostEverythingHook<mDT> | PostEverythingHook<mDT>;
468
+ /**
469
+ * Richer hook return value used when a hook needs to do more than just
470
+ * accept or veto a transition. `pass` is the required accept/veto flag
471
+ * (kept non-optional so that returning a stray object doesn't accidentally
472
+ * veto everything). The optional `state` overrides the destination state,
473
+ * `data` overrides the data observed by other hooks in the same chain,
474
+ * and `next_data` overrides the data committed after the transition.
475
+ */
314
476
  declare type HookComplexResult<mDT> = {
315
477
  pass: boolean;
316
478
  state?: StateType$1;
317
479
  data?: mDT;
318
480
  next_data?: mDT;
319
481
  };
320
- declare type HookResult<mDT> = true | false | undefined | void | HookComplexResult<mDT>; /** Documents whether a hook succeeded, either with a primitive or a reference to the hook complex object */
482
+ /**
483
+ * Return value from a {@link HookHandler}. May be a plain boolean to
484
+ * accept (`true`/`undefined`/`void`) or veto (`false`) the transition, or
485
+ * a {@link HookComplexResult} that additionally rewrites the next state
486
+ * and/or the next data payload.
487
+ */
488
+ declare type HookResult<mDT> = true | false | undefined | void | HookComplexResult<mDT>;
489
+ /**
490
+ * Context object passed to every {@link HookHandler}. `data` is the
491
+ * data payload as it stands before the transition, and `next_data` is
492
+ * the payload that will be committed if the transition is accepted —
493
+ * handlers may inspect or mutate the latter via a
494
+ * {@link HookComplexResult} return value.
495
+ */
321
496
  declare type HookContext<mDT> = {
322
497
  data: mDT;
323
498
  next_data: mDT;
324
499
  };
500
+ /**
501
+ * Context object passed to "everything" hooks ({@link EverythingHookHandler}
502
+ * and {@link PostEverythingHookHandler}). Extends the usual
503
+ * {@link HookContext} with `hook_name`, which identifies which specific
504
+ * hook fired so a single handler can route on it.
505
+ */
325
506
  declare type EverythingHookContext<mDT> = HookContext<mDT> & {
326
507
  hook_name: string;
327
508
  };
509
+ /**
510
+ * Signature of a pre-transition hook handler. Receives the current and
511
+ * proposed-next data payloads via a {@link HookContext} and returns a
512
+ * {@link HookResult}: a falsy result vetoes the transition, a truthy
513
+ * result allows it, and a {@link HookComplexResult} can additionally
514
+ * rewrite the next state or next data.
515
+ */
328
516
  declare type HookHandler<mDT> = (hook_context: HookContext<mDT>) => HookResult<mDT>;
517
+ /**
518
+ * Signature of a post-transition hook handler. Invoked after a successful
519
+ * transition has been committed; the return value is ignored (the
520
+ * transition cannot be undone).
521
+ */
329
522
  declare type PostHookHandler<mDT> = (hook_context: HookContext<mDT>) => void;
523
+ /**
524
+ * Signature of an "everything" pre-transition hook handler. Like
525
+ * {@link HookHandler} but receives an {@link EverythingHookContext} so the
526
+ * handler can dispatch on `hook_name`.
527
+ */
330
528
  declare type EverythingHookHandler<mDT> = (hook_context: EverythingHookContext<mDT>) => HookResult<mDT>;
529
+ /**
530
+ * Signature of an "everything" post-transition hook handler. Like
531
+ * {@link PostHookHandler} but receives an {@link EverythingHookContext}.
532
+ * The return value is ignored.
533
+ */
331
534
  declare type PostEverythingHookHandler<mDT> = (hook_context: EverythingHookContext<mDT>) => void;
535
+ /**
536
+ * Bounded history of recently-visited states paired with the data payload
537
+ * observed in each. Backed by `circular_buffer_js`, so the oldest entry
538
+ * is dropped silently once the configured capacity is exceeded.
539
+ */
332
540
  declare type JssmHistory<mDT> = circular_buffer<[StateType$1, mDT]>;
541
+ /**
542
+ * Pluggable random-number-generator function shape. Must return a value
543
+ * in `[0, 1)` exactly as `Math.random` does. Supplied via the
544
+ * `rng_seed`-aware machine configuration so that stochastic models can be
545
+ * made reproducible.
546
+ */
333
547
  declare type JssmRng = () => number;
334
548
 
335
549
  declare const version: string;
package/jssm_viz.es6.d.ts CHANGED
@@ -1,22 +1,82 @@
1
1
  import { circular_buffer } from 'circular_buffer_js';
2
2
 
3
- declare type StateType$1 = string; /** Composite type composing whether or not a result was successful */
3
+ declare type StateType$1 = string;
4
+ /**
5
+ * A color value accepted by jssm-viz for state and arrow styling. Currently
6
+ * any string, validated downstream by Graphviz / the named-colors list.
7
+ * Intended to be narrowed to `#RRGGBB` / `#RRGGBBAA` and CSS named colors
8
+ * in a future release.
9
+ */
4
10
  declare type JssmColor = string;
11
+ /**
12
+ * Three-state policy flag: `'required'`, `'disallowed'`, or `'optional'`.
13
+ * Used by machine configuration where a default-permissive middle ground
14
+ * is meaningful (for example, the `actions` config key).
15
+ */
5
16
  declare type JssmPermittedOpt = 'required' | 'disallowed' | 'optional';
17
+ /**
18
+ * The set of ASCII arrow tokens recognized by the FSL grammar. Each arrow
19
+ * encodes a direction (one-way left/right, or two-way) and a "kind" for
20
+ * each direction (`-` legal, `=` main path, `~` forced-only). See the
21
+ * Language Reference docs for the full semantic table.
22
+ */
6
23
  declare type JssmArrow = '->' | '<-' | '<->' | '<=->' | '<~->' | '=>' | '<=' | '<=>' | '<-=>' | '<~=>' | '~>' | '<~' | '<~>' | '<-~>' | '<=~>';
7
24
  /**
8
25
  * A type teaching Typescript the various supported shapes for nodes, mostly inherited from GraphViz
9
26
  */
10
27
  declare type JssmShape = "box" | "polygon" | "ellipse" | "oval" | "circle" | "point" | "egg" | "triangle" | "plaintext" | "plain" | "diamond" | "trapezium" | "parallelogram" | "house" | "pentagon" | "hexagon" | "septagon" | "octagon" | "doublecircle" | "doubleoctagon" | "tripleoctagon" | "invtriangle" | "invtrapezium" | "invhouse" | "Mdiamond" | "Msquare" | "Mcircle" | "rect" | "rectangle" | "square" | "star" | "none" | "underline" | "cylinder" | "note" | "tab" | "folder" | "box3d" | "component" | "promoter" | "cds" | "terminator" | "utr" | "primersite" | "restrictionsite" | "fivepoverhang" | "threepoverhang" | "noverhang" | "assembly" | "signature" | "insulator" | "ribosite" | "rnastab" | "proteasesite" | "proteinstab" | "rpromoter" | "rarrow" | "larrow" | "lpromoter" | "record";
28
+ /**
29
+ * Semantic category of an arrow's transition. `'legal'` is a normal
30
+ * transition, `'main'` is part of the machine's primary path, `'forced'`
31
+ * may only be taken via {@link Machine.force_transition}, and `'none'`
32
+ * means no transition exists in that direction.
33
+ */
11
34
  declare type JssmArrowKind = 'none' | 'legal' | 'main' | 'forced';
35
+ /**
36
+ * Graphviz layout engine selector. Controls how jssm-viz lays out the
37
+ * rendered diagram; `'dot'` is the default and most useful for state
38
+ * machines. See the Graphviz documentation for the differences.
39
+ */
12
40
  declare type JssmLayout = 'dot' | 'circo' | 'twopi' | 'fdp' | 'neato';
13
41
  declare type JssmCorner = 'regular' | 'rounded' | 'lined';
14
42
  declare type JssmLineStyle = 'solid' | 'dashed' | 'dotted';
43
+ /**
44
+ * Tristate flag for whether a property may be overridden at runtime.
45
+ * `true` permits overrides, `false` forbids them, and `undefined` defers
46
+ * the decision to the surrounding configuration's default.
47
+ */
15
48
  declare type JssmAllowsOverride = true | false | undefined;
49
+ /**
50
+ * Runtime-iterable list of valid `flow` directions for FSL diagrams.
51
+ * Use this when you need to enumerate directions; for the type itself
52
+ * see {@link FslDirection}.
53
+ */
16
54
  declare const FslDirections: readonly ["up", "right", "down", "left"];
55
+ /**
56
+ * String literal type of the four supported FSL flow directions. This is
57
+ * the type of the `flow` config key on a machine.
58
+ */
17
59
  declare type FslDirection = typeof FslDirections[number];
60
+ /**
61
+ * Runtime-iterable list of the built-in theme names that ship with jssm-viz.
62
+ * Use this when you need to enumerate themes; for the type itself see
63
+ * {@link FslTheme}.
64
+ */
18
65
  declare const FslThemes: readonly ["default", "ocean", "modern", "plain", "bold"];
66
+ /**
67
+ * String literal type of the built-in theme names. This is the element
68
+ * type of the `theme` config key (which accepts an array so that themes
69
+ * can be layered).
70
+ */
19
71
  declare type FslTheme = typeof FslThemes[number];
72
+ /**
73
+ * Persistable snapshot of a Machine produced by {@link Machine.serialize}
74
+ * and consumed by {@link deserialize}. Carries the current state, the
75
+ * associated machine data, the recent history (subject to the configured
76
+ * capacity), and metadata to detect version-skew on rehydration.
77
+ *
78
+ * @typeParam DataType - The type of the user-supplied data payload (`mDT`).
79
+ */
20
80
  declare type JssmSerialization<DataType> = {
21
81
  jssm_version: string;
22
82
  timestamp: number;
@@ -26,6 +86,11 @@ declare type JssmSerialization<DataType> = {
26
86
  history_capacity: number;
27
87
  data: DataType;
28
88
  };
89
+ /**
90
+ * Declaration of a named property that a machine's states may carry.
91
+ * Set `required: true` to force every state to define the property, or
92
+ * provide `default_value` to fall back when the state does not specify it.
93
+ */
29
94
  declare type JssmPropertyDefinition = {
30
95
  name: string;
31
96
  default_value?: any;
@@ -33,6 +98,17 @@ declare type JssmPropertyDefinition = {
33
98
  };
34
99
  declare type JssmTransitionPermitter<DataType> = (OldState: StateType$1, NewState: StateType$1, OldData: DataType, NewData: DataType) => boolean;
35
100
  declare type JssmTransitionPermitterMaybeArray<DataType> = JssmTransitionPermitter<DataType> | Array<JssmTransitionPermitter<DataType>>;
101
+ /**
102
+ * A single directed transition (edge) within a state machine. Captures
103
+ * both the topology (`from` / `to`), the FSL semantics (`kind`,
104
+ * `forced_only`, `main_path`), and any optional metadata such as a
105
+ * per-edge `name`, an action label, a guard `check`, a transition
106
+ * `probability` for stochastic models, and an `after_time` for timed
107
+ * transitions.
108
+ *
109
+ * @typeParam StateType - The state-name type (usually `string`).
110
+ * @typeParam DataType - The machine's data payload type (`mDT`).
111
+ */
36
112
  declare type JssmTransition<StateType, DataType> = {
37
113
  from: StateType;
38
114
  to: StateType;
@@ -46,17 +122,34 @@ declare type JssmTransition<StateType, DataType> = {
46
122
  forced_only: boolean;
47
123
  main_path: boolean;
48
124
  };
125
+ /** A list of {@link JssmTransition}s — the edge set of a machine. */
49
126
  declare type JssmTransitions<StateType, DataType> = JssmTransition<StateType, DataType>[];
127
+ /**
128
+ * The set of states that can immediately precede or follow a given state.
129
+ * Returned by jssm helpers that report a state's connectivity in the graph.
130
+ */
50
131
  declare type JssmTransitionList = {
51
132
  entrances: Array<StateType$1>;
52
133
  exits: Array<StateType$1>;
53
134
  };
135
+ /**
136
+ * Topology record for one node in a compiled machine: its name, the set of
137
+ * states it can be reached from, the set of states it can transition to,
138
+ * and whether reaching it constitutes "completing" the machine.
139
+ */
54
140
  declare type JssmGenericState = {
55
141
  from: Array<StateType$1>;
56
142
  name: StateType$1;
57
143
  to: Array<StateType$1>;
58
144
  complete: boolean;
59
145
  };
146
+ /**
147
+ * The full internal bookkeeping snapshot of a {@link Machine}, exposed for
148
+ * advanced introspection. Contains the current state, the state map, the
149
+ * edge map and reverse-action map, and the original edge list. The
150
+ * `internal_state_impl_version` field exists so that consumers can detect
151
+ * shape changes if this representation evolves.
152
+ */
60
153
  declare type JssmMachineInternalState<DataType> = {
61
154
  internal_state_impl_version: 1;
62
155
  state: StateType$1;
@@ -69,11 +162,21 @@ declare type JssmMachineInternalState<DataType> = {
69
162
  };
70
163
  declare type JssmStatePermitter<DataType> = (OldState: StateType$1, NewState: StateType$1, OldData: DataType, NewData: DataType) => boolean;
71
164
  declare type JssmStatePermitterMaybeArray<DataType> = JssmStatePermitter<DataType> | Array<JssmStatePermitter<DataType>>;
165
+ /**
166
+ * A single key/value pair from an FSL `state X: { ... };` block, in the
167
+ * raw form produced by the parser before being condensed into a
168
+ * {@link JssmStateDeclaration}.
169
+ */
72
170
  declare type JssmStateDeclarationRule = {
73
171
  key: string;
74
172
  value: any;
75
173
  name?: string;
76
174
  };
175
+ /**
176
+ * The fully-condensed declaration for a single state, including its raw
177
+ * rule list (`declarations`) and the well-known styling fields jssm-viz
178
+ * understands. Returned by {@link Machine.state_declaration}.
179
+ */
77
180
  declare type JssmStateDeclaration = {
78
181
  declarations: Array<JssmStateDeclarationRule>;
79
182
  shape?: JssmShape;
@@ -91,6 +194,11 @@ declare type JssmStateDeclaration = {
91
194
  value: unknown;
92
195
  };
93
196
  };
197
+ /**
198
+ * A loosened version of {@link JssmStateDeclaration} where every field is
199
+ * optional. Used as the value type for theme entries and for default
200
+ * state configuration where most fields will be inherited or merged.
201
+ */
94
202
  declare type JssmStateConfig = Partial<JssmStateDeclaration>;
95
203
  declare type JssmStateStyleShape = {
96
204
  key: 'shape';
@@ -128,8 +236,31 @@ declare type JssmStateStyleImage = {
128
236
  key: 'image';
129
237
  value: string;
130
238
  };
239
+ /**
240
+ * Tagged union of all individual style key/value pairs that may appear in
241
+ * a state's style configuration. The `key` discriminator selects which
242
+ * member, and the `value` is typed accordingly.
243
+ */
131
244
  declare type JssmStateStyleKey = JssmStateStyleShape | JssmStateStyleColor | JssmStateStyleTextColor | JssmStateStyleCorners | JssmStateStyleLineStyle | JssmStateStyleBackgroundColor | JssmStateStyleStateLabel | JssmStateStyleBorderColor | JssmStateStyleImage;
245
+ /**
246
+ * An ordered list of {@link JssmStateStyleKey} entries. Used by the
247
+ * `default_*_state_config` machine config options to provide a fallback
248
+ * style stack.
249
+ */
132
250
  declare type JssmStateStyleKeyList = JssmStateStyleKey[];
251
+ /**
252
+ * Full configuration object accepted by the {@link Machine} constructor and
253
+ * by {@link from}. Carries the transition list and the optional knobs
254
+ * governing layout, theming, history, start/end states, property
255
+ * definitions, machine metadata (author, license, version, ...) and the
256
+ * runtime hook surfaces (`time_source`, `timeout_source`, ...).
257
+ *
258
+ * Most users never construct one of these directly — the `sm` tagged
259
+ * template literal and {@link from} produce one from FSL source.
260
+ *
261
+ * @typeParam StateType - The state-name type (usually `string`).
262
+ * @typeParam DataType - The user-supplied data payload type (`mDT`).
263
+ */
133
264
  declare type JssmGenericConfig<StateType, DataType> = {
134
265
  graph_layout?: JssmLayout;
135
266
  complete?: Array<StateType>;
@@ -182,6 +313,15 @@ declare type JssmGenericConfig<StateType, DataType> = {
182
313
  timeout_source?: (Function: any, number: any) => number;
183
314
  clear_timeout_source?: (number: any) => void;
184
315
  };
316
+ /**
317
+ * Internal compiler intermediate: one link in a chained transition
318
+ * expression (an "s-expression" segment). Carries both directions of an
319
+ * arrow with optional per-direction action labels, probabilities, and
320
+ * after-times. The recursive `se` field allows the parser to chain
321
+ * arrows of the form `A -> B -> C`. Not intended for end-user code.
322
+ *
323
+ * @internal
324
+ */
185
325
  declare type JssmCompileSe<StateType, mDT> = {
186
326
  to: StateType;
187
327
  se?: JssmCompileSe<StateType, mDT>;
@@ -310,26 +450,100 @@ declare type PostEverythingHook<mDT> = {
310
450
  kind: 'post everything';
311
451
  handler: PostEverythingHookHandler<mDT>;
312
452
  };
453
+ /**
454
+ * Discriminated union of every kind of hook registration jssm understands,
455
+ * pre-transition and post-transition. The `kind` field selects the
456
+ * variant; remaining fields describe which transitions / states / actions
457
+ * the hook is bound to and supply the {@link HookHandler} or
458
+ * {@link PostHookHandler} to invoke.
459
+ *
460
+ * Pre-transition variants (`'hook'`, `'named'`, `'standard transition'`,
461
+ * `'main transition'`, `'forced transition'`, `'any transition'`,
462
+ * `'global action'`, `'any action'`, `'entry'`, `'exit'`, `'after'`)
463
+ * may return a falsy value to veto a transition. Post-transition
464
+ * variants (`'post *'`) cannot veto and are invoked only after a
465
+ * successful transition.
466
+ */
313
467
  declare type HookDescription<mDT> = BasicHookDescription<mDT> | HookDescriptionWithAction<mDT> | GlobalActionHook<mDT> | AnyActionHook<mDT> | StandardTransitionHook<mDT> | MainTransitionHook<mDT> | ForcedTransitionHook<mDT> | AnyTransitionHook<mDT> | EntryHook<mDT> | ExitHook<mDT> | AfterHook<mDT> | PostBasicHookDescription<mDT> | PostHookDescriptionWithAction<mDT> | PostGlobalActionHook<mDT> | PostAnyActionHook<mDT> | PostStandardTransitionHook<mDT> | PostMainTransitionHook<mDT> | PostForcedTransitionHook<mDT> | PostAnyTransitionHook<mDT> | PostEntryHook<mDT> | PostExitHook<mDT> | PreEverythingHook<mDT> | EverythingHook<mDT> | PrePostEverythingHook<mDT> | PostEverythingHook<mDT>;
468
+ /**
469
+ * Richer hook return value used when a hook needs to do more than just
470
+ * accept or veto a transition. `pass` is the required accept/veto flag
471
+ * (kept non-optional so that returning a stray object doesn't accidentally
472
+ * veto everything). The optional `state` overrides the destination state,
473
+ * `data` overrides the data observed by other hooks in the same chain,
474
+ * and `next_data` overrides the data committed after the transition.
475
+ */
314
476
  declare type HookComplexResult<mDT> = {
315
477
  pass: boolean;
316
478
  state?: StateType$1;
317
479
  data?: mDT;
318
480
  next_data?: mDT;
319
481
  };
320
- declare type HookResult<mDT> = true | false | undefined | void | HookComplexResult<mDT>; /** Documents whether a hook succeeded, either with a primitive or a reference to the hook complex object */
482
+ /**
483
+ * Return value from a {@link HookHandler}. May be a plain boolean to
484
+ * accept (`true`/`undefined`/`void`) or veto (`false`) the transition, or
485
+ * a {@link HookComplexResult} that additionally rewrites the next state
486
+ * and/or the next data payload.
487
+ */
488
+ declare type HookResult<mDT> = true | false | undefined | void | HookComplexResult<mDT>;
489
+ /**
490
+ * Context object passed to every {@link HookHandler}. `data` is the
491
+ * data payload as it stands before the transition, and `next_data` is
492
+ * the payload that will be committed if the transition is accepted —
493
+ * handlers may inspect or mutate the latter via a
494
+ * {@link HookComplexResult} return value.
495
+ */
321
496
  declare type HookContext<mDT> = {
322
497
  data: mDT;
323
498
  next_data: mDT;
324
499
  };
500
+ /**
501
+ * Context object passed to "everything" hooks ({@link EverythingHookHandler}
502
+ * and {@link PostEverythingHookHandler}). Extends the usual
503
+ * {@link HookContext} with `hook_name`, which identifies which specific
504
+ * hook fired so a single handler can route on it.
505
+ */
325
506
  declare type EverythingHookContext<mDT> = HookContext<mDT> & {
326
507
  hook_name: string;
327
508
  };
509
+ /**
510
+ * Signature of a pre-transition hook handler. Receives the current and
511
+ * proposed-next data payloads via a {@link HookContext} and returns a
512
+ * {@link HookResult}: a falsy result vetoes the transition, a truthy
513
+ * result allows it, and a {@link HookComplexResult} can additionally
514
+ * rewrite the next state or next data.
515
+ */
328
516
  declare type HookHandler<mDT> = (hook_context: HookContext<mDT>) => HookResult<mDT>;
517
+ /**
518
+ * Signature of a post-transition hook handler. Invoked after a successful
519
+ * transition has been committed; the return value is ignored (the
520
+ * transition cannot be undone).
521
+ */
329
522
  declare type PostHookHandler<mDT> = (hook_context: HookContext<mDT>) => void;
523
+ /**
524
+ * Signature of an "everything" pre-transition hook handler. Like
525
+ * {@link HookHandler} but receives an {@link EverythingHookContext} so the
526
+ * handler can dispatch on `hook_name`.
527
+ */
330
528
  declare type EverythingHookHandler<mDT> = (hook_context: EverythingHookContext<mDT>) => HookResult<mDT>;
529
+ /**
530
+ * Signature of an "everything" post-transition hook handler. Like
531
+ * {@link PostHookHandler} but receives an {@link EverythingHookContext}.
532
+ * The return value is ignored.
533
+ */
331
534
  declare type PostEverythingHookHandler<mDT> = (hook_context: EverythingHookContext<mDT>) => void;
535
+ /**
536
+ * Bounded history of recently-visited states paired with the data payload
537
+ * observed in each. Backed by `circular_buffer_js`, so the oldest entry
538
+ * is dropped silently once the configured capacity is exceeded.
539
+ */
332
540
  declare type JssmHistory<mDT> = circular_buffer<[StateType$1, mDT]>;
541
+ /**
542
+ * Pluggable random-number-generator function shape. Must return a value
543
+ * in `[0, 1)` exactly as `Math.random` does. Supplied via the
544
+ * `rng_seed`-aware machine configuration so that stochastic models can be
545
+ * made reproducible.
546
+ */
333
547
  declare type JssmRng = () => number;
334
548
 
335
549
  declare const version: string;