xstate 5.0.0-beta.49 → 5.0.0-beta.51
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.
- package/actions/dist/xstate-actions.cjs.js +11 -10
- package/actions/dist/xstate-actions.cjs.mjs +1 -0
- package/actions/dist/xstate-actions.development.cjs.js +11 -10
- package/actions/dist/xstate-actions.development.cjs.mjs +1 -0
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -2
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +2 -4
- package/actors/dist/xstate-actors.development.cjs.js +2 -4
- package/actors/dist/xstate-actors.development.esm.js +2 -4
- package/actors/dist/xstate-actors.esm.js +2 -4
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/actions/enqueueActions.d.ts +32 -0
- package/dist/declarations/src/actions/pure.d.ts +7 -10
- package/dist/declarations/src/actions.d.ts +3 -2
- package/dist/declarations/src/actors/callback.d.ts +5 -5
- package/dist/declarations/src/actors/observable.d.ts +5 -5
- package/dist/declarations/src/actors/promise.d.ts +2 -2
- package/dist/declarations/src/actors/transition.d.ts +3 -3
- package/dist/declarations/src/interpreter.d.ts +1 -0
- package/dist/declarations/src/setup.d.ts +2 -2
- package/dist/declarations/src/types.d.ts +5 -3
- package/dist/declarations/src/utils.d.ts +1 -20
- package/dist/{send-0a381ca2.development.esm.js → pure-296f8ebd.development.esm.js} +114 -77
- package/dist/{send-8d30b415.development.cjs.js → pure-a0f16134.development.cjs.js} +114 -76
- package/dist/{send-22880315.esm.js → pure-aefddc19.esm.js} +108 -71
- package/dist/{send-8ed5c8b2.cjs.js → pure-c5f1b46c.cjs.js} +108 -70
- package/dist/{raise-e4cc6d4f.esm.js → raise-4742bf04.esm.js} +98 -38
- package/dist/{raise-495f4b9f.development.cjs.js → raise-528386de.development.cjs.js} +97 -38
- package/dist/{raise-1873c645.development.esm.js → raise-acaa3884.development.esm.js} +98 -38
- package/dist/{raise-8f9c4a5a.cjs.js → raise-d5633a02.cjs.js} +97 -38
- package/dist/xstate.cjs.js +14 -23
- package/dist/xstate.cjs.mjs +1 -0
- package/dist/xstate.development.cjs.js +14 -23
- package/dist/xstate.development.cjs.mjs +1 -0
- package/dist/xstate.development.esm.js +5 -15
- package/dist/xstate.esm.js +5 -15
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { assign, type AssignAction, type AssignArgs } from "./actions/assign.js";
|
|
2
2
|
export { cancel, type CancelAction } from "./actions/cancel.js";
|
|
3
3
|
export { choose, type ChooseAction } from "./actions/choose.js";
|
|
4
|
+
export { enqueueActions, type EnqueueActionsAction } from "./actions/enqueueActions.js";
|
|
4
5
|
export { log, type LogAction } from "./actions/log.js";
|
|
5
|
-
export { pure
|
|
6
|
+
export { pure } from "./actions/pure.js";
|
|
6
7
|
export { raise, type RaiseAction } from "./actions/raise.js";
|
|
7
8
|
export { escalate, forwardTo, sendParent, sendTo, type SendToAction } from "./actions/send.js";
|
|
8
|
-
export { stop, stopChild, type StopAction } from "./actions/stopChild.js";
|
|
9
9
|
export { spawnChild, type SpawnAction } from "./actions/spawnChild.js";
|
|
10
|
+
export { stop, stopChild, type StopAction } from "./actions/stopChild.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ActorLogic, EventObject, AnyActorSystem, AnyEventObject, ActorSystem, ActorRefFrom, Snapshot } from "../types.js";
|
|
1
|
+
import { ActorLogic, EventObject, AnyActorSystem, AnyEventObject, ActorSystem, ActorRefFrom, Snapshot, NonReducibleUnknown } from "../types.js";
|
|
2
2
|
export type CallbackSnapshot<TInput> = Snapshot<undefined> & {
|
|
3
3
|
input: TInput;
|
|
4
4
|
};
|
|
5
|
-
export type CallbackActorLogic<TEvent extends EventObject, TInput =
|
|
6
|
-
export type CallbackActorRef<TEvent extends EventObject, TInput =
|
|
5
|
+
export type CallbackActorLogic<TEvent extends EventObject, TInput = NonReducibleUnknown> = ActorLogic<CallbackSnapshot<TInput>, TEvent, TInput, ActorSystem<any>>;
|
|
6
|
+
export type CallbackActorRef<TEvent extends EventObject, TInput = NonReducibleUnknown> = ActorRefFrom<CallbackActorLogic<TEvent, TInput>>;
|
|
7
7
|
export type Receiver<TEvent extends EventObject> = (listener: {
|
|
8
8
|
bivarianceHack(event: TEvent): void;
|
|
9
9
|
}['bivarianceHack']) => void;
|
|
10
|
-
export type InvokeCallback<TEvent extends EventObject = AnyEventObject, TSentEvent extends EventObject = AnyEventObject, TInput =
|
|
10
|
+
export type InvokeCallback<TEvent extends EventObject = AnyEventObject, TSentEvent extends EventObject = AnyEventObject, TInput = NonReducibleUnknown> = ({ input, system, self, sendBack, receive }: {
|
|
11
11
|
/**
|
|
12
12
|
* Data that was provided to the callback actor
|
|
13
13
|
* @see {@link https://stately.ai/docs/input | Input docs}
|
|
@@ -88,4 +88,4 @@ export type InvokeCallback<TEvent extends EventObject = AnyEventObject, TSentEve
|
|
|
88
88
|
* });
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
|
-
export declare function fromCallback<TEvent extends EventObject, TInput =
|
|
91
|
+
export declare function fromCallback<TEvent extends EventObject, TInput = NonReducibleUnknown>(invokeCallback: InvokeCallback<TEvent, AnyEventObject, TInput>): CallbackActorLogic<TEvent, TInput>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Subscribable, ActorLogic, EventObject, Subscription, AnyActorSystem, ActorRefFrom, Snapshot } from "../types.js";
|
|
2
|
-
export type ObservableSnapshot<TContext, TInput> = Snapshot<undefined> & {
|
|
1
|
+
import { Subscribable, ActorLogic, EventObject, Subscription, AnyActorSystem, ActorRefFrom, Snapshot, NonReducibleUnknown } from "../types.js";
|
|
2
|
+
export type ObservableSnapshot<TContext, TInput extends NonReducibleUnknown> = Snapshot<undefined> & {
|
|
3
3
|
context: TContext | undefined;
|
|
4
4
|
input: TInput | undefined;
|
|
5
5
|
_subscription: Subscription | undefined;
|
|
6
6
|
};
|
|
7
|
-
export type ObservableActorLogic<TContext, TInput> = ActorLogic<ObservableSnapshot<TContext, TInput>, {
|
|
7
|
+
export type ObservableActorLogic<TContext, TInput extends NonReducibleUnknown> = ActorLogic<ObservableSnapshot<TContext, TInput>, {
|
|
8
8
|
type: string;
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
}, TInput, AnyActorSystem>;
|
|
@@ -49,7 +49,7 @@ export type ObservableActorRef<TContext> = ActorRefFrom<ObservableActorLogic<TCo
|
|
|
49
49
|
* @see {@link https://rxjs.dev} for documentation on RxJS Observable and observable creators.
|
|
50
50
|
* @see {@link Subscribable} interface in XState, which is based on and compatible with RxJS Observable.
|
|
51
51
|
*/
|
|
52
|
-
export declare function fromObservable<TContext, TInput>(observableCreator: ({ input, system }: {
|
|
52
|
+
export declare function fromObservable<TContext, TInput extends NonReducibleUnknown>(observableCreator: ({ input, system }: {
|
|
53
53
|
input: TInput;
|
|
54
54
|
system: AnyActorSystem;
|
|
55
55
|
self: ObservableActorRef<TContext>;
|
|
@@ -98,7 +98,7 @@ export declare function fromObservable<TContext, TInput>(observableCreator: ({ i
|
|
|
98
98
|
* canvasActor.start();
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
|
-
export declare function fromEventObservable<T extends EventObject, TInput>(lazyObservable: ({ input, system }: {
|
|
101
|
+
export declare function fromEventObservable<T extends EventObject, TInput extends NonReducibleUnknown>(lazyObservable: ({ input, system }: {
|
|
102
102
|
input: TInput;
|
|
103
103
|
system: AnyActorSystem;
|
|
104
104
|
self: ObservableActorRef<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ActorLogic, ActorRefFrom, ActorSystem, AnyActorSystem, Snapshot } from "../types.js";
|
|
2
1
|
import { XSTATE_STOP } from "../constants.js";
|
|
2
|
+
import { ActorLogic, ActorRefFrom, ActorSystem, AnyActorSystem, NonReducibleUnknown, Snapshot } from "../types.js";
|
|
3
3
|
export type PromiseSnapshot<TOutput, TInput> = Snapshot<TOutput> & {
|
|
4
4
|
input: TInput | undefined;
|
|
5
5
|
};
|
|
@@ -64,7 +64,7 @@ export type PromiseActorRef<TOutput> = ActorRefFrom<PromiseActorLogic<TOutput, u
|
|
|
64
64
|
* // }
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
export declare function fromPromise<TOutput, TInput =
|
|
67
|
+
export declare function fromPromise<TOutput, TInput = NonReducibleUnknown>(promiseCreator: ({ input, system }: {
|
|
68
68
|
/**
|
|
69
69
|
* Data that was provided to the promise actor
|
|
70
70
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ActorLogic, ActorScope, ActorSystem, EventObject, ActorRefFrom, AnyActorSystem, Snapshot } from "../types.js";
|
|
1
|
+
import { ActorLogic, ActorScope, ActorSystem, EventObject, ActorRefFrom, AnyActorSystem, Snapshot, NonReducibleUnknown } from "../types.js";
|
|
2
2
|
export type TransitionSnapshot<TContext> = Snapshot<undefined> & {
|
|
3
3
|
context: TContext;
|
|
4
4
|
};
|
|
5
|
-
export type TransitionActorLogic<TContext, TEvent extends EventObject, TInput> = ActorLogic<TransitionSnapshot<TContext>, TEvent, TInput, AnyActorSystem>;
|
|
5
|
+
export type TransitionActorLogic<TContext, TEvent extends EventObject, TInput extends NonReducibleUnknown> = ActorLogic<TransitionSnapshot<TContext>, TEvent, TInput, AnyActorSystem>;
|
|
6
6
|
export type TransitionActorRef<TContext, TEvent extends EventObject> = ActorRefFrom<TransitionActorLogic<TransitionSnapshot<TContext>, TEvent, unknown>>;
|
|
7
7
|
/**
|
|
8
8
|
* Returns actor logic given a transition function and its initial state.
|
|
@@ -62,7 +62,7 @@ export type TransitionActorRef<TContext, TEvent extends EventObject> = ActorRefF
|
|
|
62
62
|
* // }
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
export declare function fromTransition<TContext, TEvent extends EventObject, TSystem extends ActorSystem<any>, TInput>(transition: (state: TContext, event: TEvent, actorScope: ActorScope<TransitionSnapshot<TContext>, TEvent, TSystem>) => TContext, initialContext: TContext | (({ input, self }: {
|
|
65
|
+
export declare function fromTransition<TContext, TEvent extends EventObject, TSystem extends ActorSystem<any>, TInput extends NonReducibleUnknown>(transition: (state: TContext, event: TEvent, actorScope: ActorScope<TransitionSnapshot<TContext>, TEvent, TSystem>) => TContext, initialContext: TContext | (({ input, self }: {
|
|
66
66
|
input: TInput;
|
|
67
67
|
self: TransitionActorRef<TContext, TEvent>;
|
|
68
68
|
}) => TContext)): TransitionActorLogic<TContext, TEvent, TInput>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StateMachine } from "./StateMachine.js";
|
|
2
2
|
import { GuardPredicate } from "./guards.js";
|
|
3
3
|
import { ResolveTypegenMeta, TypegenDisabled } from "./typegenTypes.js";
|
|
4
|
-
import { ActionFunction, AnyActorLogic, AnyActorRef, AnyEventObject, Cast, ConditionalRequired, DelayConfig, Invert, IsNever, MachineConfig, MachineContext, NonReducibleUnknown, ParameterizedObject, SetupTypes, StateSchema, ToChildren, Values } from "./types.js";
|
|
4
|
+
import { ActionFunction, AnyActorLogic, AnyActorRef, AnyEventObject, Cast, ConditionalRequired, DelayConfig, Invert, IsNever, MachineConfig, MachineContext, NonReducibleUnknown, ParameterizedObject, SetupTypes, StateSchema, ToChildren, UnknownActorLogic, Values } from "./types.js";
|
|
5
5
|
type ToParameterizedObject<TParameterizedMap extends Record<string, ParameterizedObject['params'] | undefined>> = Values<{
|
|
6
6
|
[K in keyof TParameterizedMap & string]: {
|
|
7
7
|
type: K;
|
|
@@ -33,7 +33,7 @@ type ToStateValue<T extends StateSchema> = T extends {
|
|
|
33
33
|
type: 'parallel';
|
|
34
34
|
} ? true : false> : never) : {};
|
|
35
35
|
export declare function setup<TContext extends MachineContext, TEvent extends AnyEventObject, // TODO: consider using a stricter `EventObject` here
|
|
36
|
-
TActors extends Record<Values<TChildrenMap>,
|
|
36
|
+
TActors extends Record<Values<TChildrenMap>, UnknownActorLogic>, TActions extends Record<string, ParameterizedObject['params'] | undefined>, TGuards extends Record<string, ParameterizedObject['params'] | undefined>, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TChildrenMap extends Record<string, string> = never>({ actors, actions, guards, delays }: {
|
|
37
37
|
types?: SetupTypes<TContext, TEvent, TChildrenMap, TTag, TInput, TOutput>;
|
|
38
38
|
actors?: TActors;
|
|
39
39
|
actions?: {
|
|
@@ -736,7 +736,7 @@ export interface ActorRef<TEvent extends EventObject, TSnapshot extends Snapshot
|
|
|
736
736
|
id: string;
|
|
737
737
|
sessionId: string;
|
|
738
738
|
send: (event: TEvent) => void;
|
|
739
|
-
start
|
|
739
|
+
start: () => void;
|
|
740
740
|
getSnapshot: () => TSnapshot;
|
|
741
741
|
getPersistedState: () => Snapshot<unknown>;
|
|
742
742
|
stop: () => void;
|
|
@@ -800,7 +800,7 @@ export type Snapshot<TOutput> = {
|
|
|
800
800
|
* @template TInput - The type of the input.
|
|
801
801
|
* @template TSystem - The type of the actor system.
|
|
802
802
|
*/
|
|
803
|
-
export interface ActorLogic<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject, TInput =
|
|
803
|
+
export interface ActorLogic<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject, TInput = NonReducibleUnknown, TSystem extends ActorSystem<any> = ActorSystem<any>> {
|
|
804
804
|
/** The initial setup/configuration used to create the actor logic. */
|
|
805
805
|
config?: unknown;
|
|
806
806
|
/**
|
|
@@ -811,7 +811,7 @@ export interface ActorLogic<TSnapshot extends Snapshot<unknown>, TEvent extends
|
|
|
811
811
|
* @param ctx - The actor scope.
|
|
812
812
|
* @returns The new state.
|
|
813
813
|
*/
|
|
814
|
-
transition: (
|
|
814
|
+
transition: (snapshot: TSnapshot, message: TEvent, ctx: ActorScope<TSnapshot, TEvent, TSystem>) => TSnapshot;
|
|
815
815
|
/**
|
|
816
816
|
* Called to provide the initial state of the actor.
|
|
817
817
|
* @param actorScope - The actor scope.
|
|
@@ -845,6 +845,8 @@ export type AnyActorLogic = ActorLogic<any, // snapshot
|
|
|
845
845
|
any, // event
|
|
846
846
|
any, // input
|
|
847
847
|
any>;
|
|
848
|
+
export type UnknownActorLogic = ActorLogic<any, // this is invariant and it's hard to figure out a better default than `any`
|
|
849
|
+
EventObject, NonReducibleUnknown, ActorSystem<any>>;
|
|
848
850
|
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 ActorLogic<infer _, infer __, infer ___, infer ____> ? ReturnType<R['transition']> : R extends ActorScope<infer TSnapshot, infer _, infer __> ? TSnapshot : never : never;
|
|
849
851
|
export type EventFromLogic<TLogic extends ActorLogic<any, any, any, any>> = TLogic extends ActorLogic<infer _, infer TEvent, infer __, infer _____> ? TEvent : never;
|
|
850
852
|
type ResolveEventType<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer _TContext, infer TEvent, infer _TChildren, infer _TActor, infer _TAction, infer _TGuard, infer _TDelay, infer _TStateValue, infer _TTag, infer _TInput, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends MachineSnapshot<infer _TContext, infer TEvent, infer _TChildren, infer _TTag, infer _TOutput, infer _TResolvedTypesMeta> ? TEvent : R extends ActorRef<infer TEvent, infer _> ? TEvent : never : never;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { StateNode } from "./StateNode.js";
|
|
2
|
-
import type { ActorLogic,
|
|
3
|
-
export declare function keys<T extends object>(value: T): Array<keyof T & string>;
|
|
2
|
+
import type { ActorLogic, AnyActorRef, AnyEventObject, AnyMachineSnapshot, AnyStateMachine, AnyTransitionConfig, ErrorActorEvent, EventObject, MachineContext, Mapper, NonReducibleUnknown, Observer, SingleOrArray, StateLike, StateValue, TransitionConfigTarget } from "./types.js";
|
|
4
3
|
export declare function matchesState(parentStateId: StateValue, childStateId: StateValue): boolean;
|
|
5
4
|
export declare function toStatePath(stateId: string | string[]): string[];
|
|
6
5
|
export declare function toStateValue(stateValue: StateLike<any> | StateValue): StateValue;
|
|
@@ -8,32 +7,14 @@ export declare function pathToStateValue(statePath: string[]): StateValue;
|
|
|
8
7
|
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): {
|
|
9
8
|
[key in keyof O]: P;
|
|
10
9
|
};
|
|
11
|
-
export declare function mapFilterValues<T, P>(collection: {
|
|
12
|
-
[key: string]: T;
|
|
13
|
-
}, iteratee: (item: T, key: string, collection: {
|
|
14
|
-
[key: string]: T;
|
|
15
|
-
}) => P, predicate: (item: T) => boolean): {
|
|
16
|
-
[key: string]: P;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves a value at the given path.
|
|
20
|
-
* @param props The deep path to the prop of the desired value
|
|
21
|
-
*/
|
|
22
|
-
export declare function path<T extends Record<string, any>>(props: string[]): any;
|
|
23
|
-
export declare function toStatePaths(stateValue: StateValue | undefined): string[][];
|
|
24
10
|
export declare function toArrayStrict<T>(value: readonly T[] | T): readonly T[];
|
|
25
11
|
export declare function toArray<T>(value: readonly T[] | T | undefined): readonly T[];
|
|
26
12
|
export declare function resolveOutput<TContext extends MachineContext, TExpressionEvent extends EventObject>(mapper: Mapper<TContext, TExpressionEvent, unknown, EventObject> | NonReducibleUnknown, context: TContext, event: TExpressionEvent, self: AnyActorRef): unknown;
|
|
27
|
-
export declare function isBuiltInEvent(eventType: string): boolean;
|
|
28
|
-
export declare function isPromiseLike(value: any): value is PromiseLike<any>;
|
|
29
13
|
export declare function isActorLogic(value: any): value is ActorLogic<any, any>;
|
|
30
|
-
export declare function partition<T, A extends T, B extends T>(items: T[], predicate: (item: T) => item is A): [A[], B[]];
|
|
31
14
|
export declare function isArray(value: any): value is readonly any[];
|
|
32
|
-
export declare function isObservable<T>(value: any): value is Subscribable<T>;
|
|
33
15
|
export declare function isErrorActorEvent(event: AnyEventObject): event is ErrorActorEvent;
|
|
34
16
|
export declare function toTransitionConfigArray<TContext extends MachineContext, TEvent extends EventObject>(configLike: SingleOrArray<AnyTransitionConfig | TransitionConfigTarget>): Array<AnyTransitionConfig>;
|
|
35
17
|
export declare function normalizeTarget<TContext extends MachineContext, TEvent extends EventObject>(target: SingleOrArray<string | StateNode<TContext, TEvent>> | undefined): ReadonlyArray<string | StateNode<TContext, TEvent>> | undefined;
|
|
36
|
-
export declare function reportUnhandledExceptionOnInvocation(originalError: any, currentError: any, id: string): void;
|
|
37
18
|
export declare function toObserver<T>(nextHandler?: Observer<T> | ((value: T) => void), errorHandler?: (error: any) => void, completionHandler?: () => void): Observer<T>;
|
|
38
19
|
export declare function createInvokeId(stateNodeId: string, index: number): string;
|
|
39
20
|
export declare function resolveReferencedActor(machine: AnyStateMachine, src: string): any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR, V as createErrorActorEvent, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-acaa3884.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -47,12 +47,7 @@ function createSpawner(actorScope, {
|
|
|
47
47
|
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
actorRef.start?.();
|
|
52
|
-
} catch (err) {
|
|
53
|
-
actorScope.self.send(createErrorActorEvent(actorRef.id, err));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
50
|
+
actorRef.start();
|
|
56
51
|
});
|
|
57
52
|
return actorRef;
|
|
58
53
|
};
|
|
@@ -127,75 +122,6 @@ function choose(branches) {
|
|
|
127
122
|
return choose;
|
|
128
123
|
}
|
|
129
124
|
|
|
130
|
-
function resolveLog(_, state, actionArgs, actionParams, {
|
|
131
|
-
value,
|
|
132
|
-
label
|
|
133
|
-
}) {
|
|
134
|
-
return [state, {
|
|
135
|
-
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
136
|
-
label
|
|
137
|
-
}];
|
|
138
|
-
}
|
|
139
|
-
function executeLog({
|
|
140
|
-
logger
|
|
141
|
-
}, {
|
|
142
|
-
value,
|
|
143
|
-
label
|
|
144
|
-
}) {
|
|
145
|
-
if (label) {
|
|
146
|
-
logger(label, value);
|
|
147
|
-
} else {
|
|
148
|
-
logger(value);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
*
|
|
153
|
-
* @param expr The expression function to evaluate which will be logged.
|
|
154
|
-
* Takes in 2 arguments:
|
|
155
|
-
* - `ctx` - the current state context
|
|
156
|
-
* - `event` - the event that caused this action to be executed.
|
|
157
|
-
* @param label The label to give to the logged expression.
|
|
158
|
-
*/
|
|
159
|
-
function log(value = ({
|
|
160
|
-
context,
|
|
161
|
-
event
|
|
162
|
-
}) => ({
|
|
163
|
-
context,
|
|
164
|
-
event
|
|
165
|
-
}), label) {
|
|
166
|
-
function log(args, params) {
|
|
167
|
-
{
|
|
168
|
-
throw new Error(`This isn't supposed to be called`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
log.type = 'xstate.log';
|
|
172
|
-
log.value = value;
|
|
173
|
-
log.label = label;
|
|
174
|
-
log.resolve = resolveLog;
|
|
175
|
-
log.execute = executeLog;
|
|
176
|
-
return log;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function resolvePure(_, state, args, _actionParams, {
|
|
180
|
-
get
|
|
181
|
-
}) {
|
|
182
|
-
return [state, undefined, toArray(get({
|
|
183
|
-
context: args.context,
|
|
184
|
-
event: args.event
|
|
185
|
-
}))];
|
|
186
|
-
}
|
|
187
|
-
function pure(getActions) {
|
|
188
|
-
function pure(args, params) {
|
|
189
|
-
{
|
|
190
|
-
throw new Error(`This isn't supposed to be called`);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
pure.type = 'xstate.pure';
|
|
194
|
-
pure.get = getActions;
|
|
195
|
-
pure.resolve = resolvePure;
|
|
196
|
-
return pure;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
125
|
/**
|
|
200
126
|
*
|
|
201
127
|
* @remarks
|
|
@@ -399,4 +325,115 @@ function escalate(errorData, options) {
|
|
|
399
325
|
}, options);
|
|
400
326
|
}
|
|
401
327
|
|
|
402
|
-
|
|
328
|
+
function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
329
|
+
collect
|
|
330
|
+
}) {
|
|
331
|
+
const actions = [];
|
|
332
|
+
const enqueue = function enqueue(action) {
|
|
333
|
+
actions.push(action);
|
|
334
|
+
};
|
|
335
|
+
enqueue.assign = (...args) => {
|
|
336
|
+
actions.push(assign(...args));
|
|
337
|
+
};
|
|
338
|
+
enqueue.cancel = (...args) => {
|
|
339
|
+
actions.push(cancel(...args));
|
|
340
|
+
};
|
|
341
|
+
enqueue.raise = (...args) => {
|
|
342
|
+
actions.push(raise(...args));
|
|
343
|
+
};
|
|
344
|
+
enqueue.sendTo = (...args) => {
|
|
345
|
+
actions.push(sendTo(...args));
|
|
346
|
+
};
|
|
347
|
+
enqueue.spawnChild = (...args) => {
|
|
348
|
+
actions.push(spawnChild(...args));
|
|
349
|
+
};
|
|
350
|
+
enqueue.stopChild = (...args) => {
|
|
351
|
+
actions.push(stopChild(...args));
|
|
352
|
+
};
|
|
353
|
+
collect({
|
|
354
|
+
context: args.context,
|
|
355
|
+
event: args.event,
|
|
356
|
+
enqueue,
|
|
357
|
+
check: guard => evaluateGuard(guard, state.context, args.event, state)
|
|
358
|
+
});
|
|
359
|
+
return [state, undefined, actions];
|
|
360
|
+
}
|
|
361
|
+
function enqueueActions(collect) {
|
|
362
|
+
function enqueueActions(args, params) {
|
|
363
|
+
{
|
|
364
|
+
throw new Error(`This isn't supposed to be called`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
enqueueActions.type = 'xstate.enqueueActions';
|
|
368
|
+
enqueueActions.collect = collect;
|
|
369
|
+
enqueueActions.resolve = resolveEnqueueActions;
|
|
370
|
+
return enqueueActions;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
374
|
+
value,
|
|
375
|
+
label
|
|
376
|
+
}) {
|
|
377
|
+
return [state, {
|
|
378
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
379
|
+
label
|
|
380
|
+
}];
|
|
381
|
+
}
|
|
382
|
+
function executeLog({
|
|
383
|
+
logger
|
|
384
|
+
}, {
|
|
385
|
+
value,
|
|
386
|
+
label
|
|
387
|
+
}) {
|
|
388
|
+
if (label) {
|
|
389
|
+
logger(label, value);
|
|
390
|
+
} else {
|
|
391
|
+
logger(value);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
*
|
|
396
|
+
* @param expr The expression function to evaluate which will be logged.
|
|
397
|
+
* Takes in 2 arguments:
|
|
398
|
+
* - `ctx` - the current state context
|
|
399
|
+
* - `event` - the event that caused this action to be executed.
|
|
400
|
+
* @param label The label to give to the logged expression.
|
|
401
|
+
*/
|
|
402
|
+
function log(value = ({
|
|
403
|
+
context,
|
|
404
|
+
event
|
|
405
|
+
}) => ({
|
|
406
|
+
context,
|
|
407
|
+
event
|
|
408
|
+
}), label) {
|
|
409
|
+
function log(args, params) {
|
|
410
|
+
{
|
|
411
|
+
throw new Error(`This isn't supposed to be called`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
log.type = 'xstate.log';
|
|
415
|
+
log.value = value;
|
|
416
|
+
log.label = label;
|
|
417
|
+
log.resolve = resolveLog;
|
|
418
|
+
log.execute = executeLog;
|
|
419
|
+
return log;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
*
|
|
424
|
+
* @deprecated Use `enqueueActions(...)` instead
|
|
425
|
+
*/
|
|
426
|
+
function pure(getActions) {
|
|
427
|
+
return enqueueActions(({
|
|
428
|
+
context,
|
|
429
|
+
event,
|
|
430
|
+
enqueue
|
|
431
|
+
}) => {
|
|
432
|
+
toArray(getActions({
|
|
433
|
+
context,
|
|
434
|
+
event
|
|
435
|
+
})).forEach(enqueue);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export { SpecialTargets as S, assign as a, escalate as b, choose as c, sendTo as d, enqueueActions as e, forwardTo as f, log as l, pure as p, sendParent as s };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-528386de.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -49,12 +49,7 @@ function createSpawner(actorScope, {
|
|
|
49
49
|
if (actorRef._processingStatus === guards_dist_xstateGuards.ProcessingStatus.Stopped) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
actorRef.start?.();
|
|
54
|
-
} catch (err) {
|
|
55
|
-
actorScope.self.send(guards_dist_xstateGuards.createErrorActorEvent(actorRef.id, err));
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
52
|
+
actorRef.start();
|
|
58
53
|
});
|
|
59
54
|
return actorRef;
|
|
60
55
|
};
|
|
@@ -129,75 +124,6 @@ function choose(branches) {
|
|
|
129
124
|
return choose;
|
|
130
125
|
}
|
|
131
126
|
|
|
132
|
-
function resolveLog(_, state, actionArgs, actionParams, {
|
|
133
|
-
value,
|
|
134
|
-
label
|
|
135
|
-
}) {
|
|
136
|
-
return [state, {
|
|
137
|
-
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
138
|
-
label
|
|
139
|
-
}];
|
|
140
|
-
}
|
|
141
|
-
function executeLog({
|
|
142
|
-
logger
|
|
143
|
-
}, {
|
|
144
|
-
value,
|
|
145
|
-
label
|
|
146
|
-
}) {
|
|
147
|
-
if (label) {
|
|
148
|
-
logger(label, value);
|
|
149
|
-
} else {
|
|
150
|
-
logger(value);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
*
|
|
155
|
-
* @param expr The expression function to evaluate which will be logged.
|
|
156
|
-
* Takes in 2 arguments:
|
|
157
|
-
* - `ctx` - the current state context
|
|
158
|
-
* - `event` - the event that caused this action to be executed.
|
|
159
|
-
* @param label The label to give to the logged expression.
|
|
160
|
-
*/
|
|
161
|
-
function log(value = ({
|
|
162
|
-
context,
|
|
163
|
-
event
|
|
164
|
-
}) => ({
|
|
165
|
-
context,
|
|
166
|
-
event
|
|
167
|
-
}), label) {
|
|
168
|
-
function log(args, params) {
|
|
169
|
-
{
|
|
170
|
-
throw new Error(`This isn't supposed to be called`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
log.type = 'xstate.log';
|
|
174
|
-
log.value = value;
|
|
175
|
-
log.label = label;
|
|
176
|
-
log.resolve = resolveLog;
|
|
177
|
-
log.execute = executeLog;
|
|
178
|
-
return log;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function resolvePure(_, state, args, _actionParams, {
|
|
182
|
-
get
|
|
183
|
-
}) {
|
|
184
|
-
return [state, undefined, guards_dist_xstateGuards.toArray(get({
|
|
185
|
-
context: args.context,
|
|
186
|
-
event: args.event
|
|
187
|
-
}))];
|
|
188
|
-
}
|
|
189
|
-
function pure(getActions) {
|
|
190
|
-
function pure(args, params) {
|
|
191
|
-
{
|
|
192
|
-
throw new Error(`This isn't supposed to be called`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
pure.type = 'xstate.pure';
|
|
196
|
-
pure.get = getActions;
|
|
197
|
-
pure.resolve = resolvePure;
|
|
198
|
-
return pure;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
127
|
/**
|
|
202
128
|
*
|
|
203
129
|
* @remarks
|
|
@@ -401,9 +327,121 @@ function escalate(errorData, options) {
|
|
|
401
327
|
}, options);
|
|
402
328
|
}
|
|
403
329
|
|
|
330
|
+
function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
331
|
+
collect
|
|
332
|
+
}) {
|
|
333
|
+
const actions = [];
|
|
334
|
+
const enqueue = function enqueue(action) {
|
|
335
|
+
actions.push(action);
|
|
336
|
+
};
|
|
337
|
+
enqueue.assign = (...args) => {
|
|
338
|
+
actions.push(assign(...args));
|
|
339
|
+
};
|
|
340
|
+
enqueue.cancel = (...args) => {
|
|
341
|
+
actions.push(guards_dist_xstateGuards.cancel(...args));
|
|
342
|
+
};
|
|
343
|
+
enqueue.raise = (...args) => {
|
|
344
|
+
actions.push(guards_dist_xstateGuards.raise(...args));
|
|
345
|
+
};
|
|
346
|
+
enqueue.sendTo = (...args) => {
|
|
347
|
+
actions.push(sendTo(...args));
|
|
348
|
+
};
|
|
349
|
+
enqueue.spawnChild = (...args) => {
|
|
350
|
+
actions.push(guards_dist_xstateGuards.spawnChild(...args));
|
|
351
|
+
};
|
|
352
|
+
enqueue.stopChild = (...args) => {
|
|
353
|
+
actions.push(guards_dist_xstateGuards.stopChild(...args));
|
|
354
|
+
};
|
|
355
|
+
collect({
|
|
356
|
+
context: args.context,
|
|
357
|
+
event: args.event,
|
|
358
|
+
enqueue,
|
|
359
|
+
check: guard => guards_dist_xstateGuards.evaluateGuard(guard, state.context, args.event, state)
|
|
360
|
+
});
|
|
361
|
+
return [state, undefined, actions];
|
|
362
|
+
}
|
|
363
|
+
function enqueueActions(collect) {
|
|
364
|
+
function enqueueActions(args, params) {
|
|
365
|
+
{
|
|
366
|
+
throw new Error(`This isn't supposed to be called`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
enqueueActions.type = 'xstate.enqueueActions';
|
|
370
|
+
enqueueActions.collect = collect;
|
|
371
|
+
enqueueActions.resolve = resolveEnqueueActions;
|
|
372
|
+
return enqueueActions;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
376
|
+
value,
|
|
377
|
+
label
|
|
378
|
+
}) {
|
|
379
|
+
return [state, {
|
|
380
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
381
|
+
label
|
|
382
|
+
}];
|
|
383
|
+
}
|
|
384
|
+
function executeLog({
|
|
385
|
+
logger
|
|
386
|
+
}, {
|
|
387
|
+
value,
|
|
388
|
+
label
|
|
389
|
+
}) {
|
|
390
|
+
if (label) {
|
|
391
|
+
logger(label, value);
|
|
392
|
+
} else {
|
|
393
|
+
logger(value);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
*
|
|
398
|
+
* @param expr The expression function to evaluate which will be logged.
|
|
399
|
+
* Takes in 2 arguments:
|
|
400
|
+
* - `ctx` - the current state context
|
|
401
|
+
* - `event` - the event that caused this action to be executed.
|
|
402
|
+
* @param label The label to give to the logged expression.
|
|
403
|
+
*/
|
|
404
|
+
function log(value = ({
|
|
405
|
+
context,
|
|
406
|
+
event
|
|
407
|
+
}) => ({
|
|
408
|
+
context,
|
|
409
|
+
event
|
|
410
|
+
}), label) {
|
|
411
|
+
function log(args, params) {
|
|
412
|
+
{
|
|
413
|
+
throw new Error(`This isn't supposed to be called`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
log.type = 'xstate.log';
|
|
417
|
+
log.value = value;
|
|
418
|
+
log.label = label;
|
|
419
|
+
log.resolve = resolveLog;
|
|
420
|
+
log.execute = executeLog;
|
|
421
|
+
return log;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
*
|
|
426
|
+
* @deprecated Use `enqueueActions(...)` instead
|
|
427
|
+
*/
|
|
428
|
+
function pure(getActions) {
|
|
429
|
+
return enqueueActions(({
|
|
430
|
+
context,
|
|
431
|
+
event,
|
|
432
|
+
enqueue
|
|
433
|
+
}) => {
|
|
434
|
+
guards_dist_xstateGuards.toArray(getActions({
|
|
435
|
+
context,
|
|
436
|
+
event
|
|
437
|
+
})).forEach(enqueue);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
404
441
|
exports.SpecialTargets = SpecialTargets;
|
|
405
442
|
exports.assign = assign;
|
|
406
443
|
exports.choose = choose;
|
|
444
|
+
exports.enqueueActions = enqueueActions;
|
|
407
445
|
exports.escalate = escalate;
|
|
408
446
|
exports.forwardTo = forwardTo;
|
|
409
447
|
exports.log = log;
|