jssm 5.98.8 → 5.100.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/CHANGELOG.md +48 -60
- package/README.md +5 -5
- package/dist/es6/jssm.d.ts +5 -2
- package/dist/es6/jssm.js +35 -4
- package/dist/es6/jssm_types.d.ts +6 -1
- package/dist/es6/jssm_util.d.ts +2 -1
- package/dist/es6/jssm_util.js +4 -1
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs +1 -1
- package/dist/jssm.es5.iife.cjs +1 -1
- package/dist/jssm.es5.iife.nonmin.cjs +38 -3
- package/dist/jssm.es5.nonmin.cjs +38 -3
- package/dist/jssm.es6.mjs +1 -1
- package/dist/jssm.es6.nonmin.cjs +38 -4
- package/jssm.d.ts +5 -2
- package/jssm.es5.d.cts +1767 -0
- package/jssm.es6.d.ts +1767 -0
- package/jssm_types.d.ts +6 -1
- package/jssm_util.d.ts +2 -1
- package/package.json +15 -5
- package/rollup.config.es5.js +13 -8
- package/rollup.config.es6.js +15 -7
package/dist/jssm.es6.nonmin.cjs
CHANGED
|
@@ -18962,6 +18962,9 @@ function find_repeated(arr) {
|
|
|
18962
18962
|
return [];
|
|
18963
18963
|
}
|
|
18964
18964
|
}
|
|
18965
|
+
function sleep(ms) {
|
|
18966
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
18967
|
+
}
|
|
18965
18968
|
|
|
18966
18969
|
var reductions = {
|
|
18967
18970
|
"abkhazian" : "ab",
|
|
@@ -20663,7 +20666,7 @@ var constants = /*#__PURE__*/Object.freeze({
|
|
|
20663
20666
|
named_colors: named_colors$1
|
|
20664
20667
|
});
|
|
20665
20668
|
|
|
20666
|
-
const version = "5.
|
|
20669
|
+
const version = "5.100.0", build_time = 1729447735226;
|
|
20667
20670
|
|
|
20668
20671
|
// whargarbl lots of these return arrays could/should be sets
|
|
20669
20672
|
const { shapes, gviz_shapes, named_colors } = constants;
|
|
@@ -20818,6 +20821,7 @@ class Machine {
|
|
|
20818
20821
|
this._has_named_hooks = false;
|
|
20819
20822
|
this._has_entry_hooks = false;
|
|
20820
20823
|
this._has_exit_hooks = false;
|
|
20824
|
+
this._has_after_hooks = false;
|
|
20821
20825
|
this._has_global_action_hooks = false;
|
|
20822
20826
|
this._has_transition_hooks = true;
|
|
20823
20827
|
// no need for a boolean for single hooks, just test for undefinedness
|
|
@@ -20826,6 +20830,7 @@ class Machine {
|
|
|
20826
20830
|
this._named_hooks = new Map();
|
|
20827
20831
|
this._entry_hooks = new Map();
|
|
20828
20832
|
this._exit_hooks = new Map();
|
|
20833
|
+
this._after_hooks = new Map();
|
|
20829
20834
|
this._global_action_hooks = new Map();
|
|
20830
20835
|
this._any_action_hook = undefined;
|
|
20831
20836
|
this._standard_transition_hook = undefined;
|
|
@@ -21981,6 +21986,11 @@ class Machine {
|
|
|
21981
21986
|
this._has_hooks = true;
|
|
21982
21987
|
this._has_exit_hooks = true;
|
|
21983
21988
|
break;
|
|
21989
|
+
case 'after':
|
|
21990
|
+
this._after_hooks.set(HookDesc.from, HookDesc.handler);
|
|
21991
|
+
this._has_hooks = true;
|
|
21992
|
+
this._has_after_hooks = true;
|
|
21993
|
+
break;
|
|
21984
21994
|
case 'post hook':
|
|
21985
21995
|
this._post_hooks.set(hook_name(HookDesc.from, HookDesc.to), HookDesc.handler);
|
|
21986
21996
|
this._has_post_hooks = true;
|
|
@@ -22073,6 +22083,10 @@ class Machine {
|
|
|
22073
22083
|
this.set_hook({ kind: 'exit', from, handler });
|
|
22074
22084
|
return this;
|
|
22075
22085
|
}
|
|
22086
|
+
hook_after(from, handler) {
|
|
22087
|
+
this.set_hook({ kind: 'after', from, handler });
|
|
22088
|
+
return this;
|
|
22089
|
+
}
|
|
22076
22090
|
post_hook(from, to, handler) {
|
|
22077
22091
|
this.set_hook({ kind: 'post hook', from, to, handler });
|
|
22078
22092
|
return this;
|
|
@@ -22214,19 +22228,33 @@ class Machine {
|
|
|
22214
22228
|
}
|
|
22215
22229
|
let data_changed = false;
|
|
22216
22230
|
if (wasAction) {
|
|
22217
|
-
//
|
|
22231
|
+
// 1a. any action hook
|
|
22218
22232
|
const outcome = abstract_hook_step(this._any_action_hook, hook_args);
|
|
22219
22233
|
if (outcome.pass === false) {
|
|
22220
22234
|
return false;
|
|
22221
22235
|
}
|
|
22222
22236
|
update_fields(outcome);
|
|
22223
|
-
//
|
|
22237
|
+
// 1b. global specific action hook
|
|
22224
22238
|
const outcome2 = abstract_hook_step(this._global_action_hooks.get(newStateOrAction), hook_args);
|
|
22225
22239
|
if (outcome2.pass === false) {
|
|
22226
22240
|
return false;
|
|
22227
22241
|
}
|
|
22228
22242
|
update_fields(outcome2);
|
|
22229
22243
|
}
|
|
22244
|
+
// 2. after hook
|
|
22245
|
+
if (this._has_after_hooks) {
|
|
22246
|
+
const ah = this._after_hooks.get(newStateOrAction);
|
|
22247
|
+
const outcome = abstract_hook_step(ah, hook_args);
|
|
22248
|
+
// there's no such thing as after not passing, so, omit the result pass check
|
|
22249
|
+
/* istanbul can't trace this through the timer */
|
|
22250
|
+
/* istanbul ignore next */
|
|
22251
|
+
if (ah !== undefined) {
|
|
22252
|
+
/* istanbul can't trace this through the timer */
|
|
22253
|
+
/* istanbul ignore next */
|
|
22254
|
+
ah({ data: outcome.data, next_data: outcome.next_data });
|
|
22255
|
+
}
|
|
22256
|
+
update_fields(outcome);
|
|
22257
|
+
}
|
|
22230
22258
|
// 3. any transition hook
|
|
22231
22259
|
if (this._any_transition_hook !== undefined) {
|
|
22232
22260
|
const outcome = abstract_hook_step(this._any_transition_hook, hook_args);
|
|
@@ -22956,6 +22984,12 @@ class Machine {
|
|
|
22956
22984
|
/* istanbul ignore next */
|
|
22957
22985
|
() => {
|
|
22958
22986
|
this.clear_state_timeout();
|
|
22987
|
+
if (this._has_after_hooks) {
|
|
22988
|
+
const ah = this._after_hooks.get(this.state());
|
|
22989
|
+
if (ah !== undefined) {
|
|
22990
|
+
ah({ data: this._data, next_data: this._data });
|
|
22991
|
+
}
|
|
22992
|
+
}
|
|
22959
22993
|
this.go(next_state);
|
|
22960
22994
|
}, after_time);
|
|
22961
22995
|
this._timeout_target = next_state;
|
|
@@ -23107,4 +23141,4 @@ function deserialize(machine_string, ser) {
|
|
|
23107
23141
|
return machine;
|
|
23108
23142
|
}
|
|
23109
23143
|
|
|
23110
|
-
export { FslDirections, Machine, abstract_hook_step, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compile, constants, deserialize, find_repeated, from, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sm, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
|
23144
|
+
export { FslDirections, Machine, abstract_hook_step, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compile, constants, deserialize, find_repeated, from, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
package/jssm.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JssmGenericState, JssmGenericConfig, JssmStateConfig, JssmTransition, J
|
|
|
3
3
|
JssmMachineInternalState, JssmAllowsOverride, JssmStateDeclaration, JssmStateStyleKeyList, JssmLayout, JssmHistory, JssmSerialization, FslDirection, FslDirections, FslTheme, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, JssmRng } from './jssm_types';
|
|
4
4
|
import { arrow_direction, arrow_left_kind, arrow_right_kind } from './jssm_arrow';
|
|
5
5
|
import { compile, make, wrap_parse } from './jssm_compiler';
|
|
6
|
-
import { seq, unique, find_repeated, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
|
|
6
|
+
import { seq, unique, find_repeated, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key, sleep } from './jssm_util';
|
|
7
7
|
import * as constants from './jssm_constants';
|
|
8
8
|
declare const shapes: string[], gviz_shapes: string[], named_colors: string[];
|
|
9
9
|
import { version, build_time } from './version';
|
|
@@ -56,6 +56,7 @@ declare class Machine<mDT> {
|
|
|
56
56
|
_has_named_hooks: boolean;
|
|
57
57
|
_has_entry_hooks: boolean;
|
|
58
58
|
_has_exit_hooks: boolean;
|
|
59
|
+
_has_after_hooks: boolean;
|
|
59
60
|
_has_global_action_hooks: boolean;
|
|
60
61
|
_has_transition_hooks: boolean;
|
|
61
62
|
_has_forced_transitions: boolean;
|
|
@@ -63,6 +64,7 @@ declare class Machine<mDT> {
|
|
|
63
64
|
_named_hooks: Map<string, HookHandler<mDT>>;
|
|
64
65
|
_entry_hooks: Map<string, HookHandler<mDT>>;
|
|
65
66
|
_exit_hooks: Map<string, HookHandler<mDT>>;
|
|
67
|
+
_after_hooks: Map<string, HookHandler<mDT>>;
|
|
66
68
|
_global_action_hooks: Map<string, HookHandler<mDT>>;
|
|
67
69
|
_any_action_hook: HookHandler<mDT> | undefined;
|
|
68
70
|
_standard_transition_hook: HookHandler<mDT> | undefined;
|
|
@@ -669,6 +671,7 @@ declare class Machine<mDT> {
|
|
|
669
671
|
hook_any_transition(handler: HookHandler<mDT>): Machine<mDT>;
|
|
670
672
|
hook_entry(to: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
671
673
|
hook_exit(from: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
674
|
+
hook_after(from: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
672
675
|
post_hook(from: string, to: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
673
676
|
post_hook_action(from: string, to: string, action: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
674
677
|
post_hook_global_action(action: string, handler: HookHandler<mDT>): Machine<mDT>;
|
|
@@ -1135,4 +1138,4 @@ declare function is_hook_complex_result<mDT>(hr: unknown): hr is HookComplexResu
|
|
|
1135
1138
|
declare function is_hook_rejection<mDT>(hr: HookResult<mDT>): boolean;
|
|
1136
1139
|
declare function abstract_hook_step<mDT>(maybe_hook: HookHandler<mDT> | undefined, hook_args: HookContext<mDT>): HookComplexResult<mDT>;
|
|
1137
1140
|
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
1138
|
-
export { version, build_time, transfer_state_properties, Machine, deserialize, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind, seq, unique, find_repeated, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, constants, shapes, gviz_shapes, named_colors, is_hook_rejection, is_hook_complex_result, abstract_hook_step, state_style_condense, FslDirections };
|
|
1141
|
+
export { version, build_time, transfer_state_properties, Machine, deserialize, make, wrap_parse as parse, compile, sm, from, arrow_direction, arrow_left_kind, arrow_right_kind, seq, unique, find_repeated, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key, sleep, constants, shapes, gviz_shapes, named_colors, is_hook_rejection, is_hook_complex_result, abstract_hook_step, state_style_condense, FslDirections };
|