jssm 5.57.1 → 5.58.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.
@@ -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;
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;
@@ -789,21 +794,29 @@ class Machine {
789
794
  if (valid) {
790
795
  if (this._has_hooks) {
791
796
  // 1. any action hook
797
+ if (wasAction) {
798
+ if (this._any_action_hook !== undefined) {
799
+ if (this._any_action_hook() === false) {
800
+ return false;
801
+ }
802
+ }
803
+ }
804
+ // 2. global specific action hook
792
805
  // not yet implemented
793
- // 2. any transition hook
806
+ // 3. any transition hook
794
807
  if (this._any_transition_hook !== undefined) {
795
808
  if (this._any_transition_hook() === false) {
796
809
  return false;
797
810
  }
798
811
  }
799
- // 3. exit hook
812
+ // 4. exit hook
800
813
  const maybe_ex_hook = this._exit_hooks.get(this._state);
801
814
  if (maybe_ex_hook !== undefined) {
802
815
  if (maybe_ex_hook({ from: this._state, forced: wasForced }) === false) {
803
816
  return false;
804
817
  }
805
818
  }
806
- // 4. named transition / action hook
819
+ // 5. named transition / action hook
807
820
  if (wasAction) {
808
821
  const nhn = named_hook_name(this._state, newState, newStateOrAction), n_maybe_hook = this._named_hooks.get(nhn);
809
822
  if (n_maybe_hook !== undefined) {
@@ -812,16 +825,16 @@ class Machine {
812
825
  }
813
826
  }
814
827
  }
815
- // 5. regular hook
828
+ // 6. regular hook
816
829
  const hn = hook_name(this._state, newState), maybe_hook = this._hooks.get(hn);
817
830
  if (maybe_hook !== undefined) {
818
831
  if (maybe_hook({ from: this._state, to: newState, forced: wasForced, action: wasAction ? newStateOrAction : undefined }) === false) {
819
832
  return false;
820
833
  }
821
834
  }
822
- // 6. edge type hook
835
+ // 7. edge type hook
823
836
  // not yet implemented
824
- // 7. entry hook
837
+ // 8. entry hook
825
838
  const maybe_en_hook = this._entry_hooks.get(newState);
826
839
  if (maybe_en_hook !== undefined) {
827
840
  if (maybe_en_hook({ to: newState, forced: wasForced }) === false) {
@@ -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 };
@@ -1,2 +1,2 @@
1
- const version = "5.57.1";
1
+ const version = "5.58.0";
2
2
  export { version };