jssm 5.144.7 → 5.145.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.
@@ -1355,6 +1355,24 @@ declare class Machine<mDT> {
1355
1355
  * calling this directly.
1356
1356
  * @param HookDesc - A hook descriptor specifying kind, states, and handler.
1357
1357
  */
1358
+ /**
1359
+ * Validate a {@link HookDescription} before registration. Every hook needs
1360
+ * a `handler` function, and each kind's identifying spatial fields
1361
+ * (`from`/`to`/`action`) must be exactly those `set_hook` reads for that
1362
+ * kind — present when required, absent otherwise. This turns a mis-shaped
1363
+ * descriptor into a thrown error instead of a silently dead hook keyed on
1364
+ * `undefined` (e.g. an `exit` hook handed `to` instead of `from`, #734).
1365
+ *
1366
+ * @param HookDesc - The descriptor about to be registered.
1367
+ * @throws JssmError if the kind is unknown, the handler is not a function, a
1368
+ * required field is missing, or an inapplicable field is present.
1369
+ *
1370
+ * @example
1371
+ * const m = sm`a -> b;`;
1372
+ * // an exit hook is keyed by `from`, so supplying `to` is rejected:
1373
+ * expect(() => m.set_hook({ kind: 'exit', to: 'a', handler: () => true })).toThrow();
1374
+ */
1375
+ _validate_hook_description(HookDesc: HookDescription<mDT>): void;
1358
1376
  set_hook(HookDesc: HookDescription<mDT>): void;
1359
1377
  /**
1360
1378
  * Remove a previously-registered hook described by a