jssm 5.99.0 → 5.100.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.
package/jssm.es6.d.ts ADDED
@@ -0,0 +1,1767 @@
1
+ import { circular_buffer } from 'circular_buffer_js';
2
+
3
+ declare type StateType$1 = string; /** Composite type composing whether or not a result was successful */
4
+ declare type JssmColor = string;
5
+ declare type JssmPermittedOpt = 'required' | 'disallowed' | 'optional';
6
+ declare type JssmArrow = '->' | '<-' | '<->' | '<=->' | '<~->' | '=>' | '<=' | '<=>' | '<-=>' | '<~=>' | '~>' | '<~' | '<~>' | '<-~>' | '<=~>';
7
+ /**
8
+ * A type teaching Typescript the various supported shapes for nodes, mostly inherited from GraphViz
9
+ */
10
+ 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";
11
+ declare type JssmArrowDirection = 'left' | 'right' | 'both';
12
+ declare type JssmArrowKind = 'none' | 'legal' | 'main' | 'forced';
13
+ declare type JssmLayout = 'dot' | 'circo' | 'twopi' | 'fdp' | 'neato';
14
+ declare type JssmCorner = 'regular' | 'rounded' | 'lined';
15
+ declare type JssmLineStyle = 'solid' | 'dashed' | 'dotted';
16
+ declare type JssmAllowsOverride = true | false | undefined;
17
+ declare const FslDirections: readonly ["up", "right", "down", "left"];
18
+ declare type FslDirection = typeof FslDirections[number];
19
+ declare const FslThemes: readonly ["default", "ocean", "modern", "plain", "bold"];
20
+ declare type FslTheme = typeof FslThemes[number];
21
+ declare type JssmSerialization<DataType> = {
22
+ jssm_version: string;
23
+ timestamp: number;
24
+ comment?: string | undefined;
25
+ state: StateType$1;
26
+ history: [string, DataType][];
27
+ history_capacity: number;
28
+ data: DataType;
29
+ };
30
+ declare type JssmPropertyDefinition = {
31
+ name: string;
32
+ default_value?: any;
33
+ required?: boolean;
34
+ };
35
+ declare type JssmTransitionPermitter<DataType> = (OldState: StateType$1, NewState: StateType$1, OldData: DataType, NewData: DataType) => boolean;
36
+ declare type JssmTransitionPermitterMaybeArray<DataType> = JssmTransitionPermitter<DataType> | Array<JssmTransitionPermitter<DataType>>;
37
+ declare type JssmTransition<StateType, DataType> = {
38
+ from: StateType;
39
+ to: StateType;
40
+ after_time?: number;
41
+ se?: JssmCompileSe<StateType, DataType>;
42
+ name?: StateType;
43
+ action?: StateType;
44
+ check?: JssmTransitionPermitterMaybeArray<DataType>;
45
+ probability?: number;
46
+ kind: JssmArrowKind;
47
+ forced_only: boolean;
48
+ main_path: boolean;
49
+ };
50
+ declare type JssmTransitions<StateType, DataType> = JssmTransition<StateType, DataType>[];
51
+ declare type JssmTransitionList = {
52
+ entrances: Array<StateType$1>;
53
+ exits: Array<StateType$1>;
54
+ };
55
+ declare type JssmGenericState = {
56
+ from: Array<StateType$1>;
57
+ name: StateType$1;
58
+ to: Array<StateType$1>;
59
+ complete: boolean;
60
+ };
61
+ declare type JssmMachineInternalState<DataType> = {
62
+ internal_state_impl_version: 1;
63
+ state: StateType$1;
64
+ states: Map<StateType$1, JssmGenericState>;
65
+ named_transitions: Map<StateType$1, number>;
66
+ edge_map: Map<StateType$1, Map<StateType$1, number>>;
67
+ actions: Map<StateType$1, Map<StateType$1, number>>;
68
+ reverse_actions: Map<StateType$1, Map<StateType$1, number>>;
69
+ edges: Array<JssmTransition<StateType$1, DataType>>;
70
+ };
71
+ declare type JssmStatePermitter<DataType> = (OldState: StateType$1, NewState: StateType$1, OldData: DataType, NewData: DataType) => boolean;
72
+ declare type JssmStatePermitterMaybeArray<DataType> = JssmStatePermitter<DataType> | Array<JssmStatePermitter<DataType>>;
73
+ declare type JssmStateDeclarationRule = {
74
+ key: string;
75
+ value: any;
76
+ name?: string;
77
+ };
78
+ declare type JssmStateDeclaration = {
79
+ declarations: Array<JssmStateDeclarationRule>;
80
+ shape?: JssmShape;
81
+ color?: JssmColor;
82
+ corners?: JssmCorner;
83
+ lineStyle?: JssmLineStyle;
84
+ stateLabel?: string;
85
+ textColor?: JssmColor;
86
+ backgroundColor?: JssmColor;
87
+ borderColor?: JssmColor;
88
+ state: StateType$1;
89
+ property?: {
90
+ name: string;
91
+ value: unknown;
92
+ };
93
+ };
94
+ declare type JssmStateConfig = Partial<JssmStateDeclaration>;
95
+ declare type JssmStateStyleShape = {
96
+ key: 'shape';
97
+ value: JssmShape;
98
+ };
99
+ declare type JssmStateStyleColor = {
100
+ key: 'color';
101
+ value: JssmColor;
102
+ };
103
+ declare type JssmStateStyleTextColor = {
104
+ key: 'text-color';
105
+ value: JssmColor;
106
+ };
107
+ declare type JssmStateStyleCorners = {
108
+ key: 'corners';
109
+ value: JssmCorner;
110
+ };
111
+ declare type JssmStateStyleLineStyle = {
112
+ key: 'line-style';
113
+ value: JssmLineStyle;
114
+ };
115
+ declare type JssmStateStyleStateLabel = {
116
+ key: 'state-label';
117
+ value: string;
118
+ };
119
+ declare type JssmStateStyleBackgroundColor = {
120
+ key: 'background-color';
121
+ value: JssmColor;
122
+ };
123
+ declare type JssmStateStyleBorderColor = {
124
+ key: 'border-color';
125
+ value: JssmColor;
126
+ };
127
+ declare type JssmStateStyleKey = JssmStateStyleShape | JssmStateStyleColor | JssmStateStyleTextColor | JssmStateStyleCorners | JssmStateStyleLineStyle | JssmStateStyleBackgroundColor | JssmStateStyleStateLabel | JssmStateStyleBorderColor;
128
+ declare type JssmStateStyleKeyList = JssmStateStyleKey[];
129
+ declare type JssmGenericConfig<StateType, DataType> = {
130
+ graph_layout?: JssmLayout;
131
+ complete?: Array<StateType>;
132
+ transitions: JssmTransitions<StateType, DataType>;
133
+ theme?: FslTheme[];
134
+ flow?: FslDirection;
135
+ name?: string;
136
+ data?: DataType;
137
+ nodes?: Array<StateType>;
138
+ check?: JssmStatePermitterMaybeArray<DataType>;
139
+ history?: number;
140
+ min_exits?: number;
141
+ max_exits?: number;
142
+ allow_islands?: false;
143
+ allow_force?: false;
144
+ actions?: JssmPermittedOpt;
145
+ simplify_bidi?: boolean;
146
+ allows_override?: JssmAllowsOverride;
147
+ config_allows_override?: JssmAllowsOverride;
148
+ dot_preamble?: string;
149
+ start_states: Array<StateType>;
150
+ end_states?: Array<StateType>;
151
+ initial_state?: StateType;
152
+ start_states_no_enforce?: boolean;
153
+ state_declaration?: Object[];
154
+ property_definition?: JssmPropertyDefinition[];
155
+ state_property?: JssmPropertyDefinition[];
156
+ arrange_declaration?: Array<Array<StateType>>;
157
+ arrange_start_declaration?: Array<Array<StateType>>;
158
+ arrange_end_declaration?: Array<Array<StateType>>;
159
+ machine_author?: string | Array<string>;
160
+ machine_comment?: string;
161
+ machine_contributor?: string | Array<string>;
162
+ machine_definition?: string;
163
+ machine_language?: string;
164
+ machine_license?: string;
165
+ machine_name?: string;
166
+ machine_version?: string;
167
+ fsl_version?: string;
168
+ auto_api?: boolean | string;
169
+ instance_name?: string | undefined;
170
+ default_state_config?: JssmStateStyleKeyList;
171
+ default_start_state_config?: JssmStateStyleKeyList;
172
+ default_end_state_config?: JssmStateStyleKeyList;
173
+ default_hooked_state_config?: JssmStateStyleKeyList;
174
+ default_terminal_state_config?: JssmStateStyleKeyList;
175
+ default_active_state_config?: JssmStateStyleKeyList;
176
+ rng_seed?: number | undefined;
177
+ time_source?: () => number;
178
+ timeout_source?: (Function: any, number: any) => number;
179
+ clear_timeout_source?: (number: any) => void;
180
+ };
181
+ declare type JssmCompileSe<StateType, mDT> = {
182
+ to: StateType;
183
+ se?: JssmCompileSe<StateType, mDT>;
184
+ kind: JssmArrow;
185
+ l_action?: StateType;
186
+ r_action?: StateType;
187
+ l_probability: number;
188
+ r_probability: number;
189
+ l_after?: number;
190
+ r_after?: number;
191
+ };
192
+ declare type JssmCompileSeStart<StateType, DataType> = {
193
+ from: StateType;
194
+ se: JssmCompileSe<StateType, DataType>;
195
+ key: string;
196
+ value?: string | number;
197
+ name?: string;
198
+ state?: string;
199
+ default_value?: any;
200
+ required?: boolean;
201
+ };
202
+ declare type JssmParseTree<StateType, mDT> = Array<JssmCompileSeStart<StateType, mDT>>;
203
+ declare type BasicHookDescription<mDT> = {
204
+ kind: 'hook';
205
+ from: string;
206
+ to: string;
207
+ handler: HookHandler<mDT>;
208
+ };
209
+ declare type HookDescriptionWithAction<mDT> = {
210
+ kind: 'named';
211
+ from: string;
212
+ to: string;
213
+ action: string;
214
+ handler: HookHandler<mDT>;
215
+ };
216
+ declare type StandardTransitionHook<mDT> = {
217
+ kind: 'standard transition';
218
+ handler: HookHandler<mDT>;
219
+ };
220
+ declare type MainTransitionHook<mDT> = {
221
+ kind: 'main transition';
222
+ handler: HookHandler<mDT>;
223
+ };
224
+ declare type ForcedTransitionHook<mDT> = {
225
+ kind: 'forced transition';
226
+ handler: HookHandler<mDT>;
227
+ };
228
+ declare type AnyTransitionHook<mDT> = {
229
+ kind: 'any transition';
230
+ handler: HookHandler<mDT>;
231
+ };
232
+ declare type GlobalActionHook<mDT> = {
233
+ kind: 'global action';
234
+ action: string;
235
+ handler: HookHandler<mDT>;
236
+ };
237
+ declare type AnyActionHook<mDT> = {
238
+ kind: 'any action';
239
+ handler: HookHandler<mDT>;
240
+ };
241
+ declare type EntryHook<mDT> = {
242
+ kind: 'entry';
243
+ to: string;
244
+ handler: HookHandler<mDT>;
245
+ };
246
+ declare type ExitHook<mDT> = {
247
+ kind: 'exit';
248
+ from: string;
249
+ handler: HookHandler<mDT>;
250
+ };
251
+ declare type AfterHook<mDT> = {
252
+ kind: 'after';
253
+ from: string;
254
+ handler: HookHandler<mDT>;
255
+ };
256
+ declare type PostBasicHookDescription<mDT> = {
257
+ kind: 'post hook';
258
+ from: string;
259
+ to: string;
260
+ handler: PostHookHandler<mDT>;
261
+ };
262
+ declare type PostHookDescriptionWithAction<mDT> = {
263
+ kind: 'post named';
264
+ from: string;
265
+ to: string;
266
+ action: string;
267
+ handler: PostHookHandler<mDT>;
268
+ };
269
+ declare type PostStandardTransitionHook<mDT> = {
270
+ kind: 'post standard transition';
271
+ handler: PostHookHandler<mDT>;
272
+ };
273
+ declare type PostMainTransitionHook<mDT> = {
274
+ kind: 'post main transition';
275
+ handler: PostHookHandler<mDT>;
276
+ };
277
+ declare type PostForcedTransitionHook<mDT> = {
278
+ kind: 'post forced transition';
279
+ handler: PostHookHandler<mDT>;
280
+ };
281
+ declare type PostAnyTransitionHook<mDT> = {
282
+ kind: 'post any transition';
283
+ handler: PostHookHandler<mDT>;
284
+ };
285
+ declare type PostGlobalActionHook<mDT> = {
286
+ kind: 'post global action';
287
+ action: string;
288
+ handler: PostHookHandler<mDT>;
289
+ };
290
+ declare type PostAnyActionHook<mDT> = {
291
+ kind: 'post any action';
292
+ handler: PostHookHandler<mDT>;
293
+ };
294
+ declare type PostEntryHook<mDT> = {
295
+ kind: 'post entry';
296
+ to: string;
297
+ handler: PostHookHandler<mDT>;
298
+ };
299
+ declare type PostExitHook<mDT> = {
300
+ kind: 'post exit';
301
+ from: string;
302
+ handler: PostHookHandler<mDT>;
303
+ };
304
+ 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>;
305
+ declare type HookComplexResult<mDT> = {
306
+ pass: boolean;
307
+ state?: StateType$1;
308
+ data?: mDT;
309
+ next_data?: mDT;
310
+ };
311
+ 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 */
312
+ declare type HookContext<mDT> = {
313
+ data: mDT;
314
+ next_data: mDT;
315
+ };
316
+ declare type HookHandler<mDT> = (hook_context: HookContext<mDT>) => HookResult<mDT>;
317
+ declare type PostHookHandler<mDT> = (hook_context: HookContext<mDT>) => void;
318
+ declare type JssmHistory<mDT> = circular_buffer<[StateType$1, mDT]>;
319
+ declare type JssmRng = () => number;
320
+
321
+ /*********
322
+ *
323
+ * Return the direction of an arrow - `right`, `left`, or `both`.
324
+ *
325
+ * ```typescript
326
+ * import { arrow_direction } from 'jssm';
327
+ *
328
+ * arrow_direction('->'); // 'right'
329
+ * arrow_direction('<~=>'); // 'both'
330
+ * ```
331
+ *
332
+ * @param arrow The arrow to be evaluated
333
+ *
334
+ */
335
+ declare function arrow_direction(arrow: JssmArrow): JssmArrowDirection;
336
+ /*********
337
+ *
338
+ * Return the direction of an arrow - `right`, `left`, or `both`.
339
+ *
340
+ * ```typescript
341
+ * import { arrow_left_kind } from 'jssm';
342
+ *
343
+ * arrow_left_kind('<-'); // 'legal'
344
+ * arrow_left_kind('<='); // 'main'
345
+ * arrow_left_kind('<~'); // 'forced'
346
+ * arrow_left_kind('<->'); // 'legal'
347
+ * arrow_left_kind('->'); // 'none'
348
+ * ```
349
+ *
350
+ * @param arrow The arrow to be evaluated
351
+ *
352
+ */
353
+ declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
354
+ /*********
355
+ *
356
+ * Return the direction of an arrow - `right`, `left`, or `both`.
357
+ *
358
+ * ```typescript
359
+ * import { arrow_left_kind } from 'jssm';
360
+ *
361
+ * arrow_left_kind('->'); // 'legal'
362
+ * arrow_left_kind('=>'); // 'main'
363
+ * arrow_left_kind('~>'); // 'forced'
364
+ * arrow_left_kind('<->'); // 'legal'
365
+ * arrow_left_kind('<-'); // 'none'
366
+ * ```
367
+ *
368
+ * @param arrow The arrow to be evaluated
369
+ *
370
+ */
371
+ declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
372
+
373
+ /*********
374
+ *
375
+ * This method wraps the parser call that comes from the peg grammar,
376
+ * {@link parse}. Generally neither this nor that should be used directly
377
+ * unless you mean to develop plugins or extensions for the machine.
378
+ *
379
+ * Parses the intermediate representation of a compiled string down to a
380
+ * machine configuration object. If you're using this (probably don't,) you're
381
+ * probably also using {@link compile} and {@link Machine.constructor}.
382
+ *
383
+ * ```typescript
384
+ * import { parse, compile, Machine } from 'jssm';
385
+ *
386
+ * const intermediate = wrap_parse('a -> b;', {});
387
+ * // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
388
+ *
389
+ * const cfg = compile(intermediate);
390
+ * // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
391
+ *
392
+ * const machine = new Machine(cfg);
393
+ * // Machine { _instance_name: undefined, _state: 'a', ...
394
+ * ```
395
+ *
396
+ * This method is mostly for plugin and intermediate tool authors, or people
397
+ * who need to work with the machine's intermediate representation.
398
+ *
399
+ * # Hey!
400
+ *
401
+ * Most people looking at this want either the `sm` operator or method `from`,
402
+ * which perform all the steps in the chain. The library's author mostly uses
403
+ * operator `sm`, and mostly falls back to `.from` when needing to parse
404
+ * strings dynamically instead of from template literals.
405
+ *
406
+ * Operator {@link sm}:
407
+ *
408
+ * ```typescript
409
+ * import { sm } from 'jssm';
410
+ *
411
+ * const lswitch = sm`on <=> off;`;
412
+ * ```
413
+ *
414
+ * Method {@link from}:
415
+ *
416
+ * ```typescript
417
+ * import * as jssm from 'jssm';
418
+ *
419
+ * const toggle = jssm.from('up <=> down;');
420
+ * ```
421
+ *
422
+ * `wrap_parse` itself is an internal convenience method for alting out an
423
+ * object as the options call. Not generally meant for external use.
424
+ *
425
+ * @param input The FSL code to be evaluated
426
+ *
427
+ * @param options Things to control about the instance
428
+ *
429
+ */
430
+ declare function wrap_parse(input: string, options?: Object): any;
431
+ /*********
432
+ *
433
+ * Compile a machine's JSON intermediate representation to a config object. If
434
+ * you're using this (probably don't,) you're probably also using
435
+ * {@link parse} to get the IR, and the object constructor
436
+ * {@link Machine.construct} to turn the config object into a workable machine.
437
+ *
438
+ * ```typescript
439
+ * import { parse, compile, Machine } from 'jssm';
440
+ *
441
+ * const intermediate = parse('a -> b;');
442
+ * // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
443
+ *
444
+ * const cfg = compile(intermediate);
445
+ * // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
446
+ *
447
+ * const machine = new Machine(cfg);
448
+ * // Machine { _instance_name: undefined, _state: 'a', ...
449
+ * ```
450
+ *
451
+ * This method is mostly for plugin and intermediate tool authors, or people
452
+ * who need to work with the machine's intermediate representation.
453
+ *
454
+ * # Hey!
455
+ *
456
+ * Most people looking at this want either the `sm` operator or method `from`,
457
+ * which perform all the steps in the chain. The library's author mostly uses
458
+ * operator `sm`, and mostly falls back to `.from` when needing to parse
459
+ * strings dynamically instead of from template literals.
460
+ *
461
+ * Operator {@link sm}:
462
+ *
463
+ * ```typescript
464
+ * import { sm } from 'jssm';
465
+ *
466
+ * const lswitch = sm`on <=> off;`;
467
+ * ```
468
+ *
469
+ * Method {@link from}:
470
+ *
471
+ * ```typescript
472
+ * import * as jssm from 'jssm';
473
+ *
474
+ * const toggle = jssm.from('up <=> down;');
475
+ * ```
476
+ *
477
+ * @typeparam mDT The type of the machine data member; usually omitted
478
+ *
479
+ * @param tree The parse tree to be boiled down into a machine config
480
+ *
481
+ */
482
+ declare function compile<StateType, mDT>(tree: JssmParseTree<StateType, mDT>): JssmGenericConfig<StateType, mDT>;
483
+ /*********
484
+ *
485
+ * An internal convenience wrapper for parsing then compiling a machine string.
486
+ * Not generally meant for external use. Please see {@link compile} or
487
+ * {@link sm}.
488
+ *
489
+ * @typeparam mDT The type of the machine data member; usually omitted
490
+ *
491
+ * @param plan The FSL code to be evaluated and built into a machine config
492
+ *
493
+ */
494
+ declare function make<StateType, mDT>(plan: string): JssmGenericConfig<StateType, mDT>;
495
+
496
+ declare const weighted_rand_select: Function;
497
+ /*******
498
+ *
499
+ * Returns, for a non-negative integer argument `n`, the series `[0 .. n]`.
500
+ *
501
+ * ```typescript
502
+ * import { seq } from './jssm';
503
+ *
504
+ * seq(5); // [0, 1, 2, 3, 4]
505
+ * seq(0); // []
506
+ * ```
507
+ *
508
+ */
509
+ declare function seq(n: number): number[];
510
+ /*******
511
+ *
512
+ * Returns the histograph of an array as a `Map`. Makes no attempt to cope
513
+ * with deep equality; will fail for complex contents, as such.
514
+ *
515
+ * ```typescript
516
+ * import { histograph } from './jssm';
517
+ *
518
+ * histograph( [0, 0, 1, 1, 2, 2, 1] ); // Map()
519
+ * ```
520
+ *
521
+ */
522
+ declare const histograph: Function;
523
+ declare const weighted_sample_select: Function;
524
+ declare const weighted_histo_key: Function;
525
+ /*******
526
+ *
527
+ * Reduces an array to its unique contents. Compares with `===` and makes no
528
+ * effort to deep-compare contents; two matching arrays or objects contained
529
+ * will be treated as distinct, according to javascript rules. This also means
530
+ * that `NaNs` will be ***dropped***, because they do not self-compare.
531
+ *
532
+ * ```typescript
533
+ * unique( [] ); // []
534
+ * unique( [0,0] ); // [0]
535
+ * unique( [0,1,2, 0,1,2, 0,1,2] ); // [0,1,2]
536
+ * unique( [ [1], [1] ] ); // [ [1], [1] ] because arrays don't match
537
+ * unique( [0,NaN,2] ); // [0,2]
538
+ * ```
539
+ *
540
+ */
541
+ declare const unique: <T>(arr?: T[]) => T[];
542
+ /*******
543
+ *
544
+ * Lists all repeated items in an array along with their counts. Subject to
545
+ * matching rules of Map. `NaN` is manually removed because of conflict rules
546
+ * around {@link unique}. Because these are compared with `===` and because
547
+ * arrays and objects never match that way unless they're the same object,
548
+ * arrays and objects are never considered repeats.
549
+ *
550
+ * ```typescript
551
+ * find_repeated<string>([ ]); // []
552
+ * find_repeated<string>([ "one" ]); // []
553
+ * find_repeated<string>([ "one", "two" ]); // []
554
+ * find_repeated<string>([ "one", "one" ]); // [ ["one", 2] ]
555
+ * find_repeated<string>([ "one", "two", "one" ]); // [ ["one", 2] ]
556
+ * find_repeated<number>([ 0, NaN, 0, NaN ]); // [ [0, 2] ]
557
+ * ```
558
+ *
559
+ */
560
+ declare function find_repeated<T>(arr: T[]): [T, number][];
561
+ declare function sleep(ms: number): Promise<unknown>;
562
+
563
+ declare const NegInfinity: number;
564
+ declare const PosInfinity: number;
565
+ declare const Epsilon: number;
566
+ declare const Pi: number;
567
+ declare const E: number;
568
+ declare const Root2: number;
569
+ declare const RootHalf: number;
570
+ declare const Ln2: number;
571
+ declare const Ln10: number;
572
+ declare const Log2E: number;
573
+ declare const Log10E: number;
574
+ declare const MaxSafeInt: number;
575
+ declare const MinSafeInt: number;
576
+ declare const MaxPosNum: number;
577
+ declare const MinPosNum: number;
578
+ declare const Phi = 1.618033988749895;
579
+ declare const EulerC = 0.5772156649015329;
580
+ declare const gviz_shapes$1: string[];
581
+ declare const shapes$1: string[];
582
+ declare const named_colors$1: string[];
583
+
584
+ declare const jssm_constants_d_NegInfinity: typeof NegInfinity;
585
+ declare const jssm_constants_d_PosInfinity: typeof PosInfinity;
586
+ declare const jssm_constants_d_Epsilon: typeof Epsilon;
587
+ declare const jssm_constants_d_Pi: typeof Pi;
588
+ declare const jssm_constants_d_E: typeof E;
589
+ declare const jssm_constants_d_Root2: typeof Root2;
590
+ declare const jssm_constants_d_RootHalf: typeof RootHalf;
591
+ declare const jssm_constants_d_Ln2: typeof Ln2;
592
+ declare const jssm_constants_d_Ln10: typeof Ln10;
593
+ declare const jssm_constants_d_Log2E: typeof Log2E;
594
+ declare const jssm_constants_d_Log10E: typeof Log10E;
595
+ declare const jssm_constants_d_MaxSafeInt: typeof MaxSafeInt;
596
+ declare const jssm_constants_d_MinSafeInt: typeof MinSafeInt;
597
+ declare const jssm_constants_d_MaxPosNum: typeof MaxPosNum;
598
+ declare const jssm_constants_d_MinPosNum: typeof MinPosNum;
599
+ declare const jssm_constants_d_Phi: typeof Phi;
600
+ declare const jssm_constants_d_EulerC: typeof EulerC;
601
+ declare namespace jssm_constants_d {
602
+ export {
603
+ gviz_shapes$1 as gviz_shapes,
604
+ shapes$1 as shapes,
605
+ named_colors$1 as named_colors,
606
+ jssm_constants_d_NegInfinity as NegInfinity,
607
+ jssm_constants_d_PosInfinity as PosInfinity,
608
+ jssm_constants_d_Epsilon as Epsilon,
609
+ jssm_constants_d_Pi as Pi,
610
+ jssm_constants_d_E as E,
611
+ jssm_constants_d_Root2 as Root2,
612
+ jssm_constants_d_RootHalf as RootHalf,
613
+ jssm_constants_d_Ln2 as Ln2,
614
+ jssm_constants_d_Ln10 as Ln10,
615
+ jssm_constants_d_Log2E as Log2E,
616
+ jssm_constants_d_Log10E as Log10E,
617
+ jssm_constants_d_MaxSafeInt as MaxSafeInt,
618
+ jssm_constants_d_MinSafeInt as MinSafeInt,
619
+ jssm_constants_d_MaxPosNum as MaxPosNum,
620
+ jssm_constants_d_MinPosNum as MinPosNum,
621
+ jssm_constants_d_Phi as Phi,
622
+ jssm_constants_d_EulerC as EulerC,
623
+ };
624
+ }
625
+
626
+ declare const version: string;
627
+ declare const build_time: number;
628
+
629
+ declare type StateType = string;
630
+
631
+ declare const shapes: string[];
632
+ declare const gviz_shapes: string[];
633
+ declare const named_colors: string[];
634
+
635
+ /*********
636
+ *
637
+ * An internal method meant to take a series of declarations and fold them into
638
+ * a single multi-faceted declaration, in the process of building a state. Not
639
+ * generally meant for external use.
640
+ *
641
+ * @internal
642
+ *
643
+ */
644
+ declare function transfer_state_properties(state_decl: JssmStateDeclaration): JssmStateDeclaration;
645
+ declare function state_style_condense(jssk: JssmStateStyleKeyList): JssmStateConfig;
646
+ declare class Machine<mDT> {
647
+ _state: StateType;
648
+ _states: Map<StateType, JssmGenericState>;
649
+ _edges: Array<JssmTransition<StateType, mDT>>;
650
+ _edge_map: Map<StateType, Map<StateType, number>>;
651
+ _named_transitions: Map<StateType, number>;
652
+ _actions: Map<StateType, Map<StateType, number>>;
653
+ _reverse_actions: Map<StateType, Map<StateType, number>>;
654
+ _reverse_action_targets: Map<StateType, Map<StateType, number>>;
655
+ _start_states: Set<StateType>;
656
+ _end_states: Set<StateType>;
657
+ _machine_author?: Array<string>;
658
+ _machine_comment?: string;
659
+ _machine_contributor?: Array<string>;
660
+ _machine_definition?: string;
661
+ _machine_language?: string;
662
+ _machine_license?: string;
663
+ _machine_name?: string;
664
+ _machine_version?: string;
665
+ _fsl_version?: string;
666
+ _raw_state_declaration?: Array<Object>;
667
+ _state_declarations: Map<StateType, JssmStateDeclaration>;
668
+ _data?: mDT;
669
+ _instance_name: string;
670
+ _rng_seed: number;
671
+ _rng: JssmRng;
672
+ _graph_layout: JssmLayout;
673
+ _dot_preamble: string;
674
+ _arrange_declaration: Array<Array<StateType>>;
675
+ _arrange_start_declaration: Array<Array<StateType>>;
676
+ _arrange_end_declaration: Array<Array<StateType>>;
677
+ _themes: FslTheme[];
678
+ _flow: FslDirection;
679
+ _has_hooks: boolean;
680
+ _has_basic_hooks: boolean;
681
+ _has_named_hooks: boolean;
682
+ _has_entry_hooks: boolean;
683
+ _has_exit_hooks: boolean;
684
+ _has_after_hooks: boolean;
685
+ _has_global_action_hooks: boolean;
686
+ _has_transition_hooks: boolean;
687
+ _has_forced_transitions: boolean;
688
+ _hooks: Map<string, HookHandler<mDT>>;
689
+ _named_hooks: Map<string, HookHandler<mDT>>;
690
+ _entry_hooks: Map<string, HookHandler<mDT>>;
691
+ _exit_hooks: Map<string, HookHandler<mDT>>;
692
+ _after_hooks: Map<string, HookHandler<mDT>>;
693
+ _global_action_hooks: Map<string, HookHandler<mDT>>;
694
+ _any_action_hook: HookHandler<mDT> | undefined;
695
+ _standard_transition_hook: HookHandler<mDT> | undefined;
696
+ _main_transition_hook: HookHandler<mDT> | undefined;
697
+ _forced_transition_hook: HookHandler<mDT> | undefined;
698
+ _any_transition_hook: HookHandler<mDT> | undefined;
699
+ _has_post_hooks: boolean;
700
+ _has_post_basic_hooks: boolean;
701
+ _has_post_named_hooks: boolean;
702
+ _has_post_entry_hooks: boolean;
703
+ _has_post_exit_hooks: boolean;
704
+ _has_post_global_action_hooks: boolean;
705
+ _has_post_transition_hooks: boolean;
706
+ _code_allows_override: JssmAllowsOverride;
707
+ _config_allows_override: JssmAllowsOverride;
708
+ _post_hooks: Map<string, HookHandler<mDT>>;
709
+ _post_named_hooks: Map<string, HookHandler<mDT>>;
710
+ _post_entry_hooks: Map<string, HookHandler<mDT>>;
711
+ _post_exit_hooks: Map<string, HookHandler<mDT>>;
712
+ _post_global_action_hooks: Map<string, HookHandler<mDT>>;
713
+ _post_any_action_hook: HookHandler<mDT> | undefined;
714
+ _post_standard_transition_hook: HookHandler<mDT> | undefined;
715
+ _post_main_transition_hook: HookHandler<mDT> | undefined;
716
+ _post_forced_transition_hook: HookHandler<mDT> | undefined;
717
+ _post_any_transition_hook: HookHandler<mDT> | undefined;
718
+ _property_keys: Set<string>;
719
+ _default_properties: Map<string, any>;
720
+ _state_properties: Map<string, any>;
721
+ _required_properties: Set<string>;
722
+ _history: JssmHistory<mDT>;
723
+ _history_length: number;
724
+ _state_style: JssmStateConfig;
725
+ _active_state_style: JssmStateConfig;
726
+ _hooked_state_style: JssmStateConfig;
727
+ _terminal_state_style: JssmStateConfig;
728
+ _start_state_style: JssmStateConfig;
729
+ _end_state_style: JssmStateConfig;
730
+ _state_labels: Map<string, string>;
731
+ _time_source: () => number;
732
+ _create_started: number;
733
+ _created: number;
734
+ _after_mapping: Map<string, [string, number]>;
735
+ _timeout_source: (Function: any, number: any) => number;
736
+ _clear_timeout_source: (h: any) => void;
737
+ _timeout_handle: number | undefined;
738
+ _timeout_target: string | undefined;
739
+ _timeout_target_time: number | undefined;
740
+ constructor({ start_states, end_states, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name, history, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, allows_override, config_allows_override, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
741
+ /********
742
+ *
743
+ * Internal method for fabricating states. Not meant for external use.
744
+ *
745
+ * @internal
746
+ *
747
+ */
748
+ _new_state(state_config: JssmGenericState): StateType;
749
+ /*********
750
+ *
751
+ * Get the current state of a machine.
752
+ *
753
+ * ```typescript
754
+ * import * as jssm from 'jssm';
755
+ *
756
+ * const lswitch = jssm.from('on <=> off;');
757
+ * console.log( lswitch.state() ); // 'on'
758
+ *
759
+ * lswitch.transition('off');
760
+ * console.log( lswitch.state() ); // 'off'
761
+ * ```
762
+ *
763
+ * @typeparam mDT The type of the machine data member; usually omitted
764
+ *
765
+ */
766
+ state(): StateType;
767
+ /*********
768
+ *
769
+ * Get the label for a given state, if any; return `undefined` otherwise.
770
+ *
771
+ * ```typescript
772
+ * import * as jssm from 'jssm';
773
+ *
774
+ * const lswitch = jssm.from('a -> b; state a: { label: "Foo!"; };');
775
+ * console.log( lswitch.label_for('a') ); // 'Foo!'
776
+ * console.log( lswitch.label_for('b') ); // undefined
777
+ * ```
778
+ *
779
+ * See also {@link display_text}.
780
+ *
781
+ * @typeparam mDT The type of the machine data member; usually omitted
782
+ *
783
+ */
784
+ label_for(state: StateType): string;
785
+ /*********
786
+ *
787
+ * Get whatever the node should show as text.
788
+ *
789
+ * Currently, this means to get the label for a given state, if any;
790
+ * otherwise to return the node's name. However, this definition is expected
791
+ * to grow with time, and it is currently considered ill-advised to manually
792
+ * parse this text.
793
+ *
794
+ * See also {@link label_for}.
795
+ *
796
+ * ```typescript
797
+ * import * as jssm from 'jssm';
798
+ *
799
+ * const lswitch = jssm.from('a -> b; state a: { label: "Foo!"; };');
800
+ * console.log( lswitch.display_text('a') ); // 'Foo!'
801
+ * console.log( lswitch.display_text('b') ); // 'b'
802
+ * ```
803
+ *
804
+ * @typeparam mDT The type of the machine data member; usually omitted
805
+ *
806
+ */
807
+ display_text(state: StateType): string;
808
+ /*********
809
+ *
810
+ * Get the current data of a machine.
811
+ *
812
+ * ```typescript
813
+ * import * as jssm from 'jssm';
814
+ *
815
+ * const lswitch = jssm.from('on <=> off;', {data: 1});
816
+ * console.log( lswitch.data() ); // 1
817
+ * ```
818
+ *
819
+ * @typeparam mDT The type of the machine data member; usually omitted
820
+ *
821
+ */
822
+ data(): mDT;
823
+ /*********
824
+ *
825
+ * Get the current value of a given property name.
826
+ *
827
+ * ```typescript
828
+ *
829
+ * ```
830
+ *
831
+ * @param name The relevant property name to look up
832
+ *
833
+ * @returns The value behind the prop name. Because functional props are
834
+ * evaluated as getters, this can be anything.
835
+ *
836
+ */
837
+ prop(name: string): any;
838
+ /*********
839
+ *
840
+ * Get the current value of a given property name. If missing on the state
841
+ * and without a global default, throw, unlike {@link prop}, which would
842
+ * return `undefined` instead.
843
+ *
844
+ * ```typescript
845
+ *
846
+ * ```
847
+ *
848
+ * @param name The relevant property name to look up
849
+ *
850
+ * @returns The value behind the prop name. Because functional props are
851
+ * evaluated as getters, this can be anything.
852
+ *
853
+ */
854
+ strict_prop(name: string): any;
855
+ /*********
856
+ *
857
+ * Get the current value of every prop, as an object. If no current definition
858
+ * exists for a prop - that is, if the prop was defined without a default and
859
+ * the current state also doesn't define the prop - then that prop will be listed
860
+ * in the returned object with a value of `undefined`.
861
+ *
862
+ * ```typescript
863
+ * const traffic_light = sm`
864
+ *
865
+ * property can_go default true;
866
+ * property hesitate default true;
867
+ * property stop_first default false;
868
+ *
869
+ * Off -> Red => Green => Yellow => Red;
870
+ * [Red Yellow Green] ~> [Off FlashingRed];
871
+ * FlashingRed -> Red;
872
+ *
873
+ * state Red: { property stop_first true; property can_go false; };
874
+ * state Off: { property stop_first true; };
875
+ * state FlashingRed: { property stop_first true; };
876
+ * state Green: { property hesitate false; };
877
+ *
878
+ * `;
879
+ *
880
+ * traffic_light.state(); // Off
881
+ * traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true; }
882
+ *
883
+ * traffic_light.go('Red');
884
+ * traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true; }
885
+ *
886
+ * traffic_light.go('Green');
887
+ * traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false; }
888
+ * ```
889
+ *
890
+ */
891
+ props(): object;
892
+ /*********
893
+ *
894
+ * Get the current value of every prop, as an object. Compare
895
+ * {@link prop_map}, which returns a `Map`.
896
+ *
897
+ * ```typescript
898
+ *
899
+ * ```
900
+ *
901
+ */
902
+ /*********
903
+ *
904
+ * Get the current value of every prop, as an object. Compare
905
+ * {@link prop_map}, which returns a `Map`. Akin to {@link strict_prop},
906
+ * this throws if a required prop is missing.
907
+ *
908
+ * ```typescript
909
+ *
910
+ * ```
911
+ *
912
+ */
913
+ /*********
914
+ *
915
+ * Check whether a given string is a known property's name.
916
+ *
917
+ * ```typescript
918
+ * const example = sm`property foo default 1; a->b;`;
919
+ *
920
+ * example.known_prop('foo'); // true
921
+ * example.known_prop('bar'); // false
922
+ * ```
923
+ *
924
+ * @param prop_name The relevant property name to look up
925
+ *
926
+ */
927
+ known_prop(prop_name: string): boolean;
928
+ /*********
929
+ *
930
+ * List all known property names. If you'd also like values, use
931
+ * {@link props} instead. The order of the properties is not defined, and
932
+ * the properties generally will not be sorted.
933
+ *
934
+ * ```typescript
935
+ * ```
936
+ *
937
+ */
938
+ known_props(): string[];
939
+ /********
940
+ *
941
+ * Check whether a given state is a valid start state (either because it was
942
+ * explicitly named as such, or because it was the first mentioned state.)
943
+ *
944
+ * ```typescript
945
+ * import { sm, is_start_state } from 'jssm';
946
+ *
947
+ * const example = sm`a -> b;`;
948
+ *
949
+ * console.log( final_test.is_start_state('a') ); // true
950
+ * console.log( final_test.is_start_state('b') ); // false
951
+ *
952
+ * const example = sm`start_states: [a b]; a -> b;`;
953
+ *
954
+ * console.log( final_test.is_start_state('a') ); // true
955
+ * console.log( final_test.is_start_state('b') ); // true
956
+ * ```
957
+ *
958
+ * @typeparam mDT The type of the machine data member; usually omitted
959
+ *
960
+ * @param whichState The name of the state to check
961
+ *
962
+ */
963
+ is_start_state(whichState: StateType): boolean;
964
+ /********
965
+ *
966
+ * Check whether a given state is a valid start state (either because it was
967
+ * explicitly named as such, or because it was the first mentioned state.)
968
+ *
969
+ * ```typescript
970
+ * import { sm, is_end_state } from 'jssm';
971
+ *
972
+ * const example = sm`a -> b;`;
973
+ *
974
+ * console.log( final_test.is_start_state('a') ); // false
975
+ * console.log( final_test.is_start_state('b') ); // true
976
+ *
977
+ * const example = sm`end_states: [a b]; a -> b;`;
978
+ *
979
+ * console.log( final_test.is_start_state('a') ); // true
980
+ * console.log( final_test.is_start_state('b') ); // true
981
+ * ```
982
+ *
983
+ * @typeparam mDT The type of the machine data member; usually omitted
984
+ *
985
+ * @param whichState The name of the state to check
986
+ *
987
+ */
988
+ is_end_state(whichState: StateType): boolean;
989
+ /********
990
+ *
991
+ * Check whether a given state is final (either has no exits or is marked
992
+ * `complete`.)
993
+ *
994
+ * ```typescript
995
+ * import { sm, state_is_final } from 'jssm';
996
+ *
997
+ * const final_test = sm`first -> second;`;
998
+ *
999
+ * console.log( final_test.state_is_final('first') ); // false
1000
+ * console.log( final_test.state_is_final('second') ); // true
1001
+ * ```
1002
+ *
1003
+ * @typeparam mDT The type of the machine data member; usually omitted
1004
+ *
1005
+ * @param whichState The name of the state to check for finality
1006
+ *
1007
+ */
1008
+ state_is_final(whichState: StateType): boolean;
1009
+ /********
1010
+ *
1011
+ * Check whether the current state is final (either has no exits or is marked
1012
+ * `complete`.)
1013
+ *
1014
+ * ```typescript
1015
+ * import { sm, is_final } from 'jssm';
1016
+ *
1017
+ * const final_test = sm`first -> second;`;
1018
+ *
1019
+ * console.log( final_test.is_final() ); // false
1020
+ * state.transition('second');
1021
+ * console.log( final_test.is_final() ); // true
1022
+ * ```
1023
+ *
1024
+ */
1025
+ is_final(): boolean;
1026
+ /********
1027
+ *
1028
+ * Serialize the current machine, including all defining state but not the
1029
+ * machine string, to a structure. This means you will need the machine
1030
+ * string to recreate (to not waste repeated space;) if you want the machine
1031
+ * string embedded, call {@link serialize_with_string} instead.
1032
+ *
1033
+ * @typeparam mDT The type of the machine data member; usually omitted
1034
+ *
1035
+ */
1036
+ serialize(comment?: string | undefined): JssmSerialization<mDT>;
1037
+ graph_layout(): string;
1038
+ dot_preamble(): string;
1039
+ machine_author(): Array<string>;
1040
+ machine_comment(): string;
1041
+ machine_contributor(): Array<string>;
1042
+ machine_definition(): string;
1043
+ machine_language(): string;
1044
+ machine_license(): string;
1045
+ machine_name(): string;
1046
+ machine_version(): string;
1047
+ raw_state_declarations(): Array<Object>;
1048
+ state_declaration(which: StateType): JssmStateDeclaration;
1049
+ state_declarations(): Map<StateType, JssmStateDeclaration>;
1050
+ fsl_version(): string;
1051
+ machine_state(): JssmMachineInternalState<mDT>;
1052
+ /*********
1053
+ *
1054
+ * List all the states known by the machine. Please note that the order of
1055
+ * these states is not guaranteed.
1056
+ *
1057
+ * ```typescript
1058
+ * import * as jssm from 'jssm';
1059
+ *
1060
+ * const lswitch = jssm.from('on <=> off;');
1061
+ * console.log( lswitch.states() ); // ['on', 'off']
1062
+ * ```
1063
+ *
1064
+ * @typeparam mDT The type of the machine data member; usually omitted
1065
+ *
1066
+ */
1067
+ states(): Array<StateType>;
1068
+ state_for(whichState: StateType): JssmGenericState;
1069
+ /*********
1070
+ *
1071
+ * Check whether the machine knows a given state.
1072
+ *
1073
+ * ```typescript
1074
+ * import * as jssm from 'jssm';
1075
+ *
1076
+ * const lswitch = jssm.from('on <=> off;');
1077
+ *
1078
+ * console.log( lswitch.has_state('off') ); // true
1079
+ * console.log( lswitch.has_state('dance') ); // false
1080
+ * ```
1081
+ *
1082
+ * @typeparam mDT The type of the machine data member; usually omitted
1083
+ *
1084
+ * @param whichState The state to be checked for extance
1085
+ *
1086
+ */
1087
+ has_state(whichState: StateType): boolean;
1088
+ /*********
1089
+ *
1090
+ * Lists all edges of a machine.
1091
+ *
1092
+ * ```typescript
1093
+ * import { sm } from 'jssm';
1094
+ *
1095
+ * const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
1096
+ *
1097
+ * lswitch.list_edges();
1098
+ * [
1099
+ * {
1100
+ * from: 'on',
1101
+ * to: 'off',
1102
+ * kind: 'main',
1103
+ * forced_only: false,
1104
+ * main_path: true,
1105
+ * action: 'toggle'
1106
+ * },
1107
+ * {
1108
+ * from: 'off',
1109
+ * to: 'on',
1110
+ * kind: 'main',
1111
+ * forced_only: false,
1112
+ * main_path: true,
1113
+ * action: 'toggle'
1114
+ * }
1115
+ * ]
1116
+ * ```
1117
+ *
1118
+ * @typeparam mDT The type of the machine data member; usually omitted
1119
+ *
1120
+ */
1121
+ list_edges(): Array<JssmTransition<StateType, mDT>>;
1122
+ list_named_transitions(): Map<StateType, number>;
1123
+ list_actions(): Array<StateType>;
1124
+ get uses_actions(): boolean;
1125
+ get uses_forced_transitions(): boolean;
1126
+ /*********
1127
+ *
1128
+ * Check if the code that built the machine allows overriding state and data.
1129
+ *
1130
+ */
1131
+ get code_allows_override(): JssmAllowsOverride;
1132
+ /*********
1133
+ *
1134
+ * Check if the machine config allows overriding state and data.
1135
+ *
1136
+ */
1137
+ get config_allows_override(): JssmAllowsOverride;
1138
+ /*********
1139
+ *
1140
+ * Check if a machine allows overriding state and data.
1141
+ *
1142
+ */
1143
+ get allows_override(): JssmAllowsOverride;
1144
+ all_themes(): FslTheme[];
1145
+ get themes(): FslTheme | FslTheme[];
1146
+ set themes(to: FslTheme | FslTheme[]);
1147
+ flow(): FslDirection;
1148
+ get_transition_by_state_names(from: StateType, to: StateType): number;
1149
+ lookup_transition_for(from: StateType, to: StateType): JssmTransition<StateType, mDT>;
1150
+ /********
1151
+ *
1152
+ * List all transitions attached to the current state, sorted by entrance and
1153
+ * exit. The order of each sublist is not defined. A node could appear in
1154
+ * both lists.
1155
+ *
1156
+ * ```typescript
1157
+ * import { sm } from 'jssm';
1158
+ *
1159
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1160
+ *
1161
+ * light.state(); // 'red'
1162
+ * light.list_transitions(); // { entrances: [ 'yellow', 'off' ], exits: [ 'green', 'off' ] }
1163
+ * ```
1164
+ *
1165
+ * @typeparam mDT The type of the machine data member; usually omitted
1166
+ *
1167
+ * @param whichState The state whose transitions to have listed
1168
+ *
1169
+ */
1170
+ list_transitions(whichState?: StateType): JssmTransitionList;
1171
+ /********
1172
+ *
1173
+ * List all entrances attached to the current state. Please note that the
1174
+ * order of the list is not defined. This list includes both unforced and
1175
+ * forced entrances; if this isn't desired, consider
1176
+ * {@link list_unforced_entrances} or {@link list_forced_entrances} as
1177
+ * appropriate.
1178
+ *
1179
+ * ```typescript
1180
+ * import { sm } from 'jssm';
1181
+ *
1182
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1183
+ *
1184
+ * light.state(); // 'red'
1185
+ * light.list_entrances(); // [ 'yellow', 'off' ]
1186
+ * ```
1187
+ *
1188
+ * @typeparam mDT The type of the machine data member; usually omitted
1189
+ *
1190
+ * @param whichState The state whose entrances to have listed
1191
+ *
1192
+ */
1193
+ list_entrances(whichState?: StateType): Array<StateType>;
1194
+ /********
1195
+ *
1196
+ * List all exits attached to the current state. Please note that the order
1197
+ * of the list is not defined. This list includes both unforced and forced
1198
+ * exits; if this isn't desired, consider {@link list_unforced_exits} or
1199
+ * {@link list_forced_exits} as appropriate.
1200
+ *
1201
+ * ```typescript
1202
+ * import { sm } from 'jssm';
1203
+ *
1204
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1205
+ *
1206
+ * light.state(); // 'red'
1207
+ * light.list_exits(); // [ 'green', 'off' ]
1208
+ * ```
1209
+ *
1210
+ * @typeparam mDT The type of the machine data member; usually omitted
1211
+ *
1212
+ * @param whichState The state whose exits to have listed
1213
+ *
1214
+ */
1215
+ list_exits(whichState?: StateType): Array<StateType>;
1216
+ probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
1217
+ probabilistic_transition(): boolean;
1218
+ probabilistic_walk(n: number): Array<StateType>;
1219
+ probabilistic_histo_walk(n: number): Map<StateType, number>;
1220
+ /********
1221
+ *
1222
+ * List all actions available from this state. Please note that the order of
1223
+ * the actions is not guaranteed.
1224
+ *
1225
+ * ```typescript
1226
+ * import { sm } from 'jssm';
1227
+ *
1228
+ * const machine = sm`
1229
+ * red 'next' -> green 'next' -> yellow 'next' -> red;
1230
+ * [red yellow green] 'shutdown' ~> off 'start' -> red;
1231
+ * `;
1232
+ *
1233
+ * console.log( machine.state() ); // logs 'red'
1234
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
1235
+ *
1236
+ * machine.action('next'); // true
1237
+ * console.log( machine.state() ); // logs 'green'
1238
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
1239
+ *
1240
+ * machine.action('shutdown'); // true
1241
+ * console.log( machine.state() ); // logs 'off'
1242
+ * console.log( machine.actions() ); // logs ['start']
1243
+ *
1244
+ * machine.action('start'); // true
1245
+ * console.log( machine.state() ); // logs 'red'
1246
+ * console.log( machine.actions() ); // logs ['next', 'shutdown']
1247
+ * ```
1248
+ *
1249
+ * @typeparam mDT The type of the machine data member; usually omitted
1250
+ *
1251
+ * @param whichState The state whose actions to have listed
1252
+ *
1253
+ */
1254
+ actions(whichState?: StateType): Array<StateType>;
1255
+ /********
1256
+ *
1257
+ * List all states that have a specific action attached. Please note that
1258
+ * the order of the states is not guaranteed.
1259
+ *
1260
+ * ```typescript
1261
+ * import { sm } from 'jssm';
1262
+ *
1263
+ * const machine = sm`
1264
+ * red 'next' -> green 'next' -> yellow 'next' -> red;
1265
+ * [red yellow green] 'shutdown' ~> off 'start' -> red;
1266
+ * `;
1267
+ *
1268
+ * console.log( machine.list_states_having_action('next') ); // ['red', 'green', 'yellow']
1269
+ * console.log( machine.list_states_having_action('start') ); // ['off']
1270
+ * ```
1271
+ *
1272
+ * @typeparam mDT The type of the machine data member; usually omitted
1273
+ *
1274
+ * @param whichState The action to be checked for associated states
1275
+ *
1276
+ */
1277
+ list_states_having_action(whichState: StateType): Array<StateType>;
1278
+ list_exit_actions(whichState?: StateType): Array<StateType>;
1279
+ probable_action_exits(whichState?: StateType): Array<any>;
1280
+ is_unenterable(whichState: StateType): boolean;
1281
+ has_unenterables(): boolean;
1282
+ is_terminal(): boolean;
1283
+ state_is_terminal(whichState: StateType): boolean;
1284
+ has_terminals(): boolean;
1285
+ is_complete(): boolean;
1286
+ state_is_complete(whichState: StateType): boolean;
1287
+ has_completes(): boolean;
1288
+ set_hook(HookDesc: HookDescription<mDT>): void;
1289
+ hook(from: string, to: string, handler: HookHandler<mDT>): Machine<mDT>;
1290
+ hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>;
1291
+ hook_global_action(action: string, handler: HookHandler<mDT>): Machine<mDT>;
1292
+ hook_any_action(handler: HookHandler<mDT>): Machine<mDT>;
1293
+ hook_standard_transition(handler: HookHandler<mDT>): Machine<mDT>;
1294
+ hook_main_transition(handler: HookHandler<mDT>): Machine<mDT>;
1295
+ hook_forced_transition(handler: HookHandler<mDT>): Machine<mDT>;
1296
+ hook_any_transition(handler: HookHandler<mDT>): Machine<mDT>;
1297
+ hook_entry(to: string, handler: HookHandler<mDT>): Machine<mDT>;
1298
+ hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
1299
+ hook_after(from: string, handler: HookHandler<mDT>): Machine<mDT>;
1300
+ post_hook(from: string, to: string, handler: HookHandler<mDT>): Machine<mDT>;
1301
+ post_hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>;
1302
+ post_hook_global_action(action: string, handler: HookHandler<mDT>): Machine<mDT>;
1303
+ post_hook_any_action(handler: HookHandler<mDT>): Machine<mDT>;
1304
+ post_hook_standard_transition(handler: HookHandler<mDT>): Machine<mDT>;
1305
+ post_hook_main_transition(handler: HookHandler<mDT>): Machine<mDT>;
1306
+ post_hook_forced_transition(handler: HookHandler<mDT>): Machine<mDT>;
1307
+ post_hook_any_transition(handler: HookHandler<mDT>): Machine<mDT>;
1308
+ post_hook_entry(to: string, handler: HookHandler<mDT>): Machine<mDT>;
1309
+ post_hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
1310
+ get rng_seed(): number;
1311
+ set rng_seed(to: number | undefined);
1312
+ edges_between(from: string, to: string): JssmTransition<StateType, mDT>[];
1313
+ /*********
1314
+ *
1315
+ * Replace the current state and data with no regard to the graph.
1316
+ *
1317
+ * ```typescript
1318
+ * import { sm } from 'jssm';
1319
+ *
1320
+ * const machine = sm`a -> b -> c;`;
1321
+ * console.log( machine.state() ); // 'a'
1322
+ *
1323
+ * machine.go('b');
1324
+ * machine.go('c');
1325
+ * console.log( machine.state() ); // 'c'
1326
+ *
1327
+ * machine.override('a');
1328
+ * console.log( machine.state() ); // 'a'
1329
+ * ```
1330
+ *
1331
+ */
1332
+ override(newState: StateType, newData?: mDT | undefined): void;
1333
+ transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
1334
+ auto_set_state_timeout(): void;
1335
+ /*********
1336
+ *
1337
+ * Get a truncated history of the recent states and data of the machine.
1338
+ * Turned off by default; configure with `.from('...', {data: 5})` by length,
1339
+ * or set `.history_length` at runtime.
1340
+ *
1341
+ * History *does not contain the current state*. If you want that, call
1342
+ * `.history_inclusive` instead.
1343
+ *
1344
+ * ```typescript
1345
+ * const foo = jssm.from(
1346
+ * "a 'next' -> b 'next' -> c 'next' -> d 'next' -> e;",
1347
+ * { history: 3 }
1348
+ * );
1349
+ *
1350
+ * foo.action('next');
1351
+ * foo.action('next');
1352
+ * foo.action('next');
1353
+ * foo.action('next');
1354
+ *
1355
+ * foo.history; // [ ['b',undefined], ['c',undefined], ['d',undefined] ]
1356
+ * ```
1357
+ *
1358
+ * Notice that the machine's current state, `e`, is not in the returned list.
1359
+ *
1360
+ * @typeparam mDT The type of the machine data member; usually omitted
1361
+ *
1362
+ */
1363
+ get history(): [string, mDT][];
1364
+ /*********
1365
+ *
1366
+ * Get a truncated history of the recent states and data of the machine,
1367
+ * including the current state. Turned off by default; configure with
1368
+ * `.from('...', {data: 5})` by length, or set `.history_length` at runtime.
1369
+ *
1370
+ * History inclusive contains the current state. If you only want past
1371
+ * states, call `.history` instead.
1372
+ *
1373
+ * The list returned will be one longer than the history buffer kept, as the
1374
+ * history buffer kept gets the current state added to it to produce this
1375
+ * list.
1376
+ *
1377
+ * ```typescript
1378
+ * const foo = jssm.from(
1379
+ * "a 'next' -> b 'next' -> c 'next' -> d 'next' -> e;",
1380
+ * { history: 3 }
1381
+ * );
1382
+ *
1383
+ * foo.action('next');
1384
+ * foo.action('next');
1385
+ * foo.action('next');
1386
+ * foo.action('next');
1387
+ *
1388
+ * foo.history_inclusive; // [ ['b',undefined], ['c',undefined], ['d',undefined], ['e',undefined] ]
1389
+ * ```
1390
+ *
1391
+ * Notice that the machine's current state, `e`, is in the returned list.
1392
+ *
1393
+ * @typeparam mDT The type of the machine data member; usually omitted
1394
+ *
1395
+ */
1396
+ get history_inclusive(): [string, mDT][];
1397
+ /*********
1398
+ *
1399
+ * Find out how long a history this machine is keeping. Defaults to zero.
1400
+ * Settable directly.
1401
+ *
1402
+ * ```typescript
1403
+ * const foo = jssm.from("a -> b;");
1404
+ * foo.history_length; // 0
1405
+ *
1406
+ * const bar = jssm.from("a -> b;", { history: 3 });
1407
+ * foo.history_length; // 3
1408
+ * foo.history_length = 5;
1409
+ * foo.history_length; // 5
1410
+ * ```
1411
+ *
1412
+ * @typeparam mDT The type of the machine data member; usually omitted
1413
+ *
1414
+ */
1415
+ get history_length(): number;
1416
+ set history_length(to: number);
1417
+ /********
1418
+ *
1419
+ * Instruct the machine to complete an action. Synonym for {@link do}.
1420
+ *
1421
+ * ```typescript
1422
+ * const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1423
+ *
1424
+ * light.state(); // 'red'
1425
+ * light.action('next'); // true
1426
+ * light.state(); // 'green'
1427
+ * ```
1428
+ *
1429
+ * @typeparam mDT The type of the machine data member; usually omitted
1430
+ *
1431
+ * @param actionName The action to engage
1432
+ *
1433
+ * @param newData The data change to insert during the action
1434
+ *
1435
+ */
1436
+ action(actionName: StateType, newData?: mDT): boolean;
1437
+ /********
1438
+ *
1439
+ * Get the standard style for a single state. ***Does not*** include
1440
+ * composition from an applied theme, or things from the underlying base
1441
+ * stylesheet; only the modifications applied by this machine.
1442
+ *
1443
+ * ```typescript
1444
+ * const light = sm`a -> b;`;
1445
+ * console.log(light.standard_state_style);
1446
+ * // {}
1447
+ *
1448
+ * const light = sm`a -> b; state: { shape: circle; };`;
1449
+ * console.log(light.standard_state_style);
1450
+ * // { shape: 'circle' }
1451
+ * ```
1452
+ *
1453
+ * @typeparam mDT The type of the machine data member; usually omitted
1454
+ *
1455
+ */
1456
+ get standard_state_style(): JssmStateConfig;
1457
+ /********
1458
+ *
1459
+ * Get the hooked state style. ***Does not*** include
1460
+ * composition from an applied theme, or things from the underlying base
1461
+ * stylesheet; only the modifications applied by this machine.
1462
+ *
1463
+ * The hooked style is only applied to nodes which have a named hook in the
1464
+ * graph. Open hooks set through the external API aren't graphed, because
1465
+ * that would be literally every node.
1466
+ *
1467
+ * ```typescript
1468
+ * const light = sm`a -> b;`;
1469
+ * console.log(light.hooked_state_style);
1470
+ * // {}
1471
+ *
1472
+ * const light = sm`a -> b; hooked_state: { shape: circle; };`;
1473
+ * console.log(light.hooked_state_style);
1474
+ * // { shape: 'circle' }
1475
+ * ```
1476
+ *
1477
+ * @typeparam mDT The type of the machine data member; usually omitted
1478
+ *
1479
+ */
1480
+ get hooked_state_style(): JssmStateConfig;
1481
+ /********
1482
+ *
1483
+ * Get the start state style. ***Does not*** include composition from an
1484
+ * applied theme, or things from the underlying base stylesheet; only the
1485
+ * modifications applied by this machine.
1486
+ *
1487
+ * Start states are defined by the directive `start_states`, or in absentia,
1488
+ * are the first mentioned state.
1489
+ *
1490
+ * ```typescript
1491
+ * const light = sm`a -> b;`;
1492
+ * console.log(light.start_state_style);
1493
+ * // {}
1494
+ *
1495
+ * const light = sm`a -> b; start_state: { shape: circle; };`;
1496
+ * console.log(light.start_state_style);
1497
+ * // { shape: 'circle' }
1498
+ * ```
1499
+ *
1500
+ * @typeparam mDT The type of the machine data member; usually omitted
1501
+ *
1502
+ */
1503
+ get start_state_style(): JssmStateConfig;
1504
+ /********
1505
+ *
1506
+ * Get the end state style. ***Does not*** include
1507
+ * composition from an applied theme, or things from the underlying base
1508
+ * stylesheet; only the modifications applied by this machine.
1509
+ *
1510
+ * End states are defined in the directive `end_states`, and are distinct
1511
+ * from terminal states. End states are voluntary successful endpoints for a
1512
+ * process. Terminal states are states that cannot be exited. By example,
1513
+ * most error states are terminal states, but not end states. Also, since
1514
+ * some end states can be exited and are determined by hooks, such as
1515
+ * recursive or iterative nodes, there is such a thing as an end state that
1516
+ * is not a terminal state.
1517
+ *
1518
+ * ```typescript
1519
+ * const light = sm`a -> b;`;
1520
+ * console.log(light.standard_state_style);
1521
+ * // {}
1522
+ *
1523
+ * const light = sm`a -> b; end_state: { shape: circle; };`;
1524
+ * console.log(light.standard_state_style);
1525
+ * // { shape: 'circle' }
1526
+ * ```
1527
+ *
1528
+ * @typeparam mDT The type of the machine data member; usually omitted
1529
+ *
1530
+ */
1531
+ get end_state_style(): JssmStateConfig;
1532
+ /********
1533
+ *
1534
+ * Get the terminal state style. ***Does not*** include
1535
+ * composition from an applied theme, or things from the underlying base
1536
+ * stylesheet; only the modifications applied by this machine.
1537
+ *
1538
+ * Terminal state styles are automatically determined by the machine. Any
1539
+ * state without a valid exit transition is terminal.
1540
+ *
1541
+ * ```typescript
1542
+ * const light = sm`a -> b;`;
1543
+ * console.log(light.terminal_state_style);
1544
+ * // {}
1545
+ *
1546
+ * const light = sm`a -> b; terminal_state: { shape: circle; };`;
1547
+ * console.log(light.terminal_state_style);
1548
+ * // { shape: 'circle' }
1549
+ * ```
1550
+ *
1551
+ * @typeparam mDT The type of the machine data member; usually omitted
1552
+ *
1553
+ */
1554
+ get terminal_state_style(): JssmStateConfig;
1555
+ /********
1556
+ *
1557
+ * Get the style for the active state. ***Does not*** include
1558
+ * composition from an applied theme, or things from the underlying base
1559
+ * stylesheet; only the modifications applied by this machine.
1560
+ *
1561
+ * ```typescript
1562
+ * const light = sm`a -> b;`;
1563
+ * console.log(light.active_state_style);
1564
+ * // {}
1565
+ *
1566
+ * const light = sm`a -> b; active_state: { shape: circle; };`;
1567
+ * console.log(light.active_state_style);
1568
+ * // { shape: 'circle' }
1569
+ * ```
1570
+ *
1571
+ * @typeparam mDT The type of the machine data member; usually omitted
1572
+ *
1573
+ */
1574
+ get active_state_style(): JssmStateConfig;
1575
+ /********
1576
+ *
1577
+ * Gets the composite style for a specific node by individually imposing the
1578
+ * style layers on a given object, after determining which layers are
1579
+ * appropriate.
1580
+ *
1581
+ * The order of composition is base, then theme, then user content. Each
1582
+ * item in the stack will be composited independently. First, the base state
1583
+ * style, then the theme state style, then the user state style.
1584
+ *
1585
+ * After the three state styles, we'll composite the hooked styles; then the
1586
+ * terminal styles; then the start styles; then the end styles; finally, the
1587
+ * active styles. Remember, last wins.
1588
+ *
1589
+ * The base state style must exist. All other styles are optional.
1590
+ *
1591
+ * @typeparam mDT The type of the machine data member; usually omitted
1592
+ *
1593
+ */
1594
+ style_for(state: StateType): JssmStateConfig;
1595
+ /********
1596
+ *
1597
+ * Instruct the machine to complete an action. Synonym for {@link action}.
1598
+ *
1599
+ * ```typescript
1600
+ * const light = sm`
1601
+ * off 'start' -> red;
1602
+ * red 'next' -> green 'next' -> yellow 'next' -> red;
1603
+ * [red yellow green] 'shutdown' ~> off;
1604
+ * `;
1605
+ *
1606
+ * light.state(); // 'off'
1607
+ * light.do('start'); // true
1608
+ * light.state(); // 'red'
1609
+ * light.do('next'); // true
1610
+ * light.state(); // 'green'
1611
+ * light.do('next'); // true
1612
+ * light.state(); // 'yellow'
1613
+ * light.do('dance'); // !! false - no such action
1614
+ * light.state(); // 'yellow'
1615
+ * light.do('start'); // !! false - yellow does not have the action start
1616
+ * light.state(); // 'yellow'
1617
+ * ```
1618
+ *
1619
+ * @typeparam mDT The type of the machine data member; usually omitted
1620
+ *
1621
+ * @param actionName The action to engage
1622
+ *
1623
+ * @param newData The data change to insert during the action
1624
+ *
1625
+ */
1626
+ do(actionName: StateType, newData?: mDT): boolean;
1627
+ /********
1628
+ *
1629
+ * Instruct the machine to complete a transition. Synonym for {@link go}.
1630
+ *
1631
+ * ```typescript
1632
+ * const light = sm`
1633
+ * off 'start' -> red;
1634
+ * red 'next' -> green 'next' -> yellow 'next' -> red;
1635
+ * [red yellow green] 'shutdown' ~> off;
1636
+ * `;
1637
+ *
1638
+ * light.state(); // 'off'
1639
+ * light.go('red'); // true
1640
+ * light.state(); // 'red'
1641
+ * light.go('green'); // true
1642
+ * light.state(); // 'green'
1643
+ * light.go('blue'); // !! false - no such state
1644
+ * light.state(); // 'green'
1645
+ * light.go('red'); // !! false - green may not go directly to red, only to yellow
1646
+ * light.state(); // 'green'
1647
+ * ```
1648
+ *
1649
+ * @typeparam mDT The type of the machine data member; usually omitted
1650
+ *
1651
+ * @param newState The state to switch to
1652
+ *
1653
+ * @param newData The data change to insert during the transition
1654
+ *
1655
+ */
1656
+ transition(newState: StateType, newData?: mDT): boolean;
1657
+ /********
1658
+ *
1659
+ * Instruct the machine to complete a transition. Synonym for {@link transition}.
1660
+ *
1661
+ * ```typescript
1662
+ * const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1663
+ *
1664
+ * light.state(); // 'red'
1665
+ * light.go('green'); // true
1666
+ * light.state(); // 'green'
1667
+ * ```
1668
+ *
1669
+ * @typeparam mDT The type of the machine data member; usually omitted
1670
+ *
1671
+ * @param newState The state to switch to
1672
+ *
1673
+ * @param newData The data change to insert during the transition
1674
+ *
1675
+ */
1676
+ go(newState: StateType, newData?: mDT): boolean;
1677
+ /********
1678
+ *
1679
+ * Instruct the machine to complete a forced transition (which will reject if
1680
+ * called with a normal {@link transition} call.)
1681
+ *
1682
+ * ```typescript
1683
+ * const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
1684
+ *
1685
+ * light.state(); // 'red'
1686
+ * light.transition('off'); // false
1687
+ * light.state(); // 'red'
1688
+ * light.force_transition('off'); // true
1689
+ * light.state(); // 'off'
1690
+ * ```
1691
+ *
1692
+ * @typeparam mDT The type of the machine data member; usually omitted
1693
+ *
1694
+ * @param newState The state to switch to
1695
+ *
1696
+ * @param newData The data change to insert during the transition
1697
+ *
1698
+ */
1699
+ force_transition(newState: StateType, newData?: mDT): boolean;
1700
+ current_action_for(action: StateType): number;
1701
+ current_action_edge_for(action: StateType): JssmTransition<StateType, mDT>;
1702
+ valid_action(action: StateType, _newData?: mDT): boolean;
1703
+ valid_transition(newState: StateType, _newData?: mDT): boolean;
1704
+ valid_force_transition(newState: StateType, _newData?: mDT): boolean;
1705
+ instance_name(): string | undefined;
1706
+ get creation_date(): Date;
1707
+ get creation_timestamp(): number;
1708
+ get create_start_time(): number;
1709
+ set_state_timeout(next_state: StateType, after_time: number): void;
1710
+ clear_state_timeout(): void;
1711
+ state_timeout_for(which_state: StateType): [StateType, number] | undefined;
1712
+ current_state_timeout(): [StateType, number] | undefined;
1713
+ sm(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
1714
+ }
1715
+ /*********
1716
+ *
1717
+ * Create a state machine from a template string. This is one of the two main
1718
+ * paths for working with JSSM, alongside {@link from}.
1719
+ *
1720
+ * Use this method when you want to work directly and conveniently with a
1721
+ * constant template expression. Use `.from` when you want to pull from
1722
+ * dynamic strings.
1723
+ *
1724
+ *
1725
+ * ```typescript
1726
+ * import * as jssm from 'jssm';
1727
+ *
1728
+ * const lswitch = jssm.from('on <=> off;');
1729
+ * ```
1730
+ *
1731
+ * @typeparam mDT The type of the machine data member; usually omitted
1732
+ *
1733
+ * @param template_strings The assembled code
1734
+ *
1735
+ * @param remainder The mechanic for template argument insertion
1736
+ *
1737
+ */
1738
+ declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
1739
+ /*********
1740
+ *
1741
+ * Create a state machine from an implementation string. This is one of the
1742
+ * two main paths for working with JSSM, alongside {@link sm}.
1743
+ *
1744
+ * Use this method when you want to conveniently pull a state machine from a
1745
+ * string dynamically. Use operator `sm` when you just want to work with a
1746
+ * template expression.
1747
+ *
1748
+ * ```typescript
1749
+ * import * as jssm from 'jssm';
1750
+ *
1751
+ * const lswitch = jssm.from('on <=> off;');
1752
+ * ```
1753
+ *
1754
+ * @typeparam mDT The type of the machine data member; usually omitted
1755
+ *
1756
+ * @param MachineAsString The FSL code to evaluate
1757
+ *
1758
+ * @param ExtraConstructorFields Extra non-code configuration to pass at creation time
1759
+ *
1760
+ */
1761
+ declare function from<mDT>(MachineAsString: string, ExtraConstructorFields?: Partial<JssmGenericConfig<StateType, mDT>> | undefined): Machine<mDT>;
1762
+ declare function is_hook_complex_result<mDT>(hr: unknown): hr is HookComplexResult<mDT>;
1763
+ declare function is_hook_rejection<mDT>(hr: HookResult<mDT>): boolean;
1764
+ declare function abstract_hook_step<mDT>(maybe_hook: HookHandler<mDT> | undefined, hook_args: HookContext<mDT>): HookComplexResult<mDT>;
1765
+ declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
1766
+
1767
+ export { FslDirections, Machine, abstract_hook_step, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compile, jssm_constants_d as constants, deserialize, find_repeated, from, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };