xstate 5.0.0-beta.36 → 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 (65) 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/typegenTypes.d.ts +2 -0
  36. package/dist/declarations/src/types.d.ts +47 -58
  37. package/dist/declarations/src/utils.d.ts +6 -6
  38. package/dist/declarations/src/waitFor.d.ts +1 -1
  39. package/dist/{interpreter-5c4e6634.development.esm.js → interpreter-4005eb36.development.esm.js} +14 -24
  40. package/dist/{interpreter-69605bf0.cjs.js → interpreter-b6f22ee2.cjs.js} +14 -24
  41. package/dist/{interpreter-de5217bc.esm.js → interpreter-c80ce92e.esm.js} +14 -24
  42. package/dist/{interpreter-d3567419.development.cjs.js → interpreter-ed3f81f7.development.cjs.js} +14 -24
  43. package/dist/{raise-5b7ad3b7.development.esm.js → raise-42073973.development.esm.js} +138 -118
  44. package/dist/{raise-c51b81a3.cjs.js → raise-7faa9b3b.cjs.js} +139 -118
  45. package/dist/{raise-106ea558.development.cjs.js → raise-b69a3d16.development.cjs.js} +138 -117
  46. package/dist/{raise-ffe1014a.esm.js → raise-c989c7fb.esm.js} +139 -119
  47. package/dist/{send-778692de.cjs.js → send-34160163.cjs.js} +31 -27
  48. package/dist/{send-0a7aa74e.esm.js → send-4b616da9.esm.js} +31 -27
  49. package/dist/{send-25e70bd4.development.cjs.js → send-58725522.development.cjs.js} +31 -27
  50. package/dist/{send-e93554d6.development.esm.js → send-bff8c910.development.esm.js} +31 -27
  51. package/dist/xstate.cjs.js +11 -16
  52. package/dist/xstate.cjs.mjs +1 -0
  53. package/dist/xstate.development.cjs.js +11 -16
  54. package/dist/xstate.development.cjs.mjs +1 -0
  55. package/dist/xstate.development.esm.js +13 -19
  56. package/dist/xstate.esm.js +13 -19
  57. package/dist/xstate.umd.min.js +1 -1
  58. package/dist/xstate.umd.min.js.map +1 -1
  59. package/guards/dist/xstate-guards.cjs.js +2 -2
  60. package/guards/dist/xstate-guards.development.cjs.js +2 -2
  61. package/guards/dist/xstate-guards.development.esm.js +2 -2
  62. package/guards/dist/xstate-guards.esm.js +2 -2
  63. package/guards/dist/xstate-guards.umd.min.js +1 -1
  64. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  65. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { j as cloneState, e as evaluateGuard } from './raise-5b7ad3b7.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-5c4e6634.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,
@@ -10,7 +10,7 @@ function createSpawner(actorContext, {
10
10
  systemId
11
11
  } = options;
12
12
  if (typeof src === 'string') {
13
- const referenced = resolveReferencedActor(machine.implementations.actors[src]);
13
+ const referenced = resolveReferencedActor(machine, src);
14
14
  if (!referenced) {
15
15
  throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
16
16
  }
@@ -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) {
@@ -320,6 +321,9 @@ function executeSendTo(actorContext, params) {
320
321
  actorContext.self.delaySend(params);
321
322
  return;
322
323
  }
324
+
325
+ // this forms an outgoing events queue
326
+ // thanks to that the recipient actors are able to read the *updated* snapshot value of the sender
323
327
  actorContext.defer(() => {
324
328
  const {
325
329
  to,
@@ -338,7 +342,7 @@ function executeSendTo(actorContext, params) {
338
342
  * - `delay` - The number of milliseconds to delay the sending of the event.
339
343
  */
340
344
  function sendTo(to, eventOrExpr, options) {
341
- function sendTo(_) {
345
+ function sendTo(args, params) {
342
346
  {
343
347
  throw new Error(`This isn't supposed to be called`);
344
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-69605bf0.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-c51b81a3.cjs.js');
8
- var send = require('./send-778692de.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 {
@@ -255,15 +255,7 @@ class StateNode {
255
255
  systemId
256
256
  } = invokeConfig;
257
257
  const resolvedId = invokeConfig.id || interpreter.createInvokeId(this.id, i);
258
- // TODO: resolving should not happen here
259
- const resolvedSrc = typeof src === 'string' ? src : !('type' in src) ? resolvedId : src;
260
- if (!this.machine.implementations.actors[resolvedId] && typeof src !== 'string' && !('type' in src)) {
261
- this.machine.implementations.actors = {
262
- ...this.machine.implementations.actors,
263
- // TODO: this should accept `src` as-is
264
- [resolvedId]: src
265
- };
266
- }
258
+ const resolvedSrc = typeof src === 'string' ? src : `xstate#${interpreter.createInvokeId(this.id, i)}`;
267
259
  return {
268
260
  ...invokeConfig,
269
261
  src: resolvedSrc,
@@ -595,11 +587,12 @@ class StateMachine {
595
587
  }
596
588
  restoreState(snapshot, _actorCtx) {
597
589
  const children = {};
598
- Object.keys(snapshot.children).forEach(actorId => {
599
- const actorData = snapshot.children[actorId];
590
+ const snapshotChildren = snapshot.children;
591
+ Object.keys(snapshotChildren).forEach(actorId => {
592
+ const actorData = snapshotChildren[actorId];
600
593
  const childState = actorData.state;
601
594
  const src = actorData.src;
602
- const logic = src ? interpreter.resolveReferencedActor(this.implementations.actors[src])?.src : undefined;
595
+ const logic = src ? interpreter.resolveReferencedActor(this, src)?.src : undefined;
603
596
  if (!logic) {
604
597
  return;
605
598
  }
@@ -607,7 +600,8 @@ class StateMachine {
607
600
  const actorRef = interpreter.createActor(logic, {
608
601
  id: actorId,
609
602
  parent: _actorCtx?.self,
610
- state: actorState
603
+ state: actorState,
604
+ systemId: actorData.systemId
611
605
  });
612
606
  children[actorId] = actorRef;
613
607
  });
@@ -745,6 +739,7 @@ exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
745
739
  exports.not = guards_dist_xstateGuards.not;
746
740
  exports.or = guards_dist_xstateGuards.or;
747
741
  exports.raise = guards_dist_xstateGuards.raise;
742
+ exports.spawn = guards_dist_xstateGuards.spawn;
748
743
  exports.stateIn = guards_dist_xstateGuards.stateIn;
749
744
  exports.stop = guards_dist_xstateGuards.stop;
750
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-d3567419.development.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-106ea558.development.cjs.js');
8
- var send = require('./send-25e70bd4.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 {
@@ -255,15 +255,7 @@ class StateNode {
255
255
  systemId
256
256
  } = invokeConfig;
257
257
  const resolvedId = invokeConfig.id || interpreter.createInvokeId(this.id, i);
258
- // TODO: resolving should not happen here
259
- const resolvedSrc = typeof src === 'string' ? src : !('type' in src) ? resolvedId : src;
260
- if (!this.machine.implementations.actors[resolvedId] && typeof src !== 'string' && !('type' in src)) {
261
- this.machine.implementations.actors = {
262
- ...this.machine.implementations.actors,
263
- // TODO: this should accept `src` as-is
264
- [resolvedId]: src
265
- };
266
- }
258
+ const resolvedSrc = typeof src === 'string' ? src : `xstate#${interpreter.createInvokeId(this.id, i)}`;
267
259
  return {
268
260
  ...invokeConfig,
269
261
  src: resolvedSrc,
@@ -598,11 +590,12 @@ class StateMachine {
598
590
  }
599
591
  restoreState(snapshot, _actorCtx) {
600
592
  const children = {};
601
- Object.keys(snapshot.children).forEach(actorId => {
602
- const actorData = snapshot.children[actorId];
593
+ const snapshotChildren = snapshot.children;
594
+ Object.keys(snapshotChildren).forEach(actorId => {
595
+ const actorData = snapshotChildren[actorId];
603
596
  const childState = actorData.state;
604
597
  const src = actorData.src;
605
- const logic = src ? interpreter.resolveReferencedActor(this.implementations.actors[src])?.src : undefined;
598
+ const logic = src ? interpreter.resolveReferencedActor(this, src)?.src : undefined;
606
599
  if (!logic) {
607
600
  return;
608
601
  }
@@ -610,7 +603,8 @@ class StateMachine {
610
603
  const actorRef = interpreter.createActor(logic, {
611
604
  id: actorId,
612
605
  parent: _actorCtx?.self,
613
- state: actorState
606
+ state: actorState,
607
+ systemId: actorData.systemId
614
608
  });
615
609
  children[actorId] = actorRef;
616
610
  });
@@ -751,6 +745,7 @@ exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
751
745
  exports.not = guards_dist_xstateGuards.not;
752
746
  exports.or = guards_dist_xstateGuards.or;
753
747
  exports.raise = guards_dist_xstateGuards.raise;
748
+ exports.spawn = guards_dist_xstateGuards.spawn;
754
749
  exports.stateIn = guards_dist_xstateGuards.stateIn;
755
750
  exports.stop = guards_dist_xstateGuards.stop;
756
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,
@@ -1,10 +1,10 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
2
- import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-5c4e6634.development.esm.js';
3
- export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-5c4e6634.development.esm.js';
4
- import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-5b7ad3b7.development.esm.js';
5
- export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-5b7ad3b7.development.esm.js';
6
- import { a as assign } from './send-e93554d6.development.esm.js';
7
- export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-e93554d6.development.esm.js';
2
+ import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-4005eb36.development.esm.js';
3
+ export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-4005eb36.development.esm.js';
4
+ import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-42073973.development.esm.js';
5
+ export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-42073973.development.esm.js';
6
+ import { a as assign } from './send-bff8c910.development.esm.js';
7
+ export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-bff8c910.development.esm.js';
8
8
  import '../dev/dist/xstate-dev.development.esm.js';
9
9
 
10
10
  class SimulatedClock {
@@ -254,15 +254,7 @@ class StateNode {
254
254
  systemId
255
255
  } = invokeConfig;
256
256
  const resolvedId = invokeConfig.id || createInvokeId(this.id, i);
257
- // TODO: resolving should not happen here
258
- const resolvedSrc = typeof src === 'string' ? src : !('type' in src) ? resolvedId : src;
259
- if (!this.machine.implementations.actors[resolvedId] && typeof src !== 'string' && !('type' in src)) {
260
- this.machine.implementations.actors = {
261
- ...this.machine.implementations.actors,
262
- // TODO: this should accept `src` as-is
263
- [resolvedId]: src
264
- };
265
- }
257
+ const resolvedSrc = typeof src === 'string' ? src : `xstate#${createInvokeId(this.id, i)}`;
266
258
  return {
267
259
  ...invokeConfig,
268
260
  src: resolvedSrc,
@@ -597,11 +589,12 @@ class StateMachine {
597
589
  }
598
590
  restoreState(snapshot, _actorCtx) {
599
591
  const children = {};
600
- Object.keys(snapshot.children).forEach(actorId => {
601
- const actorData = snapshot.children[actorId];
592
+ const snapshotChildren = snapshot.children;
593
+ Object.keys(snapshotChildren).forEach(actorId => {
594
+ const actorData = snapshotChildren[actorId];
602
595
  const childState = actorData.state;
603
596
  const src = actorData.src;
604
- const logic = src ? resolveReferencedActor(this.implementations.actors[src])?.src : undefined;
597
+ const logic = src ? resolveReferencedActor(this, src)?.src : undefined;
605
598
  if (!logic) {
606
599
  return;
607
600
  }
@@ -609,7 +602,8 @@ class StateMachine {
609
602
  const actorRef = createActor(logic, {
610
603
  id: actorId,
611
604
  parent: _actorCtx?.self,
612
- state: actorState
605
+ state: actorState,
606
+ systemId: actorData.systemId
613
607
  });
614
608
  children[actorId] = actorRef;
615
609
  });
@@ -1,10 +1,10 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
2
- import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-de5217bc.esm.js';
3
- export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-de5217bc.esm.js';
4
- import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-ffe1014a.esm.js';
5
- export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-ffe1014a.esm.js';
6
- import { a as assign } from './send-0a7aa74e.esm.js';
7
- export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-0a7aa74e.esm.js';
2
+ import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-c80ce92e.esm.js';
3
+ export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-c80ce92e.esm.js';
4
+ import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-c989c7fb.esm.js';
5
+ export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-c989c7fb.esm.js';
6
+ import { a as assign } from './send-4b616da9.esm.js';
7
+ export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-4b616da9.esm.js';
8
8
  import '../dev/dist/xstate-dev.esm.js';
9
9
 
10
10
  class SimulatedClock {
@@ -254,15 +254,7 @@ class StateNode {
254
254
  systemId
255
255
  } = invokeConfig;
256
256
  const resolvedId = invokeConfig.id || createInvokeId(this.id, i);
257
- // TODO: resolving should not happen here
258
- const resolvedSrc = typeof src === 'string' ? src : !('type' in src) ? resolvedId : src;
259
- if (!this.machine.implementations.actors[resolvedId] && typeof src !== 'string' && !('type' in src)) {
260
- this.machine.implementations.actors = {
261
- ...this.machine.implementations.actors,
262
- // TODO: this should accept `src` as-is
263
- [resolvedId]: src
264
- };
265
- }
257
+ const resolvedSrc = typeof src === 'string' ? src : `xstate#${createInvokeId(this.id, i)}`;
266
258
  return {
267
259
  ...invokeConfig,
268
260
  src: resolvedSrc,
@@ -594,11 +586,12 @@ class StateMachine {
594
586
  }
595
587
  restoreState(snapshot, _actorCtx) {
596
588
  const children = {};
597
- Object.keys(snapshot.children).forEach(actorId => {
598
- const actorData = snapshot.children[actorId];
589
+ const snapshotChildren = snapshot.children;
590
+ Object.keys(snapshotChildren).forEach(actorId => {
591
+ const actorData = snapshotChildren[actorId];
599
592
  const childState = actorData.state;
600
593
  const src = actorData.src;
601
- const logic = src ? resolveReferencedActor(this.implementations.actors[src])?.src : undefined;
594
+ const logic = src ? resolveReferencedActor(this, src)?.src : undefined;
602
595
  if (!logic) {
603
596
  return;
604
597
  }
@@ -606,7 +599,8 @@ class StateMachine {
606
599
  const actorRef = createActor(logic, {
607
600
  id: actorId,
608
601
  parent: _actorCtx?.self,
609
- state: actorState
602
+ state: actorState,
603
+ systemId: actorData.systemId
610
604
  });
611
605
  children[actorId] = actorRef;
612
606
  });