jssm 5.49.0 → 5.52.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/dist/es6/jssm.d.ts +2 -1
- package/dist/es6/jssm.js +37 -68
- 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 -1
- package/package.json +1 -1
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -96,7 +96,8 @@ declare class Machine<mDT> {
|
|
|
96
96
|
hook(from: string, to: string, handler: HookHandler): Machine<mDT>;
|
|
97
97
|
hook_action(from: string, to: string, action: string, handler: HookHandler): Machine<mDT>;
|
|
98
98
|
hook_any_transition(handler: HookHandler): Machine<mDT>;
|
|
99
|
-
|
|
99
|
+
transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
|
|
100
|
+
action(actionName: StateType, newData?: mDT): boolean;
|
|
100
101
|
transition(newState: StateType, newData?: mDT): boolean;
|
|
101
102
|
force_transition(newState: StateType, newData?: mDT): boolean;
|
|
102
103
|
current_action_for(action: StateType): number;
|
package/dist/es6/jssm.js
CHANGED
|
@@ -746,47 +746,30 @@ class Machine {
|
|
|
746
746
|
// remove_hook(HookDesc: HookDescription) {
|
|
747
747
|
// throw 'TODO: Should remove hook here';
|
|
748
748
|
// }
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
if (this._has_hooks) {
|
|
756
|
-
let hook_permits = undefined;
|
|
757
|
-
if (this._any_transition_hook !== undefined) {
|
|
758
|
-
if (this._any_transition_hook() === false) {
|
|
759
|
-
return false;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
const nhn = named_hook_name(this._state, edge.to, name), maybe_hook = this._named_hooks.get(nhn);
|
|
763
|
-
if (maybe_hook === undefined) {
|
|
764
|
-
hook_permits = true;
|
|
765
|
-
}
|
|
766
|
-
else {
|
|
767
|
-
hook_permits = maybe_hook({ from: this._state, to: edge.to, action: name });
|
|
768
|
-
}
|
|
769
|
-
if (hook_permits !== false) {
|
|
770
|
-
this._state = edge.to;
|
|
771
|
-
return true;
|
|
772
|
-
}
|
|
773
|
-
else {
|
|
774
|
-
return false;
|
|
775
|
-
}
|
|
749
|
+
transition_impl(newStateOrAction, newData, wasForced, wasAction) {
|
|
750
|
+
let valid = false, newState;
|
|
751
|
+
if (wasForced) {
|
|
752
|
+
if (this.valid_force_transition(newStateOrAction, newData)) {
|
|
753
|
+
valid = true;
|
|
754
|
+
newState = newStateOrAction;
|
|
776
755
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
756
|
+
}
|
|
757
|
+
else if (wasAction) {
|
|
758
|
+
if (this.valid_action(newStateOrAction, newData)) {
|
|
759
|
+
const edge = this.current_action_edge_for(newStateOrAction);
|
|
760
|
+
valid = true;
|
|
761
|
+
newState = edge.to;
|
|
780
762
|
}
|
|
781
763
|
}
|
|
782
764
|
else {
|
|
783
|
-
|
|
765
|
+
if (this.valid_transition(newStateOrAction, newData)) {
|
|
766
|
+
valid = true;
|
|
767
|
+
newState = newStateOrAction;
|
|
768
|
+
}
|
|
784
769
|
}
|
|
785
|
-
}
|
|
786
|
-
transition(newState, newData) {
|
|
787
770
|
// todo whargarbl implement data stuff
|
|
788
771
|
// todo major incomplete whargarbl comeback
|
|
789
|
-
if (
|
|
772
|
+
if (valid) {
|
|
790
773
|
if (this._has_hooks) {
|
|
791
774
|
let hook_permits = undefined;
|
|
792
775
|
if (this._any_transition_hook !== undefined) {
|
|
@@ -794,39 +777,15 @@ class Machine {
|
|
|
794
777
|
return false;
|
|
795
778
|
}
|
|
796
779
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
return true;
|
|
807
|
-
}
|
|
808
|
-
else {
|
|
809
|
-
return false;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
else {
|
|
813
|
-
this._state = newState;
|
|
814
|
-
return true;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
else {
|
|
818
|
-
return false;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
// can leave machine in inconsistent state. generally do not use
|
|
822
|
-
force_transition(newState, newData) {
|
|
823
|
-
// todo whargarbl implement data stuff
|
|
824
|
-
// todo major incomplete whargarbl comeback
|
|
825
|
-
if (this.valid_force_transition(newState, newData)) {
|
|
826
|
-
if (this._has_hooks) {
|
|
827
|
-
let hook_permits = undefined;
|
|
828
|
-
if (this._any_transition_hook !== undefined) {
|
|
829
|
-
if (this._any_transition_hook() === false) {
|
|
780
|
+
if (wasAction) {
|
|
781
|
+
const nhn = named_hook_name(this._state, newState, newStateOrAction), n_maybe_hook = this._named_hooks.get(nhn);
|
|
782
|
+
if (n_maybe_hook === undefined) {
|
|
783
|
+
hook_permits = true;
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
hook_permits = n_maybe_hook({ from: this._state, to: newState, action: newStateOrAction });
|
|
787
|
+
}
|
|
788
|
+
if (!(hook_permits)) {
|
|
830
789
|
return false;
|
|
831
790
|
}
|
|
832
791
|
}
|
|
@@ -835,7 +794,7 @@ class Machine {
|
|
|
835
794
|
hook_permits = true;
|
|
836
795
|
}
|
|
837
796
|
else {
|
|
838
|
-
hook_permits = maybe_hook({ from: this._state, to: newState, forced:
|
|
797
|
+
hook_permits = maybe_hook({ from: this._state, to: newState, forced: wasForced, action: wasAction ? newStateOrAction : undefined });
|
|
839
798
|
}
|
|
840
799
|
if (hook_permits !== false) {
|
|
841
800
|
this._state = newState;
|
|
@@ -854,6 +813,16 @@ class Machine {
|
|
|
854
813
|
return false;
|
|
855
814
|
}
|
|
856
815
|
}
|
|
816
|
+
action(actionName, newData) {
|
|
817
|
+
return this.transition_impl(actionName, newData, false, true);
|
|
818
|
+
}
|
|
819
|
+
transition(newState, newData) {
|
|
820
|
+
return this.transition_impl(newState, newData, false, false);
|
|
821
|
+
}
|
|
822
|
+
// can leave machine in inconsistent state. generally do not use
|
|
823
|
+
force_transition(newState, newData) {
|
|
824
|
+
return this.transition_impl(newState, newData, true, false);
|
|
825
|
+
}
|
|
857
826
|
current_action_for(action) {
|
|
858
827
|
const action_base = this._actions.get(action);
|
|
859
828
|
return action_base
|
package/dist/es6/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.52.0";
|
|
2
2
|
export { version };
|