xstate 5.0.0-beta.50 → 5.0.0-beta.52

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 (45) hide show
  1. package/actions/dist/xstate-actions.cjs.js +9 -10
  2. package/actions/dist/xstate-actions.cjs.mjs +1 -2
  3. package/actions/dist/xstate-actions.development.cjs.js +9 -10
  4. package/actions/dist/xstate-actions.development.cjs.mjs +1 -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.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.map +1 -1
  14. package/dist/declarations/src/StateMachine.d.ts +2 -2
  15. package/dist/declarations/src/StateNode.d.ts +3 -3
  16. package/dist/declarations/src/actions/enqueueActions.d.ts +32 -0
  17. package/dist/declarations/src/actions.d.ts +2 -3
  18. package/dist/declarations/src/actors/index.d.ts +1 -1
  19. package/dist/declarations/src/interpreter.d.ts +2 -2
  20. package/dist/declarations/src/types.d.ts +9 -9
  21. package/dist/declarations/src/utils.d.ts +1 -20
  22. package/dist/{send-7f3db830.cjs.js → log-3d815f5e.cjs.js} +90 -83
  23. package/dist/{send-88351a33.esm.js → log-6bc0e1e7.esm.js} +90 -82
  24. package/dist/{send-2b001f05.development.esm.js → log-826c9895.development.esm.js} +96 -91
  25. package/dist/{send-df1c8ef2.development.cjs.js → log-d160285c.development.cjs.js} +96 -92
  26. package/dist/{raise-6c05c91b.development.esm.js → raise-1caefe80.development.esm.js} +16 -21
  27. package/dist/{raise-8176cd35.cjs.js → raise-367eeb6f.cjs.js} +15 -20
  28. package/dist/{raise-dc9c2c58.development.cjs.js → raise-9dd3e757.development.cjs.js} +15 -20
  29. package/dist/{raise-32ec7226.esm.js → raise-f71460d6.esm.js} +16 -21
  30. package/dist/xstate.cjs.js +13 -14
  31. package/dist/xstate.cjs.mjs +1 -2
  32. package/dist/xstate.development.cjs.js +13 -14
  33. package/dist/xstate.development.cjs.mjs +1 -2
  34. package/dist/xstate.development.esm.js +6 -6
  35. package/dist/xstate.esm.js +6 -6
  36. package/dist/xstate.umd.min.js +1 -1
  37. package/dist/xstate.umd.min.js.map +1 -1
  38. package/guards/dist/xstate-guards.cjs.js +1 -1
  39. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  40. package/guards/dist/xstate-guards.development.esm.js +1 -1
  41. package/guards/dist/xstate-guards.esm.js +1 -1
  42. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  43. package/package.json +1 -1
  44. package/dist/declarations/src/actions/choose.d.ts +0 -9
  45. package/dist/declarations/src/actions/pure.d.ts +0 -13
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-dc9c2c58.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-9dd3e757.development.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -104,95 +104,6 @@ function assign(assignment) {
104
104
  return assign;
105
105
  }
106
106
 
107
- function resolveChoose(_, state, actionArgs, _actionParams, {
108
- branches
109
- }) {
110
- const matchedActions = branches.find(condition => {
111
- return !condition.guard || guards_dist_xstateGuards.evaluateGuard(condition.guard, state.context, actionArgs.event, state);
112
- })?.actions;
113
- return [state, undefined, guards_dist_xstateGuards.toArray(matchedActions)];
114
- }
115
- function choose(branches) {
116
- function choose(args, params) {
117
- {
118
- throw new Error(`This isn't supposed to be called`);
119
- }
120
- }
121
- choose.type = 'xstate.choose';
122
- choose.branches = branches;
123
- choose.resolve = resolveChoose;
124
- return choose;
125
- }
126
-
127
- function resolveLog(_, state, actionArgs, actionParams, {
128
- value,
129
- label
130
- }) {
131
- return [state, {
132
- value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
133
- label
134
- }];
135
- }
136
- function executeLog({
137
- logger
138
- }, {
139
- value,
140
- label
141
- }) {
142
- if (label) {
143
- logger(label, value);
144
- } else {
145
- logger(value);
146
- }
147
- }
148
- /**
149
- *
150
- * @param expr The expression function to evaluate which will be logged.
151
- * Takes in 2 arguments:
152
- * - `ctx` - the current state context
153
- * - `event` - the event that caused this action to be executed.
154
- * @param label The label to give to the logged expression.
155
- */
156
- function log(value = ({
157
- context,
158
- event
159
- }) => ({
160
- context,
161
- event
162
- }), label) {
163
- function log(args, params) {
164
- {
165
- throw new Error(`This isn't supposed to be called`);
166
- }
167
- }
168
- log.type = 'xstate.log';
169
- log.value = value;
170
- log.label = label;
171
- log.resolve = resolveLog;
172
- log.execute = executeLog;
173
- return log;
174
- }
175
-
176
- function resolvePure(_, state, args, _actionParams, {
177
- get
178
- }) {
179
- return [state, undefined, guards_dist_xstateGuards.toArray(get({
180
- context: args.context,
181
- event: args.event
182
- }))];
183
- }
184
- function pure(getActions) {
185
- function pure(args, params) {
186
- {
187
- throw new Error(`This isn't supposed to be called`);
188
- }
189
- }
190
- pure.type = 'xstate.pure';
191
- pure.get = getActions;
192
- pure.resolve = resolvePure;
193
- return pure;
194
- }
195
-
196
107
  /**
197
108
  *
198
109
  * @remarks
@@ -396,12 +307,105 @@ function escalate(errorData, options) {
396
307
  }, options);
397
308
  }
398
309
 
310
+ function resolveEnqueueActions(_, state, args, _actionParams, {
311
+ collect
312
+ }) {
313
+ const actions = [];
314
+ const enqueue = function enqueue(action) {
315
+ actions.push(action);
316
+ };
317
+ enqueue.assign = (...args) => {
318
+ actions.push(assign(...args));
319
+ };
320
+ enqueue.cancel = (...args) => {
321
+ actions.push(guards_dist_xstateGuards.cancel(...args));
322
+ };
323
+ enqueue.raise = (...args) => {
324
+ actions.push(guards_dist_xstateGuards.raise(...args));
325
+ };
326
+ enqueue.sendTo = (...args) => {
327
+ actions.push(sendTo(...args));
328
+ };
329
+ enqueue.spawnChild = (...args) => {
330
+ actions.push(guards_dist_xstateGuards.spawnChild(...args));
331
+ };
332
+ enqueue.stopChild = (...args) => {
333
+ actions.push(guards_dist_xstateGuards.stopChild(...args));
334
+ };
335
+ collect({
336
+ context: args.context,
337
+ event: args.event,
338
+ enqueue,
339
+ check: guard => guards_dist_xstateGuards.evaluateGuard(guard, state.context, args.event, state)
340
+ });
341
+ return [state, undefined, actions];
342
+ }
343
+ function enqueueActions(collect) {
344
+ function enqueueActions(args, params) {
345
+ {
346
+ throw new Error(`This isn't supposed to be called`);
347
+ }
348
+ }
349
+ enqueueActions.type = 'xstate.enqueueActions';
350
+ enqueueActions.collect = collect;
351
+ enqueueActions.resolve = resolveEnqueueActions;
352
+ return enqueueActions;
353
+ }
354
+
355
+ function resolveLog(_, state, actionArgs, actionParams, {
356
+ value,
357
+ label
358
+ }) {
359
+ return [state, {
360
+ value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
361
+ label
362
+ }];
363
+ }
364
+ function executeLog({
365
+ logger
366
+ }, {
367
+ value,
368
+ label
369
+ }) {
370
+ if (label) {
371
+ logger(label, value);
372
+ } else {
373
+ logger(value);
374
+ }
375
+ }
376
+ /**
377
+ *
378
+ * @param expr The expression function to evaluate which will be logged.
379
+ * Takes in 2 arguments:
380
+ * - `ctx` - the current state context
381
+ * - `event` - the event that caused this action to be executed.
382
+ * @param label The label to give to the logged expression.
383
+ */
384
+ function log(value = ({
385
+ context,
386
+ event
387
+ }) => ({
388
+ context,
389
+ event
390
+ }), label) {
391
+ function log(args, params) {
392
+ {
393
+ throw new Error(`This isn't supposed to be called`);
394
+ }
395
+ }
396
+ log.type = 'xstate.log';
397
+ log.value = value;
398
+ log.label = label;
399
+ log.resolve = resolveLog;
400
+ log.execute = executeLog;
401
+ return log;
402
+ }
403
+
399
404
  exports.SpecialTargets = SpecialTargets;
400
405
  exports.assign = assign;
401
- exports.choose = choose;
406
+ exports.enqueueActions = enqueueActions;
402
407
  exports.escalate = escalate;
403
408
  exports.forwardTo = forwardTo;
404
409
  exports.log = log;
405
- exports.pure = pure;
406
410
  exports.sendParent = sendParent;
407
411
  exports.sendTo = sendTo;
@@ -64,9 +64,8 @@ const XSTATE_STOP = 'xstate.stop';
64
64
  * @param id The state node ID where this event is handled
65
65
  */
66
66
  function createAfterEvent(delayRef, id) {
67
- const idSuffix = id ? `#${id}` : '';
68
67
  return {
69
- type: `xstate.after(${delayRef})${idSuffix}`
68
+ type: `xstate.after.${delayRef}.${id}`
70
69
  };
71
70
  }
72
71
 
@@ -203,14 +202,10 @@ function matchesState(parentStateId, childStateId) {
203
202
  });
204
203
  }
205
204
  function toStatePath(stateId) {
206
- try {
207
- if (isArray(stateId)) {
208
- return stateId;
209
- }
210
- return stateId.split(STATE_DELIMITER);
211
- } catch (e) {
212
- throw new Error(`'${stateId}' is not a valid state path.`);
205
+ if (isArray(stateId)) {
206
+ return stateId;
213
207
  }
208
+ return stateId.split(STATE_DELIMITER);
214
209
  }
215
210
  function toStateValue(stateValue) {
216
211
  if (isMachineSnapshot(stateValue)) {
@@ -305,16 +300,17 @@ function toObserver(nextHandler, errorHandler, completionHandler) {
305
300
  };
306
301
  }
307
302
  function createInvokeId(stateNodeId, index) {
308
- return `${stateNodeId}[${index}]`;
303
+ return `${index}.${stateNodeId}`;
309
304
  }
310
305
  function resolveReferencedActor(machine, src) {
311
- if (src.startsWith('xstate#')) {
312
- const [, indexStr] = src.match(/\[(\d+)\]$/);
313
- const node = machine.getStateNodeById(src.slice(7, -(indexStr.length + 2)));
314
- const invokeConfig = node.config.invoke;
315
- return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
306
+ const match = src.match(/^xstate\.invoke\.(\d+)\.(.*)/);
307
+ if (!match) {
308
+ return machine.implementations.actors[src];
316
309
  }
317
- return machine.implementations.actors[src];
310
+ const [, indexStr, nodeId] = match;
311
+ const node = machine.getStateNodeById(nodeId);
312
+ const invokeConfig = node.config.invoke;
313
+ return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
318
314
  }
319
315
  function getAllOwnEventDescriptors(snapshot) {
320
316
  return [...new Set([...snapshot._nodes.flatMap(sn => sn.ownEvents)])];
@@ -1369,8 +1365,7 @@ function getDelayedTransitions(stateNode) {
1369
1365
  return [];
1370
1366
  }
1371
1367
  const mutateEntryExit = (delay, i) => {
1372
- const delayRef = typeof delay === 'function' ? `${stateNode.id}:delay[${i}]` : delay;
1373
- const afterEvent = createAfterEvent(delayRef, stateNode.id);
1368
+ const afterEvent = createAfterEvent(delay, stateNode.id);
1374
1369
  const eventType = afterEvent.type;
1375
1370
  stateNode.entry.push(raise(afterEvent, {
1376
1371
  id: eventType,
@@ -1384,8 +1379,8 @@ function getDelayedTransitions(stateNode) {
1384
1379
  const resolvedTransition = typeof configTransition === 'string' ? {
1385
1380
  target: configTransition
1386
1381
  } : configTransition;
1387
- const resolvedDelay = !isNaN(+delay) ? +delay : delay;
1388
- const eventType = mutateEntryExit(resolvedDelay, i);
1382
+ const resolvedDelay = Number.isNaN(+delay) ? delay : +delay;
1383
+ const eventType = mutateEntryExit(resolvedDelay);
1389
1384
  return toArray(resolvedTransition).map(transition => ({
1390
1385
  ...transition,
1391
1386
  event: eventType,
@@ -2373,4 +2368,4 @@ function raise(eventOrExpr, options) {
2373
2368
  return raise;
2374
2369
  }
2375
2370
 
2376
- export { $$ACTOR_TYPE as $, Actor as A, interpret as B, isMachineSnapshot as C, matchesState as D, pathToStateValue as E, toObserver as F, getAllOwnEventDescriptors as G, and as H, not as I, or as J, stateIn as K, cancel as L, raise as M, NULL_EVENT as N, stop as O, stopChild as P, spawnChild as Q, ProcessingStatus as R, STATE_DELIMITER as S, cloneMachineSnapshot as T, XSTATE_ERROR as U, createErrorActorEvent as V, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, isStateId as v, getStateNodeByPath as w, getPersistedState as x, resolveReferencedActor as y, createActor as z };
2371
+ export { $$ACTOR_TYPE as $, Actor as A, interpret as B, isMachineSnapshot as C, matchesState as D, pathToStateValue as E, toObserver as F, getAllOwnEventDescriptors as G, and as H, not as I, or as J, stateIn as K, cancel as L, raise as M, NULL_EVENT as N, spawnChild as O, stop as P, stopChild as Q, ProcessingStatus as R, STATE_DELIMITER as S, cloneMachineSnapshot as T, XSTATE_ERROR as U, createErrorActorEvent as V, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, isStateId as v, getStateNodeByPath as w, getPersistedState as x, resolveReferencedActor as y, createActor as z };
@@ -66,9 +66,8 @@ const XSTATE_STOP = 'xstate.stop';
66
66
  * @param id The state node ID where this event is handled
67
67
  */
68
68
  function createAfterEvent(delayRef, id) {
69
- const idSuffix = id ? `#${id}` : '';
70
69
  return {
71
- type: `xstate.after(${delayRef})${idSuffix}`
70
+ type: `xstate.after.${delayRef}.${id}`
72
71
  };
73
72
  }
74
73
 
@@ -205,14 +204,10 @@ function matchesState(parentStateId, childStateId) {
205
204
  });
206
205
  }
207
206
  function toStatePath(stateId) {
208
- try {
209
- if (isArray(stateId)) {
210
- return stateId;
211
- }
212
- return stateId.split(STATE_DELIMITER);
213
- } catch (e) {
214
- throw new Error(`'${stateId}' is not a valid state path.`);
207
+ if (isArray(stateId)) {
208
+ return stateId;
215
209
  }
210
+ return stateId.split(STATE_DELIMITER);
216
211
  }
217
212
  function toStateValue(stateValue) {
218
213
  if (isMachineSnapshot(stateValue)) {
@@ -304,16 +299,17 @@ function toObserver(nextHandler, errorHandler, completionHandler) {
304
299
  };
305
300
  }
306
301
  function createInvokeId(stateNodeId, index) {
307
- return `${stateNodeId}[${index}]`;
302
+ return `${index}.${stateNodeId}`;
308
303
  }
309
304
  function resolveReferencedActor(machine, src) {
310
- if (src.startsWith('xstate#')) {
311
- const [, indexStr] = src.match(/\[(\d+)\]$/);
312
- const node = machine.getStateNodeById(src.slice(7, -(indexStr.length + 2)));
313
- const invokeConfig = node.config.invoke;
314
- return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
305
+ const match = src.match(/^xstate\.invoke\.(\d+)\.(.*)/);
306
+ if (!match) {
307
+ return machine.implementations.actors[src];
315
308
  }
316
- return machine.implementations.actors[src];
309
+ const [, indexStr, nodeId] = match;
310
+ const node = machine.getStateNodeById(nodeId);
311
+ const invokeConfig = node.config.invoke;
312
+ return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
317
313
  }
318
314
  function getAllOwnEventDescriptors(snapshot) {
319
315
  return [...new Set([...snapshot._nodes.flatMap(sn => sn.ownEvents)])];
@@ -1334,8 +1330,7 @@ function getDelayedTransitions(stateNode) {
1334
1330
  return [];
1335
1331
  }
1336
1332
  const mutateEntryExit = (delay, i) => {
1337
- const delayRef = typeof delay === 'function' ? `${stateNode.id}:delay[${i}]` : delay;
1338
- const afterEvent = createAfterEvent(delayRef, stateNode.id);
1333
+ const afterEvent = createAfterEvent(delay, stateNode.id);
1339
1334
  const eventType = afterEvent.type;
1340
1335
  stateNode.entry.push(raise(afterEvent, {
1341
1336
  id: eventType,
@@ -1349,8 +1344,8 @@ function getDelayedTransitions(stateNode) {
1349
1344
  const resolvedTransition = typeof configTransition === 'string' ? {
1350
1345
  target: configTransition
1351
1346
  } : configTransition;
1352
- const resolvedDelay = !isNaN(+delay) ? +delay : delay;
1353
- const eventType = mutateEntryExit(resolvedDelay, i);
1347
+ const resolvedDelay = Number.isNaN(+delay) ? delay : +delay;
1348
+ const eventType = mutateEntryExit(resolvedDelay);
1354
1349
  return toArray(resolvedTransition).map(transition => ({
1355
1350
  ...transition,
1356
1351
  event: eventType,
@@ -66,9 +66,8 @@ const XSTATE_STOP = 'xstate.stop';
66
66
  * @param id The state node ID where this event is handled
67
67
  */
68
68
  function createAfterEvent(delayRef, id) {
69
- const idSuffix = id ? `#${id}` : '';
70
69
  return {
71
- type: `xstate.after(${delayRef})${idSuffix}`
70
+ type: `xstate.after.${delayRef}.${id}`
72
71
  };
73
72
  }
74
73
 
@@ -205,14 +204,10 @@ function matchesState(parentStateId, childStateId) {
205
204
  });
206
205
  }
207
206
  function toStatePath(stateId) {
208
- try {
209
- if (isArray(stateId)) {
210
- return stateId;
211
- }
212
- return stateId.split(STATE_DELIMITER);
213
- } catch (e) {
214
- throw new Error(`'${stateId}' is not a valid state path.`);
207
+ if (isArray(stateId)) {
208
+ return stateId;
215
209
  }
210
+ return stateId.split(STATE_DELIMITER);
216
211
  }
217
212
  function toStateValue(stateValue) {
218
213
  if (isMachineSnapshot(stateValue)) {
@@ -307,16 +302,17 @@ function toObserver(nextHandler, errorHandler, completionHandler) {
307
302
  };
308
303
  }
309
304
  function createInvokeId(stateNodeId, index) {
310
- return `${stateNodeId}[${index}]`;
305
+ return `${index}.${stateNodeId}`;
311
306
  }
312
307
  function resolveReferencedActor(machine, src) {
313
- if (src.startsWith('xstate#')) {
314
- const [, indexStr] = src.match(/\[(\d+)\]$/);
315
- const node = machine.getStateNodeById(src.slice(7, -(indexStr.length + 2)));
316
- const invokeConfig = node.config.invoke;
317
- return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
308
+ const match = src.match(/^xstate\.invoke\.(\d+)\.(.*)/);
309
+ if (!match) {
310
+ return machine.implementations.actors[src];
318
311
  }
319
- return machine.implementations.actors[src];
312
+ const [, indexStr, nodeId] = match;
313
+ const node = machine.getStateNodeById(nodeId);
314
+ const invokeConfig = node.config.invoke;
315
+ return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
320
316
  }
321
317
  function getAllOwnEventDescriptors(snapshot) {
322
318
  return [...new Set([...snapshot._nodes.flatMap(sn => sn.ownEvents)])];
@@ -1371,8 +1367,7 @@ function getDelayedTransitions(stateNode) {
1371
1367
  return [];
1372
1368
  }
1373
1369
  const mutateEntryExit = (delay, i) => {
1374
- const delayRef = typeof delay === 'function' ? `${stateNode.id}:delay[${i}]` : delay;
1375
- const afterEvent = createAfterEvent(delayRef, stateNode.id);
1370
+ const afterEvent = createAfterEvent(delay, stateNode.id);
1376
1371
  const eventType = afterEvent.type;
1377
1372
  stateNode.entry.push(raise(afterEvent, {
1378
1373
  id: eventType,
@@ -1386,8 +1381,8 @@ function getDelayedTransitions(stateNode) {
1386
1381
  const resolvedTransition = typeof configTransition === 'string' ? {
1387
1382
  target: configTransition
1388
1383
  } : configTransition;
1389
- const resolvedDelay = !isNaN(+delay) ? +delay : delay;
1390
- const eventType = mutateEntryExit(resolvedDelay, i);
1384
+ const resolvedDelay = Number.isNaN(+delay) ? delay : +delay;
1385
+ const eventType = mutateEntryExit(resolvedDelay);
1391
1386
  return toArray(resolvedTransition).map(transition => ({
1392
1387
  ...transition,
1393
1388
  event: eventType,
@@ -64,9 +64,8 @@ const XSTATE_STOP = 'xstate.stop';
64
64
  * @param id The state node ID where this event is handled
65
65
  */
66
66
  function createAfterEvent(delayRef, id) {
67
- const idSuffix = id ? `#${id}` : '';
68
67
  return {
69
- type: `xstate.after(${delayRef})${idSuffix}`
68
+ type: `xstate.after.${delayRef}.${id}`
70
69
  };
71
70
  }
72
71
 
@@ -203,14 +202,10 @@ function matchesState(parentStateId, childStateId) {
203
202
  });
204
203
  }
205
204
  function toStatePath(stateId) {
206
- try {
207
- if (isArray(stateId)) {
208
- return stateId;
209
- }
210
- return stateId.split(STATE_DELIMITER);
211
- } catch (e) {
212
- throw new Error(`'${stateId}' is not a valid state path.`);
205
+ if (isArray(stateId)) {
206
+ return stateId;
213
207
  }
208
+ return stateId.split(STATE_DELIMITER);
214
209
  }
215
210
  function toStateValue(stateValue) {
216
211
  if (isMachineSnapshot(stateValue)) {
@@ -302,16 +297,17 @@ function toObserver(nextHandler, errorHandler, completionHandler) {
302
297
  };
303
298
  }
304
299
  function createInvokeId(stateNodeId, index) {
305
- return `${stateNodeId}[${index}]`;
300
+ return `${index}.${stateNodeId}`;
306
301
  }
307
302
  function resolveReferencedActor(machine, src) {
308
- if (src.startsWith('xstate#')) {
309
- const [, indexStr] = src.match(/\[(\d+)\]$/);
310
- const node = machine.getStateNodeById(src.slice(7, -(indexStr.length + 2)));
311
- const invokeConfig = node.config.invoke;
312
- return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
303
+ const match = src.match(/^xstate\.invoke\.(\d+)\.(.*)/);
304
+ if (!match) {
305
+ return machine.implementations.actors[src];
313
306
  }
314
- return machine.implementations.actors[src];
307
+ const [, indexStr, nodeId] = match;
308
+ const node = machine.getStateNodeById(nodeId);
309
+ const invokeConfig = node.config.invoke;
310
+ return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
315
311
  }
316
312
  function getAllOwnEventDescriptors(snapshot) {
317
313
  return [...new Set([...snapshot._nodes.flatMap(sn => sn.ownEvents)])];
@@ -1332,8 +1328,7 @@ function getDelayedTransitions(stateNode) {
1332
1328
  return [];
1333
1329
  }
1334
1330
  const mutateEntryExit = (delay, i) => {
1335
- const delayRef = typeof delay === 'function' ? `${stateNode.id}:delay[${i}]` : delay;
1336
- const afterEvent = createAfterEvent(delayRef, stateNode.id);
1331
+ const afterEvent = createAfterEvent(delay, stateNode.id);
1337
1332
  const eventType = afterEvent.type;
1338
1333
  stateNode.entry.push(raise(afterEvent, {
1339
1334
  id: eventType,
@@ -1347,8 +1342,8 @@ function getDelayedTransitions(stateNode) {
1347
1342
  const resolvedTransition = typeof configTransition === 'string' ? {
1348
1343
  target: configTransition
1349
1344
  } : configTransition;
1350
- const resolvedDelay = !isNaN(+delay) ? +delay : delay;
1351
- const eventType = mutateEntryExit(resolvedDelay, i);
1345
+ const resolvedDelay = Number.isNaN(+delay) ? delay : +delay;
1346
+ const eventType = mutateEntryExit(resolvedDelay);
1352
1347
  return toArray(resolvedTransition).map(transition => ({
1353
1348
  ...transition,
1354
1349
  event: eventType,
@@ -2319,4 +2314,4 @@ function raise(eventOrExpr, options) {
2319
2314
  return raise;
2320
2315
  }
2321
2316
 
2322
- export { $$ACTOR_TYPE as $, Actor as A, interpret as B, isMachineSnapshot as C, matchesState as D, pathToStateValue as E, toObserver as F, getAllOwnEventDescriptors as G, and as H, not as I, or as J, stateIn as K, cancel as L, raise as M, NULL_EVENT as N, stop as O, stopChild as P, spawnChild as Q, ProcessingStatus as R, STATE_DELIMITER as S, cloneMachineSnapshot as T, XSTATE_ERROR as U, createErrorActorEvent as V, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, isStateId as v, getStateNodeByPath as w, getPersistedState as x, resolveReferencedActor as y, createActor as z };
2317
+ export { $$ACTOR_TYPE as $, Actor as A, interpret as B, isMachineSnapshot as C, matchesState as D, pathToStateValue as E, toObserver as F, getAllOwnEventDescriptors as G, and as H, not as I, or as J, stateIn as K, cancel as L, raise as M, NULL_EVENT as N, spawnChild as O, stop as P, stopChild as Q, ProcessingStatus as R, STATE_DELIMITER as S, cloneMachineSnapshot as T, XSTATE_ERROR as U, createErrorActorEvent as V, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, isStateId as v, getStateNodeByPath as w, getPersistedState as x, resolveReferencedActor as y, createActor as z };
@@ -3,8 +3,8 @@
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 guards_dist_xstateGuards = require('./raise-8176cd35.cjs.js');
7
- var send = require('./send-7f3db830.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-367eeb6f.cjs.js');
7
+ var log = require('./log-3d815f5e.cjs.js');
8
8
  require('../dev/dist/xstate-dev.cjs.js');
9
9
 
10
10
  class SimulatedClock {
@@ -254,8 +254,8 @@ class StateNode {
254
254
  src,
255
255
  systemId
256
256
  } = invokeConfig;
257
- const resolvedId = invokeConfig.id || guards_dist_xstateGuards.createInvokeId(this.id, i);
258
- const resolvedSrc = typeof src === 'string' ? src : `xstate#${guards_dist_xstateGuards.createInvokeId(this.id, i)}`;
257
+ const resolvedId = invokeConfig.id ?? guards_dist_xstateGuards.createInvokeId(this.id, i);
258
+ const resolvedSrc = typeof src === 'string' ? src : `xstate.invoke.${guards_dist_xstateGuards.createInvokeId(this.id, i)}`;
259
259
  return {
260
260
  ...invokeConfig,
261
261
  src: resolvedSrc,
@@ -497,7 +497,7 @@ class StateMachine {
497
497
  spawn,
498
498
  input: event.input
499
499
  });
500
- return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [send.assign(assignment)], internalQueue);
500
+ return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [log.assign(assignment)], internalQueue);
501
501
  }
502
502
  return preInitial;
503
503
  }
@@ -716,15 +716,14 @@ exports.stateIn = guards_dist_xstateGuards.stateIn;
716
716
  exports.stop = guards_dist_xstateGuards.stop;
717
717
  exports.stopChild = guards_dist_xstateGuards.stopChild;
718
718
  exports.toObserver = guards_dist_xstateGuards.toObserver;
719
- exports.SpecialTargets = send.SpecialTargets;
720
- exports.assign = send.assign;
721
- exports.choose = send.choose;
722
- exports.escalate = send.escalate;
723
- exports.forwardTo = send.forwardTo;
724
- exports.log = send.log;
725
- exports.pure = send.pure;
726
- exports.sendParent = send.sendParent;
727
- exports.sendTo = send.sendTo;
719
+ exports.SpecialTargets = log.SpecialTargets;
720
+ exports.assign = log.assign;
721
+ exports.enqueueActions = log.enqueueActions;
722
+ exports.escalate = log.escalate;
723
+ exports.forwardTo = log.forwardTo;
724
+ exports.log = log.log;
725
+ exports.sendParent = log.sendParent;
726
+ exports.sendTo = log.sendTo;
728
727
  exports.SimulatedClock = SimulatedClock;
729
728
  exports.StateMachine = StateMachine;
730
729
  exports.StateNode = StateNode;
@@ -8,10 +8,10 @@ export {
8
8
  and,
9
9
  assign,
10
10
  cancel,
11
- choose,
12
11
  createActor,
13
12
  createEmptyActor,
14
13
  createMachine,
14
+ enqueueActions,
15
15
  escalate,
16
16
  forwardTo,
17
17
  fromCallback,
@@ -27,7 +27,6 @@ export {
27
27
  not,
28
28
  or,
29
29
  pathToStateValue,
30
- pure,
31
30
  raise,
32
31
  sendParent,
33
32
  sendTo,
@@ -3,8 +3,8 @@
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 guards_dist_xstateGuards = require('./raise-dc9c2c58.development.cjs.js');
7
- var send = require('./send-df1c8ef2.development.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-9dd3e757.development.cjs.js');
7
+ var log = require('./log-d160285c.development.cjs.js');
8
8
  require('../dev/dist/xstate-dev.development.cjs.js');
9
9
 
10
10
  class SimulatedClock {
@@ -254,8 +254,8 @@ class StateNode {
254
254
  src,
255
255
  systemId
256
256
  } = invokeConfig;
257
- const resolvedId = invokeConfig.id || guards_dist_xstateGuards.createInvokeId(this.id, i);
258
- const resolvedSrc = typeof src === 'string' ? src : `xstate#${guards_dist_xstateGuards.createInvokeId(this.id, i)}`;
257
+ const resolvedId = invokeConfig.id ?? guards_dist_xstateGuards.createInvokeId(this.id, i);
258
+ const resolvedSrc = typeof src === 'string' ? src : `xstate.invoke.${guards_dist_xstateGuards.createInvokeId(this.id, i)}`;
259
259
  return {
260
260
  ...invokeConfig,
261
261
  src: resolvedSrc,
@@ -500,7 +500,7 @@ class StateMachine {
500
500
  spawn,
501
501
  input: event.input
502
502
  });
503
- return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [send.assign(assignment)], internalQueue);
503
+ return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [log.assign(assignment)], internalQueue);
504
504
  }
505
505
  return preInitial;
506
506
  }
@@ -722,15 +722,14 @@ exports.stateIn = guards_dist_xstateGuards.stateIn;
722
722
  exports.stop = guards_dist_xstateGuards.stop;
723
723
  exports.stopChild = guards_dist_xstateGuards.stopChild;
724
724
  exports.toObserver = guards_dist_xstateGuards.toObserver;
725
- exports.SpecialTargets = send.SpecialTargets;
726
- exports.assign = send.assign;
727
- exports.choose = send.choose;
728
- exports.escalate = send.escalate;
729
- exports.forwardTo = send.forwardTo;
730
- exports.log = send.log;
731
- exports.pure = send.pure;
732
- exports.sendParent = send.sendParent;
733
- exports.sendTo = send.sendTo;
725
+ exports.SpecialTargets = log.SpecialTargets;
726
+ exports.assign = log.assign;
727
+ exports.enqueueActions = log.enqueueActions;
728
+ exports.escalate = log.escalate;
729
+ exports.forwardTo = log.forwardTo;
730
+ exports.log = log.log;
731
+ exports.sendParent = log.sendParent;
732
+ exports.sendTo = log.sendTo;
734
733
  exports.SimulatedClock = SimulatedClock;
735
734
  exports.StateMachine = StateMachine;
736
735
  exports.StateNode = StateNode;
@@ -8,10 +8,10 @@ export {
8
8
  and,
9
9
  assign,
10
10
  cancel,
11
- choose,
12
11
  createActor,
13
12
  createEmptyActor,
14
13
  createMachine,
14
+ enqueueActions,
15
15
  escalate,
16
16
  forwardTo,
17
17
  fromCallback,
@@ -27,7 +27,6 @@ export {
27
27
  not,
28
28
  or,
29
29
  pathToStateValue,
30
- pure,
31
30
  raise,
32
31
  sendParent,
33
32
  sendTo,