jssm 5.53.0 → 5.56.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-dot.js +1 -1
- package/dist/es6/jssm.d.ts +2 -0
- package/dist/es6/jssm.js +34 -23
- 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 +2 -0
- package/package.json +13 -9
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -40,8 +40,10 @@ declare class Machine<mDT> {
|
|
|
40
40
|
_has_hooks: boolean;
|
|
41
41
|
_has_basic_hooks: boolean;
|
|
42
42
|
_has_named_hooks: boolean;
|
|
43
|
+
_has_entry_hooks: boolean;
|
|
43
44
|
_hooks: Map<string, Function>;
|
|
44
45
|
_named_hooks: Map<string, Function>;
|
|
46
|
+
_entry_hooks: Map<string, Function>;
|
|
45
47
|
_any_transition_hook: HookHandler | undefined;
|
|
46
48
|
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>);
|
|
47
49
|
_new_state(state_config: JssmGenericState): StateType;
|
package/dist/es6/jssm.js
CHANGED
|
@@ -348,8 +348,11 @@ class Machine {
|
|
|
348
348
|
this._has_hooks = false;
|
|
349
349
|
this._has_basic_hooks = false;
|
|
350
350
|
this._has_named_hooks = false;
|
|
351
|
+
this._has_entry_hooks = false;
|
|
352
|
+
// no need for a boolean has any transition hook, as it's one or nothing, so just test that for undefinedness
|
|
351
353
|
this._hooks = new Map();
|
|
352
354
|
this._named_hooks = new Map();
|
|
355
|
+
this._entry_hooks = new Map();
|
|
353
356
|
this._any_transition_hook = undefined;
|
|
354
357
|
if (state_declaration) {
|
|
355
358
|
state_declaration.map((state_decl) => {
|
|
@@ -717,9 +720,10 @@ class Machine {
|
|
|
717
720
|
this._any_transition_hook = HookDesc.handler;
|
|
718
721
|
this._has_hooks = true;
|
|
719
722
|
break;
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
+
case 'entry':
|
|
724
|
+
this._entry_hooks.set(HookDesc.to, HookDesc.handler);
|
|
725
|
+
this._has_hooks = true;
|
|
726
|
+
break;
|
|
723
727
|
// case 'exit':
|
|
724
728
|
// console.log('TODO: Should add exit hook here');
|
|
725
729
|
// throw 'TODO: Should add exit hook here';
|
|
@@ -771,43 +775,50 @@ class Machine {
|
|
|
771
775
|
// todo major incomplete whargarbl comeback
|
|
772
776
|
if (valid) {
|
|
773
777
|
if (this._has_hooks) {
|
|
774
|
-
|
|
778
|
+
// 1. any action hook
|
|
779
|
+
// not yet implemented
|
|
780
|
+
// 2. any transition hook
|
|
775
781
|
if (this._any_transition_hook !== undefined) {
|
|
776
782
|
if (this._any_transition_hook() === false) {
|
|
777
783
|
return false;
|
|
778
784
|
}
|
|
779
785
|
}
|
|
786
|
+
// 3. exit hook
|
|
787
|
+
// not yet implemented
|
|
788
|
+
// 4. named transition / action hook
|
|
780
789
|
if (wasAction) {
|
|
781
790
|
const nhn = named_hook_name(this._state, newState, newStateOrAction), n_maybe_hook = this._named_hooks.get(nhn);
|
|
782
|
-
if (n_maybe_hook
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
hook_permits = n_maybe_hook({ from: this._state, to: newState, action: newStateOrAction });
|
|
787
|
-
}
|
|
788
|
-
if (!(hook_permits)) {
|
|
789
|
-
return false;
|
|
791
|
+
if (n_maybe_hook !== undefined) {
|
|
792
|
+
if (n_maybe_hook({ from: this._state, to: newState, action: newStateOrAction }) === false) {
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
790
795
|
}
|
|
791
796
|
}
|
|
797
|
+
// 5. regular hook
|
|
792
798
|
const hn = hook_name(this._state, newState), maybe_hook = this._hooks.get(hn);
|
|
793
|
-
if (maybe_hook
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
hook_permits = maybe_hook({ from: this._state, to: newState, forced: wasForced, action: wasAction ? newStateOrAction : undefined });
|
|
798
|
-
}
|
|
799
|
-
if (hook_permits !== false) {
|
|
800
|
-
this._state = newState;
|
|
801
|
-
return true;
|
|
799
|
+
if (maybe_hook !== undefined) {
|
|
800
|
+
if (maybe_hook({ from: this._state, to: newState, forced: wasForced, action: wasAction ? newStateOrAction : undefined }) === false) {
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
802
803
|
}
|
|
803
|
-
|
|
804
|
-
|
|
804
|
+
// 6. edge type hook
|
|
805
|
+
// not yet implemented
|
|
806
|
+
// 7. entry hook
|
|
807
|
+
const maybe_en_hook = this._entry_hooks.get(newState);
|
|
808
|
+
if (maybe_en_hook !== undefined) {
|
|
809
|
+
if (maybe_en_hook({ to: newState, forced: wasForced }) === false) {
|
|
810
|
+
return false;
|
|
811
|
+
}
|
|
805
812
|
}
|
|
813
|
+
this._state = newState;
|
|
814
|
+
return true;
|
|
815
|
+
// or without hooks
|
|
806
816
|
}
|
|
807
817
|
else {
|
|
808
818
|
this._state = newState;
|
|
809
819
|
return true;
|
|
810
820
|
}
|
|
821
|
+
// not valid
|
|
811
822
|
}
|
|
812
823
|
else {
|
|
813
824
|
return false;
|
package/dist/es6/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.56.0";
|
|
2
2
|
export { version };
|