@typeonce/effect-machine 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -24
- package/dist/Machine.d.ts +386 -304
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +66 -171
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/activities.d.ts +5 -12
- package/dist/internal/machine/activities.d.ts.map +1 -1
- package/dist/internal/machine/activities.js +47 -17
- package/dist/internal/machine/activities.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +2 -2
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +25 -0
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts +10 -2
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +93 -34
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/invocationEvent.d.ts +39 -0
- package/dist/internal/machine/invocationEvent.d.ts.map +1 -0
- package/dist/internal/machine/invocationEvent.js +43 -0
- package/dist/internal/machine/invocationEvent.js.map +1 -0
- package/dist/internal/machine/machine.d.ts +6 -50
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +8 -65
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +2 -1
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +45 -2
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/protocol.d.ts +9 -0
- package/dist/internal/machine/protocol.d.ts.map +1 -1
- package/dist/internal/machine/protocol.js +114 -0
- package/dist/internal/machine/protocol.js.map +1 -1
- package/dist/internal/machine/symbols.d.ts +2 -0
- package/dist/internal/machine/symbols.d.ts.map +1 -1
- package/dist/internal/machine/symbols.js +2 -0
- package/dist/internal/machine/symbols.js.map +1 -1
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +23 -0
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +3 -3
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/docs/agent-guide.md +118 -93
- package/package.json +2 -2
- package/src/Machine.ts +1040 -651
- package/src/internal/machine/activities.ts +48 -33
- package/src/internal/machine/atom.ts +3 -3
- package/src/internal/machine/executionPlan.ts +29 -0
- package/src/internal/machine/invocation.ts +179 -48
- package/src/internal/machine/invocationEvent.ts +72 -0
- package/src/internal/machine/machine.ts +20 -346
- package/src/internal/machine/planner.ts +61 -10
- package/src/internal/machine/protocol.ts +149 -0
- package/src/internal/machine/symbols.ts +3 -0
- package/src/internal/machine/topology.ts +23 -0
- package/src/unstable/reactivity/AtomMachine.ts +3 -3
package/dist/Machine.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export type TypeId = "~effect/Machine";
|
|
|
37
37
|
export declare const TypeId: TypeId;
|
|
38
38
|
declare const MachineOutputStatesTypeId: unique symbol;
|
|
39
39
|
declare const MachineTypeId: unique symbol;
|
|
40
|
+
declare const EventConstructionTypeId: unique symbol;
|
|
41
|
+
declare const ChildMachineLogicTypeId: typeof internal.ChildMachineLogicTypeId;
|
|
40
42
|
/**
|
|
41
43
|
* Type identifier used for the synthetic event passed to startup lifecycle
|
|
42
44
|
* actions.
|
|
@@ -109,7 +111,8 @@ export interface Machine<States extends Machine.StateSchemas, Events extends Rea
|
|
|
109
111
|
*/
|
|
110
112
|
readonly events: InputEvents;
|
|
111
113
|
/**
|
|
112
|
-
* Events reserved for
|
|
114
|
+
* Events reserved for raised events, child emissions, and other machine-local
|
|
115
|
+
* work.
|
|
113
116
|
*
|
|
114
117
|
* @since 0.4.0
|
|
115
118
|
*/
|
|
@@ -265,7 +268,7 @@ export interface Runtime<in Events, in Emits> {
|
|
|
265
268
|
*
|
|
266
269
|
* @since 0.4.0
|
|
267
270
|
*/
|
|
268
|
-
readonly raise: (event: Events) => Effect.Effect<void, MachineSchemaDecodeError | StoppedError>;
|
|
271
|
+
readonly raise: (event: Machine.EventInput<Events>) => Effect.Effect<void, MachineSchemaDecodeError | StoppedError>;
|
|
269
272
|
/**
|
|
270
273
|
* Emits an event through the running machine's parent boundary.
|
|
271
274
|
*
|
|
@@ -283,7 +286,7 @@ export interface Runtime<in Events, in Emits> {
|
|
|
283
286
|
*/
|
|
284
287
|
export interface Enqueue<in Events, in Emits> {
|
|
285
288
|
/** Raises an event inside the current macrostep. */
|
|
286
|
-
readonly raise: (event: Events) => void;
|
|
289
|
+
readonly raise: (event: Machine.EventInput<Events>) => void;
|
|
287
290
|
/** Emits an event through the machine's parent boundary. */
|
|
288
291
|
readonly emit: (event: Emits) => void;
|
|
289
292
|
/** Sends an event to an invoked child after the transition is selected. */
|
|
@@ -904,7 +907,8 @@ export declare namespace Logic {
|
|
|
904
907
|
*
|
|
905
908
|
* `sendParent` accepts `unknown` because process logic is independent from
|
|
906
909
|
* the parent that eventually owns it. Prefer typed process output or an
|
|
907
|
-
*
|
|
910
|
+
* invocation lifecycle transition when either can represent the
|
|
911
|
+
* communication.
|
|
908
912
|
*
|
|
909
913
|
* @category models
|
|
910
914
|
* @since 0.4.0
|
|
@@ -952,8 +956,9 @@ type InvokeLifecycleId = string & {
|
|
|
952
956
|
* **Details**
|
|
953
957
|
*
|
|
954
958
|
* The descriptor carries the child's address and complete machine type. Pass
|
|
955
|
-
* the same
|
|
956
|
-
* event, error, and output types are inferred
|
|
959
|
+
* a descriptor for the same id and machine to inline `invoke`, `sendTo`, and
|
|
960
|
+
* child lookup APIs so state, event, error, and output types are inferred
|
|
961
|
+
* without separate annotations.
|
|
957
962
|
*
|
|
958
963
|
* @category models
|
|
959
964
|
* @since 0.4.0
|
|
@@ -964,6 +969,8 @@ export interface ChildMachine<Id extends string, M extends Machine.Any> {
|
|
|
964
969
|
readonly id: Id;
|
|
965
970
|
/** Complete machine definition carried by this descriptor. */
|
|
966
971
|
readonly machine: M;
|
|
972
|
+
/** @internal */
|
|
973
|
+
readonly [ChildMachineLogicTypeId]: (input?: unknown) => Logic<any, any, any, any, any, any>;
|
|
967
974
|
}
|
|
968
975
|
/**
|
|
969
976
|
* Namespace containing type-level members associated with `ChildMachine`.
|
|
@@ -985,7 +992,7 @@ export declare namespace ChildMachine {
|
|
|
985
992
|
* @category utility types
|
|
986
993
|
* @since 0.4.0
|
|
987
994
|
*/
|
|
988
|
-
type Ref<Child> = Child extends ChildMachine<string, infer M> ? MachineRef<Machine.Snapshot<Machine.States<M>>, Machine.InputEvent<M
|
|
995
|
+
type Ref<Child> = Child extends ChildMachine<string, infer M> ? MachineRef<Machine.Snapshot<Machine.States<M>>, Machine.EventInput<Machine.InputEvent<M>>, Machine.Error<M> | ActionError<Machine.Services<M>> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Machine.Output<M>> : never;
|
|
989
996
|
/**
|
|
990
997
|
* Event accepted by the child selected by a descriptor.
|
|
991
998
|
*
|
|
@@ -1221,6 +1228,11 @@ export declare namespace Machine {
|
|
|
1221
1228
|
* @since 0.4.0
|
|
1222
1229
|
*/
|
|
1223
1230
|
type InputEvents<M extends Any> = M[typeof MachineTypeId]["inputEvents"];
|
|
1231
|
+
/** Extracts the internal event schema tuple carried by a machine definition. */
|
|
1232
|
+
type InternalEvents<M extends Any> = Events<M> extends readonly [
|
|
1233
|
+
...InputEvents<M>,
|
|
1234
|
+
...infer Internal extends ReadonlyArray<TaggedSchema>
|
|
1235
|
+
] ? Internal : readonly [];
|
|
1224
1236
|
/**
|
|
1225
1237
|
* Extracts the complete event protocol handled inside a machine.
|
|
1226
1238
|
*
|
|
@@ -1235,6 +1247,40 @@ export declare namespace Machine {
|
|
|
1235
1247
|
* @since 0.4.0
|
|
1236
1248
|
*/
|
|
1237
1249
|
type InputEvent<M extends Any> = EventOf<InputEvents<M>>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Opaque event construction returned by {@link events} and
|
|
1252
|
+
* {@link internalEvents}.
|
|
1253
|
+
*
|
|
1254
|
+
* The machine resolves the instruction through its event schema when it is
|
|
1255
|
+
* delivered. Only the discriminator is available before decoding succeeds.
|
|
1256
|
+
*/
|
|
1257
|
+
interface EventConstruction<out Event extends {
|
|
1258
|
+
readonly _tag: PropertyKey;
|
|
1259
|
+
}> {
|
|
1260
|
+
readonly [EventConstructionTypeId]: Event;
|
|
1261
|
+
readonly _tag: Event["_tag"];
|
|
1262
|
+
}
|
|
1263
|
+
/** A decoded event or a deferred machine-bound construction of that event. */
|
|
1264
|
+
type EventInput<Event> = Event | (Event extends {
|
|
1265
|
+
readonly _tag: PropertyKey;
|
|
1266
|
+
} ? EventConstruction<Event> : never);
|
|
1267
|
+
/** Event inputs accepted for a schema tuple at machine delivery boundaries. */
|
|
1268
|
+
type EventInputOf<Events extends ReadonlyArray<TaggedSchema>> = EventInput<EventOf<Events>>;
|
|
1269
|
+
type EventConstructorInput<EventSchema extends TaggedSchema> = Omit<EventSchema["~type.make.in"], "_tag">;
|
|
1270
|
+
type EventConstructor<EventSchema extends TaggedSchema, Tag extends EventSchema["Type"]["_tag"]> = {} extends EventConstructorInput<EventSchema> ? (input?: EventConstructorInput<EventSchema>) => EventConstruction<EventByTag<readonly [EventSchema], Tag>> : (input: EventConstructorInput<EventSchema>) => EventConstruction<EventByTag<readonly [EventSchema], Tag>>;
|
|
1271
|
+
type EventConstructorsForSchema<EventSchema extends TaggedSchema> = EventSchema extends {
|
|
1272
|
+
readonly cases: infer Cases extends Readonly<Record<PropertyKey, TaggedSchema>>;
|
|
1273
|
+
} ? {
|
|
1274
|
+
readonly [Tag in keyof Cases]: Tag extends Cases[Tag]["Type"]["_tag"] ? EventConstructor<Cases[Tag], Tag> : never;
|
|
1275
|
+
} : EventSchema extends {
|
|
1276
|
+
readonly members: infer Members extends ReadonlyArray<TaggedSchema>;
|
|
1277
|
+
} ? Types.UnionToIntersection<EventConstructorsForSchema<Members[number]>> : {
|
|
1278
|
+
readonly [Tag in EventSchema["Type"]["_tag"]]: EventConstructor<EventSchema, Tag>;
|
|
1279
|
+
};
|
|
1280
|
+
/** Protocol-bound constructors keyed by each configured event tag. */
|
|
1281
|
+
type EventConstructors<Events extends ReadonlyArray<TaggedSchema>> = {
|
|
1282
|
+
readonly [Tag in keyof Types.UnionToIntersection<EventConstructorsForSchema<Events[number]>>]: Types.UnionToIntersection<EventConstructorsForSchema<Events[number]>>[Tag];
|
|
1283
|
+
};
|
|
1238
1284
|
/**
|
|
1239
1285
|
* Extracts the event protocol emitted by a machine.
|
|
1240
1286
|
*
|
|
@@ -1596,6 +1642,10 @@ export declare namespace Machine {
|
|
|
1596
1642
|
readonly type: "done";
|
|
1597
1643
|
} | {
|
|
1598
1644
|
readonly type: "choice";
|
|
1645
|
+
} | {
|
|
1646
|
+
readonly type: "invoke";
|
|
1647
|
+
readonly id: string;
|
|
1648
|
+
readonly outcome: "done" | "failure" | "snapshot";
|
|
1599
1649
|
};
|
|
1600
1650
|
/**
|
|
1601
1651
|
* Statically inspectable destination paths for a transition handler.
|
|
@@ -1615,10 +1665,10 @@ export declare namespace Machine {
|
|
|
1615
1665
|
*
|
|
1616
1666
|
* **Details**
|
|
1617
1667
|
*
|
|
1618
|
-
* Event, eventless, and
|
|
1619
|
-
* possible target paths. A handler without that
|
|
1620
|
-
* reported as dynamic. The source, trigger, and
|
|
1621
|
-
* available without executing the handler.
|
|
1668
|
+
* Event, eventless, completion, and invocation lifecycle handlers may
|
|
1669
|
+
* declare an upper bound of possible target paths. A handler without that
|
|
1670
|
+
* declaration is explicitly reported as dynamic. The source, trigger, and
|
|
1671
|
+
* reentry behavior are available without executing the handler.
|
|
1622
1672
|
*
|
|
1623
1673
|
* @category models
|
|
1624
1674
|
* @since 0.4.0
|
|
@@ -1632,9 +1682,9 @@ export declare namespace Machine {
|
|
|
1632
1682
|
/**
|
|
1633
1683
|
* Serializable description of state-owned work.
|
|
1634
1684
|
*
|
|
1635
|
-
* Static invoke
|
|
1636
|
-
* retaining Effects, closures, services, or child runtimes.
|
|
1637
|
-
*
|
|
1685
|
+
* Static invoke definitions expose their lifecycle id and kind without
|
|
1686
|
+
* retaining Effects, closures, services, or child runtimes. Function-valued
|
|
1687
|
+
* sources are reported as dynamic and are never evaluated by inspection.
|
|
1638
1688
|
*
|
|
1639
1689
|
* @category models
|
|
1640
1690
|
* @since 0.4.0
|
|
@@ -2366,7 +2416,7 @@ export declare namespace Machine {
|
|
|
2366
2416
|
readonly event: LifecycleEvent<Events>;
|
|
2367
2417
|
}
|
|
2368
2418
|
/**
|
|
2369
|
-
* Context passed to
|
|
2419
|
+
* Context passed to a function-valued invocation source.
|
|
2370
2420
|
*
|
|
2371
2421
|
* @category models
|
|
2372
2422
|
* @since 0.4.0
|
|
@@ -2378,27 +2428,46 @@ export declare namespace Machine {
|
|
|
2378
2428
|
readonly event: LifecycleEvent<Events>;
|
|
2379
2429
|
}
|
|
2380
2430
|
/**
|
|
2381
|
-
* Context passed to an
|
|
2431
|
+
* Context passed to an invocation's active-snapshot transition.
|
|
2382
2432
|
*
|
|
2383
2433
|
* @category models
|
|
2384
2434
|
* @since 0.4.0
|
|
2385
2435
|
*/
|
|
2386
|
-
interface InvokeSnapshotContext<State, Error, Output> {
|
|
2436
|
+
interface InvokeSnapshotContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, State, Error, Output> {
|
|
2387
2437
|
readonly id: string;
|
|
2438
|
+
readonly state: StateByIdentifier<States, StateId>;
|
|
2439
|
+
readonly parent: ParentStateValue<States, StateId>;
|
|
2440
|
+
readonly parents: ParentStateValues<States, StateId>;
|
|
2441
|
+
readonly target: TargetBuilder<States, StateId>;
|
|
2388
2442
|
readonly snapshot: Extract<RuntimeSnapshot<State, Error, Output>, {
|
|
2389
2443
|
readonly status: "active";
|
|
2390
2444
|
}>;
|
|
2391
2445
|
}
|
|
2392
2446
|
/**
|
|
2393
|
-
* Context passed to an
|
|
2447
|
+
* Context passed to an invocation's successful completion transition.
|
|
2394
2448
|
*
|
|
2395
2449
|
* @category models
|
|
2396
2450
|
* @since 0.4.0
|
|
2397
2451
|
*/
|
|
2398
|
-
interface InvokeDoneContext<Output> {
|
|
2452
|
+
interface InvokeDoneContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Output> {
|
|
2399
2453
|
readonly id: string;
|
|
2454
|
+
readonly state: StateByIdentifier<States, StateId>;
|
|
2455
|
+
readonly parent: ParentStateValue<States, StateId>;
|
|
2456
|
+
readonly parents: ParentStateValues<States, StateId>;
|
|
2457
|
+
readonly snapshot: Snapshot<States>;
|
|
2458
|
+
readonly target: TargetBuilder<States, StateId>;
|
|
2400
2459
|
readonly output: Output;
|
|
2401
2460
|
}
|
|
2461
|
+
/** Context passed to an invocation typed-failure transition. */
|
|
2462
|
+
interface InvokeFailureContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Error> {
|
|
2463
|
+
readonly id: string;
|
|
2464
|
+
readonly state: StateByIdentifier<States, StateId>;
|
|
2465
|
+
readonly parent: ParentStateValue<States, StateId>;
|
|
2466
|
+
readonly parents: ParentStateValues<States, StateId>;
|
|
2467
|
+
readonly snapshot: Snapshot<States>;
|
|
2468
|
+
readonly target: TargetBuilder<States, StateId>;
|
|
2469
|
+
readonly error: Error;
|
|
2470
|
+
}
|
|
2402
2471
|
/**
|
|
2403
2472
|
* Context passed to an eventless transition handler.
|
|
2404
2473
|
*
|
|
@@ -2611,9 +2680,17 @@ export declare namespace Machine {
|
|
|
2611
2680
|
* @category utility types
|
|
2612
2681
|
* @since 0.4.0
|
|
2613
2682
|
*/
|
|
2683
|
+
type InvokeResolvedSource<Source> = Source extends (...args: any) => infer Resolved ? Resolved : Source;
|
|
2684
|
+
type ChildMachineLogic<Child> = Child extends ChildMachine<string, infer M> ? Logic<Snapshot<States<M>>, EventInput<InputEvent<M>>, Error<M> | ActionError<Services<M>> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, ExcludeCompatibleRuntime<Exclude<ExecutionServices<InitialServices<M> | Services<M>>, internalRuntime.MachineRuntime>, Event<M>, Emit<M>>, Output<M>, InitialError<M> | Error<M> | ActionError<InitialServices<M> | Services<M>> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError> : never;
|
|
2614
2685
|
type InvokeLogic<Invoke> = Invoke extends {
|
|
2615
|
-
readonly
|
|
2616
|
-
} ? Logic : never
|
|
2686
|
+
readonly effect: infer Source;
|
|
2687
|
+
} ? InvokeResolvedSource<Source> extends infer Fx extends Effect.Effect<any, any, any> ? Logic<void, never, Effect.Error<Fx>, Effect.Services<Fx>, Effect.Success<Fx>> : never : Invoke extends {
|
|
2688
|
+
readonly after: unknown;
|
|
2689
|
+
} ? Logic<void, never, never, never, void> : Invoke extends {
|
|
2690
|
+
readonly logic: infer Source;
|
|
2691
|
+
} ? InvokeResolvedSource<Source> : Invoke extends {
|
|
2692
|
+
readonly child: infer Child;
|
|
2693
|
+
} ? ChildMachineLogic<Child> : never;
|
|
2617
2694
|
/**
|
|
2618
2695
|
* Extracts the startup error from an invoke source child process logic.
|
|
2619
2696
|
*
|
|
@@ -2666,34 +2743,33 @@ export declare namespace Machine {
|
|
|
2666
2743
|
*/
|
|
2667
2744
|
type InvokeEmits<Invoke> = Invoke extends {
|
|
2668
2745
|
readonly [InvokeTypeId]: {
|
|
2669
|
-
readonly emits: Types.Covariant<infer
|
|
2670
|
-
};
|
|
2671
|
-
} ? Emits : never;
|
|
2672
|
-
/**
|
|
2673
|
-
* Extracts events returned by an invoked child snapshot mapper.
|
|
2674
|
-
*
|
|
2675
|
-
* @category utility types
|
|
2676
|
-
* @since 0.4.0
|
|
2677
|
-
*/
|
|
2678
|
-
type InvokeSnapshotEvent<Invoke> = Invoke extends {
|
|
2679
|
-
readonly [InvokeTypeId]: {
|
|
2680
|
-
readonly snapshotEvent: Types.Covariant<infer Event>;
|
|
2746
|
+
readonly emits: Types.Covariant<infer Emitted>;
|
|
2681
2747
|
};
|
|
2682
|
-
} ?
|
|
2748
|
+
} ? Emitted : Invoke extends {
|
|
2749
|
+
readonly child: ChildMachine<string, infer M>;
|
|
2750
|
+
} ? Emit<M> : never;
|
|
2751
|
+
/** Extracts transition results returned by invocation lifecycle handlers. */
|
|
2752
|
+
type InvokeOutcomeReturn<Invoke> = Invoke extends unknown ? (Invoke extends {
|
|
2753
|
+
readonly onDone?: infer Handler;
|
|
2754
|
+
} ? EventTransitionReturn<NonNullable<Handler>> : never) | (Invoke extends {
|
|
2755
|
+
readonly onFailure?: infer Handler;
|
|
2756
|
+
} ? EventTransitionReturn<NonNullable<Handler>> : never) | (Invoke extends {
|
|
2757
|
+
readonly onSnapshot?: infer Handler;
|
|
2758
|
+
} ? EventTransitionReturn<NonNullable<Handler>> : never) : never;
|
|
2683
2759
|
/**
|
|
2684
2760
|
* Extracts the parent transition error contribution from invoked children.
|
|
2685
2761
|
*
|
|
2686
2762
|
* @category utility types
|
|
2687
2763
|
* @since 0.4.0
|
|
2688
2764
|
*/
|
|
2689
|
-
type InvokeError<Config> = [InvokeReturn<Config>] extends [never] ? never : ChildAlreadyExistsError | InvokeInitialError<InvokeReturn<Config>> |
|
|
2765
|
+
type InvokeError<Config> = [InvokeReturn<Config>] extends [never] ? never : ChildAlreadyExistsError | InvokeInitialError<InvokeReturn<Config>> | Effect.Error<InvokeOutcomeReturn<InvokeReturn<Config>>>;
|
|
2690
2766
|
/**
|
|
2691
2767
|
* Extracts the parent service requirement contribution from invoked children.
|
|
2692
2768
|
*
|
|
2693
2769
|
* @category utility types
|
|
2694
2770
|
* @since 0.4.0
|
|
2695
2771
|
*/
|
|
2696
|
-
type InvokeRequirements<Config> = [InvokeReturn<Config>] extends [never] ? never : MachineRuntimeRequirement | InvokeServices<InvokeReturn<Config
|
|
2772
|
+
type InvokeRequirements<Config> = [InvokeReturn<Config>] extends [never] ? never : MachineRuntimeRequirement | InvokeServices<InvokeReturn<Config>> | Effect.Services<InvokeOutcomeReturn<InvokeReturn<Config>>>;
|
|
2697
2773
|
/**
|
|
2698
2774
|
* Extracts the return value from an eventless transition.
|
|
2699
2775
|
*
|
|
@@ -2728,63 +2804,171 @@ export declare namespace Machine {
|
|
|
2728
2804
|
* @since 0.4.0
|
|
2729
2805
|
*/
|
|
2730
2806
|
type ConfigServices<Config> = Effect.Services<EventHandlerReturn<Config>> | Effect.Services<AlwaysReturn<Config>> | Effect.Services<DoneReturn<Config>> | Effect.Services<StateActionReturn<Config, "entry">> | Effect.Services<StateActionReturn<Config, "exit">> | Effect.Services<StateInitialReturn<Config>> | Effect.Services<HistoryDefaultReturn<Config>> | Effect.Services<ChoiceReturn<Config>> | InvokeRequirements<Config>;
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
interface
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
readonly emits: Types.Covariant<ChildEmits>;
|
|
2741
|
-
readonly snapshotEvent: Types.Covariant<Event>;
|
|
2742
|
-
readonly error: Types.Covariant<ChildError>;
|
|
2743
|
-
readonly requirements: Types.Covariant<ChildRequirements>;
|
|
2744
|
-
readonly initialError: Types.Covariant<ChildInitialError>;
|
|
2745
|
-
};
|
|
2746
|
-
/** @internal Serializable descriptor metadata used by inspection. */
|
|
2747
|
-
readonly [Activities.ActivityMetadataTypeId]?: Activities.StaticActivityMetadata;
|
|
2748
|
-
readonly id: string;
|
|
2749
|
-
/**
|
|
2750
|
-
* Optional parent-local address for sending events to this invocation.
|
|
2751
|
-
*
|
|
2752
|
-
* The invocation `id` is only its state-local lifecycle key. Use an
|
|
2753
|
-
* explicit typed address when the parent must communicate with it.
|
|
2754
|
-
*/
|
|
2755
|
-
readonly address?: string;
|
|
2756
|
-
/** @internal */
|
|
2757
|
-
readonly descriptor?: ChildMachine.Any;
|
|
2758
|
-
src(): Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>;
|
|
2759
|
-
snapshot?(context: InvokeSnapshotContext<ChildState, ChildError, ChildOutput>): Event | undefined;
|
|
2760
|
-
onDone?(context: InvokeDoneContext<ChildOutput>): DeliveredOutput | undefined;
|
|
2807
|
+
type InvokeTransition<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Context> = ((context: Context, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => HandlerResult<States, any, any>) | {
|
|
2808
|
+
readonly reenter?: boolean;
|
|
2809
|
+
readonly targets?: ReadonlyArray<StateNodeIdentifier<States>>;
|
|
2810
|
+
readonly transition: (context: Context, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => HandlerResult<States, any, any>;
|
|
2811
|
+
};
|
|
2812
|
+
type InvokeSource<Value, Context> = Value | ((context: Context) => Value);
|
|
2813
|
+
interface AnyLogicSource {
|
|
2814
|
+
initial(...args: ReadonlyArray<any>): Effect.Effect<any, any, any>;
|
|
2815
|
+
run(...args: ReadonlyArray<any>): Effect.Effect<any, any, any>;
|
|
2761
2816
|
}
|
|
2762
|
-
/**
|
|
2763
|
-
interface
|
|
2817
|
+
/** Inline state-owned work that runs for the lifetime of its active state. */
|
|
2818
|
+
interface InvokeOwned<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> {
|
|
2819
|
+
readonly "~effect/Machine/InvokeOwner"?: Types.Covariant<readonly [States, Events, Emits, StateId]>;
|
|
2820
|
+
}
|
|
2821
|
+
/** Type evidence retained by {@link invoke} without affecting runtime data. */
|
|
2822
|
+
interface InvokeTyped<Output, Error, Requirements, InitialError, Emits = never> {
|
|
2764
2823
|
readonly [InvokeTypeId]: {
|
|
2765
2824
|
readonly output: Types.Covariant<Output>;
|
|
2766
|
-
readonly emits: Types.Covariant<Emits>;
|
|
2767
|
-
readonly snapshotEvent: Types.Covariant<SnapshotEvent>;
|
|
2768
2825
|
readonly error: Types.Covariant<Error>;
|
|
2769
2826
|
readonly requirements: Types.Covariant<Requirements>;
|
|
2770
2827
|
readonly initialError: Types.Covariant<InitialError>;
|
|
2828
|
+
readonly emits: Types.Covariant<Emits>;
|
|
2771
2829
|
};
|
|
2772
2830
|
}
|
|
2773
|
-
|
|
2774
|
-
readonly
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2831
|
+
type InvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> = InvokeOwned<States, Events, Emits, StateId> & ({
|
|
2832
|
+
readonly id: string;
|
|
2833
|
+
readonly effect: InvokeSource<Effect.Effect<any, any, any>, InvokeContext<States, Events, Emits, StateId>>;
|
|
2834
|
+
readonly after?: never;
|
|
2835
|
+
readonly logic?: never;
|
|
2836
|
+
readonly child?: never;
|
|
2837
|
+
readonly address?: never;
|
|
2838
|
+
readonly onDone?: unknown;
|
|
2839
|
+
readonly onFailure?: unknown;
|
|
2840
|
+
readonly onSnapshot?: never;
|
|
2841
|
+
} | {
|
|
2842
|
+
readonly id: string;
|
|
2843
|
+
readonly after: InvokeSource<Duration.Input, InvokeContext<States, Events, Emits, StateId>>;
|
|
2844
|
+
readonly effect?: never;
|
|
2845
|
+
readonly logic?: never;
|
|
2846
|
+
readonly child?: never;
|
|
2847
|
+
readonly address?: never;
|
|
2848
|
+
readonly onDone: unknown;
|
|
2849
|
+
readonly onFailure?: never;
|
|
2850
|
+
readonly onSnapshot?: never;
|
|
2851
|
+
} | {
|
|
2852
|
+
readonly id: string;
|
|
2853
|
+
readonly address: string;
|
|
2854
|
+
readonly logic: InvokeSource<AnyLogicSource, InvokeContext<States, Events, Emits, StateId>>;
|
|
2855
|
+
readonly effect?: never;
|
|
2856
|
+
readonly after?: never;
|
|
2857
|
+
readonly child?: never;
|
|
2858
|
+
readonly onDone?: unknown;
|
|
2859
|
+
readonly onFailure?: unknown;
|
|
2860
|
+
readonly onSnapshot?: unknown;
|
|
2861
|
+
} | {
|
|
2862
|
+
readonly child: ChildMachine.Any;
|
|
2863
|
+
readonly input?: {} | null | ((context: InvokeContext<States, Events, Emits, StateId>) => unknown);
|
|
2864
|
+
readonly id?: never;
|
|
2865
|
+
readonly address?: never;
|
|
2866
|
+
readonly effect?: never;
|
|
2867
|
+
readonly after?: never;
|
|
2868
|
+
readonly logic?: never;
|
|
2869
|
+
readonly onDone?: unknown;
|
|
2870
|
+
readonly onFailure?: unknown;
|
|
2871
|
+
readonly onSnapshot?: unknown;
|
|
2872
|
+
});
|
|
2873
|
+
/** State-bound inline invocation configuration. */
|
|
2874
|
+
type InvokeDefinition<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> = InvokeConfig<States, Events, Emits, StateId> | ReadonlyArray<InvokeConfig<States, Events, Emits, StateId>>;
|
|
2875
|
+
type InvokeHandlerRequirement<Value, Handler> = IsAny<Value> extends true ? {
|
|
2876
|
+
readonly handler: Handler;
|
|
2877
|
+
} : [Value] extends [never] ? {
|
|
2878
|
+
readonly handler?: never;
|
|
2879
|
+
} : {
|
|
2880
|
+
readonly handler: Handler;
|
|
2881
|
+
};
|
|
2882
|
+
type InvokeDoneRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends infer Requirement ? Requirement extends {
|
|
2883
|
+
readonly handler: infer Required;
|
|
2884
|
+
} ? {
|
|
2885
|
+
readonly onDone: Required;
|
|
2886
|
+
} : {
|
|
2887
|
+
readonly onDone?: never;
|
|
2888
|
+
} : never;
|
|
2889
|
+
type InvokeFailureRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends infer Requirement ? Requirement extends {
|
|
2890
|
+
readonly handler: infer Required;
|
|
2891
|
+
} ? {
|
|
2892
|
+
readonly onFailure: Required;
|
|
2893
|
+
} : {
|
|
2894
|
+
readonly onFailure?: never;
|
|
2895
|
+
} : never;
|
|
2896
|
+
type EffectInvokeArgs<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Fx extends Effect.Effect<any, any, any>, Source = Fx> = {
|
|
2897
|
+
readonly id: InvokeLifecycleId;
|
|
2898
|
+
readonly effect: Source;
|
|
2899
|
+
readonly after?: never;
|
|
2900
|
+
readonly logic?: never;
|
|
2901
|
+
readonly child?: never;
|
|
2902
|
+
readonly address?: never;
|
|
2903
|
+
readonly onSnapshot?: never;
|
|
2904
|
+
} & InvokeDoneRequirement<Effect.Success<NoInfer<Fx>>, InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<NoInfer<Fx>>>>> & InvokeFailureRequirement<Effect.Error<NoInfer<Fx>>, InvokeTransition<States, Events, Emits, InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<NoInfer<Fx>>>>>;
|
|
2905
|
+
type TimerInvokeArgs<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>> = {
|
|
2906
|
+
readonly id: InvokeLifecycleId;
|
|
2907
|
+
readonly after: InvokeSource<Duration.Input, InvokeContext<States, Events, Emits, StateId>>;
|
|
2908
|
+
readonly effect?: never;
|
|
2909
|
+
readonly logic?: never;
|
|
2910
|
+
readonly child?: never;
|
|
2911
|
+
readonly address?: never;
|
|
2912
|
+
readonly onFailure?: never;
|
|
2913
|
+
readonly onSnapshot?: never;
|
|
2914
|
+
readonly onDone: InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, void>>;
|
|
2915
|
+
};
|
|
2916
|
+
type LogicInvokeArgs<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address extends ChildAddress<never>, Source = Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>> = {
|
|
2917
|
+
readonly id: InvokeLifecycleId;
|
|
2918
|
+
readonly address: Address & ChildAddress.Compatibility<Address, ChildEvent>;
|
|
2919
|
+
readonly logic: Source;
|
|
2920
|
+
readonly effect?: never;
|
|
2921
|
+
readonly after?: never;
|
|
2922
|
+
readonly child?: never;
|
|
2923
|
+
readonly onSnapshot?: InvokeTransition<States, Events, Emits, InvokeSnapshotContext<States, Events, Emits, StateId, ChildState, ChildError, ChildOutput>>;
|
|
2924
|
+
} & InvokeDoneRequirement<ChildOutput, InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, ChildOutput>>> & InvokeFailureRequirement<ChildError, InvokeTransition<States, Events, Emits, InvokeFailureContext<States, Events, Emits, StateId, ChildError>>>;
|
|
2925
|
+
type ChildInvokeArgs<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, ChildDefinition extends Machine.Any, Child extends ChildMachine<string, ChildDefinition>> = {
|
|
2926
|
+
readonly child: Child & (ChildDefinition extends EnsureExecutable<Machine.States<ChildDefinition>, Machine.UnhandledStates<ChildDefinition>, Machine.OutputStates<ChildDefinition>> ? unknown : never);
|
|
2927
|
+
readonly id?: never;
|
|
2928
|
+
readonly address?: never;
|
|
2929
|
+
readonly effect?: never;
|
|
2930
|
+
readonly after?: never;
|
|
2931
|
+
readonly logic?: never;
|
|
2932
|
+
readonly onSnapshot?: InvokeTransition<States, Events, Emits, InvokeSnapshotContext<States, Events, Emits, StateId, Snapshot<Machine.States<ChildDefinition>>, Error<ChildDefinition>, Output<ChildDefinition>>>;
|
|
2933
|
+
} & (Input<ChildDefinition> extends typeof Schema.Void ? {
|
|
2934
|
+
readonly input?: never;
|
|
2935
|
+
} : {
|
|
2936
|
+
readonly input: InvokeSource<Input<ChildDefinition>["Type"], InvokeContext<States, Events, Emits, StateId>>;
|
|
2937
|
+
}) & InvokeDoneRequirement<Output<ChildDefinition>, InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, Output<ChildDefinition>>>> & InvokeFailureRequirement<Error<ChildDefinition> | ActionError<Services<ChildDefinition>>, InvokeTransition<States, Events, Emits, InvokeFailureContext<States, Events, Emits, StateId, Error<ChildDefinition> | ActionError<Services<ChildDefinition>>>>>;
|
|
2938
|
+
type LogicStateOf<Value> = Value extends Logic<infer State, any, any, any, any, any> ? State : never;
|
|
2939
|
+
type LogicEventOf<Value> = Value extends Logic<any, infer Event, any, any, any, any> ? Event : never;
|
|
2940
|
+
type LogicErrorOf<Value> = Value extends Logic<any, any, infer Error, any, any, any> ? Error : never;
|
|
2941
|
+
type LogicServicesOf<Value> = Value extends Logic<any, any, any, infer Services, any, any> ? Services : never;
|
|
2942
|
+
type LogicOutputOf<Value> = Value extends Logic<any, any, any, any, infer Output, any> ? Output : never;
|
|
2943
|
+
type LogicInitialErrorOf<Value> = Value extends Logic<any, any, any, any, any, infer Error> ? Error : never;
|
|
2944
|
+
type ContextualInvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Raw> = Raw extends InvokeTyped<any, any, any, any, any> ? unknown : Raw extends {
|
|
2945
|
+
readonly effect: infer Source;
|
|
2946
|
+
} ? InvokeResolvedSource<Source> extends infer Fx extends Effect.Effect<any, any, any> ? InvokeDoneRequirement<Effect.Success<Fx>, InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<Fx>>>> & InvokeFailureRequirement<Effect.Error<Fx>, InvokeTransition<States, Events, Emits, InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<Fx>>>> & {
|
|
2947
|
+
readonly onSnapshot?: never;
|
|
2948
|
+
} : never : Raw extends {
|
|
2949
|
+
readonly after: unknown;
|
|
2950
|
+
} ? {
|
|
2951
|
+
readonly onDone: InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, void>>;
|
|
2952
|
+
readonly onFailure?: never;
|
|
2953
|
+
readonly onSnapshot?: never;
|
|
2954
|
+
} : Raw extends {
|
|
2955
|
+
readonly logic: infer Source;
|
|
2956
|
+
readonly address: infer Address;
|
|
2957
|
+
} ? InvokeResolvedSource<Source> extends infer ChildLogic extends Logic<any, any, any, any, any, any> ? InvokeDoneRequirement<InvokeOutput<Raw>, InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, InvokeOutput<Raw>>>> & InvokeFailureRequirement<InvokeRuntimeError<Raw>, InvokeTransition<States, Events, Emits, InvokeFailureContext<States, Events, Emits, StateId, InvokeRuntimeError<Raw>>>> & {
|
|
2958
|
+
readonly address: ChildAddress<never> & ChildAddress.Compatibility<Address, ChildLogic extends Logic<any, infer ChildEvent, any, any, any, any> ? ChildEvent : never>;
|
|
2959
|
+
readonly onSnapshot?: InvokeTransition<States, Events, Emits, InvokeSnapshotContext<States, Events, Emits, StateId, ChildLogic extends Logic<infer ChildState, any, any, any, any, any> ? ChildState : never, InvokeRuntimeError<Raw>, InvokeOutput<Raw>>>;
|
|
2960
|
+
} : never : Raw extends {
|
|
2961
|
+
readonly child: infer Child extends ChildMachine<string, infer ChildDefinition>;
|
|
2962
|
+
} ? ChildMachineLogic<Child> extends infer ChildLogic extends Logic<any, any, any, any, any, any> ? InvokeDoneRequirement<Output<ChildDefinition>, InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, Output<ChildDefinition>>>> & InvokeFailureRequirement<Error<ChildDefinition> | ActionError<Services<ChildDefinition>>, InvokeTransition<States, Events, Emits, InvokeFailureContext<States, Events, Emits, StateId, Error<ChildDefinition> | ActionError<Services<ChildDefinition>>>>> & (Input<ChildDefinition> extends typeof Schema.Void ? {
|
|
2963
|
+
readonly input?: never;
|
|
2964
|
+
} : {
|
|
2965
|
+
readonly input: InvokeSource<Input<ChildDefinition>["Type"], InvokeContext<States, Events, Emits, StateId>>;
|
|
2966
|
+
}) & {
|
|
2967
|
+
readonly onSnapshot?: InvokeTransition<States, Events, Emits, InvokeSnapshotContext<States, Events, Emits, StateId, Snapshot<Machine.States<ChildDefinition>>, Error<ChildDefinition>, Output<ChildDefinition>>>;
|
|
2968
|
+
} : never : never;
|
|
2969
|
+
type ContextualInvokeDefinition<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Raw> = Raw extends ReadonlyArray<any> ? {
|
|
2970
|
+
readonly [Index in keyof Raw]: ContextualInvokeConfig<States, Events, Emits, StateId, Raw[Index]>;
|
|
2971
|
+
} : ContextualInvokeConfig<States, Events, Emits, StateId, Raw>;
|
|
2788
2972
|
type OutputHandlerConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Context> = NodeByIdentifier<States, StateId> extends {
|
|
2789
2973
|
readonly output: Schema.Top;
|
|
2790
2974
|
} ? {
|
|
@@ -2918,6 +3102,12 @@ export declare namespace Machine {
|
|
|
2918
3102
|
readonly states: infer Children extends StateSchemas;
|
|
2919
3103
|
} ? HandlerNodeByPath<Children, Rest> : never : never : Path extends keyof States ? States[Path] : never;
|
|
2920
3104
|
type HandlerConfigAtPath<Config, Path extends string> = Path extends `${infer Head}.${infer Rest}` ? Head extends keyof Config ? HandlerConfigAtPath<HandlerNodeChildrenConfig<Config[Head]>, Rest> : never : Path extends keyof Config ? Config[Path] : never;
|
|
3105
|
+
type HandlerInvokeContextAtPath<AllStates extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Config, StateId extends StateNodeIdentifier<AllStates>, NodeConfig = HandlerConfigAtPath<Config, StateId>> = StateId extends StateIdentifier<AllStates> ? NodeConfig extends {
|
|
3106
|
+
readonly invoke: infer Invoke;
|
|
3107
|
+
} ? HandlerValidationAtPath<StateId, {
|
|
3108
|
+
readonly invoke: ContextualInvokeDefinition<AllStates, Events, Emits, StateId, Invoke>;
|
|
3109
|
+
}> : unknown : unknown;
|
|
3110
|
+
type HandlerInvokeContexts<AllStates extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Config> = Types.UnionToIntersection<StateNodeIdentifier<AllStates> extends infer StateId extends StateNodeIdentifier<AllStates> ? StateId extends StateNodeIdentifier<AllStates> ? HandlerInvokeContextAtPath<AllStates, Events, Emits, Config, StateId> : never : never>;
|
|
2921
3111
|
type HandlerValidationAtPath<Path extends string, Validation> = Path extends `${infer Head}.${infer Rest}` ? {
|
|
2922
3112
|
readonly [Key in Head]?: {
|
|
2923
3113
|
readonly states: HandlerValidationAtPath<Rest, Validation>;
|
|
@@ -3020,7 +3210,7 @@ export declare namespace Machine {
|
|
|
3020
3210
|
] extends [never] ? unknown : {
|
|
3021
3211
|
readonly output: HandlerValidationError<"Handler config is missing a region output implementation required by parallel output", StateId, Exclude<RequiredParallelOutputStates<AllStates, StateId>, AvailableOutputStates>>;
|
|
3022
3212
|
} : unknown : unknown);
|
|
3023
|
-
type HandlerNodeValidation<AllStates extends StateSchemas, Node, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<AllStates>, Config, AvailableOutputStates extends StateIdentifier<AllStates>> = StateId extends ChoiceIdentifier<AllStates> ? HandlerChoiceUnknownConfigKeyValidation<StateId, Config> & HandlerChoiceTargetValidation<StateId, Config> & HandlerRuntimeValidation<Events, Emits, StateId, Config> : StateId extends StateIdentifier<AllStates> ? HandlerUnknownConfigKeyValidation<StateId, Config> & HandlerOnKeyValidation<Events, StateId, Config> & HandlerOnTargetValidation<StateId, Config> & HandlerDirectTargetValidation<StateId, Config, "always"> & HandlerDirectTargetValidation<StateId, Config, "onDone"> &
|
|
3213
|
+
type HandlerNodeValidation<AllStates extends StateSchemas, Node, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<AllStates>, Config, AvailableOutputStates extends StateIdentifier<AllStates>> = StateId extends ChoiceIdentifier<AllStates> ? HandlerChoiceUnknownConfigKeyValidation<StateId, Config> & HandlerChoiceTargetValidation<StateId, Config> & HandlerRuntimeValidation<Events, Emits, StateId, Config> : StateId extends StateIdentifier<AllStates> ? HandlerUnknownConfigKeyValidation<StateId, Config> & HandlerOnKeyValidation<Events, StateId, Config> & HandlerOnTargetValidation<StateId, Config> & HandlerDirectTargetValidation<StateId, Config, "always"> & HandlerDirectTargetValidation<StateId, Config, "onDone"> & HandlerInvokeEmitsValidation<Events, StateId, Config> & HandlerChildrenValidation<Node, StateId, Config> & HandlerOutputRequirementValidation<AllStates, StateId, AvailableOutputStates, Config> & HandlerRuntimeValidation<Events, Emits, StateId, Config> : unknown;
|
|
3024
3214
|
type HandlerChoiceUnknownConfigKeyValidation<StateId extends string, Config, UnknownKeys extends string = Exclude<Extract<keyof Config, string>, "choice">> = [UnknownKeys] extends [never] ? unknown : {
|
|
3025
3215
|
readonly [Key in UnknownKeys]: HandlerValidationError<"Choice handler config contains an invalid key", StateId, Key>;
|
|
3026
3216
|
};
|
|
@@ -3029,15 +3219,9 @@ export declare namespace Machine {
|
|
|
3029
3219
|
} ? [UndeclaredTransitionTarget<Choice>] extends [never] ? unknown : {
|
|
3030
3220
|
readonly choice: HandlerValidationError<"Choice resolver returns a target not listed in targets", StateId, UndeclaredTransitionTarget<Choice>>;
|
|
3031
3221
|
} : unknown;
|
|
3032
|
-
type HandlerInvokeOutputValidation<Events extends ReadonlyArray<TaggedSchema>, StateId extends string, Config> = [InvokeReturn<Config>] extends [never] ? unknown : [Exclude<InvokeOutput<InvokeReturn<Config>>, EventOf<Events> | void>] extends [never] ? unknown : {
|
|
3033
|
-
readonly invoke: HandlerValidationError<"Invoked child output must be a machine event or void", StateId, Exclude<InvokeOutput<InvokeReturn<Config>>, EventOf<Events> | void>>;
|
|
3034
|
-
};
|
|
3035
3222
|
type HandlerInvokeEmitsValidation<Events extends ReadonlyArray<TaggedSchema>, StateId extends string, Config> = [InvokeReturn<Config>] extends [never] ? unknown : [Exclude<InvokeEmits<InvokeReturn<Config>>, EventOf<Events>>] extends [never] ? unknown : {
|
|
3036
3223
|
readonly invoke: HandlerValidationError<"Invoked child emits events not accepted by the parent machine", StateId, Exclude<InvokeEmits<InvokeReturn<Config>>, EventOf<Events>>>;
|
|
3037
3224
|
};
|
|
3038
|
-
type HandlerInvokeSnapshotValidation<Events extends ReadonlyArray<TaggedSchema>, StateId extends string, Config> = [InvokeReturn<Config>] extends [never] ? unknown : IsAny<InvokeSnapshotEvent<InvokeReturn<Config>>> extends true ? unknown : [Exclude<InvokeSnapshotEvent<InvokeReturn<Config>>, EventOf<Events> | undefined>] extends [never] ? unknown : {
|
|
3039
|
-
readonly invoke: HandlerValidationError<"Invoked child snapshot mapper must return a machine event or undefined", StateId, Exclude<InvokeSnapshotEvent<InvokeReturn<Config>>, EventOf<Events> | undefined>>;
|
|
3040
|
-
};
|
|
3041
3225
|
type HandlerRuntimeValidation<Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends string, Config, Incompatible = IncompatibleRuntime<ConfigServices<HandlerConfigPart<Config>>, EventOf<Events>, EmitOf<Emits>>> = [Incompatible] extends [never] ? unknown : HandlerValidationError<"Handler config requires an incompatible machine runtime", StateId, Incompatible>;
|
|
3042
3226
|
type HandlerNodeValidationAtPath<AllStates extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Config, AvailableOutputStates extends StateIdentifier<AllStates>, StateId extends StateNodeIdentifier<AllStates>, NodeConfig = HandlerConfigAtPath<Config, StateId>> = [NodeConfig] extends [never] ? never : HandlerNodeValidation<AllStates, HandlerNodeByPath<AllStates, StateId>, Events, Emits, StateId, NodeConfig, AvailableOutputStates> extends infer Validation ? unknown extends Validation ? never : HandlerValidationAtPath<StateId, Validation> : never;
|
|
3043
3227
|
type HandlerTreeNodeValidations<AllStates extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Config, AvailableOutputStates extends StateIdentifier<AllStates>> = Types.UnionToIntersection<StateNodeIdentifier<AllStates> extends infer StateId extends StateNodeIdentifier<AllStates> ? StateId extends StateNodeIdentifier<AllStates> ? HandlerNodeValidationAtPath<AllStates, Events, Emits, Config, AvailableOutputStates, StateId> : never : never>;
|
|
@@ -3074,7 +3258,7 @@ export declare namespace Machine {
|
|
|
3074
3258
|
* @since 0.4.0
|
|
3075
3259
|
*/
|
|
3076
3260
|
interface Handler<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Input extends Schema.Top, UnhandledStates extends StateIdentifier<States>, E, R, InitialE, InitialR, FinalStates extends StateIdentifier<States>, Output, OutputStates extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema>> {
|
|
3077
|
-
<const Config extends HandlerTree<States, States, Events, Emits, E, R, "">>(config: Config & HandlerTreeValidation<States, Events, Emits, NoInfer<Config>, OutputStates | Extract<HandlerTreeEvidence<States, NoInfer<Config>>["outputState"], StateIdentifier<States>>>): HandleTreeResult<States, Events, Emits, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, OutputStates, InputEvents, Config>;
|
|
3261
|
+
<const Config extends HandlerTree<States, States, Events, Emits, E, R, "">>(config: Config & HandlerInvokeContexts<States, Events, Emits, NoInfer<Config>> & HandlerTreeValidation<States, Events, Emits, NoInfer<Config>, OutputStates | Extract<HandlerTreeEvidence<States, NoInfer<Config>>["outputState"], StateIdentifier<States>>>): HandleTreeResult<States, Events, Emits, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, OutputStates, InputEvents, Config>;
|
|
3078
3262
|
}
|
|
3079
3263
|
/**
|
|
3080
3264
|
* Any state config.
|
|
@@ -3203,8 +3387,8 @@ interface Make {
|
|
|
3203
3387
|
* to implement state behavior with ordinary TypeScript control flow.
|
|
3204
3388
|
*
|
|
3205
3389
|
* Schemas in `events` define the public input protocol. Schemas in
|
|
3206
|
-
* `internalEvents` are added to the complete handler protocol for
|
|
3207
|
-
*
|
|
3390
|
+
* `internalEvents` are added to the complete handler protocol for raised
|
|
3391
|
+
* events, child emissions, and other machine-local deliveries. Their tags
|
|
3208
3392
|
* must be disjoint.
|
|
3209
3393
|
*
|
|
3210
3394
|
* **Example** (Typed counter machine)
|
|
@@ -3256,6 +3440,9 @@ type EventConstructorArgs<EventSchema extends Machine.TaggedSchema> = {} extends
|
|
|
3256
3440
|
* Events supplied through ordinary `send` and `plan` calls remain untrusted
|
|
3257
3441
|
* and continue through full runtime schema validation.
|
|
3258
3442
|
* Treat the returned event as immutable after construction.
|
|
3443
|
+
* This eager low-level constructor throws `MachineSchemaDecodeError` when
|
|
3444
|
+
* construction fails. Prefer {@link events} and {@link internalEvents} for
|
|
3445
|
+
* ordinary delivery so construction remains inside the machine error channel.
|
|
3259
3446
|
*
|
|
3260
3447
|
* The schema must be one of the machine's configured public or internal event
|
|
3261
3448
|
* schemas, or a case schema belonging to a configured `Schema.TaggedUnion`.
|
|
@@ -3285,6 +3472,37 @@ type EventConstructorArgs<EventSchema extends Machine.TaggedSchema> = {} extends
|
|
|
3285
3472
|
* @since 0.4.0
|
|
3286
3473
|
*/
|
|
3287
3474
|
export declare const event: <const M extends Machine.Any, const EventSchema extends Machine.TaggedSchema>(machine: M, schema: EventSchema & ([EventSchema["Type"]] extends [Machine.Event<M>] ? unknown : never), ...args: EventConstructorArgs<EventSchema>) => EventSchema["Type"];
|
|
3475
|
+
/**
|
|
3476
|
+
* Returns deferred constructors for every public event in a machine protocol.
|
|
3477
|
+
*
|
|
3478
|
+
* Constructor inputs retain their schema-derived required fields, defaults,
|
|
3479
|
+
* and transformations. Construction is deferred until delivery so failures
|
|
3480
|
+
* enter the machine's `MachineSchemaDecodeError` channel rather than throwing
|
|
3481
|
+
* at the call site.
|
|
3482
|
+
*
|
|
3483
|
+
* **Example**
|
|
3484
|
+
*
|
|
3485
|
+
* ```ts
|
|
3486
|
+
* const Event = Machine.events(counter)
|
|
3487
|
+
* yield* ref.send(Event.Increment({ by: 1 }))
|
|
3488
|
+
* ```
|
|
3489
|
+
*
|
|
3490
|
+
* @category constructors
|
|
3491
|
+
* @since 0.9.0
|
|
3492
|
+
*/
|
|
3493
|
+
export declare const events: <const M extends Machine.Any>(machine: M) => Machine.EventConstructors<Machine.InputEvents<M>>;
|
|
3494
|
+
/**
|
|
3495
|
+
* Returns deferred constructors for every internal event in a machine
|
|
3496
|
+
* protocol.
|
|
3497
|
+
*
|
|
3498
|
+
* Use these constructors for raised events and other machine-local deliveries.
|
|
3499
|
+
* Construction failures are reported through the
|
|
3500
|
+
* owning machine's `MachineSchemaDecodeError` channel.
|
|
3501
|
+
*
|
|
3502
|
+
* @category constructors
|
|
3503
|
+
* @since 0.9.0
|
|
3504
|
+
*/
|
|
3505
|
+
export declare const internalEvents: <const M extends Machine.Any>(machine: M) => Machine.EventConstructors<Machine.InternalEvents<M>>;
|
|
3288
3506
|
/**
|
|
3289
3507
|
* Encodes a decoded machine snapshot into a normalized data representation.
|
|
3290
3508
|
*
|
|
@@ -3378,131 +3596,81 @@ export declare const encodeSnapshot: <const States extends Machine.StateSchemas,
|
|
|
3378
3596
|
* @since 0.4.0
|
|
3379
3597
|
*/
|
|
3380
3598
|
export declare const decodeSnapshot: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents>, encoded: unknown) => Effect.Effect<Machine.Snapshot<States>, MachineSchemaDecodeError, Machine.SnapshotDecodingServices<States>>;
|
|
3381
|
-
|
|
3382
|
-
* Creates an invoked child process configuration for an active state.
|
|
3383
|
-
*
|
|
3384
|
-
* **When to use**
|
|
3385
|
-
*
|
|
3386
|
-
* Use to run a child process while a machine remains in a state. Successful
|
|
3387
|
-
* outputs are sent directly to the parent machine as events; `void` sends
|
|
3388
|
-
* nothing. Unrecovered child failures fail the owning machine. Active
|
|
3389
|
-
* snapshots can optionally be mapped to progress events.
|
|
3390
|
-
*
|
|
3391
|
-
* **Gotchas**
|
|
3392
|
-
*
|
|
3393
|
-
* Invoked child processes run while their owning state is active and are
|
|
3394
|
-
* stopped before the state exits. An unrecovered child failure fails the owning
|
|
3395
|
-
* machine; recover inside the child Effect when failure should become an event.
|
|
3396
|
-
* The `id` is a state-local lifecycle key, not a communication address. To
|
|
3397
|
-
* send events to the invocation, pass a typed `childAddress` as `address`.
|
|
3398
|
-
* The `src` callback is intentionally independent from its parent state. When
|
|
3399
|
-
* construction depends on the typed state, lifecycle event, or runtime, use
|
|
3400
|
-
* the state config factory form `invoke: (context) => Machine.invoke(...)` and
|
|
3401
|
-
* close over that context from `src`.
|
|
3402
|
-
*
|
|
3403
|
-
* **Example** (Effect output as a parent event)
|
|
3404
|
-
*
|
|
3405
|
-
* ```ts
|
|
3406
|
-
* import { Effect, Schema } from "effect"
|
|
3407
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
3408
|
-
*
|
|
3409
|
-
* class Loaded extends Schema.TaggedClass<Loaded>("Loaded")("Loaded", {
|
|
3410
|
-
* value: Schema.String
|
|
3411
|
-
* }) {}
|
|
3412
|
-
*
|
|
3413
|
-
* const load = Machine.invoke({
|
|
3414
|
-
* id: "load",
|
|
3415
|
-
* src: () => Machine.effect(Effect.succeed(new Loaded({ value: "ready" })))
|
|
3416
|
-
* })
|
|
3417
|
-
* ```
|
|
3418
|
-
*
|
|
3419
|
-
* @see {@link effect} for one-shot child effects.
|
|
3420
|
-
* @see {@link spawn} for children whose lifetime is controlled by actions.
|
|
3421
|
-
* @category constructors
|
|
3422
|
-
* @since 0.4.0
|
|
3423
|
-
*/
|
|
3424
|
-
export declare const invoke: <ChildState, ChildEvent, ChildError = never, ChildRequirements = never, ChildOutput = never, ChildInitialError = never, Event = never, Address extends ChildAddress<never> | undefined = undefined>(config: {
|
|
3599
|
+
type DynamicEffectInvokeSource<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId>) => Effect.Effect<unknown, unknown, unknown>> = {
|
|
3425
3600
|
readonly id: InvokeLifecycleId;
|
|
3426
|
-
readonly
|
|
3427
|
-
readonly
|
|
3428
|
-
|
|
3601
|
+
readonly effect: Source;
|
|
3602
|
+
readonly after?: never;
|
|
3603
|
+
readonly logic?: never;
|
|
3604
|
+
readonly child?: never;
|
|
3429
3605
|
readonly address?: never;
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
type
|
|
3434
|
-
type
|
|
3435
|
-
type
|
|
3436
|
-
readonly id: InvokeLifecycleId;
|
|
3437
|
-
readonly effect: Fx;
|
|
3438
|
-
readonly onSuccess: (value: NoInfer<Effect.Success<Fx>>) => SuccessEvent | void;
|
|
3439
|
-
} & (InvokeEffectIsInfallible<Fx> extends true ? {
|
|
3440
|
-
readonly onFailure?: never;
|
|
3441
|
-
} : {
|
|
3442
|
-
readonly onFailure: (error: NoInfer<Effect.Error<Fx>>) => FailureEvent | void;
|
|
3443
|
-
});
|
|
3606
|
+
readonly onSnapshot?: never;
|
|
3607
|
+
};
|
|
3608
|
+
type DynamicEffectDoneHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeTransition<States, Events, Emits, Machine.InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<ReturnType<NoInfer<Source>>>>>;
|
|
3609
|
+
type DynamicEffectFailureHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeTransition<States, Events, Emits, Machine.InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<ReturnType<NoInfer<Source>>>>>;
|
|
3610
|
+
type DynamicEffectInvokeResult<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeConfig<States, Events, Emits, StateId> & Machine.InvokeTyped<Effect.Success<ReturnType<Source>>, Effect.Error<ReturnType<Source>>, Effect.Services<ReturnType<Source>>, never>;
|
|
3611
|
+
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false;
|
|
3444
3612
|
/**
|
|
3445
|
-
*
|
|
3446
|
-
*
|
|
3447
|
-
* **Details**
|
|
3613
|
+
* Preserves inference for a state-owned invocation configuration.
|
|
3448
3614
|
*
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3451
|
-
*
|
|
3452
|
-
*
|
|
3615
|
+
* Use `effect` for one-shot work, `after` for a cancellable timer, `logic` for
|
|
3616
|
+
* reusable process logic, or `child` for a complete child machine. `onDone` is
|
|
3617
|
+
* required whenever the source can complete with an output, while `onFailure`
|
|
3618
|
+
* is required only when the source has a typed failure channel.
|
|
3453
3619
|
*
|
|
3454
|
-
*
|
|
3455
|
-
*
|
|
3456
|
-
*
|
|
3457
|
-
*
|
|
3620
|
+
* This constructor is an identity at runtime, but preserves lifecycle callback
|
|
3621
|
+
* inference through published declarations. Effects and durations may be
|
|
3622
|
+
* supplied directly or derived from the owning state's entry context. Dynamic
|
|
3623
|
+
* Effect sources infer the owner context, output, error, and service channels
|
|
3624
|
+
* together without a return annotation. Logic invocations require both a
|
|
3625
|
+
* lifecycle `id` and a typed communication `address`. Child descriptors already
|
|
3626
|
+
* own their identity, so `id` and `address` must not be repeated.
|
|
3458
3627
|
*
|
|
3459
3628
|
* ```ts
|
|
3460
|
-
*
|
|
3461
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
3462
|
-
*
|
|
3463
|
-
* class Loaded extends Schema.TaggedClass<Loaded>("Loaded")("Loaded", {
|
|
3464
|
-
* value: Schema.String
|
|
3465
|
-
* }) {}
|
|
3466
|
-
*
|
|
3467
|
-
* const load = Machine.invokeEffect({
|
|
3629
|
+
* invoke: Machine.invoke({
|
|
3468
3630
|
* id: "load",
|
|
3469
|
-
* effect: Effect.
|
|
3470
|
-
*
|
|
3631
|
+
* effect: Effect.tryPromise({
|
|
3632
|
+
* try: () => fetch("/api/data").then((response) => response.json()),
|
|
3633
|
+
* catch: (cause) => new LoadError({ cause })
|
|
3634
|
+
* }),
|
|
3635
|
+
* onDone: ({ output, target }) => target.full.Ready({ data: output }),
|
|
3636
|
+
* onFailure: ({ error, target }) => target.full.Failed({ error })
|
|
3471
3637
|
* })
|
|
3472
3638
|
* ```
|
|
3473
3639
|
*
|
|
3474
|
-
* @see {@link invoke} for arbitrary child process logic.
|
|
3475
|
-
* @see {@link after} for a state-scoped delayed event.
|
|
3476
3640
|
* @category constructors
|
|
3477
|
-
* @since 0.
|
|
3641
|
+
* @since 0.9.0
|
|
3478
3642
|
*/
|
|
3479
|
-
export declare const
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
}
|
|
3504
|
-
|
|
3505
|
-
|
|
3643
|
+
export declare const invoke: {
|
|
3644
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId>) => Effect.Effect<unknown, unknown, unknown>>(config: DynamicEffectInvokeSource<States, Events, Emits, StateId, Source> & {
|
|
3645
|
+
readonly onDone: DynamicEffectDoneHandler<States, Events, Emits, StateId, Source>;
|
|
3646
|
+
readonly onFailure: DynamicEffectFailureHandler<States, Events, Emits, StateId, Source>;
|
|
3647
|
+
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
3648
|
+
"onDone must be omitted when the Effect output is never"
|
|
3649
|
+
] : InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
3650
|
+
"onFailure must be omitted when the Effect error is never"
|
|
3651
|
+
] : []): DynamicEffectInvokeResult<States, Events, Emits, StateId, Source>;
|
|
3652
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId>) => Effect.Effect<unknown, never, unknown>>(config: DynamicEffectInvokeSource<States, Events, Emits, StateId, Source> & {
|
|
3653
|
+
readonly onDone: DynamicEffectDoneHandler<States, Events, Emits, StateId, Source>;
|
|
3654
|
+
readonly onFailure?: never;
|
|
3655
|
+
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
3656
|
+
"onDone must be omitted when the Effect output is never"
|
|
3657
|
+
] : []): DynamicEffectInvokeResult<States, Events, Emits, StateId, Source>;
|
|
3658
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId>) => Effect.Effect<never, unknown, unknown>>(config: DynamicEffectInvokeSource<States, Events, Emits, StateId, Source> & {
|
|
3659
|
+
readonly onDone?: never;
|
|
3660
|
+
readonly onFailure: DynamicEffectFailureHandler<States, Events, Emits, StateId, Source>;
|
|
3661
|
+
}, ..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
3662
|
+
"onFailure must be omitted when the Effect error is never"
|
|
3663
|
+
] : []): DynamicEffectInvokeResult<States, Events, Emits, StateId, Source>;
|
|
3664
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId>) => Effect.Effect<never, never, unknown>>(config: DynamicEffectInvokeSource<States, Events, Emits, StateId, Source> & {
|
|
3665
|
+
readonly onDone?: never;
|
|
3666
|
+
readonly onFailure?: never;
|
|
3667
|
+
}): DynamicEffectInvokeResult<States, Events, Emits, StateId, Source>;
|
|
3668
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Fx extends Effect.Effect<any, any, any>, const Config extends object>(config: Config & Machine.EffectInvokeArgs<States, Events, Emits, StateId, Fx>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<Effect.Success<Fx>, Effect.Error<Fx>, Effect.Services<Fx>, never>;
|
|
3669
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Config extends object>(config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>;
|
|
3670
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address extends ChildAddress<never>>(config: Machine.LogicInvokeArgs<States, Events, Emits, StateId, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address, (context: Machine.InvokeContext<States, Events, Emits, StateId>) => Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>>): Machine.InvokeConfig<States, Events, Emits, StateId> & Machine.InvokeTyped<ChildOutput, ChildError, ChildRequirements, ChildInitialError>;
|
|
3671
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address extends ChildAddress<never>, const Config extends object>(config: Config & Machine.LogicInvokeArgs<States, Events, Emits, StateId, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<ChildOutput, ChildError, ChildRequirements, ChildInitialError>;
|
|
3672
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Child extends ChildMachine.Any, const Config extends object>(config: Config & Machine.ChildInvokeArgs<States, Events, Emits, StateId, Child["machine"], Child>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<Machine.Output<Child["machine"]>, Machine.Error<Child["machine"]> | ActionError<Machine.Services<Child["machine"]>>, Machine.Services<Child["machine"]>, Machine.InitialError<Child["machine"]>, Machine.Emit<Child["machine"]>>;
|
|
3673
|
+
};
|
|
3506
3674
|
type RetagFields<Target extends Machine.TaggedSchema> = Omit<Target["~type.make.in"], "_tag">;
|
|
3507
3675
|
type RetagTargetCompatibility<Target extends Machine.TaggedSchema> = Target extends {
|
|
3508
3676
|
readonly fields: Schema.Struct.Fields;
|
|
@@ -3537,48 +3705,6 @@ type RetagArgs<Target extends Machine.TaggedSchema, Source> = [
|
|
|
3537
3705
|
export declare const retag: <const Target extends Machine.TaggedSchema, const Source extends {
|
|
3538
3706
|
readonly _tag: PropertyKey;
|
|
3539
3707
|
}>(target: Target & RetagTargetCompatibility<Target>, source: Source, ...args: RetagArgs<Target, Source>) => Target["Type"];
|
|
3540
|
-
type InvokeMachineInput<Input extends Schema.Top> = Input extends typeof Schema.Void ? {
|
|
3541
|
-
readonly input?: never;
|
|
3542
|
-
} : {
|
|
3543
|
-
readonly input: Input["Type"];
|
|
3544
|
-
};
|
|
3545
|
-
/**
|
|
3546
|
-
* Creates an invoked child process from a complete statechart machine.
|
|
3547
|
-
*
|
|
3548
|
-
* **When to use**
|
|
3549
|
-
*
|
|
3550
|
-
* Use when a state should own another statechart machine and communicate with
|
|
3551
|
-
* it through typed child events, emissions, snapshots, or terminal output.
|
|
3552
|
-
*
|
|
3553
|
-
* **Details**
|
|
3554
|
-
*
|
|
3555
|
-
* Child emissions are delivered directly to the parent as events. Active
|
|
3556
|
-
* snapshots and terminal output can be mapped to parent events. The owning
|
|
3557
|
-
* state controls the child lifetime.
|
|
3558
|
-
*
|
|
3559
|
-
* **Gotchas**
|
|
3560
|
-
*
|
|
3561
|
-
* Active invoked machines must have unique child addresses. A machine starts
|
|
3562
|
-
* after its owning state's entry actions, so those actions cannot send events
|
|
3563
|
-
* to a newly entered child. Unrecovered child failures fail the parent.
|
|
3564
|
-
*
|
|
3565
|
-
* @see {@link invoke} for invoking lower-level process logic.
|
|
3566
|
-
* @see {@link sendTo} for sending events to the invoked machine.
|
|
3567
|
-
* @category constructors
|
|
3568
|
-
* @since 0.4.0
|
|
3569
|
-
*/
|
|
3570
|
-
export declare const invokeMachine: {
|
|
3571
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, SnapshotEvent = never, DoneEvent = never, Id extends string = string, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(config: {
|
|
3572
|
-
readonly child: ChildMachine<Id, Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>>;
|
|
3573
|
-
readonly snapshot?: (context: Machine.InvokeSnapshotContext<Machine.Snapshot<States>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output>) => SnapshotEvent | undefined;
|
|
3574
|
-
readonly onDone: (context: Machine.InvokeDoneContext<Output>) => DoneEvent | undefined;
|
|
3575
|
-
} & InvokeMachineInput<Input>): Machine.InvokeConfig<any, any, any, any, SnapshotEvent, Machine.Snapshot<States>, Machine.EventOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, ExcludeCompatibleRuntime<Exclude<ExecutionServices<InitialR | R>, internalRuntime.MachineRuntime>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>, Output, InitialE | E | ActionError<InitialR | R> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError, Machine.EmitOf<Emits>, DoneEvent>;
|
|
3576
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, SnapshotEvent = never, Id extends string = string, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(config: {
|
|
3577
|
-
readonly child: ChildMachine<Id, Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>>;
|
|
3578
|
-
readonly snapshot?: (context: Machine.InvokeSnapshotContext<Machine.Snapshot<States>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output>) => SnapshotEvent | undefined;
|
|
3579
|
-
readonly onDone?: never;
|
|
3580
|
-
} & InvokeMachineInput<Input>): Machine.InvokeConfig<any, any, any, any, SnapshotEvent, Machine.Snapshot<States>, Machine.EventOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, ExcludeCompatibleRuntime<Exclude<ExecutionServices<InitialR | R>, internalRuntime.MachineRuntime>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>, Output, InitialE | E | ActionError<InitialR | R> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError, Machine.EmitOf<Emits>>;
|
|
3581
|
-
};
|
|
3582
3708
|
/**
|
|
3583
3709
|
* Plans the initial state for a machine without executing actor commands.
|
|
3584
3710
|
*
|
|
@@ -3678,10 +3804,9 @@ export declare const transitionDefinitions: <M extends Machine.Any>(machine: M)
|
|
|
3678
3804
|
*
|
|
3679
3805
|
* **Details**
|
|
3680
3806
|
*
|
|
3681
|
-
* Static
|
|
3682
|
-
*
|
|
3683
|
-
*
|
|
3684
|
-
* never evaluated during inspection.
|
|
3807
|
+
* Static inline invocation definitions expose stable ownership and lifecycle
|
|
3808
|
+
* metadata without serializing runtime values. Function-valued sources are
|
|
3809
|
+
* represented as dynamic and are never evaluated during inspection.
|
|
3685
3810
|
*
|
|
3686
3811
|
* @category getters
|
|
3687
3812
|
* @since 0.4.0
|
|
@@ -3751,7 +3876,7 @@ export declare const enabled: <const States extends Machine.StateSchemas, const
|
|
|
3751
3876
|
* @category combinators
|
|
3752
3877
|
* @since 0.4.0
|
|
3753
3878
|
*/
|
|
3754
|
-
export declare const plan: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, state: Machine.Snapshot<States>, event: Machine.
|
|
3879
|
+
export declare const plan: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, state: Machine.Snapshot<States>, event: Machine.EventInputOf<InputEvents>) => Effect.Effect<{
|
|
3755
3880
|
readonly next: Machine.Snapshot<States>;
|
|
3756
3881
|
readonly commands: ReadonlyArray<Command>;
|
|
3757
3882
|
readonly emittedEvents: ReadonlyArray<Machine.EmitOf<Emits>>;
|
|
@@ -3773,49 +3898,6 @@ export declare const plan: <const States extends Machine.StateSchemas, const Eve
|
|
|
3773
3898
|
readonly done: false;
|
|
3774
3899
|
readonly output: undefined;
|
|
3775
3900
|
}), E | InfiniteTransitionError | MachineSchemaDecodeError, never>;
|
|
3776
|
-
/**
|
|
3777
|
-
* Creates a one-shot child process from an Effect.
|
|
3778
|
-
*
|
|
3779
|
-
* **When to use**
|
|
3780
|
-
*
|
|
3781
|
-
* Use when you need side effects that produce one typed output or error.
|
|
3782
|
-
*
|
|
3783
|
-
* **Details**
|
|
3784
|
-
*
|
|
3785
|
-
* The Effect may run arbitrary side effects. Its success value is the process
|
|
3786
|
-
* output, its typed error is preserved, and its services are inferred. When
|
|
3787
|
-
* invoked, the output is sent to the owning machine as an event unless it is
|
|
3788
|
-
* `void`.
|
|
3789
|
-
*
|
|
3790
|
-
* **Gotchas**
|
|
3791
|
-
*
|
|
3792
|
-
* This process has no incoming event protocol. Its Effect runs once. Use
|
|
3793
|
-
* `transition` for a process that receives events over time and `logic` for
|
|
3794
|
-
* direct machine-local communication or intermediate snapshots.
|
|
3795
|
-
*
|
|
3796
|
-
* **Example** (Recover a child failure as output)
|
|
3797
|
-
*
|
|
3798
|
-
* ```ts
|
|
3799
|
-
* import { Effect, Schema } from "effect"
|
|
3800
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
3801
|
-
*
|
|
3802
|
-
* class LoadFailed extends Schema.TaggedClass<LoadFailed>("LoadFailed")("LoadFailed", {
|
|
3803
|
-
* reason: Schema.String
|
|
3804
|
-
* }) {}
|
|
3805
|
-
*
|
|
3806
|
-
* const load = Machine.effect(
|
|
3807
|
-
* Effect.fail("unavailable").pipe(
|
|
3808
|
-
* Effect.catch((reason) => Effect.succeed(new LoadFailed({ reason })))
|
|
3809
|
-
* )
|
|
3810
|
-
* )
|
|
3811
|
-
* ```
|
|
3812
|
-
*
|
|
3813
|
-
* @see {@link transition} for event-driven state.
|
|
3814
|
-
* @see {@link logic} for direct control over intermediate snapshots.
|
|
3815
|
-
* @category constructors
|
|
3816
|
-
* @since 0.4.0
|
|
3817
|
-
*/
|
|
3818
|
-
export declare const effect: <Output, Error = never, Requirements = never>(effect: Effect.Effect<Output, Error, Requirements>) => Logic<void, never, Error, Requirements, Output>;
|
|
3819
3901
|
/**
|
|
3820
3902
|
* Creates advanced stateful process logic from explicit initialization and
|
|
3821
3903
|
* execution methods.
|
|
@@ -3837,9 +3919,9 @@ export declare const effect: <Output, Error = never, Requirements = never>(effec
|
|
|
3837
3919
|
* This is the low-level process constructor. Parent messages sent directly
|
|
3838
3920
|
* through its scope are intentionally `unknown` because the logic does not know
|
|
3839
3921
|
* which machine will eventually own it. Prefer typed output, typed child
|
|
3840
|
-
* addresses, or
|
|
3922
|
+
* addresses, or invocation lifecycle transitions when possible.
|
|
3841
3923
|
*
|
|
3842
|
-
*
|
|
3924
|
+
* Use an inline `invoke` with an `effect` source for one-shot work.
|
|
3843
3925
|
* @see {@link transition} for event-driven state.
|
|
3844
3926
|
* @category constructors
|
|
3845
3927
|
* @since 0.4.0
|
|
@@ -3873,7 +3955,7 @@ export declare const logic: <State, Event = never, Output = void, Error = never,
|
|
|
3873
3955
|
* )
|
|
3874
3956
|
* ```
|
|
3875
3957
|
*
|
|
3876
|
-
*
|
|
3958
|
+
* Use an inline `invoke` with an `effect` source for one-shot work.
|
|
3877
3959
|
* @see {@link logic} for direct process lifecycle control.
|
|
3878
3960
|
* @category constructors
|
|
3879
3961
|
* @since 0.4.0
|
|
@@ -3996,7 +4078,7 @@ export declare const watch: <State, Event, Error = never, Output = never>(ref: M
|
|
|
3996
4078
|
* @category constructors
|
|
3997
4079
|
* @since 0.4.0
|
|
3998
4080
|
*/
|
|
3999
|
-
export declare const start: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.
|
|
4081
|
+
export declare const start: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.EventInputOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output>, InitialE | E | ActionError<InitialR | R> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError, ExcludeCompatibleRuntime<ExecutionServices<InitialR | R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>;
|
|
4000
4082
|
/**
|
|
4001
4083
|
* Starts a fresh managed runtime from a decoded logical snapshot.
|
|
4002
4084
|
*
|
|
@@ -4007,8 +4089,8 @@ export declare const start: <const States extends Machine.StateSchemas, const Ev
|
|
|
4007
4089
|
* entry or transition actions, re-deliver raised or emitted events, or
|
|
4008
4090
|
* re-evaluate historical completion and eventless transitions. Active-state
|
|
4009
4091
|
* invokes start once in ancestor and document order with {@link InitialEvent};
|
|
4010
|
-
*
|
|
4011
|
-
* from their own initial state.
|
|
4092
|
+
* timer invocations restart their complete duration and child-machine
|
|
4093
|
+
* invocations start from their own initial state.
|
|
4012
4094
|
*
|
|
4013
4095
|
* Only logical state, completion, and history metadata are resumed. Queues,
|
|
4014
4096
|
* scopes, subscriptions, fibers, spawned children, invoke progress, and prior
|
|
@@ -4048,5 +4130,5 @@ export declare const start: <const States extends Machine.StateSchemas, const Ev
|
|
|
4048
4130
|
* @category constructors
|
|
4049
4131
|
* @since 0.4.0
|
|
4050
4132
|
*/
|
|
4051
|
-
export declare const resume: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, snapshot: Machine.Snapshot<States>) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.
|
|
4133
|
+
export declare const resume: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, snapshot: Machine.Snapshot<States>) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.EventInputOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output>, MachineSchemaDecodeError, ExcludeCompatibleRuntime<ExecutionServices<R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>;
|
|
4052
4134
|
//# sourceMappingURL=Machine.d.ts.map
|