jssm 5.104.1 → 5.112.3
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/.gitattributes +17 -6
- package/.log-progress.json +9 -0
- package/CHANGELOG.md +130 -47
- package/CLAUDE.md +11 -0
- package/MIGRATING-jssm-viz.md +67 -0
- package/README.md +179 -882
- package/dist/es6/fsl_parser.js +1 -1
- package/dist/es6/jssm.d.ts +773 -39
- package/dist/es6/jssm.js +921 -89
- package/dist/es6/jssm_arrow.js +24 -0
- package/dist/es6/jssm_compiler.d.ts +17 -2
- package/dist/es6/jssm_compiler.js +17 -3
- package/dist/es6/jssm_constants.d.ts +27 -0
- package/dist/es6/jssm_constants.js +27 -0
- package/dist/es6/jssm_error.d.ts +19 -0
- package/dist/es6/jssm_error.js +19 -0
- package/dist/es6/jssm_theme.d.ts +11 -0
- package/dist/es6/jssm_theme.js +11 -0
- package/dist/es6/jssm_types.d.ts +29 -3
- package/dist/es6/jssm_util.d.ts +161 -9
- package/dist/es6/jssm_util.js +174 -17
- package/dist/es6/jssm_viz.d.ts +175 -0
- package/dist/es6/jssm_viz.js +560 -0
- package/dist/es6/jssm_viz_colors.d.ts +63 -0
- package/dist/es6/jssm_viz_colors.js +63 -0
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs +1 -1
- package/dist/jssm.es5.iife.js +1 -0
- package/dist/jssm.es5.nonmin.cjs +2201 -870
- package/dist/jssm.es6.mjs +1 -1
- package/dist/jssm.es6.nonmin.cjs +2200 -871
- package/dist/jssm_viz.cjs +1 -0
- package/dist/{jssm.es5.iife.nonmin.cjs → jssm_viz.es5.iife.nonmin.cjs} +2589 -1090
- package/dist/jssm_viz.es5.nonmin.cjs +24674 -0
- package/dist/jssm_viz.es6.nonmin.cjs +24661 -0
- package/dist/jssm_viz.iife.cjs +1 -0
- package/dist/jssm_viz.mjs +1 -0
- package/jest-dragon.config.cjs +4 -1
- package/jest-spec.config.cjs +9 -6
- package/jest-stoch.config.cjs +4 -1
- package/jest-unicode.config.cjs +4 -1
- package/jssm.es5.d.cts +950 -41
- package/jssm.es6.d.ts +950 -41
- package/jssm_viz.es5.d.cts +2127 -0
- package/jssm_viz.es6.d.ts +2127 -0
- package/log-progress.data.json +28 -0
- package/package.json +56 -23
- package/rollup.config.viz.es5.js +46 -0
- package/rollup.config.viz.es6.js +46 -0
- package/rollup.config.viz.iife.js +36 -0
- package/typedoc-options.cjs +4 -3
- package/dist/jssm.es5.iife.cjs +0 -1
- package/fsl_parser.d.ts +0 -6
- package/jssm.d.ts +0 -1141
- package/jssm_arrow.d.ts +0 -53
- package/jssm_compiler.d.ts +0 -135
- package/jssm_constants.d.ts +0 -5
- package/jssm_error.d.ts +0 -8
- package/jssm_theme.d.ts +0 -4
- package/jssm_types.d.ts +0 -378
- package/jssm_util.d.ts +0 -106
- package/version.d.ts +0 -2
package/jssm.d.ts
DELETED
|
@@ -1,1141 +0,0 @@
|
|
|
1
|
-
declare type StateType = string;
|
|
2
|
-
import { JssmGenericState, JssmGenericConfig, JssmStateConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
|
|
3
|
-
JssmMachineInternalState, JssmAllowsOverride, JssmStateDeclaration, JssmStateStyleKeyList, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslDirections, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, JssmRng } from './jssm_types';
|
|
4
|
-
import { arrow_direction, arrow_left_kind, arrow_right_kind } from './jssm_arrow';
|
|
5
|
-
import { compile, make, wrap_parse } from './jssm_compiler';
|
|
6
|
-
import { seq, unique, find_repeated, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key, sleep } from './jssm_util';
|
|
7
|
-
import * as constants from './jssm_constants';
|
|
8
|
-
declare const shapes: string[], gviz_shapes: string[], named_colors: string[];
|
|
9
|
-
import { version, build_time } from './version';
|
|
10
|
-
/*********
|
|
11
|
-
*
|
|
12
|
-
* An internal method meant to take a series of declarations and fold them into
|
|
13
|
-
* a single multi-faceted declaration, in the process of building a state. Not
|
|
14
|
-
* generally meant for external use.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
declare function transfer_state_properties(state_decl: JssmStateDeclaration): JssmStateDeclaration;
|
|
20
|
-
declare function state_style_condense(jssk: JssmStateStyleKeyList): JssmStateConfig;
|
|
21
|
-
declare class Machine<mDT> {
|
|
22
|
-
_state: StateType;
|
|
23
|
-
_states: Map<StateType, JssmGenericState>;
|
|
24
|
-
_edges: Array<JssmTransition<StateType, mDT>>;
|
|
25
|
-
_edge_map: Map<StateType, Map<StateType, number>>;
|
|
26
|
-
_named_transitions: Map<StateType, number>;
|
|
27
|
-
_actions: Map<StateType, Map<StateType, number>>;
|
|
28
|
-
_reverse_actions: Map<StateType, Map<StateType, number>>;
|
|
29
|
-
_reverse_action_targets: Map<StateType, Map<StateType, number>>;
|
|
30
|
-
_start_states: Set<StateType>;
|
|
31
|
-
_end_states: Set<StateType>;
|
|
32
|
-
_machine_author?: Array<string>;
|
|
33
|
-
_machine_comment?: string;
|
|
34
|
-
_machine_contributor?: Array<string>;
|
|
35
|
-
_machine_definition?: string;
|
|
36
|
-
_machine_language?: string;
|
|
37
|
-
_machine_license?: string;
|
|
38
|
-
_machine_name?: string;
|
|
39
|
-
_machine_version?: string;
|
|
40
|
-
_fsl_version?: string;
|
|
41
|
-
_raw_state_declaration?: Array<Object>;
|
|
42
|
-
_state_declarations: Map<StateType, JssmStateDeclaration>;
|
|
43
|
-
_data?: mDT;
|
|
44
|
-
_instance_name: string;
|
|
45
|
-
_rng_seed: number;
|
|
46
|
-
_rng: JssmRng;
|
|
47
|
-
_graph_layout: JssmLayout;
|
|
48
|
-
_dot_preamble: string;
|
|
49
|
-
_arrange_declaration: Array<Array<StateType>>;
|
|
50
|
-
_arrange_start_declaration: Array<Array<StateType>>;
|
|
51
|
-
_arrange_end_declaration: Array<Array<StateType>>;
|
|
52
|
-
_themes: FslTheme[];
|
|
53
|
-
_flow: FslDirection;
|
|
54
|
-
_has_hooks: boolean;
|
|
55
|
-
_has_basic_hooks: boolean;
|
|
56
|
-
_has_named_hooks: boolean;
|
|
57
|
-
_has_entry_hooks: boolean;
|
|
58
|
-
_has_exit_hooks: boolean;
|
|
59
|
-
_has_after_hooks: boolean;
|
|
60
|
-
_has_global_action_hooks: boolean;
|
|
61
|
-
_has_transition_hooks: boolean;
|
|
62
|
-
_has_forced_transitions: boolean;
|
|
63
|
-
_hooks: Map<string, HookHandler<mDT>>;
|
|
64
|
-
_named_hooks: Map<string, HookHandler<mDT>>;
|
|
65
|
-
_entry_hooks: Map<string, HookHandler<mDT>>;
|
|
66
|
-
_exit_hooks: Map<string, HookHandler<mDT>>;
|
|
67
|
-
_after_hooks: Map<string, HookHandler<mDT>>;
|
|
68
|
-
_global_action_hooks: Map<string, HookHandler<mDT>>;
|
|
69
|
-
_any_action_hook: HookHandler<mDT> | undefined;
|
|
70
|
-
_standard_transition_hook: HookHandler<mDT> | undefined;
|
|
71
|
-
_main_transition_hook: HookHandler<mDT> | undefined;
|
|
72
|
-
_forced_transition_hook: HookHandler<mDT> | undefined;
|
|
73
|
-
_any_transition_hook: HookHandler<mDT> | undefined;
|
|
74
|
-
_has_post_hooks: boolean;
|
|
75
|
-
_has_post_basic_hooks: boolean;
|
|
76
|
-
_has_post_named_hooks: boolean;
|
|
77
|
-
_has_post_entry_hooks: boolean;
|
|
78
|
-
_has_post_exit_hooks: boolean;
|
|
79
|
-
_has_post_global_action_hooks: boolean;
|
|
80
|
-
_has_post_transition_hooks: boolean;
|
|
81
|
-
_code_allows_override: JssmAllowsOverride;
|
|
82
|
-
_config_allows_override: JssmAllowsOverride;
|
|
83
|
-
_post_hooks: Map<string, HookHandler<mDT>>;
|
|
84
|
-
_post_named_hooks: Map<string, HookHandler<mDT>>;
|
|
85
|
-
_post_entry_hooks: Map<string, HookHandler<mDT>>;
|
|
86
|
-
_post_exit_hooks: Map<string, HookHandler<mDT>>;
|
|
87
|
-
_post_global_action_hooks: Map<string, HookHandler<mDT>>;
|
|
88
|
-
_post_any_action_hook: HookHandler<mDT> | undefined;
|
|
89
|
-
_post_standard_transition_hook: HookHandler<mDT> | undefined;
|
|
90
|
-
_post_main_transition_hook: HookHandler<mDT> | undefined;
|
|
91
|
-
_post_forced_transition_hook: HookHandler<mDT> | undefined;
|
|
92
|
-
_post_any_transition_hook: HookHandler<mDT> | undefined;
|
|
93
|
-
_property_keys: Set<string>;
|
|
94
|
-
_default_properties: Map<string, any>;
|
|
95
|
-
_state_properties: Map<string, any>;
|
|
96
|
-
_required_properties: Set<string>;
|
|
97
|
-
_history: JssmHistory<mDT>;
|
|
98
|
-
_history_length: number;
|
|
99
|
-
_state_style: JssmStateConfig;
|
|
100
|
-
_active_state_style: JssmStateConfig;
|
|
101
|
-
_hooked_state_style: JssmStateConfig;
|
|
102
|
-
_terminal_state_style: JssmStateConfig;
|
|
103
|
-
_start_state_style: JssmStateConfig;
|
|
104
|
-
_end_state_style: JssmStateConfig;
|
|
105
|
-
_state_labels: Map<string, string>;
|
|
106
|
-
_time_source: () => number;
|
|
107
|
-
_create_started: number;
|
|
108
|
-
_created: number;
|
|
109
|
-
_after_mapping: Map<string, [string, number]>;
|
|
110
|
-
_timeout_source: (Function: any, number: any) => number;
|
|
111
|
-
_clear_timeout_source: (h: any) => void;
|
|
112
|
-
_timeout_handle: number | undefined;
|
|
113
|
-
_timeout_target: string | undefined;
|
|
114
|
-
_timeout_target_time: number | undefined;
|
|
115
|
-
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>);
|
|
116
|
-
/********
|
|
117
|
-
*
|
|
118
|
-
* Internal method for fabricating states. Not meant for external use.
|
|
119
|
-
*
|
|
120
|
-
* @internal
|
|
121
|
-
*
|
|
122
|
-
*/
|
|
123
|
-
_new_state(state_config: JssmGenericState): StateType;
|
|
124
|
-
/*********
|
|
125
|
-
*
|
|
126
|
-
* Get the current state of a machine.
|
|
127
|
-
*
|
|
128
|
-
* ```typescript
|
|
129
|
-
* import * as jssm from 'jssm';
|
|
130
|
-
*
|
|
131
|
-
* const lswitch = jssm.from('on <=> off;');
|
|
132
|
-
* console.log( lswitch.state() ); // 'on'
|
|
133
|
-
*
|
|
134
|
-
* lswitch.transition('off');
|
|
135
|
-
* console.log( lswitch.state() ); // 'off'
|
|
136
|
-
* ```
|
|
137
|
-
*
|
|
138
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
139
|
-
*
|
|
140
|
-
*/
|
|
141
|
-
state(): StateType;
|
|
142
|
-
/*********
|
|
143
|
-
*
|
|
144
|
-
* Get the label for a given state, if any; return `undefined` otherwise.
|
|
145
|
-
*
|
|
146
|
-
* ```typescript
|
|
147
|
-
* import * as jssm from 'jssm';
|
|
148
|
-
*
|
|
149
|
-
* const lswitch = jssm.from('a -> b; state a: { label: "Foo!"; };');
|
|
150
|
-
* console.log( lswitch.label_for('a') ); // 'Foo!'
|
|
151
|
-
* console.log( lswitch.label_for('b') ); // undefined
|
|
152
|
-
* ```
|
|
153
|
-
*
|
|
154
|
-
* See also {@link display_text}.
|
|
155
|
-
*
|
|
156
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
157
|
-
*
|
|
158
|
-
*/
|
|
159
|
-
label_for(state: StateType): string;
|
|
160
|
-
/*********
|
|
161
|
-
*
|
|
162
|
-
* Get whatever the node should show as text.
|
|
163
|
-
*
|
|
164
|
-
* Currently, this means to get the label for a given state, if any;
|
|
165
|
-
* otherwise to return the node's name. However, this definition is expected
|
|
166
|
-
* to grow with time, and it is currently considered ill-advised to manually
|
|
167
|
-
* parse this text.
|
|
168
|
-
*
|
|
169
|
-
* See also {@link label_for}.
|
|
170
|
-
*
|
|
171
|
-
* ```typescript
|
|
172
|
-
* import * as jssm from 'jssm';
|
|
173
|
-
*
|
|
174
|
-
* const lswitch = jssm.from('a -> b; state a: { label: "Foo!"; };');
|
|
175
|
-
* console.log( lswitch.display_text('a') ); // 'Foo!'
|
|
176
|
-
* console.log( lswitch.display_text('b') ); // 'b'
|
|
177
|
-
* ```
|
|
178
|
-
*
|
|
179
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
180
|
-
*
|
|
181
|
-
*/
|
|
182
|
-
display_text(state: StateType): string;
|
|
183
|
-
/*********
|
|
184
|
-
*
|
|
185
|
-
* Get the current data of a machine.
|
|
186
|
-
*
|
|
187
|
-
* ```typescript
|
|
188
|
-
* import * as jssm from 'jssm';
|
|
189
|
-
*
|
|
190
|
-
* const lswitch = jssm.from('on <=> off;', {data: 1});
|
|
191
|
-
* console.log( lswitch.data() ); // 1
|
|
192
|
-
* ```
|
|
193
|
-
*
|
|
194
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
195
|
-
*
|
|
196
|
-
*/
|
|
197
|
-
data(): mDT;
|
|
198
|
-
/*********
|
|
199
|
-
*
|
|
200
|
-
* Get the current value of a given property name.
|
|
201
|
-
*
|
|
202
|
-
* ```typescript
|
|
203
|
-
*
|
|
204
|
-
* ```
|
|
205
|
-
*
|
|
206
|
-
* @param name The relevant property name to look up
|
|
207
|
-
*
|
|
208
|
-
* @returns The value behind the prop name. Because functional props are
|
|
209
|
-
* evaluated as getters, this can be anything.
|
|
210
|
-
*
|
|
211
|
-
*/
|
|
212
|
-
prop(name: string): any;
|
|
213
|
-
/*********
|
|
214
|
-
*
|
|
215
|
-
* Get the current value of a given property name. If missing on the state
|
|
216
|
-
* and without a global default, throw, unlike {@link prop}, which would
|
|
217
|
-
* return `undefined` instead.
|
|
218
|
-
*
|
|
219
|
-
* ```typescript
|
|
220
|
-
*
|
|
221
|
-
* ```
|
|
222
|
-
*
|
|
223
|
-
* @param name The relevant property name to look up
|
|
224
|
-
*
|
|
225
|
-
* @returns The value behind the prop name. Because functional props are
|
|
226
|
-
* evaluated as getters, this can be anything.
|
|
227
|
-
*
|
|
228
|
-
*/
|
|
229
|
-
strict_prop(name: string): any;
|
|
230
|
-
/*********
|
|
231
|
-
*
|
|
232
|
-
* Get the current value of every prop, as an object. If no current definition
|
|
233
|
-
* exists for a prop - that is, if the prop was defined without a default and
|
|
234
|
-
* the current state also doesn't define the prop - then that prop will be listed
|
|
235
|
-
* in the returned object with a value of `undefined`.
|
|
236
|
-
*
|
|
237
|
-
* ```typescript
|
|
238
|
-
* const traffic_light = sm`
|
|
239
|
-
*
|
|
240
|
-
* property can_go default true;
|
|
241
|
-
* property hesitate default true;
|
|
242
|
-
* property stop_first default false;
|
|
243
|
-
*
|
|
244
|
-
* Off -> Red => Green => Yellow => Red;
|
|
245
|
-
* [Red Yellow Green] ~> [Off FlashingRed];
|
|
246
|
-
* FlashingRed -> Red;
|
|
247
|
-
*
|
|
248
|
-
* state Red: { property stop_first true; property can_go false; };
|
|
249
|
-
* state Off: { property stop_first true; };
|
|
250
|
-
* state FlashingRed: { property stop_first true; };
|
|
251
|
-
* state Green: { property hesitate false; };
|
|
252
|
-
*
|
|
253
|
-
* `;
|
|
254
|
-
*
|
|
255
|
-
* traffic_light.state(); // Off
|
|
256
|
-
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true; }
|
|
257
|
-
*
|
|
258
|
-
* traffic_light.go('Red');
|
|
259
|
-
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true; }
|
|
260
|
-
*
|
|
261
|
-
* traffic_light.go('Green');
|
|
262
|
-
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false; }
|
|
263
|
-
* ```
|
|
264
|
-
*
|
|
265
|
-
*/
|
|
266
|
-
props(): object;
|
|
267
|
-
/*********
|
|
268
|
-
*
|
|
269
|
-
* Get the current value of every prop, as an object. Compare
|
|
270
|
-
* {@link prop_map}, which returns a `Map`.
|
|
271
|
-
*
|
|
272
|
-
* ```typescript
|
|
273
|
-
*
|
|
274
|
-
* ```
|
|
275
|
-
*
|
|
276
|
-
*/
|
|
277
|
-
/*********
|
|
278
|
-
*
|
|
279
|
-
* Get the current value of every prop, as an object. Compare
|
|
280
|
-
* {@link prop_map}, which returns a `Map`. Akin to {@link strict_prop},
|
|
281
|
-
* this throws if a required prop is missing.
|
|
282
|
-
*
|
|
283
|
-
* ```typescript
|
|
284
|
-
*
|
|
285
|
-
* ```
|
|
286
|
-
*
|
|
287
|
-
*/
|
|
288
|
-
/*********
|
|
289
|
-
*
|
|
290
|
-
* Check whether a given string is a known property's name.
|
|
291
|
-
*
|
|
292
|
-
* ```typescript
|
|
293
|
-
* const example = sm`property foo default 1; a->b;`;
|
|
294
|
-
*
|
|
295
|
-
* example.known_prop('foo'); // true
|
|
296
|
-
* example.known_prop('bar'); // false
|
|
297
|
-
* ```
|
|
298
|
-
*
|
|
299
|
-
* @param prop_name The relevant property name to look up
|
|
300
|
-
*
|
|
301
|
-
*/
|
|
302
|
-
known_prop(prop_name: string): boolean;
|
|
303
|
-
/*********
|
|
304
|
-
*
|
|
305
|
-
* List all known property names. If you'd also like values, use
|
|
306
|
-
* {@link props} instead. The order of the properties is not defined, and
|
|
307
|
-
* the properties generally will not be sorted.
|
|
308
|
-
*
|
|
309
|
-
* ```typescript
|
|
310
|
-
* ```
|
|
311
|
-
*
|
|
312
|
-
*/
|
|
313
|
-
known_props(): string[];
|
|
314
|
-
/********
|
|
315
|
-
*
|
|
316
|
-
* Check whether a given state is a valid start state (either because it was
|
|
317
|
-
* explicitly named as such, or because it was the first mentioned state.)
|
|
318
|
-
*
|
|
319
|
-
* ```typescript
|
|
320
|
-
* import { sm, is_start_state } from 'jssm';
|
|
321
|
-
*
|
|
322
|
-
* const example = sm`a -> b;`;
|
|
323
|
-
*
|
|
324
|
-
* console.log( final_test.is_start_state('a') ); // true
|
|
325
|
-
* console.log( final_test.is_start_state('b') ); // false
|
|
326
|
-
*
|
|
327
|
-
* const example = sm`start_states: [a b]; a -> b;`;
|
|
328
|
-
*
|
|
329
|
-
* console.log( final_test.is_start_state('a') ); // true
|
|
330
|
-
* console.log( final_test.is_start_state('b') ); // true
|
|
331
|
-
* ```
|
|
332
|
-
*
|
|
333
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
334
|
-
*
|
|
335
|
-
* @param whichState The name of the state to check
|
|
336
|
-
*
|
|
337
|
-
*/
|
|
338
|
-
is_start_state(whichState: StateType): boolean;
|
|
339
|
-
/********
|
|
340
|
-
*
|
|
341
|
-
* Check whether a given state is a valid start state (either because it was
|
|
342
|
-
* explicitly named as such, or because it was the first mentioned state.)
|
|
343
|
-
*
|
|
344
|
-
* ```typescript
|
|
345
|
-
* import { sm, is_end_state } from 'jssm';
|
|
346
|
-
*
|
|
347
|
-
* const example = sm`a -> b;`;
|
|
348
|
-
*
|
|
349
|
-
* console.log( final_test.is_start_state('a') ); // false
|
|
350
|
-
* console.log( final_test.is_start_state('b') ); // true
|
|
351
|
-
*
|
|
352
|
-
* const example = sm`end_states: [a b]; a -> b;`;
|
|
353
|
-
*
|
|
354
|
-
* console.log( final_test.is_start_state('a') ); // true
|
|
355
|
-
* console.log( final_test.is_start_state('b') ); // true
|
|
356
|
-
* ```
|
|
357
|
-
*
|
|
358
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
359
|
-
*
|
|
360
|
-
* @param whichState The name of the state to check
|
|
361
|
-
*
|
|
362
|
-
*/
|
|
363
|
-
is_end_state(whichState: StateType): boolean;
|
|
364
|
-
/********
|
|
365
|
-
*
|
|
366
|
-
* Check whether a given state is final (either has no exits or is marked
|
|
367
|
-
* `complete`.)
|
|
368
|
-
*
|
|
369
|
-
* ```typescript
|
|
370
|
-
* import { sm, state_is_final } from 'jssm';
|
|
371
|
-
*
|
|
372
|
-
* const final_test = sm`first -> second;`;
|
|
373
|
-
*
|
|
374
|
-
* console.log( final_test.state_is_final('first') ); // false
|
|
375
|
-
* console.log( final_test.state_is_final('second') ); // true
|
|
376
|
-
* ```
|
|
377
|
-
*
|
|
378
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
379
|
-
*
|
|
380
|
-
* @param whichState The name of the state to check for finality
|
|
381
|
-
*
|
|
382
|
-
*/
|
|
383
|
-
state_is_final(whichState: StateType): boolean;
|
|
384
|
-
/********
|
|
385
|
-
*
|
|
386
|
-
* Check whether the current state is final (either has no exits or is marked
|
|
387
|
-
* `complete`.)
|
|
388
|
-
*
|
|
389
|
-
* ```typescript
|
|
390
|
-
* import { sm, is_final } from 'jssm';
|
|
391
|
-
*
|
|
392
|
-
* const final_test = sm`first -> second;`;
|
|
393
|
-
*
|
|
394
|
-
* console.log( final_test.is_final() ); // false
|
|
395
|
-
* state.transition('second');
|
|
396
|
-
* console.log( final_test.is_final() ); // true
|
|
397
|
-
* ```
|
|
398
|
-
*
|
|
399
|
-
*/
|
|
400
|
-
is_final(): boolean;
|
|
401
|
-
/********
|
|
402
|
-
*
|
|
403
|
-
* Serialize the current machine, including all defining state but not the
|
|
404
|
-
* machine string, to a structure. This means you will need the machine
|
|
405
|
-
* string to recreate (to not waste repeated space;) if you want the machine
|
|
406
|
-
* string embedded, call {@link serialize_with_string} instead.
|
|
407
|
-
*
|
|
408
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
409
|
-
*
|
|
410
|
-
*/
|
|
411
|
-
serialize(comment?: string | undefined): JssmSerialization<mDT>;
|
|
412
|
-
graph_layout(): string;
|
|
413
|
-
dot_preamble(): string;
|
|
414
|
-
machine_author(): Array<string>;
|
|
415
|
-
machine_comment(): string;
|
|
416
|
-
machine_contributor(): Array<string>;
|
|
417
|
-
machine_definition(): string;
|
|
418
|
-
machine_language(): string;
|
|
419
|
-
machine_license(): string;
|
|
420
|
-
machine_name(): string;
|
|
421
|
-
machine_version(): string;
|
|
422
|
-
raw_state_declarations(): Array<Object>;
|
|
423
|
-
state_declaration(which: StateType): JssmStateDeclaration;
|
|
424
|
-
state_declarations(): Map<StateType, JssmStateDeclaration>;
|
|
425
|
-
fsl_version(): string;
|
|
426
|
-
machine_state(): JssmMachineInternalState<mDT>;
|
|
427
|
-
/*********
|
|
428
|
-
*
|
|
429
|
-
* List all the states known by the machine. Please note that the order of
|
|
430
|
-
* these states is not guaranteed.
|
|
431
|
-
*
|
|
432
|
-
* ```typescript
|
|
433
|
-
* import * as jssm from 'jssm';
|
|
434
|
-
*
|
|
435
|
-
* const lswitch = jssm.from('on <=> off;');
|
|
436
|
-
* console.log( lswitch.states() ); // ['on', 'off']
|
|
437
|
-
* ```
|
|
438
|
-
*
|
|
439
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
440
|
-
*
|
|
441
|
-
*/
|
|
442
|
-
states(): Array<StateType>;
|
|
443
|
-
state_for(whichState: StateType): JssmGenericState;
|
|
444
|
-
/*********
|
|
445
|
-
*
|
|
446
|
-
* Check whether the machine knows a given state.
|
|
447
|
-
*
|
|
448
|
-
* ```typescript
|
|
449
|
-
* import * as jssm from 'jssm';
|
|
450
|
-
*
|
|
451
|
-
* const lswitch = jssm.from('on <=> off;');
|
|
452
|
-
*
|
|
453
|
-
* console.log( lswitch.has_state('off') ); // true
|
|
454
|
-
* console.log( lswitch.has_state('dance') ); // false
|
|
455
|
-
* ```
|
|
456
|
-
*
|
|
457
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
458
|
-
*
|
|
459
|
-
* @param whichState The state to be checked for extance
|
|
460
|
-
*
|
|
461
|
-
*/
|
|
462
|
-
has_state(whichState: StateType): boolean;
|
|
463
|
-
/*********
|
|
464
|
-
*
|
|
465
|
-
* Lists all edges of a machine.
|
|
466
|
-
*
|
|
467
|
-
* ```typescript
|
|
468
|
-
* import { sm } from 'jssm';
|
|
469
|
-
*
|
|
470
|
-
* const lswitch = sm`on 'toggle' <=> 'toggle' off;`;
|
|
471
|
-
*
|
|
472
|
-
* lswitch.list_edges();
|
|
473
|
-
* [
|
|
474
|
-
* {
|
|
475
|
-
* from: 'on',
|
|
476
|
-
* to: 'off',
|
|
477
|
-
* kind: 'main',
|
|
478
|
-
* forced_only: false,
|
|
479
|
-
* main_path: true,
|
|
480
|
-
* action: 'toggle'
|
|
481
|
-
* },
|
|
482
|
-
* {
|
|
483
|
-
* from: 'off',
|
|
484
|
-
* to: 'on',
|
|
485
|
-
* kind: 'main',
|
|
486
|
-
* forced_only: false,
|
|
487
|
-
* main_path: true,
|
|
488
|
-
* action: 'toggle'
|
|
489
|
-
* }
|
|
490
|
-
* ]
|
|
491
|
-
* ```
|
|
492
|
-
*
|
|
493
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
494
|
-
*
|
|
495
|
-
*/
|
|
496
|
-
list_edges(): Array<JssmTransition<StateType, mDT>>;
|
|
497
|
-
list_named_transitions(): Map<StateType, number>;
|
|
498
|
-
list_actions(): Array<StateType>;
|
|
499
|
-
get uses_actions(): boolean;
|
|
500
|
-
get uses_forced_transitions(): boolean;
|
|
501
|
-
/*********
|
|
502
|
-
*
|
|
503
|
-
* Check if the code that built the machine allows overriding state and data.
|
|
504
|
-
*
|
|
505
|
-
*/
|
|
506
|
-
get code_allows_override(): JssmAllowsOverride;
|
|
507
|
-
/*********
|
|
508
|
-
*
|
|
509
|
-
* Check if the machine config allows overriding state and data.
|
|
510
|
-
*
|
|
511
|
-
*/
|
|
512
|
-
get config_allows_override(): JssmAllowsOverride;
|
|
513
|
-
/*********
|
|
514
|
-
*
|
|
515
|
-
* Check if a machine allows overriding state and data.
|
|
516
|
-
*
|
|
517
|
-
*/
|
|
518
|
-
get allows_override(): JssmAllowsOverride;
|
|
519
|
-
all_themes(): FslTheme[];
|
|
520
|
-
get themes(): FslTheme | FslTheme[];
|
|
521
|
-
set themes(to: FslTheme | FslTheme[]);
|
|
522
|
-
flow(): FslDirection;
|
|
523
|
-
get_transition_by_state_names(from: StateType, to: StateType): number;
|
|
524
|
-
lookup_transition_for(from: StateType, to: StateType): JssmTransition<StateType, mDT>;
|
|
525
|
-
/********
|
|
526
|
-
*
|
|
527
|
-
* List all transitions attached to the current state, sorted by entrance and
|
|
528
|
-
* exit. The order of each sublist is not defined. A node could appear in
|
|
529
|
-
* both lists.
|
|
530
|
-
*
|
|
531
|
-
* ```typescript
|
|
532
|
-
* import { sm } from 'jssm';
|
|
533
|
-
*
|
|
534
|
-
* const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
535
|
-
*
|
|
536
|
-
* light.state(); // 'red'
|
|
537
|
-
* light.list_transitions(); // { entrances: [ 'yellow', 'off' ], exits: [ 'green', 'off' ] }
|
|
538
|
-
* ```
|
|
539
|
-
*
|
|
540
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
541
|
-
*
|
|
542
|
-
* @param whichState The state whose transitions to have listed
|
|
543
|
-
*
|
|
544
|
-
*/
|
|
545
|
-
list_transitions(whichState?: StateType): JssmTransitionList;
|
|
546
|
-
/********
|
|
547
|
-
*
|
|
548
|
-
* List all entrances attached to the current state. Please note that the
|
|
549
|
-
* order of the list is not defined. This list includes both unforced and
|
|
550
|
-
* forced entrances; if this isn't desired, consider
|
|
551
|
-
* {@link list_unforced_entrances} or {@link list_forced_entrances} as
|
|
552
|
-
* appropriate.
|
|
553
|
-
*
|
|
554
|
-
* ```typescript
|
|
555
|
-
* import { sm } from 'jssm';
|
|
556
|
-
*
|
|
557
|
-
* const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
558
|
-
*
|
|
559
|
-
* light.state(); // 'red'
|
|
560
|
-
* light.list_entrances(); // [ 'yellow', 'off' ]
|
|
561
|
-
* ```
|
|
562
|
-
*
|
|
563
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
564
|
-
*
|
|
565
|
-
* @param whichState The state whose entrances to have listed
|
|
566
|
-
*
|
|
567
|
-
*/
|
|
568
|
-
list_entrances(whichState?: StateType): Array<StateType>;
|
|
569
|
-
/********
|
|
570
|
-
*
|
|
571
|
-
* List all exits attached to the current state. Please note that the order
|
|
572
|
-
* of the list is not defined. This list includes both unforced and forced
|
|
573
|
-
* exits; if this isn't desired, consider {@link list_unforced_exits} or
|
|
574
|
-
* {@link list_forced_exits} as appropriate.
|
|
575
|
-
*
|
|
576
|
-
* ```typescript
|
|
577
|
-
* import { sm } from 'jssm';
|
|
578
|
-
*
|
|
579
|
-
* const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
580
|
-
*
|
|
581
|
-
* light.state(); // 'red'
|
|
582
|
-
* light.list_exits(); // [ 'green', 'off' ]
|
|
583
|
-
* ```
|
|
584
|
-
*
|
|
585
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
586
|
-
*
|
|
587
|
-
* @param whichState The state whose exits to have listed
|
|
588
|
-
*
|
|
589
|
-
*/
|
|
590
|
-
list_exits(whichState?: StateType): Array<StateType>;
|
|
591
|
-
probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
|
|
592
|
-
probabilistic_transition(): boolean;
|
|
593
|
-
probabilistic_walk(n: number): Array<StateType>;
|
|
594
|
-
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
595
|
-
/********
|
|
596
|
-
*
|
|
597
|
-
* List all actions available from this state. Please note that the order of
|
|
598
|
-
* the actions is not guaranteed.
|
|
599
|
-
*
|
|
600
|
-
* ```typescript
|
|
601
|
-
* import { sm } from 'jssm';
|
|
602
|
-
*
|
|
603
|
-
* const machine = sm`
|
|
604
|
-
* red 'next' -> green 'next' -> yellow 'next' -> red;
|
|
605
|
-
* [red yellow green] 'shutdown' ~> off 'start' -> red;
|
|
606
|
-
* `;
|
|
607
|
-
*
|
|
608
|
-
* console.log( machine.state() ); // logs 'red'
|
|
609
|
-
* console.log( machine.actions() ); // logs ['next', 'shutdown']
|
|
610
|
-
*
|
|
611
|
-
* machine.action('next'); // true
|
|
612
|
-
* console.log( machine.state() ); // logs 'green'
|
|
613
|
-
* console.log( machine.actions() ); // logs ['next', 'shutdown']
|
|
614
|
-
*
|
|
615
|
-
* machine.action('shutdown'); // true
|
|
616
|
-
* console.log( machine.state() ); // logs 'off'
|
|
617
|
-
* console.log( machine.actions() ); // logs ['start']
|
|
618
|
-
*
|
|
619
|
-
* machine.action('start'); // true
|
|
620
|
-
* console.log( machine.state() ); // logs 'red'
|
|
621
|
-
* console.log( machine.actions() ); // logs ['next', 'shutdown']
|
|
622
|
-
* ```
|
|
623
|
-
*
|
|
624
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
625
|
-
*
|
|
626
|
-
* @param whichState The state whose actions to have listed
|
|
627
|
-
*
|
|
628
|
-
*/
|
|
629
|
-
actions(whichState?: StateType): Array<StateType>;
|
|
630
|
-
/********
|
|
631
|
-
*
|
|
632
|
-
* List all states that have a specific action attached. Please note that
|
|
633
|
-
* the order of the states is not guaranteed.
|
|
634
|
-
*
|
|
635
|
-
* ```typescript
|
|
636
|
-
* import { sm } from 'jssm';
|
|
637
|
-
*
|
|
638
|
-
* const machine = sm`
|
|
639
|
-
* red 'next' -> green 'next' -> yellow 'next' -> red;
|
|
640
|
-
* [red yellow green] 'shutdown' ~> off 'start' -> red;
|
|
641
|
-
* `;
|
|
642
|
-
*
|
|
643
|
-
* console.log( machine.list_states_having_action('next') ); // ['red', 'green', 'yellow']
|
|
644
|
-
* console.log( machine.list_states_having_action('start') ); // ['off']
|
|
645
|
-
* ```
|
|
646
|
-
*
|
|
647
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
648
|
-
*
|
|
649
|
-
* @param whichState The action to be checked for associated states
|
|
650
|
-
*
|
|
651
|
-
*/
|
|
652
|
-
list_states_having_action(whichState: StateType): Array<StateType>;
|
|
653
|
-
list_exit_actions(whichState?: StateType): Array<StateType>;
|
|
654
|
-
probable_action_exits(whichState?: StateType): Array<any>;
|
|
655
|
-
is_unenterable(whichState: StateType): boolean;
|
|
656
|
-
has_unenterables(): boolean;
|
|
657
|
-
is_terminal(): boolean;
|
|
658
|
-
state_is_terminal(whichState: StateType): boolean;
|
|
659
|
-
has_terminals(): boolean;
|
|
660
|
-
is_complete(): boolean;
|
|
661
|
-
state_is_complete(whichState: StateType): boolean;
|
|
662
|
-
has_completes(): boolean;
|
|
663
|
-
set_hook(HookDesc: HookDescription<mDT>): void;
|
|
664
|
-
hook(from: string, to: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
665
|
-
hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
666
|
-
hook_global_action(action: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
667
|
-
hook_any_action(handler: HookHandler<mDT>): Machine<mDT>;
|
|
668
|
-
hook_standard_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
669
|
-
hook_main_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
670
|
-
hook_forced_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
671
|
-
hook_any_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
672
|
-
hook_entry(to: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
673
|
-
hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
674
|
-
hook_after(from: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
675
|
-
post_hook(from: string, to: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
676
|
-
post_hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
677
|
-
post_hook_global_action(action: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
678
|
-
post_hook_any_action(handler: HookHandler<mDT>): Machine<mDT>;
|
|
679
|
-
post_hook_standard_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
680
|
-
post_hook_main_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
681
|
-
post_hook_forced_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
682
|
-
post_hook_any_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
683
|
-
post_hook_entry(to: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
684
|
-
post_hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
685
|
-
get rng_seed(): number;
|
|
686
|
-
set rng_seed(to: number | undefined);
|
|
687
|
-
edges_between(from: string, to: string): JssmTransition<StateType, mDT>[];
|
|
688
|
-
/*********
|
|
689
|
-
*
|
|
690
|
-
* Replace the current state and data with no regard to the graph.
|
|
691
|
-
*
|
|
692
|
-
* ```typescript
|
|
693
|
-
* import { sm } from 'jssm';
|
|
694
|
-
*
|
|
695
|
-
* const machine = sm`a -> b -> c;`;
|
|
696
|
-
* console.log( machine.state() ); // 'a'
|
|
697
|
-
*
|
|
698
|
-
* machine.go('b');
|
|
699
|
-
* machine.go('c');
|
|
700
|
-
* console.log( machine.state() ); // 'c'
|
|
701
|
-
*
|
|
702
|
-
* machine.override('a');
|
|
703
|
-
* console.log( machine.state() ); // 'a'
|
|
704
|
-
* ```
|
|
705
|
-
*
|
|
706
|
-
*/
|
|
707
|
-
override(newState: StateType, newData?: mDT | undefined): void;
|
|
708
|
-
transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
|
|
709
|
-
auto_set_state_timeout(): void;
|
|
710
|
-
/*********
|
|
711
|
-
*
|
|
712
|
-
* Get a truncated history of the recent states and data of the machine.
|
|
713
|
-
* Turned off by default; configure with `.from('...', {data: 5})` by length,
|
|
714
|
-
* or set `.history_length` at runtime.
|
|
715
|
-
*
|
|
716
|
-
* History *does not contain the current state*. If you want that, call
|
|
717
|
-
* `.history_inclusive` instead.
|
|
718
|
-
*
|
|
719
|
-
* ```typescript
|
|
720
|
-
* const foo = jssm.from(
|
|
721
|
-
* "a 'next' -> b 'next' -> c 'next' -> d 'next' -> e;",
|
|
722
|
-
* { history: 3 }
|
|
723
|
-
* );
|
|
724
|
-
*
|
|
725
|
-
* foo.action('next');
|
|
726
|
-
* foo.action('next');
|
|
727
|
-
* foo.action('next');
|
|
728
|
-
* foo.action('next');
|
|
729
|
-
*
|
|
730
|
-
* foo.history; // [ ['b',undefined], ['c',undefined], ['d',undefined] ]
|
|
731
|
-
* ```
|
|
732
|
-
*
|
|
733
|
-
* Notice that the machine's current state, `e`, is not in the returned list.
|
|
734
|
-
*
|
|
735
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
736
|
-
*
|
|
737
|
-
*/
|
|
738
|
-
get history(): [string, mDT][];
|
|
739
|
-
/*********
|
|
740
|
-
*
|
|
741
|
-
* Get a truncated history of the recent states and data of the machine,
|
|
742
|
-
* including the current state. Turned off by default; configure with
|
|
743
|
-
* `.from('...', {data: 5})` by length, or set `.history_length` at runtime.
|
|
744
|
-
*
|
|
745
|
-
* History inclusive contains the current state. If you only want past
|
|
746
|
-
* states, call `.history` instead.
|
|
747
|
-
*
|
|
748
|
-
* The list returned will be one longer than the history buffer kept, as the
|
|
749
|
-
* history buffer kept gets the current state added to it to produce this
|
|
750
|
-
* list.
|
|
751
|
-
*
|
|
752
|
-
* ```typescript
|
|
753
|
-
* const foo = jssm.from(
|
|
754
|
-
* "a 'next' -> b 'next' -> c 'next' -> d 'next' -> e;",
|
|
755
|
-
* { history: 3 }
|
|
756
|
-
* );
|
|
757
|
-
*
|
|
758
|
-
* foo.action('next');
|
|
759
|
-
* foo.action('next');
|
|
760
|
-
* foo.action('next');
|
|
761
|
-
* foo.action('next');
|
|
762
|
-
*
|
|
763
|
-
* foo.history_inclusive; // [ ['b',undefined], ['c',undefined], ['d',undefined], ['e',undefined] ]
|
|
764
|
-
* ```
|
|
765
|
-
*
|
|
766
|
-
* Notice that the machine's current state, `e`, is in the returned list.
|
|
767
|
-
*
|
|
768
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
769
|
-
*
|
|
770
|
-
*/
|
|
771
|
-
get history_inclusive(): [string, mDT][];
|
|
772
|
-
/*********
|
|
773
|
-
*
|
|
774
|
-
* Find out how long a history this machine is keeping. Defaults to zero.
|
|
775
|
-
* Settable directly.
|
|
776
|
-
*
|
|
777
|
-
* ```typescript
|
|
778
|
-
* const foo = jssm.from("a -> b;");
|
|
779
|
-
* foo.history_length; // 0
|
|
780
|
-
*
|
|
781
|
-
* const bar = jssm.from("a -> b;", { history: 3 });
|
|
782
|
-
* foo.history_length; // 3
|
|
783
|
-
* foo.history_length = 5;
|
|
784
|
-
* foo.history_length; // 5
|
|
785
|
-
* ```
|
|
786
|
-
*
|
|
787
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
788
|
-
*
|
|
789
|
-
*/
|
|
790
|
-
get history_length(): number;
|
|
791
|
-
set history_length(to: number);
|
|
792
|
-
/********
|
|
793
|
-
*
|
|
794
|
-
* Instruct the machine to complete an action. Synonym for {@link do}.
|
|
795
|
-
*
|
|
796
|
-
* ```typescript
|
|
797
|
-
* const light = sm`red 'next' -> green 'next' -> yellow 'next' -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
798
|
-
*
|
|
799
|
-
* light.state(); // 'red'
|
|
800
|
-
* light.action('next'); // true
|
|
801
|
-
* light.state(); // 'green'
|
|
802
|
-
* ```
|
|
803
|
-
*
|
|
804
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
805
|
-
*
|
|
806
|
-
* @param actionName The action to engage
|
|
807
|
-
*
|
|
808
|
-
* @param newData The data change to insert during the action
|
|
809
|
-
*
|
|
810
|
-
*/
|
|
811
|
-
action(actionName: StateType, newData?: mDT): boolean;
|
|
812
|
-
/********
|
|
813
|
-
*
|
|
814
|
-
* Get the standard style for a single state. ***Does not*** include
|
|
815
|
-
* composition from an applied theme, or things from the underlying base
|
|
816
|
-
* stylesheet; only the modifications applied by this machine.
|
|
817
|
-
*
|
|
818
|
-
* ```typescript
|
|
819
|
-
* const light = sm`a -> b;`;
|
|
820
|
-
* console.log(light.standard_state_style);
|
|
821
|
-
* // {}
|
|
822
|
-
*
|
|
823
|
-
* const light = sm`a -> b; state: { shape: circle; };`;
|
|
824
|
-
* console.log(light.standard_state_style);
|
|
825
|
-
* // { shape: 'circle' }
|
|
826
|
-
* ```
|
|
827
|
-
*
|
|
828
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
829
|
-
*
|
|
830
|
-
*/
|
|
831
|
-
get standard_state_style(): JssmStateConfig;
|
|
832
|
-
/********
|
|
833
|
-
*
|
|
834
|
-
* Get the hooked state style. ***Does not*** include
|
|
835
|
-
* composition from an applied theme, or things from the underlying base
|
|
836
|
-
* stylesheet; only the modifications applied by this machine.
|
|
837
|
-
*
|
|
838
|
-
* The hooked style is only applied to nodes which have a named hook in the
|
|
839
|
-
* graph. Open hooks set through the external API aren't graphed, because
|
|
840
|
-
* that would be literally every node.
|
|
841
|
-
*
|
|
842
|
-
* ```typescript
|
|
843
|
-
* const light = sm`a -> b;`;
|
|
844
|
-
* console.log(light.hooked_state_style);
|
|
845
|
-
* // {}
|
|
846
|
-
*
|
|
847
|
-
* const light = sm`a -> b; hooked_state: { shape: circle; };`;
|
|
848
|
-
* console.log(light.hooked_state_style);
|
|
849
|
-
* // { shape: 'circle' }
|
|
850
|
-
* ```
|
|
851
|
-
*
|
|
852
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
853
|
-
*
|
|
854
|
-
*/
|
|
855
|
-
get hooked_state_style(): JssmStateConfig;
|
|
856
|
-
/********
|
|
857
|
-
*
|
|
858
|
-
* Get the start state style. ***Does not*** include composition from an
|
|
859
|
-
* applied theme, or things from the underlying base stylesheet; only the
|
|
860
|
-
* modifications applied by this machine.
|
|
861
|
-
*
|
|
862
|
-
* Start states are defined by the directive `start_states`, or in absentia,
|
|
863
|
-
* are the first mentioned state.
|
|
864
|
-
*
|
|
865
|
-
* ```typescript
|
|
866
|
-
* const light = sm`a -> b;`;
|
|
867
|
-
* console.log(light.start_state_style);
|
|
868
|
-
* // {}
|
|
869
|
-
*
|
|
870
|
-
* const light = sm`a -> b; start_state: { shape: circle; };`;
|
|
871
|
-
* console.log(light.start_state_style);
|
|
872
|
-
* // { shape: 'circle' }
|
|
873
|
-
* ```
|
|
874
|
-
*
|
|
875
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
876
|
-
*
|
|
877
|
-
*/
|
|
878
|
-
get start_state_style(): JssmStateConfig;
|
|
879
|
-
/********
|
|
880
|
-
*
|
|
881
|
-
* Get the end state style. ***Does not*** include
|
|
882
|
-
* composition from an applied theme, or things from the underlying base
|
|
883
|
-
* stylesheet; only the modifications applied by this machine.
|
|
884
|
-
*
|
|
885
|
-
* End states are defined in the directive `end_states`, and are distinct
|
|
886
|
-
* from terminal states. End states are voluntary successful endpoints for a
|
|
887
|
-
* process. Terminal states are states that cannot be exited. By example,
|
|
888
|
-
* most error states are terminal states, but not end states. Also, since
|
|
889
|
-
* some end states can be exited and are determined by hooks, such as
|
|
890
|
-
* recursive or iterative nodes, there is such a thing as an end state that
|
|
891
|
-
* is not a terminal state.
|
|
892
|
-
*
|
|
893
|
-
* ```typescript
|
|
894
|
-
* const light = sm`a -> b;`;
|
|
895
|
-
* console.log(light.standard_state_style);
|
|
896
|
-
* // {}
|
|
897
|
-
*
|
|
898
|
-
* const light = sm`a -> b; end_state: { shape: circle; };`;
|
|
899
|
-
* console.log(light.standard_state_style);
|
|
900
|
-
* // { shape: 'circle' }
|
|
901
|
-
* ```
|
|
902
|
-
*
|
|
903
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
904
|
-
*
|
|
905
|
-
*/
|
|
906
|
-
get end_state_style(): JssmStateConfig;
|
|
907
|
-
/********
|
|
908
|
-
*
|
|
909
|
-
* Get the terminal state style. ***Does not*** include
|
|
910
|
-
* composition from an applied theme, or things from the underlying base
|
|
911
|
-
* stylesheet; only the modifications applied by this machine.
|
|
912
|
-
*
|
|
913
|
-
* Terminal state styles are automatically determined by the machine. Any
|
|
914
|
-
* state without a valid exit transition is terminal.
|
|
915
|
-
*
|
|
916
|
-
* ```typescript
|
|
917
|
-
* const light = sm`a -> b;`;
|
|
918
|
-
* console.log(light.terminal_state_style);
|
|
919
|
-
* // {}
|
|
920
|
-
*
|
|
921
|
-
* const light = sm`a -> b; terminal_state: { shape: circle; };`;
|
|
922
|
-
* console.log(light.terminal_state_style);
|
|
923
|
-
* // { shape: 'circle' }
|
|
924
|
-
* ```
|
|
925
|
-
*
|
|
926
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
927
|
-
*
|
|
928
|
-
*/
|
|
929
|
-
get terminal_state_style(): JssmStateConfig;
|
|
930
|
-
/********
|
|
931
|
-
*
|
|
932
|
-
* Get the style for the active state. ***Does not*** include
|
|
933
|
-
* composition from an applied theme, or things from the underlying base
|
|
934
|
-
* stylesheet; only the modifications applied by this machine.
|
|
935
|
-
*
|
|
936
|
-
* ```typescript
|
|
937
|
-
* const light = sm`a -> b;`;
|
|
938
|
-
* console.log(light.active_state_style);
|
|
939
|
-
* // {}
|
|
940
|
-
*
|
|
941
|
-
* const light = sm`a -> b; active_state: { shape: circle; };`;
|
|
942
|
-
* console.log(light.active_state_style);
|
|
943
|
-
* // { shape: 'circle' }
|
|
944
|
-
* ```
|
|
945
|
-
*
|
|
946
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
947
|
-
*
|
|
948
|
-
*/
|
|
949
|
-
get active_state_style(): JssmStateConfig;
|
|
950
|
-
/********
|
|
951
|
-
*
|
|
952
|
-
* Gets the composite style for a specific node by individually imposing the
|
|
953
|
-
* style layers on a given object, after determining which layers are
|
|
954
|
-
* appropriate.
|
|
955
|
-
*
|
|
956
|
-
* The order of composition is base, then theme, then user content. Each
|
|
957
|
-
* item in the stack will be composited independently. First, the base state
|
|
958
|
-
* style, then the theme state style, then the user state style.
|
|
959
|
-
*
|
|
960
|
-
* After the three state styles, we'll composite the hooked styles; then the
|
|
961
|
-
* terminal styles; then the start styles; then the end styles; finally, the
|
|
962
|
-
* active styles. Remember, last wins.
|
|
963
|
-
*
|
|
964
|
-
* The base state style must exist. All other styles are optional.
|
|
965
|
-
*
|
|
966
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
967
|
-
*
|
|
968
|
-
*/
|
|
969
|
-
style_for(state: StateType): JssmStateConfig;
|
|
970
|
-
/********
|
|
971
|
-
*
|
|
972
|
-
* Instruct the machine to complete an action. Synonym for {@link action}.
|
|
973
|
-
*
|
|
974
|
-
* ```typescript
|
|
975
|
-
* const light = sm`
|
|
976
|
-
* off 'start' -> red;
|
|
977
|
-
* red 'next' -> green 'next' -> yellow 'next' -> red;
|
|
978
|
-
* [red yellow green] 'shutdown' ~> off;
|
|
979
|
-
* `;
|
|
980
|
-
*
|
|
981
|
-
* light.state(); // 'off'
|
|
982
|
-
* light.do('start'); // true
|
|
983
|
-
* light.state(); // 'red'
|
|
984
|
-
* light.do('next'); // true
|
|
985
|
-
* light.state(); // 'green'
|
|
986
|
-
* light.do('next'); // true
|
|
987
|
-
* light.state(); // 'yellow'
|
|
988
|
-
* light.do('dance'); // !! false - no such action
|
|
989
|
-
* light.state(); // 'yellow'
|
|
990
|
-
* light.do('start'); // !! false - yellow does not have the action start
|
|
991
|
-
* light.state(); // 'yellow'
|
|
992
|
-
* ```
|
|
993
|
-
*
|
|
994
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
995
|
-
*
|
|
996
|
-
* @param actionName The action to engage
|
|
997
|
-
*
|
|
998
|
-
* @param newData The data change to insert during the action
|
|
999
|
-
*
|
|
1000
|
-
*/
|
|
1001
|
-
do(actionName: StateType, newData?: mDT): boolean;
|
|
1002
|
-
/********
|
|
1003
|
-
*
|
|
1004
|
-
* Instruct the machine to complete a transition. Synonym for {@link go}.
|
|
1005
|
-
*
|
|
1006
|
-
* ```typescript
|
|
1007
|
-
* const light = sm`
|
|
1008
|
-
* off 'start' -> red;
|
|
1009
|
-
* red 'next' -> green 'next' -> yellow 'next' -> red;
|
|
1010
|
-
* [red yellow green] 'shutdown' ~> off;
|
|
1011
|
-
* `;
|
|
1012
|
-
*
|
|
1013
|
-
* light.state(); // 'off'
|
|
1014
|
-
* light.go('red'); // true
|
|
1015
|
-
* light.state(); // 'red'
|
|
1016
|
-
* light.go('green'); // true
|
|
1017
|
-
* light.state(); // 'green'
|
|
1018
|
-
* light.go('blue'); // !! false - no such state
|
|
1019
|
-
* light.state(); // 'green'
|
|
1020
|
-
* light.go('red'); // !! false - green may not go directly to red, only to yellow
|
|
1021
|
-
* light.state(); // 'green'
|
|
1022
|
-
* ```
|
|
1023
|
-
*
|
|
1024
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
1025
|
-
*
|
|
1026
|
-
* @param newState The state to switch to
|
|
1027
|
-
*
|
|
1028
|
-
* @param newData The data change to insert during the transition
|
|
1029
|
-
*
|
|
1030
|
-
*/
|
|
1031
|
-
transition(newState: StateType, newData?: mDT): boolean;
|
|
1032
|
-
/********
|
|
1033
|
-
*
|
|
1034
|
-
* Instruct the machine to complete a transition. Synonym for {@link transition}.
|
|
1035
|
-
*
|
|
1036
|
-
* ```typescript
|
|
1037
|
-
* const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
1038
|
-
*
|
|
1039
|
-
* light.state(); // 'red'
|
|
1040
|
-
* light.go('green'); // true
|
|
1041
|
-
* light.state(); // 'green'
|
|
1042
|
-
* ```
|
|
1043
|
-
*
|
|
1044
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
1045
|
-
*
|
|
1046
|
-
* @param newState The state to switch to
|
|
1047
|
-
*
|
|
1048
|
-
* @param newData The data change to insert during the transition
|
|
1049
|
-
*
|
|
1050
|
-
*/
|
|
1051
|
-
go(newState: StateType, newData?: mDT): boolean;
|
|
1052
|
-
/********
|
|
1053
|
-
*
|
|
1054
|
-
* Instruct the machine to complete a forced transition (which will reject if
|
|
1055
|
-
* called with a normal {@link transition} call.)
|
|
1056
|
-
*
|
|
1057
|
-
* ```typescript
|
|
1058
|
-
* const light = sm`red -> green -> yellow -> red; [red yellow green] 'shutdown' ~> off 'start' -> red;`;
|
|
1059
|
-
*
|
|
1060
|
-
* light.state(); // 'red'
|
|
1061
|
-
* light.transition('off'); // false
|
|
1062
|
-
* light.state(); // 'red'
|
|
1063
|
-
* light.force_transition('off'); // true
|
|
1064
|
-
* light.state(); // 'off'
|
|
1065
|
-
* ```
|
|
1066
|
-
*
|
|
1067
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
1068
|
-
*
|
|
1069
|
-
* @param newState The state to switch to
|
|
1070
|
-
*
|
|
1071
|
-
* @param newData The data change to insert during the transition
|
|
1072
|
-
*
|
|
1073
|
-
*/
|
|
1074
|
-
force_transition(newState: StateType, newData?: mDT): boolean;
|
|
1075
|
-
current_action_for(action: StateType): number;
|
|
1076
|
-
current_action_edge_for(action: StateType): JssmTransition<StateType, mDT>;
|
|
1077
|
-
valid_action(action: StateType, _newData?: mDT): boolean;
|
|
1078
|
-
valid_transition(newState: StateType, _newData?: mDT): boolean;
|
|
1079
|
-
valid_force_transition(newState: StateType, _newData?: mDT): boolean;
|
|
1080
|
-
instance_name(): string | undefined;
|
|
1081
|
-
get creation_date(): Date;
|
|
1082
|
-
get creation_timestamp(): number;
|
|
1083
|
-
get create_start_time(): number;
|
|
1084
|
-
set_state_timeout(next_state: StateType, after_time: number): void;
|
|
1085
|
-
clear_state_timeout(): void;
|
|
1086
|
-
state_timeout_for(which_state: StateType): [StateType, number] | undefined;
|
|
1087
|
-
current_state_timeout(): [StateType, number] | undefined;
|
|
1088
|
-
sm(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
|
|
1089
|
-
}
|
|
1090
|
-
/*********
|
|
1091
|
-
*
|
|
1092
|
-
* Create a state machine from a template string. This is one of the two main
|
|
1093
|
-
* paths for working with JSSM, alongside {@link from}.
|
|
1094
|
-
*
|
|
1095
|
-
* Use this method when you want to work directly and conveniently with a
|
|
1096
|
-
* constant template expression. Use `.from` when you want to pull from
|
|
1097
|
-
* dynamic strings.
|
|
1098
|
-
*
|
|
1099
|
-
*
|
|
1100
|
-
* ```typescript
|
|
1101
|
-
* import * as jssm from 'jssm';
|
|
1102
|
-
*
|
|
1103
|
-
* const lswitch = jssm.from('on <=> off;');
|
|
1104
|
-
* ```
|
|
1105
|
-
*
|
|
1106
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
1107
|
-
*
|
|
1108
|
-
* @param template_strings The assembled code
|
|
1109
|
-
*
|
|
1110
|
-
* @param remainder The mechanic for template argument insertion
|
|
1111
|
-
*
|
|
1112
|
-
*/
|
|
1113
|
-
declare function sm<mDT>(template_strings: TemplateStringsArray, ...remainder: any[]): Machine<mDT>;
|
|
1114
|
-
/*********
|
|
1115
|
-
*
|
|
1116
|
-
* Create a state machine from an implementation string. This is one of the
|
|
1117
|
-
* two main paths for working with JSSM, alongside {@link sm}.
|
|
1118
|
-
*
|
|
1119
|
-
* Use this method when you want to conveniently pull a state machine from a
|
|
1120
|
-
* string dynamically. Use operator `sm` when you just want to work with a
|
|
1121
|
-
* template expression.
|
|
1122
|
-
*
|
|
1123
|
-
* ```typescript
|
|
1124
|
-
* import * as jssm from 'jssm';
|
|
1125
|
-
*
|
|
1126
|
-
* const lswitch = jssm.from('on <=> off;');
|
|
1127
|
-
* ```
|
|
1128
|
-
*
|
|
1129
|
-
* @typeparam mDT The type of the machine data member; usually omitted
|
|
1130
|
-
*
|
|
1131
|
-
* @param MachineAsString The FSL code to evaluate
|
|
1132
|
-
*
|
|
1133
|
-
* @param ExtraConstructorFields Extra non-code configuration to pass at creation time
|
|
1134
|
-
*
|
|
1135
|
-
*/
|
|
1136
|
-
declare function from<mDT>(MachineAsString: string, ExtraConstructorFields?: Partial<JssmGenericConfig<StateType, mDT>> | undefined): Machine<mDT>;
|
|
1137
|
-
declare function is_hook_complex_result<mDT>(hr: unknown): hr is HookComplexResult<mDT>;
|
|
1138
|
-
declare function is_hook_rejection<mDT>(hr: HookResult<mDT>): boolean;
|
|
1139
|
-
declare function abstract_hook_step<mDT>(maybe_hook: HookHandler<mDT> | undefined, hook_args: HookContext<mDT>): HookComplexResult<mDT>;
|
|
1140
|
-
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
1141
|
-
export { version, build_time, transfer_state_properties, Machine, deserialize, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind, seq, unique, find_repeated, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, sleep, constants, shapes, gviz_shapes, named_colors, is_hook_rejection, is_hook_complex_result, abstract_hook_step, state_style_condense, FslDirections };
|