xstate 5.0.0-beta.41 → 5.0.0-beta.43

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 (48) hide show
  1. package/actions/dist/xstate-actions.cjs.js +3 -3
  2. package/actions/dist/xstate-actions.development.cjs.js +3 -3
  3. package/actions/dist/xstate-actions.development.esm.js +3 -3
  4. package/actions/dist/xstate-actions.esm.js +3 -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 +45 -1
  8. package/actors/dist/xstate-actors.development.cjs.js +45 -1
  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.map +1 -1
  12. package/dist/declarations/src/State.d.ts +36 -43
  13. package/dist/declarations/src/StateMachine.d.ts +12 -29
  14. package/dist/declarations/src/StateNode.d.ts +2 -2
  15. package/dist/declarations/src/actions/spawn.d.ts +3 -3
  16. package/dist/declarations/src/actors/promise.d.ts +53 -0
  17. package/dist/declarations/src/index.d.ts +3 -4
  18. package/dist/declarations/src/interpreter.d.ts +12 -0
  19. package/dist/declarations/src/stateUtils.d.ts +7 -8
  20. package/dist/declarations/src/types.d.ts +153 -21
  21. package/dist/declarations/src/utils.d.ts +2 -8
  22. package/dist/{interpreter-fb2829f1.cjs.js → interpreter-36d5556e.cjs.js} +25 -19
  23. package/dist/{interpreter-70ed981b.development.cjs.js → interpreter-4e8e2a0d.development.cjs.js} +25 -19
  24. package/dist/{interpreter-480db258.esm.js → interpreter-63c80754.esm.js} +26 -19
  25. package/dist/{interpreter-936da690.development.esm.js → interpreter-80eb3bec.development.esm.js} +26 -19
  26. package/dist/{raise-5ab465ed.development.cjs.js → raise-23dea0d7.development.cjs.js} +101 -188
  27. package/dist/{raise-9d6921da.esm.js → raise-8dc8e1aa.esm.js} +95 -181
  28. package/dist/{raise-beae3fd3.cjs.js → raise-e0fe5c2d.cjs.js} +96 -183
  29. package/dist/{raise-f757be00.development.esm.js → raise-f4ad5a87.development.esm.js} +100 -186
  30. package/dist/{send-fb87a01a.development.cjs.js → send-0174c155.development.cjs.js} +10 -10
  31. package/dist/{send-b26e3812.development.esm.js → send-5d129d95.development.esm.js} +10 -10
  32. package/dist/{send-a931d1b8.esm.js → send-84e2e742.esm.js} +10 -10
  33. package/dist/{send-ca5f706c.cjs.js → send-87bbaaab.cjs.js} +10 -10
  34. package/dist/xstate.cjs.js +24 -50
  35. package/dist/xstate.cjs.mjs +0 -2
  36. package/dist/xstate.development.cjs.js +24 -50
  37. package/dist/xstate.development.cjs.mjs +0 -2
  38. package/dist/xstate.development.esm.js +28 -52
  39. package/dist/xstate.esm.js +28 -52
  40. package/dist/xstate.umd.min.js +1 -1
  41. package/dist/xstate.umd.min.js.map +1 -1
  42. package/guards/dist/xstate-guards.cjs.js +2 -2
  43. package/guards/dist/xstate-guards.development.cjs.js +2 -2
  44. package/guards/dist/xstate-guards.development.esm.js +2 -2
  45. package/guards/dist/xstate-guards.esm.js +2 -2
  46. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  47. package/package.json +1 -1
  48. package/dist/declarations/src/mapState.d.ts +0 -3
@@ -1,4 +1,4 @@
1
- import { AnyActorLogic, AnyState } from "./index.js";
1
+ import { AnyState } from "./index.js";
2
2
  import type { StateNode } from "./StateNode.js";
3
3
  import type { ActorLogic, AnyEventObject, EventObject, MachineContext, Mapper, Observer, ErrorActorEvent, SingleOrArray, StateLike, StateValue, Subscribable, TransitionConfigTarget, AnyActorRef, AnyTransitionConfig, NonReducibleUnknown, AnyStateMachine } from "./types.js";
4
4
  export declare function keys<T extends object>(value: T): Array<keyof T & string>;
@@ -39,10 +39,4 @@ export declare function normalizeTarget<TContext extends MachineContext, TEvent
39
39
  export declare function reportUnhandledExceptionOnInvocation(originalError: any, currentError: any, id: string): void;
40
40
  export declare function toObserver<T>(nextHandler?: Observer<T> | ((value: T) => void), errorHandler?: (error: any) => void, completionHandler?: () => void): Observer<T>;
41
41
  export declare function createInvokeId(stateNodeId: string, index: number): string;
42
- export declare function resolveReferencedActor(machine: AnyStateMachine, src: string): {
43
- src: AnyActorLogic;
44
- input: NonReducibleUnknown | Mapper<any, any, unknown, any>;
45
- } | {
46
- src: any;
47
- input: undefined;
48
- } | undefined;
42
+ export declare function resolveReferencedActor(machine: AnyStateMachine, src: string): any;
@@ -2,15 +2,6 @@
2
2
 
3
3
  var dev_dist_xstateDev = require('../dev/dist/xstate-dev.cjs.js');
4
4
 
5
- const STATE_DELIMITER = '.';
6
- const TARGETLESS_KEY = '';
7
- const NULL_EVENT = '';
8
- const STATE_IDENTIFIER = '#';
9
- const WILDCARD = '*';
10
- const XSTATE_INIT = 'xstate.init';
11
- const XSTATE_ERROR = 'xstate.error';
12
- const XSTATE_STOP = 'xstate.stop';
13
-
14
5
  class Mailbox {
15
6
  constructor(_process) {
16
7
  this._process = _process;
@@ -58,6 +49,15 @@ class Mailbox {
58
49
  }
59
50
  }
60
51
 
52
+ const STATE_DELIMITER = '.';
53
+ const TARGETLESS_KEY = '';
54
+ const NULL_EVENT = '';
55
+ const STATE_IDENTIFIER = '#';
56
+ const WILDCARD = '*';
57
+ const XSTATE_INIT = 'xstate.init';
58
+ const XSTATE_ERROR = 'xstate.error';
59
+ const XSTATE_STOP = 'xstate.stop';
60
+
61
61
  /**
62
62
  * Returns an event that represents an implicit event that
63
63
  * is sent after the specified `delay`.
@@ -320,16 +320,9 @@ function resolveReferencedActor(machine, src) {
320
320
  const [, indexStr] = src.match(/\[(\d+)\]$/);
321
321
  const node = machine.getStateNodeById(src.slice(7, -(indexStr.length + 2)));
322
322
  const invokeConfig = node.config.invoke;
323
- return {
324
- src: (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src,
325
- input: undefined
326
- };
323
+ return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
327
324
  }
328
- const referenced = machine.implementations.actors[src];
329
- return referenced ? 'transition' in referenced ? {
330
- src: referenced,
331
- input: undefined
332
- } : referenced : undefined;
325
+ return machine.implementations.actors[src];
333
326
  }
334
327
 
335
328
  const $$ACTOR_TYPE = 1;
@@ -800,6 +793,20 @@ class Actor {
800
793
  id: this.id
801
794
  };
802
795
  }
796
+
797
+ /**
798
+ * Obtain the internal state of the actor, which can be persisted.
799
+ *
800
+ * @remarks
801
+ * The internal state can be persisted from any actor, not only machines.
802
+ *
803
+ * Note that the persisted state is not the same as the snapshot from {@link Actor.getSnapshot}. Persisted state represents the internal state of the actor, while snapshots represent the actor's last emitted value.
804
+ *
805
+ * Can be restored with {@link ActorOptions.state}
806
+ *
807
+ * @see https://stately.ai/docs/persistence
808
+ */
809
+
803
810
  getPersistedState(options) {
804
811
  return this.logic.getPersistedState(this._state, options);
805
812
  }
@@ -877,5 +884,4 @@ exports.resolveReferencedActor = resolveReferencedActor;
877
884
  exports.toArray = toArray;
878
885
  exports.toObserver = toObserver;
879
886
  exports.toStatePath = toStatePath;
880
- exports.toStateValue = toStateValue;
881
887
  exports.toTransitionConfigArray = toTransitionConfigArray;
@@ -2,15 +2,6 @@
2
2
 
3
3
  var dev_dist_xstateDev = require('../dev/dist/xstate-dev.development.cjs.js');
4
4
 
5
- const STATE_DELIMITER = '.';
6
- const TARGETLESS_KEY = '';
7
- const NULL_EVENT = '';
8
- const STATE_IDENTIFIER = '#';
9
- const WILDCARD = '*';
10
- const XSTATE_INIT = 'xstate.init';
11
- const XSTATE_ERROR = 'xstate.error';
12
- const XSTATE_STOP = 'xstate.stop';
13
-
14
5
  class Mailbox {
15
6
  constructor(_process) {
16
7
  this._process = _process;
@@ -58,6 +49,15 @@ class Mailbox {
58
49
  }
59
50
  }
60
51
 
52
+ const STATE_DELIMITER = '.';
53
+ const TARGETLESS_KEY = '';
54
+ const NULL_EVENT = '';
55
+ const STATE_IDENTIFIER = '#';
56
+ const WILDCARD = '*';
57
+ const XSTATE_INIT = 'xstate.init';
58
+ const XSTATE_ERROR = 'xstate.error';
59
+ const XSTATE_STOP = 'xstate.stop';
60
+
61
61
  /**
62
62
  * Returns an event that represents an implicit event that
63
63
  * is sent after the specified `delay`.
@@ -323,16 +323,9 @@ function resolveReferencedActor(machine, src) {
323
323
  const [, indexStr] = src.match(/\[(\d+)\]$/);
324
324
  const node = machine.getStateNodeById(src.slice(7, -(indexStr.length + 2)));
325
325
  const invokeConfig = node.config.invoke;
326
- return {
327
- src: (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src,
328
- input: undefined
329
- };
326
+ return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
330
327
  }
331
- const referenced = machine.implementations.actors[src];
332
- return referenced ? 'transition' in referenced ? {
333
- src: referenced,
334
- input: undefined
335
- } : referenced : undefined;
328
+ return machine.implementations.actors[src];
336
329
  }
337
330
 
338
331
  const $$ACTOR_TYPE = 1;
@@ -811,6 +804,20 @@ class Actor {
811
804
  id: this.id
812
805
  };
813
806
  }
807
+
808
+ /**
809
+ * Obtain the internal state of the actor, which can be persisted.
810
+ *
811
+ * @remarks
812
+ * The internal state can be persisted from any actor, not only machines.
813
+ *
814
+ * Note that the persisted state is not the same as the snapshot from {@link Actor.getSnapshot}. Persisted state represents the internal state of the actor, while snapshots represent the actor's last emitted value.
815
+ *
816
+ * Can be restored with {@link ActorOptions.state}
817
+ *
818
+ * @see https://stately.ai/docs/persistence
819
+ */
820
+
814
821
  getPersistedState(options) {
815
822
  return this.logic.getPersistedState(this._state, options);
816
823
  }
@@ -888,5 +895,4 @@ exports.resolveReferencedActor = resolveReferencedActor;
888
895
  exports.toArray = toArray;
889
896
  exports.toObserver = toObserver;
890
897
  exports.toStatePath = toStatePath;
891
- exports.toStateValue = toStateValue;
892
898
  exports.toTransitionConfigArray = toTransitionConfigArray;
@@ -1,14 +1,5 @@
1
1
  import { devToolsAdapter } from '../dev/dist/xstate-dev.esm.js';
2
2
 
3
- const STATE_DELIMITER = '.';
4
- const TARGETLESS_KEY = '';
5
- const NULL_EVENT = '';
6
- const STATE_IDENTIFIER = '#';
7
- const WILDCARD = '*';
8
- const XSTATE_INIT = 'xstate.init';
9
- const XSTATE_ERROR = 'xstate.error';
10
- const XSTATE_STOP = 'xstate.stop';
11
-
12
3
  class Mailbox {
13
4
  constructor(_process) {
14
5
  this._process = _process;
@@ -56,6 +47,15 @@ class Mailbox {
56
47
  }
57
48
  }
58
49
 
50
+ const STATE_DELIMITER = '.';
51
+ const TARGETLESS_KEY = '';
52
+ const NULL_EVENT = '';
53
+ const STATE_IDENTIFIER = '#';
54
+ const WILDCARD = '*';
55
+ const XSTATE_INIT = 'xstate.init';
56
+ const XSTATE_ERROR = 'xstate.error';
57
+ const XSTATE_STOP = 'xstate.stop';
58
+
59
59
  /**
60
60
  * Returns an event that represents an implicit event that
61
61
  * is sent after the specified `delay`.
@@ -318,16 +318,9 @@ function resolveReferencedActor(machine, src) {
318
318
  const [, indexStr] = src.match(/\[(\d+)\]$/);
319
319
  const node = machine.getStateNodeById(src.slice(7, -(indexStr.length + 2)));
320
320
  const invokeConfig = node.config.invoke;
321
- return {
322
- src: (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src,
323
- input: undefined
324
- };
321
+ return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
325
322
  }
326
- const referenced = machine.implementations.actors[src];
327
- return referenced ? 'transition' in referenced ? {
328
- src: referenced,
329
- input: undefined
330
- } : referenced : undefined;
323
+ return machine.implementations.actors[src];
331
324
  }
332
325
 
333
326
  const $$ACTOR_TYPE = 1;
@@ -798,6 +791,20 @@ class Actor {
798
791
  id: this.id
799
792
  };
800
793
  }
794
+
795
+ /**
796
+ * Obtain the internal state of the actor, which can be persisted.
797
+ *
798
+ * @remarks
799
+ * The internal state can be persisted from any actor, not only machines.
800
+ *
801
+ * Note that the persisted state is not the same as the snapshot from {@link Actor.getSnapshot}. Persisted state represents the internal state of the actor, while snapshots represent the actor's last emitted value.
802
+ *
803
+ * Can be restored with {@link ActorOptions.state}
804
+ *
805
+ * @see https://stately.ai/docs/persistence
806
+ */
807
+
801
808
  getPersistedState(options) {
802
809
  return this.logic.getPersistedState(this._state, options);
803
810
  }
@@ -847,4 +854,4 @@ const interpret = createActor;
847
854
  * @deprecated Use `Actor` instead.
848
855
  */
849
856
 
850
- export { $$ACTOR_TYPE as $, Actor as A, NULL_EVENT as N, ProcessingStatus as P, STATE_DELIMITER as S, WILDCARD as W, XSTATE_STOP as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, matchesState as e, interpret as f, toObserver as g, createErrorActorEvent as h, isErrorActorEvent as i, toStateValue as j, STATE_IDENTIFIER as k, toStatePath as l, mapValues as m, normalizeTarget as n, createDoneStateEvent as o, pathToStateValue as p, resolveOutput as q, resolveReferencedActor as r, XSTATE_INIT as s, toArray as t, createAfterEvent as u, flatten as v, XSTATE_ERROR as w };
857
+ export { $$ACTOR_TYPE as $, Actor as A, NULL_EVENT as N, ProcessingStatus as P, STATE_DELIMITER as S, WILDCARD as W, XSTATE_STOP as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, interpret as e, matchesState as f, toObserver as g, createErrorActorEvent as h, isErrorActorEvent as i, STATE_IDENTIFIER as j, toStatePath as k, createDoneStateEvent as l, mapValues as m, normalizeTarget as n, resolveOutput as o, pathToStateValue as p, XSTATE_INIT as q, resolveReferencedActor as r, createAfterEvent as s, toArray as t, flatten as u, XSTATE_ERROR as v };
@@ -1,14 +1,5 @@
1
1
  import { devToolsAdapter } from '../dev/dist/xstate-dev.development.esm.js';
2
2
 
3
- const STATE_DELIMITER = '.';
4
- const TARGETLESS_KEY = '';
5
- const NULL_EVENT = '';
6
- const STATE_IDENTIFIER = '#';
7
- const WILDCARD = '*';
8
- const XSTATE_INIT = 'xstate.init';
9
- const XSTATE_ERROR = 'xstate.error';
10
- const XSTATE_STOP = 'xstate.stop';
11
-
12
3
  class Mailbox {
13
4
  constructor(_process) {
14
5
  this._process = _process;
@@ -56,6 +47,15 @@ class Mailbox {
56
47
  }
57
48
  }
58
49
 
50
+ const STATE_DELIMITER = '.';
51
+ const TARGETLESS_KEY = '';
52
+ const NULL_EVENT = '';
53
+ const STATE_IDENTIFIER = '#';
54
+ const WILDCARD = '*';
55
+ const XSTATE_INIT = 'xstate.init';
56
+ const XSTATE_ERROR = 'xstate.error';
57
+ const XSTATE_STOP = 'xstate.stop';
58
+
59
59
  /**
60
60
  * Returns an event that represents an implicit event that
61
61
  * is sent after the specified `delay`.
@@ -321,16 +321,9 @@ function resolveReferencedActor(machine, src) {
321
321
  const [, indexStr] = src.match(/\[(\d+)\]$/);
322
322
  const node = machine.getStateNodeById(src.slice(7, -(indexStr.length + 2)));
323
323
  const invokeConfig = node.config.invoke;
324
- return {
325
- src: (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src,
326
- input: undefined
327
- };
324
+ return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
328
325
  }
329
- const referenced = machine.implementations.actors[src];
330
- return referenced ? 'transition' in referenced ? {
331
- src: referenced,
332
- input: undefined
333
- } : referenced : undefined;
326
+ return machine.implementations.actors[src];
334
327
  }
335
328
 
336
329
  const $$ACTOR_TYPE = 1;
@@ -809,6 +802,20 @@ class Actor {
809
802
  id: this.id
810
803
  };
811
804
  }
805
+
806
+ /**
807
+ * Obtain the internal state of the actor, which can be persisted.
808
+ *
809
+ * @remarks
810
+ * The internal state can be persisted from any actor, not only machines.
811
+ *
812
+ * Note that the persisted state is not the same as the snapshot from {@link Actor.getSnapshot}. Persisted state represents the internal state of the actor, while snapshots represent the actor's last emitted value.
813
+ *
814
+ * Can be restored with {@link ActorOptions.state}
815
+ *
816
+ * @see https://stately.ai/docs/persistence
817
+ */
818
+
812
819
  getPersistedState(options) {
813
820
  return this.logic.getPersistedState(this._state, options);
814
821
  }
@@ -858,4 +865,4 @@ const interpret = createActor;
858
865
  * @deprecated Use `Actor` instead.
859
866
  */
860
867
 
861
- export { $$ACTOR_TYPE as $, Actor as A, NULL_EVENT as N, ProcessingStatus as P, STATE_DELIMITER as S, WILDCARD as W, XSTATE_STOP as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, matchesState as e, interpret as f, toObserver as g, createErrorActorEvent as h, isErrorActorEvent as i, toStateValue as j, STATE_IDENTIFIER as k, toStatePath as l, mapValues as m, normalizeTarget as n, createDoneStateEvent as o, pathToStateValue as p, resolveOutput as q, resolveReferencedActor as r, XSTATE_INIT as s, toArray as t, createAfterEvent as u, flatten as v, XSTATE_ERROR as w };
868
+ export { $$ACTOR_TYPE as $, Actor as A, NULL_EVENT as N, ProcessingStatus as P, STATE_DELIMITER as S, WILDCARD as W, XSTATE_STOP as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, interpret as e, matchesState as f, toObserver as g, createErrorActorEvent as h, isErrorActorEvent as i, STATE_IDENTIFIER as j, toStatePath as k, createDoneStateEvent as l, mapValues as m, normalizeTarget as n, resolveOutput as o, pathToStateValue as p, XSTATE_INIT as q, resolveReferencedActor as r, createAfterEvent as s, toArray as t, flatten as u, XSTATE_ERROR as v };