xstate 5.0.0-beta.12 → 5.0.0-beta.14

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 (57) hide show
  1. package/actions/dist/xstate-actions.cjs.js +1 -1
  2. package/actions/dist/xstate-actions.development.cjs.js +1 -1
  3. package/actions/dist/xstate-actions.development.esm.js +1 -1
  4. package/actions/dist/xstate-actions.esm.js +1 -1
  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/{actions-e4c704f3.cjs.js → actions-17c3bcfa.cjs.js} +803 -853
  14. package/dist/{actions-b34f6ce7.esm.js → actions-444a17c3.esm.js} +804 -854
  15. package/dist/{actions-c8b9504d.development.esm.js → actions-60622c0c.development.esm.js} +829 -879
  16. package/dist/{actions-d9c19f35.development.cjs.js → actions-73b8d456.development.cjs.js} +828 -878
  17. package/dist/declarations/src/Machine.d.ts +3 -3
  18. package/dist/declarations/src/SimulatedClock.d.ts +1 -1
  19. package/dist/declarations/src/State.d.ts +4 -10
  20. package/dist/declarations/src/StateMachine.d.ts +8 -13
  21. package/dist/declarations/src/StateNode.d.ts +4 -4
  22. package/dist/declarations/src/actionTypes.d.ts +1 -1
  23. package/dist/declarations/src/actions/assign.d.ts +1 -1
  24. package/dist/declarations/src/actions/cancel.d.ts +2 -2
  25. package/dist/declarations/src/actions/choose.d.ts +2 -2
  26. package/dist/declarations/src/actions/log.d.ts +2 -2
  27. package/dist/declarations/src/actions/pure.d.ts +2 -2
  28. package/dist/declarations/src/actions/raise.d.ts +1 -1
  29. package/dist/declarations/src/actions/send.d.ts +2 -2
  30. package/dist/declarations/src/actions/stop.d.ts +1 -1
  31. package/dist/declarations/src/actions.d.ts +10 -10
  32. package/dist/declarations/src/actors/callback.d.ts +2 -2
  33. package/dist/declarations/src/actors/index.d.ts +6 -6
  34. package/dist/declarations/src/actors/observable.d.ts +8 -6
  35. package/dist/declarations/src/actors/promise.d.ts +4 -3
  36. package/dist/declarations/src/actors/transition.d.ts +4 -4
  37. package/dist/declarations/src/dev/index.d.ts +1 -1
  38. package/dist/declarations/src/guards.d.ts +2 -2
  39. package/dist/declarations/src/index.d.ts +22 -22
  40. package/dist/declarations/src/interpreter.d.ts +18 -18
  41. package/dist/declarations/src/stateUtils.d.ts +8 -10
  42. package/dist/declarations/src/typegenTypes.d.ts +1 -1
  43. package/dist/declarations/src/types.d.ts +29 -39
  44. package/dist/declarations/src/utils.d.ts +9 -9
  45. package/dist/declarations/src/waitFor.d.ts +1 -1
  46. package/dist/xstate.cjs.js +13 -37
  47. package/dist/xstate.development.cjs.js +13 -37
  48. package/dist/xstate.development.esm.js +14 -38
  49. package/dist/xstate.esm.js +14 -38
  50. package/dist/xstate.umd.min.js +1 -1
  51. package/dist/xstate.umd.min.js.map +1 -1
  52. package/guards/dist/xstate-guards.cjs.js +1 -1
  53. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  54. package/guards/dist/xstate-guards.development.esm.js +1 -1
  55. package/guards/dist/xstate-guards.esm.js +1 -1
  56. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  57. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { MachineConfig, EventObject, AnyEventObject, MachineContext, ActorMap, InternalMachineImplementations, ParameterizedObject } from './types.ts';
2
- import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from './typegenTypes.ts';
3
- import { StateMachine } from './StateMachine.ts';
1
+ import { MachineConfig, EventObject, AnyEventObject, MachineContext, ActorMap, InternalMachineImplementations, ParameterizedObject } from "./types.js";
2
+ import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from "./typegenTypes.js";
3
+ import { StateMachine } from "./StateMachine.js";
4
4
  export declare function createMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TActorMap extends ActorMap = ActorMap, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, ParameterizedObject, TActorMap, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, ResolveTypegenMeta<TTypesMeta, TEvent, ParameterizedObject, TActorMap>>): StateMachine<TContext, TEvent, ParameterizedObject, TActorMap, ResolveTypegenMeta<TTypesMeta, TEvent, ParameterizedObject, TActorMap>>;
@@ -1,4 +1,4 @@
1
- import { Clock } from './interpreter.ts';
1
+ import { Clock } from "./interpreter.js";
2
2
  export interface SimulatedClock extends Clock {
3
3
  start(speed: number): void;
4
4
  increment(ms: number): void;
@@ -1,6 +1,6 @@
1
- import type { StateNode } from './StateNode.ts';
2
- import { TypegenDisabled, TypegenEnabled } from './typegenTypes.ts';
3
- import type { ActorRef, AnyState, AnyStateMachine, BaseActionObject, EventObject, HistoryValue, MachineContext, PersistedMachineState, Prop, StateConfig, StateValue, TransitionDefinition } from './types.ts';
1
+ import type { StateNode } from "./StateNode.js";
2
+ import { TypegenDisabled, TypegenEnabled } from "./typegenTypes.js";
3
+ import type { ActorRef, AnyState, AnyStateMachine, EventObject, HistoryValue, MachineContext, PersistedMachineState, Prop, StateConfig, StateValue } from "./types.js";
4
4
  export declare function isStateConfig<TContext extends MachineContext, TEvent extends EventObject>(state: any): state is StateConfig<TContext, TEvent>;
5
5
  /**
6
6
  * @deprecated Use `isStateConfig(object)` or `state instanceof State` instead.
@@ -20,8 +20,6 @@ export declare class State<TContext extends MachineContext, TEvent extends Event
20
20
  output: any;
21
21
  context: TContext;
22
22
  historyValue: Readonly<HistoryValue<TContext, TEvent>>;
23
- actions: BaseActionObject[];
24
- event: TEvent;
25
23
  _internalQueue: Array<TEvent>;
26
24
  _initial: boolean;
27
25
  /**
@@ -37,10 +35,6 @@ export declare class State<TContext extends MachineContext, TEvent extends Event
37
35
  * The enabled state nodes representative of the state value.
38
36
  */
39
37
  configuration: Array<StateNode<TContext, TEvent>>;
40
- /**
41
- * The transition definitions that resulted in this state.
42
- */
43
- transitions: Array<TransitionDefinition<TContext, TEvent>>;
44
38
  /**
45
39
  * An object mapping actor names to spawned/invoked actors.
46
40
  */
@@ -63,7 +57,7 @@ export declare class State<TContext extends MachineContext, TEvent extends Event
63
57
  * @param delimiter The character(s) that separate each subpath in the string state node path.
64
58
  */
65
59
  toStrings(stateValue?: StateValue, delimiter?: string): string[];
66
- toJSON(): Omit<this, "meta" | "toJSON" | "configuration" | "transitions" | "tags" | "machine" | "toStrings" | "matches" | "hasTag" | "can" | "nextEvents"> & {
60
+ toJSON(): Omit<this, "meta" | "toJSON" | "configuration" | "tags" | "machine" | "toStrings" | "matches" | "hasTag" | "can" | "nextEvents"> & {
67
61
  tags: string[];
68
62
  meta: Record<string, any>;
69
63
  };
@@ -1,11 +1,11 @@
1
- import { State } from './State.ts';
2
- import { StateNode } from './StateNode.ts';
3
- import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, ResolveTypegenMeta, TypegenDisabled } from './typegenTypes.ts';
4
- import type { ActorContext, ActorMap, ActorBehavior, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineTypes, NoInfer, StateConfig, StateMachineDefinition, StateValue, TransitionDefinition, PersistedMachineState, ParameterizedObject, AnyActorContext } from './types.ts';
1
+ import { State } from "./State.js";
2
+ import { StateNode } from "./StateNode.js";
3
+ import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, ResolveTypegenMeta, TypegenDisabled } from "./typegenTypes.js";
4
+ import type { ActorContext, ActorLogic, ActorMap, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineTypes, NoInfer, StateConfig, StateMachineDefinition, StateValue, TransitionDefinition, PersistedMachineState, ParameterizedObject, AnyActorContext } from "./types.js";
5
5
  export declare const NULL_EVENT = "";
6
6
  export declare const STATE_IDENTIFIER = "#";
7
7
  export declare const WILDCARD = "*";
8
- export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject = EventObject, TAction extends ParameterizedObject = ParameterizedObject, TActorMap extends ActorMap = ActorMap, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TAction, TActorMap>> implements ActorBehavior<TEvent, State<TContext, TEvent, TResolvedTypesMeta>, State<TContext, TEvent, TResolvedTypesMeta>, PersistedMachineState<State<TContext, TEvent, TResolvedTypesMeta>>> {
8
+ export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject = EventObject, TAction extends ParameterizedObject = ParameterizedObject, TActorMap extends ActorMap = ActorMap, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TAction, TActorMap>> implements ActorLogic<TEvent, State<TContext, TEvent, TResolvedTypesMeta>, State<TContext, TEvent, TResolvedTypesMeta>, PersistedMachineState<State<TContext, TEvent, TResolvedTypesMeta>>> {
9
9
  /**
10
10
  * The raw config used to create the machine.
11
11
  */
@@ -59,7 +59,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
59
59
  * @param state The current State instance or state value
60
60
  * @param event The received event
61
61
  */
62
- transition(state: StateValue | State<TContext, TEvent, TResolvedTypesMeta> | undefined, event: TEvent, actorCtx?: ActorContext<TEvent, State<TContext, TEvent, any>>): State<TContext, TEvent, TResolvedTypesMeta>;
62
+ transition(state: State<TContext, TEvent, TResolvedTypesMeta>, event: TEvent, actorCtx: ActorContext<TEvent, State<TContext, TEvent, any>>): State<TContext, TEvent, TResolvedTypesMeta>;
63
63
  /**
64
64
  * Determines the next state given the current `state` and `event`.
65
65
  * Calculates a microstep.
@@ -67,22 +67,17 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
67
67
  * @param state The current state
68
68
  * @param event The received event
69
69
  */
70
- microstep(state: State<TContext, TEvent, TResolvedTypesMeta> | undefined, event: TEvent, actorCtx?: AnyActorContext | undefined): Array<State<TContext, TEvent, TResolvedTypesMeta>>;
70
+ microstep(state: State<TContext, TEvent, TResolvedTypesMeta>, event: TEvent, actorCtx: AnyActorContext): Array<State<TContext, TEvent, TResolvedTypesMeta>>;
71
71
  getTransitionData(state: State<TContext, TEvent, TResolvedTypesMeta>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>>;
72
72
  /**
73
73
  * The initial state _before_ evaluating any microsteps.
74
74
  * This "pre-initial" state is provided to initial actions executed in the initial state.
75
75
  */
76
76
  private getPreInitialState;
77
- /**
78
- * The initial State instance, which includes all actions to be executed from
79
- * entering the initial state.
80
- */
81
- get initialState(): State<TContext, TEvent, TResolvedTypesMeta>;
82
77
  /**
83
78
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
84
79
  */
85
- getInitialState(actorCtx?: ActorContext<TEvent, State<TContext, TEvent, TResolvedTypesMeta>>, input?: any): State<TContext, TEvent, TResolvedTypesMeta>;
80
+ getInitialState(actorCtx: ActorContext<TEvent, State<TContext, TEvent, TResolvedTypesMeta>>, input?: any): State<TContext, TEvent, TResolvedTypesMeta>;
86
81
  start(state: State<TContext, TEvent, TResolvedTypesMeta>, actorCtx: ActorContext<TEvent, State<TContext, TEvent, TResolvedTypesMeta>>): void;
87
82
  getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
88
83
  get definition(): StateMachineDefinition<TContext, TEvent>;
@@ -1,6 +1,6 @@
1
- import type { EventObject, StateNodeDefinition, TransitionDefinition, DelayedTransitionDefinition, StateNodeConfig, StateNodesConfig, InvokeDefinition, Mapper, PropertyMapper, TransitionDefinitionMap, InitialTransitionDefinition, MachineContext, BaseActionObject } from './types.ts';
2
- import type { State } from './State.ts';
3
- import type { StateMachine } from './StateMachine.ts';
1
+ import type { EventObject, StateNodeDefinition, TransitionDefinition, DelayedTransitionDefinition, StateNodeConfig, StateNodesConfig, InvokeDefinition, Mapper, PropertyMapper, TransitionDefinitionMap, InitialTransitionDefinition, MachineContext, BaseActionObject } from "./types.js";
2
+ import type { State } from "./State.js";
3
+ import type { StateMachine } from "./StateMachine.js";
4
4
  interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
5
5
  _key: string;
6
6
  _parent?: StateNode<TContext, TEvent>;
@@ -88,7 +88,7 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
88
88
  get definition(): StateNodeDefinition<TContext, TEvent>;
89
89
  toJSON(): StateNodeDefinition<TContext, TEvent>;
90
90
  /**
91
- * The behaviors invoked as actors by this state node.
91
+ * The logic invoked as actors by this state node.
92
92
  */
93
93
  get invoke(): Array<InvokeDefinition<TContext, TEvent>>;
94
94
  /**
@@ -1,4 +1,4 @@
1
- import { ActionTypes } from './types.ts';
1
+ import { ActionTypes } from "./types.js";
2
2
  export declare const stop = ActionTypes.Stop;
3
3
  export declare const raise = ActionTypes.Raise;
4
4
  export declare const send = ActionTypes.Send;
@@ -1,4 +1,4 @@
1
- import type { EventObject, Assigner, PropertyAssigner, MachineContext, DynamicAssignAction, LowInfer } from '../types.ts';
1
+ import type { EventObject, Assigner, PropertyAssigner, MachineContext, DynamicAssignAction, LowInfer } from "../types.js";
2
2
  /**
3
3
  * Updates the current context of the machine.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { EventObject, ExprWithMeta, MachineContext } from '../types.ts';
2
- import { BaseDynamicActionObject, CancelActionObject, DynamicCancelActionObject } from '../index.ts';
1
+ import { EventObject, ExprWithMeta, MachineContext } from "../types.js";
2
+ import { BaseDynamicActionObject, CancelActionObject, DynamicCancelActionObject } from "../index.js";
3
3
  /**
4
4
  * Cancels an in-flight `send(...)` action. A canceled sent action will not
5
5
  * be executed, nor will its event be sent, unless it has already been sent
@@ -1,3 +1,3 @@
1
- import { EventObject, ChooseCondition, MachineContext } from '../types.ts';
2
- import { BaseDynamicActionObject, ChooseAction, ResolvedChooseAction } from '../index.ts';
1
+ import { EventObject, ChooseCondition, MachineContext } from "../types.js";
2
+ import { BaseDynamicActionObject, ChooseAction, ResolvedChooseAction } from "../index.js";
3
3
  export declare function choose<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(guards: Array<ChooseCondition<TContext, TExpressionEvent>>): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, ResolvedChooseAction, ChooseAction<TContext, TExpressionEvent>['params']>;
@@ -1,5 +1,5 @@
1
- import { EventObject, LogExpr, MachineContext, LogActionObject } from '../types.ts';
2
- import { BaseDynamicActionObject, DynamicLogAction } from '../index.ts';
1
+ import { EventObject, LogExpr, MachineContext, LogActionObject } from "../types.js";
2
+ import { BaseDynamicActionObject, DynamicLogAction } from "../index.js";
3
3
  /**
4
4
  *
5
5
  * @param expr The expression function to evaluate which will be logged.
@@ -1,5 +1,5 @@
1
- import { EventObject, SingleOrArray, MachineContext } from '../types.ts';
2
- import { BaseActionObject, BaseDynamicActionObject, DynamicPureActionObject, PureActionObject } from '..';
1
+ import { EventObject, SingleOrArray, MachineContext } from "../types.js";
2
+ import { BaseActionObject, BaseDynamicActionObject, DynamicPureActionObject, PureActionObject } from "../index.js";
3
3
  export declare function pure<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(getActions: ({ context, event }: {
4
4
  context: TContext;
5
5
  event: TExpressionEvent;
@@ -1,4 +1,4 @@
1
- import { EventObject, MachineContext, RaiseActionObject, BaseDynamicActionObject, RaiseActionOptions, SendExpr, RaiseActionParams, NoInfer } from '../types.ts';
1
+ import { EventObject, MachineContext, RaiseActionObject, BaseDynamicActionObject, RaiseActionOptions, SendExpr, RaiseActionParams, NoInfer } from "../types.js";
2
2
  /**
3
3
  * Raises an event. This places the event in the internal event queue, so that
4
4
  * the event is immediately consumed by the machine in the current step.
@@ -1,5 +1,5 @@
1
- import { EventObject, SendActionParams, SendExpr, AnyEventObject, MachineContext } from '../types.ts';
2
- import { AnyActorRef, BaseDynamicActionObject, Cast, EventFrom, ExprWithMeta, InferEvent, SendActionObject, SendActionOptions } from '../index.ts';
1
+ import { EventObject, SendActionParams, SendExpr, AnyEventObject, MachineContext } from "../types.js";
2
+ import { AnyActorRef, BaseDynamicActionObject, Cast, EventFrom, ExprWithMeta, InferEvent, SendActionObject, SendActionOptions } from "../index.js";
3
3
  /**
4
4
  * Sends an event. This returns an action that will be read by an interpreter to
5
5
  * send the event in the next step, after the current step is finished executing.
@@ -1,4 +1,4 @@
1
- import { ActorRef, BaseDynamicActionObject, DynamicStopActionObject, EventObject, Expr, MachineContext, StopActionObject } from '../types.ts';
1
+ import { ActorRef, BaseDynamicActionObject, DynamicStopActionObject, EventObject, Expr, MachineContext, StopActionObject } from "../types.js";
2
2
  /**
3
3
  * Stops an actor.
4
4
  *
@@ -1,13 +1,13 @@
1
- import { Action, EventObject, SingleOrArray, ActionFunction, ActionFunctionMap, ActionTypes, DoneEvent, ErrorPlatformEvent, DoneEventObject, MachineContext, BaseActionObject } from './types.ts';
2
- import * as actionTypes from './actionTypes.ts';
3
- export { send, sendTo, sendParent, forwardTo, escalate } from './actions/send.ts';
4
- export { stop } from './actions/stop.ts';
5
- export { log } from './actions/log.ts';
6
- export { cancel } from './actions/cancel.ts';
7
- export { assign } from './actions/assign.ts';
8
- export { raise } from './actions/raise.ts';
9
- export { choose } from './actions/choose.ts';
10
- export { pure } from './actions/pure.ts';
1
+ import { Action, EventObject, SingleOrArray, ActionFunction, ActionFunctionMap, ActionTypes, DoneEvent, ErrorPlatformEvent, DoneEventObject, MachineContext, BaseActionObject } from "./types.js";
2
+ import * as actionTypes from "./actionTypes.js";
3
+ export { send, sendTo, sendParent, forwardTo, escalate } from "./actions/send.js";
4
+ export { stop } from "./actions/stop.js";
5
+ export { log } from "./actions/log.js";
6
+ export { cancel } from "./actions/cancel.js";
7
+ export { assign } from "./actions/assign.js";
8
+ export { raise } from "./actions/raise.js";
9
+ export { choose } from "./actions/choose.js";
10
+ export { pure } from "./actions/pure.js";
11
11
  export { actionTypes };
12
12
  export declare const initEvent: {
13
13
  type: ActionTypes;
@@ -1,8 +1,8 @@
1
- import { InvokeCallback, ActorBehavior, EventObject } from '../types';
1
+ import { InvokeCallback, ActorLogic, EventObject } from "../types.js";
2
2
  export interface CallbackInternalState {
3
3
  canceled: boolean;
4
4
  receivers: Set<(e: EventObject) => void>;
5
5
  dispose: void | (() => void) | Promise<any>;
6
6
  input?: any;
7
7
  }
8
- export declare function fromCallback<TEvent extends EventObject>(invokeCallback: InvokeCallback): ActorBehavior<TEvent, undefined>;
8
+ export declare function fromCallback<TEvent extends EventObject>(invokeCallback: InvokeCallback): ActorLogic<TEvent, undefined, CallbackInternalState>;
@@ -1,8 +1,8 @@
1
- import type { EventObject, ActorRef, BaseActorRef, AnyEventObject } from '../types.ts';
2
- export { fromTransition } from './transition.ts';
3
- export { fromPromise } from './promise.ts';
4
- export { fromObservable, fromEventObservable } from './observable.ts';
5
- export { fromCallback } from './callback.ts';
1
+ import type { EventObject, ActorRef, BaseActorRef, AnyEventObject } from "../types.js";
2
+ export { fromTransition } from "./transition.js";
3
+ export { fromPromise } from "./promise.js";
4
+ export { fromObservable, fromEventObservable } from "./observable.js";
5
+ export { fromCallback } from "./callback.js";
6
6
  export declare const startSignalType = "xstate.init";
7
7
  export declare const stopSignalType = "xstate.stop";
8
8
  export declare const startSignal: StartSignal;
@@ -16,7 +16,7 @@ export interface StopSignal {
16
16
  export type LifecycleSignal = StartSignal | StopSignal;
17
17
  export type LifecycleSignalType = typeof startSignalType | typeof stopSignalType;
18
18
  /**
19
- * An object that expresses the behavior of an actor in reaction to received events,
19
+ * An object that expresses the actor logic in reaction to received events,
20
20
  * as well as an optionally emitted stream of values.
21
21
  *
22
22
  * @template TReceived The received event
@@ -1,4 +1,4 @@
1
- import { Subscribable, ActorBehavior, EventObject, Subscription } from '../types';
1
+ import { Subscribable, ActorLogic, EventObject, Subscription, AnyActorSystem } from "../types.js";
2
2
  export interface ObservableInternalState<T> {
3
3
  subscription: Subscription | undefined;
4
4
  status: 'active' | 'done' | 'error' | 'canceled';
@@ -6,17 +6,19 @@ export interface ObservableInternalState<T> {
6
6
  input?: any;
7
7
  }
8
8
  export type ObservablePersistedState<T> = Omit<ObservableInternalState<T>, 'subscription'>;
9
- export declare function fromObservable<T, TEvent extends EventObject>(observableCreator: ({ input }: {
9
+ export declare function fromObservable<T, TEvent extends EventObject>(observableCreator: ({ input, system }: {
10
10
  input: any;
11
- }) => Subscribable<T>): ActorBehavior<TEvent, T | undefined, ObservableInternalState<T>, ObservablePersistedState<T>>;
11
+ system: AnyActorSystem;
12
+ }) => Subscribable<T>): ActorLogic<TEvent, T | undefined, ObservableInternalState<T>, ObservablePersistedState<T>>;
12
13
  /**
13
- * Creates an event observable behavior that listens to an observable
14
+ * Creates event observable logic that listens to an observable
14
15
  * that delivers event objects.
15
16
  *
16
17
  *
17
18
  * @param lazyObservable A function that creates an observable
18
- * @returns An event observable behavior
19
+ * @returns Event observable logic
19
20
  */
20
21
  export declare function fromEventObservable<T extends EventObject>(lazyObservable: ({ input }: {
21
22
  input: any;
22
- }) => Subscribable<T>): ActorBehavior<EventObject, T | undefined>;
23
+ system: AnyActorSystem;
24
+ }) => Subscribable<T>): ActorLogic<EventObject, T | undefined, ObservableInternalState<T>, ObservablePersistedState<T>>;
@@ -1,11 +1,12 @@
1
- import { ActorBehavior } from '../types';
1
+ import { ActorLogic, AnyActorSystem } from "../types.js";
2
2
  export interface PromiseInternalState<T> {
3
3
  status: 'active' | 'error' | 'done' | 'canceled';
4
4
  data: T | undefined;
5
5
  input?: any;
6
6
  }
7
- export declare function fromPromise<T>(promiseCreator: ({ input }: {
7
+ export declare function fromPromise<T>(promiseCreator: ({ input, system }: {
8
8
  input: any;
9
- }) => PromiseLike<T>): ActorBehavior<{
9
+ system: AnyActorSystem;
10
+ }) => PromiseLike<T>): ActorLogic<{
10
11
  type: string;
11
12
  }, T | undefined, PromiseInternalState<T>>;
@@ -1,13 +1,13 @@
1
- import { ActorBehavior, ActorContext, ActorSystem, EventObject } from '../types';
1
+ import { ActorLogic, ActorContext, ActorSystem, EventObject } from "../types.js";
2
2
  /**
3
- * Returns an actor behavior from a transition function and its initial state.
3
+ * Returns actor logic from a transition function and its initial state.
4
4
  *
5
5
  * A transition function is a function that takes the current state and an event and returns the next state.
6
6
  *
7
7
  * @param transition The transition function that returns the next state given the current state and event.
8
8
  * @param initialState The initial state of the transition function.
9
- * @returns An actor behavior
9
+ * @returns Actor logic
10
10
  */
11
11
  export declare function fromTransition<TState, TEvent extends EventObject, TSystem extends ActorSystem<any>>(transition: (state: TState, event: TEvent, actorContext: ActorContext<TEvent, TState, TSystem>) => TState, initialState: TState | (({ input }: {
12
12
  input: any;
13
- }) => TState)): ActorBehavior<TEvent, TState, TState>;
13
+ }) => TState)): ActorLogic<TEvent, TState, TState>;
@@ -1,4 +1,4 @@
1
- import { AnyInterpreter, DevToolsAdapter } from '../types.ts';
1
+ import { AnyInterpreter, DevToolsAdapter } from "../types.js";
2
2
  type ServiceListener = (service: AnyInterpreter) => void;
3
3
  export interface XStateDevInterface {
4
4
  register: (service: AnyInterpreter) => void;
@@ -1,5 +1,5 @@
1
- import type { EventObject, StateValue, BooleanGuardDefinition, GuardConfig, GuardDefinition, GuardPredicate, MachineContext } from './types.ts';
2
- import type { State } from './State.ts';
1
+ import type { EventObject, StateValue, BooleanGuardDefinition, GuardConfig, GuardDefinition, GuardPredicate, MachineContext } from "./types.js";
2
+ import type { State } from "./State.js";
3
3
  export declare function stateIn<TContext extends MachineContext, TEvent extends EventObject>(stateValue: StateValue): GuardDefinition<TContext, TEvent>;
4
4
  export declare function not<TContext extends MachineContext, TEvent extends EventObject>(guard: GuardConfig<TContext, TEvent>): BooleanGuardDefinition<TContext, TEvent>;
5
5
  export declare function and<TContext extends MachineContext, TEvent extends EventObject>(guards: Array<GuardConfig<TContext, TEvent>>): BooleanGuardDefinition<TContext, TEvent>;
@@ -1,26 +1,26 @@
1
- import { doneInvoke, forwardTo, sendParent, sendTo } from './actions.ts';
2
- export { assign } from './actions/assign.ts';
3
- export { cancel } from './actions/cancel.ts';
4
- export { choose } from './actions/choose.ts';
5
- export { log } from './actions/log.ts';
6
- export { pure } from './actions/pure.ts';
7
- export { raise } from './actions/raise.ts';
8
- export { stop } from './actions/stop.ts';
9
- import { interpret, Interpreter, ActorStatus } from './interpreter.ts';
10
- import { createMachine } from './Machine.ts';
11
- import { mapState } from './mapState.ts';
12
- import { State } from './State.ts';
13
- import { StateNode } from './StateNode.ts';
14
- export { SimulatedClock } from './SimulatedClock.ts';
15
- export { StateMachine } from './StateMachine.ts';
16
- export { getStateNodes } from './stateUtils.ts';
17
- export { waitFor } from './waitFor.ts';
18
- export * from './typegenTypes.ts';
19
- export * from './types.ts';
20
- export { matchesState, pathToStateValue, toObserver } from './utils.ts';
1
+ import { doneInvoke, forwardTo, sendParent, sendTo } from "./actions.js";
2
+ export { assign } from "./actions/assign.js";
3
+ export { cancel } from "./actions/cancel.js";
4
+ export { choose } from "./actions/choose.js";
5
+ export { log } from "./actions/log.js";
6
+ export { pure } from "./actions/pure.js";
7
+ export { raise } from "./actions/raise.js";
8
+ export { stop } from "./actions/stop.js";
9
+ import { interpret, Interpreter, ActorStatus } from "./interpreter.js";
10
+ import { createMachine } from "./Machine.js";
11
+ import { mapState } from "./mapState.js";
12
+ import { State } from "./State.js";
13
+ import { StateNode } from "./StateNode.js";
14
+ export { SimulatedClock } from "./SimulatedClock.js";
15
+ export { StateMachine } from "./StateMachine.js";
16
+ export { getStateNodes } from "./stateUtils.js";
17
+ export { waitFor } from "./waitFor.js";
18
+ export * from "./typegenTypes.js";
19
+ export * from "./types.js";
20
+ export { matchesState, pathToStateValue, toObserver } from "./utils.js";
21
21
  export { StateNode, State, mapState, sendTo, sendParent, forwardTo, interpret, Interpreter, ActorStatus as InterpreterStatus, doneInvoke, createMachine };
22
- export { fromPromise, fromObservable, fromCallback, fromEventObservable, fromTransition } from './actors/index.ts';
23
- export { stateIn, not, and, or } from './guards.ts';
22
+ export { fromPromise, fromObservable, fromCallback, fromEventObservable, fromTransition } from "./actors/index.js";
23
+ export { stateIn, not, and, or } from "./guards.js";
24
24
  declare global {
25
25
  interface SymbolConstructor {
26
26
  readonly observable: symbol;
@@ -1,8 +1,8 @@
1
- import { symbolObservable } from './symbolObservable.ts';
2
- import { AreAllImplementationsAssumedToBeProvided, MissingImplementationsError } from './typegenTypes.ts';
3
- import type { ActorSystem, AnyActorBehavior, AnyStateMachine, EventFromBehavior, InterpreterFrom, PersistedStateFrom, RaiseActionObject, SnapshotFrom } from './types.ts';
4
- import { ActorRef, EventObject, InteropSubscribable, InterpreterOptions, Observer, SendActionObject, Subscription } from './types.ts';
5
- export type SnapshotListener<TBehavior extends AnyActorBehavior> = (state: SnapshotFrom<TBehavior>) => void;
1
+ import { symbolObservable } from "./symbolObservable.js";
2
+ import { AreAllImplementationsAssumedToBeProvided, MissingImplementationsError } from "./typegenTypes.js";
3
+ import type { ActorSystem, AnyActorLogic, AnyStateMachine, EventFromLogic, InterpreterFrom, PersistedStateFrom, RaiseActionObject, SnapshotFrom } from "./types.js";
4
+ import { ActorRef, EventObject, InteropSubscribable, InterpreterOptions, Observer, SendActionObject, Subscription } from "./types.js";
5
+ export type SnapshotListener<TLogic extends AnyActorLogic> = (state: SnapshotFrom<TLogic>) => void;
6
6
  export type EventListener<TEvent extends EventObject = EventObject> = (event: TEvent) => void;
7
7
  export type Listener = () => void;
8
8
  export type ErrorListener = (error: any) => void;
@@ -15,17 +15,17 @@ export declare enum ActorStatus {
15
15
  Running = 1,
16
16
  Stopped = 2
17
17
  }
18
- export declare class Interpreter<TBehavior extends AnyActorBehavior, TEvent extends EventObject = EventFromBehavior<TBehavior>> implements ActorRef<TEvent, SnapshotFrom<TBehavior>> {
19
- behavior: TBehavior;
18
+ export declare class Interpreter<TLogic extends AnyActorLogic, TEvent extends EventObject = EventFromLogic<TLogic>> implements ActorRef<TEvent, SnapshotFrom<TLogic>> {
19
+ logic: TLogic;
20
20
  /**
21
- * The current state of the interpreted behavior.
21
+ * The current state of the interpreted logic.
22
22
  */
23
23
  private _state;
24
24
  /**
25
25
  * The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
26
26
  */
27
27
  clock: Clock;
28
- options: Readonly<InterpreterOptions<TBehavior>>;
28
+ options: Readonly<InterpreterOptions<TLogic>>;
29
29
  /**
30
30
  * The unique identifier for this actor relative to its parent.
31
31
  */
@@ -50,17 +50,17 @@ export declare class Interpreter<TBehavior extends AnyActorBehavior, TEvent exte
50
50
  private _doneEvent?;
51
51
  src?: string;
52
52
  /**
53
- * Creates a new Interpreter instance (i.e., service) for the given behavior with the provided options, if any.
53
+ * Creates a new Interpreter instance (i.e., service) for the given logic with the provided options, if any.
54
54
  *
55
- * @param behavior The behavior to be interpreted
55
+ * @param logic The logic to be interpreted
56
56
  * @param options Interpreter options
57
57
  */
58
- constructor(behavior: TBehavior, options?: InterpreterOptions<TBehavior>);
58
+ constructor(logic: TLogic, options?: InterpreterOptions<TLogic>);
59
59
  private _initState;
60
60
  private _deferred;
61
61
  private update;
62
- subscribe(observer: Observer<SnapshotFrom<TBehavior>>): Subscription;
63
- subscribe(nextListener?: (state: SnapshotFrom<TBehavior>) => void, errorListener?: (error: any) => void, completeListener?: () => void): Subscription;
62
+ subscribe(observer: Observer<SnapshotFrom<TLogic>>): Subscription;
63
+ subscribe(nextListener?: (state: SnapshotFrom<TLogic>) => void, errorListener?: (error: any) => void, completeListener?: () => void): Subscription;
64
64
  /**
65
65
  * Starts the interpreter from the initial state
66
66
  */
@@ -86,9 +86,9 @@ export declare class Interpreter<TBehavior extends AnyActorBehavior, TEvent exte
86
86
  toJSON(): {
87
87
  id: string;
88
88
  };
89
- getPersistedState(): PersistedStateFrom<TBehavior> | undefined;
90
- [Symbol.observable](): InteropSubscribable<SnapshotFrom<TBehavior>>;
91
- getSnapshot(): SnapshotFrom<TBehavior>;
89
+ getPersistedState(): PersistedStateFrom<TLogic> | undefined;
90
+ [Symbol.observable](): InteropSubscribable<SnapshotFrom<TLogic>>;
91
+ getSnapshot(): SnapshotFrom<TLogic>;
92
92
  }
93
93
  /**
94
94
  * Creates a new Interpreter instance for the given machine with the provided options, if any.
@@ -97,4 +97,4 @@ export declare class Interpreter<TBehavior extends AnyActorBehavior, TEvent exte
97
97
  * @param options Interpreter options
98
98
  */
99
99
  export declare function interpret<TMachine extends AnyStateMachine>(machine: AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? TMachine : MissingImplementationsError<TMachine['__TResolvedTypesMeta']>, options?: InterpreterOptions<TMachine>): InterpreterFrom<TMachine>;
100
- export declare function interpret<TBehavior extends AnyActorBehavior>(behavior: TBehavior, options?: InterpreterOptions<TBehavior>): Interpreter<TBehavior>;
100
+ export declare function interpret<TLogic extends AnyActorLogic>(logic: TLogic, options?: InterpreterOptions<TLogic>): Interpreter<TLogic>;
@@ -1,8 +1,8 @@
1
- import { BaseActionObject, EventObject, StateValue, TransitionConfig, TransitionDefinition, SingleOrArray, StateValueMap, InitialTransitionConfig, MachineContext } from './types.ts';
2
- import { State } from './State.ts';
3
- import { NULL_EVENT } from './constants.ts';
4
- import type { StateNode } from './StateNode.ts';
5
- import { AnyActorContext, AnyHistoryValue, AnyState, AnyStateMachine, AnyStateNode, AnyTransitionDefinition, DelayedTransitionDefinition, InitialTransitionDefinition, StateFromMachine } from '.';
1
+ import { BaseActionObject, EventObject, StateValue, TransitionConfig, TransitionDefinition, SingleOrArray, StateValueMap, InitialTransitionConfig, MachineContext } from "./types.js";
2
+ import { State } from "./State.js";
3
+ import { NULL_EVENT } from "./constants.js";
4
+ import type { StateNode } from "./StateNode.js";
5
+ import { AnyActorContext, AnyHistoryValue, AnyState, AnyStateNode, AnyTransitionDefinition, DelayedTransitionDefinition, InitialTransitionDefinition } from "./index.js";
6
6
  type Configuration<TContext extends MachineContext, TE extends EventObject> = Iterable<StateNode<TContext, TE>>;
7
7
  type AnyConfiguration = Configuration<any, any>;
8
8
  type AdjList = Map<AnyStateNode, Array<AnyStateNode>>;
@@ -52,11 +52,9 @@ export declare function removeConflictingTransitions(enabledTransitions: Array<A
52
52
  * @param currentState
53
53
  * @param mutConfiguration
54
54
  */
55
- export declare function microstep<TContext extends MachineContext, TEvent extends EventObject>(transitions: Array<TransitionDefinition<TContext, TEvent>>, currentState: State<TContext, TEvent, any>, actorCtx: AnyActorContext | undefined, event: TEvent): State<TContext, TEvent, any>;
56
- export declare function resolveActionsAndContext<TContext extends MachineContext, TEvent extends EventObject>(actions: BaseActionObject[], event: TEvent, currentState: State<TContext, TEvent, any>, actorCtx: AnyActorContext | undefined): {
57
- nextState: AnyState;
58
- };
59
- export declare function macrostep<TMachine extends AnyStateMachine>(state: StateFromMachine<TMachine>, event: TMachine['__TEvent'], actorCtx: AnyActorContext | undefined): {
55
+ export declare function microstep<TContext extends MachineContext, TEvent extends EventObject>(transitions: Array<TransitionDefinition<TContext, TEvent>>, currentState: State<TContext, TEvent, any>, actorCtx: AnyActorContext, event: TEvent): State<TContext, TEvent, any>;
56
+ export declare function resolveActionsAndContext<TContext extends MachineContext, TEvent extends EventObject>(actions: BaseActionObject[], event: TEvent, currentState: State<TContext, TEvent, any>, actorCtx: AnyActorContext | undefined): [AnyState, BaseActionObject[]];
57
+ export declare function macrostep(state: AnyState, event: EventObject, actorCtx: AnyActorContext): {
60
58
  state: typeof state;
61
59
  microstates: Array<typeof state>;
62
60
  };
@@ -1,4 +1,4 @@
1
- import { Compute, EventObject, IndexByType, IsNever, Prop, Values, IsAny, ActorMap, Cast, ParameterizedObject } from './types.ts';
1
+ import { Compute, EventObject, IndexByType, IsNever, Prop, Values, IsAny, ActorMap, Cast, ParameterizedObject } from "./types.js";
2
2
  export interface TypegenDisabled {
3
3
  '@@xstate/typegen': false;
4
4
  }