jssm 5.58.1 → 5.60.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 +4 -0
- package/dist/es6/jssm.js +46 -4
- package/dist/es6/jssm_types.d.ts +12 -1
- 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/jssm_types.d.ts +12 -1
- package/package.json +1 -1
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -46,7 +46,9 @@ 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
|
+
_global_action_hooks: Map<string, Function>;
|
|
49
50
|
_any_action_hook: HookHandler | undefined;
|
|
51
|
+
_standard_transition_hook: HookHandler | undefined;
|
|
50
52
|
_any_transition_hook: HookHandler | undefined;
|
|
51
53
|
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>);
|
|
52
54
|
_new_state(state_config: JssmGenericState): StateType;
|
|
@@ -100,10 +102,12 @@ declare class Machine<mDT> {
|
|
|
100
102
|
set_hook(HookDesc: HookDescription): void;
|
|
101
103
|
hook(from: string, to: string, handler: HookHandler): Machine<mDT>;
|
|
102
104
|
hook_action(from: string, to: string, action: string, handler: HookHandler): Machine<mDT>;
|
|
105
|
+
hook_global_action(action: string, handler: HookHandler): Machine<mDT>;
|
|
103
106
|
hook_any_action(handler: HookHandler): Machine<mDT>;
|
|
104
107
|
hook_any_transition(handler: HookHandler): Machine<mDT>;
|
|
105
108
|
hook_entry(to: string, handler: HookHandler): Machine<mDT>;
|
|
106
109
|
hook_exit(from: string, handler: HookHandler): Machine<mDT>;
|
|
110
|
+
edges_between(from: string, to: string): JssmTransition<mDT>[];
|
|
107
111
|
transition_impl(newStateOrAction: StateType, newData: mDT | undefined, wasForced: boolean, wasAction: boolean): boolean;
|
|
108
112
|
action(actionName: StateType, newData?: mDT): boolean;
|
|
109
113
|
transition(newState: StateType, newData?: mDT): boolean;
|
package/dist/es6/jssm.js
CHANGED
|
@@ -355,8 +355,11 @@ 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._global_action_hooks = new Map();
|
|
358
359
|
this._any_action_hook = undefined;
|
|
360
|
+
this._standard_transition_hook = undefined;
|
|
359
361
|
this._any_transition_hook = undefined;
|
|
362
|
+
this._standard_transition_hook = undefined;
|
|
360
363
|
if (state_declaration) {
|
|
361
364
|
state_declaration.map((state_decl) => {
|
|
362
365
|
if (this._state_declarations.has(state_decl.state)) { // no repeats
|
|
@@ -719,10 +722,18 @@ class Machine {
|
|
|
719
722
|
this._named_hooks.set(named_hook_name(HookDesc.from, HookDesc.to, HookDesc.action), HookDesc.handler);
|
|
720
723
|
this._has_hooks = true;
|
|
721
724
|
break;
|
|
725
|
+
case 'global action':
|
|
726
|
+
this._global_action_hooks.set(HookDesc.action, HookDesc.handler);
|
|
727
|
+
this._has_hooks = true;
|
|
728
|
+
break;
|
|
722
729
|
case 'any action':
|
|
723
730
|
this._any_action_hook = HookDesc.handler;
|
|
724
731
|
this._has_hooks = true;
|
|
725
732
|
break;
|
|
733
|
+
case 'standard transition':
|
|
734
|
+
this._standard_transition_hook = HookDesc.handler;
|
|
735
|
+
this._has_hooks = true;
|
|
736
|
+
break;
|
|
726
737
|
case 'any transition':
|
|
727
738
|
this._any_transition_hook = HookDesc.handler;
|
|
728
739
|
this._has_hooks = true;
|
|
@@ -750,6 +761,11 @@ class Machine {
|
|
|
750
761
|
this.set_hook({ kind: 'named', from, to, action, handler });
|
|
751
762
|
return this;
|
|
752
763
|
}
|
|
764
|
+
hook_global_action(action, handler) {
|
|
765
|
+
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
766
|
+
this.set_hook({ kind: 'global action', action, handler });
|
|
767
|
+
return this;
|
|
768
|
+
}
|
|
753
769
|
hook_any_action(handler) {
|
|
754
770
|
// TODO: should this throw if setting the hook fails, or ignore it and continue?
|
|
755
771
|
this.set_hook({ kind: 'any action', handler });
|
|
@@ -773,11 +789,17 @@ class Machine {
|
|
|
773
789
|
// remove_hook(HookDesc: HookDescription) {
|
|
774
790
|
// throw 'TODO: Should remove hook here';
|
|
775
791
|
// }
|
|
792
|
+
edges_between(from, to) {
|
|
793
|
+
return this._edges.filter(edge => ((edge.from === from) && (edge.to === to)));
|
|
794
|
+
}
|
|
776
795
|
transition_impl(newStateOrAction, newData, wasForced, wasAction) {
|
|
777
|
-
|
|
796
|
+
// TODO the forced-ness behavior needs to be cleaned up a lot here
|
|
797
|
+
// TODO all the callbacks are wrong on forced, action, etc
|
|
798
|
+
let valid = false, trans_type, newState;
|
|
778
799
|
if (wasForced) {
|
|
779
800
|
if (this.valid_force_transition(newStateOrAction, newData)) {
|
|
780
801
|
valid = true;
|
|
802
|
+
trans_type = 'forced';
|
|
781
803
|
newState = newStateOrAction;
|
|
782
804
|
}
|
|
783
805
|
}
|
|
@@ -785,12 +807,14 @@ class Machine {
|
|
|
785
807
|
if (this.valid_action(newStateOrAction, newData)) {
|
|
786
808
|
const edge = this.current_action_edge_for(newStateOrAction);
|
|
787
809
|
valid = true;
|
|
810
|
+
trans_type = edge.kind;
|
|
788
811
|
newState = edge.to;
|
|
789
812
|
}
|
|
790
813
|
}
|
|
791
814
|
else {
|
|
792
815
|
if (this.valid_transition(newStateOrAction, newData)) {
|
|
793
816
|
valid = true;
|
|
817
|
+
trans_type = this.edges_between(this._state, newStateOrAction)[0].kind; // TODO this won't do the right thing if various edges have different types
|
|
794
818
|
newState = newStateOrAction;
|
|
795
819
|
}
|
|
796
820
|
}
|
|
@@ -798,16 +822,21 @@ class Machine {
|
|
|
798
822
|
// todo major incomplete whargarbl comeback
|
|
799
823
|
if (valid) {
|
|
800
824
|
if (this._has_hooks) {
|
|
801
|
-
// 1. any action hook
|
|
802
825
|
if (wasAction) {
|
|
826
|
+
// 1. any action hook
|
|
803
827
|
if (this._any_action_hook !== undefined) {
|
|
804
828
|
if (this._any_action_hook() === false) {
|
|
805
829
|
return false;
|
|
806
830
|
}
|
|
807
831
|
}
|
|
832
|
+
// 2. global specific action hook
|
|
833
|
+
const maybe_ga_hook = this._global_action_hooks.get(newStateOrAction);
|
|
834
|
+
if (maybe_ga_hook !== undefined) {
|
|
835
|
+
if (maybe_ga_hook({ action: newStateOrAction, forced: wasForced }) === false) {
|
|
836
|
+
return false;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
808
839
|
}
|
|
809
|
-
// 2. global specific action hook
|
|
810
|
-
// not yet implemented
|
|
811
840
|
// 3. any transition hook
|
|
812
841
|
if (this._any_transition_hook !== undefined) {
|
|
813
842
|
if (this._any_transition_hook() === false) {
|
|
@@ -838,6 +867,19 @@ class Machine {
|
|
|
838
867
|
}
|
|
839
868
|
}
|
|
840
869
|
// 7. edge type hook
|
|
870
|
+
// 7a. standard transition hook
|
|
871
|
+
if (trans_type === 'legal') {
|
|
872
|
+
if (this._standard_transition_hook !== undefined) {
|
|
873
|
+
// todo handle actions
|
|
874
|
+
// todo handle forced
|
|
875
|
+
if (this._standard_transition_hook({ from: this._state, to: newState }) === false) {
|
|
876
|
+
return false;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
// 7b. main type hook
|
|
881
|
+
// not yet implemented
|
|
882
|
+
// 7c. forced transition hook
|
|
841
883
|
// not yet implemented
|
|
842
884
|
// 8. entry hook
|
|
843
885
|
const maybe_en_hook = this._entry_hooks.get(newState);
|
package/dist/es6/jssm_types.d.ts
CHANGED
|
@@ -162,10 +162,21 @@ declare type HookDescriptionWithAction = {
|
|
|
162
162
|
action: string;
|
|
163
163
|
handler: HookHandler;
|
|
164
164
|
};
|
|
165
|
+
declare type StandardTransitionHook = {
|
|
166
|
+
kind: 'standard transition';
|
|
167
|
+
from: string;
|
|
168
|
+
to: string;
|
|
169
|
+
handler: HookHandler;
|
|
170
|
+
};
|
|
165
171
|
declare type AnyTransitionHook = {
|
|
166
172
|
kind: 'any transition';
|
|
167
173
|
handler: HookHandler;
|
|
168
174
|
};
|
|
175
|
+
declare type GlobalActionHook = {
|
|
176
|
+
kind: 'global action';
|
|
177
|
+
action: string;
|
|
178
|
+
handler: HookHandler;
|
|
179
|
+
};
|
|
169
180
|
declare type AnyActionHook = {
|
|
170
181
|
kind: 'any action';
|
|
171
182
|
handler: HookHandler;
|
|
@@ -180,5 +191,5 @@ declare type ExitHook = {
|
|
|
180
191
|
from: string;
|
|
181
192
|
handler: HookHandler;
|
|
182
193
|
};
|
|
183
|
-
declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | AnyActionHook | AnyTransitionHook | EntryHook | ExitHook;
|
|
194
|
+
declare type HookDescription = BasicHookDescription | HookDescriptionWithAction | GlobalActionHook | AnyActionHook | StandardTransitionHook | AnyTransitionHook | EntryHook | ExitHook;
|
|
184
195
|
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 };
|
package/dist/es6/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.60.0";
|
|
2
2
|
export { version };
|