jssm 5.49.0 → 5.50.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.
@@ -97,6 +97,7 @@ declare class 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
  action(name: StateType, newData?: mDT): boolean;
100
+ transition_impl(newState: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): 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
@@ -783,46 +783,21 @@ class Machine {
783
783
  return false;
784
784
  }
785
785
  }
786
- transition(newState, newData) {
787
- // todo whargarbl implement data stuff
788
- // todo major incomplete whargarbl comeback
789
- if (this.valid_transition(newState, newData)) {
790
- if (this._has_hooks) {
791
- let hook_permits = undefined;
792
- if (this._any_transition_hook !== undefined) {
793
- if (this._any_transition_hook() === false) {
794
- return false;
795
- }
796
- }
797
- const hn = hook_name(this._state, newState), maybe_hook = this._hooks.get(hn);
798
- if (maybe_hook === undefined) {
799
- hook_permits = true;
800
- }
801
- else {
802
- hook_permits = maybe_hook({ from: this._state, to: newState });
803
- }
804
- if (hook_permits !== false) {
805
- this._state = newState;
806
- return true;
807
- }
808
- else {
809
- return false;
810
- }
811
- }
812
- else {
813
- this._state = newState;
814
- return true;
786
+ transition_impl(newState, newData, wasForced, wasAction) {
787
+ let valid = false;
788
+ if (wasForced) {
789
+ if (this.valid_force_transition(newState, newData)) {
790
+ valid = true;
815
791
  }
816
792
  }
817
793
  else {
818
- return false;
794
+ if (this.valid_transition(newState, newData)) {
795
+ valid = true;
796
+ }
819
797
  }
820
- }
821
- // can leave machine in inconsistent state. generally do not use
822
- force_transition(newState, newData) {
823
798
  // todo whargarbl implement data stuff
824
799
  // todo major incomplete whargarbl comeback
825
- if (this.valid_force_transition(newState, newData)) {
800
+ if (valid) {
826
801
  if (this._has_hooks) {
827
802
  let hook_permits = undefined;
828
803
  if (this._any_transition_hook !== undefined) {
@@ -835,7 +810,7 @@ class Machine {
835
810
  hook_permits = true;
836
811
  }
837
812
  else {
838
- hook_permits = maybe_hook({ from: this._state, to: newState, forced: true });
813
+ hook_permits = maybe_hook({ from: this._state, to: newState, forced: wasForced });
839
814
  }
840
815
  if (hook_permits !== false) {
841
816
  this._state = newState;
@@ -854,6 +829,13 @@ class Machine {
854
829
  return false;
855
830
  }
856
831
  }
832
+ transition(newState, newData) {
833
+ return this.transition_impl(newState, newData, false, false);
834
+ }
835
+ // can leave machine in inconsistent state. generally do not use
836
+ force_transition(newState, newData) {
837
+ return this.transition_impl(newState, newData, true, false);
838
+ }
857
839
  current_action_for(action) {
858
840
  const action_base = this._actions.get(action);
859
841
  return action_base
@@ -1,2 +1,2 @@
1
- const version = "5.49.0";
1
+ const version = "5.50.0";
2
2
  export { version };