jssm 5.98.7 → 5.99.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.
@@ -18965,6 +18965,9 @@ var jssm = (function (exports) {
18965
18965
  return [];
18966
18966
  }
18967
18967
  }
18968
+ function sleep(ms) {
18969
+ return new Promise(resolve => setTimeout(resolve, ms));
18970
+ }
18968
18971
 
18969
18972
  var reductions = {
18970
18973
  "abkhazian" : "ab",
@@ -20666,7 +20669,7 @@ var jssm = (function (exports) {
20666
20669
  named_colors: named_colors$1
20667
20670
  });
20668
20671
 
20669
- const version = "5.98.7", build_time = 1720294433127;
20672
+ const version = "5.99.0", build_time = 1720314479976;
20670
20673
 
20671
20674
  // whargarbl lots of these return arrays could/should be sets
20672
20675
  const { shapes, gviz_shapes, named_colors } = constants;
@@ -20821,6 +20824,7 @@ var jssm = (function (exports) {
20821
20824
  this._has_named_hooks = false;
20822
20825
  this._has_entry_hooks = false;
20823
20826
  this._has_exit_hooks = false;
20827
+ this._has_after_hooks = false;
20824
20828
  this._has_global_action_hooks = false;
20825
20829
  this._has_transition_hooks = true;
20826
20830
  // no need for a boolean for single hooks, just test for undefinedness
@@ -20829,6 +20833,7 @@ var jssm = (function (exports) {
20829
20833
  this._named_hooks = new Map();
20830
20834
  this._entry_hooks = new Map();
20831
20835
  this._exit_hooks = new Map();
20836
+ this._after_hooks = new Map();
20832
20837
  this._global_action_hooks = new Map();
20833
20838
  this._any_action_hook = undefined;
20834
20839
  this._standard_transition_hook = undefined;
@@ -21984,6 +21989,11 @@ var jssm = (function (exports) {
21984
21989
  this._has_hooks = true;
21985
21990
  this._has_exit_hooks = true;
21986
21991
  break;
21992
+ case 'after':
21993
+ this._after_hooks.set(HookDesc.from, HookDesc.handler);
21994
+ this._has_hooks = true;
21995
+ this._has_after_hooks = true;
21996
+ break;
21987
21997
  case 'post hook':
21988
21998
  this._post_hooks.set(hook_name(HookDesc.from, HookDesc.to), HookDesc.handler);
21989
21999
  this._has_post_hooks = true;
@@ -22076,6 +22086,10 @@ var jssm = (function (exports) {
22076
22086
  this.set_hook({ kind: 'exit', from, handler });
22077
22087
  return this;
22078
22088
  }
22089
+ hook_after(from, handler) {
22090
+ this.set_hook({ kind: 'after', from, handler });
22091
+ return this;
22092
+ }
22079
22093
  post_hook(from, to, handler) {
22080
22094
  this.set_hook({ kind: 'post hook', from, to, handler });
22081
22095
  return this;
@@ -22217,19 +22231,33 @@ var jssm = (function (exports) {
22217
22231
  }
22218
22232
  let data_changed = false;
22219
22233
  if (wasAction) {
22220
- // 1. any action hook
22234
+ // 1a. any action hook
22221
22235
  const outcome = abstract_hook_step(this._any_action_hook, hook_args);
22222
22236
  if (outcome.pass === false) {
22223
22237
  return false;
22224
22238
  }
22225
22239
  update_fields(outcome);
22226
- // 2. global specific action hook
22240
+ // 1b. global specific action hook
22227
22241
  const outcome2 = abstract_hook_step(this._global_action_hooks.get(newStateOrAction), hook_args);
22228
22242
  if (outcome2.pass === false) {
22229
22243
  return false;
22230
22244
  }
22231
22245
  update_fields(outcome2);
22232
22246
  }
22247
+ // 2. after hook
22248
+ if (this._has_after_hooks) {
22249
+ const ah = this._after_hooks.get(newStateOrAction);
22250
+ const outcome = abstract_hook_step(ah, hook_args);
22251
+ // there's no such thing as after not passing, so, omit the result pass check
22252
+ /* istanbul can't trace this through the timer */
22253
+ /* istanbul ignore next */
22254
+ if (ah !== undefined) {
22255
+ /* istanbul can't trace this through the timer */
22256
+ /* istanbul ignore next */
22257
+ ah({ data: outcome.data, next_data: outcome.next_data });
22258
+ }
22259
+ update_fields(outcome);
22260
+ }
22233
22261
  // 3. any transition hook
22234
22262
  if (this._any_transition_hook !== undefined) {
22235
22263
  const outcome = abstract_hook_step(this._any_transition_hook, hook_args);
@@ -22959,6 +22987,12 @@ var jssm = (function (exports) {
22959
22987
  /* istanbul ignore next */
22960
22988
  () => {
22961
22989
  this.clear_state_timeout();
22990
+ if (this._has_after_hooks) {
22991
+ const ah = this._after_hooks.get(this.state());
22992
+ if (ah !== undefined) {
22993
+ ah({ data: this._data, next_data: this._data });
22994
+ }
22995
+ }
22962
22996
  this.go(next_state);
22963
22997
  }, after_time);
22964
22998
  this._timeout_target = next_state;
@@ -23131,6 +23165,7 @@ var jssm = (function (exports) {
23131
23165
  exports.parse = wrap_parse;
23132
23166
  exports.seq = seq;
23133
23167
  exports.shapes = shapes;
23168
+ exports.sleep = sleep;
23134
23169
  exports.sm = sm;
23135
23170
  exports.state_style_condense = state_style_condense;
23136
23171
  exports.transfer_state_properties = transfer_state_properties;
@@ -18966,6 +18966,9 @@ function find_repeated(arr) {
18966
18966
  return [];
18967
18967
  }
18968
18968
  }
18969
+ function sleep(ms) {
18970
+ return new Promise(resolve => setTimeout(resolve, ms));
18971
+ }
18969
18972
 
18970
18973
  var reductions = {
18971
18974
  "abkhazian" : "ab",
@@ -20667,7 +20670,7 @@ var constants = /*#__PURE__*/Object.freeze({
20667
20670
  named_colors: named_colors$1
20668
20671
  });
20669
20672
 
20670
- const version = "5.98.7", build_time = 1720294433127;
20673
+ const version = "5.99.0", build_time = 1720314479976;
20671
20674
 
20672
20675
  // whargarbl lots of these return arrays could/should be sets
20673
20676
  const { shapes, gviz_shapes, named_colors } = constants;
@@ -20822,6 +20825,7 @@ class Machine {
20822
20825
  this._has_named_hooks = false;
20823
20826
  this._has_entry_hooks = false;
20824
20827
  this._has_exit_hooks = false;
20828
+ this._has_after_hooks = false;
20825
20829
  this._has_global_action_hooks = false;
20826
20830
  this._has_transition_hooks = true;
20827
20831
  // no need for a boolean for single hooks, just test for undefinedness
@@ -20830,6 +20834,7 @@ class Machine {
20830
20834
  this._named_hooks = new Map();
20831
20835
  this._entry_hooks = new Map();
20832
20836
  this._exit_hooks = new Map();
20837
+ this._after_hooks = new Map();
20833
20838
  this._global_action_hooks = new Map();
20834
20839
  this._any_action_hook = undefined;
20835
20840
  this._standard_transition_hook = undefined;
@@ -21985,6 +21990,11 @@ class Machine {
21985
21990
  this._has_hooks = true;
21986
21991
  this._has_exit_hooks = true;
21987
21992
  break;
21993
+ case 'after':
21994
+ this._after_hooks.set(HookDesc.from, HookDesc.handler);
21995
+ this._has_hooks = true;
21996
+ this._has_after_hooks = true;
21997
+ break;
21988
21998
  case 'post hook':
21989
21999
  this._post_hooks.set(hook_name(HookDesc.from, HookDesc.to), HookDesc.handler);
21990
22000
  this._has_post_hooks = true;
@@ -22077,6 +22087,10 @@ class Machine {
22077
22087
  this.set_hook({ kind: 'exit', from, handler });
22078
22088
  return this;
22079
22089
  }
22090
+ hook_after(from, handler) {
22091
+ this.set_hook({ kind: 'after', from, handler });
22092
+ return this;
22093
+ }
22080
22094
  post_hook(from, to, handler) {
22081
22095
  this.set_hook({ kind: 'post hook', from, to, handler });
22082
22096
  return this;
@@ -22218,19 +22232,33 @@ class Machine {
22218
22232
  }
22219
22233
  let data_changed = false;
22220
22234
  if (wasAction) {
22221
- // 1. any action hook
22235
+ // 1a. any action hook
22222
22236
  const outcome = abstract_hook_step(this._any_action_hook, hook_args);
22223
22237
  if (outcome.pass === false) {
22224
22238
  return false;
22225
22239
  }
22226
22240
  update_fields(outcome);
22227
- // 2. global specific action hook
22241
+ // 1b. global specific action hook
22228
22242
  const outcome2 = abstract_hook_step(this._global_action_hooks.get(newStateOrAction), hook_args);
22229
22243
  if (outcome2.pass === false) {
22230
22244
  return false;
22231
22245
  }
22232
22246
  update_fields(outcome2);
22233
22247
  }
22248
+ // 2. after hook
22249
+ if (this._has_after_hooks) {
22250
+ const ah = this._after_hooks.get(newStateOrAction);
22251
+ const outcome = abstract_hook_step(ah, hook_args);
22252
+ // there's no such thing as after not passing, so, omit the result pass check
22253
+ /* istanbul can't trace this through the timer */
22254
+ /* istanbul ignore next */
22255
+ if (ah !== undefined) {
22256
+ /* istanbul can't trace this through the timer */
22257
+ /* istanbul ignore next */
22258
+ ah({ data: outcome.data, next_data: outcome.next_data });
22259
+ }
22260
+ update_fields(outcome);
22261
+ }
22234
22262
  // 3. any transition hook
22235
22263
  if (this._any_transition_hook !== undefined) {
22236
22264
  const outcome = abstract_hook_step(this._any_transition_hook, hook_args);
@@ -22960,6 +22988,12 @@ class Machine {
22960
22988
  /* istanbul ignore next */
22961
22989
  () => {
22962
22990
  this.clear_state_timeout();
22991
+ if (this._has_after_hooks) {
22992
+ const ah = this._after_hooks.get(this.state());
22993
+ if (ah !== undefined) {
22994
+ ah({ data: this._data, next_data: this._data });
22995
+ }
22996
+ }
22963
22997
  this.go(next_state);
22964
22998
  }, after_time);
22965
22999
  this._timeout_target = next_state;
@@ -23132,6 +23166,7 @@ exports.named_colors = named_colors;
23132
23166
  exports.parse = wrap_parse;
23133
23167
  exports.seq = seq;
23134
23168
  exports.shapes = shapes;
23169
+ exports.sleep = sleep;
23135
23170
  exports.sm = sm;
23136
23171
  exports.state_style_condense = state_style_condense;
23137
23172
  exports.transfer_state_properties = transfer_state_properties;