jssm 5.59.1 → 5.60.4
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/dist/es6/jssm.d.ts +7 -0
- package/dist/es6/jssm.js +70 -2
- package/dist/es6/jssm_types.d.ts +13 -1
- 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 +7 -0
- package/jssm_types.d.ts +13 -1
- package/package.json +1 -1
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -48,6 +48,9 @@ declare class Machine<mDT> {
|
|
|
48
48
|
_exit_hooks: Map<string, Function>;
|
|
49
49
|
_global_action_hooks: Map<string, Function>;
|
|
50
50
|
_any_action_hook: HookHandler | undefined;
|
|
51
|
+
_standard_transition_hook: HookHandler | undefined;
|
|
52
|
+
_main_transition_hook: HookHandler | undefined;
|
|
53
|
+
_forced_transition_hook: HookHandler | undefined;
|
|
51
54
|
_any_transition_hook: HookHandler | undefined;
|
|
52
55
|
constructor({ start_states, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout }: JssmGenericConfig<mDT>);
|
|
53
56
|
_new_state(state_config: JssmGenericState): StateType;
|
|
@@ -103,9 +106,13 @@ declare class Machine<mDT> {
|
|
|
103
106
|
hook_action(from: string, to: string, action: string, handler: HookHandler): Machine<mDT>;
|
|
104
107
|
hook_global_action(action: string, handler: HookHandler): Machine<mDT>;
|
|
105
108
|
hook_any_action(handler: HookHandler): Machine<mDT>;
|
|
109
|
+
hook_standard_transition(handler: HookHandler): Machine<mDT>;
|
|
110
|
+
hook_main_transition(handler: HookHandler): Machine<mDT>;
|
|
111
|
+
hook_forced_transition(handler: HookHandler): Machine<mDT>;
|
|
106
112
|
hook_any_transition(handler: HookHandler): Machine<mDT>;
|
|
107
113
|
hook_entry(to: string, handler: HookHandler): Machine<mDT>;
|
|
108
114
|
hook_exit(from: string, handler: HookHandler): Machine<mDT>;
|
|
115
|
+
edges_between(from: string, to: string): JssmTransition<mDT>[];
|
|
109
116
|
transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
|
|
110
117
|
action(actionName: StateType, newData?: mDT): boolean;
|
|
111
118
|
transition(newState: StateType, newData?: mDT): boolean;
|
package/dist/es6/jssm.js
CHANGED
|
@@ -357,7 +357,11 @@ class Machine {
|
|
|
357
357
|
this._exit_hooks = new Map();
|
|
358
358
|
this._global_action_hooks = new Map();
|
|
359
359
|
this._any_action_hook = undefined;
|
|
360
|
+
this._standard_transition_hook = undefined;
|
|
361
|
+
this._main_transition_hook = undefined;
|
|
362
|
+
this._forced_transition_hook = undefined;
|
|
360
363
|
this._any_transition_hook = undefined;
|
|
364
|
+
this._standard_transition_hook = undefined;
|
|
361
365
|
if (state_declaration) {
|
|
362
366
|
state_declaration.map((state_decl) => {
|
|
363
367
|
if (this._state_declarations.has(state_decl.state)) { // no repeats
|
|
@@ -728,6 +732,18 @@ class Machine {
|
|
|
728
732
|
this._any_action_hook = HookDesc.handler;
|
|
729
733
|
this._has_hooks = true;
|
|
730
734
|
break;
|
|
735
|
+
case 'standard transition':
|
|
736
|
+
this._standard_transition_hook = HookDesc.handler;
|
|
737
|
+
this._has_hooks = true;
|
|
738
|
+
break;
|
|
739
|
+
case 'main transition':
|
|
740
|
+
this._main_transition_hook = HookDesc.handler;
|
|
741
|
+
this._has_hooks = true;
|
|
742
|
+
break;
|
|
743
|
+
case 'forced transition':
|
|
744
|
+
this._forced_transition_hook = HookDesc.handler;
|
|
745
|
+
this._has_hooks = true;
|
|
746
|
+
break;
|
|
731
747
|
case 'any transition':
|
|
732
748
|
this._any_transition_hook = HookDesc.handler;
|
|
733
749
|
this._has_hooks = true;
|
|
@@ -765,6 +781,21 @@ class Machine {
|
|
|
765
781
|
this.set_hook({ kind: 'any action', handler });
|
|
766
782
|
return this;
|
|
767
783
|
}
|
|
784
|
+
hook_standard_transition(handler) {
|
|
785
|
+
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
786
|
+
this.set_hook({ kind: 'standard transition', handler });
|
|
787
|
+
return this;
|
|
788
|
+
}
|
|
789
|
+
hook_main_transition(handler) {
|
|
790
|
+
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
791
|
+
this.set_hook({ kind: 'main transition', handler });
|
|
792
|
+
return this;
|
|
793
|
+
}
|
|
794
|
+
hook_forced_transition(handler) {
|
|
795
|
+
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
796
|
+
this.set_hook({ kind: 'forced transition', handler });
|
|
797
|
+
return this;
|
|
798
|
+
}
|
|
768
799
|
hook_any_transition(handler) {
|
|
769
800
|
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
770
801
|
this.set_hook({ kind: 'any transition', handler });
|
|
@@ -783,11 +814,17 @@ class Machine {
|
|
|
783
814
|
// remove_hook(HookDesc: HookDescription) {
|
|
784
815
|
// throw 'TODO: Should remove hook here';
|
|
785
816
|
// }
|
|
817
|
+
edges_between(from, to) {
|
|
818
|
+
return this._edges.filter(edge => ((edge.from === from) && (edge.to === to)));
|
|
819
|
+
}
|
|
786
820
|
transition_impl(newStateOrAction, newData, wasForced, wasAction) {
|
|
787
|
-
|
|
821
|
+
// TODO the forced-ness behavior needs to be cleaned up a lot here
|
|
822
|
+
// TODO all the callbacks are wrong on forced, action, etc
|
|
823
|
+
let valid = false, trans_type, newState;
|
|
788
824
|
if (wasForced) {
|
|
789
825
|
if (this.valid_force_transition(newStateOrAction, newData)) {
|
|
790
826
|
valid = true;
|
|
827
|
+
trans_type = 'forced';
|
|
791
828
|
newState = newStateOrAction;
|
|
792
829
|
}
|
|
793
830
|
}
|
|
@@ -795,12 +832,14 @@ class Machine {
|
|
|
795
832
|
if (this.valid_action(newStateOrAction, newData)) {
|
|
796
833
|
const edge = this.current_action_edge_for(newStateOrAction);
|
|
797
834
|
valid = true;
|
|
835
|
+
trans_type = edge.kind;
|
|
798
836
|
newState = edge.to;
|
|
799
837
|
}
|
|
800
838
|
}
|
|
801
839
|
else {
|
|
802
840
|
if (this.valid_transition(newStateOrAction, newData)) {
|
|
803
841
|
valid = true;
|
|
842
|
+
trans_type = this.edges_between(this._state, newStateOrAction)[0].kind; // TODO this won't do the right thing if various edges have different types
|
|
804
843
|
newState = newStateOrAction;
|
|
805
844
|
}
|
|
806
845
|
}
|
|
@@ -853,7 +892,36 @@ class Machine {
|
|
|
853
892
|
}
|
|
854
893
|
}
|
|
855
894
|
// 7. edge type hook
|
|
856
|
-
//
|
|
895
|
+
// 7a. standard transition hook
|
|
896
|
+
if (trans_type === 'legal') {
|
|
897
|
+
if (this._standard_transition_hook !== undefined) {
|
|
898
|
+
// todo handle actions
|
|
899
|
+
// todo handle forced
|
|
900
|
+
if (this._standard_transition_hook({ from: this._state, to: newState }) === false) {
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
// 7b. main type hook
|
|
906
|
+
if (trans_type === 'main') {
|
|
907
|
+
if (this._main_transition_hook !== undefined) {
|
|
908
|
+
// todo handle actions
|
|
909
|
+
// todo handle forced
|
|
910
|
+
if (this._main_transition_hook({ from: this._state, to: newState }) === false) {
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
// 7c. forced transition hook
|
|
916
|
+
if (trans_type === 'forced') {
|
|
917
|
+
if (this._forced_transition_hook !== undefined) {
|
|
918
|
+
// todo handle actions
|
|
919
|
+
// todo handle forced
|
|
920
|
+
if (this._forced_transition_hook({ from: this._state, to: newState }) === false) {
|
|
921
|
+
return false;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
857
925
|
// 8. entry hook
|
|
858
926
|
const maybe_en_hook = this._entry_hooks.get(newState);
|
|
859
927
|
if (maybe_en_hook !== undefined) {
|
package/dist/es6/jssm_types.d.ts
CHANGED
|
@@ -162,6 +162,18 @@ declare type HookDescriptionWithAction = {
|
|
|
162
162
|
action: string;
|
|
163
163
|
handler: HookHandler;
|
|
164
164
|
};
|
|
165
|
+
declare type StandardTransitionHook = {
|
|
166
|
+
kind: 'standard transition';
|
|
167
|
+
handler: HookHandler;
|
|
168
|
+
};
|
|
169
|
+
declare type MainTransitionHook = {
|
|
170
|
+
kind: 'main transition';
|
|
171
|
+
handler: HookHandler;
|
|
172
|
+
};
|
|
173
|
+
declare type ForcedTransitionHook = {
|
|
174
|
+
kind: 'forced transition';
|
|
175
|
+
handler: HookHandler;
|
|
176
|
+
};
|
|
165
177
|
declare type AnyTransitionHook = {
|
|
166
178
|
kind: 'any transition';
|
|
167
179
|
handler: HookHandler;
|
|
@@ -185,5 +197,5 @@ declare type ExitHook = {
|
|
|
185
197
|
from: string;
|
|
186
198
|
handler: HookHandler;
|
|
187
199
|
};
|
|
188
|
-
declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | GlobalActionHook | AnyActionHook | AnyTransitionHook | EntryHook | ExitHook;
|
|
200
|
+
declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | GlobalActionHook | AnyActionHook | StandardTransitionHook | MainTransitionHook | ForcedTransitionHook | AnyTransitionHook | EntryHook | ExitHook;
|
|
189
201
|
export { JssmColor, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmLayout, JssmParseFunctionType, JssmMachineInternalState, FslDirection, FslTheme, HookDescription, HookHandler };
|
package/dist/es6/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.60.4";
|
|
2
2
|
export { version };
|