jssm 5.141.4 → 5.141.5

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/README.md CHANGED
@@ -18,10 +18,10 @@ Please edit the file it's derived from, instead: `./src/md/readme_base.md`
18
18
 
19
19
 
20
20
 
21
- * Generated for version 5.141.4 at 6/2/2026, 10:32:57 AM
21
+ * Generated for version 5.141.5 at 6/4/2026, 3:42:26 PM
22
22
 
23
23
  -->
24
- # jssm 5.141.4
24
+ # jssm 5.141.5
25
25
 
26
26
  [**Try the live editor**](https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html) ·
27
27
  [Documentation](https://stonecypher.github.io/jssm/docs/) ·
@@ -418,7 +418,7 @@ If your contribution is missing here, please open an issue.
418
418
 
419
419
  - 5,971 specs with 100.0% coverage
420
420
  - 513 fuzz tests with 3.4% coverage
421
- - 5,573 TypeScript lines - 1.2 tests per line, 10.3 generated tests per line
421
+ - 5,581 TypeScript lines - 1.2 tests per line, 10.3 generated tests per line
422
422
 
423
423
  [![Actions Status](https://github.com/StoneCypher/jssm/workflows/Node%20CI/badge.svg)](https://github.com/StoneCypher/jssm/actions)
424
424
  [![NPM version](https://img.shields.io/npm/v/jssm.svg)](https://www.npmjs.com/package/jssm)
@@ -21327,7 +21327,7 @@ var constants = /*#__PURE__*/Object.freeze({
21327
21327
  * Useful for runtime diagnostics and for embedding in serialized machine
21328
21328
  * snapshots so that deserializers can detect version-skew.
21329
21329
  */
21330
- const version = "5.141.4";
21330
+ const version = "5.141.5";
21331
21331
 
21332
21332
  // whargarbl lots of these return arrays could/should be sets
21333
21333
  const { state_name_chars, state_name_first_chars, action_label_chars } = constants;
@@ -23046,6 +23046,62 @@ class Machine {
23046
23046
  this._event_listener_count++;
23047
23047
  return () => { this._unsubscribe_entry(set, entry); };
23048
23048
  }
23049
+ /**
23050
+ * Invoke a single event-handler entry, respecting its filter, once-removal
23051
+ * semantics, and the error re-fire / recursion-guard logic. Extracted so
23052
+ * {@link _fire} can share identical behavior between the size-1 fast-path
23053
+ * and the general snapshotted loop.
23054
+ *
23055
+ * @param entry - The subscriber descriptor to invoke.
23056
+ * @param set - The live Set that owns `entry`; needed for once-removal.
23057
+ * @param name - The event name being dispatched (used in error re-fires).
23058
+ * @param detail - The event payload forwarded to the handler.
23059
+ *
23060
+ * @internal
23061
+ */
23062
+ _fire_one(entry, set, name, detail) {
23063
+ // filter check
23064
+ if (entry.filter !== undefined) {
23065
+ for (const k of Object.keys(entry.filter)) {
23066
+ if (entry.filter[k] !== detail[k]) {
23067
+ return;
23068
+ }
23069
+ }
23070
+ }
23071
+ // once removal happens BEFORE invocation so a throwing handler still
23072
+ // gets removed and so re-entrant `on` calls during the handler see
23073
+ // the post-removal state.
23074
+ if (entry.once) {
23075
+ this._unsubscribe_entry(set, entry);
23076
+ }
23077
+ try {
23078
+ entry.handler(detail);
23079
+ }
23080
+ catch (err) {
23081
+ if (name === 'error' || this._firing_error) {
23082
+ // surface to stderr as a last resort but never recurse;
23083
+ // `console` is in the JS standard library and present in every
23084
+ // supported runtime, so guarding it would just add an untestable
23085
+ // branch. See #638.
23086
+ // eslint-disable-next-line no-console
23087
+ console.error(err);
23088
+ }
23089
+ else {
23090
+ this._firing_error = true;
23091
+ try {
23092
+ this._fire('error', {
23093
+ error: err,
23094
+ source_event: name,
23095
+ source_detail: detail,
23096
+ handler: entry.handler
23097
+ });
23098
+ }
23099
+ finally {
23100
+ this._firing_error = false;
23101
+ }
23102
+ }
23103
+ }
23104
+ }
23049
23105
  /**
23050
23106
  * Dispatch an event to every registered subscriber in registration
23051
23107
  * order. Filters are checked first; non-matching handlers are skipped
@@ -23057,6 +23113,11 @@ class Machine {
23057
23113
  * handler throws, the new exception is swallowed rather than rebroadcast
23058
23114
  * to avoid an infinite loop.
23059
23115
  *
23116
+ * When exactly one subscriber is registered the common case avoids the
23117
+ * `Array.from(set)` snapshot allocation by capturing the lone entry into a
23118
+ * local first — equivalent to a 1-element snapshot but allocation-free.
23119
+ * The general path still snapshots for re-entrancy safety.
23120
+ *
23060
23121
  * @internal
23061
23122
  */
23062
23123
  _fire(name, detail) {
@@ -23064,55 +23125,19 @@ class Machine {
23064
23125
  if (set === undefined || set.size === 0) {
23065
23126
  return;
23066
23127
  }
23067
- // Snapshot so handlers can `off()` mid-loop without disturbing iteration.
23128
+ // Fast-path: single subscriber capture entry before invoking so that
23129
+ // even if the handler mutates `set` (via off/once auto-removal) we hold a
23130
+ // stable reference. Behaviorally identical to a 1-element snapshot.
23131
+ if (set.size === 1) {
23132
+ const only = set.values().next().value;
23133
+ this._fire_one(only, set, name, detail);
23134
+ return;
23135
+ }
23136
+ // General path: snapshot so handlers can `off()` mid-loop without
23137
+ // disturbing iteration.
23068
23138
  const entries = Array.from(set);
23069
23139
  for (const entry of entries) {
23070
- // filter check
23071
- if (entry.filter !== undefined) {
23072
- let matched = true;
23073
- for (const k of Object.keys(entry.filter)) {
23074
- if (entry.filter[k] !== detail[k]) {
23075
- matched = false;
23076
- break;
23077
- }
23078
- }
23079
- if (!matched) {
23080
- continue;
23081
- }
23082
- }
23083
- // once removal happens BEFORE invocation so a throwing handler still
23084
- // gets removed and so re-entrant `on` calls during the handler see
23085
- // the post-removal state.
23086
- if (entry.once) {
23087
- this._unsubscribe_entry(set, entry);
23088
- }
23089
- try {
23090
- entry.handler(detail);
23091
- }
23092
- catch (err) {
23093
- if (name === 'error' || this._firing_error) {
23094
- // surface to stderr as a last resort but never recurse;
23095
- // `console` is in the JS standard library and present in every
23096
- // supported runtime, so guarding it would just add an untestable
23097
- // branch. See #638.
23098
- // eslint-disable-next-line no-console
23099
- console.error(err);
23100
- }
23101
- else {
23102
- this._firing_error = true;
23103
- try {
23104
- this._fire('error', {
23105
- error: err,
23106
- source_event: name,
23107
- source_detail: detail,
23108
- handler: entry.handler
23109
- });
23110
- }
23111
- finally {
23112
- this._firing_error = false;
23113
- }
23114
- }
23115
- }
23140
+ this._fire_one(entry, set, name, detail);
23116
23141
  }
23117
23142
  }
23118
23143
  /** Low-level hook registration. Installs a handler described by a
package/dist/cdn/viz.js CHANGED
@@ -21352,7 +21352,7 @@ var constants = /*#__PURE__*/Object.freeze({
21352
21352
  * Useful for runtime diagnostics and for embedding in serialized machine
21353
21353
  * snapshots so that deserializers can detect version-skew.
21354
21354
  */
21355
- const version = "5.141.4";
21355
+ const version = "5.141.5";
21356
21356
 
21357
21357
  // whargarbl lots of these return arrays could/should be sets
21358
21358
  const { state_name_chars, state_name_first_chars, action_label_chars } = constants;
@@ -23071,6 +23071,62 @@ class Machine {
23071
23071
  this._event_listener_count++;
23072
23072
  return () => { this._unsubscribe_entry(set, entry); };
23073
23073
  }
23074
+ /**
23075
+ * Invoke a single event-handler entry, respecting its filter, once-removal
23076
+ * semantics, and the error re-fire / recursion-guard logic. Extracted so
23077
+ * {@link _fire} can share identical behavior between the size-1 fast-path
23078
+ * and the general snapshotted loop.
23079
+ *
23080
+ * @param entry - The subscriber descriptor to invoke.
23081
+ * @param set - The live Set that owns `entry`; needed for once-removal.
23082
+ * @param name - The event name being dispatched (used in error re-fires).
23083
+ * @param detail - The event payload forwarded to the handler.
23084
+ *
23085
+ * @internal
23086
+ */
23087
+ _fire_one(entry, set, name, detail) {
23088
+ // filter check
23089
+ if (entry.filter !== undefined) {
23090
+ for (const k of Object.keys(entry.filter)) {
23091
+ if (entry.filter[k] !== detail[k]) {
23092
+ return;
23093
+ }
23094
+ }
23095
+ }
23096
+ // once removal happens BEFORE invocation so a throwing handler still
23097
+ // gets removed and so re-entrant `on` calls during the handler see
23098
+ // the post-removal state.
23099
+ if (entry.once) {
23100
+ this._unsubscribe_entry(set, entry);
23101
+ }
23102
+ try {
23103
+ entry.handler(detail);
23104
+ }
23105
+ catch (err) {
23106
+ if (name === 'error' || this._firing_error) {
23107
+ // surface to stderr as a last resort but never recurse;
23108
+ // `console` is in the JS standard library and present in every
23109
+ // supported runtime, so guarding it would just add an untestable
23110
+ // branch. See #638.
23111
+ // eslint-disable-next-line no-console
23112
+ console.error(err);
23113
+ }
23114
+ else {
23115
+ this._firing_error = true;
23116
+ try {
23117
+ this._fire('error', {
23118
+ error: err,
23119
+ source_event: name,
23120
+ source_detail: detail,
23121
+ handler: entry.handler
23122
+ });
23123
+ }
23124
+ finally {
23125
+ this._firing_error = false;
23126
+ }
23127
+ }
23128
+ }
23129
+ }
23074
23130
  /**
23075
23131
  * Dispatch an event to every registered subscriber in registration
23076
23132
  * order. Filters are checked first; non-matching handlers are skipped
@@ -23082,6 +23138,11 @@ class Machine {
23082
23138
  * handler throws, the new exception is swallowed rather than rebroadcast
23083
23139
  * to avoid an infinite loop.
23084
23140
  *
23141
+ * When exactly one subscriber is registered the common case avoids the
23142
+ * `Array.from(set)` snapshot allocation by capturing the lone entry into a
23143
+ * local first — equivalent to a 1-element snapshot but allocation-free.
23144
+ * The general path still snapshots for re-entrancy safety.
23145
+ *
23085
23146
  * @internal
23086
23147
  */
23087
23148
  _fire(name, detail) {
@@ -23089,55 +23150,19 @@ class Machine {
23089
23150
  if (set === undefined || set.size === 0) {
23090
23151
  return;
23091
23152
  }
23092
- // Snapshot so handlers can `off()` mid-loop without disturbing iteration.
23153
+ // Fast-path: single subscriber capture entry before invoking so that
23154
+ // even if the handler mutates `set` (via off/once auto-removal) we hold a
23155
+ // stable reference. Behaviorally identical to a 1-element snapshot.
23156
+ if (set.size === 1) {
23157
+ const only = set.values().next().value;
23158
+ this._fire_one(only, set, name, detail);
23159
+ return;
23160
+ }
23161
+ // General path: snapshot so handlers can `off()` mid-loop without
23162
+ // disturbing iteration.
23093
23163
  const entries = Array.from(set);
23094
23164
  for (const entry of entries) {
23095
- // filter check
23096
- if (entry.filter !== undefined) {
23097
- let matched = true;
23098
- for (const k of Object.keys(entry.filter)) {
23099
- if (entry.filter[k] !== detail[k]) {
23100
- matched = false;
23101
- break;
23102
- }
23103
- }
23104
- if (!matched) {
23105
- continue;
23106
- }
23107
- }
23108
- // once removal happens BEFORE invocation so a throwing handler still
23109
- // gets removed and so re-entrant `on` calls during the handler see
23110
- // the post-removal state.
23111
- if (entry.once) {
23112
- this._unsubscribe_entry(set, entry);
23113
- }
23114
- try {
23115
- entry.handler(detail);
23116
- }
23117
- catch (err) {
23118
- if (name === 'error' || this._firing_error) {
23119
- // surface to stderr as a last resort but never recurse;
23120
- // `console` is in the JS standard library and present in every
23121
- // supported runtime, so guarding it would just add an untestable
23122
- // branch. See #638.
23123
- // eslint-disable-next-line no-console
23124
- console.error(err);
23125
- }
23126
- else {
23127
- this._firing_error = true;
23128
- try {
23129
- this._fire('error', {
23130
- error: err,
23131
- source_event: name,
23132
- source_detail: detail,
23133
- handler: entry.handler
23134
- });
23135
- }
23136
- finally {
23137
- this._firing_error = false;
23138
- }
23139
- }
23140
- }
23165
+ this._fire_one(entry, set, name, detail);
23141
23166
  }
23142
23167
  }
23143
23168
  /** Low-level hook registration. Installs a handler described by a