xstate 5.0.0-beta.37 → 5.0.0-beta.38

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 (62) hide show
  1. package/actions/dist/xstate-actions.cjs.js +4 -3
  2. package/actions/dist/xstate-actions.cjs.mjs +1 -0
  3. package/actions/dist/xstate-actions.development.cjs.js +4 -3
  4. package/actions/dist/xstate-actions.development.cjs.mjs +1 -0
  5. package/actions/dist/xstate-actions.development.esm.js +3 -3
  6. package/actions/dist/xstate-actions.esm.js +3 -3
  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.js +1 -1
  10. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  11. package/actors/dist/xstate-actors.development.esm.js +1 -1
  12. package/actors/dist/xstate-actors.esm.js +1 -1
  13. package/actors/dist/xstate-actors.umd.min.js +1 -1
  14. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  15. package/dist/declarations/src/State.d.ts +2 -2
  16. package/dist/declarations/src/StateMachine.d.ts +4 -4
  17. package/dist/declarations/src/actions/assign.d.ts +4 -4
  18. package/dist/declarations/src/actions/cancel.d.ts +4 -4
  19. package/dist/declarations/src/actions/choose.d.ts +3 -3
  20. package/dist/declarations/src/actions/log.d.ts +4 -4
  21. package/dist/declarations/src/actions/pure.d.ts +4 -4
  22. package/dist/declarations/src/actions/raise.d.ts +3 -3
  23. package/dist/declarations/src/actions/send.d.ts +7 -7
  24. package/dist/declarations/src/actions/spawn.d.ts +34 -0
  25. package/dist/declarations/src/actions/stop.d.ts +4 -4
  26. package/dist/declarations/src/actions.d.ts +1 -0
  27. package/dist/declarations/src/actors/callback.d.ts +2 -2
  28. package/dist/declarations/src/actors/observable.d.ts +2 -3
  29. package/dist/declarations/src/actors/promise.d.ts +0 -1
  30. package/dist/declarations/src/actors/transition.d.ts +1 -1
  31. package/dist/declarations/src/guards.d.ts +9 -10
  32. package/dist/declarations/src/interpreter.d.ts +2 -2
  33. package/dist/declarations/src/spawn.d.ts +1 -2
  34. package/dist/declarations/src/stateUtils.d.ts +0 -5
  35. package/dist/declarations/src/types.d.ts +46 -57
  36. package/dist/{interpreter-1c52b23c.development.esm.js → interpreter-4005eb36.development.esm.js} +1 -1
  37. package/dist/{interpreter-97aff8d2.cjs.js → interpreter-b6f22ee2.cjs.js} +1 -1
  38. package/dist/{interpreter-8def682e.esm.js → interpreter-c80ce92e.esm.js} +1 -1
  39. package/dist/{interpreter-e58ca48d.development.cjs.js → interpreter-ed3f81f7.development.cjs.js} +1 -1
  40. package/dist/{raise-e342a840.development.esm.js → raise-42073973.development.esm.js} +68 -79
  41. package/dist/{raise-800296d7.cjs.js → raise-7faa9b3b.cjs.js} +69 -79
  42. package/dist/{raise-1fd59c65.development.cjs.js → raise-b69a3d16.development.cjs.js} +68 -78
  43. package/dist/{raise-21c417c1.esm.js → raise-c989c7fb.esm.js} +69 -80
  44. package/dist/{send-4cc29786.cjs.js → send-34160163.cjs.js} +27 -26
  45. package/dist/{send-92854675.esm.js → send-4b616da9.esm.js} +27 -26
  46. package/dist/{send-b309ef4e.development.cjs.js → send-58725522.development.cjs.js} +27 -26
  47. package/dist/{send-83ccc98b.development.esm.js → send-bff8c910.development.esm.js} +27 -26
  48. package/dist/xstate.cjs.js +9 -6
  49. package/dist/xstate.cjs.mjs +1 -0
  50. package/dist/xstate.development.cjs.js +9 -6
  51. package/dist/xstate.development.cjs.mjs +1 -0
  52. package/dist/xstate.development.esm.js +11 -9
  53. package/dist/xstate.esm.js +11 -9
  54. package/dist/xstate.umd.min.js +1 -1
  55. package/dist/xstate.umd.min.js.map +1 -1
  56. package/guards/dist/xstate-guards.cjs.js +2 -2
  57. package/guards/dist/xstate-guards.development.cjs.js +2 -2
  58. package/guards/dist/xstate-guards.development.esm.js +2 -2
  59. package/guards/dist/xstate-guards.esm.js +2 -2
  60. package/guards/dist/xstate-guards.umd.min.js +1 -1
  61. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  62. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { j as cloneState, e as evaluateGuard } from './raise-21c417c1.esm.js';
2
- import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-8def682e.esm.js';
1
+ import { j as cloneState, e as evaluateGuard } from './raise-c989c7fb.esm.js';
2
+ import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-c80ce92e.esm.js';
3
3
 
4
4
  function createSpawner(actorContext, {
5
5
  machine,
@@ -39,9 +39,7 @@ function createSpawner(actorContext, {
39
39
  });
40
40
  }
41
41
  },
42
- error: () => {
43
- /* TODO */
44
- }
42
+ error: () => {}
45
43
  });
46
44
  }
47
45
  return actorRef;
@@ -65,9 +63,7 @@ function createSpawner(actorContext, {
65
63
  });
66
64
  }
67
65
  },
68
- error: () => {
69
- /* TODO */
70
- }
66
+ error: () => {}
71
67
  });
72
68
  }
73
69
  return actorRef;
@@ -91,7 +87,7 @@ function createSpawner(actorContext, {
91
87
  };
92
88
  }
93
89
 
94
- function resolveAssign(actorContext, state, actionArgs, {
90
+ function resolveAssign(actorContext, state, actionArgs, actionParams, {
95
91
  assignment
96
92
  }) {
97
93
  if (!state.context) {
@@ -101,18 +97,17 @@ function resolveAssign(actorContext, state, actionArgs, {
101
97
  const assignArgs = {
102
98
  context: state.context,
103
99
  event: actionArgs.event,
104
- action: actionArgs.action,
105
100
  spawn: createSpawner(actorContext, state, actionArgs.event, spawnedChildren),
106
101
  self: actorContext?.self,
107
102
  system: actorContext?.system
108
103
  };
109
104
  let partialUpdate = {};
110
105
  if (typeof assignment === 'function') {
111
- partialUpdate = assignment(assignArgs);
106
+ partialUpdate = assignment(assignArgs, actionParams);
112
107
  } else {
113
108
  for (const key of Object.keys(assignment)) {
114
109
  const propAssignment = assignment[key];
115
- partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs) : propAssignment;
110
+ partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
116
111
  }
117
112
  }
118
113
  const updatedContext = Object.assign({}, state.context, partialUpdate);
@@ -130,7 +125,7 @@ function resolveAssign(actorContext, state, actionArgs, {
130
125
  * @param assignment An object that represents the partial context to update.
131
126
  */
132
127
  function assign(assignment) {
133
- function assign(_) {
128
+ function assign(args, params) {
134
129
  }
135
130
  assign.type = 'xstate.assign';
136
131
  assign.assignment = assignment;
@@ -138,7 +133,7 @@ function assign(assignment) {
138
133
  return assign;
139
134
  }
140
135
 
141
- function resolveChoose(_, state, actionArgs, {
136
+ function resolveChoose(_, state, actionArgs, _actionParams, {
142
137
  branches
143
138
  }) {
144
139
  const matchedActions = branches.find(condition => {
@@ -147,7 +142,7 @@ function resolveChoose(_, state, actionArgs, {
147
142
  return [state, undefined, toArray(matchedActions)];
148
143
  }
149
144
  function choose(branches) {
150
- function choose(_) {
145
+ function choose(args, params) {
151
146
  }
152
147
  choose.type = 'xstate.choose';
153
148
  choose.branches = branches;
@@ -155,12 +150,12 @@ function choose(branches) {
155
150
  return choose;
156
151
  }
157
152
 
158
- function resolveLog(_, state, actionArgs, {
153
+ function resolveLog(_, state, actionArgs, actionParams, {
159
154
  value,
160
155
  label
161
156
  }) {
162
157
  return [state, {
163
- value: typeof value === 'function' ? value(actionArgs) : value,
158
+ value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
164
159
  label
165
160
  }];
166
161
  }
@@ -191,7 +186,7 @@ function log(value = ({
191
186
  context,
192
187
  event
193
188
  }), label) {
194
- function log(_) {
189
+ function log(args, params) {
195
190
  }
196
191
  log.type = 'xstate.log';
197
192
  log.value = value;
@@ -201,7 +196,7 @@ function log(value = ({
201
196
  return log;
202
197
  }
203
198
 
204
- function resolvePure(_, state, args, {
199
+ function resolvePure(_, state, args, _actionParams, {
205
200
  get
206
201
  }) {
207
202
  return [state, undefined, toArray(get({
@@ -210,7 +205,7 @@ function resolvePure(_, state, args, {
210
205
  }))];
211
206
  }
212
207
  function pure(getActions) {
213
- function pure(_) {
208
+ function pure(args, params) {
214
209
  }
215
210
  pure.type = 'xstate.pure';
216
211
  pure.get = getActions;
@@ -219,6 +214,9 @@ function pure(getActions) {
219
214
  }
220
215
 
221
216
  /**
217
+ *
218
+ * @remarks
219
+ *
222
220
  * `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
223
221
  * It especially is a problem when the union has a function member, like here:
224
222
  *
@@ -239,7 +237,10 @@ function pure(getActions) {
239
237
  /**
240
238
  * The string or object representing the state value relative to the parent state node.
241
239
  *
240
+ * @remarks
241
+ *
242
242
  * - For a child atomic state node, this is a string, e.g., `"pending"`.
243
+ *
243
244
  * - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
244
245
  */
245
246
 
@@ -253,7 +254,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
253
254
  return SpecialTargets;
254
255
  }({});
255
256
 
256
- function resolveSendTo(actorContext, state, args, {
257
+ function resolveSendTo(actorContext, state, args, actionParams, {
257
258
  to,
258
259
  event: eventOrExpr,
259
260
  id,
@@ -263,15 +264,15 @@ function resolveSendTo(actorContext, state, args, {
263
264
  if (typeof eventOrExpr === 'string') {
264
265
  throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
265
266
  }
266
- const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
267
+ const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
267
268
  let resolvedDelay;
268
269
  if (typeof delay === 'string') {
269
270
  const configDelay = delaysMap && delaysMap[delay];
270
- resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
271
+ resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
271
272
  } else {
272
- resolvedDelay = typeof delay === 'function' ? delay(args) : delay;
273
+ resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
273
274
  }
274
- const resolvedTarget = typeof to === 'function' ? to(args) : to;
275
+ const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
275
276
  let targetActorRef;
276
277
  if (typeof resolvedTarget === 'string') {
277
278
  if (resolvedTarget === SpecialTargets.Parent) {
@@ -329,7 +330,7 @@ function executeSendTo(actorContext, params) {
329
330
  * - `delay` - The number of milliseconds to delay the sending of the event.
330
331
  */
331
332
  function sendTo(to, eventOrExpr, options) {
332
- function sendTo(_) {
333
+ function sendTo(args, params) {
333
334
  }
334
335
  sendTo.type = 'xstate.sendTo';
335
336
  sendTo.to = to;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-1fd59c65.development.cjs.js');
4
- var interpreter = require('./interpreter-e58ca48d.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-b69a3d16.development.cjs.js');
4
+ var interpreter = require('./interpreter-ed3f81f7.development.cjs.js');
5
5
 
6
6
  function createSpawner(actorContext, {
7
7
  machine,
@@ -41,9 +41,7 @@ function createSpawner(actorContext, {
41
41
  });
42
42
  }
43
43
  },
44
- error: () => {
45
- /* TODO */
46
- }
44
+ error: () => {}
47
45
  });
48
46
  }
49
47
  return actorRef;
@@ -67,9 +65,7 @@ function createSpawner(actorContext, {
67
65
  });
68
66
  }
69
67
  },
70
- error: () => {
71
- /* TODO */
72
- }
68
+ error: () => {}
73
69
  });
74
70
  }
75
71
  return actorRef;
@@ -93,7 +89,7 @@ function createSpawner(actorContext, {
93
89
  };
94
90
  }
95
91
 
96
- function resolveAssign(actorContext, state, actionArgs, {
92
+ function resolveAssign(actorContext, state, actionArgs, actionParams, {
97
93
  assignment
98
94
  }) {
99
95
  if (!state.context) {
@@ -103,18 +99,17 @@ function resolveAssign(actorContext, state, actionArgs, {
103
99
  const assignArgs = {
104
100
  context: state.context,
105
101
  event: actionArgs.event,
106
- action: actionArgs.action,
107
102
  spawn: createSpawner(actorContext, state, actionArgs.event, spawnedChildren),
108
103
  self: actorContext?.self,
109
104
  system: actorContext?.system
110
105
  };
111
106
  let partialUpdate = {};
112
107
  if (typeof assignment === 'function') {
113
- partialUpdate = assignment(assignArgs);
108
+ partialUpdate = assignment(assignArgs, actionParams);
114
109
  } else {
115
110
  for (const key of Object.keys(assignment)) {
116
111
  const propAssignment = assignment[key];
117
- partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs) : propAssignment;
112
+ partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
118
113
  }
119
114
  }
120
115
  const updatedContext = Object.assign({}, state.context, partialUpdate);
@@ -132,7 +127,7 @@ function resolveAssign(actorContext, state, actionArgs, {
132
127
  * @param assignment An object that represents the partial context to update.
133
128
  */
134
129
  function assign(assignment) {
135
- function assign(_) {
130
+ function assign(args, params) {
136
131
  {
137
132
  throw new Error(`This isn't supposed to be called`);
138
133
  }
@@ -143,7 +138,7 @@ function assign(assignment) {
143
138
  return assign;
144
139
  }
145
140
 
146
- function resolveChoose(_, state, actionArgs, {
141
+ function resolveChoose(_, state, actionArgs, _actionParams, {
147
142
  branches
148
143
  }) {
149
144
  const matchedActions = branches.find(condition => {
@@ -152,7 +147,7 @@ function resolveChoose(_, state, actionArgs, {
152
147
  return [state, undefined, interpreter.toArray(matchedActions)];
153
148
  }
154
149
  function choose(branches) {
155
- function choose(_) {
150
+ function choose(args, params) {
156
151
  {
157
152
  throw new Error(`This isn't supposed to be called`);
158
153
  }
@@ -163,12 +158,12 @@ function choose(branches) {
163
158
  return choose;
164
159
  }
165
160
 
166
- function resolveLog(_, state, actionArgs, {
161
+ function resolveLog(_, state, actionArgs, actionParams, {
167
162
  value,
168
163
  label
169
164
  }) {
170
165
  return [state, {
171
- value: typeof value === 'function' ? value(actionArgs) : value,
166
+ value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
172
167
  label
173
168
  }];
174
169
  }
@@ -199,7 +194,7 @@ function log(value = ({
199
194
  context,
200
195
  event
201
196
  }), label) {
202
- function log(_) {
197
+ function log(args, params) {
203
198
  {
204
199
  throw new Error(`This isn't supposed to be called`);
205
200
  }
@@ -212,7 +207,7 @@ function log(value = ({
212
207
  return log;
213
208
  }
214
209
 
215
- function resolvePure(_, state, args, {
210
+ function resolvePure(_, state, args, _actionParams, {
216
211
  get
217
212
  }) {
218
213
  return [state, undefined, interpreter.toArray(get({
@@ -221,7 +216,7 @@ function resolvePure(_, state, args, {
221
216
  }))];
222
217
  }
223
218
  function pure(getActions) {
224
- function pure(_) {
219
+ function pure(args, params) {
225
220
  {
226
221
  throw new Error(`This isn't supposed to be called`);
227
222
  }
@@ -233,6 +228,9 @@ function pure(getActions) {
233
228
  }
234
229
 
235
230
  /**
231
+ *
232
+ * @remarks
233
+ *
236
234
  * `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
237
235
  * It especially is a problem when the union has a function member, like here:
238
236
  *
@@ -253,7 +251,10 @@ function pure(getActions) {
253
251
  /**
254
252
  * The string or object representing the state value relative to the parent state node.
255
253
  *
254
+ * @remarks
255
+ *
256
256
  * - For a child atomic state node, this is a string, e.g., `"pending"`.
257
+ *
257
258
  * - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
258
259
  */
259
260
 
@@ -267,7 +268,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
267
268
  return SpecialTargets;
268
269
  }({});
269
270
 
270
- function resolveSendTo(actorContext, state, args, {
271
+ function resolveSendTo(actorContext, state, args, actionParams, {
271
272
  to,
272
273
  event: eventOrExpr,
273
274
  id,
@@ -277,15 +278,15 @@ function resolveSendTo(actorContext, state, args, {
277
278
  if (typeof eventOrExpr === 'string') {
278
279
  throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
279
280
  }
280
- const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
281
+ const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
281
282
  let resolvedDelay;
282
283
  if (typeof delay === 'string') {
283
284
  const configDelay = delaysMap && delaysMap[delay];
284
- resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
285
+ resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
285
286
  } else {
286
- resolvedDelay = typeof delay === 'function' ? delay(args) : delay;
287
+ resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
287
288
  }
288
- const resolvedTarget = typeof to === 'function' ? to(args) : to;
289
+ const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
289
290
  let targetActorRef;
290
291
  if (typeof resolvedTarget === 'string') {
291
292
  if (resolvedTarget === SpecialTargets.Parent) {
@@ -343,7 +344,7 @@ function executeSendTo(actorContext, params) {
343
344
  * - `delay` - The number of milliseconds to delay the sending of the event.
344
345
  */
345
346
  function sendTo(to, eventOrExpr, options) {
346
- function sendTo(_) {
347
+ function sendTo(args, params) {
347
348
  {
348
349
  throw new Error(`This isn't supposed to be called`);
349
350
  }
@@ -1,5 +1,5 @@
1
- import { j as cloneState, e as evaluateGuard } from './raise-e342a840.development.esm.js';
2
- import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-1c52b23c.development.esm.js';
1
+ import { j as cloneState, e as evaluateGuard } from './raise-42073973.development.esm.js';
2
+ import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-4005eb36.development.esm.js';
3
3
 
4
4
  function createSpawner(actorContext, {
5
5
  machine,
@@ -39,9 +39,7 @@ function createSpawner(actorContext, {
39
39
  });
40
40
  }
41
41
  },
42
- error: () => {
43
- /* TODO */
44
- }
42
+ error: () => {}
45
43
  });
46
44
  }
47
45
  return actorRef;
@@ -65,9 +63,7 @@ function createSpawner(actorContext, {
65
63
  });
66
64
  }
67
65
  },
68
- error: () => {
69
- /* TODO */
70
- }
66
+ error: () => {}
71
67
  });
72
68
  }
73
69
  return actorRef;
@@ -91,7 +87,7 @@ function createSpawner(actorContext, {
91
87
  };
92
88
  }
93
89
 
94
- function resolveAssign(actorContext, state, actionArgs, {
90
+ function resolveAssign(actorContext, state, actionArgs, actionParams, {
95
91
  assignment
96
92
  }) {
97
93
  if (!state.context) {
@@ -101,18 +97,17 @@ function resolveAssign(actorContext, state, actionArgs, {
101
97
  const assignArgs = {
102
98
  context: state.context,
103
99
  event: actionArgs.event,
104
- action: actionArgs.action,
105
100
  spawn: createSpawner(actorContext, state, actionArgs.event, spawnedChildren),
106
101
  self: actorContext?.self,
107
102
  system: actorContext?.system
108
103
  };
109
104
  let partialUpdate = {};
110
105
  if (typeof assignment === 'function') {
111
- partialUpdate = assignment(assignArgs);
106
+ partialUpdate = assignment(assignArgs, actionParams);
112
107
  } else {
113
108
  for (const key of Object.keys(assignment)) {
114
109
  const propAssignment = assignment[key];
115
- partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs) : propAssignment;
110
+ partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
116
111
  }
117
112
  }
118
113
  const updatedContext = Object.assign({}, state.context, partialUpdate);
@@ -130,7 +125,7 @@ function resolveAssign(actorContext, state, actionArgs, {
130
125
  * @param assignment An object that represents the partial context to update.
131
126
  */
132
127
  function assign(assignment) {
133
- function assign(_) {
128
+ function assign(args, params) {
134
129
  {
135
130
  throw new Error(`This isn't supposed to be called`);
136
131
  }
@@ -141,7 +136,7 @@ function assign(assignment) {
141
136
  return assign;
142
137
  }
143
138
 
144
- function resolveChoose(_, state, actionArgs, {
139
+ function resolveChoose(_, state, actionArgs, _actionParams, {
145
140
  branches
146
141
  }) {
147
142
  const matchedActions = branches.find(condition => {
@@ -150,7 +145,7 @@ function resolveChoose(_, state, actionArgs, {
150
145
  return [state, undefined, toArray(matchedActions)];
151
146
  }
152
147
  function choose(branches) {
153
- function choose(_) {
148
+ function choose(args, params) {
154
149
  {
155
150
  throw new Error(`This isn't supposed to be called`);
156
151
  }
@@ -161,12 +156,12 @@ function choose(branches) {
161
156
  return choose;
162
157
  }
163
158
 
164
- function resolveLog(_, state, actionArgs, {
159
+ function resolveLog(_, state, actionArgs, actionParams, {
165
160
  value,
166
161
  label
167
162
  }) {
168
163
  return [state, {
169
- value: typeof value === 'function' ? value(actionArgs) : value,
164
+ value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
170
165
  label
171
166
  }];
172
167
  }
@@ -197,7 +192,7 @@ function log(value = ({
197
192
  context,
198
193
  event
199
194
  }), label) {
200
- function log(_) {
195
+ function log(args, params) {
201
196
  {
202
197
  throw new Error(`This isn't supposed to be called`);
203
198
  }
@@ -210,7 +205,7 @@ function log(value = ({
210
205
  return log;
211
206
  }
212
207
 
213
- function resolvePure(_, state, args, {
208
+ function resolvePure(_, state, args, _actionParams, {
214
209
  get
215
210
  }) {
216
211
  return [state, undefined, toArray(get({
@@ -219,7 +214,7 @@ function resolvePure(_, state, args, {
219
214
  }))];
220
215
  }
221
216
  function pure(getActions) {
222
- function pure(_) {
217
+ function pure(args, params) {
223
218
  {
224
219
  throw new Error(`This isn't supposed to be called`);
225
220
  }
@@ -231,6 +226,9 @@ function pure(getActions) {
231
226
  }
232
227
 
233
228
  /**
229
+ *
230
+ * @remarks
231
+ *
234
232
  * `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
235
233
  * It especially is a problem when the union has a function member, like here:
236
234
  *
@@ -251,7 +249,10 @@ function pure(getActions) {
251
249
  /**
252
250
  * The string or object representing the state value relative to the parent state node.
253
251
  *
252
+ * @remarks
253
+ *
254
254
  * - For a child atomic state node, this is a string, e.g., `"pending"`.
255
+ *
255
256
  * - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
256
257
  */
257
258
 
@@ -265,7 +266,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
265
266
  return SpecialTargets;
266
267
  }({});
267
268
 
268
- function resolveSendTo(actorContext, state, args, {
269
+ function resolveSendTo(actorContext, state, args, actionParams, {
269
270
  to,
270
271
  event: eventOrExpr,
271
272
  id,
@@ -275,15 +276,15 @@ function resolveSendTo(actorContext, state, args, {
275
276
  if (typeof eventOrExpr === 'string') {
276
277
  throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
277
278
  }
278
- const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
279
+ const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
279
280
  let resolvedDelay;
280
281
  if (typeof delay === 'string') {
281
282
  const configDelay = delaysMap && delaysMap[delay];
282
- resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
283
+ resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
283
284
  } else {
284
- resolvedDelay = typeof delay === 'function' ? delay(args) : delay;
285
+ resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
285
286
  }
286
- const resolvedTarget = typeof to === 'function' ? to(args) : to;
287
+ const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
287
288
  let targetActorRef;
288
289
  if (typeof resolvedTarget === 'string') {
289
290
  if (resolvedTarget === SpecialTargets.Parent) {
@@ -341,7 +342,7 @@ function executeSendTo(actorContext, params) {
341
342
  * - `delay` - The number of milliseconds to delay the sending of the event.
342
343
  */
343
344
  function sendTo(to, eventOrExpr, options) {
344
- function sendTo(_) {
345
+ function sendTo(args, params) {
345
346
  {
346
347
  throw new Error(`This isn't supposed to be called`);
347
348
  }
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
6
- var interpreter = require('./interpreter-97aff8d2.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-800296d7.cjs.js');
8
- var send = require('./send-4cc29786.cjs.js');
6
+ var interpreter = require('./interpreter-b6f22ee2.cjs.js');
7
+ var guards_dist_xstateGuards = require('./raise-7faa9b3b.cjs.js');
8
+ var send = require('./send-34160163.cjs.js');
9
9
  require('../dev/dist/xstate-dev.cjs.js');
10
10
 
11
11
  class SimulatedClock {
@@ -587,8 +587,9 @@ class StateMachine {
587
587
  }
588
588
  restoreState(snapshot, _actorCtx) {
589
589
  const children = {};
590
- Object.keys(snapshot.children).forEach(actorId => {
591
- const actorData = snapshot.children[actorId];
590
+ const snapshotChildren = snapshot.children;
591
+ Object.keys(snapshotChildren).forEach(actorId => {
592
+ const actorData = snapshotChildren[actorId];
592
593
  const childState = actorData.state;
593
594
  const src = actorData.src;
594
595
  const logic = src ? interpreter.resolveReferencedActor(this, src)?.src : undefined;
@@ -599,7 +600,8 @@ class StateMachine {
599
600
  const actorRef = interpreter.createActor(logic, {
600
601
  id: actorId,
601
602
  parent: _actorCtx?.self,
602
- state: actorState
603
+ state: actorState,
604
+ systemId: actorData.systemId
603
605
  });
604
606
  children[actorId] = actorRef;
605
607
  });
@@ -737,6 +739,7 @@ exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
737
739
  exports.not = guards_dist_xstateGuards.not;
738
740
  exports.or = guards_dist_xstateGuards.or;
739
741
  exports.raise = guards_dist_xstateGuards.raise;
742
+ exports.spawn = guards_dist_xstateGuards.spawn;
740
743
  exports.stateIn = guards_dist_xstateGuards.stateIn;
741
744
  exports.stop = guards_dist_xstateGuards.stop;
742
745
  exports.SpecialTargets = send.SpecialTargets;
@@ -33,6 +33,7 @@ export {
33
33
  raise,
34
34
  sendParent,
35
35
  sendTo,
36
+ spawn,
36
37
  stateIn,
37
38
  stop,
38
39
  toObserver,
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var actors_dist_xstateActors = require('../actors/dist/xstate-actors.development.cjs.js');
6
- var interpreter = require('./interpreter-e58ca48d.development.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-1fd59c65.development.cjs.js');
8
- var send = require('./send-b309ef4e.development.cjs.js');
6
+ var interpreter = require('./interpreter-ed3f81f7.development.cjs.js');
7
+ var guards_dist_xstateGuards = require('./raise-b69a3d16.development.cjs.js');
8
+ var send = require('./send-58725522.development.cjs.js');
9
9
  require('../dev/dist/xstate-dev.development.cjs.js');
10
10
 
11
11
  class SimulatedClock {
@@ -590,8 +590,9 @@ class StateMachine {
590
590
  }
591
591
  restoreState(snapshot, _actorCtx) {
592
592
  const children = {};
593
- Object.keys(snapshot.children).forEach(actorId => {
594
- const actorData = snapshot.children[actorId];
593
+ const snapshotChildren = snapshot.children;
594
+ Object.keys(snapshotChildren).forEach(actorId => {
595
+ const actorData = snapshotChildren[actorId];
595
596
  const childState = actorData.state;
596
597
  const src = actorData.src;
597
598
  const logic = src ? interpreter.resolveReferencedActor(this, src)?.src : undefined;
@@ -602,7 +603,8 @@ class StateMachine {
602
603
  const actorRef = interpreter.createActor(logic, {
603
604
  id: actorId,
604
605
  parent: _actorCtx?.self,
605
- state: actorState
606
+ state: actorState,
607
+ systemId: actorData.systemId
606
608
  });
607
609
  children[actorId] = actorRef;
608
610
  });
@@ -743,6 +745,7 @@ exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
743
745
  exports.not = guards_dist_xstateGuards.not;
744
746
  exports.or = guards_dist_xstateGuards.or;
745
747
  exports.raise = guards_dist_xstateGuards.raise;
748
+ exports.spawn = guards_dist_xstateGuards.spawn;
746
749
  exports.stateIn = guards_dist_xstateGuards.stateIn;
747
750
  exports.stop = guards_dist_xstateGuards.stop;
748
751
  exports.SpecialTargets = send.SpecialTargets;
@@ -33,6 +33,7 @@ export {
33
33
  raise,
34
34
  sendParent,
35
35
  sendTo,
36
+ spawn,
36
37
  stateIn,
37
38
  stop,
38
39
  toObserver,