xstate 5.0.0-beta.41 → 5.0.0-beta.42

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 +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 +1 -1
  8. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  9. package/actors/dist/xstate-actors.development.esm.js +1 -1
  10. package/actors/dist/xstate-actors.esm.js +1 -1
  11. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  12. package/dist/declarations/src/State.d.ts +35 -42
  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/index.d.ts +3 -4
  16. package/dist/declarations/src/interpreter.d.ts +12 -0
  17. package/dist/declarations/src/stateUtils.d.ts +7 -8
  18. package/dist/declarations/src/types.d.ts +112 -15
  19. package/dist/{interpreter-70ed981b.development.cjs.js → interpreter-23e4041c.development.cjs.js} +23 -10
  20. package/dist/{interpreter-480db258.esm.js → interpreter-3d0c0ff2.esm.js} +24 -10
  21. package/dist/{interpreter-fb2829f1.cjs.js → interpreter-b6bdd134.cjs.js} +23 -10
  22. package/dist/{interpreter-936da690.development.esm.js → interpreter-f2620ea7.development.esm.js} +24 -10
  23. package/dist/{raise-f757be00.development.esm.js → raise-51ae36e5.development.esm.js} +76 -175
  24. package/dist/{raise-beae3fd3.cjs.js → raise-6b64c553.cjs.js} +74 -174
  25. package/dist/{raise-5ab465ed.development.cjs.js → raise-8f482ce9.development.cjs.js} +77 -177
  26. package/dist/{raise-9d6921da.esm.js → raise-d2084327.esm.js} +73 -172
  27. package/dist/{send-a931d1b8.esm.js → send-4e732fa5.esm.js} +5 -3
  28. package/dist/{send-b26e3812.development.esm.js → send-7a350091.development.esm.js} +5 -3
  29. package/dist/{send-ca5f706c.cjs.js → send-85b562d8.cjs.js} +5 -3
  30. package/dist/{send-fb87a01a.development.cjs.js → send-cc8f864e.development.cjs.js} +5 -3
  31. package/dist/xstate.cjs.js +23 -49
  32. package/dist/xstate.cjs.mjs +0 -2
  33. package/dist/xstate.development.cjs.js +23 -49
  34. package/dist/xstate.development.cjs.mjs +0 -2
  35. package/dist/xstate.development.esm.js +27 -51
  36. package/dist/xstate.esm.js +27 -51
  37. package/dist/xstate.umd.min.js +1 -1
  38. package/dist/xstate.umd.min.js.map +1 -1
  39. package/guards/dist/xstate-guards.cjs.js +2 -2
  40. package/guards/dist/xstate-guards.development.cjs.js +2 -2
  41. package/guards/dist/xstate-guards.development.esm.js +2 -2
  42. package/guards/dist/xstate-guards.esm.js +2 -2
  43. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  44. package/package.json +1 -1
  45. package/dist/declarations/src/mapState.d.ts +0 -3
@@ -2,18 +2,17 @@ export * from "./actions.js";
2
2
  export * from "./actors/index.js";
3
3
  export { SimulatedClock } from "./SimulatedClock.js";
4
4
  export { type Spawner } from "./spawn.js";
5
- export { StateMachine, type MachineSnapshot } from "./StateMachine.js";
5
+ export { StateMachine } from "./StateMachine.js";
6
6
  export { getStateNodes } from "./stateUtils.js";
7
7
  export * from "./typegenTypes.js";
8
8
  export * from "./types.js";
9
9
  export { waitFor } from "./waitFor.js";
10
10
  import { Actor, createActor, interpret, Interpreter } from "./interpreter.js";
11
11
  import { createMachine } from "./Machine.js";
12
- import { mapState } from "./mapState.js";
13
- import { State } from "./State.js";
12
+ export { type MachineSnapshot } from "./State.js";
14
13
  import { StateNode } from "./StateNode.js";
15
14
  export { matchesState, pathToStateValue, toObserver } from "./utils.js";
16
- export { Actor, createActor, createMachine, interpret, mapState, State, StateNode, type Interpreter };
15
+ export { Actor, createActor, createMachine, interpret, StateNode, type Interpreter };
17
16
  export type { InspectedActorEvent, InspectedEventEvent, InspectedSnapshotEvent, InspectionEvent } from "./system.js";
18
17
  export { and, not, or, stateIn } from "./guards.js";
19
18
  declare global {
@@ -136,6 +136,18 @@ export declare class Actor<TLogic extends AnyActorLogic> implements ActorRef<Eve
136
136
  xstate$$type: number;
137
137
  id: string;
138
138
  };
139
+ /**
140
+ * Obtain the internal state of the actor, which can be persisted.
141
+ *
142
+ * @remarks
143
+ * The internal state can be persisted from any actor, not only machines.
144
+ *
145
+ * 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.
146
+ *
147
+ * Can be restored with {@link ActorOptions.state}
148
+ *
149
+ * @see https://stately.ai/docs/persistence
150
+ */
139
151
  getPersistedState(): Snapshot<unknown>;
140
152
  [symbolObservable](): InteropSubscribable<SnapshotFrom<TLogic>>;
141
153
  /**
@@ -1,4 +1,4 @@
1
- import { State } from "./State.js";
1
+ import { MachineSnapshot } from "./State.js";
2
2
  import type { StateNode } from "./StateNode.js";
3
3
  import { AnyEventObject, AnyHistoryValue, AnyState, AnyStateNode, AnyTransitionDefinition, DelayedTransitionDefinition, EventObject, InitialTransitionConfig, InitialTransitionDefinition, MachineContext, StateValue, StateValueMap, TransitionDefinition, TODO, UnknownAction, AnyTransitionConfig, AnyActorScope } from "./types.js";
4
4
  type Configuration<TContext extends MachineContext, TE extends EventObject> = Iterable<StateNode<TContext, TE>>;
@@ -34,13 +34,13 @@ export declare function getStateNodeByPath(stateNode: AnyStateNode, statePath: s
34
34
  /**
35
35
  * Returns the state nodes represented by the current state value.
36
36
  *
37
- * @param state The state value or State instance
37
+ * @param stateValue The state value or State instance
38
38
  */
39
- export declare function getStateNodes<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, state: StateValue | State<TContext, TEvent, TODO, TODO, TODO>): Array<AnyStateNode>;
40
- export declare function transitionAtomicNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: string, state: State<TContext, TEvent, TODO, TODO, TODO>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
41
- export declare function transitionCompoundNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValueMap, state: State<TContext, TEvent, TODO, TODO, TODO>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
42
- export declare function transitionParallelNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValueMap, state: State<TContext, TEvent, TODO, TODO, TODO>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
43
- export declare function transitionNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValue, state: State<TContext, TEvent, TODO, TODO, TODO>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
39
+ export declare function getStateNodes<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValue): Array<AnyStateNode>;
40
+ export declare function transitionAtomicNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: string, state: MachineSnapshot<TContext, TEvent, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
41
+ export declare function transitionCompoundNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValueMap, state: MachineSnapshot<TContext, TEvent, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
42
+ export declare function transitionParallelNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValueMap, state: MachineSnapshot<TContext, TEvent, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
43
+ export declare function transitionNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValue, state: MachineSnapshot<TContext, TEvent, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
44
44
  export declare function removeConflictingTransitions(enabledTransitions: Array<AnyTransitionDefinition>, configuration: Set<AnyStateNode>, historyValue: AnyHistoryValue): Array<AnyTransitionDefinition>;
45
45
  /**
46
46
  * https://www.w3.org/TR/scxml/#microstepProcedure
@@ -58,5 +58,4 @@ export declare function macrostep(state: AnyState, event: EventObject, actorScop
58
58
  */
59
59
  export declare function resolveStateValue(rootNode: AnyStateNode, stateValue: StateValue): StateValue;
60
60
  export declare function stateValuesEqual(a: StateValue | undefined, b: StateValue | undefined): boolean;
61
- export declare function getInitialConfiguration(rootNode: AnyStateNode): AnyStateNode[];
62
61
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { StateNode } from "./StateNode.js";
2
- import type { State } from "./State.js";
2
+ import type { MachineSnapshot } from "./State.js";
3
3
  import type { Clock, Actor } from "./interpreter.js";
4
- import type { MachineSnapshot, StateMachine } from "./StateMachine.js";
4
+ import type { StateMachine } from "./StateMachine.js";
5
5
  import { TypegenDisabled, ResolveTypegenMeta, TypegenConstraint, MarkAllImplementationsAsProvided, AreAllImplementationsAssumedToBeProvided } from "./typegenTypes.js";
6
6
  import { PromiseActorLogic } from "./actors/promise.js";
7
7
  import { Guard, GuardPredicate, UnknownGuard } from "./guards.js";
@@ -347,11 +347,7 @@ export interface StateMachineDefinition<TContext extends MachineContext, TEvent
347
347
  }
348
348
  export type AnyStateNode = StateNode<any, any>;
349
349
  export type AnyStateNodeDefinition = StateNodeDefinition<any, any>;
350
- export type AnyState = State<any, // context
351
- any, // event
352
- any, // actor
353
- any, // tags
354
- any>;
350
+ export type AnyState = MachineSnapshot<any, any, any, any, any, any>;
355
351
  export type AnyStateMachine = StateMachine<any, any, any, any, any, any, any, any, any, // delays
356
352
  any>;
357
353
  export type AnyStateConfig = StateConfig<any, AnyEventObject>;
@@ -546,22 +542,37 @@ export interface StateLike<TContext extends MachineContext> {
546
542
  event: EventObject;
547
543
  }
548
544
  export interface StateConfig<TContext extends MachineContext, TEvent extends EventObject> {
549
- value: StateValue;
550
545
  context: TContext;
551
546
  historyValue?: HistoryValue<TContext, TEvent>;
552
- meta?: any;
553
- configuration?: Array<StateNode<TContext, TEvent>>;
547
+ configuration: Array<StateNode<TContext, TEvent>>;
554
548
  children: Record<string, ActorRef<any, any>>;
555
549
  status: 'active' | 'done' | 'error' | 'stopped';
556
550
  output?: any;
557
551
  error?: unknown;
558
- tags?: Set<string>;
559
552
  machine?: StateMachine<TContext, TEvent, any, any, any, any, any, any, any>;
560
553
  }
561
554
  export interface ActorOptions<TLogic extends AnyActorLogic> {
555
+ /**
556
+ * The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
557
+ *
558
+ * @remarks
559
+ * You can create your own “clock”. The clock interface is an object with two functions/methods:
560
+ *
561
+ * - `setTimeout` - same arguments as `window.setTimeout(fn, timeout)`
562
+ * - `clearTimeout` - same arguments as `window.clearTimeout(id)`
563
+ *
564
+ * By default, the native `setTimeout` and `clearTimeout` functions are used.
565
+ *
566
+ * For testing, XState provides `SimulatedClock`.
567
+ *
568
+ * @see {@link Clock}
569
+ * @see {@link SimulatedClock}
570
+ */
562
571
  clock?: Clock;
572
+ /**
573
+ * Specifies the logger to be used for log(...) actions. Defaults to the native console.log method.
574
+ */
563
575
  logger?: (...args: any[]) => void;
564
- parent?: ActorRef<any, any>;
565
576
  /**
566
577
  * The custom `id` for referencing this service.
567
578
  */
@@ -572,7 +583,6 @@ export interface ActorOptions<TLogic extends AnyActorLogic> {
572
583
  * Default: `false`
573
584
  */
574
585
  devTools?: boolean | DevToolsAdapter;
575
- sync?: boolean;
576
586
  /**
577
587
  * The system ID to register this actor under
578
588
  */
@@ -581,11 +591,98 @@ export interface ActorOptions<TLogic extends AnyActorLogic> {
581
591
  * The input data to pass to the actor.
582
592
  */
583
593
  input?: InputFrom<TLogic>;
594
+ /**
595
+ * Initializes actor logic from a specific persisted internal state.
596
+ *
597
+ * @remarks
598
+ *
599
+ * If the state is compatible with the actor logic, when the actor is started it will be at that persisted state.
600
+ * Actions from machine actors will not be re-executed, because they are assumed to have been already executed.
601
+ * However, invocations will be restarted, and spawned actors will be restored recursively.
602
+ *
603
+ * Can be generated with {@link Actor.getPersistedState}.
604
+ *
605
+ * @see https://stately.ai/docs/persistence
606
+ */
584
607
  state?: any;
585
608
  /**
586
609
  * The source definition.
587
610
  */
588
611
  src?: string | AnyActorLogic;
612
+ /**
613
+ * A callback function or observer object which can be used to inspect actor system updates.
614
+ *
615
+ * @remarks
616
+ * If a callback function is provided, it can accept an inspection event argument. The types of inspection events that can be observed include:
617
+ *
618
+ * - `@xstate.actor` - An actor ref has been created in the system
619
+ * - `@xstate.event` - An event was sent from a source actor ref to a target actor ref in the system
620
+ * - `@xstate.snapshot` - An actor ref emitted a snapshot due to a received event
621
+ *
622
+ * @example
623
+ * ```ts
624
+ * import { createMachine } from 'xstate';
625
+ *
626
+ * const machine = createMachine({
627
+ * // ...
628
+ * });
629
+ *
630
+ * const actor = createActor(machine, {
631
+ * inspect: (inspectionEvent) => {
632
+ * if (inspectionEvent.actorRef === actor) {
633
+ * // This event is for the root actor
634
+ * }
635
+ *
636
+ * if (inspectionEvent.type === '@xstate.actor') {
637
+ * console.log(inspectionEvent.actorRef);
638
+ * }
639
+ *
640
+ * if (inspectionEvent.type === '@xstate.event') {
641
+ * console.log(inspectionEvent.sourceRef);
642
+ * console.log(inspectionEvent.actorRef);
643
+ * console.log(inspectionEvent.event);
644
+ * }
645
+ *
646
+ * if (inspectionEvent.type === '@xstate.snapshot') {
647
+ * console.log(inspectionEvent.actorRef);
648
+ * console.log(inspectionEvent.event);
649
+ * console.log(inspectionEvent.snapshot);
650
+ * }
651
+ * }
652
+ * });
653
+ * ```
654
+ *
655
+ * Alternately, an observer object (`{ next?, error?, complete? }`) can be provided:
656
+ *
657
+ * @example
658
+ * ```ts
659
+ * const actor = createActor(machine, {
660
+ * inspect: {
661
+ * next: (inspectionEvent) => {
662
+ * if (inspectionEvent.actorRef === actor) {
663
+ * // This event is for the root actor
664
+ * }
665
+ *
666
+ * if (inspectionEvent.type === '@xstate.actor') {
667
+ * console.log(inspectionEvent.actorRef);
668
+ * }
669
+ *
670
+ * if (inspectionEvent.type === '@xstate.event') {
671
+ * console.log(inspectionEvent.sourceRef);
672
+ * console.log(inspectionEvent.actorRef);
673
+ * console.log(inspectionEvent.event);
674
+ * }
675
+ *
676
+ * if (inspectionEvent.type === '@xstate.snapshot') {
677
+ * console.log(inspectionEvent.actorRef);
678
+ * console.log(inspectionEvent.event);
679
+ * console.log(inspectionEvent.snapshot);
680
+ * }
681
+ * }
682
+ * }
683
+ * });
684
+ * ```
685
+ */
589
686
  inspect?: Observer<InspectionEvent> | ((inspectionEvent: InspectionEvent) => void);
590
687
  }
591
688
  export type AnyActor = Actor<any>;
@@ -697,9 +794,9 @@ any, // input
697
794
  any>;
698
795
  export type SnapshotFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer _, infer TSnapshot> ? TSnapshot : R extends Actor<infer TLogic> ? SnapshotFrom<TLogic> : R extends StateMachine<infer _TContext, infer _TEvent, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TTag, infer _TInput, infer _TOutput, infer _TResolvedTypesMeta> ? StateFrom<R> : R extends ActorLogic<any, any, any, any> ? ReturnType<R['transition']> : R extends ActorScope<infer TSnapshot, infer _, infer __> ? TSnapshot : never : never;
699
796
  export type EventFromLogic<TLogic extends ActorLogic<any, any, any, any>> = TLogic extends ActorLogic<infer _, infer TEvent, infer __, infer _____> ? TEvent : never;
700
- type ResolveEventType<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer _TContext, infer TEvent, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TTag, infer _TInput, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends State<infer _TContext, infer TEvent, infer _TActor, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends ActorRef<infer TEvent, infer _> ? TEvent : never : never;
797
+ type ResolveEventType<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer _TContext, infer TEvent, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TTag, infer _TInput, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends MachineSnapshot<infer _TContext, infer TEvent, infer _TActor, infer _TTag, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends ActorRef<infer TEvent, infer _> ? TEvent : never : never;
701
798
  export type EventFrom<T, K extends Prop<TEvent, 'type'> = never, TEvent extends EventObject = ResolveEventType<T>> = IsNever<K> extends true ? TEvent : ExtractEvent<TEvent, K>;
702
- export type ContextFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer _TEvent, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TTag, infer _TInput, infer _TOutput, infer _TTypesMeta> ? TContext : R extends State<infer TContext, infer _TEvent, infer _TActor, infer _TOutput, infer _TResolvedTypesMeta> ? TContext : R extends Actor<infer TActorLogic> ? TActorLogic extends StateMachine<infer TContext, infer _TEvent, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TTag, infer _TInput, infer _TOutput, infer _TTypesMeta> ? TContext : never : never : never;
799
+ export type ContextFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer _TEvent, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TTag, infer _TInput, infer _TOutput, infer _TTypesMeta> ? TContext : R extends MachineSnapshot<infer TContext, infer _TEvent, infer _TActor, infer _TTag, infer _TOutput, infer _TResolvedTypesMeta> ? TContext : R extends Actor<infer TActorLogic> ? TActorLogic extends StateMachine<infer TContext, infer _TEvent, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TTag, infer _TInput, infer _TOutput, infer _TTypesMeta> ? TContext : never : never : never;
703
800
  export type InferEvent<E extends EventObject> = {
704
801
  [T in E['type']]: {
705
802
  type: T;
@@ -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`.
@@ -811,6 +811,20 @@ class Actor {
811
811
  id: this.id
812
812
  };
813
813
  }
814
+
815
+ /**
816
+ * Obtain the internal state of the actor, which can be persisted.
817
+ *
818
+ * @remarks
819
+ * The internal state can be persisted from any actor, not only machines.
820
+ *
821
+ * 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.
822
+ *
823
+ * Can be restored with {@link ActorOptions.state}
824
+ *
825
+ * @see https://stately.ai/docs/persistence
826
+ */
827
+
814
828
  getPersistedState(options) {
815
829
  return this.logic.getPersistedState(this._state, options);
816
830
  }
@@ -888,5 +902,4 @@ exports.resolveReferencedActor = resolveReferencedActor;
888
902
  exports.toArray = toArray;
889
903
  exports.toObserver = toObserver;
890
904
  exports.toStatePath = toStatePath;
891
- exports.toStateValue = toStateValue;
892
905
  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`.
@@ -798,6 +798,20 @@ class Actor {
798
798
  id: this.id
799
799
  };
800
800
  }
801
+
802
+ /**
803
+ * Obtain the internal state of the actor, which can be persisted.
804
+ *
805
+ * @remarks
806
+ * The internal state can be persisted from any actor, not only machines.
807
+ *
808
+ * 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.
809
+ *
810
+ * Can be restored with {@link ActorOptions.state}
811
+ *
812
+ * @see https://stately.ai/docs/persistence
813
+ */
814
+
801
815
  getPersistedState(options) {
802
816
  return this.logic.getPersistedState(this._state, options);
803
817
  }
@@ -847,4 +861,4 @@ const interpret = createActor;
847
861
  * @deprecated Use `Actor` instead.
848
862
  */
849
863
 
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 };
864
+ 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 };
@@ -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`.
@@ -800,6 +800,20 @@ class Actor {
800
800
  id: this.id
801
801
  };
802
802
  }
803
+
804
+ /**
805
+ * Obtain the internal state of the actor, which can be persisted.
806
+ *
807
+ * @remarks
808
+ * The internal state can be persisted from any actor, not only machines.
809
+ *
810
+ * 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.
811
+ *
812
+ * Can be restored with {@link ActorOptions.state}
813
+ *
814
+ * @see https://stately.ai/docs/persistence
815
+ */
816
+
803
817
  getPersistedState(options) {
804
818
  return this.logic.getPersistedState(this._state, options);
805
819
  }
@@ -877,5 +891,4 @@ exports.resolveReferencedActor = resolveReferencedActor;
877
891
  exports.toArray = toArray;
878
892
  exports.toObserver = toObserver;
879
893
  exports.toStatePath = toStatePath;
880
- exports.toStateValue = toStateValue;
881
894
  exports.toTransitionConfigArray = toTransitionConfigArray;
@@ -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`.
@@ -809,6 +809,20 @@ class Actor {
809
809
  id: this.id
810
810
  };
811
811
  }
812
+
813
+ /**
814
+ * Obtain the internal state of the actor, which can be persisted.
815
+ *
816
+ * @remarks
817
+ * The internal state can be persisted from any actor, not only machines.
818
+ *
819
+ * 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.
820
+ *
821
+ * Can be restored with {@link ActorOptions.state}
822
+ *
823
+ * @see https://stately.ai/docs/persistence
824
+ */
825
+
812
826
  getPersistedState(options) {
813
827
  return this.logic.getPersistedState(this._state, options);
814
828
  }
@@ -858,4 +872,4 @@ const interpret = createActor;
858
872
  * @deprecated Use `Actor` instead.
859
873
  */
860
874
 
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 };
875
+ 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 };