xstate 5.0.0-beta.42 → 5.0.0-beta.44

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 (47) hide show
  1. package/actions/dist/xstate-actions.cjs.js +2 -3
  2. package/actions/dist/xstate-actions.development.cjs.js +2 -3
  3. package/actions/dist/xstate-actions.development.esm.js +2 -3
  4. package/actions/dist/xstate-actions.esm.js +2 -3
  5. package/actions/dist/xstate-actions.umd.min.js +1 -1
  6. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  7. package/actors/dist/xstate-actors.cjs.js +50 -6
  8. package/actors/dist/xstate-actors.development.cjs.js +50 -6
  9. package/actors/dist/xstate-actors.development.esm.js +45 -1
  10. package/actors/dist/xstate-actors.esm.js +45 -1
  11. package/actors/dist/xstate-actors.umd.min.js +1 -1
  12. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  13. package/dist/declarations/src/State.d.ts +8 -12
  14. package/dist/declarations/src/actions/spawn.d.ts +11 -16
  15. package/dist/declarations/src/actors/promise.d.ts +53 -0
  16. package/dist/declarations/src/guards.d.ts +2 -2
  17. package/dist/declarations/src/index.d.ts +1 -1
  18. package/dist/declarations/src/spawn.d.ts +9 -13
  19. package/dist/declarations/src/stateUtils.d.ts +4 -4
  20. package/dist/declarations/src/types.d.ts +56 -22
  21. package/dist/declarations/src/utils.d.ts +2 -10
  22. package/dist/{raise-6b64c553.cjs.js → raise-348cc74e.development.esm.js} +1007 -116
  23. package/dist/{raise-51ae36e5.development.esm.js → raise-5854eaca.esm.js} +925 -101
  24. package/dist/{raise-8f482ce9.development.cjs.js → raise-ed700d14.development.cjs.js} +986 -87
  25. package/dist/{raise-d2084327.esm.js → raise-fb6f017b.cjs.js} +972 -54
  26. package/dist/{send-cc8f864e.development.cjs.js → send-00466e37.development.cjs.js} +14 -17
  27. package/dist/{send-85b562d8.cjs.js → send-53e5693c.cjs.js} +14 -17
  28. package/dist/{send-7a350091.development.esm.js → send-a0193bdb.development.esm.js} +7 -10
  29. package/dist/{send-4e732fa5.esm.js → send-b7b4befa.esm.js} +7 -10
  30. package/dist/xstate.cjs.js +25 -25
  31. package/dist/xstate.cjs.mjs +1 -0
  32. package/dist/xstate.development.cjs.js +25 -25
  33. package/dist/xstate.development.cjs.mjs +1 -0
  34. package/dist/xstate.development.esm.js +5 -7
  35. package/dist/xstate.esm.js +5 -7
  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 -2
  39. package/guards/dist/xstate-guards.development.cjs.js +1 -2
  40. package/guards/dist/xstate-guards.development.esm.js +1 -2
  41. package/guards/dist/xstate-guards.esm.js +1 -2
  42. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  43. package/package.json +1 -1
  44. package/dist/interpreter-23e4041c.development.cjs.js +0 -905
  45. package/dist/interpreter-3d0c0ff2.esm.js +0 -864
  46. package/dist/interpreter-b6bdd134.cjs.js +0 -894
  47. package/dist/interpreter-f2620ea7.development.esm.js +0 -875
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-8f482ce9.development.cjs.js');
4
- var interpreter = require('./interpreter-23e4041c.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-ed700d14.development.cjs.js');
5
4
 
6
5
  function createSpawner(actorScope, {
7
6
  machine,
@@ -9,17 +8,15 @@ function createSpawner(actorScope, {
9
8
  }, event, spawnedChildren) {
10
9
  const spawn = (src, options = {}) => {
11
10
  const {
12
- systemId
11
+ systemId,
12
+ input
13
13
  } = options;
14
14
  if (typeof src === 'string') {
15
- const referenced = interpreter.resolveReferencedActor(machine, src);
16
- if (!referenced) {
15
+ const logic = guards_dist_xstateGuards.resolveReferencedActor(machine, src);
16
+ if (!logic) {
17
17
  throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
18
18
  }
19
- const input = 'input' in options ? options.input : referenced.input;
20
-
21
- // TODO: this should also receive `src`
22
- const actorRef = interpreter.createActor(referenced.src, {
19
+ const actorRef = guards_dist_xstateGuards.createActor(logic, {
23
20
  id: options.id,
24
21
  parent: actorScope.self,
25
22
  input: typeof input === 'function' ? input({
@@ -46,7 +43,7 @@ function createSpawner(actorScope, {
46
43
  }
47
44
  return actorRef;
48
45
  } else {
49
- const actorRef = interpreter.createActor(src, {
46
+ const actorRef = guards_dist_xstateGuards.createActor(src, {
50
47
  id: options.id,
51
48
  parent: actorScope.self,
52
49
  input: options.input,
@@ -74,13 +71,13 @@ function createSpawner(actorScope, {
74
71
  const actorRef = spawn(src, options); // TODO: fix types
75
72
  spawnedChildren[actorRef.id] = actorRef;
76
73
  actorScope.defer(() => {
77
- if (actorRef._processingStatus === interpreter.ProcessingStatus.Stopped) {
74
+ if (actorRef._processingStatus === guards_dist_xstateGuards.ProcessingStatus.Stopped) {
78
75
  return;
79
76
  }
80
77
  try {
81
78
  actorRef.start?.();
82
79
  } catch (err) {
83
- actorScope.self.send(interpreter.createErrorActorEvent(actorRef.id, err));
80
+ actorScope.self.send(guards_dist_xstateGuards.createErrorActorEvent(actorRef.id, err));
84
81
  return;
85
82
  }
86
83
  });
@@ -143,7 +140,7 @@ function resolveChoose(_, state, actionArgs, _actionParams, {
143
140
  const matchedActions = branches.find(condition => {
144
141
  return !condition.guard || guards_dist_xstateGuards.evaluateGuard(condition.guard, state.context, actionArgs.event, state);
145
142
  })?.actions;
146
- return [state, undefined, interpreter.toArray(matchedActions)];
143
+ return [state, undefined, guards_dist_xstateGuards.toArray(matchedActions)];
147
144
  }
148
145
  function choose(branches) {
149
146
  function choose(args, params) {
@@ -209,7 +206,7 @@ function log(value = ({
209
206
  function resolvePure(_, state, args, _actionParams, {
210
207
  get
211
208
  }) {
212
- return [state, undefined, interpreter.toArray(get({
209
+ return [state, undefined, guards_dist_xstateGuards.toArray(get({
213
210
  context: args.context,
214
211
  event: args.event
215
212
  }))];
@@ -259,7 +256,7 @@ function pure(getActions) {
259
256
 
260
257
  // TODO: remove once TS fixes this type-widening issue
261
258
 
262
- // TODO: replace with AnyMachineSnapshot
259
+ /** @deprecated use `AnyMachineSnapshot` instead */
263
260
 
264
261
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
265
262
 
@@ -332,7 +329,7 @@ function executeSendTo(actorScope, params) {
332
329
  to,
333
330
  event
334
331
  } = params;
335
- actorScope?.system._relay(actorScope.self, to, event.type === interpreter.XSTATE_ERROR ? interpreter.createErrorActorEvent(actorScope.self.id, event.data) : event);
332
+ actorScope?.system._relay(actorScope.self, to, event.type === guards_dist_xstateGuards.XSTATE_ERROR ? guards_dist_xstateGuards.createErrorActorEvent(actorScope.self.id, event.data) : event);
336
333
  });
337
334
  }
338
335
  /**
@@ -402,7 +399,7 @@ function forwardTo(target, options) {
402
399
  function escalate(errorData, options) {
403
400
  return sendParent(arg => {
404
401
  return {
405
- type: interpreter.XSTATE_ERROR,
402
+ type: guards_dist_xstateGuards.XSTATE_ERROR,
406
403
  data: typeof errorData === 'function' ? errorData(arg) : errorData
407
404
  };
408
405
  }, options);
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-6b64c553.cjs.js');
4
- var interpreter = require('./interpreter-b6bdd134.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-fb6f017b.cjs.js');
5
4
 
6
5
  function createSpawner(actorScope, {
7
6
  machine,
@@ -9,17 +8,15 @@ function createSpawner(actorScope, {
9
8
  }, event, spawnedChildren) {
10
9
  const spawn = (src, options = {}) => {
11
10
  const {
12
- systemId
11
+ systemId,
12
+ input
13
13
  } = options;
14
14
  if (typeof src === 'string') {
15
- const referenced = interpreter.resolveReferencedActor(machine, src);
16
- if (!referenced) {
15
+ const logic = guards_dist_xstateGuards.resolveReferencedActor(machine, src);
16
+ if (!logic) {
17
17
  throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
18
18
  }
19
- const input = 'input' in options ? options.input : referenced.input;
20
-
21
- // TODO: this should also receive `src`
22
- const actorRef = interpreter.createActor(referenced.src, {
19
+ const actorRef = guards_dist_xstateGuards.createActor(logic, {
23
20
  id: options.id,
24
21
  parent: actorScope.self,
25
22
  input: typeof input === 'function' ? input({
@@ -46,7 +43,7 @@ function createSpawner(actorScope, {
46
43
  }
47
44
  return actorRef;
48
45
  } else {
49
- const actorRef = interpreter.createActor(src, {
46
+ const actorRef = guards_dist_xstateGuards.createActor(src, {
50
47
  id: options.id,
51
48
  parent: actorScope.self,
52
49
  input: options.input,
@@ -74,13 +71,13 @@ function createSpawner(actorScope, {
74
71
  const actorRef = spawn(src, options); // TODO: fix types
75
72
  spawnedChildren[actorRef.id] = actorRef;
76
73
  actorScope.defer(() => {
77
- if (actorRef._processingStatus === interpreter.ProcessingStatus.Stopped) {
74
+ if (actorRef._processingStatus === guards_dist_xstateGuards.ProcessingStatus.Stopped) {
78
75
  return;
79
76
  }
80
77
  try {
81
78
  actorRef.start?.();
82
79
  } catch (err) {
83
- actorScope.self.send(interpreter.createErrorActorEvent(actorRef.id, err));
80
+ actorScope.self.send(guards_dist_xstateGuards.createErrorActorEvent(actorRef.id, err));
84
81
  return;
85
82
  }
86
83
  });
@@ -140,7 +137,7 @@ function resolveChoose(_, state, actionArgs, _actionParams, {
140
137
  const matchedActions = branches.find(condition => {
141
138
  return !condition.guard || guards_dist_xstateGuards.evaluateGuard(condition.guard, state.context, actionArgs.event, state);
142
139
  })?.actions;
143
- return [state, undefined, interpreter.toArray(matchedActions)];
140
+ return [state, undefined, guards_dist_xstateGuards.toArray(matchedActions)];
144
141
  }
145
142
  function choose(branches) {
146
143
  function choose(args, params) {
@@ -200,7 +197,7 @@ function log(value = ({
200
197
  function resolvePure(_, state, args, _actionParams, {
201
198
  get
202
199
  }) {
203
- return [state, undefined, interpreter.toArray(get({
200
+ return [state, undefined, guards_dist_xstateGuards.toArray(get({
204
201
  context: args.context,
205
202
  event: args.event
206
203
  }))];
@@ -247,7 +244,7 @@ function pure(getActions) {
247
244
 
248
245
  // TODO: remove once TS fixes this type-widening issue
249
246
 
250
- // TODO: replace with AnyMachineSnapshot
247
+ /** @deprecated use `AnyMachineSnapshot` instead */
251
248
 
252
249
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
253
250
 
@@ -320,7 +317,7 @@ function executeSendTo(actorScope, params) {
320
317
  to,
321
318
  event
322
319
  } = params;
323
- actorScope?.system._relay(actorScope.self, to, event.type === interpreter.XSTATE_ERROR ? interpreter.createErrorActorEvent(actorScope.self.id, event.data) : event);
320
+ actorScope?.system._relay(actorScope.self, to, event.type === guards_dist_xstateGuards.XSTATE_ERROR ? guards_dist_xstateGuards.createErrorActorEvent(actorScope.self.id, event.data) : event);
324
321
  });
325
322
  }
326
323
  /**
@@ -377,7 +374,7 @@ function forwardTo(target, options) {
377
374
  function escalate(errorData, options) {
378
375
  return sendParent(arg => {
379
376
  return {
380
- type: interpreter.XSTATE_ERROR,
377
+ type: guards_dist_xstateGuards.XSTATE_ERROR,
381
378
  data: typeof errorData === 'function' ? errorData(arg) : errorData
382
379
  };
383
380
  }, options);
@@ -1,5 +1,4 @@
1
- import { k as cloneMachineSnapshot, e as evaluateGuard } from './raise-51ae36e5.development.esm.js';
2
- import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, v as XSTATE_ERROR } from './interpreter-f2620ea7.development.esm.js';
1
+ import { T as ProcessingStatus, U as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, V as XSTATE_ERROR } from './raise-348cc74e.development.esm.js';
3
2
 
4
3
  function createSpawner(actorScope, {
5
4
  machine,
@@ -7,17 +6,15 @@ function createSpawner(actorScope, {
7
6
  }, event, spawnedChildren) {
8
7
  const spawn = (src, options = {}) => {
9
8
  const {
10
- systemId
9
+ systemId,
10
+ input
11
11
  } = options;
12
12
  if (typeof src === 'string') {
13
- const referenced = resolveReferencedActor(machine, src);
14
- if (!referenced) {
13
+ const logic = resolveReferencedActor(machine, src);
14
+ if (!logic) {
15
15
  throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
16
16
  }
17
- const input = 'input' in options ? options.input : referenced.input;
18
-
19
- // TODO: this should also receive `src`
20
- const actorRef = createActor(referenced.src, {
17
+ const actorRef = createActor(logic, {
21
18
  id: options.id,
22
19
  parent: actorScope.self,
23
20
  input: typeof input === 'function' ? input({
@@ -257,7 +254,7 @@ function pure(getActions) {
257
254
 
258
255
  // TODO: remove once TS fixes this type-widening issue
259
256
 
260
- // TODO: replace with AnyMachineSnapshot
257
+ /** @deprecated use `AnyMachineSnapshot` instead */
261
258
 
262
259
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
263
260
 
@@ -1,5 +1,4 @@
1
- import { k as cloneMachineSnapshot, e as evaluateGuard } from './raise-d2084327.esm.js';
2
- import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, v as XSTATE_ERROR } from './interpreter-3d0c0ff2.esm.js';
1
+ import { T as ProcessingStatus, U as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, V as XSTATE_ERROR } from './raise-5854eaca.esm.js';
3
2
 
4
3
  function createSpawner(actorScope, {
5
4
  machine,
@@ -7,17 +6,15 @@ function createSpawner(actorScope, {
7
6
  }, event, spawnedChildren) {
8
7
  const spawn = (src, options = {}) => {
9
8
  const {
10
- systemId
9
+ systemId,
10
+ input
11
11
  } = options;
12
12
  if (typeof src === 'string') {
13
- const referenced = resolveReferencedActor(machine, src);
14
- if (!referenced) {
13
+ const logic = resolveReferencedActor(machine, src);
14
+ if (!logic) {
15
15
  throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
16
16
  }
17
- const input = 'input' in options ? options.input : referenced.input;
18
-
19
- // TODO: this should also receive `src`
20
- const actorRef = createActor(referenced.src, {
17
+ const actorRef = createActor(logic, {
21
18
  id: options.id,
22
19
  parent: actorScope.self,
23
20
  input: typeof input === 'function' ? input({
@@ -245,7 +242,7 @@ function pure(getActions) {
245
242
 
246
243
  // TODO: remove once TS fixes this type-widening issue
247
244
 
248
- // TODO: replace with AnyMachineSnapshot
245
+ /** @deprecated use `AnyMachineSnapshot` instead */
249
246
 
250
247
  // TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
251
248
 
@@ -3,9 +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 interpreter = require('./interpreter-b6bdd134.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-6b64c553.cjs.js');
8
- var send = require('./send-85b562d8.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-fb6f017b.cjs.js');
7
+ var send = require('./send-53e5693c.cjs.js');
9
8
  require('../dev/dist/xstate-dev.cjs.js');
10
9
 
11
10
  class SimulatedClock {
@@ -165,12 +164,12 @@ class StateNode {
165
164
  this.key = options._key;
166
165
  this.machine = options._machine;
167
166
  this.path = this.parent ? this.parent.path.concat(this.key) : [];
168
- this.id = this.config.id || [this.machine.id, ...this.path].join(interpreter.STATE_DELIMITER);
167
+ this.id = this.config.id || [this.machine.id, ...this.path].join(guards_dist_xstateGuards.STATE_DELIMITER);
169
168
  this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? 'compound' : this.config.history ? 'history' : 'atomic');
170
169
  this.description = this.config.description;
171
170
  this.order = this.machine.idMap.size;
172
171
  this.machine.idMap.set(this.id, this);
173
- this.states = this.config.states ? interpreter.mapValues(this.config.states, (stateConfig, key) => {
172
+ this.states = this.config.states ? guards_dist_xstateGuards.mapValues(this.config.states, (stateConfig, key) => {
174
173
  const stateNode = new StateNode(stateConfig, {
175
174
  _parent: this,
176
175
  _key: key,
@@ -184,16 +183,16 @@ class StateNode {
184
183
 
185
184
  // History config
186
185
  this.history = this.config.history === true ? 'shallow' : this.config.history || false;
187
- this.entry = interpreter.toArray(this.config.entry).slice();
188
- this.exit = interpreter.toArray(this.config.exit).slice();
186
+ this.entry = guards_dist_xstateGuards.toArray(this.config.entry).slice();
187
+ this.exit = guards_dist_xstateGuards.toArray(this.config.exit).slice();
189
188
  this.meta = this.config.meta;
190
189
  this.output = this.type === 'final' || !this.parent ? this.config.output : undefined;
191
- this.tags = interpreter.toArray(config.tags).slice();
190
+ this.tags = guards_dist_xstateGuards.toArray(config.tags).slice();
192
191
  }
193
192
  _initialize() {
194
193
  this.transitions = guards_dist_xstateGuards.formatTransitions(this);
195
194
  if (this.config.always) {
196
- this.always = interpreter.toTransitionConfigArray(this.config.always).map(t => guards_dist_xstateGuards.formatTransition(this, interpreter.NULL_EVENT, t));
195
+ this.always = guards_dist_xstateGuards.toTransitionConfigArray(this.config.always).map(t => guards_dist_xstateGuards.formatTransition(this, guards_dist_xstateGuards.NULL_EVENT, t));
197
196
  }
198
197
  Object.keys(this.states).forEach(key => {
199
198
  this.states[key]._initialize();
@@ -223,7 +222,7 @@ class StateNode {
223
222
  })
224
223
  } : undefined,
225
224
  history: this.history,
226
- states: interpreter.mapValues(this.states, state => {
225
+ states: guards_dist_xstateGuards.mapValues(this.states, state => {
227
226
  return state.definition;
228
227
  }),
229
228
  on: this.on,
@@ -249,13 +248,13 @@ class StateNode {
249
248
  * The logic invoked as actors by this state node.
250
249
  */
251
250
  get invoke() {
252
- return guards_dist_xstateGuards.memo(this, 'invoke', () => interpreter.toArray(this.config.invoke).map((invokeConfig, i) => {
251
+ return guards_dist_xstateGuards.memo(this, 'invoke', () => guards_dist_xstateGuards.toArray(this.config.invoke).map((invokeConfig, i) => {
253
252
  const {
254
253
  src,
255
254
  systemId
256
255
  } = invokeConfig;
257
- const resolvedId = invokeConfig.id || interpreter.createInvokeId(this.id, i);
258
- const resolvedSrc = typeof src === 'string' ? src : `xstate#${interpreter.createInvokeId(this.id, i)}`;
256
+ const resolvedId = invokeConfig.id || guards_dist_xstateGuards.createInvokeId(this.id, i);
257
+ const resolvedSrc = typeof src === 'string' ? src : `xstate#${guards_dist_xstateGuards.createInvokeId(this.id, i)}`;
259
258
  return {
260
259
  ...invokeConfig,
261
260
  src: resolvedSrc,
@@ -470,7 +469,7 @@ class StateMachine {
470
469
  */
471
470
  transition(state, event, actorScope) {
472
471
  // TODO: handle error events in a better way
473
- if (interpreter.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
472
+ if (guards_dist_xstateGuards.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
474
473
  return guards_dist_xstateGuards.cloneMachineSnapshot(state, {
475
474
  status: 'error',
476
475
  error: event.data
@@ -527,7 +526,7 @@ class StateMachine {
527
526
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
528
527
  */
529
528
  getInitialState(actorScope, input) {
530
- const initEvent = interpreter.createInitEvent(input); // TODO: fix;
529
+ const initEvent = guards_dist_xstateGuards.createInitEvent(input); // TODO: fix;
531
530
  const internalQueue = [];
532
531
  const preInitialState = this.getPreInitialState(actorScope, initEvent, internalQueue);
533
532
  const nextState = guards_dist_xstateGuards.microstep([{
@@ -551,7 +550,7 @@ class StateMachine {
551
550
  });
552
551
  }
553
552
  getStateNodeById(stateId) {
554
- const fullPath = stateId.split(interpreter.STATE_DELIMITER);
553
+ const fullPath = stateId.split(guards_dist_xstateGuards.STATE_DELIMITER);
555
554
  const relativePath = fullPath.slice(1);
556
555
  const resolvedStateId = guards_dist_xstateGuards.isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];
557
556
  const stateNode = this.idMap.get(resolvedStateId);
@@ -576,12 +575,12 @@ class StateMachine {
576
575
  const actorData = snapshotChildren[actorId];
577
576
  const childState = actorData.state;
578
577
  const src = actorData.src;
579
- const logic = typeof src === 'string' ? interpreter.resolveReferencedActor(this, src)?.src : src;
578
+ const logic = typeof src === 'string' ? guards_dist_xstateGuards.resolveReferencedActor(this, src) : src;
580
579
  if (!logic) {
581
580
  return;
582
581
  }
583
582
  const actorState = logic.restoreState?.(childState, _actorScope);
584
- const actorRef = interpreter.createActor(logic, {
583
+ const actorRef = guards_dist_xstateGuards.createActor(logic, {
585
584
  id: actorId,
586
585
  parent: _actorScope?.self,
587
586
  state: actorState,
@@ -604,7 +603,7 @@ class StateMachine {
604
603
  for (let key in contextPart) {
605
604
  const value = contextPart[key];
606
605
  if (value && typeof value === 'object') {
607
- if ('xstate$$type' in value && value.xstate$$type === interpreter.$$ACTOR_TYPE) {
606
+ if ('xstate$$type' in value && value.xstate$$type === guards_dist_xstateGuards.$$ACTOR_TYPE) {
608
607
  contextPart[key] = children[value.id];
609
608
  continue;
610
609
  }
@@ -700,21 +699,22 @@ exports.fromEventObservable = actors_dist_xstateActors.fromEventObservable;
700
699
  exports.fromObservable = actors_dist_xstateActors.fromObservable;
701
700
  exports.fromPromise = actors_dist_xstateActors.fromPromise;
702
701
  exports.fromTransition = actors_dist_xstateActors.fromTransition;
703
- exports.Actor = interpreter.Actor;
704
- exports.createActor = interpreter.createActor;
705
- exports.interpret = interpreter.interpret;
706
- exports.matchesState = interpreter.matchesState;
707
- exports.pathToStateValue = interpreter.pathToStateValue;
708
- exports.toObserver = interpreter.toObserver;
702
+ exports.Actor = guards_dist_xstateGuards.Actor;
709
703
  exports.and = guards_dist_xstateGuards.and;
710
704
  exports.cancel = guards_dist_xstateGuards.cancel;
705
+ exports.createActor = guards_dist_xstateGuards.createActor;
711
706
  exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
707
+ exports.interpret = guards_dist_xstateGuards.interpret;
708
+ exports.isMachineSnapshot = guards_dist_xstateGuards.isMachineSnapshot;
709
+ exports.matchesState = guards_dist_xstateGuards.matchesState;
712
710
  exports.not = guards_dist_xstateGuards.not;
713
711
  exports.or = guards_dist_xstateGuards.or;
712
+ exports.pathToStateValue = guards_dist_xstateGuards.pathToStateValue;
714
713
  exports.raise = guards_dist_xstateGuards.raise;
715
714
  exports.spawn = guards_dist_xstateGuards.spawn;
716
715
  exports.stateIn = guards_dist_xstateGuards.stateIn;
717
716
  exports.stop = guards_dist_xstateGuards.stop;
717
+ exports.toObserver = guards_dist_xstateGuards.toObserver;
718
718
  exports.SpecialTargets = send.SpecialTargets;
719
719
  exports.assign = send.assign;
720
720
  exports.choose = send.choose;
@@ -20,6 +20,7 @@ export {
20
20
  fromTransition,
21
21
  getStateNodes,
22
22
  interpret,
23
+ isMachineSnapshot,
23
24
  log,
24
25
  matchesState,
25
26
  not,
@@ -3,9 +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 interpreter = require('./interpreter-23e4041c.development.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-8f482ce9.development.cjs.js');
8
- var send = require('./send-cc8f864e.development.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-ed700d14.development.cjs.js');
7
+ var send = require('./send-00466e37.development.cjs.js');
9
8
  require('../dev/dist/xstate-dev.development.cjs.js');
10
9
 
11
10
  class SimulatedClock {
@@ -165,12 +164,12 @@ class StateNode {
165
164
  this.key = options._key;
166
165
  this.machine = options._machine;
167
166
  this.path = this.parent ? this.parent.path.concat(this.key) : [];
168
- this.id = this.config.id || [this.machine.id, ...this.path].join(interpreter.STATE_DELIMITER);
167
+ this.id = this.config.id || [this.machine.id, ...this.path].join(guards_dist_xstateGuards.STATE_DELIMITER);
169
168
  this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? 'compound' : this.config.history ? 'history' : 'atomic');
170
169
  this.description = this.config.description;
171
170
  this.order = this.machine.idMap.size;
172
171
  this.machine.idMap.set(this.id, this);
173
- this.states = this.config.states ? interpreter.mapValues(this.config.states, (stateConfig, key) => {
172
+ this.states = this.config.states ? guards_dist_xstateGuards.mapValues(this.config.states, (stateConfig, key) => {
174
173
  const stateNode = new StateNode(stateConfig, {
175
174
  _parent: this,
176
175
  _key: key,
@@ -184,16 +183,16 @@ class StateNode {
184
183
 
185
184
  // History config
186
185
  this.history = this.config.history === true ? 'shallow' : this.config.history || false;
187
- this.entry = interpreter.toArray(this.config.entry).slice();
188
- this.exit = interpreter.toArray(this.config.exit).slice();
186
+ this.entry = guards_dist_xstateGuards.toArray(this.config.entry).slice();
187
+ this.exit = guards_dist_xstateGuards.toArray(this.config.exit).slice();
189
188
  this.meta = this.config.meta;
190
189
  this.output = this.type === 'final' || !this.parent ? this.config.output : undefined;
191
- this.tags = interpreter.toArray(config.tags).slice();
190
+ this.tags = guards_dist_xstateGuards.toArray(config.tags).slice();
192
191
  }
193
192
  _initialize() {
194
193
  this.transitions = guards_dist_xstateGuards.formatTransitions(this);
195
194
  if (this.config.always) {
196
- this.always = interpreter.toTransitionConfigArray(this.config.always).map(t => guards_dist_xstateGuards.formatTransition(this, interpreter.NULL_EVENT, t));
195
+ this.always = guards_dist_xstateGuards.toTransitionConfigArray(this.config.always).map(t => guards_dist_xstateGuards.formatTransition(this, guards_dist_xstateGuards.NULL_EVENT, t));
197
196
  }
198
197
  Object.keys(this.states).forEach(key => {
199
198
  this.states[key]._initialize();
@@ -223,7 +222,7 @@ class StateNode {
223
222
  })
224
223
  } : undefined,
225
224
  history: this.history,
226
- states: interpreter.mapValues(this.states, state => {
225
+ states: guards_dist_xstateGuards.mapValues(this.states, state => {
227
226
  return state.definition;
228
227
  }),
229
228
  on: this.on,
@@ -249,13 +248,13 @@ class StateNode {
249
248
  * The logic invoked as actors by this state node.
250
249
  */
251
250
  get invoke() {
252
- return guards_dist_xstateGuards.memo(this, 'invoke', () => interpreter.toArray(this.config.invoke).map((invokeConfig, i) => {
251
+ return guards_dist_xstateGuards.memo(this, 'invoke', () => guards_dist_xstateGuards.toArray(this.config.invoke).map((invokeConfig, i) => {
253
252
  const {
254
253
  src,
255
254
  systemId
256
255
  } = invokeConfig;
257
- const resolvedId = invokeConfig.id || interpreter.createInvokeId(this.id, i);
258
- const resolvedSrc = typeof src === 'string' ? src : `xstate#${interpreter.createInvokeId(this.id, i)}`;
256
+ const resolvedId = invokeConfig.id || guards_dist_xstateGuards.createInvokeId(this.id, i);
257
+ const resolvedSrc = typeof src === 'string' ? src : `xstate#${guards_dist_xstateGuards.createInvokeId(this.id, i)}`;
259
258
  return {
260
259
  ...invokeConfig,
261
260
  src: resolvedSrc,
@@ -473,7 +472,7 @@ class StateMachine {
473
472
  */
474
473
  transition(state, event, actorScope) {
475
474
  // TODO: handle error events in a better way
476
- if (interpreter.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
475
+ if (guards_dist_xstateGuards.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
477
476
  return guards_dist_xstateGuards.cloneMachineSnapshot(state, {
478
477
  status: 'error',
479
478
  error: event.data
@@ -530,7 +529,7 @@ class StateMachine {
530
529
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
531
530
  */
532
531
  getInitialState(actorScope, input) {
533
- const initEvent = interpreter.createInitEvent(input); // TODO: fix;
532
+ const initEvent = guards_dist_xstateGuards.createInitEvent(input); // TODO: fix;
534
533
  const internalQueue = [];
535
534
  const preInitialState = this.getPreInitialState(actorScope, initEvent, internalQueue);
536
535
  const nextState = guards_dist_xstateGuards.microstep([{
@@ -554,7 +553,7 @@ class StateMachine {
554
553
  });
555
554
  }
556
555
  getStateNodeById(stateId) {
557
- const fullPath = stateId.split(interpreter.STATE_DELIMITER);
556
+ const fullPath = stateId.split(guards_dist_xstateGuards.STATE_DELIMITER);
558
557
  const relativePath = fullPath.slice(1);
559
558
  const resolvedStateId = guards_dist_xstateGuards.isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];
560
559
  const stateNode = this.idMap.get(resolvedStateId);
@@ -579,12 +578,12 @@ class StateMachine {
579
578
  const actorData = snapshotChildren[actorId];
580
579
  const childState = actorData.state;
581
580
  const src = actorData.src;
582
- const logic = typeof src === 'string' ? interpreter.resolveReferencedActor(this, src)?.src : src;
581
+ const logic = typeof src === 'string' ? guards_dist_xstateGuards.resolveReferencedActor(this, src) : src;
583
582
  if (!logic) {
584
583
  return;
585
584
  }
586
585
  const actorState = logic.restoreState?.(childState, _actorScope);
587
- const actorRef = interpreter.createActor(logic, {
586
+ const actorRef = guards_dist_xstateGuards.createActor(logic, {
588
587
  id: actorId,
589
588
  parent: _actorScope?.self,
590
589
  state: actorState,
@@ -607,7 +606,7 @@ class StateMachine {
607
606
  for (let key in contextPart) {
608
607
  const value = contextPart[key];
609
608
  if (value && typeof value === 'object') {
610
- if ('xstate$$type' in value && value.xstate$$type === interpreter.$$ACTOR_TYPE) {
609
+ if ('xstate$$type' in value && value.xstate$$type === guards_dist_xstateGuards.$$ACTOR_TYPE) {
611
610
  contextPart[key] = children[value.id];
612
611
  continue;
613
612
  }
@@ -706,21 +705,22 @@ exports.fromEventObservable = actors_dist_xstateActors.fromEventObservable;
706
705
  exports.fromObservable = actors_dist_xstateActors.fromObservable;
707
706
  exports.fromPromise = actors_dist_xstateActors.fromPromise;
708
707
  exports.fromTransition = actors_dist_xstateActors.fromTransition;
709
- exports.Actor = interpreter.Actor;
710
- exports.createActor = interpreter.createActor;
711
- exports.interpret = interpreter.interpret;
712
- exports.matchesState = interpreter.matchesState;
713
- exports.pathToStateValue = interpreter.pathToStateValue;
714
- exports.toObserver = interpreter.toObserver;
708
+ exports.Actor = guards_dist_xstateGuards.Actor;
715
709
  exports.and = guards_dist_xstateGuards.and;
716
710
  exports.cancel = guards_dist_xstateGuards.cancel;
711
+ exports.createActor = guards_dist_xstateGuards.createActor;
717
712
  exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
713
+ exports.interpret = guards_dist_xstateGuards.interpret;
714
+ exports.isMachineSnapshot = guards_dist_xstateGuards.isMachineSnapshot;
715
+ exports.matchesState = guards_dist_xstateGuards.matchesState;
718
716
  exports.not = guards_dist_xstateGuards.not;
719
717
  exports.or = guards_dist_xstateGuards.or;
718
+ exports.pathToStateValue = guards_dist_xstateGuards.pathToStateValue;
720
719
  exports.raise = guards_dist_xstateGuards.raise;
721
720
  exports.spawn = guards_dist_xstateGuards.spawn;
722
721
  exports.stateIn = guards_dist_xstateGuards.stateIn;
723
722
  exports.stop = guards_dist_xstateGuards.stop;
723
+ exports.toObserver = guards_dist_xstateGuards.toObserver;
724
724
  exports.SpecialTargets = send.SpecialTargets;
725
725
  exports.assign = send.assign;
726
726
  exports.choose = send.choose;
@@ -20,6 +20,7 @@ export {
20
20
  fromTransition,
21
21
  getStateNodes,
22
22
  interpret,
23
+ isMachineSnapshot,
23
24
  log,
24
25
  matchesState,
25
26
  not,
@@ -1,10 +1,8 @@
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 } from './interpreter-f2620ea7.development.esm.js';
3
- export { A as Actor, d as createActor, e as interpret, f as matchesState, p as pathToStateValue, g as toObserver } from './interpreter-f2620ea7.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, r as resolveStateValue, d as getConfiguration, h as getStateNodes, i as createMachineSnapshot, j as isInFinalState, k as cloneMachineSnapshot, l as macrostep, t as transitionNode, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-51ae36e5.development.esm.js';
5
- export { 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-51ae36e5.development.esm.js';
6
- import { a as assign } from './send-7a350091.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-7a350091.development.esm.js';
2
+ import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, c as memo, e as evaluateGuard, d as createInvokeId, g as getDelayedTransitions, h as formatInitialTransition, i as getCandidates, r as resolveStateValue, j as getConfiguration, k as getStateNodes, l as createMachineSnapshot, n as isInFinalState, o as isErrorActorEvent, p as cloneMachineSnapshot, q as macrostep, s as transitionNode, u as resolveActionsAndContext, v as createInitEvent, w as microstep, x as getInitialStateNodes, y as isStateId, z as getStateNodeByPath, A as getPersistedState, B as resolveReferencedActor, C as createActor, $ as $$ACTOR_TYPE } from './raise-348cc74e.development.esm.js';
3
+ export { D as Actor, J as and, O as cancel, C as createActor, k as getStateNodes, E as interpret, F as isMachineSnapshot, G as matchesState, K as not, L as or, H as pathToStateValue, P as raise, R as spawn, M as stateIn, Q as stop, I as toObserver } from './raise-348cc74e.development.esm.js';
4
+ import { a as assign } from './send-a0193bdb.development.esm.js';
5
+ 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-a0193bdb.development.esm.js';
8
6
  import '../dev/dist/xstate-dev.development.esm.js';
9
7
 
10
8
  class SimulatedClock {
@@ -578,7 +576,7 @@ class StateMachine {
578
576
  const actorData = snapshotChildren[actorId];
579
577
  const childState = actorData.state;
580
578
  const src = actorData.src;
581
- const logic = typeof src === 'string' ? resolveReferencedActor(this, src)?.src : src;
579
+ const logic = typeof src === 'string' ? resolveReferencedActor(this, src) : src;
582
580
  if (!logic) {
583
581
  return;
584
582
  }