xstate 5.32.2 → 6.0.0-alpha.10
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/README.md +25 -24
- package/dist/StateMachine-0aa98f54.development.esm.js +746 -0
- package/dist/StateMachine-aef700df.cjs.js +732 -0
- package/dist/StateMachine-d4931336.esm.js +729 -0
- package/dist/StateMachine-da872dde.development.cjs.js +749 -0
- package/dist/declarations/src/State.d.ts +11 -13
- package/dist/declarations/src/StateMachine.d.ts +40 -26
- package/dist/declarations/src/StateNode.d.ts +18 -54
- package/dist/declarations/src/actions.d.ts +14 -9
- package/dist/declarations/src/actors/callback.d.ts +42 -16
- package/dist/declarations/src/actors/index.d.ts +9 -6
- package/dist/declarations/src/actors/listener.d.ts +18 -0
- package/dist/declarations/src/actors/logic.d.ts +105 -0
- package/dist/declarations/src/actors/observable.d.ts +72 -27
- package/dist/declarations/src/actors/promise.d.ts +133 -48
- package/dist/declarations/src/actors/subscription.d.ts +22 -0
- package/dist/declarations/src/createActor.d.ts +33 -34
- package/dist/declarations/src/createMachine.d.ts +38 -7
- package/dist/declarations/src/createMachineFromConfig.d.ts +177 -0
- package/dist/declarations/src/graph/graph.d.ts +6 -4
- package/dist/declarations/src/graph/shortestPaths.d.ts +2 -2
- package/dist/declarations/src/graph/simplePaths.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +13 -9
- package/dist/declarations/src/inspection.d.ts +84 -30
- package/dist/declarations/src/mapState.d.ts +4 -2
- package/dist/declarations/src/schema.types.d.ts +90 -0
- package/dist/declarations/src/serialize.d.ts +50 -0
- package/dist/declarations/src/setup.d.ts +396 -136
- package/dist/declarations/src/spawn.d.ts +7 -32
- package/dist/declarations/src/stateUtils.d.ts +22 -19
- package/dist/declarations/src/system.d.ts +8 -7
- package/dist/declarations/src/transition.d.ts +8 -5
- package/dist/declarations/src/transitionActions.d.ts +4 -0
- package/dist/declarations/src/types.d.ts +494 -429
- package/dist/declarations/src/types.v6.d.ts +423 -0
- package/dist/declarations/src/utils.d.ts +5 -3
- package/dist/index-219cb621.development.cjs.js +4476 -0
- package/dist/index-2f2fbd9b.development.esm.js +4421 -0
- package/dist/index-559ceab3.cjs.js +4437 -0
- package/dist/index-8828376f.esm.js +4382 -0
- package/dist/xstate-actors.cjs.js +12 -838
- package/dist/xstate-actors.cjs.mjs +10 -5
- package/dist/xstate-actors.development.cjs.js +12 -838
- package/dist/xstate-actors.development.cjs.mjs +10 -5
- package/dist/xstate-actors.development.esm.js +1 -836
- package/dist/xstate-actors.esm.js +1 -836
- package/dist/xstate-actors.umd.min.js +1 -1
- package/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/xstate-graph.cjs.js +18 -29
- package/dist/xstate-graph.development.cjs.js +18 -29
- package/dist/xstate-graph.development.esm.js +15 -26
- package/dist/xstate-graph.esm.js +15 -26
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate.cjs.js +1477 -122
- package/dist/xstate.cjs.mjs +19 -22
- package/dist/xstate.development.cjs.js +1477 -122
- package/dist/xstate.development.cjs.mjs +19 -22
- package/dist/xstate.development.esm.js +1442 -86
- package/dist/xstate.esm.js +1442 -86
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +3 -47
- package/dist/StateMachine-23c204bb.development.esm.js +0 -566
- package/dist/StateMachine-67a0f463.development.cjs.js +0 -569
- package/dist/StateMachine-94d215e3.cjs.js +0 -563
- package/dist/StateMachine-d1d80308.esm.js +0 -560
- package/dist/assign-43b1b558.development.esm.js +0 -133
- package/dist/assign-54b312bc.esm.js +0 -127
- package/dist/assign-b5bc78f7.cjs.js +0 -129
- package/dist/assign-f8f66278.development.cjs.js +0 -135
- package/dist/declarations/src/actions/assign.d.ts +0 -45
- package/dist/declarations/src/actions/cancel.d.ts +0 -39
- package/dist/declarations/src/actions/emit.d.ts +0 -44
- package/dist/declarations/src/actions/enqueueActions.d.ts +0 -57
- package/dist/declarations/src/actions/log.d.ts +0 -16
- package/dist/declarations/src/actions/raise.d.ts +0 -21
- package/dist/declarations/src/actions/send.d.ts +0 -42
- package/dist/declarations/src/actions/spawnChild.d.ts +0 -34
- package/dist/declarations/src/actions/stopChild.d.ts +0 -19
- package/dist/declarations/src/actors/transition.d.ts +0 -143
- package/dist/declarations/src/dev/index.d.ts +0 -14
- package/dist/declarations/src/guards.d.ts +0 -128
- package/dist/log-9b02c355.esm.js +0 -401
- package/dist/log-c94995c7.cjs.js +0 -409
- package/dist/log-d9f3f459.development.cjs.js +0 -437
- package/dist/log-db444cad.development.esm.js +0 -429
- package/dist/raise-235108c6.esm.js +0 -2762
- package/dist/raise-45f11c00.development.esm.js +0 -2824
- package/dist/raise-c445379d.cjs.js +0 -2817
- package/dist/raise-eca73993.development.cjs.js +0 -2879
- package/dist/xstate-actions.cjs.d.mts +0 -2
- package/dist/xstate-actions.cjs.d.ts +0 -2
- package/dist/xstate-actions.cjs.js +0 -23
- package/dist/xstate-actions.cjs.mjs +0 -14
- package/dist/xstate-actions.development.cjs.js +0 -23
- package/dist/xstate-actions.development.cjs.mjs +0 -14
- package/dist/xstate-actions.development.esm.js +0 -4
- package/dist/xstate-actions.esm.js +0 -4
- package/dist/xstate-actions.umd.min.js +0 -2
- package/dist/xstate-actions.umd.min.js.map +0 -1
- package/dist/xstate-dev.cjs.d.mts +0 -2
- package/dist/xstate-dev.cjs.d.ts +0 -2
- package/dist/xstate-dev.cjs.js +0 -48
- package/dist/xstate-dev.cjs.mjs +0 -5
- package/dist/xstate-dev.development.cjs.js +0 -51
- package/dist/xstate-dev.development.cjs.mjs +0 -5
- package/dist/xstate-dev.development.esm.js +0 -45
- package/dist/xstate-dev.esm.js +0 -42
- package/dist/xstate-dev.umd.min.js +0 -2
- package/dist/xstate-dev.umd.min.js.map +0 -1
- package/dist/xstate-guards.cjs.d.mts +0 -2
- package/dist/xstate-guards.cjs.d.ts +0 -2
- package/dist/xstate-guards.cjs.js +0 -14
- package/dist/xstate-guards.cjs.mjs +0 -7
- package/dist/xstate-guards.development.cjs.js +0 -14
- package/dist/xstate-guards.development.cjs.mjs +0 -7
- package/dist/xstate-guards.development.esm.js +0 -2
- package/dist/xstate-guards.esm.js +0 -2
- package/dist/xstate-guards.umd.min.js +0 -2
- package/dist/xstate-guards.umd.min.js.map +0 -1
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { StateMachine } from "./StateMachine.js";
|
|
3
|
-
import type { ProvidedActor, AnyMachineSnapshot, AnyStateMachine, EventObject, HistoryValue, MachineContext, StateConfig, StateValue, AnyActorRef, Snapshot, ParameterizedObject, IsNever, MetaObject, StateSchema, StateId, SnapshotStatus } from "./types.js";
|
|
4
|
-
type ToTestStateValue<TStateValue extends StateValue> = TStateValue extends string ? TStateValue : IsNever<keyof TStateValue> extends true ? never : keyof TStateValue | {
|
|
5
|
-
[K in keyof TStateValue]?: ToTestStateValue<NonNullable<TStateValue[K]>>;
|
|
6
|
-
};
|
|
1
|
+
import type { AnyMachineSnapshot, AnyStateMachine, EventObject, HistoryValue, MachineContext, StateConfig, StateValue, AnyActorRef, Snapshot, MetaObject, StateSchema, StateId, StateIdInputs, StateContextFromStateValue, SnapshotStatus, AnyStateNode } from "./types.js";
|
|
7
2
|
export declare function isMachineSnapshot(value: unknown): value is AnyMachineSnapshot;
|
|
8
|
-
interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string,
|
|
3
|
+
interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, _TOutput, TMeta extends MetaObject, TStateSchema extends StateSchema = StateSchema> {
|
|
9
4
|
/** The state machine that produced this state snapshot. */
|
|
10
|
-
machine:
|
|
11
|
-
any, // TMeta
|
|
12
|
-
TStateSchema>;
|
|
5
|
+
machine: AnyStateMachine;
|
|
13
6
|
/** The tags of the active state nodes that represent the current state value. */
|
|
14
7
|
tags: Set<string>;
|
|
15
8
|
/**
|
|
@@ -38,9 +31,9 @@ interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends Ev
|
|
|
38
31
|
status: SnapshotStatus;
|
|
39
32
|
error: unknown;
|
|
40
33
|
context: TContext;
|
|
41
|
-
historyValue: Readonly<HistoryValue
|
|
34
|
+
historyValue: Readonly<HistoryValue>;
|
|
42
35
|
/** The enabled state nodes representative of the state value. */
|
|
43
|
-
_nodes: Array<
|
|
36
|
+
_nodes: Array<AnyStateNode>;
|
|
44
37
|
/** An object mapping actor names to spawned/invoked actors. */
|
|
45
38
|
children: TChildren;
|
|
46
39
|
/**
|
|
@@ -49,7 +42,7 @@ interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends Ev
|
|
|
49
42
|
*
|
|
50
43
|
* @param partialStateValue
|
|
51
44
|
*/
|
|
52
|
-
matches
|
|
45
|
+
matches<const TTestStateValue extends StateValue>(partialStateValue: TTestStateValue): this is MachineSnapshot<StateContextFromStateValue<TStateSchema, TContext, TTestStateValue>, TEvent, TChildren, TStateValue, TTag, _TOutput, TMeta, TStateSchema>;
|
|
53
46
|
/**
|
|
54
47
|
* Whether the current state nodes has a state node with the specified `tag`.
|
|
55
48
|
*
|
|
@@ -66,6 +59,11 @@ interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends Ev
|
|
|
66
59
|
*/
|
|
67
60
|
can: (event: TEvent) => boolean;
|
|
68
61
|
getMeta: () => Record<StateId<TStateSchema> & string, TMeta | undefined>;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the inputs for the current active state nodes, keyed by state node
|
|
64
|
+
* id.
|
|
65
|
+
*/
|
|
66
|
+
getInputs: () => StateIdInputs<TStateSchema>;
|
|
69
67
|
toJSON: () => unknown;
|
|
70
68
|
}
|
|
71
69
|
interface ActiveMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject, TStateSchema extends StateSchema> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TStateSchema> {
|
|
@@ -1,47 +1,60 @@
|
|
|
1
1
|
import { MachineSnapshot } from "./State.js";
|
|
2
2
|
import { StateNode } from "./StateNode.js";
|
|
3
3
|
import { AnyActorSystem } from "./system.js";
|
|
4
|
-
import type { ActorLogic, ActorScope, AnyActorRef, AnyActorScope,
|
|
5
|
-
|
|
4
|
+
import type { ActorLogic, ActorLogicTransitionResult, ActorScope, AnyActor, AnyActorLogic, AnyActorRef, AnyActorScope, AnyTransitionDefinition, Equals, EventDescriptor, EmittedFrom, EventObject, EventFromLogic, ExecutableActionObjectFromLogic, HistoryValue, InputFrom, IsAny, MachineContext, MetaObject, OutputFrom, Snapshot, SnapshotFrom, StateValue, StateSchema, SnapshotStatus } from "./types.js";
|
|
5
|
+
import { AnyMachineSchemas, Implementations, Next_MachineConfig, MachineOptions } from "./types.v6.js";
|
|
6
|
+
type CompatibleProvidedActorSource<TExpected extends AnyActorLogic, TActual extends AnyActorLogic> = IsAny<TActual> extends true ? TActual : [OutputFrom<TActual>] extends [OutputFrom<TExpected>] ? [Omit<SnapshotFrom<TActual>, 'input'>] extends [
|
|
7
|
+
Omit<SnapshotFrom<TExpected>, 'input'>
|
|
8
|
+
] ? [InputFrom<TExpected>] extends [InputFrom<TActual>] ? [EventFromLogic<TExpected>] extends [EventFromLogic<TActual>] ? [EmittedFrom<TActual>] extends [EmittedFrom<TExpected>] ? TActual : never : never : never : never : never;
|
|
9
|
+
type ProvidedActorSources<TExpectedActorMap extends Implementations['actorSources'], TProvidedActorMap extends Partial<Record<keyof TExpectedActorMap & string, AnyActorLogic>>> = {
|
|
10
|
+
[K in keyof TProvidedActorMap]: K extends keyof TExpectedActorMap ? TProvidedActorMap[K] extends AnyActorLogic ? CompatibleProvidedActorSource<TExpectedActorMap[K], TProvidedActorMap[K]> : never : never;
|
|
11
|
+
};
|
|
12
|
+
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TConfig extends StateSchema, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
|
6
13
|
/** The raw config used to create the machine. */
|
|
7
|
-
config:
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any> & {
|
|
15
|
+
schemas?: AnyMachineSchemas;
|
|
16
|
+
internalEvents?: readonly string[];
|
|
10
17
|
};
|
|
11
18
|
/** The machine's own version. */
|
|
12
19
|
version?: string;
|
|
13
|
-
schemas:
|
|
14
|
-
implementations:
|
|
20
|
+
schemas: AnyMachineSchemas | undefined;
|
|
21
|
+
implementations: Implementations;
|
|
15
22
|
/** Runtime options for machine execution. */
|
|
16
23
|
options: MachineOptions;
|
|
17
24
|
root: StateNode<TContext, TEvent>;
|
|
18
25
|
id: string;
|
|
19
26
|
states: StateNode<TContext, TEvent>['states'];
|
|
20
27
|
events: Array<EventDescriptor<TEvent>>;
|
|
28
|
+
internalEventDescriptors: ReadonlyArray<string>;
|
|
21
29
|
constructor(
|
|
22
30
|
/** The raw config used to create the machine. */
|
|
23
|
-
config:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, implementations?:
|
|
31
|
+
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any> & {
|
|
32
|
+
schemas?: AnyMachineSchemas;
|
|
33
|
+
internalEvents?: readonly string[];
|
|
34
|
+
}, implementations?: Implementations);
|
|
27
35
|
/**
|
|
28
36
|
* Clones this state machine with the provided implementations.
|
|
29
37
|
*
|
|
30
|
-
* @param implementations Options (`actions`, `guards`, `
|
|
31
|
-
* recursively merge with the existing options.
|
|
38
|
+
* @param implementations Options (`actions`, `guards`, `actorSources`,
|
|
39
|
+
* `delays`) to recursively merge with the existing options.
|
|
32
40
|
* @returns A new `StateMachine` instance with the provided implementations.
|
|
33
41
|
*/
|
|
34
|
-
provide
|
|
42
|
+
provide<const TProvidedActorMap extends Partial<Record<keyof TActorMap & string, AnyActorLogic>> = {}>(implementations: {
|
|
43
|
+
actions?: Partial<TActionMap>;
|
|
44
|
+
actorSources?: TProvidedActorMap & ProvidedActorSources<TActorMap, TProvidedActorMap>;
|
|
45
|
+
guards?: Partial<TGuardMap>;
|
|
46
|
+
delays?: Partial<TDelayMap>;
|
|
47
|
+
}): StateMachine<TContext, TEvent, TChildren, TStateValue, TTag, TInput, TOutput, TEmitted, TMeta, TConfig, TActionMap, TActorMap, TGuardMap, TDelayMap>;
|
|
35
48
|
resolveState(config: {
|
|
36
49
|
value: StateValue;
|
|
37
50
|
context?: TContext;
|
|
38
|
-
historyValue?: HistoryValue
|
|
51
|
+
historyValue?: HistoryValue;
|
|
39
52
|
status?: SnapshotStatus;
|
|
40
53
|
output?: TOutput;
|
|
41
54
|
error?: unknown;
|
|
42
|
-
} & (Equals<TContext, MachineContext> extends false ? {
|
|
55
|
+
} & ([TContext] extends [never] ? {} : Equals<TContext, MachineContext> extends false ? {
|
|
43
56
|
context: unknown;
|
|
44
|
-
} : {})): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta,
|
|
57
|
+
} : {})): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
45
58
|
/**
|
|
46
59
|
* Determines the next snapshot given the current `snapshot` and received
|
|
47
60
|
* `event`. Calculates a full macrostep from all microsteps.
|
|
@@ -49,7 +62,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
49
62
|
* @param snapshot The current snapshot
|
|
50
63
|
* @param event The received event
|
|
51
64
|
*/
|
|
52
|
-
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta,
|
|
65
|
+
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, event: TEvent, actorScope: ActorScope<typeof snapshot, TEvent, AnyActorSystem, TEmitted>): ActorLogicTransitionResult<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, ExecutableActionObjectFromLogic<this>>;
|
|
53
66
|
/**
|
|
54
67
|
* Determines the next state given the current `state` and `event`. Calculates
|
|
55
68
|
* a microstep.
|
|
@@ -57,17 +70,18 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
57
70
|
* @param state The current state
|
|
58
71
|
* @param event The received event
|
|
59
72
|
*/
|
|
60
|
-
microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta,
|
|
61
|
-
getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta,
|
|
73
|
+
microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, event: TEvent, actorScope: AnyActorScope): Array<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>>;
|
|
74
|
+
getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, event: TEvent, self: AnyActor): Array<AnyTransitionDefinition>;
|
|
75
|
+
isInternalEventType(eventType: string): boolean;
|
|
62
76
|
/**
|
|
63
77
|
* Returns the initial `State` instance, with reference to `self` as an
|
|
64
78
|
* `ActorRef`.
|
|
65
79
|
*/
|
|
66
|
-
getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta,
|
|
67
|
-
|
|
80
|
+
getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>, input?: TInput): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
81
|
+
initialTransition(input: TInput | undefined, actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>): ActorLogicTransitionResult<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, ExecutableActionObjectFromLogic<this>>;
|
|
82
|
+
start(snapshot?: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>): void;
|
|
68
83
|
getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TStateSchema>, options?: unknown): Snapshot<unknown>;
|
|
72
|
-
restoreSnapshot(snapshot: Snapshot<unknown>, _actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TStateSchema>, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TStateSchema>;
|
|
84
|
+
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, options?: unknown): Snapshot<unknown>;
|
|
85
|
+
restoreSnapshot(snapshot: Snapshot<unknown>, _actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
73
86
|
}
|
|
87
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, InvokeDefinition, MachineContext, Mapper, StateNodeConfig, StateNodeDefinition, StateNodesConfig, TransitionDefinition, TransitionDefinitionMap, TODO, UnknownAction, ParameterizedObject, AnyStateMachine, ProvidedActor, NonReducibleUnknown, EventDescriptor } from "./types.js";
|
|
1
|
+
import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, MachineContext, Mapper, StateNodesConfig, TransitionDefinitionMap, AnyStateMachine, AnyStateNodeConfig, NonReducibleUnknown, EventDescriptor, AnyAction, AnyTransitionDefinition, AnyInvokeDefinition } from "./types.js";
|
|
3
2
|
interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
|
|
4
3
|
_key: string;
|
|
5
4
|
_parent?: StateNode<TContext, TEvent>;
|
|
@@ -7,14 +6,7 @@ interface StateNodeOptions<TContext extends MachineContext, TEvent extends Event
|
|
|
7
6
|
}
|
|
8
7
|
export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject> {
|
|
9
8
|
/** The raw config used to create the machine. */
|
|
10
|
-
config:
|
|
11
|
-
TODO, // actions
|
|
12
|
-
TODO, // guards
|
|
13
|
-
TODO, // delays
|
|
14
|
-
TODO, // tags
|
|
15
|
-
TODO, // output
|
|
16
|
-
TODO, // emitted
|
|
17
|
-
TODO>;
|
|
9
|
+
config: AnyStateNodeConfig;
|
|
18
10
|
/**
|
|
19
11
|
* The relative key of the state node, which represents its location in the
|
|
20
12
|
* overall state value.
|
|
@@ -29,13 +21,14 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
29
21
|
* - `'compound'` - nested child state nodes (XOR)
|
|
30
22
|
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
31
23
|
* - `'history'` - history state node
|
|
24
|
+
* - `'choice'` - pure routing decision state node
|
|
32
25
|
* - `'final'` - final state node
|
|
33
26
|
*/
|
|
34
|
-
type: 'atomic' | 'compound' | 'parallel' | 'final' | 'history';
|
|
27
|
+
type: 'atomic' | 'compound' | 'parallel' | 'final' | 'history' | 'choice';
|
|
35
28
|
/** The string path from the root machine node to this node. */
|
|
36
29
|
path: string[];
|
|
37
30
|
/** The child state nodes. */
|
|
38
|
-
states: StateNodesConfig<
|
|
31
|
+
states: StateNodesConfig<any, any>;
|
|
39
32
|
/**
|
|
40
33
|
* The type of history on this state node. Can be:
|
|
41
34
|
*
|
|
@@ -44,24 +37,13 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
44
37
|
*/
|
|
45
38
|
history: false | 'shallow' | 'deep';
|
|
46
39
|
/** The action(s) to be executed upon entering the state node. */
|
|
47
|
-
entry:
|
|
40
|
+
entry: AnyAction | undefined;
|
|
48
41
|
/** The action(s) to be executed upon exiting the state node. */
|
|
49
|
-
exit:
|
|
42
|
+
exit: AnyAction | undefined;
|
|
50
43
|
/** The parent state node. */
|
|
51
|
-
parent?: StateNode<
|
|
44
|
+
parent?: StateNode<any, any>;
|
|
52
45
|
/** The root machine node. */
|
|
53
|
-
machine:
|
|
54
|
-
any, // actor
|
|
55
|
-
any, // action
|
|
56
|
-
any, // guard
|
|
57
|
-
any, // delay
|
|
58
|
-
any, // state value
|
|
59
|
-
any, // tag
|
|
60
|
-
any, // input
|
|
61
|
-
any, // output
|
|
62
|
-
any, // emitted
|
|
63
|
-
any, // meta
|
|
64
|
-
any>;
|
|
46
|
+
machine: AnyStateMachine;
|
|
65
47
|
/**
|
|
66
48
|
* The meta data associated with this state node, which will be returned in
|
|
67
49
|
* State instances.
|
|
@@ -79,34 +61,16 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
79
61
|
order: number;
|
|
80
62
|
description?: string;
|
|
81
63
|
tags: string[];
|
|
82
|
-
transitions: Map<string,
|
|
83
|
-
always?: Array<
|
|
64
|
+
transitions: Map<string, AnyTransitionDefinition[]>;
|
|
65
|
+
always?: Array<AnyTransitionDefinition>;
|
|
66
|
+
invoke: Array<AnyInvokeDefinition>;
|
|
67
|
+
on: TransitionDefinitionMap<any, any>;
|
|
68
|
+
after: Array<DelayedTransitionDefinition<any, any>>;
|
|
69
|
+
events: Array<EventDescriptor<any>>;
|
|
70
|
+
ownEvents: Array<EventDescriptor<any>>;
|
|
84
71
|
constructor(
|
|
85
72
|
/** The raw config used to create the machine. */
|
|
86
|
-
config:
|
|
87
|
-
|
|
88
|
-
TODO, // guards
|
|
89
|
-
TODO, // delays
|
|
90
|
-
TODO, // tags
|
|
91
|
-
TODO, // output
|
|
92
|
-
TODO, // emitted
|
|
93
|
-
TODO>, options: StateNodeOptions<TContext, TEvent>);
|
|
94
|
-
/** The well-structured state node definition. */
|
|
95
|
-
get definition(): StateNodeDefinition<TContext, TEvent>;
|
|
96
|
-
/** The logic invoked as actors by this state node. */
|
|
97
|
-
get invoke(): Array<InvokeDefinition<TContext, TEvent, ProvidedActor, ParameterizedObject, ParameterizedObject, string, TODO, // TEmitted
|
|
98
|
-
TODO>>;
|
|
99
|
-
/** The mapping of events to transitions. */
|
|
100
|
-
get on(): TransitionDefinitionMap<TContext, TEvent>;
|
|
101
|
-
get after(): Array<DelayedTransitionDefinition<TContext, TEvent>>;
|
|
102
|
-
get initial(): InitialTransitionDefinition<TContext, TEvent>;
|
|
103
|
-
/** All the event types accepted by this state node and its descendants. */
|
|
104
|
-
get events(): Array<EventDescriptor<TEvent>>;
|
|
105
|
-
/**
|
|
106
|
-
* All the events that have transitions directly from this state node.
|
|
107
|
-
*
|
|
108
|
-
* Excludes any inert events.
|
|
109
|
-
*/
|
|
110
|
-
get ownEvents(): Array<EventDescriptor<TEvent>>;
|
|
73
|
+
config: AnyStateNodeConfig, options: StateNodeOptions<TContext, TEvent>);
|
|
74
|
+
get initial(): InitialTransitionDefinition;
|
|
111
75
|
}
|
|
112
76
|
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { AnyActor, AnyActorScope, EventObject } from "./types.js";
|
|
2
|
+
export declare const builtInActions: {
|
|
3
|
+
"@xstate.start": (actor: AnyActor) => void;
|
|
4
|
+
"@xstate.raise": (actorScope: AnyActorScope, event: EventObject, options: {
|
|
5
|
+
id?: string;
|
|
6
|
+
delay?: number;
|
|
7
|
+
}) => void;
|
|
8
|
+
"@xstate.sendTo": (actorScope: AnyActorScope, actor: AnyActor, event: EventObject, options: {
|
|
9
|
+
id?: string;
|
|
10
|
+
delay?: number;
|
|
11
|
+
}) => void;
|
|
12
|
+
"@xstate.cancel": (actorScope: AnyActorScope, sendId: string) => void;
|
|
13
|
+
"@xstate.stop": (actorScope: AnyActorScope, actor: AnyActor) => void;
|
|
14
|
+
};
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { AnyActorSystem } from "../system.js";
|
|
2
2
|
import { ActorLogic, ActorRefFromLogic, AnyEventObject, EventObject, NonReducibleUnknown, Snapshot } from "../types.js";
|
|
3
|
+
import { StandardSchemaV1 } from "../schema.types.js";
|
|
3
4
|
export type CallbackSnapshot<TInput> = Snapshot<undefined> & {
|
|
4
5
|
input: TInput;
|
|
6
|
+
effects?: Record<string, {
|
|
7
|
+
status: 'active';
|
|
8
|
+
} | {
|
|
9
|
+
status: 'done';
|
|
10
|
+
output?: unknown;
|
|
11
|
+
} | {
|
|
12
|
+
status: 'error';
|
|
13
|
+
error: unknown;
|
|
14
|
+
}>;
|
|
5
15
|
};
|
|
6
16
|
export type CallbackActorLogic<TEvent extends EventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject> = ActorLogic<CallbackSnapshot<TInput>, TEvent, TInput, AnyActorSystem, TEmitted>;
|
|
7
17
|
/**
|
|
8
|
-
* Represents an actor created by `
|
|
18
|
+
* Represents an actor created by `createCallbackLogic`.
|
|
9
19
|
*
|
|
10
20
|
* The type of `self` within the actor's logic.
|
|
11
21
|
*
|
|
12
22
|
* @example
|
|
13
23
|
*
|
|
14
24
|
* ```ts
|
|
15
|
-
* import {
|
|
25
|
+
* import { createCallbackLogic, createActor } from 'xstate';
|
|
16
26
|
*
|
|
17
27
|
* // The events the actor receives.
|
|
18
28
|
* type Event = { type: 'someEvent' };
|
|
@@ -20,23 +30,25 @@ export type CallbackActorLogic<TEvent extends EventObject, TInput = NonReducible
|
|
|
20
30
|
* type Input = { name: string };
|
|
21
31
|
*
|
|
22
32
|
* // Actor logic that logs whenever it receives an event of type `someEvent`.
|
|
23
|
-
* const logic =
|
|
24
|
-
* self
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
33
|
+
* const logic = createCallbackLogic<Event, Input>(
|
|
34
|
+
* ({ self, input, receive }) => {
|
|
35
|
+
* self;
|
|
36
|
+
* // ^? CallbackActorRef<Event, Input>
|
|
37
|
+
*
|
|
38
|
+
* receive((event) => {
|
|
39
|
+
* if (event.type === 'someEvent') {
|
|
40
|
+
* console.log(`${input.name}: received "someEvent" event`);
|
|
41
|
+
* // logs 'myActor: received "someEvent" event'
|
|
42
|
+
* }
|
|
43
|
+
* });
|
|
44
|
+
* }
|
|
45
|
+
* );
|
|
34
46
|
*
|
|
35
47
|
* const actor = createActor(logic, { input: { name: 'myActor' } });
|
|
36
48
|
* // ^? CallbackActorRef<Event, Input>
|
|
37
49
|
* ```
|
|
38
50
|
*
|
|
39
|
-
* @see {@link
|
|
51
|
+
* @see {@link createCallbackLogic}
|
|
40
52
|
*/
|
|
41
53
|
export type CallbackActorRef<TEvent extends EventObject, TInput = NonReducibleUnknown> = ActorRefFromLogic<CallbackActorLogic<TEvent, TInput>>;
|
|
42
54
|
type Receiver<TEvent extends EventObject> = (listener: {
|
|
@@ -62,6 +74,12 @@ export type CallbackLogicFunction<TEvent extends EventObject = AnyEventObject, T
|
|
|
62
74
|
receive: Receiver<TEvent>;
|
|
63
75
|
emit: (emitted: TEmitted) => void;
|
|
64
76
|
}) => (() => void) | void;
|
|
77
|
+
export interface CallbackLogicConfig<TEvent extends EventObject = AnyEventObject, TSentEvent extends EventObject = AnyEventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject, TInputSchema extends StandardSchemaV1 = StandardSchemaV1> {
|
|
78
|
+
schemas?: {
|
|
79
|
+
input?: TInputSchema;
|
|
80
|
+
};
|
|
81
|
+
run: CallbackLogicFunction<TEvent, TSentEvent, TInput, TEmitted>;
|
|
82
|
+
}
|
|
65
83
|
/**
|
|
66
84
|
* An actor logic creator which returns callback logic as defined by a callback
|
|
67
85
|
* function.
|
|
@@ -85,7 +103,7 @@ export type CallbackLogicFunction<TEvent extends EventObject = AnyEventObject, T
|
|
|
85
103
|
* @example
|
|
86
104
|
*
|
|
87
105
|
* ```typescript
|
|
88
|
-
* const callbackLogic =
|
|
106
|
+
* const callbackLogic = createCallbackLogic(({ sendBack, receive }) => {
|
|
89
107
|
* let lockStatus = 'unlocked';
|
|
90
108
|
*
|
|
91
109
|
* const handler = (event) => {
|
|
@@ -128,5 +146,13 @@ export type CallbackLogicFunction<TEvent extends EventObject = AnyEventObject, T
|
|
|
128
146
|
* @see {@link CallbackLogicFunction} for more information about the callback function and its object argument
|
|
129
147
|
* @see {@link https://stately.ai/docs/input | Input docs} for more information about how input is passed
|
|
130
148
|
*/
|
|
131
|
-
export declare function
|
|
149
|
+
export declare function createCallbackLogic<TEvent extends EventObject, const TInputSchema extends StandardSchemaV1, TEmitted extends EventObject = EventObject>(config: CallbackLogicConfig<TEvent, AnyEventObject, StandardSchemaV1.InferOutput<TInputSchema>, TEmitted, TInputSchema> & {
|
|
150
|
+
schemas: {
|
|
151
|
+
input: TInputSchema;
|
|
152
|
+
};
|
|
153
|
+
}): CallbackActorLogic<TEvent, StandardSchemaV1.InferOutput<TInputSchema>, TEmitted>;
|
|
154
|
+
export declare function createCallbackLogic<TEvent extends EventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject>(config: CallbackLogicConfig<TEvent, AnyEventObject, TInput, TEmitted> & {
|
|
155
|
+
schemas?: undefined;
|
|
156
|
+
}): CallbackActorLogic<TEvent, TInput, TEmitted>;
|
|
157
|
+
export declare function createCallbackLogic<TEvent extends EventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject>(callback: CallbackLogicFunction<TEvent, AnyEventObject, TInput, TEmitted>): CallbackActorLogic<TEvent, TInput, TEmitted>;
|
|
132
158
|
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
1
|
+
import type { ActorFromLogic } from "../types.js";
|
|
2
|
+
export { createCallbackLogic, type CallbackActorLogic, type CallbackActorRef, type CallbackLogicConfig, type CallbackSnapshot, type CallbackLogicFunction } from "./callback.js";
|
|
3
|
+
export { createObservableLogic, createEventObservableLogic, type EventObservableLogicConfig, type EventObservableLogicFunction, type ObservableActorLogic, type ObservableActorRef, type ObservableLogicConfig, type ObservableLogicFunction, type ObservableSnapshot } from "./observable.js";
|
|
4
|
+
export { createLogic, type LogicActorLogic, type LogicActorRef, type LogicArgs, type LogicConfig, type LogicEffect, type LogicEffectState, type LogicEnqueue, type LogicFunction, type LogicPatch, type LogicSnapshot } from "./logic.js";
|
|
5
|
+
export { createAsyncLogic, type AsyncActorLogic, type AsyncActorRef, type AsyncSnapshot, type LogicArgs as AsyncLogicArgs, type LogicConfig as AsyncLogicConfig, type LogicEnqueue as AsyncLogicEnqueue, type LogicFunction as AsyncLogicFunction, TimeoutError } from "./promise.js";
|
|
6
|
+
export { createListenerLogic, listenerLogic, type ListenerActorLogic, type ListenerActorRef, type ListenerSnapshot, type ListenerInput } from "./listener.js";
|
|
7
|
+
export { createSubscriptionLogic, subscriptionLogic, type SubscriptionActorLogic, type SubscriptionActorRef, type SubscriptionSnapshot, type SubscriptionInput, type SubscriptionMappers } from "./subscription.js";
|
|
8
|
+
declare const emptyLogic: import("./logic.js").LogicActorLogic<undefined, undefined, import("../types.js").EventObject, import("../types.js").NonReducibleUnknown, import("../types.js").EventObject>;
|
|
9
|
+
export declare function createEmptyActor(): ActorFromLogic<typeof emptyLogic>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnyActorSystem } from "../system.js";
|
|
2
|
+
import { ActorLogic, ActorRefFromLogic, AnyActor, EventObject, Snapshot } from "../types.js";
|
|
3
|
+
export type ListenerSnapshot = Snapshot<undefined> & {
|
|
4
|
+
input: ListenerInput<any, any>;
|
|
5
|
+
};
|
|
6
|
+
export interface ListenerInput<TEmitted extends EventObject, TMappedEvent extends EventObject> {
|
|
7
|
+
actor: AnyActor;
|
|
8
|
+
eventType: string;
|
|
9
|
+
mapper: (event: TEmitted) => TMappedEvent;
|
|
10
|
+
}
|
|
11
|
+
export type ListenerActorLogic<TEmitted extends EventObject = EventObject, TMappedEvent extends EventObject = EventObject> = ActorLogic<ListenerSnapshot, EventObject, ListenerInput<TEmitted, TMappedEvent>, AnyActorSystem, EventObject>;
|
|
12
|
+
export type ListenerActorRef<TEmitted extends EventObject = EventObject, TMappedEvent extends EventObject = EventObject> = ActorRefFromLogic<ListenerActorLogic<TEmitted, TMappedEvent>>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates actor logic for listening to emitted events from another actor. Used
|
|
15
|
+
* internally by `enq.listen()`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createListenerLogic<TEmitted extends EventObject = EventObject, TMappedEvent extends EventObject = EventObject>(): ListenerActorLogic<TEmitted, TMappedEvent>;
|
|
18
|
+
export declare const listenerLogic: ListenerActorLogic<EventObject, EventObject>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "../schema.types.js";
|
|
2
|
+
import { AnyActorSystem } from "../system.js";
|
|
3
|
+
import { ActorLogic, ActorRefFromLogic, ActorScope, EventObject, NonReducibleUnknown, Snapshot } from "../types.js";
|
|
4
|
+
export type LogicSnapshot<TContext, TOutput, TInput> = Snapshot<TOutput> & {
|
|
5
|
+
context: TContext;
|
|
6
|
+
input: TInput | undefined;
|
|
7
|
+
effects?: Record<string, LogicEffectState>;
|
|
8
|
+
};
|
|
9
|
+
export type LogicEffectState = {
|
|
10
|
+
status: 'active';
|
|
11
|
+
} | {
|
|
12
|
+
status: 'done';
|
|
13
|
+
output?: unknown;
|
|
14
|
+
} | {
|
|
15
|
+
status: 'error';
|
|
16
|
+
error: unknown;
|
|
17
|
+
};
|
|
18
|
+
export interface LogicArgs<TContext, TEvent extends EventObject, TInput> {
|
|
19
|
+
context: TContext;
|
|
20
|
+
event: TEvent;
|
|
21
|
+
input: TInput;
|
|
22
|
+
system: AnyActorSystem;
|
|
23
|
+
self: LogicActorRef<TContext, unknown, TEvent, TInput>;
|
|
24
|
+
}
|
|
25
|
+
export type LogicEffect<TEvent extends EventObject, TEmitted extends EventObject> = {
|
|
26
|
+
type: 'emit';
|
|
27
|
+
event: TEmitted;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'sendBack';
|
|
30
|
+
event: EventObject;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'raise';
|
|
33
|
+
event: TEvent;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'effect';
|
|
36
|
+
key?: string;
|
|
37
|
+
exec: () => void | (() => void);
|
|
38
|
+
} | {
|
|
39
|
+
type: 'cleanupEffects';
|
|
40
|
+
};
|
|
41
|
+
export interface LogicEnqueue<TEvent extends EventObject, TEmitted extends EventObject> {
|
|
42
|
+
emit: (emitted: TEmitted) => void;
|
|
43
|
+
sendBack: (event: EventObject) => void;
|
|
44
|
+
raise: (event: TEvent) => void;
|
|
45
|
+
effect: {
|
|
46
|
+
(exec: () => void | (() => void)): void;
|
|
47
|
+
(key: string, exec: () => void | (() => void)): void;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export type LogicPatch<TContext, TOutput, TInput> = Partial<{
|
|
51
|
+
context: TContext;
|
|
52
|
+
input: TInput | undefined;
|
|
53
|
+
status: LogicSnapshot<TContext, TOutput, TInput>['status'];
|
|
54
|
+
output: TOutput;
|
|
55
|
+
error: unknown;
|
|
56
|
+
effects: Record<string, LogicEffectState>;
|
|
57
|
+
}>;
|
|
58
|
+
export type LogicFunction<TContext, TOutput, TEvent extends EventObject, TInput, TEmitted extends EventObject> = (args: LogicArgs<TContext, TEvent, TInput>, enq: LogicEnqueue<TEvent, TEmitted>) => void | LogicPatch<TContext, TOutput, TInput>;
|
|
59
|
+
export interface LogicConfig<TContext, TOutput, TEvent extends EventObject, TInput, TEmitted extends EventObject, TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TOutputSchema extends StandardSchemaV1 = StandardSchemaV1> {
|
|
60
|
+
id?: string;
|
|
61
|
+
schemas?: {
|
|
62
|
+
input?: TInputSchema;
|
|
63
|
+
output?: TOutputSchema;
|
|
64
|
+
};
|
|
65
|
+
context: TContext | ((args: {
|
|
66
|
+
input: TInput;
|
|
67
|
+
}) => TContext);
|
|
68
|
+
run: LogicFunction<TContext, TOutput, TEvent, TInput, TEmitted>;
|
|
69
|
+
}
|
|
70
|
+
interface LogicTransition<TContext, TOutput, TEvent extends EventObject, TInput, TEmitted extends EventObject> {
|
|
71
|
+
(snapshot: LogicSnapshot<TContext, TOutput, TInput>, event: TEvent, actorScope: ActorScope<LogicSnapshot<TContext, TOutput, TInput>, TEvent, AnyActorSystem, TEmitted>): [
|
|
72
|
+
LogicSnapshot<TContext, TOutput, TInput>,
|
|
73
|
+
LogicEffect<TEvent, TEmitted>[]
|
|
74
|
+
];
|
|
75
|
+
(snapshot: LogicSnapshot<TContext, TOutput, TInput>, event: TEvent, actorScope: ActorScope<LogicSnapshot<TContext, TOutput, TInput>, TEvent, AnyActorSystem, TEmitted>): LogicSnapshot<TContext, TOutput, TInput>;
|
|
76
|
+
}
|
|
77
|
+
export type LogicActorLogic<TContext, TOutput, TEvent extends EventObject = EventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject> = Omit<ActorLogic<LogicSnapshot<TContext, TOutput, TInput>, TEvent, TInput, AnyActorSystem, TEmitted>, 'transition'> & {
|
|
78
|
+
id?: string;
|
|
79
|
+
transition: LogicTransition<TContext, TOutput, TEvent, TInput, TEmitted>;
|
|
80
|
+
};
|
|
81
|
+
export type LogicActorRef<TContext, TOutput, TEvent extends EventObject, TInput> = ActorRefFromLogic<LogicActorLogic<TContext, TOutput, TEvent, TInput>>;
|
|
82
|
+
export declare const XSTATE_LOGIC_EFFECT_RESOLVE = "xstate.logic.effect.resolve";
|
|
83
|
+
export declare const XSTATE_LOGIC_EFFECT_REJECT = "xstate.logic.effect.reject";
|
|
84
|
+
export declare const XSTATE_LOGIC_EFFECT_START = "xstate.logic.effect.start";
|
|
85
|
+
export declare function executeLogicEffects(effects: readonly unknown[] | undefined, actorScope: ActorScope<any, any, any, any>): void;
|
|
86
|
+
export declare function createLogic<TContext, const TInputSchema extends StandardSchemaV1, const TOutputSchema extends StandardSchemaV1, TEvent extends EventObject = EventObject, TEmitted extends EventObject = EventObject>(config: LogicConfig<TContext, StandardSchemaV1.InferOutput<TOutputSchema>, TEvent, StandardSchemaV1.InferOutput<TInputSchema>, TEmitted, TInputSchema, TOutputSchema> & {
|
|
87
|
+
schemas: {
|
|
88
|
+
input: TInputSchema;
|
|
89
|
+
output: TOutputSchema;
|
|
90
|
+
};
|
|
91
|
+
}): LogicActorLogic<TContext, StandardSchemaV1.InferOutput<TOutputSchema>, TEvent, StandardSchemaV1.InferOutput<TInputSchema>, TEmitted>;
|
|
92
|
+
export declare function createLogic<TContext, TOutput, const TInputSchema extends StandardSchemaV1, TEvent extends EventObject = EventObject, TEmitted extends EventObject = EventObject>(config: LogicConfig<TContext, TOutput, TEvent, StandardSchemaV1.InferOutput<TInputSchema>, TEmitted, TInputSchema> & {
|
|
93
|
+
schemas: {
|
|
94
|
+
input: TInputSchema;
|
|
95
|
+
output?: undefined;
|
|
96
|
+
};
|
|
97
|
+
}): LogicActorLogic<TContext, TOutput, TEvent, StandardSchemaV1.InferOutput<TInputSchema>, TEmitted>;
|
|
98
|
+
export declare function createLogic<TContext, const TOutputSchema extends StandardSchemaV1, TEvent extends EventObject = EventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject>(config: LogicConfig<TContext, StandardSchemaV1.InferOutput<TOutputSchema>, TEvent, TInput, TEmitted, StandardSchemaV1, TOutputSchema> & {
|
|
99
|
+
schemas: {
|
|
100
|
+
input?: undefined;
|
|
101
|
+
output: TOutputSchema;
|
|
102
|
+
};
|
|
103
|
+
}): LogicActorLogic<TContext, StandardSchemaV1.InferOutput<TOutputSchema>, TEvent, TInput, TEmitted>;
|
|
104
|
+
export declare function createLogic<TContext, TOutput = unknown, TEvent extends EventObject = EventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject>(config: LogicConfig<TContext, TOutput, TEvent, TInput, TEmitted>): LogicActorLogic<TContext, TOutput, TEvent, TInput, TEmitted>;
|
|
105
|
+
export {};
|