xstate 5.14.0 → 5.16.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 (59) hide show
  1. package/actions/dist/xstate-actions.cjs.js +2 -2
  2. package/actions/dist/xstate-actions.development.cjs.js +2 -2
  3. package/actions/dist/xstate-actions.development.esm.js +2 -2
  4. package/actions/dist/xstate-actions.esm.js +2 -2
  5. package/actions/dist/xstate-actions.umd.min.js +1 -1
  6. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  7. package/actors/dist/xstate-actors.cjs.js +272 -65
  8. package/actors/dist/xstate-actors.development.cjs.js +272 -65
  9. package/actors/dist/xstate-actors.development.esm.js +272 -65
  10. package/actors/dist/xstate-actors.esm.js +272 -65
  11. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  12. package/dist/declarations/src/State.d.ts +23 -27
  13. package/dist/declarations/src/StateMachine.d.ts +19 -31
  14. package/dist/declarations/src/StateNode.d.ts +29 -51
  15. package/dist/declarations/src/actions/assign.d.ts +29 -27
  16. package/dist/declarations/src/actions/cancel.d.ts +28 -22
  17. package/dist/declarations/src/actions/emit.d.ts +33 -33
  18. package/dist/declarations/src/actions/enqueueActions.d.ts +21 -18
  19. package/dist/declarations/src/actions/log.d.ts +5 -4
  20. package/dist/declarations/src/actions/send.d.ts +5 -3
  21. package/dist/declarations/src/actors/callback.d.ts +65 -26
  22. package/dist/declarations/src/actors/index.d.ts +4 -4
  23. package/dist/declarations/src/actors/observable.d.ts +65 -22
  24. package/dist/declarations/src/actors/promise.d.ts +86 -9
  25. package/dist/declarations/src/actors/transition.d.ts +89 -15
  26. package/dist/declarations/src/assert.d.ts +21 -20
  27. package/dist/declarations/src/createActor.d.ts +51 -42
  28. package/dist/declarations/src/createMachine.d.ts +40 -54
  29. package/dist/declarations/src/getNextSnapshot.d.ts +27 -24
  30. package/dist/declarations/src/guards.d.ts +67 -66
  31. package/dist/declarations/src/index.d.ts +1 -2
  32. package/dist/declarations/src/inspection.d.ts +1 -0
  33. package/dist/declarations/src/setup.d.ts +1 -2
  34. package/dist/declarations/src/spawn.d.ts +2 -5
  35. package/dist/declarations/src/stateUtils.d.ts +5 -10
  36. package/dist/declarations/src/toPromise.d.ts +1 -0
  37. package/dist/declarations/src/types.d.ts +164 -189
  38. package/dist/declarations/src/waitFor.d.ts +9 -9
  39. package/dist/{log-c943e6aa.development.esm.js → log-17f4495d.development.esm.js} +115 -117
  40. package/dist/{log-505687fd.development.cjs.js → log-31321d85.development.cjs.js} +115 -117
  41. package/dist/{log-b87cb6bd.esm.js → log-8320f5e6.esm.js} +115 -117
  42. package/dist/{log-7ae0ddf8.cjs.js → log-f9587b82.cjs.js} +115 -117
  43. package/dist/{raise-4e39e875.esm.js → raise-2cfe6b8f.esm.js} +164 -154
  44. package/dist/{raise-0f400094.development.esm.js → raise-7d030497.development.esm.js} +164 -154
  45. package/dist/{raise-f79d2832.cjs.js → raise-a6298350.cjs.js} +164 -154
  46. package/dist/{raise-0cd7e521.development.cjs.js → raise-bad6a97b.development.cjs.js} +164 -154
  47. package/dist/xstate.cjs.js +134 -157
  48. package/dist/xstate.development.cjs.js +134 -157
  49. package/dist/xstate.development.esm.js +136 -159
  50. package/dist/xstate.esm.js +136 -159
  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.js +1 -1
  54. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  55. package/guards/dist/xstate-guards.development.esm.js +1 -1
  56. package/guards/dist/xstate-guards.esm.js +1 -1
  57. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  58. package/package.json +1 -1
  59. package/dist/declarations/src/typegenTypes.d.ts +0 -168
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-0cd7e521.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-bad6a97b.development.cjs.js');
4
4
 
5
- // it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
6
- // but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
7
- // and we strive to support TS 5.0 whenever possible
8
5
  function createSpawner(actorScope, {
9
6
  machine,
10
7
  context
@@ -93,34 +90,36 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
93
90
  /**
94
91
  * Updates the current context of the machine.
95
92
  *
96
- * @param assignment An object that represents the partial context to update, or a
97
- * function that returns an object that represents the partial context to update.
98
- *
99
93
  * @example
100
- ```ts
101
- import { createMachine, assign } from 'xstate';
102
-
103
- const countMachine = createMachine({
104
- context: {
105
- count: 0,
106
- message: ''
107
- },
108
- on: {
109
- inc: {
110
- actions: assign({
111
- count: ({ context }) => context.count + 1
112
- })
113
- },
114
- updateMessage: {
115
- actions: assign(({ context, event }) => {
116
- return {
117
- message: event.message.trim()
118
- }
119
- })
120
- }
121
- }
122
- });
123
- ```
94
+ *
95
+ * ```ts
96
+ * import { createMachine, assign } from 'xstate';
97
+ *
98
+ * const countMachine = createMachine({
99
+ * context: {
100
+ * count: 0,
101
+ * message: ''
102
+ * },
103
+ * on: {
104
+ * inc: {
105
+ * actions: assign({
106
+ * count: ({ context }) => context.count + 1
107
+ * })
108
+ * },
109
+ * updateMessage: {
110
+ * actions: assign(({ context, event }) => {
111
+ * return {
112
+ * message: event.message.trim()
113
+ * };
114
+ * })
115
+ * }
116
+ * }
117
+ * });
118
+ * ```
119
+ *
120
+ * @param assignment An object that represents the partial context to update, or
121
+ * a function that returns an object that represents the partial context to
122
+ * update.
124
123
  */
125
124
  function assign(assignment) {
126
125
  if (guards_dist_xstateGuards.executingCustomAction) {
@@ -154,43 +153,42 @@ function executeEmit(actorScope, {
154
153
  actorScope.defer(() => actorScope.emit(event));
155
154
  }
156
155
  /**
157
- * Emits an event to event handlers registered on the actor via `actor.on(event, handler)`.
156
+ * Emits an event to event handlers registered on the actor via `actor.on(event,
157
+ * handler)`.
158
158
  *
159
159
  * @example
160
- ```ts
161
- import { emit } from 'xstate';
162
-
163
- const machine = createMachine({
164
- // ...
165
- on: {
166
- something: {
167
- actions: emit({
168
- type: 'emitted',
169
- some: 'data'
170
- })
171
- }
172
- }
173
- // ...
174
- });
175
-
176
- const actor = createActor(machine).start();
177
-
178
- actor.on('emitted', (event) => {
179
- console.log(event);
180
- });
181
-
182
- actor.send({ type: 'something' });
183
- // logs:
184
- // {
185
- // type: 'emitted',
186
- // some: 'data'
187
- // }
188
- ```
189
- */
190
- function emit(
191
- /**
192
- * The event to emit, or an expression that returns an event to emit.
160
+ *
161
+ * ```ts
162
+ * import { emit } from 'xstate';
163
+ *
164
+ * const machine = createMachine({
165
+ * // ...
166
+ * on: {
167
+ * something: {
168
+ * actions: emit({
169
+ * type: 'emitted',
170
+ * some: 'data'
171
+ * })
172
+ * }
173
+ * }
174
+ * // ...
175
+ * });
176
+ *
177
+ * const actor = createActor(machine).start();
178
+ *
179
+ * actor.on('emitted', (event) => {
180
+ * console.log(event);
181
+ * });
182
+ *
183
+ * actor.send({ type: 'something' });
184
+ * // logs:
185
+ * // {
186
+ * // type: 'emitted',
187
+ * // some: 'data'
188
+ * // }
189
+ * ```
193
190
  */
191
+ function emit( /** The event to emit, or an expression that returns an event to emit. */
194
192
  eventOrExpr) {
195
193
  if (guards_dist_xstateGuards.executingCustomAction) {
196
194
  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.');
@@ -208,62 +206,52 @@ eventOrExpr) {
208
206
  }
209
207
 
210
208
  /**
211
- *
212
209
  * @remarks
213
- *
214
- * `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
215
- * It especially is a problem when the union has a function member, like here:
210
+ * `T | unknown` reduces to `unknown` and that can be problematic when it comes
211
+ * to contextual typing. It especially is a problem when the union has a
212
+ * function member, like here:
216
213
  *
217
214
  * ```ts
218
- * declare function test(cbOrVal: ((arg: number) => unknown) | unknown): void;
219
- * test((arg) => {}) // oops, implicit any
215
+ * declare function test(
216
+ * cbOrVal: ((arg: number) => unknown) | unknown
217
+ * ): void;
218
+ * test((arg) => {}); // oops, implicit any
220
219
  * ```
221
220
  *
222
- * This type can be used to avoid this problem. This union represents the same value space as `unknown`.
221
+ * This type can be used to avoid this problem. This union represents the same
222
+ * value space as `unknown`.
223
223
  */
224
224
 
225
225
  // https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
226
226
 
227
227
  // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
228
228
  // https://github.com/microsoft/TypeScript/pull/57673
229
+ /** @deprecated Use the built-in `NoInfer` type instead */
230
+ /** The full definition of an event, with a string `type`. */
229
231
  /**
230
- * @deprecated Use the built-in `NoInfer` type instead
231
- */
232
- /**
233
- * The full definition of an event, with a string `type`.
234
- */
235
- /**
236
- * The string or object representing the state value relative to the parent state node.
232
+ * The string or object representing the state value relative to the parent
233
+ * state node.
237
234
  *
238
235
  * @remarks
239
- *
240
236
  * - For a child atomic state node, this is a string, e.g., `"pending"`.
241
- *
242
- * - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
237
+ * - For complex state nodes, this is an object, e.g., `{ success:
238
+ * "someChildState" }`.
243
239
  */
244
240
  // TODO: remove once TS fixes this type-widening issue
245
- /** @deprecated use `AnyMachineSnapshot` instead */
241
+ /** @deprecated Use `AnyMachineSnapshot` instead */
246
242
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
247
- /**
248
- * @hidden
249
- */
243
+ /** @ignore */
250
244
  let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
251
245
  SpecialTargets["Parent"] = "#_parent";
252
246
  SpecialTargets["Internal"] = "#_internal";
253
247
  return SpecialTargets;
254
248
  }({});
255
249
 
256
- /**
257
- * @deprecated Use `AnyActor` instead.
258
- */
250
+ /** @deprecated Use `AnyActor` instead. */
259
251
 
260
252
  // Based on RxJS types
261
253
 
262
- /**
263
- * @deprecated Use `Actor<T>` instead.
264
- */
265
-
266
- // only meant to be used internally for debugging purposes
254
+ /** @deprecated Use `Actor<T>` instead. */
267
255
 
268
256
  /**
269
257
  * Represents logic which can be used by an actor.
@@ -274,6 +262,8 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
274
262
  * @template TSystem - The type of the actor system.
275
263
  */
276
264
 
265
+ /** @deprecated */
266
+
277
267
  function resolveSendTo(actorScope, snapshot, args, actionParams, {
278
268
  to,
279
269
  event: eventOrExpr,
@@ -348,10 +338,12 @@ function executeSendTo(actorScope, params) {
348
338
  * Sends an event to an actor.
349
339
  *
350
340
  * @param actor The `ActorRef` to send the event to.
351
- * @param event The event to send, or an expression that evaluates to the event to send
341
+ * @param event The event to send, or an expression that evaluates to the event
342
+ * to send
352
343
  * @param options Send action options
353
- * - `id` - The unique send event identifier (used with `cancel()`).
354
- * - `delay` - The number of milliseconds to delay the sending of the event.
344
+ *
345
+ * - `id` - The unique send event identifier (used with `cancel()`).
346
+ * - `delay` - The number of milliseconds to delay the sending of the event.
355
347
  */
356
348
  function sendTo(to, eventOrExpr, options) {
357
349
  if (guards_dist_xstateGuards.executingCustomAction) {
@@ -427,6 +419,9 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
427
419
  // then it fails to typecheck that because `...args` use `string` in place of `TDelay
428
420
  actions.push(sendTo(...args));
429
421
  };
422
+ enqueue.sendParent = (...args) => {
423
+ actions.push(sendParent(...args));
424
+ };
430
425
  enqueue.spawnChild = (...args) => {
431
426
  actions.push(guards_dist_xstateGuards.spawnChild(...args));
432
427
  };
@@ -447,24 +442,26 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
447
442
  return [snapshot, undefined, actions];
448
443
  }
449
444
  /**
450
- * Creates an action object that will execute actions that are queued by the `enqueue(action)` function.
445
+ * Creates an action object that will execute actions that are queued by the
446
+ * `enqueue(action)` function.
451
447
  *
452
448
  * @example
453
- ```ts
454
- import { createMachine, enqueueActions } from 'xstate';
455
-
456
- const machine = createMachine({
457
- entry: enqueueActions(({ enqueue, check }) => {
458
- enqueue.assign({ count: 0 });
459
-
460
- if (check('someGuard')) {
461
- enqueue.assign({ count: 1 });
462
- }
463
-
464
- enqueue('someAction');
465
- })
466
- })
467
- ```
449
+ *
450
+ * ```ts
451
+ * import { createMachine, enqueueActions } from 'xstate';
452
+ *
453
+ * const machine = createMachine({
454
+ * entry: enqueueActions(({ enqueue, check }) => {
455
+ * enqueue.assign({ count: 0 });
456
+ *
457
+ * if (check('someGuard')) {
458
+ * enqueue.assign({ count: 1 });
459
+ * }
460
+ *
461
+ * enqueue('someAction');
462
+ * })
463
+ * });
464
+ * ```
468
465
  */
469
466
  function enqueueActions(collect) {
470
467
  function enqueueActions(args, params) {
@@ -500,11 +497,12 @@ function executeLog({
500
497
  }
501
498
  }
502
499
  /**
500
+ * @param expr The expression function to evaluate which will be logged. Takes
501
+ * in 2 arguments:
502
+ *
503
+ * - `ctx` - the current state context
504
+ * - `event` - the event that caused this action to be executed.
503
505
  *
504
- * @param expr The expression function to evaluate which will be logged.
505
- * Takes in 2 arguments:
506
- * - `ctx` - the current state context
507
- * - `event` - the event that caused this action to be executed.
508
506
  * @param label The label to give to the logged expression.
509
507
  */
510
508
  function log(value = ({
@@ -1,8 +1,5 @@
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-4e39e875.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-2cfe6b8f.esm.js';
2
2
 
3
- // it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
4
- // but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
5
- // and we strive to support TS 5.0 whenever possible
6
3
  function createSpawner(actorScope, {
7
4
  machine,
8
5
  context
@@ -91,34 +88,36 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
91
88
  /**
92
89
  * Updates the current context of the machine.
93
90
  *
94
- * @param assignment An object that represents the partial context to update, or a
95
- * function that returns an object that represents the partial context to update.
96
- *
97
91
  * @example
98
- ```ts
99
- import { createMachine, assign } from 'xstate';
100
-
101
- const countMachine = createMachine({
102
- context: {
103
- count: 0,
104
- message: ''
105
- },
106
- on: {
107
- inc: {
108
- actions: assign({
109
- count: ({ context }) => context.count + 1
110
- })
111
- },
112
- updateMessage: {
113
- actions: assign(({ context, event }) => {
114
- return {
115
- message: event.message.trim()
116
- }
117
- })
118
- }
119
- }
120
- });
121
- ```
92
+ *
93
+ * ```ts
94
+ * import { createMachine, assign } from 'xstate';
95
+ *
96
+ * const countMachine = createMachine({
97
+ * context: {
98
+ * count: 0,
99
+ * message: ''
100
+ * },
101
+ * on: {
102
+ * inc: {
103
+ * actions: assign({
104
+ * count: ({ context }) => context.count + 1
105
+ * })
106
+ * },
107
+ * updateMessage: {
108
+ * actions: assign(({ context, event }) => {
109
+ * return {
110
+ * message: event.message.trim()
111
+ * };
112
+ * })
113
+ * }
114
+ * }
115
+ * });
116
+ * ```
117
+ *
118
+ * @param assignment An object that represents the partial context to update, or
119
+ * a function that returns an object that represents the partial context to
120
+ * update.
122
121
  */
123
122
  function assign(assignment) {
124
123
  function assign(args, params) {
@@ -143,43 +142,42 @@ function executeEmit(actorScope, {
143
142
  actorScope.defer(() => actorScope.emit(event));
144
143
  }
145
144
  /**
146
- * Emits an event to event handlers registered on the actor via `actor.on(event, handler)`.
145
+ * Emits an event to event handlers registered on the actor via `actor.on(event,
146
+ * handler)`.
147
147
  *
148
148
  * @example
149
- ```ts
150
- import { emit } from 'xstate';
151
-
152
- const machine = createMachine({
153
- // ...
154
- on: {
155
- something: {
156
- actions: emit({
157
- type: 'emitted',
158
- some: 'data'
159
- })
160
- }
161
- }
162
- // ...
163
- });
164
-
165
- const actor = createActor(machine).start();
166
-
167
- actor.on('emitted', (event) => {
168
- console.log(event);
169
- });
170
-
171
- actor.send({ type: 'something' });
172
- // logs:
173
- // {
174
- // type: 'emitted',
175
- // some: 'data'
176
- // }
177
- ```
178
- */
179
- function emit(
180
- /**
181
- * The event to emit, or an expression that returns an event to emit.
149
+ *
150
+ * ```ts
151
+ * import { emit } from 'xstate';
152
+ *
153
+ * const machine = createMachine({
154
+ * // ...
155
+ * on: {
156
+ * something: {
157
+ * actions: emit({
158
+ * type: 'emitted',
159
+ * some: 'data'
160
+ * })
161
+ * }
162
+ * }
163
+ * // ...
164
+ * });
165
+ *
166
+ * const actor = createActor(machine).start();
167
+ *
168
+ * actor.on('emitted', (event) => {
169
+ * console.log(event);
170
+ * });
171
+ *
172
+ * actor.send({ type: 'something' });
173
+ * // logs:
174
+ * // {
175
+ * // type: 'emitted',
176
+ * // some: 'data'
177
+ * // }
178
+ * ```
182
179
  */
180
+ function emit( /** The event to emit, or an expression that returns an event to emit. */
183
181
  eventOrExpr) {
184
182
  function emit(args, params) {
185
183
  }
@@ -191,62 +189,52 @@ eventOrExpr) {
191
189
  }
192
190
 
193
191
  /**
194
- *
195
192
  * @remarks
196
- *
197
- * `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
198
- * It especially is a problem when the union has a function member, like here:
193
+ * `T | unknown` reduces to `unknown` and that can be problematic when it comes
194
+ * to contextual typing. It especially is a problem when the union has a
195
+ * function member, like here:
199
196
  *
200
197
  * ```ts
201
- * declare function test(cbOrVal: ((arg: number) => unknown) | unknown): void;
202
- * test((arg) => {}) // oops, implicit any
198
+ * declare function test(
199
+ * cbOrVal: ((arg: number) => unknown) | unknown
200
+ * ): void;
201
+ * test((arg) => {}); // oops, implicit any
203
202
  * ```
204
203
  *
205
- * This type can be used to avoid this problem. This union represents the same value space as `unknown`.
204
+ * This type can be used to avoid this problem. This union represents the same
205
+ * value space as `unknown`.
206
206
  */
207
207
 
208
208
  // https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
209
209
 
210
210
  // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
211
211
  // https://github.com/microsoft/TypeScript/pull/57673
212
+ /** @deprecated Use the built-in `NoInfer` type instead */
213
+ /** The full definition of an event, with a string `type`. */
212
214
  /**
213
- * @deprecated Use the built-in `NoInfer` type instead
214
- */
215
- /**
216
- * The full definition of an event, with a string `type`.
217
- */
218
- /**
219
- * The string or object representing the state value relative to the parent state node.
215
+ * The string or object representing the state value relative to the parent
216
+ * state node.
220
217
  *
221
218
  * @remarks
222
- *
223
219
  * - For a child atomic state node, this is a string, e.g., `"pending"`.
224
- *
225
- * - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
220
+ * - For complex state nodes, this is an object, e.g., `{ success:
221
+ * "someChildState" }`.
226
222
  */
227
223
  // TODO: remove once TS fixes this type-widening issue
228
- /** @deprecated use `AnyMachineSnapshot` instead */
224
+ /** @deprecated Use `AnyMachineSnapshot` instead */
229
225
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
230
- /**
231
- * @hidden
232
- */
226
+ /** @ignore */
233
227
  let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
234
228
  SpecialTargets["Parent"] = "#_parent";
235
229
  SpecialTargets["Internal"] = "#_internal";
236
230
  return SpecialTargets;
237
231
  }({});
238
232
 
239
- /**
240
- * @deprecated Use `AnyActor` instead.
241
- */
233
+ /** @deprecated Use `AnyActor` instead. */
242
234
 
243
235
  // Based on RxJS types
244
236
 
245
- /**
246
- * @deprecated Use `Actor<T>` instead.
247
- */
248
-
249
- // only meant to be used internally for debugging purposes
237
+ /** @deprecated Use `Actor<T>` instead. */
250
238
 
251
239
  /**
252
240
  * Represents logic which can be used by an actor.
@@ -257,6 +245,8 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
257
245
  * @template TSystem - The type of the actor system.
258
246
  */
259
247
 
248
+ /** @deprecated */
249
+
260
250
  function resolveSendTo(actorScope, snapshot, args, actionParams, {
261
251
  to,
262
252
  event: eventOrExpr,
@@ -331,10 +321,12 @@ function executeSendTo(actorScope, params) {
331
321
  * Sends an event to an actor.
332
322
  *
333
323
  * @param actor The `ActorRef` to send the event to.
334
- * @param event The event to send, or an expression that evaluates to the event to send
324
+ * @param event The event to send, or an expression that evaluates to the event
325
+ * to send
335
326
  * @param options Send action options
336
- * - `id` - The unique send event identifier (used with `cancel()`).
337
- * - `delay` - The number of milliseconds to delay the sending of the event.
327
+ *
328
+ * - `id` - The unique send event identifier (used with `cancel()`).
329
+ * - `delay` - The number of milliseconds to delay the sending of the event.
338
330
  */
339
331
  function sendTo(to, eventOrExpr, options) {
340
332
  function sendTo(args, params) {
@@ -394,6 +386,9 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
394
386
  // then it fails to typecheck that because `...args` use `string` in place of `TDelay
395
387
  actions.push(sendTo(...args));
396
388
  };
389
+ enqueue.sendParent = (...args) => {
390
+ actions.push(sendParent(...args));
391
+ };
397
392
  enqueue.spawnChild = (...args) => {
398
393
  actions.push(spawnChild(...args));
399
394
  };
@@ -414,24 +409,26 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
414
409
  return [snapshot, undefined, actions];
415
410
  }
416
411
  /**
417
- * Creates an action object that will execute actions that are queued by the `enqueue(action)` function.
412
+ * Creates an action object that will execute actions that are queued by the
413
+ * `enqueue(action)` function.
418
414
  *
419
415
  * @example
420
- ```ts
421
- import { createMachine, enqueueActions } from 'xstate';
422
-
423
- const machine = createMachine({
424
- entry: enqueueActions(({ enqueue, check }) => {
425
- enqueue.assign({ count: 0 });
426
-
427
- if (check('someGuard')) {
428
- enqueue.assign({ count: 1 });
429
- }
430
-
431
- enqueue('someAction');
432
- })
433
- })
434
- ```
416
+ *
417
+ * ```ts
418
+ * import { createMachine, enqueueActions } from 'xstate';
419
+ *
420
+ * const machine = createMachine({
421
+ * entry: enqueueActions(({ enqueue, check }) => {
422
+ * enqueue.assign({ count: 0 });
423
+ *
424
+ * if (check('someGuard')) {
425
+ * enqueue.assign({ count: 1 });
426
+ * }
427
+ *
428
+ * enqueue('someAction');
429
+ * })
430
+ * });
431
+ * ```
435
432
  */
436
433
  function enqueueActions(collect) {
437
434
  function enqueueActions(args, params) {
@@ -464,11 +461,12 @@ function executeLog({
464
461
  }
465
462
  }
466
463
  /**
464
+ * @param expr The expression function to evaluate which will be logged. Takes
465
+ * in 2 arguments:
466
+ *
467
+ * - `ctx` - the current state context
468
+ * - `event` - the event that caused this action to be executed.
467
469
  *
468
- * @param expr The expression function to evaluate which will be logged.
469
- * Takes in 2 arguments:
470
- * - `ctx` - the current state context
471
- * - `event` - the event that caused this action to be executed.
472
470
  * @param label The label to give to the logged expression.
473
471
  */
474
472
  function log(value = ({