jssm 5.57.0 → 5.58.1
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 +3 -0
- package/dist/es6/jssm.js +29 -6
- package/dist/es6/jssm_types.d.ts +5 -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 +3 -0
- package/jssm_types.d.ts +5 -1
- package/package.json +1 -1
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ declare class Machine<mDT> {
|
|
|
46
46
|
_named_hooks: Map<string, Function>;
|
|
47
47
|
_entry_hooks: Map<string, Function>;
|
|
48
48
|
_exit_hooks: Map<string, Function>;
|
|
49
|
+
_any_action_hook: HookHandler | undefined;
|
|
49
50
|
_any_transition_hook: HookHandler | undefined;
|
|
50
51
|
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>);
|
|
51
52
|
_new_state(state_config: JssmGenericState): StateType;
|
|
@@ -99,8 +100,10 @@ declare class Machine<mDT> {
|
|
|
99
100
|
set_hook(HookDesc: HookDescription): void;
|
|
100
101
|
hook(from: string, to: string, handler: HookHandler): Machine<mDT>;
|
|
101
102
|
hook_action(from: string, to: string, action: string, handler: HookHandler): Machine<mDT>;
|
|
103
|
+
hook_any_action(handler: HookHandler): Machine<mDT>;
|
|
102
104
|
hook_any_transition(handler: HookHandler): Machine<mDT>;
|
|
103
105
|
hook_entry(to: string, handler: HookHandler): Machine<mDT>;
|
|
106
|
+
hook_exit(from: string, handler: HookHandler): Machine<mDT>;
|
|
104
107
|
transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
|
|
105
108
|
action(actionName: StateType, newData?: mDT): boolean;
|
|
106
109
|
transition(newState: StateType, newData?: mDT): boolean;
|
package/dist/es6/jssm.js
CHANGED
|
@@ -355,6 +355,7 @@ class Machine {
|
|
|
355
355
|
this._named_hooks = new Map();
|
|
356
356
|
this._entry_hooks = new Map();
|
|
357
357
|
this._exit_hooks = new Map();
|
|
358
|
+
this._any_action_hook = undefined;
|
|
358
359
|
this._any_transition_hook = undefined;
|
|
359
360
|
if (state_declaration) {
|
|
360
361
|
state_declaration.map((state_decl) => {
|
|
@@ -718,6 +719,10 @@ class Machine {
|
|
|
718
719
|
this._named_hooks.set(named_hook_name(HookDesc.from, HookDesc.to, HookDesc.action), HookDesc.handler);
|
|
719
720
|
this._has_hooks = true;
|
|
720
721
|
break;
|
|
722
|
+
case 'any action':
|
|
723
|
+
this._any_action_hook = HookDesc.handler;
|
|
724
|
+
this._has_hooks = true;
|
|
725
|
+
break;
|
|
721
726
|
case 'any transition':
|
|
722
727
|
this._any_transition_hook = HookDesc.handler;
|
|
723
728
|
this._has_hooks = true;
|
|
@@ -745,6 +750,11 @@ class Machine {
|
|
|
745
750
|
this.set_hook({ kind: 'named', from, to, action, handler });
|
|
746
751
|
return this;
|
|
747
752
|
}
|
|
753
|
+
hook_any_action(handler) {
|
|
754
|
+
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
755
|
+
this.set_hook({ kind: 'any action', handler });
|
|
756
|
+
return this;
|
|
757
|
+
}
|
|
748
758
|
hook_any_transition(handler) {
|
|
749
759
|
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
750
760
|
this.set_hook({ kind: 'any transition', handler });
|
|
@@ -755,6 +765,11 @@ class Machine {
|
|
|
755
765
|
this.set_hook({ kind: 'entry', to, handler });
|
|
756
766
|
return this;
|
|
757
767
|
}
|
|
768
|
+
hook_exit(from, handler) {
|
|
769
|
+
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
770
|
+
this.set_hook({ kind: 'exit', from, handler });
|
|
771
|
+
return this;
|
|
772
|
+
}
|
|
758
773
|
// remove_hook(HookDesc: HookDescription) {
|
|
759
774
|
// throw 'TODO: Should remove hook here';
|
|
760
775
|
// }
|
|
@@ -784,21 +799,29 @@ class Machine {
|
|
|
784
799
|
if (valid) {
|
|
785
800
|
if (this._has_hooks) {
|
|
786
801
|
// 1. any action hook
|
|
802
|
+
if (wasAction) {
|
|
803
|
+
if (this._any_action_hook !== undefined) {
|
|
804
|
+
if (this._any_action_hook() === false) {
|
|
805
|
+
return false;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
// 2. global specific action hook
|
|
787
810
|
// not yet implemented
|
|
788
|
-
//
|
|
811
|
+
// 3. any transition hook
|
|
789
812
|
if (this._any_transition_hook !== undefined) {
|
|
790
813
|
if (this._any_transition_hook() === false) {
|
|
791
814
|
return false;
|
|
792
815
|
}
|
|
793
816
|
}
|
|
794
|
-
//
|
|
817
|
+
// 4. exit hook
|
|
795
818
|
const maybe_ex_hook = this._exit_hooks.get(this._state);
|
|
796
819
|
if (maybe_ex_hook !== undefined) {
|
|
797
820
|
if (maybe_ex_hook({ from: this._state, forced: wasForced }) === false) {
|
|
798
821
|
return false;
|
|
799
822
|
}
|
|
800
823
|
}
|
|
801
|
-
//
|
|
824
|
+
// 5. named transition / action hook
|
|
802
825
|
if (wasAction) {
|
|
803
826
|
const nhn = named_hook_name(this._state, newState, newStateOrAction), n_maybe_hook = this._named_hooks.get(nhn);
|
|
804
827
|
if (n_maybe_hook !== undefined) {
|
|
@@ -807,16 +830,16 @@ class Machine {
|
|
|
807
830
|
}
|
|
808
831
|
}
|
|
809
832
|
}
|
|
810
|
-
//
|
|
833
|
+
// 6. regular hook
|
|
811
834
|
const hn = hook_name(this._state, newState), maybe_hook = this._hooks.get(hn);
|
|
812
835
|
if (maybe_hook !== undefined) {
|
|
813
836
|
if (maybe_hook({ from: this._state, to: newState, forced: wasForced, action: wasAction ? newStateOrAction : undefined }) === false) {
|
|
814
837
|
return false;
|
|
815
838
|
}
|
|
816
839
|
}
|
|
817
|
-
//
|
|
840
|
+
// 7. edge type hook
|
|
818
841
|
// not yet implemented
|
|
819
|
-
//
|
|
842
|
+
// 8. entry hook
|
|
820
843
|
const maybe_en_hook = this._entry_hooks.get(newState);
|
|
821
844
|
if (maybe_en_hook !== undefined) {
|
|
822
845
|
if (maybe_en_hook({ to: newState, forced: wasForced }) === false) {
|
package/dist/es6/jssm_types.d.ts
CHANGED
|
@@ -166,6 +166,10 @@ declare type AnyTransitionHook = {
|
|
|
166
166
|
kind: 'any transition';
|
|
167
167
|
handler: HookHandler;
|
|
168
168
|
};
|
|
169
|
+
declare type AnyActionHook = {
|
|
170
|
+
kind: 'any action';
|
|
171
|
+
handler: HookHandler;
|
|
172
|
+
};
|
|
169
173
|
declare type EntryHook = {
|
|
170
174
|
kind: 'entry';
|
|
171
175
|
to: string;
|
|
@@ -176,5 +180,5 @@ declare type ExitHook = {
|
|
|
176
180
|
from: string;
|
|
177
181
|
handler: HookHandler;
|
|
178
182
|
};
|
|
179
|
-
declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | AnyTransitionHook | EntryHook | ExitHook;
|
|
183
|
+
declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | AnyActionHook | AnyTransitionHook | EntryHook | ExitHook;
|
|
180
184
|
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.58.1";
|
|
2
2
|
export { version };
|