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.
- package/actions/dist/xstate-actions.cjs.js +1 -1
- package/actions/dist/xstate-actions.development.cjs.js +1 -1
- package/actions/dist/xstate-actions.development.esm.js +1 -1
- package/actions/dist/xstate-actions.esm.js +1 -1
- 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 +1 -1
- package/actors/dist/xstate-actors.development.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.esm.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/{actions-e4c704f3.cjs.js → actions-17c3bcfa.cjs.js} +803 -853
- package/dist/{actions-b34f6ce7.esm.js → actions-444a17c3.esm.js} +804 -854
- package/dist/{actions-c8b9504d.development.esm.js → actions-60622c0c.development.esm.js} +829 -879
- package/dist/{actions-d9c19f35.development.cjs.js → actions-73b8d456.development.cjs.js} +828 -878
- package/dist/declarations/src/Machine.d.ts +3 -3
- package/dist/declarations/src/SimulatedClock.d.ts +1 -1
- package/dist/declarations/src/State.d.ts +4 -10
- package/dist/declarations/src/StateMachine.d.ts +8 -13
- package/dist/declarations/src/StateNode.d.ts +4 -4
- package/dist/declarations/src/actionTypes.d.ts +1 -1
- package/dist/declarations/src/actions/assign.d.ts +1 -1
- package/dist/declarations/src/actions/cancel.d.ts +2 -2
- package/dist/declarations/src/actions/choose.d.ts +2 -2
- package/dist/declarations/src/actions/log.d.ts +2 -2
- package/dist/declarations/src/actions/pure.d.ts +2 -2
- package/dist/declarations/src/actions/raise.d.ts +1 -1
- package/dist/declarations/src/actions/send.d.ts +2 -2
- package/dist/declarations/src/actions/stop.d.ts +1 -1
- package/dist/declarations/src/actions.d.ts +10 -10
- package/dist/declarations/src/actors/callback.d.ts +2 -2
- package/dist/declarations/src/actors/index.d.ts +6 -6
- package/dist/declarations/src/actors/observable.d.ts +8 -6
- package/dist/declarations/src/actors/promise.d.ts +4 -3
- package/dist/declarations/src/actors/transition.d.ts +4 -4
- package/dist/declarations/src/dev/index.d.ts +1 -1
- package/dist/declarations/src/guards.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +22 -22
- package/dist/declarations/src/interpreter.d.ts +18 -18
- package/dist/declarations/src/stateUtils.d.ts +8 -10
- package/dist/declarations/src/typegenTypes.d.ts +1 -1
- package/dist/declarations/src/types.d.ts +29 -39
- package/dist/declarations/src/utils.d.ts +9 -9
- package/dist/declarations/src/waitFor.d.ts +1 -1
- package/dist/xstate.cjs.js +13 -37
- package/dist/xstate.development.cjs.js +13 -37
- package/dist/xstate.development.esm.js +14 -38
- package/dist/xstate.esm.js +14 -38
- 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,9 @@
|
|
|
1
|
-
import type { StateNode } from
|
|
2
|
-
import type { State } from
|
|
3
|
-
import type { ActorStatus, Clock, Interpreter } from
|
|
4
|
-
import type { StateMachine } from
|
|
5
|
-
import type { LifecycleSignal } from
|
|
6
|
-
import { TypegenDisabled, ResolveTypegenMeta, TypegenConstraint, MarkAllImplementationsAsProvided, AreAllImplementationsAssumedToBeProvided } from
|
|
1
|
+
import type { StateNode } from "./StateNode.js";
|
|
2
|
+
import type { State } from "./State.js";
|
|
3
|
+
import type { ActorStatus, Clock, Interpreter } from "./interpreter.js";
|
|
4
|
+
import type { StateMachine } from "./StateMachine.js";
|
|
5
|
+
import type { LifecycleSignal } from "./actors/index.js";
|
|
6
|
+
import { TypegenDisabled, ResolveTypegenMeta, TypegenConstraint, MarkAllImplementationsAsProvided, AreAllImplementationsAssumedToBeProvided } from "./typegenTypes.js";
|
|
7
7
|
export type AnyFunction = (...args: any[]) => any;
|
|
8
8
|
type ReturnTypeOrValue<T> = T extends AnyFunction ? ReturnType<T> : T;
|
|
9
9
|
export type IsNever<T> = [T] extends [never] ? true : false;
|
|
@@ -76,12 +76,12 @@ export type MachineContext = Record<string, any>;
|
|
|
76
76
|
export interface ActionMeta<TEvent extends EventObject, TAction extends ParameterizedObject = ParameterizedObject> extends StateMeta<TEvent> {
|
|
77
77
|
action: TAction;
|
|
78
78
|
}
|
|
79
|
-
export type Spawner = <T extends
|
|
80
|
-
|
|
79
|
+
export type Spawner = <T extends ActorLogic<any, any> | string>(// TODO: read string from machine logic keys
|
|
80
|
+
logic: T, options?: Partial<{
|
|
81
81
|
id: string;
|
|
82
82
|
systemId?: string;
|
|
83
83
|
input: any;
|
|
84
|
-
}>) => T extends
|
|
84
|
+
}>) => T extends ActorLogic<infer TActorEvent, infer TActorEmitted, infer _, infer __, infer ___> ? ActorRef<TActorEvent, TActorEmitted> : ActorRef<any, any>;
|
|
85
85
|
export interface AssignMeta<TExpressionEvent extends EventObject, _TEvent extends EventObject> extends StateMeta<TExpressionEvent> {
|
|
86
86
|
action: BaseActionObject;
|
|
87
87
|
event: TExpressionEvent;
|
|
@@ -182,17 +182,10 @@ type ExtractWithSimpleSupport<T extends {
|
|
|
182
182
|
export type Receiver<TEvent extends EventObject> = (listener: {
|
|
183
183
|
bivarianceHack(event: TEvent): void;
|
|
184
184
|
}['bivarianceHack']) => void;
|
|
185
|
-
export type InvokeCallback<TEvent extends EventObject = AnyEventObject, TSentEvent extends EventObject = AnyEventObject> = (sendBack: (event: TSentEvent) => void, onReceive: Receiver<TEvent>, { input }: {
|
|
185
|
+
export type InvokeCallback<TEvent extends EventObject = AnyEventObject, TSentEvent extends EventObject = AnyEventObject> = (sendBack: (event: TSentEvent) => void, onReceive: Receiver<TEvent>, { input, system }: {
|
|
186
186
|
input: any;
|
|
187
|
+
system: AnyActorSystem;
|
|
187
188
|
}) => (() => void) | Promise<any> | void;
|
|
188
|
-
export type ActorBehaviorCreator<TContext extends MachineContext, TEvent extends EventObject, TActorBehavior extends AnyActorBehavior = AnyActorBehavior> = (context: TContext, event: TEvent, meta: {
|
|
189
|
-
id: string;
|
|
190
|
-
data?: any;
|
|
191
|
-
src: string;
|
|
192
|
-
event: TEvent;
|
|
193
|
-
meta: MetaObject | undefined;
|
|
194
|
-
input: any;
|
|
195
|
-
}) => TActorBehavior;
|
|
196
189
|
export interface InvokeMeta {
|
|
197
190
|
src: string;
|
|
198
191
|
meta: MetaObject | undefined;
|
|
@@ -201,7 +194,7 @@ export interface InvokeDefinition<TContext extends MachineContext, TEvent extend
|
|
|
201
194
|
id: string;
|
|
202
195
|
systemId: string | undefined;
|
|
203
196
|
/**
|
|
204
|
-
* The source of the actor
|
|
197
|
+
* The source of the actor logic to be invoked
|
|
205
198
|
*/
|
|
206
199
|
src: string;
|
|
207
200
|
input?: Mapper<TContext, TEvent, any> | any;
|
|
@@ -259,7 +252,7 @@ export interface InvokeConfig<TContext extends MachineContext, TEvent extends Ev
|
|
|
259
252
|
/**
|
|
260
253
|
* The source of the machine to be invoked, or the machine itself.
|
|
261
254
|
*/
|
|
262
|
-
src: string |
|
|
255
|
+
src: string | ActorLogic<any, any>;
|
|
263
256
|
input?: Mapper<TContext, TEvent, any> | any;
|
|
264
257
|
/**
|
|
265
258
|
* The transition to take upon the invoked child machine reaching its final top-level state.
|
|
@@ -428,8 +421,8 @@ export type DelayConfig<TContext extends MachineContext, TEvent extends EventObj
|
|
|
428
421
|
export interface MachineImplementationsSimplified<TContext extends MachineContext, TEvent extends EventObject, TAction extends ParameterizedObject = ParameterizedObject> {
|
|
429
422
|
guards: Record<string, GuardPredicate<TContext, TEvent>>;
|
|
430
423
|
actions: ActionFunctionMap<TContext, TEvent, TAction>;
|
|
431
|
-
actors: Record<string,
|
|
432
|
-
src:
|
|
424
|
+
actors: Record<string, AnyActorLogic | {
|
|
425
|
+
src: AnyActorLogic;
|
|
433
426
|
input: Mapper<TContext, TEvent, any> | any;
|
|
434
427
|
}>;
|
|
435
428
|
delays: DelayFunctionMap<TContext, TEvent>;
|
|
@@ -446,8 +439,8 @@ type MachineImplementationsGuards<TContext extends MachineContext, TResolvedType
|
|
|
446
439
|
[K in keyof TEventsCausingGuards]?: GuardPredicate<TContext, Cast<Prop<TIndexedEvents, TEventsCausingGuards[K]>, EventObject>>;
|
|
447
440
|
};
|
|
448
441
|
type MachineImplementationsActors<TContext extends MachineContext, TResolvedTypesMeta, TEventsCausingActors = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'eventsCausingActors'>, TIndexedEvents = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'indexedEvents'>, _TInvokeSrcNameMap = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'invokeSrcNameMap'>> = {
|
|
449
|
-
[K in keyof TEventsCausingActors]?:
|
|
450
|
-
src:
|
|
442
|
+
[K in keyof TEventsCausingActors]?: AnyActorLogic | {
|
|
443
|
+
src: AnyActorLogic;
|
|
451
444
|
input: Mapper<TContext, Cast<Prop<TIndexedEvents, TEventsCausingActors[K]>, EventObject>, any> | any;
|
|
452
445
|
};
|
|
453
446
|
};
|
|
@@ -782,9 +775,7 @@ export interface StateLike<TContext extends MachineContext> {
|
|
|
782
775
|
export interface StateConfig<TContext extends MachineContext, TEvent extends EventObject> {
|
|
783
776
|
value: StateValue;
|
|
784
777
|
context: TContext;
|
|
785
|
-
event: TEvent;
|
|
786
778
|
historyValue?: HistoryValue<TContext, TEvent>;
|
|
787
|
-
actions?: BaseActionObject[];
|
|
788
779
|
meta?: any;
|
|
789
780
|
configuration?: Array<StateNode<TContext, TEvent>>;
|
|
790
781
|
transitions?: Array<TransitionDefinition<TContext, TEvent>>;
|
|
@@ -795,7 +786,7 @@ export interface StateConfig<TContext extends MachineContext, TEvent extends Eve
|
|
|
795
786
|
machine?: StateMachine<TContext, TEvent, any, any, any>;
|
|
796
787
|
_internalQueue?: Array<TEvent>;
|
|
797
788
|
}
|
|
798
|
-
export interface InterpreterOptions<
|
|
789
|
+
export interface InterpreterOptions<_TActorLogic extends AnyActorLogic> {
|
|
799
790
|
/**
|
|
800
791
|
* Whether state actions should be executed immediately upon transition. Defaults to `true`.
|
|
801
792
|
*/
|
|
@@ -855,7 +846,6 @@ export interface Subscribable<T> extends InteropSubscribable<T> {
|
|
|
855
846
|
subscribe(observer: Observer<T>): Subscription;
|
|
856
847
|
subscribe(next: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;
|
|
857
848
|
}
|
|
858
|
-
export type Spawnable = AnyStateMachine | PromiseLike<any> | InvokeCallback | InteropObservable<any> | Subscribable<any> | ActorBehavior<any, any>;
|
|
859
849
|
export type ExtractEvent<TEvent extends EventObject, TEventType extends TEvent['type']> = TEvent extends any ? TEventType extends TEvent['type'] ? TEvent : never : never;
|
|
860
850
|
export interface BaseActorRef<TEvent extends EventObject> {
|
|
861
851
|
send: (event: TEvent) => void;
|
|
@@ -883,9 +873,9 @@ export interface ActorRef<TEvent extends EventObject, TSnapshot = any> extends S
|
|
|
883
873
|
export type AnyActorRef = ActorRef<any, any>;
|
|
884
874
|
export type ActorRefFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer TEvent, any, any, infer TResolvedTypesMeta> ? ActorRef<TEvent, State<TContext, TEvent, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>> : R extends Promise<infer U> ? ActorRef<{
|
|
885
875
|
type: string;
|
|
886
|
-
}, U | undefined> : R extends
|
|
876
|
+
}, U | undefined> : R extends ActorLogic<infer TEvent, infer TSnapshot> ? ActorRef<TEvent, TSnapshot> : never : never;
|
|
887
877
|
export type DevToolsAdapter = (service: AnyInterpreter) => void;
|
|
888
|
-
export type InterpreterFrom<T extends AnyStateMachine | ((...args: any[]) => AnyStateMachine)> = ReturnTypeOrValue<T> extends StateMachine<infer TContext, infer TEvent, any, any, infer TResolvedTypesMeta> ? Interpreter<
|
|
878
|
+
export type InterpreterFrom<T extends AnyStateMachine | ((...args: any[]) => AnyStateMachine)> = ReturnTypeOrValue<T> extends StateMachine<infer TContext, infer TEvent, any, any, infer TResolvedTypesMeta> ? Interpreter<ActorLogic<TEvent, State<TContext, TEvent, TResolvedTypesMeta>, State<TContext, TEvent, TResolvedTypesMeta>, PersistedMachineState<State<TContext, TEvent, TResolvedTypesMeta>>>> : never;
|
|
889
879
|
export type MachineImplementationsFrom<T extends AnyStateMachine | ((...args: any[]) => AnyStateMachine), TRequireMissingImplementations extends boolean = false> = ReturnTypeOrValue<T> extends StateMachine<infer TContext, infer TEvent, any, any, infer TResolvedTypesMeta> ? InternalMachineImplementations<TContext, TEvent, TResolvedTypesMeta, TRequireMissingImplementations> : never;
|
|
890
880
|
export type __ResolvedTypesMetaFrom<T> = T extends StateMachine<any, any, any, infer TResolvedTypesMeta> ? TResolvedTypesMeta : never;
|
|
891
881
|
export type EventOfMachine<TMachine extends AnyStateMachine> = TMachine extends StateMachine<any, infer E, any, any, any> ? E : never;
|
|
@@ -899,7 +889,7 @@ export interface ActorContext<TEvent extends EventObject, TSnapshot, TSystem ext
|
|
|
899
889
|
stopChild: (child: AnyActorRef) => void;
|
|
900
890
|
}
|
|
901
891
|
export type AnyActorContext = ActorContext<any, any, any>;
|
|
902
|
-
export interface
|
|
892
|
+
export interface ActorLogic<TEvent extends EventObject, TSnapshot = any, TInternalState = TSnapshot,
|
|
903
893
|
/**
|
|
904
894
|
* Serialized internal state used for persistence & restoration
|
|
905
895
|
*/
|
|
@@ -919,14 +909,14 @@ TPersisted = TInternalState, TSystem extends ActorSystem<any> = ActorSystem<any>
|
|
|
919
909
|
*/
|
|
920
910
|
getPersistedState?: (state: TInternalState) => TPersisted;
|
|
921
911
|
}
|
|
922
|
-
export type
|
|
923
|
-
export type SnapshotFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer _, infer TSnapshot> ? TSnapshot : R extends Interpreter<infer
|
|
924
|
-
export type
|
|
925
|
-
export type PersistedStateFrom<
|
|
926
|
-
export type InternalStateFrom<
|
|
912
|
+
export type AnyActorLogic = ActorLogic<any, any, any, any>;
|
|
913
|
+
export type SnapshotFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer _, infer TSnapshot> ? TSnapshot : R extends Interpreter<infer TLogic> ? SnapshotFrom<TLogic> : R extends StateMachine<infer _, infer __, infer ___, infer ____, infer _____> ? StateFrom<R> : R extends ActorLogic<infer _, infer TSnapshot, infer __, infer ___, infer ____> ? TSnapshot : R extends ActorContext<infer _, infer TSnapshot, infer __> ? TSnapshot : never : never;
|
|
914
|
+
export type EventFromLogic<TLogic extends ActorLogic<any, any>> = TLogic extends ActorLogic<infer TEvent, infer _, infer __, infer ___, infer ____> ? TEvent : never;
|
|
915
|
+
export type PersistedStateFrom<TLogic extends ActorLogic<any, any>> = TLogic extends ActorLogic<infer _TEvent, infer _TSnapshot, infer _TInternalState, infer TPersisted> ? TPersisted : never;
|
|
916
|
+
export type InternalStateFrom<TLogic extends ActorLogic<any, any>> = TLogic extends ActorLogic<infer _TEvent, infer _TSnapshot, infer TInternalState, infer _TPersisted> ? TInternalState : never;
|
|
927
917
|
type ResolveEventType<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer _, infer TEvent, infer __, infer ___, infer ____> ? TEvent : R extends State<infer _, infer TEvent, infer __> ? TEvent : R extends ActorRef<infer TEvent, infer _> ? TEvent : never : never;
|
|
928
918
|
export type EventFrom<T, K extends Prop<TEvent, 'type'> = never, TEvent extends EventObject = ResolveEventType<T>> = IsNever<K> extends true ? TEvent : ExtractEvent<TEvent, K>;
|
|
929
|
-
export type ContextFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer _, infer __, infer ___, infer ____> ? TContext : R extends State<infer TContext, infer _, infer __> ? TContext : R extends Interpreter<infer
|
|
919
|
+
export type ContextFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer _, infer __, infer ___, infer ____> ? TContext : R extends State<infer TContext, infer _, infer __> ? TContext : R extends Interpreter<infer TActorLogic> ? TActorLogic extends StateMachine<infer TContext, infer _> ? TContext : never : never : never;
|
|
930
920
|
export type InferEvent<E extends EventObject> = {
|
|
931
921
|
[T in E['type']]: {
|
|
932
922
|
type: T;
|
|
@@ -937,7 +927,6 @@ export type InferEvent<E extends EventObject> = {
|
|
|
937
927
|
export type TODO = any;
|
|
938
928
|
export type StateValueFrom<TMachine extends AnyStateMachine> = Parameters<StateFrom<TMachine>['matches']>[0];
|
|
939
929
|
export type TagsFrom<TMachine extends AnyStateMachine> = Parameters<StateFrom<TMachine>['hasTag']>[0];
|
|
940
|
-
export type StateFromMachine<TMachine extends AnyStateMachine> = TMachine['initialState'];
|
|
941
930
|
export interface ActorSystemInfo {
|
|
942
931
|
actors: Record<string, AnyActorRef>;
|
|
943
932
|
}
|
|
@@ -948,7 +937,8 @@ export interface ActorSystem<T extends ActorSystemInfo> {
|
|
|
948
937
|
_set: <K extends keyof T['actors']>(key: K, actorRef: T['actors'][K]) => void;
|
|
949
938
|
get: <K extends keyof T['actors']>(key: K) => T['actors'][K] | undefined;
|
|
950
939
|
}
|
|
951
|
-
export type
|
|
940
|
+
export type AnyActorSystem = ActorSystem<any>;
|
|
941
|
+
export type PersistedMachineState<TState extends AnyState> = Pick<TState, 'value' | 'output' | 'context' | 'done' | 'historyValue'> & {
|
|
952
942
|
children: {
|
|
953
943
|
[K in keyof TState['children']]: {
|
|
954
944
|
state: any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NULL_EVENT } from
|
|
3
|
-
import type { StateNode } from
|
|
4
|
-
import type {
|
|
1
|
+
import { AnyActorLogic, AnyState } from "./index.js";
|
|
2
|
+
import { NULL_EVENT } from "./constants.js";
|
|
3
|
+
import type { StateNode } from "./StateNode.js";
|
|
4
|
+
import type { ActorLogic, AnyEventObject, EventObject, EventType, InvokeConfig, MachineContext, Mapper, Observer, PropertyMapper, ErrorEvent, SingleOrArray, StateLike, StateValue, Subscribable, TransitionConfig, TransitionConfigTarget } from "./types.js";
|
|
5
5
|
export declare function keys<T extends object>(value: T): Array<keyof T & string>;
|
|
6
6
|
export declare function matchesState(parentStateId: StateValue, childStateId: StateValue, delimiter?: string): boolean;
|
|
7
7
|
export declare function toStatePath(stateId: string | string[], delimiter: string): string[];
|
|
@@ -30,7 +30,7 @@ export declare function toArray<T>(value: T[] | T | undefined): T[];
|
|
|
30
30
|
export declare function mapContext<TContext extends MachineContext, TEvent extends EventObject>(mapper: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>, context: TContext, event: TEvent): any;
|
|
31
31
|
export declare function isBuiltInEvent(eventType: EventType): boolean;
|
|
32
32
|
export declare function isPromiseLike(value: any): value is PromiseLike<any>;
|
|
33
|
-
export declare function
|
|
33
|
+
export declare function isActorLogic(value: any): value is ActorLogic<any, any>;
|
|
34
34
|
export declare function partition<T, A extends T, B extends T>(items: T[], predicate: (item: T) => item is A): [A[], B[]];
|
|
35
35
|
export declare function isArray(value: any): value is any[];
|
|
36
36
|
export declare function isFunction(value: any): value is Function;
|
|
@@ -43,13 +43,13 @@ export declare function toTransitionConfigArray<TContext extends MachineContext,
|
|
|
43
43
|
}>;
|
|
44
44
|
export declare function normalizeTarget<TContext extends MachineContext, TEvent extends EventObject>(target: SingleOrArray<string | StateNode<TContext, TEvent>> | undefined): Array<string | StateNode<TContext, TEvent>> | undefined;
|
|
45
45
|
export declare function reportUnhandledExceptionOnInvocation(originalError: any, currentError: any, id: string): void;
|
|
46
|
-
export declare function toInvokeConfig<TContext extends MachineContext, TEvent extends EventObject>(invocable: InvokeConfig<TContext, TEvent> | string |
|
|
46
|
+
export declare function toInvokeConfig<TContext extends MachineContext, TEvent extends EventObject>(invocable: InvokeConfig<TContext, TEvent> | string | ActorLogic<any, any>, id: string): InvokeConfig<TContext, TEvent>;
|
|
47
47
|
export declare function toObserver<T>(nextHandler?: Observer<T> | ((value: T) => void), errorHandler?: (error: any) => void, completionHandler?: () => void): Observer<T>;
|
|
48
48
|
export declare function createInvokeId(stateNodeId: string, index: number): string;
|
|
49
|
-
export declare function resolveReferencedActor(referenced:
|
|
50
|
-
src:
|
|
49
|
+
export declare function resolveReferencedActor(referenced: AnyActorLogic | {
|
|
50
|
+
src: AnyActorLogic;
|
|
51
51
|
input: Mapper<any, any, any> | any;
|
|
52
52
|
} | undefined): {
|
|
53
|
-
src:
|
|
53
|
+
src: AnyActorLogic;
|
|
54
54
|
input: Mapper<any, any, any> | any;
|
|
55
55
|
} | undefined;
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var actors_dist_xstateActors = require('./actions-
|
|
5
|
+
var actors_dist_xstateActors = require('./actions-17c3bcfa.cjs.js');
|
|
6
6
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
7
7
|
|
|
8
8
|
const EMPTY_OBJECT = {};
|
|
@@ -173,15 +173,15 @@ class StateNode {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
|
-
* The
|
|
176
|
+
* The logic invoked as actors by this state node.
|
|
177
177
|
*/
|
|
178
178
|
get invoke() {
|
|
179
179
|
return actors_dist_xstateActors.memo(this, 'invoke', () => actors_dist_xstateActors.toArray(this.config.invoke).map((invocable, i) => {
|
|
180
180
|
const generatedId = actors_dist_xstateActors.createInvokeId(this.id, i);
|
|
181
181
|
const invokeConfig = actors_dist_xstateActors.toInvokeConfig(invocable, generatedId);
|
|
182
182
|
const resolvedId = invokeConfig.id || generatedId;
|
|
183
|
+
const src = invokeConfig.src;
|
|
183
184
|
const {
|
|
184
|
-
src,
|
|
185
185
|
systemId
|
|
186
186
|
} = invokeConfig;
|
|
187
187
|
const resolvedSrc = actors_dist_xstateActors.isString(src) ? src : !('type' in src) ? resolvedId : src;
|
|
@@ -451,15 +451,14 @@ class StateMachine {
|
|
|
451
451
|
* @param state The current State instance or state value
|
|
452
452
|
* @param event The received event
|
|
453
453
|
*/
|
|
454
|
-
transition(state
|
|
455
|
-
const currentState = state instanceof actors_dist_xstateActors.State ? state : this.resolveStateValue(state);
|
|
454
|
+
transition(state, event, actorCtx) {
|
|
456
455
|
// TODO: handle error events in a better way
|
|
457
|
-
if (actors_dist_xstateActors.isErrorEvent(event) && !
|
|
456
|
+
if (actors_dist_xstateActors.isErrorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
458
457
|
throw event.data;
|
|
459
458
|
}
|
|
460
459
|
const {
|
|
461
460
|
state: nextState
|
|
462
|
-
} = actors_dist_xstateActors.macrostep(
|
|
461
|
+
} = actors_dist_xstateActors.macrostep(state, event, actorCtx);
|
|
463
462
|
return nextState;
|
|
464
463
|
}
|
|
465
464
|
|
|
@@ -470,7 +469,7 @@ class StateMachine {
|
|
|
470
469
|
* @param state The current state
|
|
471
470
|
* @param event The received event
|
|
472
471
|
*/
|
|
473
|
-
microstep(state
|
|
472
|
+
microstep(state, event, actorCtx) {
|
|
474
473
|
return actors_dist_xstateActors.macrostep(state, event, actorCtx).microstates;
|
|
475
474
|
}
|
|
476
475
|
getTransitionData(state, event) {
|
|
@@ -488,33 +487,19 @@ class StateMachine {
|
|
|
488
487
|
value: {},
|
|
489
488
|
// TODO: this is computed in state constructor
|
|
490
489
|
context,
|
|
491
|
-
event: actors_dist_xstateActors.createInitEvent({}),
|
|
492
|
-
actions: [],
|
|
493
490
|
meta: undefined,
|
|
494
491
|
configuration: config,
|
|
495
492
|
transitions: [],
|
|
496
493
|
children: {}
|
|
497
494
|
}));
|
|
498
495
|
preInitial._initial = true;
|
|
499
|
-
preInitial.actions.unshift(...actions);
|
|
500
496
|
if (actorCtx) {
|
|
501
|
-
const
|
|
502
|
-
nextState
|
|
503
|
-
} = actors_dist_xstateActors.resolveActionsAndContext(actions, actors_dist_xstateActors.initEvent, preInitial, actorCtx);
|
|
497
|
+
const [nextState] = actors_dist_xstateActors.resolveActionsAndContext(actions, actors_dist_xstateActors.initEvent, preInitial, actorCtx);
|
|
504
498
|
preInitial.children = nextState.children;
|
|
505
|
-
preInitial.actions = nextState.actions;
|
|
506
499
|
}
|
|
507
500
|
return preInitial;
|
|
508
501
|
}
|
|
509
502
|
|
|
510
|
-
/**
|
|
511
|
-
* The initial State instance, which includes all actions to be executed from
|
|
512
|
-
* entering the initial state.
|
|
513
|
-
*/
|
|
514
|
-
get initialState() {
|
|
515
|
-
return this.getInitialState();
|
|
516
|
-
}
|
|
517
|
-
|
|
518
503
|
/**
|
|
519
504
|
* Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
|
|
520
505
|
*/
|
|
@@ -523,16 +508,12 @@ class StateMachine {
|
|
|
523
508
|
|
|
524
509
|
const preInitialState = this.getPreInitialState(actorCtx, input);
|
|
525
510
|
const nextState = actors_dist_xstateActors.microstep([], preInitialState, actorCtx, initEvent);
|
|
526
|
-
nextState.actions.unshift(...preInitialState.actions);
|
|
527
511
|
const {
|
|
528
512
|
state: macroState
|
|
529
513
|
} = actors_dist_xstateActors.macrostep(nextState, initEvent, actorCtx);
|
|
530
514
|
return macroState;
|
|
531
515
|
}
|
|
532
516
|
start(state, actorCtx) {
|
|
533
|
-
state.actions.forEach(action => {
|
|
534
|
-
action.execute?.(actorCtx);
|
|
535
|
-
});
|
|
536
517
|
Object.values(state.children).forEach(child => {
|
|
537
518
|
if (child.status === 0) {
|
|
538
519
|
try {
|
|
@@ -567,11 +548,7 @@ class StateMachine {
|
|
|
567
548
|
return actors_dist_xstateActors.getPersistedState(state);
|
|
568
549
|
}
|
|
569
550
|
createState(stateConfig) {
|
|
570
|
-
|
|
571
|
-
const {
|
|
572
|
-
nextState: resolvedState
|
|
573
|
-
} = actors_dist_xstateActors.resolveActionsAndContext(state.actions, state.event, state, undefined);
|
|
574
|
-
return resolvedState;
|
|
551
|
+
return stateConfig instanceof actors_dist_xstateActors.State ? stateConfig : new actors_dist_xstateActors.State(stateConfig, this);
|
|
575
552
|
}
|
|
576
553
|
getStatus(state) {
|
|
577
554
|
return state.done ? {
|
|
@@ -587,12 +564,12 @@ class StateMachine {
|
|
|
587
564
|
const actorData = state.children[actorId];
|
|
588
565
|
const childState = actorData.state;
|
|
589
566
|
const src = actorData.src;
|
|
590
|
-
const
|
|
591
|
-
if (!
|
|
567
|
+
const logic = src ? actors_dist_xstateActors.resolveReferencedActor(this.options.actors[src])?.src : undefined;
|
|
568
|
+
if (!logic) {
|
|
592
569
|
return;
|
|
593
570
|
}
|
|
594
|
-
const actorState =
|
|
595
|
-
const actorRef = actors_dist_xstateActors.interpret(
|
|
571
|
+
const actorState = logic.restoreState?.(childState, _actorCtx);
|
|
572
|
+
const actorRef = actors_dist_xstateActors.interpret(logic, {
|
|
596
573
|
id: actorId,
|
|
597
574
|
state: actorState
|
|
598
575
|
});
|
|
@@ -626,7 +603,6 @@ class StateMachine {
|
|
|
626
603
|
});
|
|
627
604
|
}
|
|
628
605
|
});
|
|
629
|
-
restoredState.actions = [];
|
|
630
606
|
return restoredState;
|
|
631
607
|
}
|
|
632
608
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var actors_dist_xstateActors = require('./actions-
|
|
5
|
+
var actors_dist_xstateActors = require('./actions-73b8d456.development.cjs.js');
|
|
6
6
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
7
7
|
|
|
8
8
|
const EMPTY_OBJECT = {};
|
|
@@ -173,15 +173,15 @@ class StateNode {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
|
-
* The
|
|
176
|
+
* The logic invoked as actors by this state node.
|
|
177
177
|
*/
|
|
178
178
|
get invoke() {
|
|
179
179
|
return actors_dist_xstateActors.memo(this, 'invoke', () => actors_dist_xstateActors.toArray(this.config.invoke).map((invocable, i) => {
|
|
180
180
|
const generatedId = actors_dist_xstateActors.createInvokeId(this.id, i);
|
|
181
181
|
const invokeConfig = actors_dist_xstateActors.toInvokeConfig(invocable, generatedId);
|
|
182
182
|
const resolvedId = invokeConfig.id || generatedId;
|
|
183
|
+
const src = invokeConfig.src;
|
|
183
184
|
const {
|
|
184
|
-
src,
|
|
185
185
|
systemId
|
|
186
186
|
} = invokeConfig;
|
|
187
187
|
const resolvedSrc = actors_dist_xstateActors.isString(src) ? src : !('type' in src) ? resolvedId : src;
|
|
@@ -451,15 +451,14 @@ class StateMachine {
|
|
|
451
451
|
* @param state The current State instance or state value
|
|
452
452
|
* @param event The received event
|
|
453
453
|
*/
|
|
454
|
-
transition(state
|
|
455
|
-
const currentState = state instanceof actors_dist_xstateActors.State ? state : this.resolveStateValue(state);
|
|
454
|
+
transition(state, event, actorCtx) {
|
|
456
455
|
// TODO: handle error events in a better way
|
|
457
|
-
if (actors_dist_xstateActors.isErrorEvent(event) && !
|
|
456
|
+
if (actors_dist_xstateActors.isErrorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
458
457
|
throw event.data;
|
|
459
458
|
}
|
|
460
459
|
const {
|
|
461
460
|
state: nextState
|
|
462
|
-
} = actors_dist_xstateActors.macrostep(
|
|
461
|
+
} = actors_dist_xstateActors.macrostep(state, event, actorCtx);
|
|
463
462
|
return nextState;
|
|
464
463
|
}
|
|
465
464
|
|
|
@@ -470,7 +469,7 @@ class StateMachine {
|
|
|
470
469
|
* @param state The current state
|
|
471
470
|
* @param event The received event
|
|
472
471
|
*/
|
|
473
|
-
microstep(state
|
|
472
|
+
microstep(state, event, actorCtx) {
|
|
474
473
|
return actors_dist_xstateActors.macrostep(state, event, actorCtx).microstates;
|
|
475
474
|
}
|
|
476
475
|
getTransitionData(state, event) {
|
|
@@ -488,33 +487,19 @@ class StateMachine {
|
|
|
488
487
|
value: {},
|
|
489
488
|
// TODO: this is computed in state constructor
|
|
490
489
|
context,
|
|
491
|
-
event: actors_dist_xstateActors.createInitEvent({}),
|
|
492
|
-
actions: [],
|
|
493
490
|
meta: undefined,
|
|
494
491
|
configuration: config,
|
|
495
492
|
transitions: [],
|
|
496
493
|
children: {}
|
|
497
494
|
}));
|
|
498
495
|
preInitial._initial = true;
|
|
499
|
-
preInitial.actions.unshift(...actions);
|
|
500
496
|
if (actorCtx) {
|
|
501
|
-
const
|
|
502
|
-
nextState
|
|
503
|
-
} = actors_dist_xstateActors.resolveActionsAndContext(actions, actors_dist_xstateActors.initEvent, preInitial, actorCtx);
|
|
497
|
+
const [nextState] = actors_dist_xstateActors.resolveActionsAndContext(actions, actors_dist_xstateActors.initEvent, preInitial, actorCtx);
|
|
504
498
|
preInitial.children = nextState.children;
|
|
505
|
-
preInitial.actions = nextState.actions;
|
|
506
499
|
}
|
|
507
500
|
return preInitial;
|
|
508
501
|
}
|
|
509
502
|
|
|
510
|
-
/**
|
|
511
|
-
* The initial State instance, which includes all actions to be executed from
|
|
512
|
-
* entering the initial state.
|
|
513
|
-
*/
|
|
514
|
-
get initialState() {
|
|
515
|
-
return this.getInitialState();
|
|
516
|
-
}
|
|
517
|
-
|
|
518
503
|
/**
|
|
519
504
|
* Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
|
|
520
505
|
*/
|
|
@@ -523,16 +508,12 @@ class StateMachine {
|
|
|
523
508
|
|
|
524
509
|
const preInitialState = this.getPreInitialState(actorCtx, input);
|
|
525
510
|
const nextState = actors_dist_xstateActors.microstep([], preInitialState, actorCtx, initEvent);
|
|
526
|
-
nextState.actions.unshift(...preInitialState.actions);
|
|
527
511
|
const {
|
|
528
512
|
state: macroState
|
|
529
513
|
} = actors_dist_xstateActors.macrostep(nextState, initEvent, actorCtx);
|
|
530
514
|
return macroState;
|
|
531
515
|
}
|
|
532
516
|
start(state, actorCtx) {
|
|
533
|
-
state.actions.forEach(action => {
|
|
534
|
-
action.execute?.(actorCtx);
|
|
535
|
-
});
|
|
536
517
|
Object.values(state.children).forEach(child => {
|
|
537
518
|
if (child.status === 0) {
|
|
538
519
|
try {
|
|
@@ -567,11 +548,7 @@ class StateMachine {
|
|
|
567
548
|
return actors_dist_xstateActors.getPersistedState(state);
|
|
568
549
|
}
|
|
569
550
|
createState(stateConfig) {
|
|
570
|
-
|
|
571
|
-
const {
|
|
572
|
-
nextState: resolvedState
|
|
573
|
-
} = actors_dist_xstateActors.resolveActionsAndContext(state.actions, state.event, state, undefined);
|
|
574
|
-
return resolvedState;
|
|
551
|
+
return stateConfig instanceof actors_dist_xstateActors.State ? stateConfig : new actors_dist_xstateActors.State(stateConfig, this);
|
|
575
552
|
}
|
|
576
553
|
getStatus(state) {
|
|
577
554
|
return state.done ? {
|
|
@@ -587,12 +564,12 @@ class StateMachine {
|
|
|
587
564
|
const actorData = state.children[actorId];
|
|
588
565
|
const childState = actorData.state;
|
|
589
566
|
const src = actorData.src;
|
|
590
|
-
const
|
|
591
|
-
if (!
|
|
567
|
+
const logic = src ? actors_dist_xstateActors.resolveReferencedActor(this.options.actors[src])?.src : undefined;
|
|
568
|
+
if (!logic) {
|
|
592
569
|
return;
|
|
593
570
|
}
|
|
594
|
-
const actorState =
|
|
595
|
-
const actorRef = actors_dist_xstateActors.interpret(
|
|
571
|
+
const actorState = logic.restoreState?.(childState, _actorCtx);
|
|
572
|
+
const actorRef = actors_dist_xstateActors.interpret(logic, {
|
|
596
573
|
id: actorId,
|
|
597
574
|
state: actorState
|
|
598
575
|
});
|
|
@@ -626,7 +603,6 @@ class StateMachine {
|
|
|
626
603
|
});
|
|
627
604
|
}
|
|
628
605
|
});
|
|
629
|
-
restoredState.actions = [];
|
|
630
606
|
return restoredState;
|
|
631
607
|
}
|
|
632
608
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as mapValues, t as toActionObjects, a as toArray, f as formatTransitions, b as toTransitionConfigArray, N as NULL_EVENT, c as formatTransition, d as memo, e as evaluateGuard, g as flatten, h as createInvokeId, i as isString, j as invoke, k as getDelayedTransitions, l as formatInitialTransition, n as getCandidates, o as toInvokeConfig, p as createSpawner, S as STATE_DELIMITER, q as getConfiguration, r as getStateNodes, s as resolveStateValue, u as isInFinalState, v as State, w as isErrorEvent, x as macrostep, y as transitionNode, z as getInitialConfiguration, A as
|
|
2
|
-
export { a9 as ActionTypes, P as Interpreter, Q as InterpreterStatus, aa as SpecialTargets, v as State, a7 as and, T as assign, U as cancel, V as choose, R as doneInvoke, O as forwardTo, a2 as fromCallback, a3 as fromEventObservable, a1 as fromObservable, a0 as fromPromise, a4 as fromTransition, r as getStateNodes,
|
|
1
|
+
import { m as mapValues, t as toActionObjects, a as toArray, f as formatTransitions, b as toTransitionConfigArray, N as NULL_EVENT, c as formatTransition, d as memo, e as evaluateGuard, g as flatten, h as createInvokeId, i as isString, j as invoke, k as getDelayedTransitions, l as formatInitialTransition, n as getCandidates, o as toInvokeConfig, p as createSpawner, S as STATE_DELIMITER, q as getConfiguration, r as getStateNodes, s as resolveStateValue, u as isInFinalState, v as State, w as isErrorEvent, x as macrostep, y as transitionNode, z as getInitialConfiguration, A as resolveActionsAndContext, B as microstep, C as error, D as isStateId, E as getStateNodeByPath, F as getPersistedState, G as resolveReferencedActor, H as interpret, I as createInitEvent, J as initEvent, K as matchesState } from './actions-60622c0c.development.esm.js';
|
|
2
|
+
export { a9 as ActionTypes, P as Interpreter, Q as InterpreterStatus, aa as SpecialTargets, v as State, a7 as and, T as assign, U as cancel, V as choose, R as doneInvoke, O as forwardTo, a2 as fromCallback, a3 as fromEventObservable, a1 as fromObservable, a0 as fromPromise, a4 as fromTransition, r as getStateNodes, H as interpret, W as log, K as matchesState, a6 as not, a8 as or, _ as pathToStateValue, X as pure, Y as raise, M as sendParent, L as sendTo, a5 as stateIn, Z as stop, $ as toObserver } from './actions-60622c0c.development.esm.js';
|
|
3
3
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
4
4
|
|
|
5
5
|
const EMPTY_OBJECT = {};
|
|
@@ -170,15 +170,15 @@ class StateNode {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
* The
|
|
173
|
+
* The logic invoked as actors by this state node.
|
|
174
174
|
*/
|
|
175
175
|
get invoke() {
|
|
176
176
|
return memo(this, 'invoke', () => toArray(this.config.invoke).map((invocable, i) => {
|
|
177
177
|
const generatedId = createInvokeId(this.id, i);
|
|
178
178
|
const invokeConfig = toInvokeConfig(invocable, generatedId);
|
|
179
179
|
const resolvedId = invokeConfig.id || generatedId;
|
|
180
|
+
const src = invokeConfig.src;
|
|
180
181
|
const {
|
|
181
|
-
src,
|
|
182
182
|
systemId
|
|
183
183
|
} = invokeConfig;
|
|
184
184
|
const resolvedSrc = isString(src) ? src : !('type' in src) ? resolvedId : src;
|
|
@@ -448,15 +448,14 @@ class StateMachine {
|
|
|
448
448
|
* @param state The current State instance or state value
|
|
449
449
|
* @param event The received event
|
|
450
450
|
*/
|
|
451
|
-
transition(state
|
|
452
|
-
const currentState = state instanceof State ? state : this.resolveStateValue(state);
|
|
451
|
+
transition(state, event, actorCtx) {
|
|
453
452
|
// TODO: handle error events in a better way
|
|
454
|
-
if (isErrorEvent(event) && !
|
|
453
|
+
if (isErrorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
|
|
455
454
|
throw event.data;
|
|
456
455
|
}
|
|
457
456
|
const {
|
|
458
457
|
state: nextState
|
|
459
|
-
} = macrostep(
|
|
458
|
+
} = macrostep(state, event, actorCtx);
|
|
460
459
|
return nextState;
|
|
461
460
|
}
|
|
462
461
|
|
|
@@ -467,7 +466,7 @@ class StateMachine {
|
|
|
467
466
|
* @param state The current state
|
|
468
467
|
* @param event The received event
|
|
469
468
|
*/
|
|
470
|
-
microstep(state
|
|
469
|
+
microstep(state, event, actorCtx) {
|
|
471
470
|
return macrostep(state, event, actorCtx).microstates;
|
|
472
471
|
}
|
|
473
472
|
getTransitionData(state, event) {
|
|
@@ -485,33 +484,19 @@ class StateMachine {
|
|
|
485
484
|
value: {},
|
|
486
485
|
// TODO: this is computed in state constructor
|
|
487
486
|
context,
|
|
488
|
-
event: createInitEvent({}),
|
|
489
|
-
actions: [],
|
|
490
487
|
meta: undefined,
|
|
491
488
|
configuration: config,
|
|
492
489
|
transitions: [],
|
|
493
490
|
children: {}
|
|
494
491
|
}));
|
|
495
492
|
preInitial._initial = true;
|
|
496
|
-
preInitial.actions.unshift(...actions);
|
|
497
493
|
if (actorCtx) {
|
|
498
|
-
const
|
|
499
|
-
nextState
|
|
500
|
-
} = resolveActionsAndContext(actions, initEvent, preInitial, actorCtx);
|
|
494
|
+
const [nextState] = resolveActionsAndContext(actions, initEvent, preInitial, actorCtx);
|
|
501
495
|
preInitial.children = nextState.children;
|
|
502
|
-
preInitial.actions = nextState.actions;
|
|
503
496
|
}
|
|
504
497
|
return preInitial;
|
|
505
498
|
}
|
|
506
499
|
|
|
507
|
-
/**
|
|
508
|
-
* The initial State instance, which includes all actions to be executed from
|
|
509
|
-
* entering the initial state.
|
|
510
|
-
*/
|
|
511
|
-
get initialState() {
|
|
512
|
-
return this.getInitialState();
|
|
513
|
-
}
|
|
514
|
-
|
|
515
500
|
/**
|
|
516
501
|
* Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
|
|
517
502
|
*/
|
|
@@ -520,16 +505,12 @@ class StateMachine {
|
|
|
520
505
|
|
|
521
506
|
const preInitialState = this.getPreInitialState(actorCtx, input);
|
|
522
507
|
const nextState = microstep([], preInitialState, actorCtx, initEvent);
|
|
523
|
-
nextState.actions.unshift(...preInitialState.actions);
|
|
524
508
|
const {
|
|
525
509
|
state: macroState
|
|
526
510
|
} = macrostep(nextState, initEvent, actorCtx);
|
|
527
511
|
return macroState;
|
|
528
512
|
}
|
|
529
513
|
start(state, actorCtx) {
|
|
530
|
-
state.actions.forEach(action => {
|
|
531
|
-
action.execute?.(actorCtx);
|
|
532
|
-
});
|
|
533
514
|
Object.values(state.children).forEach(child => {
|
|
534
515
|
if (child.status === 0) {
|
|
535
516
|
try {
|
|
@@ -564,11 +545,7 @@ class StateMachine {
|
|
|
564
545
|
return getPersistedState(state);
|
|
565
546
|
}
|
|
566
547
|
createState(stateConfig) {
|
|
567
|
-
|
|
568
|
-
const {
|
|
569
|
-
nextState: resolvedState
|
|
570
|
-
} = resolveActionsAndContext(state.actions, state.event, state, undefined);
|
|
571
|
-
return resolvedState;
|
|
548
|
+
return stateConfig instanceof State ? stateConfig : new State(stateConfig, this);
|
|
572
549
|
}
|
|
573
550
|
getStatus(state) {
|
|
574
551
|
return state.done ? {
|
|
@@ -584,12 +561,12 @@ class StateMachine {
|
|
|
584
561
|
const actorData = state.children[actorId];
|
|
585
562
|
const childState = actorData.state;
|
|
586
563
|
const src = actorData.src;
|
|
587
|
-
const
|
|
588
|
-
if (!
|
|
564
|
+
const logic = src ? resolveReferencedActor(this.options.actors[src])?.src : undefined;
|
|
565
|
+
if (!logic) {
|
|
589
566
|
return;
|
|
590
567
|
}
|
|
591
|
-
const actorState =
|
|
592
|
-
const actorRef = interpret(
|
|
568
|
+
const actorState = logic.restoreState?.(childState, _actorCtx);
|
|
569
|
+
const actorRef = interpret(logic, {
|
|
593
570
|
id: actorId,
|
|
594
571
|
state: actorState
|
|
595
572
|
});
|
|
@@ -623,7 +600,6 @@ class StateMachine {
|
|
|
623
600
|
});
|
|
624
601
|
}
|
|
625
602
|
});
|
|
626
|
-
restoredState.actions = [];
|
|
627
603
|
return restoredState;
|
|
628
604
|
}
|
|
629
605
|
|