xstate 5.18.1 → 5.19.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.
Files changed (71) hide show
  1. package/actions/dist/xstate-actions.cjs.d.mts +1 -1
  2. package/actions/dist/xstate-actions.cjs.d.ts +1 -1
  3. package/actions/dist/xstate-actions.cjs.js +2 -2
  4. package/actions/dist/xstate-actions.development.cjs.js +2 -2
  5. package/actions/dist/xstate-actions.development.esm.js +2 -2
  6. package/actions/dist/xstate-actions.esm.js +2 -2
  7. package/actions/dist/xstate-actions.umd.min.js +1 -1
  8. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  9. package/actors/dist/xstate-actors.cjs.d.mts +1 -1
  10. package/actors/dist/xstate-actors.cjs.d.ts +1 -1
  11. package/actors/dist/xstate-actors.cjs.js +1 -1
  12. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  13. package/actors/dist/xstate-actors.development.esm.js +1 -1
  14. package/actors/dist/xstate-actors.esm.js +1 -1
  15. package/actors/dist/xstate-actors.umd.min.js +1 -1
  16. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  17. package/dev/dist/xstate-dev.cjs.d.mts +1 -1
  18. package/dev/dist/xstate-dev.cjs.d.ts +1 -1
  19. package/dev/dist/xstate-dev.cjs.js +1 -1
  20. package/dev/dist/xstate-dev.development.cjs.js +1 -1
  21. package/dev/dist/xstate-dev.development.esm.js +1 -1
  22. package/dev/dist/xstate-dev.esm.js +1 -1
  23. package/dev/dist/xstate-dev.umd.min.js.map +1 -1
  24. package/dist/declarations/src/State.d.ts +1 -1
  25. package/dist/declarations/src/actions/raise.d.ts +9 -1
  26. package/dist/declarations/src/actions/send.d.ts +10 -1
  27. package/dist/declarations/src/createActor.d.ts +2 -1
  28. package/dist/declarations/src/getNextSnapshot.d.ts +2 -0
  29. package/dist/declarations/src/index.d.ts +1 -0
  30. package/dist/declarations/src/inspection.d.ts +3 -3
  31. package/dist/declarations/src/stateUtils.d.ts +17 -7
  32. package/dist/declarations/src/transition.d.ts +16 -0
  33. package/dist/declarations/src/types.d.ts +47 -14
  34. package/dist/declarations/src/utils.d.ts +1 -1
  35. package/dist/{log-d26be77d.development.cjs.js → log-17337367.development.cjs.js} +29 -19
  36. package/dist/{log-a2c94240.esm.js → log-2a773d37.esm.js} +28 -15
  37. package/dist/{log-098d2ed5.cjs.js → log-b0ee96de.cjs.js} +28 -15
  38. package/dist/{log-c92a07bc.development.esm.js → log-ef30c65f.development.esm.js} +29 -19
  39. package/dist/{raise-206d3d29.development.esm.js → raise-1db27a82.development.esm.js} +98 -73
  40. package/dist/{raise-830a98f7.development.cjs.js → raise-4acdb210.development.cjs.js} +98 -73
  41. package/dist/{raise-cde45f56.cjs.js → raise-60cebf03.cjs.js} +94 -71
  42. package/dist/{raise-c0e3c984.esm.js → raise-c17ec2bc.esm.js} +94 -71
  43. package/dist/xstate.cjs.d.mts +1 -1
  44. package/dist/xstate.cjs.d.ts +1 -1
  45. package/dist/xstate.cjs.js +60 -16
  46. package/dist/xstate.cjs.mjs +2 -0
  47. package/dist/xstate.development.cjs.js +60 -16
  48. package/dist/xstate.development.cjs.mjs +2 -0
  49. package/dist/xstate.development.esm.js +61 -19
  50. package/dist/xstate.esm.js +61 -19
  51. package/dist/xstate.umd.min.js +1 -1
  52. package/dist/xstate.umd.min.js.map +1 -1
  53. package/guards/dist/xstate-guards.cjs.d.mts +1 -1
  54. package/guards/dist/xstate-guards.cjs.d.ts +1 -1
  55. package/guards/dist/xstate-guards.cjs.js +1 -1
  56. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  57. package/guards/dist/xstate-guards.development.esm.js +1 -1
  58. package/guards/dist/xstate-guards.esm.js +1 -1
  59. package/guards/dist/xstate-guards.umd.min.js +1 -1
  60. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  61. package/package.json +7 -7
  62. package/actions/dist/xstate-actions.cjs.d.mts.map +0 -1
  63. package/actions/dist/xstate-actions.cjs.d.ts.map +0 -1
  64. package/actors/dist/xstate-actors.cjs.d.mts.map +0 -1
  65. package/actors/dist/xstate-actors.cjs.d.ts.map +0 -1
  66. package/dev/dist/xstate-dev.cjs.d.mts.map +0 -1
  67. package/dev/dist/xstate-dev.cjs.d.ts.map +0 -1
  68. package/dist/xstate.cjs.d.mts.map +0 -1
  69. package/dist/xstate.cjs.d.ts.map +0 -1
  70. package/guards/dist/xstate-guards.cjs.d.mts.map +0 -1
  71. package/guards/dist/xstate-guards.cjs.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-c0e3c984.esm.js';
1
+ import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-c17ec2bc.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -83,7 +83,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
83
83
  ...snapshot.children,
84
84
  ...spawnedChildren
85
85
  } : snapshot.children
86
- })];
86
+ }), undefined, undefined];
87
87
  }
88
88
  /**
89
89
  * Updates the current context of the machine.
@@ -120,7 +120,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
120
120
  * update.
121
121
  */
122
122
  function assign(assignment) {
123
- function assign(args, params) {
123
+ function assign(_args, _params) {
124
124
  }
125
125
  assign.type = 'xstate.assign';
126
126
  assign.assignment = assignment;
@@ -134,7 +134,7 @@ function resolveEmit(_, snapshot, args, actionParams, {
134
134
  const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
135
135
  return [snapshot, {
136
136
  event: resolvedEvent
137
- }];
137
+ }, undefined];
138
138
  }
139
139
  function executeEmit(actorScope, {
140
140
  event
@@ -177,9 +177,9 @@ function executeEmit(actorScope, {
177
177
  * // }
178
178
  * ```
179
179
  */
180
- function emit( /** The event to emit, or an expression that returns an event to emit. */
180
+ function emit(/** The event to emit, or an expression that returns an event to emit. */
181
181
  eventOrExpr) {
182
- function emit(args, params) {
182
+ function emit(_args, _params) {
183
183
  }
184
184
  emit.type = 'xstate.emit';
185
185
  emit.event = eventOrExpr;
@@ -209,8 +209,11 @@ eventOrExpr) {
209
209
 
210
210
  // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
211
211
  // https://github.com/microsoft/TypeScript/pull/57673
212
+
212
213
  /** @deprecated Use the built-in `NoInfer` type instead */
214
+
213
215
  /** The full definition of an event, with a string `type`. */
216
+
214
217
  /**
215
218
  * The string or object representing the state value relative to the parent
216
219
  * state node.
@@ -220,10 +223,12 @@ eventOrExpr) {
220
223
  * - For complex state nodes, this is an object, e.g., `{ success:
221
224
  * "someChildState" }`.
222
225
  */
223
- // TODO: remove once TS fixes this type-widening issue
226
+
224
227
  /** @deprecated Use `AnyMachineSnapshot` instead */
228
+
225
229
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
226
230
  /** @ignore */
231
+
227
232
  let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
228
233
  SpecialTargets["Parent"] = "#_parent";
229
234
  SpecialTargets["Internal"] = "#_internal";
@@ -249,6 +254,8 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
249
254
 
250
255
  /** @deprecated */
251
256
 
257
+ // TODO: cover all that can be actually returned
258
+
252
259
  function resolveSendTo(actorScope, snapshot, args, actionParams, {
253
260
  to,
254
261
  event: eventOrExpr,
@@ -257,7 +264,9 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
257
264
  }, extra) {
258
265
  const delaysMap = snapshot.machine.implementations.delays;
259
266
  if (typeof eventOrExpr === 'string') {
260
- throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
267
+ throw new Error(
268
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
269
+ `Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
261
270
  }
262
271
  const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
263
272
  let resolvedDelay;
@@ -270,9 +279,12 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
270
279
  const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
271
280
  let targetActorRef;
272
281
  if (typeof resolvedTarget === 'string') {
282
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
273
283
  if (resolvedTarget === SpecialTargets.Parent) {
274
284
  targetActorRef = actorScope.self._parent;
275
- } else if (resolvedTarget === SpecialTargets.Internal) {
285
+ }
286
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
287
+ else if (resolvedTarget === SpecialTargets.Internal) {
276
288
  targetActorRef = actorScope.self;
277
289
  } else if (resolvedTarget.startsWith('#_')) {
278
290
  // SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
@@ -289,10 +301,11 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
289
301
  }
290
302
  return [snapshot, {
291
303
  to: targetActorRef,
304
+ targetId: typeof resolvedTarget === 'string' ? resolvedTarget : undefined,
292
305
  event: resolvedEvent,
293
306
  id,
294
307
  delay: resolvedDelay
295
- }];
308
+ }, undefined];
296
309
  }
297
310
  function retryResolveSendTo(_, snapshot, params) {
298
311
  if (typeof params.to === 'string') {
@@ -331,9 +344,9 @@ function executeSendTo(actorScope, params) {
331
344
  * - `delay` - The number of milliseconds to delay the sending of the event.
332
345
  */
333
346
  function sendTo(to, eventOrExpr, options) {
334
- function sendTo(args, params) {
347
+ function sendTo(_args, _params) {
335
348
  }
336
- sendTo.type = 'xsnapshot.sendTo';
349
+ sendTo.type = 'xstate.sendTo';
337
350
  sendTo.to = to;
338
351
  sendTo.event = eventOrExpr;
339
352
  sendTo.id = options?.id;
@@ -433,7 +446,7 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
433
446
  * ```
434
447
  */
435
448
  function enqueueActions(collect) {
436
- function enqueueActions(args, params) {
449
+ function enqueueActions(_args, _params) {
437
450
  }
438
451
  enqueueActions.type = 'xstate.enqueueActions';
439
452
  enqueueActions.collect = collect;
@@ -448,7 +461,7 @@ function resolveLog(_, snapshot, actionArgs, actionParams, {
448
461
  return [snapshot, {
449
462
  value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
450
463
  label
451
- }];
464
+ }, undefined];
452
465
  }
453
466
  function executeLog({
454
467
  logger
@@ -478,7 +491,7 @@ function log(value = ({
478
491
  context,
479
492
  event
480
493
  }), label) {
481
- function log(args, params) {
494
+ function log(_args, _params) {
482
495
  }
483
496
  log.type = 'xstate.log';
484
497
  log.value = value;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-cde45f56.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-60cebf03.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -85,7 +85,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
85
85
  ...snapshot.children,
86
86
  ...spawnedChildren
87
87
  } : snapshot.children
88
- })];
88
+ }), undefined, undefined];
89
89
  }
90
90
  /**
91
91
  * Updates the current context of the machine.
@@ -122,7 +122,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
122
122
  * update.
123
123
  */
124
124
  function assign(assignment) {
125
- function assign(args, params) {
125
+ function assign(_args, _params) {
126
126
  }
127
127
  assign.type = 'xstate.assign';
128
128
  assign.assignment = assignment;
@@ -136,7 +136,7 @@ function resolveEmit(_, snapshot, args, actionParams, {
136
136
  const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
137
137
  return [snapshot, {
138
138
  event: resolvedEvent
139
- }];
139
+ }, undefined];
140
140
  }
141
141
  function executeEmit(actorScope, {
142
142
  event
@@ -179,9 +179,9 @@ function executeEmit(actorScope, {
179
179
  * // }
180
180
  * ```
181
181
  */
182
- function emit( /** The event to emit, or an expression that returns an event to emit. */
182
+ function emit(/** The event to emit, or an expression that returns an event to emit. */
183
183
  eventOrExpr) {
184
- function emit(args, params) {
184
+ function emit(_args, _params) {
185
185
  }
186
186
  emit.type = 'xstate.emit';
187
187
  emit.event = eventOrExpr;
@@ -211,8 +211,11 @@ eventOrExpr) {
211
211
 
212
212
  // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
213
213
  // https://github.com/microsoft/TypeScript/pull/57673
214
+
214
215
  /** @deprecated Use the built-in `NoInfer` type instead */
216
+
215
217
  /** The full definition of an event, with a string `type`. */
218
+
216
219
  /**
217
220
  * The string or object representing the state value relative to the parent
218
221
  * state node.
@@ -222,10 +225,12 @@ eventOrExpr) {
222
225
  * - For complex state nodes, this is an object, e.g., `{ success:
223
226
  * "someChildState" }`.
224
227
  */
225
- // TODO: remove once TS fixes this type-widening issue
228
+
226
229
  /** @deprecated Use `AnyMachineSnapshot` instead */
230
+
227
231
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
228
232
  /** @ignore */
233
+
229
234
  let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
230
235
  SpecialTargets["Parent"] = "#_parent";
231
236
  SpecialTargets["Internal"] = "#_internal";
@@ -251,6 +256,8 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
251
256
 
252
257
  /** @deprecated */
253
258
 
259
+ // TODO: cover all that can be actually returned
260
+
254
261
  function resolveSendTo(actorScope, snapshot, args, actionParams, {
255
262
  to,
256
263
  event: eventOrExpr,
@@ -259,7 +266,9 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
259
266
  }, extra) {
260
267
  const delaysMap = snapshot.machine.implementations.delays;
261
268
  if (typeof eventOrExpr === 'string') {
262
- throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
269
+ throw new Error(
270
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
271
+ `Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
263
272
  }
264
273
  const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
265
274
  let resolvedDelay;
@@ -272,9 +281,12 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
272
281
  const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
273
282
  let targetActorRef;
274
283
  if (typeof resolvedTarget === 'string') {
284
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
275
285
  if (resolvedTarget === SpecialTargets.Parent) {
276
286
  targetActorRef = actorScope.self._parent;
277
- } else if (resolvedTarget === SpecialTargets.Internal) {
287
+ }
288
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
289
+ else if (resolvedTarget === SpecialTargets.Internal) {
278
290
  targetActorRef = actorScope.self;
279
291
  } else if (resolvedTarget.startsWith('#_')) {
280
292
  // SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
@@ -291,10 +303,11 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
291
303
  }
292
304
  return [snapshot, {
293
305
  to: targetActorRef,
306
+ targetId: typeof resolvedTarget === 'string' ? resolvedTarget : undefined,
294
307
  event: resolvedEvent,
295
308
  id,
296
309
  delay: resolvedDelay
297
- }];
310
+ }, undefined];
298
311
  }
299
312
  function retryResolveSendTo(_, snapshot, params) {
300
313
  if (typeof params.to === 'string') {
@@ -333,9 +346,9 @@ function executeSendTo(actorScope, params) {
333
346
  * - `delay` - The number of milliseconds to delay the sending of the event.
334
347
  */
335
348
  function sendTo(to, eventOrExpr, options) {
336
- function sendTo(args, params) {
349
+ function sendTo(_args, _params) {
337
350
  }
338
- sendTo.type = 'xsnapshot.sendTo';
351
+ sendTo.type = 'xstate.sendTo';
339
352
  sendTo.to = to;
340
353
  sendTo.event = eventOrExpr;
341
354
  sendTo.id = options?.id;
@@ -435,7 +448,7 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
435
448
  * ```
436
449
  */
437
450
  function enqueueActions(collect) {
438
- function enqueueActions(args, params) {
451
+ function enqueueActions(_args, _params) {
439
452
  }
440
453
  enqueueActions.type = 'xstate.enqueueActions';
441
454
  enqueueActions.collect = collect;
@@ -450,7 +463,7 @@ function resolveLog(_, snapshot, actionArgs, actionParams, {
450
463
  return [snapshot, {
451
464
  value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
452
465
  label
453
- }];
466
+ }, undefined];
454
467
  }
455
468
  function executeLog({
456
469
  logger
@@ -480,7 +493,7 @@ function log(value = ({
480
493
  context,
481
494
  event
482
495
  }), label) {
483
- function log(args, params) {
496
+ function log(_args, _params) {
484
497
  }
485
498
  log.type = 'xstate.log';
486
499
  log.value = value;
@@ -1,4 +1,4 @@
1
- import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as executingCustomAction, W as XSTATE_ERROR, Y as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-206d3d29.development.esm.js';
1
+ import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as executingCustomAction, W as XSTATE_ERROR, Y as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-1db27a82.development.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -83,7 +83,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
83
83
  ...snapshot.children,
84
84
  ...spawnedChildren
85
85
  } : snapshot.children
86
- })];
86
+ }), undefined, undefined];
87
87
  }
88
88
  /**
89
89
  * Updates the current context of the machine.
@@ -123,7 +123,7 @@ function assign(assignment) {
123
123
  if (executingCustomAction) {
124
124
  console.warn('Custom actions should not call `assign()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
125
125
  }
126
- function assign(args, params) {
126
+ function assign(_args, _params) {
127
127
  {
128
128
  throw new Error(`This isn't supposed to be called`);
129
129
  }
@@ -137,13 +137,10 @@ function assign(assignment) {
137
137
  function resolveEmit(_, snapshot, args, actionParams, {
138
138
  event: eventOrExpr
139
139
  }) {
140
- if (typeof eventOrExpr === 'string') {
141
- throw new Error(`Only event objects may be used with emit; use emit({ type: "${eventOrExpr}" }) instead`);
142
- }
143
140
  const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
144
141
  return [snapshot, {
145
142
  event: resolvedEvent
146
- }];
143
+ }, undefined];
147
144
  }
148
145
  function executeEmit(actorScope, {
149
146
  event
@@ -186,12 +183,12 @@ function executeEmit(actorScope, {
186
183
  * // }
187
184
  * ```
188
185
  */
189
- function emit( /** The event to emit, or an expression that returns an event to emit. */
186
+ function emit(/** The event to emit, or an expression that returns an event to emit. */
190
187
  eventOrExpr) {
191
188
  if (executingCustomAction) {
192
189
  console.warn('Custom actions should not call `emit()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
193
190
  }
194
- function emit(args, params) {
191
+ function emit(_args, _params) {
195
192
  {
196
193
  throw new Error(`This isn't supposed to be called`);
197
194
  }
@@ -224,8 +221,11 @@ eventOrExpr) {
224
221
 
225
222
  // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
226
223
  // https://github.com/microsoft/TypeScript/pull/57673
224
+
227
225
  /** @deprecated Use the built-in `NoInfer` type instead */
226
+
228
227
  /** The full definition of an event, with a string `type`. */
228
+
229
229
  /**
230
230
  * The string or object representing the state value relative to the parent
231
231
  * state node.
@@ -235,10 +235,12 @@ eventOrExpr) {
235
235
  * - For complex state nodes, this is an object, e.g., `{ success:
236
236
  * "someChildState" }`.
237
237
  */
238
- // TODO: remove once TS fixes this type-widening issue
238
+
239
239
  /** @deprecated Use `AnyMachineSnapshot` instead */
240
+
240
241
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
241
242
  /** @ignore */
243
+
242
244
  let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
243
245
  SpecialTargets["Parent"] = "#_parent";
244
246
  SpecialTargets["Internal"] = "#_internal";
@@ -264,6 +266,8 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
264
266
 
265
267
  /** @deprecated */
266
268
 
269
+ // TODO: cover all that can be actually returned
270
+
267
271
  function resolveSendTo(actorScope, snapshot, args, actionParams, {
268
272
  to,
269
273
  event: eventOrExpr,
@@ -272,7 +276,9 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
272
276
  }, extra) {
273
277
  const delaysMap = snapshot.machine.implementations.delays;
274
278
  if (typeof eventOrExpr === 'string') {
275
- throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
279
+ throw new Error(
280
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
281
+ `Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
276
282
  }
277
283
  const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
278
284
  let resolvedDelay;
@@ -285,9 +291,12 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
285
291
  const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
286
292
  let targetActorRef;
287
293
  if (typeof resolvedTarget === 'string') {
294
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
288
295
  if (resolvedTarget === SpecialTargets.Parent) {
289
296
  targetActorRef = actorScope.self._parent;
290
- } else if (resolvedTarget === SpecialTargets.Internal) {
297
+ }
298
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
299
+ else if (resolvedTarget === SpecialTargets.Internal) {
291
300
  targetActorRef = actorScope.self;
292
301
  } else if (resolvedTarget.startsWith('#_')) {
293
302
  // SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
@@ -304,10 +313,11 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
304
313
  }
305
314
  return [snapshot, {
306
315
  to: targetActorRef,
316
+ targetId: typeof resolvedTarget === 'string' ? resolvedTarget : undefined,
307
317
  event: resolvedEvent,
308
318
  id,
309
319
  delay: resolvedDelay
310
- }];
320
+ }, undefined];
311
321
  }
312
322
  function retryResolveSendTo(_, snapshot, params) {
313
323
  if (typeof params.to === 'string') {
@@ -347,14 +357,14 @@ function executeSendTo(actorScope, params) {
347
357
  */
348
358
  function sendTo(to, eventOrExpr, options) {
349
359
  if (executingCustomAction) {
350
- console.warn('Custom actions should not call `raise()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
360
+ console.warn('Custom actions should not call `sendTo()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
351
361
  }
352
- function sendTo(args, params) {
362
+ function sendTo(_args, _params) {
353
363
  {
354
364
  throw new Error(`This isn't supposed to be called`);
355
365
  }
356
366
  }
357
- sendTo.type = 'xsnapshot.sendTo';
367
+ sendTo.type = 'xstate.sendTo';
358
368
  sendTo.to = to;
359
369
  sendTo.event = eventOrExpr;
360
370
  sendTo.id = options?.id;
@@ -464,7 +474,7 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
464
474
  * ```
465
475
  */
466
476
  function enqueueActions(collect) {
467
- function enqueueActions(args, params) {
477
+ function enqueueActions(_args, _params) {
468
478
  {
469
479
  throw new Error(`This isn't supposed to be called`);
470
480
  }
@@ -482,7 +492,7 @@ function resolveLog(_, snapshot, actionArgs, actionParams, {
482
492
  return [snapshot, {
483
493
  value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
484
494
  label
485
- }];
495
+ }, undefined];
486
496
  }
487
497
  function executeLog({
488
498
  logger
@@ -512,7 +522,7 @@ function log(value = ({
512
522
  context,
513
523
  event
514
524
  }), label) {
515
- function log(args, params) {
525
+ function log(_args, _params) {
516
526
  {
517
527
  throw new Error(`This isn't supposed to be called`);
518
528
  }