jssm 5.79.16 → 5.80.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/CHANGELOG.md +45 -40
- package/README.md +2 -2
- package/dist/es6/jssm-dot.js +1 -1
- package/dist/es6/jssm.d.ts +222 -5
- package/dist/es6/jssm.js +371 -10
- package/dist/es6/jssm_base_stylesheet.d.ts +10 -0
- package/dist/es6/jssm_base_stylesheet.js +33 -0
- package/dist/es6/jssm_types.d.ts +39 -2
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs.js +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/jssm.d.ts +222 -5
- package/jssm_base_stylesheet.d.ts +10 -0
- package/jssm_types.d.ts +39 -2
- package/package.json +1 -1
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare type StateType = string;
|
|
2
|
-
import { JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
|
|
3
|
-
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult } from './jssm_types';
|
|
2
|
+
import { JssmGenericState, JssmGenericConfig, JssmStateConfig, JssmTransition, JssmTransitionList, // JssmTransitionRule,
|
|
3
|
+
JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmStateStyleKeyList, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult } from './jssm_types';
|
|
4
4
|
import { seq, unique, find_repeated, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
|
|
5
5
|
import * as constants from './jssm_constants';
|
|
6
6
|
declare const shapes: string[], gviz_shapes: string[], named_colors: string[];
|
|
@@ -188,6 +188,7 @@ declare function make<mDT>(plan: string): JssmGenericConfig<mDT>;
|
|
|
188
188
|
*
|
|
189
189
|
*/
|
|
190
190
|
declare function transfer_state_properties(state_decl: JssmStateDeclaration): JssmStateDeclaration;
|
|
191
|
+
declare function state_style_condense(jssk: JssmStateStyleKeyList): JssmStateConfig;
|
|
191
192
|
declare class Machine<mDT> {
|
|
192
193
|
_state: StateType;
|
|
193
194
|
_states: Map<StateType, JssmGenericState>;
|
|
@@ -197,6 +198,8 @@ declare class Machine<mDT> {
|
|
|
197
198
|
_actions: Map<StateType, Map<StateType, number>>;
|
|
198
199
|
_reverse_actions: Map<StateType, Map<StateType, number>>;
|
|
199
200
|
_reverse_action_targets: Map<StateType, Map<StateType, number>>;
|
|
201
|
+
_start_states: Set<StateType>;
|
|
202
|
+
_end_states: Set<StateType>;
|
|
200
203
|
_machine_author?: Array<string>;
|
|
201
204
|
_machine_comment?: string;
|
|
202
205
|
_machine_contributor?: Array<string>;
|
|
@@ -257,7 +260,13 @@ declare class Machine<mDT> {
|
|
|
257
260
|
_required_properties: Set<string>;
|
|
258
261
|
_history: JssmHistory<mDT>;
|
|
259
262
|
_history_length: number;
|
|
260
|
-
|
|
263
|
+
_state_style: JssmStateConfig;
|
|
264
|
+
_active_state_style: JssmStateConfig;
|
|
265
|
+
_hooked_state_style: JssmStateConfig;
|
|
266
|
+
_terminal_state_style: JssmStateConfig;
|
|
267
|
+
_start_state_style: JssmStateConfig;
|
|
268
|
+
_end_state_style: JssmStateConfig;
|
|
269
|
+
constructor({ start_states, end_states, 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 }: JssmGenericConfig<mDT>);
|
|
261
270
|
/********
|
|
262
271
|
*
|
|
263
272
|
* Internal method for fabricating states. Not meant for external use.
|
|
@@ -415,6 +424,56 @@ declare class Machine<mDT> {
|
|
|
415
424
|
*
|
|
416
425
|
*/
|
|
417
426
|
known_props(): string[];
|
|
427
|
+
/********
|
|
428
|
+
*
|
|
429
|
+
* Check whether a given state is a valid start state (either because it was
|
|
430
|
+
* explicitly named as such, or because it was the first mentioned state.)
|
|
431
|
+
*
|
|
432
|
+
* ```typescript
|
|
433
|
+
* import { sm, is_start_state } from 'jssm';
|
|
434
|
+
*
|
|
435
|
+
* const example = sm`a -> b;`;
|
|
436
|
+
*
|
|
437
|
+
* console.log( final_test.is_start_state('a') ); // true
|
|
438
|
+
* console.log( final_test.is_start_state('b') ); // false
|
|
439
|
+
*
|
|
440
|
+
* const example = sm`start_states: [a b]; a -> b;`;
|
|
441
|
+
*
|
|
442
|
+
* console.log( final_test.is_start_state('a') ); // true
|
|
443
|
+
* console.log( final_test.is_start_state('b') ); // true
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
447
|
+
*
|
|
448
|
+
* @param whichState The name of the state to check
|
|
449
|
+
*
|
|
450
|
+
*/
|
|
451
|
+
is_start_state(whichState: StateType): boolean;
|
|
452
|
+
/********
|
|
453
|
+
*
|
|
454
|
+
* Check whether a given state is a valid start state (either because it was
|
|
455
|
+
* explicitly named as such, or because it was the first mentioned state.)
|
|
456
|
+
*
|
|
457
|
+
* ```typescript
|
|
458
|
+
* import { sm, is_end_state } from 'jssm';
|
|
459
|
+
*
|
|
460
|
+
* const example = sm`a -> b;`;
|
|
461
|
+
*
|
|
462
|
+
* console.log( final_test.is_start_state('a') ); // false
|
|
463
|
+
* console.log( final_test.is_start_state('b') ); // true
|
|
464
|
+
*
|
|
465
|
+
* const example = sm`end_states: [a b]; a -> b;`;
|
|
466
|
+
*
|
|
467
|
+
* console.log( final_test.is_start_state('a') ); // true
|
|
468
|
+
* console.log( final_test.is_start_state('b') ); // true
|
|
469
|
+
* ```
|
|
470
|
+
*
|
|
471
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
472
|
+
*
|
|
473
|
+
* @param whichState The name of the state to check
|
|
474
|
+
*
|
|
475
|
+
*/
|
|
476
|
+
is_end_state(whichState: StateType): boolean;
|
|
418
477
|
/********
|
|
419
478
|
*
|
|
420
479
|
* Check whether a given state is final (either has no exits or is marked
|
|
@@ -441,7 +500,7 @@ declare class Machine<mDT> {
|
|
|
441
500
|
* `complete`.)
|
|
442
501
|
*
|
|
443
502
|
* ```typescript
|
|
444
|
-
* import { sm,
|
|
503
|
+
* import { sm, is_final } from 'jssm';
|
|
445
504
|
*
|
|
446
505
|
* const final_test = sm`first -> second;`;
|
|
447
506
|
*
|
|
@@ -812,6 +871,164 @@ declare class Machine<mDT> {
|
|
|
812
871
|
*
|
|
813
872
|
*/
|
|
814
873
|
action(actionName: StateType, newData?: mDT): boolean;
|
|
874
|
+
/********
|
|
875
|
+
*
|
|
876
|
+
* Get the standard style for a single state. ***Does not*** include
|
|
877
|
+
* composition from an applied theme, or things from the underlying base
|
|
878
|
+
* stylesheet; only the modifications applied by this machine.
|
|
879
|
+
*
|
|
880
|
+
* ```typescript
|
|
881
|
+
* const light = sm`a -> b;`;
|
|
882
|
+
* console.log(light.standard_state_style);
|
|
883
|
+
* // {}
|
|
884
|
+
*
|
|
885
|
+
* const light = sm`a -> b; state: { shape: circle; };`;
|
|
886
|
+
* console.log(light.standard_state_style);
|
|
887
|
+
* // { shape: 'circle' }
|
|
888
|
+
* ```
|
|
889
|
+
*
|
|
890
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
891
|
+
*
|
|
892
|
+
*/
|
|
893
|
+
get standard_state_style(): JssmStateConfig;
|
|
894
|
+
/********
|
|
895
|
+
*
|
|
896
|
+
* Get the hooked state style. ***Does not*** include
|
|
897
|
+
* composition from an applied theme, or things from the underlying base
|
|
898
|
+
* stylesheet; only the modifications applied by this machine.
|
|
899
|
+
*
|
|
900
|
+
* The hooked style is only applied to nodes which have a named hook in the
|
|
901
|
+
* graph. Open hooks set through the external API aren't graphed, because
|
|
902
|
+
* that would be literally every node.
|
|
903
|
+
*
|
|
904
|
+
* ```typescript
|
|
905
|
+
* const light = sm`a -> b;`;
|
|
906
|
+
* console.log(light.hooked_state_style);
|
|
907
|
+
* // {}
|
|
908
|
+
*
|
|
909
|
+
* const light = sm`a -> b; hooked_state: { shape: circle; };`;
|
|
910
|
+
* console.log(light.hooked_state_style);
|
|
911
|
+
* // { shape: 'circle' }
|
|
912
|
+
* ```
|
|
913
|
+
*
|
|
914
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
915
|
+
*
|
|
916
|
+
*/
|
|
917
|
+
get hooked_state_style(): JssmStateConfig;
|
|
918
|
+
/********
|
|
919
|
+
*
|
|
920
|
+
* Get the start state style. ***Does not*** include composition from an
|
|
921
|
+
* applied theme, or things from the underlying base stylesheet; only the
|
|
922
|
+
* modifications applied by this machine.
|
|
923
|
+
*
|
|
924
|
+
* Start states are defined by the directive `start_states`, or in absentia,
|
|
925
|
+
* are the first mentioned state.
|
|
926
|
+
*
|
|
927
|
+
* ```typescript
|
|
928
|
+
* const light = sm`a -> b;`;
|
|
929
|
+
* console.log(light.start_state_style);
|
|
930
|
+
* // {}
|
|
931
|
+
*
|
|
932
|
+
* const light = sm`a -> b; start_state: { shape: circle; };`;
|
|
933
|
+
* console.log(light.start_state_style);
|
|
934
|
+
* // { shape: 'circle' }
|
|
935
|
+
* ```
|
|
936
|
+
*
|
|
937
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
938
|
+
*
|
|
939
|
+
*/
|
|
940
|
+
get start_state_style(): JssmStateConfig;
|
|
941
|
+
/********
|
|
942
|
+
*
|
|
943
|
+
* Get the end state style. ***Does not*** include
|
|
944
|
+
* composition from an applied theme, or things from the underlying base
|
|
945
|
+
* stylesheet; only the modifications applied by this machine.
|
|
946
|
+
*
|
|
947
|
+
* End states are defined in the directive `end_states`, and are distinct
|
|
948
|
+
* from terminal states. End states are voluntary successful endpoints for a
|
|
949
|
+
* process. Terminal states are states that cannot be exited. By example,
|
|
950
|
+
* most error states are terminal states, but not end states. Also, since
|
|
951
|
+
* some end states can be exited and are determined by hooks, such as
|
|
952
|
+
* recursive or iterative nodes, there is such a thing as an end state that
|
|
953
|
+
* is not a terminal state.
|
|
954
|
+
*
|
|
955
|
+
* ```typescript
|
|
956
|
+
* const light = sm`a -> b;`;
|
|
957
|
+
* console.log(light.standard_state_style);
|
|
958
|
+
* // {}
|
|
959
|
+
*
|
|
960
|
+
* const light = sm`a -> b; end_state: { shape: circle; };`;
|
|
961
|
+
* console.log(light.standard_state_style);
|
|
962
|
+
* // { shape: 'circle' }
|
|
963
|
+
* ```
|
|
964
|
+
*
|
|
965
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
966
|
+
*
|
|
967
|
+
*/
|
|
968
|
+
get end_state_style(): JssmStateConfig;
|
|
969
|
+
/********
|
|
970
|
+
*
|
|
971
|
+
* Get the terminal state style. ***Does not*** include
|
|
972
|
+
* composition from an applied theme, or things from the underlying base
|
|
973
|
+
* stylesheet; only the modifications applied by this machine.
|
|
974
|
+
*
|
|
975
|
+
* Terminal state styles are automatically determined by the machine. Any
|
|
976
|
+
* state without a valid exit transition is terminal.
|
|
977
|
+
*
|
|
978
|
+
* ```typescript
|
|
979
|
+
* const light = sm`a -> b;`;
|
|
980
|
+
* console.log(light.terminal_state_style);
|
|
981
|
+
* // {}
|
|
982
|
+
*
|
|
983
|
+
* const light = sm`a -> b; terminal_state: { shape: circle; };`;
|
|
984
|
+
* console.log(light.terminal_state_style);
|
|
985
|
+
* // { shape: 'circle' }
|
|
986
|
+
* ```
|
|
987
|
+
*
|
|
988
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
989
|
+
*
|
|
990
|
+
*/
|
|
991
|
+
get terminal_state_style(): JssmStateConfig;
|
|
992
|
+
/********
|
|
993
|
+
*
|
|
994
|
+
* Get the style for the active state. ***Does not*** include
|
|
995
|
+
* composition from an applied theme, or things from the underlying base
|
|
996
|
+
* stylesheet; only the modifications applied by this machine.
|
|
997
|
+
*
|
|
998
|
+
* ```typescript
|
|
999
|
+
* const light = sm`a -> b;`;
|
|
1000
|
+
* console.log(light.active_state_style);
|
|
1001
|
+
* // {}
|
|
1002
|
+
*
|
|
1003
|
+
* const light = sm`a -> b; active_state: { shape: circle; };`;
|
|
1004
|
+
* console.log(light.active_state_style);
|
|
1005
|
+
* // { shape: 'circle' }
|
|
1006
|
+
* ```
|
|
1007
|
+
*
|
|
1008
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
1009
|
+
*
|
|
1010
|
+
*/
|
|
1011
|
+
get active_state_style(): JssmStateConfig;
|
|
1012
|
+
/********
|
|
1013
|
+
*
|
|
1014
|
+
* Gets the composite style for a specific node by individually imposing the
|
|
1015
|
+
* style layers on a given object, after determining which layers are
|
|
1016
|
+
* appropriate.
|
|
1017
|
+
*
|
|
1018
|
+
* The order of composition is base, then theme, then user content. Each
|
|
1019
|
+
* item in the stack will be composited independently. First, the base state
|
|
1020
|
+
* style, then the theme state style, then the user state style.
|
|
1021
|
+
*
|
|
1022
|
+
* After the three state styles, we'll composite the hooked styles; then the
|
|
1023
|
+
* terminal styles; then the start styles; then the end styles; finally, the
|
|
1024
|
+
* active styles. Remember, last wins.
|
|
1025
|
+
*
|
|
1026
|
+
* The base state style must exist. All other styles are optional.
|
|
1027
|
+
*
|
|
1028
|
+
* @typeparam mDT The type of the machine data member; usually omitted
|
|
1029
|
+
*
|
|
1030
|
+
*/
|
|
1031
|
+
style_for(state: StateType): JssmStateConfig;
|
|
815
1032
|
/********
|
|
816
1033
|
*
|
|
817
1034
|
* Instruct the machine to complete an action. Synonym for {@link action}.
|
|
@@ -976,4 +1193,4 @@ declare function is_hook_complex_result<mDT>(hr: unknown): hr is HookComplexResu
|
|
|
976
1193
|
declare function is_hook_rejection<mDT>(hr: HookResult<mDT>): boolean;
|
|
977
1194
|
declare function abstract_hook_step<mDT>(maybe_hook: HookHandler<mDT> | undefined, hook_args: HookContext<mDT>): HookComplexResult<mDT>;
|
|
978
1195
|
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
979
|
-
export { version, 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, constants, shapes, gviz_shapes, named_colors, is_hook_rejection, is_hook_complex_result, abstract_hook_step };
|
|
1196
|
+
export { version, 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, constants, shapes, gviz_shapes, named_colors, is_hook_rejection, is_hook_complex_result, abstract_hook_step, state_style_condense };
|