xstate 5.15.0 → 5.17.0

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 +2 -2
  2. package/actions/dist/xstate-actions.development.cjs.js +2 -2
  3. package/actions/dist/xstate-actions.development.esm.js +2 -2
  4. package/actions/dist/xstate-actions.esm.js +2 -2
  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 +1 -1
  12. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  13. package/dist/{raise-a6298350.cjs.js → State-30c95050.cjs.js} +199 -191
  14. package/dist/{raise-7d030497.development.esm.js → State-34039d2a.development.esm.js} +215 -207
  15. package/dist/{raise-bad6a97b.development.cjs.js → State-a2464a1e.development.cjs.js} +214 -206
  16. package/dist/{raise-2cfe6b8f.esm.js → State-cdbc7940.esm.js} +200 -192
  17. package/dist/declarations/src/State.d.ts +9 -9
  18. package/dist/declarations/src/StateMachine.d.ts +11 -13
  19. package/dist/declarations/src/actions/enqueueActions.d.ts +3 -2
  20. package/dist/declarations/src/actions/stopChild.d.ts +1 -0
  21. package/dist/declarations/src/actors/callback.d.ts +3 -2
  22. package/dist/declarations/src/createActor.d.ts +6 -6
  23. package/dist/declarations/src/index.d.ts +11 -12
  24. package/dist/declarations/src/inspection.d.ts +3 -2
  25. package/dist/declarations/src/setup.d.ts +1 -1
  26. package/dist/declarations/src/stateUtils.d.ts +1 -13
  27. package/dist/declarations/src/system.d.ts +3 -2
  28. package/dist/declarations/src/types.d.ts +9 -2
  29. package/dist/declarations/src/utils.d.ts +1 -5
  30. package/dist/{log-b8c93ee3.cjs.js → log-19086852.cjs.js} +4 -1
  31. package/dist/{log-63de2429.esm.js → log-4a38a98a.esm.js} +4 -1
  32. package/dist/{log-e9953143.development.esm.js → log-62f17756.development.esm.js} +4 -1
  33. package/dist/{log-d2c282d6.development.cjs.js → log-ec36113c.development.cjs.js} +4 -1
  34. package/dist/xstate.cjs.js +92 -92
  35. package/dist/xstate.development.cjs.js +95 -95
  36. package/dist/xstate.development.esm.js +91 -91
  37. package/dist/xstate.esm.js +88 -88
  38. package/dist/xstate.umd.min.js +1 -1
  39. package/dist/xstate.umd.min.js.map +1 -1
  40. package/guards/dist/xstate-guards.cjs.js +1 -1
  41. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  42. package/guards/dist/xstate-guards.development.esm.js +1 -1
  43. package/guards/dist/xstate-guards.esm.js +1 -1
  44. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  45. package/package.json +1 -3
@@ -1,24 +1,23 @@
1
- export * from "./actions.js";
2
- export * from "./actors/index.js";
3
1
  export { SimulatedClock } from "./SimulatedClock.js";
4
- export { type Spawner } from "./spawn.js";
5
2
  export { isMachineSnapshot, type MachineSnapshot } from "./State.js";
6
3
  export { StateMachine } from "./StateMachine.js";
7
- export { getStateNodes } from "./stateUtils.js";
8
- export * from "./types.js";
9
- export { waitFor } from "./waitFor.js";
10
- import { createMachine } from "./createMachine.js";
4
+ export { StateNode } from "./StateNode.js";
5
+ export * from "./actions.js";
6
+ export * from "./actors/index.js";
7
+ export { assertEvent } from "./assert.js";
8
+ export { Actor, createActor, interpret, type Interpreter } from "./createActor.js";
9
+ export { createMachine } from "./createMachine.js";
11
10
  export { getInitialSnapshot, getNextSnapshot } from "./getNextSnapshot.js";
12
- import { Actor, createActor, interpret, Interpreter } from "./createActor.js";
13
- import { StateNode } from "./StateNode.js";
14
11
  export { and, not, or, stateIn } from "./guards.js";
12
+ export type { InspectedActorEvent, InspectedEventEvent, InspectedSnapshotEvent, InspectionEvent } from "./inspection.js";
15
13
  export { setup } from "./setup.js";
14
+ export { type Spawner } from "./spawn.js";
15
+ export { getStateNodes } from "./stateUtils.js";
16
16
  export type { ActorSystem } from "./system.js";
17
- export type { InspectedActorEvent, InspectedEventEvent, InspectedSnapshotEvent, InspectionEvent } from "./inspection.js";
18
17
  export { toPromise } from "./toPromise.js";
18
+ export * from "./types.js";
19
19
  export { getAllOwnEventDescriptors as __unsafe_getAllOwnEventDescriptors, matchesState, pathToStateValue, toObserver } from "./utils.js";
20
- export { Actor, createActor, createMachine, interpret, StateNode, type Interpreter };
21
- export { assertEvent } from "./assert.js";
20
+ export { waitFor } from "./waitFor.js";
22
21
  declare global {
23
22
  interface SymbolConstructor {
24
23
  readonly observable: symbol;
@@ -1,6 +1,6 @@
1
1
  import { AnyActorRef, AnyEventObject, AnyTransitionDefinition, Snapshot } from "./types.js";
2
2
  export type InspectionEvent = InspectedSnapshotEvent | InspectedEventEvent | InspectedActorEvent | InspectedMicrostepEvent | InspectedActionEvent;
3
- export interface BaseInspectionEventProperties {
3
+ interface BaseInspectionEventProperties {
4
4
  rootId: string;
5
5
  /**
6
6
  * The relevant actorRef for the inspection event.
@@ -16,7 +16,7 @@ export interface InspectedSnapshotEvent extends BaseInspectionEventProperties {
16
16
  event: AnyEventObject;
17
17
  snapshot: Snapshot<unknown>;
18
18
  }
19
- export interface InspectedMicrostepEvent extends BaseInspectionEventProperties {
19
+ interface InspectedMicrostepEvent extends BaseInspectionEventProperties {
20
20
  type: '@xstate.microstep';
21
21
  event: AnyEventObject;
22
22
  snapshot: Snapshot<unknown>;
@@ -37,3 +37,4 @@ export interface InspectedEventEvent extends BaseInspectionEventProperties {
37
37
  export interface InspectedActorEvent extends BaseInspectionEventProperties {
38
38
  type: '@xstate.actor';
39
39
  }
40
+ export {};
@@ -50,6 +50,6 @@ TActors extends Record<string, UnknownActorLogic> = {}, TChildrenMap extends Rec
50
50
  } & {
51
51
  [K in RequiredSetupKeys<TChildrenMap>]: unknown;
52
52
  }): {
53
- createMachine: <const TConfig extends MachineConfig<TContext, TEvent, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, TTag, TInput, TOutput, TEmitted, TMeta>>(config: TConfig) => StateMachine<TContext, TEvent, Cast<ToChildren<ToProvidedActor<TChildrenMap, TActors>>, Record<string, AnyActorRef | undefined>>, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, ToStateValue<TConfig>, TTag, TInput, TOutput, TEmitted, TMeta>;
53
+ createMachine: <const TConfig extends MachineConfig<TContext, TEvent, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, TTag, TInput, TOutput, TEmitted, TMeta>>(config: TConfig) => StateMachine<TContext, TEvent, Cast<ToChildren<ToProvidedActor<TChildrenMap, TActors>>, Record<string, AnyActorRef | undefined>>, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, ToStateValue<TConfig>, TTag, TInput, TOutput, TEmitted, TMeta, TConfig>;
54
54
  };
55
55
  export {};
@@ -1,12 +1,9 @@
1
1
  import { MachineSnapshot } from "./State.js";
2
2
  import type { StateNode } from "./StateNode.js";
3
- import { AnyEventObject, AnyHistoryValue, AnyMachineSnapshot, AnyStateNode, AnyTransitionDefinition, DelayedTransitionDefinition, EventObject, InitialTransitionConfig, InitialTransitionDefinition, MachineContext, StateValue, StateValueMap, TransitionDefinition, TODO, UnknownAction, ActionFunction, AnyTransitionConfig, AnyActorScope } from "./types.js";
3
+ import { AnyEventObject, AnyMachineSnapshot, AnyStateNode, AnyTransitionDefinition, DelayedTransitionDefinition, EventObject, InitialTransitionConfig, InitialTransitionDefinition, MachineContext, StateValue, TransitionDefinition, TODO, UnknownAction, ActionFunction, AnyTransitionConfig, AnyActorScope } from "./types.js";
4
4
  type StateNodeIterable<TContext extends MachineContext, TE extends EventObject> = Iterable<StateNode<TContext, TE>>;
5
5
  type AnyStateNodeIterable = StateNodeIterable<any, any>;
6
- type AdjList = Map<AnyStateNode, Array<AnyStateNode>>;
7
- export declare const isAtomicStateNode: (stateNode: StateNode<any, any>) => boolean;
8
6
  export declare function getAllStateNodes(stateNodes: Iterable<AnyStateNode>): Set<AnyStateNode>;
9
- export declare function getAdjList<TContext extends MachineContext, TE extends EventObject>(stateNodes: StateNodeIterable<TContext, TE>): AdjList;
10
7
  export declare function getStateValue(rootNode: AnyStateNode, stateNodes: AnyStateNodeIterable): StateValue;
11
8
  export declare function isInFinalState(stateNodeSet: Set<AnyStateNode>, stateNode: AnyStateNode): boolean;
12
9
  export declare const isStateId: (str: string) => boolean;
@@ -16,11 +13,7 @@ export declare function getDelayedTransitions(stateNode: AnyStateNode): Array<De
16
13
  export declare function formatTransition<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, descriptor: string, transitionConfig: AnyTransitionConfig): AnyTransitionDefinition;
17
14
  export declare function formatTransitions<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode): Map<string, TransitionDefinition<TContext, TEvent>[]>;
18
15
  export declare function formatInitialTransition<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, _target: string | undefined | InitialTransitionConfig<TContext, TEvent, TODO, TODO, TODO, TODO>): InitialTransitionDefinition<TContext, TEvent>;
19
- export declare function resolveTarget(stateNode: AnyStateNode, targets: ReadonlyArray<string | AnyStateNode> | undefined): ReadonlyArray<AnyStateNode> | undefined;
20
- export declare function getInitialStateNodesWithTheirAncestors(stateNode: AnyStateNode): Set<AnyStateNode>;
21
16
  export declare function getInitialStateNodes(stateNode: AnyStateNode): Set<AnyStateNode>;
22
- /** Returns the child state node from its relative `stateKey`, or throws. */
23
- export declare function getStateNode(stateNode: AnyStateNode, stateKey: string): AnyStateNode;
24
17
  /**
25
18
  * Returns the relative state node from the given `statePath`, or throws.
26
19
  *
@@ -33,11 +26,7 @@ export declare function getStateNodeByPath(stateNode: AnyStateNode, statePath: s
33
26
  * @param stateValue The state value or State instance
34
27
  */
35
28
  export declare function getStateNodes<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValue): Array<AnyStateNode>;
36
- export declare function transitionAtomicNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: string, snapshot: MachineSnapshot<TContext, TEvent, any, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
37
- export declare function transitionCompoundNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValueMap, snapshot: MachineSnapshot<TContext, TEvent, any, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
38
- export declare function transitionParallelNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValueMap, snapshot: MachineSnapshot<TContext, TEvent, any, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
39
29
  export declare function transitionNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValue, snapshot: MachineSnapshot<TContext, TEvent, any, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
40
- export declare function removeConflictingTransitions(enabledTransitions: Array<AnyTransitionDefinition>, stateNodeSet: Set<AnyStateNode>, historyValue: AnyHistoryValue): Array<AnyTransitionDefinition>;
41
30
  /** https://www.w3.org/TR/scxml/#microstepProcedure */
42
31
  export declare function microstep<TContext extends MachineContext, TEvent extends EventObject>(transitions: Array<AnyTransitionDefinition>, currentSnapshot: AnyMachineSnapshot, actorScope: AnyActorScope, event: AnyEventObject, isInitial: boolean, internalQueue: Array<AnyEventObject>): AnyMachineSnapshot;
43
32
  export declare let executingCustomAction: ActionFunction<any, any, any, any, any, any, any, any, any> | false;
@@ -53,5 +42,4 @@ export declare function macrostep(snapshot: AnyMachineSnapshot, event: EventObje
53
42
  * @param stateValue The partial state value to resolve.
54
43
  */
55
44
  export declare function resolveStateValue(rootNode: AnyStateNode, stateValue: StateValue): StateValue;
56
- export declare function stateValuesEqual(a: StateValue | undefined, b: StateValue | undefined): boolean;
57
45
  export {};
@@ -1,6 +1,6 @@
1
1
  import { InspectionEvent } from "./inspection.js";
2
2
  import { ActorSystemInfo, AnyActorRef, Observer, EventObject, Subscription } from "./types.js";
3
- export interface ScheduledEvent {
3
+ interface ScheduledEvent {
4
4
  id: string;
5
5
  event: EventObject;
6
6
  startedAt: number;
@@ -12,7 +12,7 @@ export interface Clock {
12
12
  setTimeout(fn: (...args: any[]) => void, timeout: number): any;
13
13
  clearTimeout(id: any): void;
14
14
  }
15
- export interface Scheduler {
15
+ interface Scheduler {
16
16
  schedule(source: AnyActorRef, target: AnyActorRef, event: EventObject, delay: number, id: string | undefined): void;
17
17
  cancel(source: AnyActorRef, id: string): void;
18
18
  cancelAll(actorRef: AnyActorRef): void;
@@ -34,3 +34,4 @@ export declare function createSystem<T extends ActorSystemInfo>(rootActor: AnyAc
34
34
  logger: (...args: any[]) => void;
35
35
  snapshot?: unknown;
36
36
  }): ActorSystem<T>;
37
+ export {};
@@ -366,7 +366,7 @@ export interface StateMachineDefinition<TContext extends MachineContext, TEvent
366
366
  }
367
367
  export type AnyStateNode = StateNode<any, any>;
368
368
  export type AnyStateNodeDefinition = StateNodeDefinition<any, any>;
369
- export type AnyMachineSnapshot = MachineSnapshot<any, any, any, any, any, any, any>;
369
+ export type AnyMachineSnapshot = MachineSnapshot<any, any, any, any, any, any, any, any>;
370
370
  /** @deprecated Use `AnyMachineSnapshot` instead */
371
371
  export type AnyState = AnyMachineSnapshot;
372
372
  export type AnyStateMachine = StateMachine<any, // context
@@ -569,7 +569,7 @@ export interface StateConfig<TContext extends MachineContext, TEvent extends Eve
569
569
  context: TContext;
570
570
  historyValue?: HistoryValue<TContext, TEvent>;
571
571
  children: Record<string, AnyActorRef>;
572
- status: 'active' | 'done' | 'error' | 'stopped';
572
+ status: SnapshotStatus;
573
573
  output?: any;
574
574
  error?: unknown;
575
575
  machine?: StateMachine<TContext, TEvent, any, any, any, any, any, any, any, any, any, any, // TMeta
@@ -777,6 +777,7 @@ export interface ActorScope<TSnapshot extends Snapshot<unknown>, TEvent extends
777
777
  export type AnyActorScope = ActorScope<any, // TSnapshot
778
778
  any, // TEvent
779
779
  AnyActorSystem, any>;
780
+ export type SnapshotStatus = 'active' | 'done' | 'error' | 'stopped';
780
781
  export type Snapshot<TOutput> = {
781
782
  status: 'active';
782
783
  output: undefined;
@@ -891,8 +892,14 @@ export type ToChildren<TActor extends ProvidedActor> = string extends TActor['sr
891
892
  exclude: {};
892
893
  }[undefined extends TActor['id'] ? 'include' : string extends TActor['id'] ? 'include' : 'exclude']>;
893
894
  export type StateSchema = {
895
+ id?: string;
894
896
  states?: Record<string, StateSchema>;
895
897
  };
898
+ export type StateId<TSchema extends StateSchema, TKey extends string = '(machine)', TParentKey extends string | null = null> = (TSchema extends {
899
+ id: string;
900
+ } ? TSchema['id'] : TParentKey extends null ? TKey : `${TParentKey}.${TKey}`) | (TSchema['states'] extends Record<string, any> ? Values<{
901
+ [K in keyof TSchema['states'] & string]: StateId<TSchema['states'][K], K, TParentKey extends string ? `${TParentKey}.${TKey}` : TSchema['id'] extends string ? TSchema['id'] : TKey>;
902
+ }> : never);
896
903
  export interface StateMachineTypes {
897
904
  context: MachineContext;
898
905
  events: EventObject;
@@ -1,17 +1,13 @@
1
1
  import type { StateNode } from "./StateNode.js";
2
- import type { AnyActorLogic, AnyActorRef, AnyEventObject, AnyMachineSnapshot, AnyStateMachine, AnyTransitionConfig, ErrorActorEvent, EventObject, MachineContext, Mapper, NonReducibleUnknown, Observer, SingleOrArray, StateLike, StateValue, TransitionConfigTarget } from "./types.js";
2
+ import type { AnyActorRef, AnyEventObject, AnyMachineSnapshot, AnyStateMachine, AnyTransitionConfig, ErrorActorEvent, EventObject, MachineContext, Mapper, NonReducibleUnknown, Observer, SingleOrArray, StateValue, TransitionConfigTarget } from "./types.js";
3
3
  export declare function matchesState(parentStateId: StateValue, childStateId: StateValue): boolean;
4
4
  export declare function toStatePath(stateId: string | string[]): string[];
5
- export declare function toStateValue(stateValue: StateLike<any> | StateValue): StateValue;
6
5
  export declare function pathToStateValue(statePath: string[]): StateValue;
7
6
  export declare function mapValues<P, O extends Record<string, unknown>>(collection: O, iteratee: (item: O[keyof O], key: keyof O, collection: O, i: number) => P): {
8
7
  [key in keyof O]: P;
9
8
  };
10
- export declare function toArrayStrict<T>(value: readonly T[] | T): readonly T[];
11
9
  export declare function toArray<T>(value: readonly T[] | T | undefined): readonly T[];
12
10
  export declare function resolveOutput<TContext extends MachineContext, TExpressionEvent extends EventObject>(mapper: Mapper<TContext, TExpressionEvent, unknown, EventObject> | NonReducibleUnknown, context: TContext, event: TExpressionEvent, self: AnyActorRef): unknown;
13
- export declare function isActorLogic(value: any): value is AnyActorLogic;
14
- export declare function isArray(value: any): value is readonly any[];
15
11
  export declare function isErrorActorEvent(event: AnyEventObject): event is ErrorActorEvent;
16
12
  export declare function toTransitionConfigArray<TContext extends MachineContext, TEvent extends EventObject>(configLike: SingleOrArray<AnyTransitionConfig | TransitionConfigTarget>): Array<AnyTransitionConfig>;
17
13
  export declare function normalizeTarget<TContext extends MachineContext, TEvent extends EventObject>(target: SingleOrArray<string | StateNode<TContext, TEvent>> | undefined): ReadonlyArray<string | StateNode<TContext, TEvent>> | undefined;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-a6298350.cjs.js');
3
+ var guards_dist_xstateGuards = require('./State-30c95050.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -388,6 +388,9 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
388
388
  // then it fails to typecheck that because `...args` use `string` in place of `TDelay
389
389
  actions.push(sendTo(...args));
390
390
  };
391
+ enqueue.sendParent = (...args) => {
392
+ actions.push(sendParent(...args));
393
+ };
391
394
  enqueue.spawnChild = (...args) => {
392
395
  actions.push(guards_dist_xstateGuards.spawnChild(...args));
393
396
  };
@@ -1,4 +1,4 @@
1
- import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-2cfe6b8f.esm.js';
1
+ import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './State-cdbc7940.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -386,6 +386,9 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
386
386
  // then it fails to typecheck that because `...args` use `string` in place of `TDelay
387
387
  actions.push(sendTo(...args));
388
388
  };
389
+ enqueue.sendParent = (...args) => {
390
+ actions.push(sendParent(...args));
391
+ };
389
392
  enqueue.spawnChild = (...args) => {
390
393
  actions.push(spawnChild(...args));
391
394
  };
@@ -1,4 +1,4 @@
1
- import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as executingCustomAction, W as XSTATE_ERROR, Y as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-7d030497.development.esm.js';
1
+ import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as executingCustomAction, V as cloneMachineSnapshot, W as XSTATE_ERROR, Y as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './State-34039d2a.development.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -417,6 +417,9 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
417
417
  // then it fails to typecheck that because `...args` use `string` in place of `TDelay
418
418
  actions.push(sendTo(...args));
419
419
  };
420
+ enqueue.sendParent = (...args) => {
421
+ actions.push(sendParent(...args));
422
+ };
420
423
  enqueue.spawnChild = (...args) => {
421
424
  actions.push(spawnChild(...args));
422
425
  };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-bad6a97b.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./State-a2464a1e.development.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -419,6 +419,9 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
419
419
  // then it fails to typecheck that because `...args` use `string` in place of `TDelay
420
420
  actions.push(sendTo(...args));
421
421
  };
422
+ enqueue.sendParent = (...args) => {
423
+ actions.push(sendParent(...args));
424
+ };
422
425
  enqueue.spawnChild = (...args) => {
423
426
  actions.push(guards_dist_xstateGuards.spawnChild(...args));
424
427
  };
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var guards_dist_xstateGuards = require('./State-30c95050.cjs.js');
6
+ var log = require('./log-19086852.cjs.js');
5
7
  var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
6
- var guards_dist_xstateGuards = require('./raise-a6298350.cjs.js');
7
- var log = require('./log-b8c93ee3.cjs.js');
8
8
  require('../dev/dist/xstate-dev.cjs.js');
9
9
 
10
10
  class SimulatedClock {
@@ -598,75 +598,35 @@ class StateMachine {
598
598
  }
599
599
  }
600
600
 
601
- const defaultWaitForOptions = {
602
- timeout: Infinity // much more than 10 seconds
603
- };
604
-
605
601
  /**
606
- * Subscribes to an actor ref and waits for its emitted value to satisfy a
607
- * predicate, and then resolves with that value. Will throw if the desired state
608
- * is not reached after an optional timeout. (defaults to Infinity).
602
+ * Asserts that the given event object is of the specified type or types. Throws
603
+ * an error if the event object is not of the specified types.
609
604
  *
610
605
  * @example
611
606
  *
612
- * ```js
613
- * const state = await waitFor(someService, (state) => {
614
- * return state.hasTag('loaded');
615
- * });
607
+ * ```ts
608
+ * // ...
609
+ * entry: ({ event }) => {
610
+ * assertEvent(event, 'doNothing');
611
+ * // event is { type: 'doNothing' }
612
+ * },
613
+ * // ...
614
+ * exit: ({ event }) => {
615
+ * assertEvent(event, 'greet');
616
+ * // event is { type: 'greet'; message: string }
616
617
  *
617
- * state.hasTag('loaded'); // true
618
+ * assertEvent(event, ['greet', 'notify']);
619
+ * // event is { type: 'greet'; message: string }
620
+ * // or { type: 'notify'; message: string; level: 'info' | 'error' }
621
+ * },
618
622
  * ```
619
- *
620
- * @param actorRef The actor ref to subscribe to
621
- * @param predicate Determines if a value matches the condition to wait for
622
- * @param options
623
- * @returns A promise that eventually resolves to the emitted value that matches
624
- * the condition
625
623
  */
626
- function waitFor(actorRef, predicate, options) {
627
- const resolvedOptions = {
628
- ...defaultWaitForOptions,
629
- ...options
630
- };
631
- return new Promise((res, rej) => {
632
- let done = false;
633
- const handle = resolvedOptions.timeout === Infinity ? undefined : setTimeout(() => {
634
- sub.unsubscribe();
635
- rej(new Error(`Timeout of ${resolvedOptions.timeout} ms exceeded`));
636
- }, resolvedOptions.timeout);
637
- const dispose = () => {
638
- clearTimeout(handle);
639
- done = true;
640
- sub?.unsubscribe();
641
- };
642
- function checkEmitted(emitted) {
643
- if (predicate(emitted)) {
644
- dispose();
645
- res(emitted);
646
- }
647
- }
648
- let sub; // avoid TDZ when disposing synchronously
649
-
650
- // See if the current snapshot already matches the predicate
651
- checkEmitted(actorRef.getSnapshot());
652
- if (done) {
653
- return;
654
- }
655
- sub = actorRef.subscribe({
656
- next: checkEmitted,
657
- error: err => {
658
- dispose();
659
- rej(err);
660
- },
661
- complete: () => {
662
- dispose();
663
- rej(new Error(`Actor terminated without satisfying predicate`));
664
- }
665
- });
666
- if (done) {
667
- sub.unsubscribe();
668
- }
669
- });
624
+ function assertEvent(event, type) {
625
+ const types = guards_dist_xstateGuards.toArray(type);
626
+ if (!types.includes(event.type)) {
627
+ const typesText = types.length === 1 ? `type "${types[0]}"` : `one of types "${types.join('", "')}"`;
628
+ throw new Error(`Expected event ${JSON.stringify(event)} to have ${typesText}`);
629
+ }
670
630
  }
671
631
 
672
632
  // this is not 100% accurate since we can't make parallel regions required in the result
@@ -832,43 +792,77 @@ function toPromise(actor) {
832
792
  });
833
793
  }
834
794
 
795
+ const defaultWaitForOptions = {
796
+ timeout: Infinity // much more than 10 seconds
797
+ };
798
+
835
799
  /**
836
- * Asserts that the given event object is of the specified type or types. Throws
837
- * an error if the event object is not of the specified types.
800
+ * Subscribes to an actor ref and waits for its emitted value to satisfy a
801
+ * predicate, and then resolves with that value. Will throw if the desired state
802
+ * is not reached after an optional timeout. (defaults to Infinity).
838
803
  *
839
804
  * @example
840
805
  *
841
- * ```ts
842
- * // ...
843
- * entry: ({ event }) => {
844
- * assertEvent(event, 'doNothing');
845
- * // event is { type: 'doNothing' }
846
- * },
847
- * // ...
848
- * exit: ({ event }) => {
849
- * assertEvent(event, 'greet');
850
- * // event is { type: 'greet'; message: string }
806
+ * ```js
807
+ * const state = await waitFor(someService, (state) => {
808
+ * return state.hasTag('loaded');
809
+ * });
851
810
  *
852
- * assertEvent(event, ['greet', 'notify']);
853
- * // event is { type: 'greet'; message: string }
854
- * // or { type: 'notify'; message: string; level: 'info' | 'error' }
855
- * },
811
+ * state.hasTag('loaded'); // true
856
812
  * ```
813
+ *
814
+ * @param actorRef The actor ref to subscribe to
815
+ * @param predicate Determines if a value matches the condition to wait for
816
+ * @param options
817
+ * @returns A promise that eventually resolves to the emitted value that matches
818
+ * the condition
857
819
  */
858
- function assertEvent(event, type) {
859
- const types = guards_dist_xstateGuards.toArray(type);
860
- if (!types.includes(event.type)) {
861
- const typesText = types.length === 1 ? `type "${types[0]}"` : `one of types "${types.join('", "')}"`;
862
- throw new Error(`Expected event ${JSON.stringify(event)} to have ${typesText}`);
863
- }
820
+ function waitFor(actorRef, predicate, options) {
821
+ const resolvedOptions = {
822
+ ...defaultWaitForOptions,
823
+ ...options
824
+ };
825
+ return new Promise((res, rej) => {
826
+ let done = false;
827
+ const handle = resolvedOptions.timeout === Infinity ? undefined : setTimeout(() => {
828
+ sub.unsubscribe();
829
+ rej(new Error(`Timeout of ${resolvedOptions.timeout} ms exceeded`));
830
+ }, resolvedOptions.timeout);
831
+ const dispose = () => {
832
+ clearTimeout(handle);
833
+ done = true;
834
+ sub?.unsubscribe();
835
+ };
836
+ function checkEmitted(emitted) {
837
+ if (predicate(emitted)) {
838
+ dispose();
839
+ res(emitted);
840
+ }
841
+ }
842
+ let sub; // avoid TDZ when disposing synchronously
843
+
844
+ // See if the current snapshot already matches the predicate
845
+ checkEmitted(actorRef.getSnapshot());
846
+ if (done) {
847
+ return;
848
+ }
849
+ sub = actorRef.subscribe({
850
+ next: checkEmitted,
851
+ error: err => {
852
+ dispose();
853
+ rej(err);
854
+ },
855
+ complete: () => {
856
+ dispose();
857
+ rej(new Error(`Actor terminated without satisfying predicate`));
858
+ }
859
+ });
860
+ if (done) {
861
+ sub.unsubscribe();
862
+ }
863
+ });
864
864
  }
865
865
 
866
- exports.createEmptyActor = actors_dist_xstateActors.createEmptyActor;
867
- exports.fromCallback = actors_dist_xstateActors.fromCallback;
868
- exports.fromEventObservable = actors_dist_xstateActors.fromEventObservable;
869
- exports.fromObservable = actors_dist_xstateActors.fromObservable;
870
- exports.fromPromise = actors_dist_xstateActors.fromPromise;
871
- exports.fromTransition = actors_dist_xstateActors.fromTransition;
872
866
  exports.Actor = guards_dist_xstateGuards.Actor;
873
867
  exports.__unsafe_getAllOwnEventDescriptors = guards_dist_xstateGuards.getAllOwnEventDescriptors;
874
868
  exports.and = guards_dist_xstateGuards.and;
@@ -895,6 +889,12 @@ exports.forwardTo = log.forwardTo;
895
889
  exports.log = log.log;
896
890
  exports.sendParent = log.sendParent;
897
891
  exports.sendTo = log.sendTo;
892
+ exports.createEmptyActor = actors_dist_xstateActors.createEmptyActor;
893
+ exports.fromCallback = actors_dist_xstateActors.fromCallback;
894
+ exports.fromEventObservable = actors_dist_xstateActors.fromEventObservable;
895
+ exports.fromObservable = actors_dist_xstateActors.fromObservable;
896
+ exports.fromPromise = actors_dist_xstateActors.fromPromise;
897
+ exports.fromTransition = actors_dist_xstateActors.fromTransition;
898
898
  exports.SimulatedClock = SimulatedClock;
899
899
  exports.StateMachine = StateMachine;
900
900
  exports.StateNode = StateNode;