xstate 5.0.0-beta.52 → 5.0.0-beta.54

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 (46) hide show
  1. package/actions/dist/xstate-actions.cjs.js +2 -3
  2. package/actions/dist/xstate-actions.cjs.mjs +0 -1
  3. package/actions/dist/xstate-actions.development.cjs.js +2 -3
  4. package/actions/dist/xstate-actions.development.cjs.mjs +0 -1
  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.js +17 -17
  10. package/actors/dist/xstate-actors.development.cjs.js +17 -17
  11. package/actors/dist/xstate-actors.development.esm.js +17 -17
  12. package/actors/dist/xstate-actors.esm.js +17 -17
  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/StateNode.d.ts +1 -1
  18. package/dist/declarations/src/actions/send.d.ts +1 -9
  19. package/dist/declarations/src/actions.d.ts +1 -1
  20. package/dist/declarations/src/actors/transition.d.ts +1 -1
  21. package/dist/declarations/src/guards.d.ts +1 -1
  22. package/dist/declarations/src/interpreter.d.ts +5 -5
  23. package/dist/declarations/src/stateUtils.d.ts +9 -9
  24. package/dist/declarations/src/types.d.ts +15 -11
  25. package/dist/{log-d160285c.development.cjs.js → log-516ee274.development.cjs.js} +23 -40
  26. package/dist/{log-3d815f5e.cjs.js → log-5b24d580.cjs.js} +23 -40
  27. package/dist/{log-826c9895.development.esm.js → log-5ebdc815.development.esm.js} +24 -40
  28. package/dist/{log-6bc0e1e7.esm.js → log-ee8cb6d6.esm.js} +24 -40
  29. package/dist/{raise-9dd3e757.development.cjs.js → raise-57f3c654.development.cjs.js} +130 -130
  30. package/dist/{raise-367eeb6f.cjs.js → raise-5f22d333.cjs.js} +130 -130
  31. package/dist/{raise-f71460d6.esm.js → raise-6f820d79.esm.js} +130 -130
  32. package/dist/{raise-1caefe80.development.esm.js → raise-a6c478f8.development.esm.js} +130 -130
  33. package/dist/xstate.cjs.js +17 -18
  34. package/dist/xstate.cjs.mjs +0 -1
  35. package/dist/xstate.development.cjs.js +17 -18
  36. package/dist/xstate.development.cjs.mjs +0 -1
  37. package/dist/xstate.development.esm.js +19 -19
  38. package/dist/xstate.esm.js +19 -19
  39. package/dist/xstate.umd.min.js +1 -1
  40. package/dist/xstate.umd.min.js.map +1 -1
  41. package/guards/dist/xstate-guards.cjs.js +1 -1
  42. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  43. package/guards/dist/xstate-guards.development.esm.js +1 -1
  44. package/guards/dist/xstate-guards.esm.js +1 -1
  45. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  46. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-f71460d6.esm.js';
1
+ import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-6f820d79.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -53,17 +53,17 @@ function createSpawner(actorScope, {
53
53
  };
54
54
  }
55
55
 
56
- function resolveAssign(actorScope, state, actionArgs, actionParams, {
56
+ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
57
57
  assignment
58
58
  }) {
59
- if (!state.context) {
59
+ if (!snapshot.context) {
60
60
  throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
61
61
  }
62
62
  const spawnedChildren = {};
63
63
  const assignArgs = {
64
- context: state.context,
64
+ context: snapshot.context,
65
65
  event: actionArgs.event,
66
- spawn: createSpawner(actorScope, state, actionArgs.event, spawnedChildren),
66
+ spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
67
67
  self: actorScope?.self,
68
68
  system: actorScope?.system
69
69
  };
@@ -76,13 +76,13 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
76
76
  partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
77
77
  }
78
78
  }
79
- const updatedContext = Object.assign({}, state.context, partialUpdate);
80
- return [cloneMachineSnapshot(state, {
79
+ const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
80
+ return [cloneMachineSnapshot(snapshot, {
81
81
  context: updatedContext,
82
82
  children: Object.keys(spawnedChildren).length ? {
83
- ...state.children,
83
+ ...snapshot.children,
84
84
  ...spawnedChildren
85
- } : state.children
85
+ } : snapshot.children
86
86
  })];
87
87
  }
88
88
  /**
@@ -163,13 +163,13 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
163
163
  * @template TSystem - The type of the actor system.
164
164
  */
165
165
 
166
- function resolveSendTo(actorScope, state, args, actionParams, {
166
+ function resolveSendTo(actorScope, snapshot, args, actionParams, {
167
167
  to,
168
168
  event: eventOrExpr,
169
169
  id,
170
170
  delay
171
171
  }, extra) {
172
- const delaysMap = state.machine.implementations.delays;
172
+ const delaysMap = snapshot.machine.implementations.delays;
173
173
  if (typeof eventOrExpr === 'string') {
174
174
  throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
175
175
  }
@@ -191,26 +191,26 @@ function resolveSendTo(actorScope, state, args, actionParams, {
191
191
  } else if (resolvedTarget.startsWith('#_')) {
192
192
  // SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
193
193
  // #_invokeid. If the target is the special term '#_invokeid', where invokeid is the invokeid of an SCXML session that the sending session has created by <invoke>, the Processor must add the event to the external queue of that session.
194
- targetActorRef = state.children[resolvedTarget.slice(2)];
194
+ targetActorRef = snapshot.children[resolvedTarget.slice(2)];
195
195
  } else {
196
- targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget : state.children[resolvedTarget];
196
+ targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget : snapshot.children[resolvedTarget];
197
197
  }
198
198
  if (!targetActorRef) {
199
- throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${state.machine.id}'.`);
199
+ throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${snapshot.machine.id}'.`);
200
200
  }
201
201
  } else {
202
202
  targetActorRef = resolvedTarget || actorScope?.self;
203
203
  }
204
- return [state, {
204
+ return [snapshot, {
205
205
  to: targetActorRef,
206
206
  event: resolvedEvent,
207
207
  id,
208
208
  delay: resolvedDelay
209
209
  }];
210
210
  }
211
- function retryResolveSendTo(_, state, params) {
211
+ function retryResolveSendTo(_, snapshot, params) {
212
212
  if (typeof params.to === 'string') {
213
- params.to = state.children[params.to];
213
+ params.to = snapshot.children[params.to];
214
214
  }
215
215
  }
216
216
  function executeSendTo(actorScope, params) {
@@ -241,7 +241,7 @@ function executeSendTo(actorScope, params) {
241
241
  function sendTo(to, eventOrExpr, options) {
242
242
  function sendTo(args, params) {
243
243
  }
244
- sendTo.type = 'xstate.sendTo';
244
+ sendTo.type = 'xsnapshot.sendTo';
245
245
  sendTo.to = to;
246
246
  sendTo.event = eventOrExpr;
247
247
  sendTo.id = options?.id;
@@ -273,23 +273,7 @@ function forwardTo(target, options) {
273
273
  }) => event, options);
274
274
  }
275
275
 
276
- /**
277
- * Escalates an error by sending it as an event to this machine's parent.
278
- *
279
- * @param errorData The error data to send, or the expression function that
280
- * takes in the `context`, `event`, and `meta`, and returns the error data to send.
281
- * @param options Options to pass into the send action creator.
282
- */
283
- function escalate(errorData, options) {
284
- return sendParent(arg => {
285
- return {
286
- type: XSTATE_ERROR,
287
- data: typeof errorData === 'function' ? errorData(arg) : errorData
288
- };
289
- }, options);
290
- }
291
-
292
- function resolveEnqueueActions(_, state, args, _actionParams, {
276
+ function resolveEnqueueActions(_, snapshot, args, _actionParams, {
293
277
  collect
294
278
  }) {
295
279
  const actions = [];
@@ -318,9 +302,9 @@ function resolveEnqueueActions(_, state, args, _actionParams, {
318
302
  context: args.context,
319
303
  event: args.event,
320
304
  enqueue,
321
- check: guard => evaluateGuard(guard, state.context, args.event, state)
305
+ check: guard => evaluateGuard(guard, snapshot.context, args.event, snapshot)
322
306
  });
323
- return [state, undefined, actions];
307
+ return [snapshot, undefined, actions];
324
308
  }
325
309
  function enqueueActions(collect) {
326
310
  function enqueueActions(args, params) {
@@ -331,11 +315,11 @@ function enqueueActions(collect) {
331
315
  return enqueueActions;
332
316
  }
333
317
 
334
- function resolveLog(_, state, actionArgs, actionParams, {
318
+ function resolveLog(_, snapshot, actionArgs, actionParams, {
335
319
  value,
336
320
  label
337
321
  }) {
338
- return [state, {
322
+ return [snapshot, {
339
323
  value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
340
324
  label
341
325
  }];
@@ -377,4 +361,4 @@ function log(value = ({
377
361
  return log;
378
362
  }
379
363
 
380
- export { SpecialTargets as S, assign as a, escalate as b, sendTo as c, enqueueActions as e, forwardTo as f, log as l, sendParent as s };
364
+ export { SpecialTargets as S, assign as a, sendTo as b, enqueueActions as e, forwardTo as f, log as l, sendParent as s };