jssm 5.56.1 → 5.57.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 +4 -0
- package/dist/es6/jssm.js +22 -4
- 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 +4 -0
- package/package.json +1 -1
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -41,9 +41,11 @@ declare class Machine<mDT> {
|
|
|
41
41
|
_has_basic_hooks: boolean;
|
|
42
42
|
_has_named_hooks: boolean;
|
|
43
43
|
_has_entry_hooks: boolean;
|
|
44
|
+
_has_exit_hooks: boolean;
|
|
44
45
|
_hooks: Map<string, Function>;
|
|
45
46
|
_named_hooks: Map<string, Function>;
|
|
46
47
|
_entry_hooks: Map<string, Function>;
|
|
48
|
+
_exit_hooks: Map<string, Function>;
|
|
47
49
|
_any_transition_hook: HookHandler | undefined;
|
|
48
50
|
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>);
|
|
49
51
|
_new_state(state_config: JssmGenericState): StateType;
|
|
@@ -98,6 +100,8 @@ declare class Machine<mDT> {
|
|
|
98
100
|
hook(from: string, to: string, handler: HookHandler): Machine<mDT>;
|
|
99
101
|
hook_action(from: string, to: string, action: string, handler: HookHandler): Machine<mDT>;
|
|
100
102
|
hook_any_transition(handler: HookHandler): Machine<mDT>;
|
|
103
|
+
hook_entry(to: string, handler: HookHandler): Machine<mDT>;
|
|
104
|
+
hook_exit(from: string, handler: HookHandler): Machine<mDT>;
|
|
101
105
|
transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
|
|
102
106
|
action(actionName: StateType, newData?: mDT): boolean;
|
|
103
107
|
transition(newState: StateType, newData?: mDT): boolean;
|
package/dist/es6/jssm.js
CHANGED
|
@@ -349,10 +349,12 @@ class Machine {
|
|
|
349
349
|
this._has_basic_hooks = false;
|
|
350
350
|
this._has_named_hooks = false;
|
|
351
351
|
this._has_entry_hooks = false;
|
|
352
|
+
this._has_exit_hooks = false;
|
|
352
353
|
// no need for a boolean has any transition hook, as it's one or nothing, so just test that for undefinedness
|
|
353
354
|
this._hooks = new Map();
|
|
354
355
|
this._named_hooks = new Map();
|
|
355
356
|
this._entry_hooks = new Map();
|
|
357
|
+
this._exit_hooks = new Map();
|
|
356
358
|
this._any_transition_hook = undefined;
|
|
357
359
|
if (state_declaration) {
|
|
358
360
|
state_declaration.map((state_decl) => {
|
|
@@ -724,9 +726,10 @@ class Machine {
|
|
|
724
726
|
this._entry_hooks.set(HookDesc.to, HookDesc.handler);
|
|
725
727
|
this._has_hooks = true;
|
|
726
728
|
break;
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
729
|
+
case 'exit':
|
|
730
|
+
this._exit_hooks.set(HookDesc.from, HookDesc.handler);
|
|
731
|
+
this._has_hooks = true;
|
|
732
|
+
break;
|
|
730
733
|
default:
|
|
731
734
|
console.log(`Unknown hook type ${HookDesc.kind}, should be impossible`);
|
|
732
735
|
throw new RangeError(`Unknown hook type ${HookDesc.kind}, should be impossible`);
|
|
@@ -747,6 +750,16 @@ class Machine {
|
|
|
747
750
|
this.set_hook({ kind: 'any transition', handler });
|
|
748
751
|
return this;
|
|
749
752
|
}
|
|
753
|
+
hook_entry(to, handler) {
|
|
754
|
+
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
755
|
+
this.set_hook({ kind: 'entry', to, handler });
|
|
756
|
+
return this;
|
|
757
|
+
}
|
|
758
|
+
hook_exit(from, handler) {
|
|
759
|
+
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
760
|
+
this.set_hook({ kind: 'exit', from, handler });
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
750
763
|
// remove_hook(HookDesc: HookDescription) {
|
|
751
764
|
// throw 'TODO: Should remove hook here';
|
|
752
765
|
// }
|
|
@@ -784,7 +797,12 @@ class Machine {
|
|
|
784
797
|
}
|
|
785
798
|
}
|
|
786
799
|
// 3. exit hook
|
|
787
|
-
|
|
800
|
+
const maybe_ex_hook = this._exit_hooks.get(this._state);
|
|
801
|
+
if (maybe_ex_hook !== undefined) {
|
|
802
|
+
if (maybe_ex_hook({ from: this._state, forced: wasForced }) === false) {
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
788
806
|
// 4. named transition / action hook
|
|
789
807
|
if (wasAction) {
|
|
790
808
|
const nhn = named_hook_name(this._state, newState, newStateOrAction), n_maybe_hook = this._named_hooks.get(nhn);
|
package/dist/es6/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.57.1";
|
|
2
2
|
export { version };
|