@typeonce/effect-machine 0.15.0 → 0.17.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 +115 -95
- package/dist/Machine.d.ts +464 -337
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +72 -107
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/activities.d.ts +2 -0
- package/dist/internal/machine/activities.d.ts.map +1 -1
- package/dist/internal/machine/activities.js +4 -0
- package/dist/internal/machine/activities.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +7 -7
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/cluster.d.ts +2 -2
- package/dist/internal/machine/cluster.d.ts.map +1 -1
- package/dist/internal/machine/cluster.js +6 -5
- package/dist/internal/machine/cluster.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +16 -4
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts +1 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +25 -3
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/invocationEvent.d.ts +8 -0
- package/dist/internal/machine/invocationEvent.d.ts.map +1 -1
- package/dist/internal/machine/invocationEvent.js +8 -0
- package/dist/internal/machine/invocationEvent.js.map +1 -1
- package/dist/internal/machine/machine.d.ts +8 -6
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +308 -71
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +26 -4
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +76 -31
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +1 -0
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +25 -16
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/stateDefinition.d.ts.map +1 -1
- package/dist/internal/machine/stateDefinition.js +14 -0
- package/dist/internal/machine/stateDefinition.js.map +1 -1
- package/dist/internal/machine/topology.d.ts +20 -0
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +33 -6
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/finiteModel.js +15 -20
- package/dist/internal/testing/machine/finiteModel.js.map +1 -1
- package/dist/internal/testing/machine/transitionCoverage.d.ts.map +1 -1
- package/dist/internal/testing/machine/transitionCoverage.js +8 -2
- package/dist/internal/testing/machine/transitionCoverage.js.map +1 -1
- package/dist/internal/testing/machine/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js +6 -0
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +13 -12
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js +5 -8
- package/dist/testing/MachineTest.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +2 -2
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +12 -12
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +182 -159
- package/package.json +1 -1
- package/src/Machine.ts +1073 -700
- package/src/internal/machine/activities.ts +7 -0
- package/src/internal/machine/atom.ts +20 -15
- package/src/internal/machine/cluster.ts +14 -9
- package/src/internal/machine/executionPlan.ts +14 -4
- package/src/internal/machine/invocation.ts +39 -4
- package/src/internal/machine/invocationEvent.ts +16 -0
- package/src/internal/machine/machine.ts +460 -86
- package/src/internal/machine/planner.ts +106 -30
- package/src/internal/machine/runtime.ts +61 -25
- package/src/internal/machine/stateDefinition.ts +39 -0
- package/src/internal/machine/topology.ts +59 -2
- package/src/internal/testing/machine/finiteModel.ts +18 -21
- package/src/internal/testing/machine/transitionCoverage.ts +8 -2
- package/src/internal/testing/machine/verification.ts +11 -0
- package/src/testing/MachineTest.ts +16 -11
- package/src/unstable/cluster/ClusterMachine.ts +8 -4
- package/src/unstable/reactivity/AtomMachine.ts +19 -12
package/dist/Machine.d.ts
CHANGED
|
@@ -41,7 +41,8 @@ declare const MachineTypeId: unique symbol;
|
|
|
41
41
|
declare const EventConstructionTypeId: unique symbol;
|
|
42
42
|
declare const EmittedEventConstructionTypeId: unique symbol;
|
|
43
43
|
declare const EventProtocolTypeId: unique symbol;
|
|
44
|
-
declare const
|
|
44
|
+
declare const ParentModeTypeId: unique symbol;
|
|
45
|
+
declare const ParentTypeId = "~effect/Machine/Parent";
|
|
45
46
|
declare const ChildMachineLogicTypeId: typeof internal.ChildMachineLogicTypeId;
|
|
46
47
|
/**
|
|
47
48
|
* Type identifier used for the synthetic event passed to startup lifecycle
|
|
@@ -128,16 +129,16 @@ export interface Machine<States extends Machine.StateSchemas, Events extends Rea
|
|
|
128
129
|
*/
|
|
129
130
|
readonly emittedEvents: Machine.EventProtocol<"emitted", Emits>;
|
|
130
131
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
132
|
+
* Declared owning-machine protocol, or `undefined` when this machine does
|
|
133
|
+
* not communicate with its owner.
|
|
133
134
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
135
|
+
* Required parents make the machine child-only and expose a non-optional
|
|
136
|
+
* `parent` target to handlers. Optional parents keep root execution valid
|
|
137
|
+
* and expose `parent` as possibly absent.
|
|
137
138
|
*
|
|
138
|
-
* @since 0.
|
|
139
|
+
* @since 0.17.0
|
|
139
140
|
*/
|
|
140
|
-
readonly
|
|
141
|
+
readonly parent: Machine.ParentDeclarationOf<ParentEvents>;
|
|
141
142
|
/**
|
|
142
143
|
* Optional schema used to decode the machine input before initialization.
|
|
143
144
|
*
|
|
@@ -156,14 +157,6 @@ export interface Machine<States extends Machine.StateSchemas, Events extends Rea
|
|
|
156
157
|
readonly makeTargetBuilder: <Source extends Machine.StateNodeIdentifier<States>>(source: Source) => Machine.TargetBuilder<States, Source>;
|
|
157
158
|
/** @internal */
|
|
158
159
|
readonly handlers: Machine.StateConfigs<States, Events, Emits, UnhandledStates, Machine.TagOf<Events[number]>, E, R>;
|
|
159
|
-
/**
|
|
160
|
-
* Machine-bound equivalent of {@link invoke}. Both forms preserve this
|
|
161
|
-
* machine's public input and parent protocols in invocation callbacks;
|
|
162
|
-
* `Machine.invoke(...)` inside `handle(...)` is the canonical inline form.
|
|
163
|
-
*
|
|
164
|
-
* @since 0.11.0
|
|
165
|
-
*/
|
|
166
|
-
readonly invoke: Invoker<States, Events, Emits, InputEvents, ParentEvents>;
|
|
167
160
|
/** @internal */
|
|
168
161
|
readonly initial: (...args: [...Machine.InputArgs<Input>]) => Machine.InitialResult<States, InitialE, InitialR>;
|
|
169
162
|
/** @internal */
|
|
@@ -344,18 +337,51 @@ export interface MachineTarget<in Event> {
|
|
|
344
337
|
readonly sessionId: string;
|
|
345
338
|
readonly send: (event: Event) => Effect.Effect<void, StoppedError>;
|
|
346
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Availability declared for an owning-machine target.
|
|
342
|
+
*
|
|
343
|
+
* @category models
|
|
344
|
+
* @since 0.17.0
|
|
345
|
+
*/
|
|
346
|
+
export type ParentMode = "required" | "optional";
|
|
347
|
+
/**
|
|
348
|
+
* Owning-machine protocol declared by {@link parent} or
|
|
349
|
+
* {@link optionalParent}.
|
|
350
|
+
*
|
|
351
|
+
* @category models
|
|
352
|
+
* @since 0.17.0
|
|
353
|
+
*/
|
|
354
|
+
export interface Parent<Mode extends ParentMode, Events extends ReadonlyArray<Machine.TaggedSchema>> {
|
|
355
|
+
readonly [ParentTypeId]: typeof ParentTypeId;
|
|
356
|
+
readonly mode: Mode;
|
|
357
|
+
readonly events: Machine.EventProtocol<"public", Events>;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Namespace containing type-level members associated with {@link Parent}.
|
|
361
|
+
*
|
|
362
|
+
* @category models
|
|
363
|
+
* @since 0.17.0
|
|
364
|
+
*/
|
|
365
|
+
export declare namespace Parent {
|
|
366
|
+
/** Any owning-machine protocol declaration. */
|
|
367
|
+
type Any = Parent<ParentMode, ReadonlyArray<Machine.TaggedSchema>>;
|
|
368
|
+
}
|
|
347
369
|
/**
|
|
348
370
|
* Machine targets available while evaluating machine behavior.
|
|
349
371
|
*
|
|
350
372
|
* @category models
|
|
351
373
|
* @since 0.12.0
|
|
352
374
|
*/
|
|
353
|
-
export
|
|
375
|
+
export type MachineReferences<InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>> = {
|
|
354
376
|
/** Target for the current machine. Sending queues a later mailbox event. */
|
|
355
377
|
readonly self: MachineTarget<Machine.EventInputOf<InputEvents>>;
|
|
378
|
+
} & (Machine.ParentModeOf<ParentEvents> extends "required" ? {
|
|
379
|
+
/** Required target for the machine that owns this child. */
|
|
380
|
+
readonly parent: MachineTarget<Machine.EventInputOf<ParentEvents>>;
|
|
381
|
+
} : Machine.ParentModeOf<ParentEvents> extends "optional" ? {
|
|
356
382
|
/** Target for the owning machine, or `undefined` when running as a root. */
|
|
357
383
|
readonly parent: MachineTarget<Machine.EventInputOf<ParentEvents>> | undefined;
|
|
358
|
-
}
|
|
384
|
+
} : {});
|
|
359
385
|
/**
|
|
360
386
|
* Synchronous commands available while a machine transition is being
|
|
361
387
|
* selected. Enqueuing only records statechart and machine operations; it never
|
|
@@ -447,6 +473,8 @@ type ExcludeCompatibleRuntime<Requirements, Events, Emits> = Requirements extend
|
|
|
447
473
|
type IncompatibleRuntime<Requirements, Events, Emits> = Requirements extends Runtime.Requirement<infer RequiredEvents, infer RequiredEmits> ? IsAny<Requirements> extends true ? never : [RequiredEvents] extends [Events] ? [RequiredEmits] extends [Emits] ? never : Requirements : Requirements : never;
|
|
448
474
|
declare const InvokeTypeId: typeof internal.InvokeTypeId;
|
|
449
475
|
declare const TransitionTypeId: typeof internal.TransitionTypeId;
|
|
476
|
+
declare const TransitionBuilderTypeId: unique symbol;
|
|
477
|
+
declare const InitialBuilderTypeId: unique symbol;
|
|
450
478
|
type StateDefinitionError<Message extends string, Path extends PropertyKey = never, Details extends PropertyKey = never> = {
|
|
451
479
|
readonly "~effect/Machine/DefinitionError": Message;
|
|
452
480
|
readonly path: Path;
|
|
@@ -487,16 +515,21 @@ type ValidateStateNodeConfig<Node extends Machine.StateNodeConfig, Path extends
|
|
|
487
515
|
type ValidateOutputSchema<Node> = "output" extends keyof Node ? Node extends {
|
|
488
516
|
readonly output: Schema.Top;
|
|
489
517
|
} ? unknown : StateDefinitionError<"State output must be a schema"> : unknown;
|
|
518
|
+
type SelectorChildKey<Children extends Machine.StateSchemas> = ActiveStateKey<Children> | ChoiceStateKey<Children>;
|
|
519
|
+
type ValidateInitialSelectorChild<Children extends Machine.StateSchemas, Path extends PropertyKey> = "initial" extends SelectorChildKey<Children> ? StateDefinitionError<"Active and choice child states cannot use the reserved target selector key \"initial\"", StateDefinitionPath<Extract<Path, string>, "initial">, "initial"> : unknown;
|
|
520
|
+
type ValidateWithSelectorChild<Node extends Machine.StateNodeConfig, Children extends Machine.StateSchemas, Path extends PropertyKey> = Node extends {
|
|
521
|
+
readonly schema: Machine.TaggedSchema;
|
|
522
|
+
} ? "with" extends SelectorChildKey<Children> ? StateDefinitionError<"Schema-backed compound child states cannot use the reserved local target selector key \"with\"", StateDefinitionPath<Extract<Path, string>, "with">, "with"> : unknown : unknown;
|
|
490
523
|
type ValidateStateNodeWithChildren<Node extends Machine.StateNodeConfig, Children, Path extends PropertyKey> = Children extends Machine.StateSchemas ? Node extends {
|
|
491
524
|
readonly type: "final";
|
|
492
525
|
} ? StateDefinitionError<"Final states cannot declare child states"> : Node extends {
|
|
493
526
|
readonly type: "parallel";
|
|
494
|
-
} ? "initial" extends keyof Node ? StateDefinitionError<"Parallel states cannot declare an initial child"> : {
|
|
527
|
+
} ? ValidateInitialSelectorChild<Children, Path> & ("initial" extends keyof Node ? StateDefinitionError<"Parallel states cannot declare an initial child"> : {
|
|
495
528
|
readonly states: ValidateStateTree<Children, true, Extract<Path, string>>;
|
|
496
|
-
} & ValidateOutputSchema<Node> : "output" extends keyof Node ? StateDefinitionError<"Only final and parallel states can declare output"> : ValidateCompoundStateNode<Node, Children, Path> : StateDefinitionError<"Child states must be a state tree">;
|
|
529
|
+
} & ValidateOutputSchema<Node>) : "output" extends keyof Node ? StateDefinitionError<"Only final and parallel states can declare output"> : ValidateCompoundStateNode<Node, Children, Path> : StateDefinitionError<"Child states must be a state tree">;
|
|
497
530
|
type ValidateCompoundStateNode<Node extends Machine.StateNodeConfig, Children extends Machine.StateSchemas, Path extends PropertyKey> = Node extends {
|
|
498
531
|
readonly initial: infer Initial;
|
|
499
|
-
} ? Initial extends ActiveStateKey<Children> | ChoiceStateKey<Children> ? {
|
|
532
|
+
} ? Initial extends ActiveStateKey<Children> | ChoiceStateKey<Children> ? ValidateInitialSelectorChild<Children, Path> & ValidateWithSelectorChild<Node, Children, Path> & {
|
|
500
533
|
readonly states: ValidateStateTree<Children, true, Extract<Path, string>>;
|
|
501
534
|
} : StateDefinitionError<"Compound initial must be one of its direct child keys", Path, Extract<Initial, PropertyKey>> : StateDefinitionError<"Compound states must declare an initial child", Path>;
|
|
502
535
|
type ValidateStateNodeWithoutChildren<Node extends Machine.StateNodeConfig> = "initial" extends keyof Node ? StateDefinitionError<"Atomic states cannot declare an initial child"> : Node extends {
|
|
@@ -1020,9 +1053,9 @@ export declare namespace Inspection {
|
|
|
1020
1053
|
readonly sessionId: string;
|
|
1021
1054
|
readonly owner: Subject;
|
|
1022
1055
|
readonly ownerPath: string;
|
|
1023
|
-
readonly kind: "Effect" | "Timer";
|
|
1056
|
+
readonly kind: "Effect" | "Stream" | "Timer";
|
|
1024
1057
|
}
|
|
1025
|
-
/** Announces an Effect or timer invocation starting. */
|
|
1058
|
+
/** Announces an Effect, Stream, or timer invocation starting. */
|
|
1026
1059
|
interface ActivityStarted extends Base {
|
|
1027
1060
|
readonly _tag: "ActivityStarted";
|
|
1028
1061
|
readonly activity: Activity;
|
|
@@ -1408,6 +1441,20 @@ export declare namespace Machine {
|
|
|
1408
1441
|
readonly inputEvents: InputEvents;
|
|
1409
1442
|
readonly parentEvents: ParentEvents;
|
|
1410
1443
|
}
|
|
1444
|
+
/** @internal Carries parent availability without widening the event tuple. */
|
|
1445
|
+
type ParentEventSchemas<Mode extends ParentMode, Events extends ReadonlyArray<TaggedSchema>> = Events & {
|
|
1446
|
+
readonly [ParentModeTypeId]: Mode;
|
|
1447
|
+
};
|
|
1448
|
+
/** Extracts the parent availability encoded in a machine event tuple. */
|
|
1449
|
+
type ParentModeOf<Events extends ReadonlyArray<TaggedSchema>> = Events extends {
|
|
1450
|
+
readonly [ParentModeTypeId]: infer Mode extends ParentMode;
|
|
1451
|
+
} ? Mode : Events extends readonly [] ? "none" : "optional";
|
|
1452
|
+
/** Extracts the event schemas declared by an owning-machine protocol. */
|
|
1453
|
+
type ParentEventsOf<Declaration extends Parent.Any | undefined> = Declaration extends Parent<infer Mode, infer Events> ? ParentEventSchemas<Mode, Events> : readonly [];
|
|
1454
|
+
/** Extracts the owning-machine declaration carried by a machine. */
|
|
1455
|
+
type ParentDeclarationOf<Events extends ReadonlyArray<TaggedSchema>> = ParentModeOf<Events> extends infer Mode ? Mode extends ParentMode ? Parent<Mode, Events> : undefined : never;
|
|
1456
|
+
/** Constraint applied to APIs that create an independent root runtime. */
|
|
1457
|
+
type RootCompatible<Events extends ReadonlyArray<TaggedSchema>> = ParentModeOf<Events> extends "required" ? never : unknown;
|
|
1411
1458
|
/**
|
|
1412
1459
|
* Any schema-first machine.
|
|
1413
1460
|
*
|
|
@@ -1428,7 +1475,7 @@ export declare namespace Machine {
|
|
|
1428
1475
|
readonly events: EventProtocol.Any<"public">;
|
|
1429
1476
|
readonly internalEvents: EventProtocol.Any<"internal">;
|
|
1430
1477
|
readonly emittedEvents: EventProtocol.Any<"emitted">;
|
|
1431
|
-
readonly
|
|
1478
|
+
readonly parent: Parent.Any | undefined;
|
|
1432
1479
|
readonly input: Schema.Top | undefined;
|
|
1433
1480
|
readonly id: string | undefined;
|
|
1434
1481
|
/** @internal */
|
|
@@ -1438,8 +1485,6 @@ export declare namespace Machine {
|
|
|
1438
1485
|
/** @internal */
|
|
1439
1486
|
readonly handlers: any;
|
|
1440
1487
|
/** @internal */
|
|
1441
|
-
readonly invoke: any;
|
|
1442
|
-
/** @internal */
|
|
1443
1488
|
readonly initial: any;
|
|
1444
1489
|
/** @internal */
|
|
1445
1490
|
readonly initialDefinition: InitialDefinition;
|
|
@@ -1539,6 +1584,8 @@ export declare namespace Machine {
|
|
|
1539
1584
|
type InputEvents<M extends Any> = M[typeof MachineTypeId]["inputEvents"];
|
|
1540
1585
|
/** Extracts the public input protocol required from an owning machine. */
|
|
1541
1586
|
type ParentEvents<M extends Any> = M[typeof MachineTypeId]["parentEvents"];
|
|
1587
|
+
/** Extracts whether a machine requires or optionally accepts an owner. */
|
|
1588
|
+
type ParentAvailability<M extends Any> = ParentModeOf<M[typeof MachineTypeId]["parentEvents"]>;
|
|
1542
1589
|
/** Extracts an internal event schema tuple from the complete and public protocols. */
|
|
1543
1590
|
type InternalEventSchemas<Events extends ReadonlyArray<TaggedSchema>, InputEvents extends ReadonlyArray<TaggedSchema>> = Events extends readonly [
|
|
1544
1591
|
...InputEvents,
|
|
@@ -2014,7 +2061,7 @@ export declare namespace Machine {
|
|
|
2014
2061
|
} | {
|
|
2015
2062
|
readonly type: "invoke";
|
|
2016
2063
|
readonly id: string;
|
|
2017
|
-
readonly outcome: "done" | "failure" | "snapshot";
|
|
2064
|
+
readonly outcome: "element" | "done" | "failure" | "snapshot";
|
|
2018
2065
|
};
|
|
2019
2066
|
/** Static topology selected by a transition branch. */
|
|
2020
2067
|
interface TransitionTargetSelection<Path extends string | undefined = string | undefined, Kind extends Topology.TargetSelectionKind = Topology.TargetSelectionKind, Scope extends Topology.TargetSelectionScope | undefined = Topology.TargetSelectionScope | undefined> {
|
|
@@ -2028,14 +2075,11 @@ export declare namespace Machine {
|
|
|
2028
2075
|
readonly target: Path | undefined;
|
|
2029
2076
|
readonly selection: TransitionTargetSelection<Path | undefined>;
|
|
2030
2077
|
} | {
|
|
2031
|
-
readonly type: "
|
|
2078
|
+
readonly type: "branch";
|
|
2079
|
+
readonly key: string;
|
|
2032
2080
|
readonly title: string;
|
|
2033
2081
|
readonly target: Path | undefined;
|
|
2034
2082
|
readonly selection: TransitionTargetSelection<Path | undefined>;
|
|
2035
|
-
} | {
|
|
2036
|
-
readonly type: "otherwise";
|
|
2037
|
-
readonly target: Path | undefined;
|
|
2038
|
-
readonly selection: TransitionTargetSelection<Path | undefined>;
|
|
2039
2083
|
};
|
|
2040
2084
|
/** The statically selected root entry for machine startup. */
|
|
2041
2085
|
interface InitialDefinition<Path extends string = string> {
|
|
@@ -2047,8 +2091,8 @@ export declare namespace Machine {
|
|
|
2047
2091
|
*
|
|
2048
2092
|
* **Details**
|
|
2049
2093
|
*
|
|
2050
|
-
* Every branch exposes its selected target without executing its
|
|
2051
|
-
*
|
|
2094
|
+
* Every branch exposes its selected target without executing its resolver.
|
|
2095
|
+
* A compound local or branch target covers its descendants;
|
|
2052
2096
|
* `undefined` identifies an explicitly targetless branch.
|
|
2053
2097
|
*
|
|
2054
2098
|
* @category models
|
|
@@ -2058,6 +2102,7 @@ export declare namespace Machine {
|
|
|
2058
2102
|
readonly source: SourcePath;
|
|
2059
2103
|
readonly trigger: TransitionTrigger<EventTag>;
|
|
2060
2104
|
readonly reenter: boolean;
|
|
2105
|
+
readonly acceptance: TransitionAcceptance;
|
|
2061
2106
|
readonly branches: ReadonlyArray<TransitionBranch<TargetPath>>;
|
|
2062
2107
|
}
|
|
2063
2108
|
/**
|
|
@@ -2084,6 +2129,8 @@ export declare namespace Machine {
|
|
|
2084
2129
|
readonly reenter: boolean;
|
|
2085
2130
|
/** Zero-based index of the selected static branch. */
|
|
2086
2131
|
readonly branchIndex: number;
|
|
2132
|
+
/** Stable key of a named branch, or `undefined` for a direct transition. */
|
|
2133
|
+
readonly branchKey: string | undefined;
|
|
2087
2134
|
/** Path returned by the handler, including a choice or history pseudo-state. */
|
|
2088
2135
|
readonly target: TargetPath | undefined;
|
|
2089
2136
|
/**
|
|
@@ -2660,6 +2707,22 @@ export declare namespace Machine {
|
|
|
2660
2707
|
interface NoTarget {
|
|
2661
2708
|
readonly [Topology.NoTargetTypeId]: typeof Topology.NoTargetTypeId;
|
|
2662
2709
|
}
|
|
2710
|
+
/**
|
|
2711
|
+
* Opaque result returned when a declinable transition does not accept the
|
|
2712
|
+
* current event or lifecycle outcome.
|
|
2713
|
+
*
|
|
2714
|
+
* Declining selects no transition and discards operations enqueued by that
|
|
2715
|
+
* resolver. Hierarchical event and eventless dispatch continues with the
|
|
2716
|
+
* next eligible ancestor candidate.
|
|
2717
|
+
*
|
|
2718
|
+
* @category models
|
|
2719
|
+
* @since 0.17.0
|
|
2720
|
+
*/
|
|
2721
|
+
interface Declined {
|
|
2722
|
+
readonly [Topology.DeclinedTypeId]: typeof Topology.DeclinedTypeId;
|
|
2723
|
+
}
|
|
2724
|
+
/** Static acceptance contract of one transition definition. */
|
|
2725
|
+
type TransitionAcceptance = "required" | "declinable";
|
|
2663
2726
|
/**
|
|
2664
2727
|
* Transition instruction that restores a history pseudo-state's parent.
|
|
2665
2728
|
*
|
|
@@ -2823,11 +2886,12 @@ export declare namespace Machine {
|
|
|
2823
2886
|
readonly path: Path;
|
|
2824
2887
|
readonly "~effect/Machine/TargetSelectionResult"?: Types.Covariant<Result>;
|
|
2825
2888
|
}
|
|
2826
|
-
type
|
|
2889
|
+
type SelectionValue<Builder, Path extends string, Kind extends Topology.TargetSelectionKind = "state"> = TargetSelection<Builder, Path, Kind>;
|
|
2890
|
+
type SelectionMethod<Builder, Path extends string, Kind extends Topology.TargetSelectionKind = "state"> = () => SelectionValue<Builder, Path, Kind>;
|
|
2827
2891
|
type InitialSelectionMethod<Builder, Path extends string> = Builder extends {
|
|
2828
2892
|
readonly initial: infer Initial;
|
|
2829
2893
|
} ? {
|
|
2830
|
-
readonly initial:
|
|
2894
|
+
readonly initial: SelectionValue<Initial, Path, "initial">;
|
|
2831
2895
|
} : {};
|
|
2832
2896
|
type SelectionTreeWithPrefix<AllStates extends StateSchemas, States extends StateSchemas, Prefix extends string, Scope extends "local" | "branch", Builder> = {
|
|
2833
2897
|
readonly [Key in Extract<ActiveStateKey<States> | ChoiceStateKey<States>, keyof Builder>]: SelectionNode<AllStates, States[Key], JoinPath<Prefix, Key>, Scope, Builder[Key]>;
|
|
@@ -2845,27 +2909,32 @@ export declare namespace Machine {
|
|
|
2845
2909
|
readonly [Key in Root]: SelectionNode<States, States[Key], Key, "branch", BranchTargetBuilder<States, Source>[Key]>;
|
|
2846
2910
|
} : {} : {};
|
|
2847
2911
|
type LocalTargetSelector<States extends StateSchemas, Source extends StateNodeIdentifier<States>> = NearestCompoundScope<States, Source> extends infer Scope extends StateIdentifier<States> ? ChildrenOf<States, Scope> extends infer Children extends StateSchemas ? LocalTargetBuilder<States, Source> extends infer Builder ? SelectionTreeWithPrefix<States, Children, Scope, "local", Builder> & ("with" extends keyof Builder ? {
|
|
2848
|
-
readonly with:
|
|
2912
|
+
readonly with: SelectionValue<Builder["with"], Scope>;
|
|
2849
2913
|
} : {}) : {} : {} : {};
|
|
2850
2914
|
type HistorySelectionTree<AllStates extends StateSchemas, States extends StateSchemas, Prefix extends string, Builder> = {
|
|
2851
|
-
readonly [Key in Extract<HistoryContainingKey<States>, keyof Builder>]: States[Key] extends HistoryStateNodeConfig ?
|
|
2915
|
+
readonly [Key in Extract<HistoryContainingKey<States>, keyof Builder>]: States[Key] extends HistoryStateNodeConfig ? SelectionValue<Builder[Key], JoinPath<Prefix, Key>, "history"> : States[Key] extends {
|
|
2852
2916
|
readonly states: infer Children extends StateSchemas;
|
|
2853
2917
|
} ? HistorySelectionTree<AllStates, Children, JoinPath<Prefix, Key>, Builder[Key]> : never;
|
|
2854
2918
|
};
|
|
2855
|
-
/**
|
|
2919
|
+
/**
|
|
2920
|
+
* Definition-time topology selector available to an ordinary transition.
|
|
2921
|
+
* Topology-only instructions (`none`, declared `initial` and history
|
|
2922
|
+
* selections, and `local.with`) are values. State and choice destinations
|
|
2923
|
+
* remain callable selection methods.
|
|
2924
|
+
*/
|
|
2856
2925
|
interface TargetSelector<States extends StateSchemas, Source extends StateNodeIdentifier<States>> {
|
|
2857
|
-
readonly none:
|
|
2926
|
+
readonly none: SelectionValue<TargetBuilder<States, Source>["none"], never, "none">;
|
|
2858
2927
|
readonly local: LocalTargetSelector<States, Source>;
|
|
2859
2928
|
readonly branch: BranchTargetSelector<States, Source>;
|
|
2860
2929
|
readonly full: FullTargetSelector<States>;
|
|
2861
2930
|
readonly history: HistorySelectionTree<States, States, "", HistoryTargetBuilder<States>>;
|
|
2862
2931
|
}
|
|
2863
2932
|
/** Definition-time selector that can choose only a valid top-level initial entry. */
|
|
2864
|
-
type
|
|
2933
|
+
type InitialTargetSelector<States extends StateSchemas> = {
|
|
2865
2934
|
readonly [Key in Extract<ActiveStateKey<States>, keyof InitialBuilder<States>>]: States[Key] extends {
|
|
2866
2935
|
readonly states: StateSchemas;
|
|
2867
2936
|
} ? {
|
|
2868
|
-
readonly initial:
|
|
2937
|
+
readonly initial: SelectionValue<InitialBuilder<States>[Key], Key, "initial">;
|
|
2869
2938
|
} : SelectionMethod<InitialBuilder<States>[Key], Key>;
|
|
2870
2939
|
};
|
|
2871
2940
|
/**
|
|
@@ -2874,7 +2943,7 @@ export declare namespace Machine {
|
|
|
2874
2943
|
* @category models
|
|
2875
2944
|
* @since 0.4.0
|
|
2876
2945
|
*/
|
|
2877
|
-
|
|
2946
|
+
type HandlerContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
2878
2947
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2879
2948
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2880
2949
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
@@ -2888,38 +2957,38 @@ export declare namespace Machine {
|
|
|
2888
2957
|
* @since 0.4.0
|
|
2889
2958
|
*/
|
|
2890
2959
|
readonly target: TargetBuilder<States, StateId>;
|
|
2891
|
-
}
|
|
2960
|
+
};
|
|
2892
2961
|
/**
|
|
2893
2962
|
* Context passed to an entry or exit state handler.
|
|
2894
2963
|
*
|
|
2895
2964
|
* @category models
|
|
2896
2965
|
* @since 0.4.0
|
|
2897
2966
|
*/
|
|
2898
|
-
|
|
2967
|
+
type StateActionContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
2899
2968
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2900
2969
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2901
2970
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
2902
2971
|
readonly event: LifecycleEvent<Events>;
|
|
2903
|
-
}
|
|
2972
|
+
};
|
|
2904
2973
|
/**
|
|
2905
2974
|
* Context passed to a function-valued invocation source.
|
|
2906
2975
|
*
|
|
2907
2976
|
* @category models
|
|
2908
2977
|
* @since 0.4.0
|
|
2909
2978
|
*/
|
|
2910
|
-
|
|
2979
|
+
type InvokeContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
2911
2980
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2912
2981
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2913
2982
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
2914
2983
|
readonly event: LifecycleEvent<Events>;
|
|
2915
|
-
}
|
|
2984
|
+
};
|
|
2916
2985
|
/**
|
|
2917
2986
|
* Context passed to an invocation's active-snapshot transition.
|
|
2918
2987
|
*
|
|
2919
2988
|
* @category models
|
|
2920
2989
|
* @since 0.4.0
|
|
2921
2990
|
*/
|
|
2922
|
-
|
|
2991
|
+
type InvokeSnapshotContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, State, Error, Output, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
2923
2992
|
readonly id: string;
|
|
2924
2993
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2925
2994
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
@@ -2928,14 +2997,14 @@ export declare namespace Machine {
|
|
|
2928
2997
|
readonly snapshot: Extract<RuntimeSnapshot<State, Error, Output>, {
|
|
2929
2998
|
readonly status: "active";
|
|
2930
2999
|
}>;
|
|
2931
|
-
}
|
|
3000
|
+
};
|
|
2932
3001
|
/**
|
|
2933
3002
|
* Context passed to an invocation's successful completion transition.
|
|
2934
3003
|
*
|
|
2935
3004
|
* @category models
|
|
2936
3005
|
* @since 0.4.0
|
|
2937
3006
|
*/
|
|
2938
|
-
|
|
3007
|
+
type InvokeDoneContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Output, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
2939
3008
|
readonly id: string;
|
|
2940
3009
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2941
3010
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
@@ -2943,9 +3012,19 @@ export declare namespace Machine {
|
|
|
2943
3012
|
readonly snapshot: Snapshot<States>;
|
|
2944
3013
|
readonly target: TargetBuilder<States, StateId>;
|
|
2945
3014
|
readonly output: Output;
|
|
2946
|
-
}
|
|
3015
|
+
};
|
|
3016
|
+
/** Context passed to a Stream invocation's element transition. */
|
|
3017
|
+
type InvokeElementContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Element, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
3018
|
+
readonly id: string;
|
|
3019
|
+
readonly state: StateByIdentifier<States, StateId>;
|
|
3020
|
+
readonly containingState: ParentStateValue<States, StateId>;
|
|
3021
|
+
readonly ancestors: ParentStateValues<States, StateId>;
|
|
3022
|
+
readonly snapshot: Snapshot<States>;
|
|
3023
|
+
readonly target: TargetBuilder<States, StateId>;
|
|
3024
|
+
readonly element: Element;
|
|
3025
|
+
};
|
|
2947
3026
|
/** Context passed to an invocation typed-failure transition. */
|
|
2948
|
-
|
|
3027
|
+
type InvokeFailureContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Error, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
2949
3028
|
readonly id: string;
|
|
2950
3029
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2951
3030
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
@@ -2953,14 +3032,14 @@ export declare namespace Machine {
|
|
|
2953
3032
|
readonly snapshot: Snapshot<States>;
|
|
2954
3033
|
readonly target: TargetBuilder<States, StateId>;
|
|
2955
3034
|
readonly error: Error;
|
|
2956
|
-
}
|
|
3035
|
+
};
|
|
2957
3036
|
/**
|
|
2958
3037
|
* Context passed to an eventless transition handler.
|
|
2959
3038
|
*
|
|
2960
3039
|
* @category models
|
|
2961
3040
|
* @since 0.4.0
|
|
2962
3041
|
*/
|
|
2963
|
-
|
|
3042
|
+
type AlwaysContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
2964
3043
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2965
3044
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2966
3045
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
@@ -2975,14 +3054,14 @@ export declare namespace Machine {
|
|
|
2975
3054
|
* @since 0.4.0
|
|
2976
3055
|
*/
|
|
2977
3056
|
readonly target: TargetBuilder<States, StateId>;
|
|
2978
|
-
}
|
|
3057
|
+
};
|
|
2979
3058
|
/**
|
|
2980
3059
|
* Context passed to a state completion transition handler.
|
|
2981
3060
|
*
|
|
2982
3061
|
* @category models
|
|
2983
3062
|
* @since 0.4.0
|
|
2984
3063
|
*/
|
|
2985
|
-
|
|
3064
|
+
type DoneContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
2986
3065
|
readonly state: StateByIdentifier<States, StateId>;
|
|
2987
3066
|
readonly containingState: ParentStateValue<States, StateId>;
|
|
2988
3067
|
readonly ancestors: ParentStateValues<States, StateId>;
|
|
@@ -2998,16 +3077,16 @@ export declare namespace Machine {
|
|
|
2998
3077
|
* @since 0.4.0
|
|
2999
3078
|
*/
|
|
3000
3079
|
readonly target: TargetBuilder<States, StateId>;
|
|
3001
|
-
}
|
|
3080
|
+
};
|
|
3002
3081
|
/** Context passed to a transient choice resolver. There is no `state` value. */
|
|
3003
|
-
|
|
3082
|
+
type ChoiceContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, ChoiceId extends ChoiceIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = MachineReferences<InputEvents, ParentEvents> & {
|
|
3004
3083
|
readonly containingState: StateByIdentifier<States, Extract<ImmediateParentStateIdentifier<ChoiceId>, StateIdentifier<States>>>;
|
|
3005
3084
|
readonly ancestors: {
|
|
3006
3085
|
readonly [Parent in Extract<ParentStateIdentifier<ChoiceId>, ValuedStateIdentifier<States>>]: StateByIdentifier<States, Parent>;
|
|
3007
3086
|
};
|
|
3008
3087
|
readonly event: LifecycleEvent<Events>;
|
|
3009
3088
|
readonly target: TargetBuilder<States, ChoiceId>;
|
|
3010
|
-
}
|
|
3089
|
+
};
|
|
3011
3090
|
/**
|
|
3012
3091
|
* Context passed to a final state output function.
|
|
3013
3092
|
*
|
|
@@ -3136,13 +3215,9 @@ export declare namespace Machine {
|
|
|
3136
3215
|
* @category utility types
|
|
3137
3216
|
* @since 0.4.0
|
|
3138
3217
|
*/
|
|
3139
|
-
type EventTransitionReturn<Transition> = (Transition extends {
|
|
3218
|
+
type EventTransitionReturn<Transition> = Transition extends (...args: any) => infer Authored ? Authored extends TransitionBuilderEvidence<infer Result, any> ? Result : never : Transition extends {
|
|
3140
3219
|
readonly resolve?: infer Resolve;
|
|
3141
|
-
} ? NonNullable<Resolve> extends (...args: any) => infer Ret ? Ret : never : never
|
|
3142
|
-
readonly cases: infer Cases extends ReadonlyArray<unknown>;
|
|
3143
|
-
} ? EventTransitionReturn<Cases[number]> : never) | (Transition extends {
|
|
3144
|
-
readonly otherwise: infer Otherwise;
|
|
3145
|
-
} ? EventTransitionReturn<Otherwise> : never);
|
|
3220
|
+
} ? NonNullable<Resolve> extends (...args: any) => infer Ret ? Ret : never : never;
|
|
3146
3221
|
/**
|
|
3147
3222
|
* Extracts the return value from a state's event handlers.
|
|
3148
3223
|
*
|
|
@@ -3175,6 +3250,8 @@ export declare namespace Machine {
|
|
|
3175
3250
|
type InvokeLogic<Invoke> = Invoke extends {
|
|
3176
3251
|
readonly effect: infer Source;
|
|
3177
3252
|
} ? InvokeFactoryResult<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 {
|
|
3253
|
+
readonly stream: infer Source;
|
|
3254
|
+
} ? InvokeFactoryResult<Source> extends infer SourceStream extends Stream.Stream<any, any, any> ? Logic<void, never, Stream.Error<SourceStream>, Stream.Services<SourceStream>, void> : never : Invoke extends {
|
|
3178
3255
|
readonly after: unknown;
|
|
3179
3256
|
} ? Logic<void, never, never, never, void> : Invoke extends {
|
|
3180
3257
|
readonly logic: infer Source;
|
|
@@ -3251,6 +3328,8 @@ export declare namespace Machine {
|
|
|
3251
3328
|
readonly onDone?: infer Handler;
|
|
3252
3329
|
} ? EventTransitionReturn<NonNullable<Handler>> : never) | (Invoke extends {
|
|
3253
3330
|
readonly onFailure?: infer Handler;
|
|
3331
|
+
} ? EventTransitionReturn<NonNullable<Handler>> : never) | (Invoke extends {
|
|
3332
|
+
readonly onElement?: infer Handler;
|
|
3254
3333
|
} ? EventTransitionReturn<NonNullable<Handler>> : never) | (Invoke extends {
|
|
3255
3334
|
readonly onSnapshot?: infer Handler;
|
|
3256
3335
|
} ? EventTransitionReturn<NonNullable<Handler>> : never) : never;
|
|
@@ -3302,23 +3381,15 @@ export declare namespace Machine {
|
|
|
3302
3381
|
* @since 0.4.0
|
|
3303
3382
|
*/
|
|
3304
3383
|
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<HistoryDefaultReturn<Config>> | Effect.Services<ChoiceReturn<Config>> | InvokeRequirements<Config>;
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
interface TransitionTyped<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean> {
|
|
3384
|
+
/** Type evidence retained by an authored transition without affecting runtime data. */
|
|
3385
|
+
interface TransitionTyped<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Acceptance extends TransitionAcceptance = "required"> {
|
|
3308
3386
|
readonly [TransitionTypeId]: {
|
|
3309
3387
|
readonly owner: Types.Covariant<readonly [States, Events, Emits, StateId, Context]>;
|
|
3310
|
-
|
|
3311
|
-
}
|
|
3312
|
-
/** Type evidence for a targetless transition reusable in every owning context. */
|
|
3313
|
-
interface TargetlessTransitionTyped {
|
|
3314
|
-
readonly [TransitionTypeId]: {
|
|
3315
|
-
readonly targetless: true;
|
|
3388
|
+
readonly acceptance: Types.Covariant<Acceptance>;
|
|
3316
3389
|
};
|
|
3317
3390
|
}
|
|
3318
3391
|
/** The only transition value accepted by machine handler APIs. */
|
|
3319
|
-
type TransitionConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean = false> =
|
|
3320
|
-
readonly reenter?: [Reenter] extends [true] ? boolean : never;
|
|
3321
|
-
};
|
|
3392
|
+
type TransitionConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean = false, Acceptance extends TransitionAcceptance = "required"> = TransitionBuilderInput<States, Events, Emits, StateId, Context, Reenter, Acceptance>;
|
|
3322
3393
|
type SelectionBuilder<Selection> = Selection extends TargetSelection<infer Builder, any, any> ? Builder : never;
|
|
3323
3394
|
type SelectionKind<Selection> = Selection extends TargetSelection<any, any, infer Kind> ? Kind : never;
|
|
3324
3395
|
type SelectionPath<Selection> = Selection extends TargetSelection<any, infer Path, any> ? Path : never;
|
|
@@ -3326,40 +3397,128 @@ export declare namespace Machine {
|
|
|
3326
3397
|
readonly from: (...args: any) => infer Result;
|
|
3327
3398
|
} ? Result : never);
|
|
3328
3399
|
type SelectedTargetResult<Selection> = SelectionBuilder<Selection> extends infer Builder ? TargetBuilderResult<Builder> : never;
|
|
3329
|
-
type
|
|
3330
|
-
readonly
|
|
3331
|
-
}
|
|
3400
|
+
type SelectionSupportsDefaultConstruction<Selection> = SelectionKind<Selection> extends "none" ? true : SelectionBuilder<Selection> extends {
|
|
3401
|
+
readonly from: (...args: infer Args) => any;
|
|
3402
|
+
} ? [] extends Args ? true : false : SelectionBuilder<Selection> extends (...args: infer Args) => any ? [] extends Args ? true : false : false;
|
|
3403
|
+
type TransitionResolveContext<Context, Selection> = Omit<Context, "target"> & (SelectionKind<Selection> extends "none" ? {} : {
|
|
3332
3404
|
readonly target: SelectionBuilder<Selection>;
|
|
3333
3405
|
});
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
readonly
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3406
|
+
/** Context capability available only to explicitly declinable resolvers. */
|
|
3407
|
+
interface DeclineCapability {
|
|
3408
|
+
readonly decline: () => Declined;
|
|
3409
|
+
}
|
|
3410
|
+
type TransitionResolver<Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Context, Selection> = (context: TransitionResolveContext<Context, Selection>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined;
|
|
3411
|
+
type DeclinableTransitionResolver<Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Context, Selection> = (context: TransitionResolveContext<Context, Selection> & DeclineCapability, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => (SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined) | Declined;
|
|
3412
|
+
/** One named destination declared by a branching transition. */
|
|
3413
|
+
interface TransitionBranchInput<Selection extends TargetSelection<any, any, any> = TargetSelection<any, any, any>> {
|
|
3414
|
+
readonly target: Selection;
|
|
3415
|
+
readonly title?: string;
|
|
3416
|
+
}
|
|
3417
|
+
/** Opaque evidence that a branching resolver selected one declared branch. */
|
|
3418
|
+
interface SelectedBranch<out Key extends string, out Result> {
|
|
3419
|
+
readonly [Topology.SelectedBranchTypeId]: {
|
|
3420
|
+
readonly key: Types.Covariant<Key>;
|
|
3421
|
+
readonly result: Types.Covariant<Result>;
|
|
3422
|
+
};
|
|
3423
|
+
}
|
|
3424
|
+
type SelectedBranchCallable<Callable, Key extends string> = Callable extends {
|
|
3425
|
+
(...args: infer Arguments1): infer Result1;
|
|
3426
|
+
(...args: infer Arguments2): infer Result2;
|
|
3427
|
+
} ? {
|
|
3428
|
+
(...args: Arguments1): SelectedBranch<Key, Result1>;
|
|
3429
|
+
(...args: Arguments2): SelectedBranch<Key, Result2>;
|
|
3430
|
+
} : Callable extends (...args: infer Arguments) => infer Result ? (...args: Arguments) => SelectedBranch<Key, Result> : {};
|
|
3431
|
+
type SelectedBranchBuilderProperties<Builder, Key extends string> = {
|
|
3432
|
+
readonly [Property in keyof Builder]: Builder[Property] extends (...args: any) => any ? SelectedBranchCallable<Builder[Property], Key> : Builder[Property];
|
|
3341
3433
|
};
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
readonly
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
readonly
|
|
3434
|
+
/** Target-specific builder that brands every construction with its branch key. */
|
|
3435
|
+
type SelectedBranchBuilder<Builder, Key extends string> = SelectedBranchCallable<Builder, Key> & SelectedBranchBuilderProperties<Builder, Key>;
|
|
3436
|
+
type BranchSelectors<Branches extends Readonly<Record<string, TransitionBranchInput>>> = {
|
|
3437
|
+
readonly [Key in Extract<keyof Branches, string>]: SelectedBranchBuilder<SelectionBuilder<Branches[Key]["target"]>, Key>;
|
|
3438
|
+
};
|
|
3439
|
+
type BranchSelectionResult<Branches extends Readonly<Record<string, TransitionBranchInput>>> = {
|
|
3440
|
+
readonly [Key in Extract<keyof Branches, string>]: SelectedBranch<Key, SelectedTargetResult<Branches[Key]["target"]>>;
|
|
3441
|
+
}[Extract<keyof Branches, string>];
|
|
3442
|
+
type TransitionBranchesResolveContext<Context, Branches extends Readonly<Record<string, TransitionBranchInput>>> = Omit<Context, "target"> & {
|
|
3443
|
+
readonly select: BranchSelectors<Branches>;
|
|
3444
|
+
};
|
|
3445
|
+
type TransitionBranchesResolver<Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Context, Branches extends Readonly<Record<string, TransitionBranchInput>>> = (context: TransitionBranchesResolveContext<Context, Branches>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => BranchSelectionResult<Branches>;
|
|
3446
|
+
type DeclinableTransitionBranchesResolver<Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Context, Branches extends Readonly<Record<string, TransitionBranchInput>>> = (context: TransitionBranchesResolveContext<Context, Branches> & DeclineCapability, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => BranchSelectionResult<Branches> | Declined;
|
|
3447
|
+
/** @internal Type evidence retained by a transition authored through its bound selector. */
|
|
3448
|
+
interface TransitionBuilderEvidence<out Result, out Acceptance extends TransitionAcceptance> {
|
|
3449
|
+
readonly [TransitionBuilderTypeId]: {
|
|
3450
|
+
readonly result: Types.Covariant<Result>;
|
|
3451
|
+
readonly acceptance: Types.Covariant<Acceptance>;
|
|
3452
|
+
};
|
|
3453
|
+
}
|
|
3454
|
+
type TransitionReenterOption<Reenter extends boolean> = [Reenter] extends [true] ? {
|
|
3455
|
+
readonly reenter?: boolean;
|
|
3456
|
+
} : {
|
|
3349
3457
|
readonly reenter?: never;
|
|
3350
3458
|
};
|
|
3351
|
-
type
|
|
3352
|
-
readonly
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
readonly
|
|
3356
|
-
readonly reenter?: Reenter;
|
|
3459
|
+
type TransitionRequiredOptions<Reenter extends boolean> = TransitionReenterOption<Reenter> & {
|
|
3460
|
+
readonly declinable?: false;
|
|
3461
|
+
};
|
|
3462
|
+
type TransitionDeclinableOptions<Reenter extends boolean> = TransitionReenterOption<Reenter> & {
|
|
3463
|
+
readonly declinable: true;
|
|
3357
3464
|
};
|
|
3358
|
-
type
|
|
3465
|
+
type BuiltTransition<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Result, Acceptance extends TransitionAcceptance> = TransitionTyped<States, Events, Emits, StateId, Context, Reenter, Acceptance> & TransitionBuilderEvidence<Result, Acceptance>;
|
|
3466
|
+
interface TransitionResolveRequired<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Selection extends TargetSelection<any, any, any>> {
|
|
3467
|
+
(resolve: TransitionResolver<Events, Emits, Context, Selection>, options?: TransitionRequiredOptions<Reenter>): BuiltTransition<States, Events, Emits, StateId, Context, Reenter, SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined, "required">;
|
|
3468
|
+
}
|
|
3469
|
+
interface TransitionResolveDeclinable<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Selection extends TargetSelection<any, any, any>> {
|
|
3470
|
+
(resolve: DeclinableTransitionResolver<Events, Emits, Context, Selection>, options: TransitionDeclinableOptions<Reenter>): BuiltTransition<States, Events, Emits, StateId, Context, Reenter, (SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined) | Declined, "declinable">;
|
|
3471
|
+
}
|
|
3472
|
+
/** A selected transition target with target-specific resolver operations. */
|
|
3473
|
+
type TransitionTarget<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Acceptance extends TransitionAcceptance, Selection extends TargetSelection<any, any, any>> = Selection & (SelectionSupportsDefaultConstruction<Selection> extends true ? BuiltTransition<States, Events, Emits, StateId, Context, Reenter, SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined, "required"> : {}) & {
|
|
3474
|
+
readonly resolve: TransitionResolveRequired<States, Events, Emits, StateId, Context, Reenter, Selection> & ("declinable" extends Acceptance ? TransitionResolveDeclinable<States, Events, Emits, StateId, Context, Reenter, Selection> : {});
|
|
3475
|
+
} & ([Reenter] extends [true] ? SelectionSupportsDefaultConstruction<Selection> extends true ? {
|
|
3476
|
+
readonly reenter: () => BuiltTransition<States, Events, Emits, StateId, Context, Reenter, SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined, "required">;
|
|
3477
|
+
} : {} : {});
|
|
3478
|
+
/** @internal Type evidence retained by a machine initial-entry declaration. */
|
|
3479
|
+
interface InitialBuilderEvidence<out Selection> {
|
|
3480
|
+
readonly [InitialBuilderTypeId]: Types.Covariant<Selection>;
|
|
3481
|
+
}
|
|
3482
|
+
/** A selected machine initial entry with its exact resolver target. */
|
|
3483
|
+
type InitialTransitionTarget<Input, Selection extends TargetSelection<any, any, any>> = Selection & (SelectionSupportsDefaultConstruction<Selection> extends true ? InitialBuilderEvidence<Selection> : {}) & {
|
|
3484
|
+
readonly resolve: (resolve: (context: {
|
|
3485
|
+
readonly input: Input;
|
|
3486
|
+
readonly target: SelectionBuilder<Selection>;
|
|
3487
|
+
}) => SelectedTargetResult<Selection>) => InitialBuilderEvidence<Selection>;
|
|
3488
|
+
};
|
|
3489
|
+
type InitialSelectorNode<Input, Node> = Node extends (...args: infer Args) => infer Selection ? Selection extends TargetSelection<any, any, any> ? ((...args: Args) => InitialTransitionTarget<Input, Selection>) & {
|
|
3490
|
+
readonly [Key in keyof Node]: InitialSelectorNode<Input, Node[Key]>;
|
|
3491
|
+
} : never : Node extends TargetSelection<any, any, any> ? InitialTransitionTarget<Input, Node> : {
|
|
3492
|
+
readonly [Key in keyof Node]: InitialSelectorNode<Input, Node[Key]>;
|
|
3493
|
+
};
|
|
3494
|
+
/** Definition-time selector for a machine's top-level initial entry. */
|
|
3495
|
+
type InitialSelector<States extends StateSchemas, Input = void> = InitialSelectorNode<Input, InitialTargetSelector<States>>;
|
|
3496
|
+
/** Target-first initial-entry declaration accepted by {@link make}. */
|
|
3497
|
+
type InitialBuilderInput<States extends StateSchemas, Input> = (to: InitialSelector<States, Input>) => InitialBuilderEvidence<TargetSelection<any, any, any>>;
|
|
3498
|
+
type TransitionSelectorNode<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Acceptance extends TransitionAcceptance, Node> = Node extends (...args: infer Args) => infer Selection ? Selection extends TargetSelection<any, any, any> ? ((...args: Args) => TransitionTarget<States, Events, Emits, StateId, Context, Reenter, Acceptance, Selection>) & {
|
|
3499
|
+
readonly [Key in keyof Node]: TransitionSelectorNode<States, Events, Emits, StateId, Context, Reenter, Acceptance, Node[Key]>;
|
|
3500
|
+
} : never : Node extends TargetSelection<any, any, any> ? TransitionTarget<States, Events, Emits, StateId, Context, Reenter, Acceptance, Node> : {
|
|
3501
|
+
readonly [Key in keyof Node]: TransitionSelectorNode<States, Events, Emits, StateId, Context, Reenter, Acceptance, Node[Key]>;
|
|
3502
|
+
};
|
|
3503
|
+
interface TransitionBranchesResolveRequired<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Branches extends Readonly<Record<string, TransitionBranchInput>>> {
|
|
3504
|
+
(resolve: TransitionBranchesResolver<Events, Emits, Context, Branches>, options?: TransitionRequiredOptions<Reenter>): BuiltTransition<States, Events, Emits, StateId, Context, Reenter, BranchSelectionResult<Branches>, "required">;
|
|
3505
|
+
}
|
|
3506
|
+
interface TransitionBranchesResolveDeclinable<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Branches extends Readonly<Record<string, TransitionBranchInput>>> {
|
|
3507
|
+
(resolve: DeclinableTransitionBranchesResolver<Events, Emits, Context, Branches>, options: TransitionDeclinableOptions<Reenter>): BuiltTransition<States, Events, Emits, StateId, Context, Reenter, BranchSelectionResult<Branches> | Declined, "declinable">;
|
|
3508
|
+
}
|
|
3509
|
+
/** Selector supplied to inline transition declarations. */
|
|
3510
|
+
type TransitionSelector<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Acceptance extends TransitionAcceptance> = TransitionSelectorNode<States, Events, Emits, StateId, Context, Reenter, Acceptance, TargetSelector<States, StateId>> & {
|
|
3511
|
+
readonly branches: <const Branches extends Readonly<Record<string, TransitionBranchInput>>>(branches: Branches & ValidateTransitionBranchRecord<NoInfer<Branches>>) => {
|
|
3512
|
+
readonly resolve: TransitionBranchesResolveRequired<States, Events, Emits, StateId, Context, Reenter, Branches> & ("declinable" extends Acceptance ? TransitionBranchesResolveDeclinable<States, Events, Emits, StateId, Context, Reenter, Branches> : {});
|
|
3513
|
+
};
|
|
3514
|
+
};
|
|
3515
|
+
/** Inline transition declaration accepted by state and invocation handlers. */
|
|
3516
|
+
type TransitionBuilderInput<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context, Reenter extends boolean, Acceptance extends TransitionAcceptance> = (to: TransitionSelector<States, Events, Emits, StateId, Context, Reenter, Acceptance>) => TransitionTyped<States, Events, Emits, StateId, Context, Reenter, Acceptance> & TransitionBuilderEvidence<any, Acceptance>;
|
|
3517
|
+
type InvokeTransition<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<States>, Context> = TransitionConfig<States, Events, Emits, StateId, Context, true, TransitionAcceptance>;
|
|
3359
3518
|
type InvokeSource<Value, Context> = Value | ((context: Context) => Value);
|
|
3360
3519
|
/** Inline state-owned work that runs for the lifetime of its active state. */
|
|
3361
|
-
interface InvokeOwned<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States
|
|
3362
|
-
readonly "~effect/Machine/InvokeOwner"?: Types.Covariant<readonly [States, Events, Emits, StateId]>;
|
|
3520
|
+
interface InvokeOwned<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> {
|
|
3521
|
+
readonly "~effect/Machine/InvokeOwner"?: Types.Covariant<readonly [States, Events, Emits, StateId, InputEvents, ParentEvents]>;
|
|
3363
3522
|
}
|
|
3364
3523
|
/** Type evidence retained by {@link invoke} without affecting runtime data. */
|
|
3365
3524
|
interface InvokeTyped<Output, Error, Requirements, InitialError, Emits = never, ParentEvent = never> {
|
|
@@ -3372,35 +3531,53 @@ export declare namespace Machine {
|
|
|
3372
3531
|
readonly parentEvents: Types.Covariant<ParentEvent>;
|
|
3373
3532
|
};
|
|
3374
3533
|
}
|
|
3375
|
-
type InvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = InvokeOwned<States, Events, Emits, StateId> & ({
|
|
3534
|
+
type InvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & ({
|
|
3376
3535
|
readonly id: string;
|
|
3377
3536
|
readonly effect: (context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<any, any, any>;
|
|
3537
|
+
readonly stream?: never;
|
|
3378
3538
|
readonly after?: never;
|
|
3379
3539
|
readonly logic?: never;
|
|
3380
3540
|
readonly child?: never;
|
|
3381
3541
|
readonly address?: never;
|
|
3382
3542
|
readonly onDone?: unknown;
|
|
3383
3543
|
readonly onFailure?: unknown;
|
|
3544
|
+
readonly onElement?: never;
|
|
3545
|
+
readonly onSnapshot?: never;
|
|
3546
|
+
} | {
|
|
3547
|
+
readonly id: string;
|
|
3548
|
+
readonly stream: (context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Stream.Stream<any, any, any>;
|
|
3549
|
+
readonly effect?: never;
|
|
3550
|
+
readonly after?: never;
|
|
3551
|
+
readonly logic?: never;
|
|
3552
|
+
readonly child?: never;
|
|
3553
|
+
readonly address?: never;
|
|
3554
|
+
readonly onElement?: unknown;
|
|
3555
|
+
readonly onDone: unknown;
|
|
3556
|
+
readonly onFailure?: unknown;
|
|
3384
3557
|
readonly onSnapshot?: never;
|
|
3385
3558
|
} | {
|
|
3386
3559
|
readonly id: string;
|
|
3387
3560
|
readonly after: InvokeSource<Duration.Input, InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>>;
|
|
3388
3561
|
readonly effect?: never;
|
|
3562
|
+
readonly stream?: never;
|
|
3389
3563
|
readonly logic?: never;
|
|
3390
3564
|
readonly child?: never;
|
|
3391
3565
|
readonly address?: never;
|
|
3392
3566
|
readonly onDone: unknown;
|
|
3393
3567
|
readonly onFailure?: never;
|
|
3568
|
+
readonly onElement?: never;
|
|
3394
3569
|
readonly onSnapshot?: never;
|
|
3395
3570
|
} | {
|
|
3396
3571
|
readonly id: string;
|
|
3397
3572
|
readonly address: string;
|
|
3398
3573
|
readonly logic: InvokeSource<Logic<any, any, any, any, any, any>, InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>>;
|
|
3399
3574
|
readonly effect?: never;
|
|
3575
|
+
readonly stream?: never;
|
|
3400
3576
|
readonly after?: never;
|
|
3401
3577
|
readonly child?: never;
|
|
3402
3578
|
readonly onDone?: unknown;
|
|
3403
3579
|
readonly onFailure?: unknown;
|
|
3580
|
+
readonly onElement?: never;
|
|
3404
3581
|
readonly onSnapshot?: unknown;
|
|
3405
3582
|
} | {
|
|
3406
3583
|
readonly child: ChildMachine.Any;
|
|
@@ -3408,10 +3585,12 @@ export declare namespace Machine {
|
|
|
3408
3585
|
readonly id?: never;
|
|
3409
3586
|
readonly address?: never;
|
|
3410
3587
|
readonly effect?: never;
|
|
3588
|
+
readonly stream?: never;
|
|
3411
3589
|
readonly after?: never;
|
|
3412
3590
|
readonly logic?: never;
|
|
3413
3591
|
readonly onDone?: unknown;
|
|
3414
3592
|
readonly onFailure?: unknown;
|
|
3593
|
+
readonly onElement?: never;
|
|
3415
3594
|
readonly onSnapshot?: unknown;
|
|
3416
3595
|
});
|
|
3417
3596
|
/** State-bound inline invocation configuration. */
|
|
@@ -3438,14 +3617,23 @@ export declare namespace Machine {
|
|
|
3438
3617
|
} : {
|
|
3439
3618
|
readonly onFailure?: never;
|
|
3440
3619
|
} : never;
|
|
3620
|
+
type InvokeElementRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends infer Requirement ? Requirement extends {
|
|
3621
|
+
readonly handler: infer Required;
|
|
3622
|
+
} ? {
|
|
3623
|
+
readonly onElement: Required;
|
|
3624
|
+
} : {
|
|
3625
|
+
readonly onElement?: never;
|
|
3626
|
+
} : never;
|
|
3441
3627
|
type TimerInvokeArgs<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = {
|
|
3442
3628
|
readonly id: InvokeLifecycleId;
|
|
3443
3629
|
readonly after: InvokeSource<Duration.Input, InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>>;
|
|
3444
3630
|
readonly effect?: never;
|
|
3631
|
+
readonly stream?: never;
|
|
3445
3632
|
readonly logic?: never;
|
|
3446
3633
|
readonly child?: never;
|
|
3447
3634
|
readonly address?: never;
|
|
3448
3635
|
readonly onFailure?: never;
|
|
3636
|
+
readonly onElement?: never;
|
|
3449
3637
|
readonly onSnapshot?: never;
|
|
3450
3638
|
readonly onDone: InvokeTransition<States, Events, Emits, StateId, InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>>;
|
|
3451
3639
|
};
|
|
@@ -3454,8 +3642,10 @@ export declare namespace Machine {
|
|
|
3454
3642
|
readonly address: Address & ChildAddress.Compatibility<Address, ChildEvent>;
|
|
3455
3643
|
readonly logic: Source;
|
|
3456
3644
|
readonly effect?: never;
|
|
3645
|
+
readonly stream?: never;
|
|
3457
3646
|
readonly after?: never;
|
|
3458
3647
|
readonly child?: never;
|
|
3648
|
+
readonly onElement?: never;
|
|
3459
3649
|
readonly onSnapshot?: InvokeTransition<States, Events, Emits, StateId, InvokeSnapshotContext<States, Events, Emits, StateId, NoInfer<ChildState>, NoInfer<ChildError>, NoInfer<ChildOutput>, InputEvents, ParentEvents>>;
|
|
3460
3650
|
} & InvokeDoneRequirement<NoInfer<ChildOutput>, InvokeTransition<States, Events, Emits, StateId, InvokeDoneContext<States, Events, Emits, StateId, NoInfer<ChildOutput>, InputEvents, ParentEvents>>> & InvokeFailureRequirement<NoInfer<ChildError>, InvokeTransition<States, Events, Emits, StateId, InvokeFailureContext<States, Events, Emits, StateId, NoInfer<ChildError>, InputEvents, ParentEvents>>>;
|
|
3461
3651
|
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>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = {
|
|
@@ -3463,8 +3653,10 @@ export declare namespace Machine {
|
|
|
3463
3653
|
readonly id?: never;
|
|
3464
3654
|
readonly address?: never;
|
|
3465
3655
|
readonly effect?: never;
|
|
3656
|
+
readonly stream?: never;
|
|
3466
3657
|
readonly after?: never;
|
|
3467
3658
|
readonly logic?: never;
|
|
3659
|
+
readonly onElement?: never;
|
|
3468
3660
|
readonly onSnapshot?: InvokeTransition<States, Events, Emits, StateId, InvokeSnapshotContext<States, Events, Emits, StateId, Snapshot<Machine.States<ChildDefinition>>, Error<ChildDefinition>, Output<ChildDefinition>, InputEvents, ParentEvents>>;
|
|
3469
3661
|
} & (Input<ChildDefinition> extends typeof Schema.Void ? {
|
|
3470
3662
|
readonly input?: never;
|
|
@@ -3485,10 +3677,16 @@ export declare namespace Machine {
|
|
|
3485
3677
|
type LogicServicesOf<Value> = Effect.Services<LogicInitialEffectOf<Value> | LogicRunEffectOf<Value>>;
|
|
3486
3678
|
type LogicOutputOf<Value> = Effect.Success<LogicRunEffectOf<Value>>;
|
|
3487
3679
|
type LogicInitialErrorOf<Value> = Effect.Error<LogicInitialEffectOf<Value>>;
|
|
3488
|
-
type ContextualInvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema>, ParentEvents extends ReadonlyArray<TaggedSchema>, Raw> = Raw extends InvokeTyped<any, any, any, any, any> ? unknown : Raw extends {
|
|
3680
|
+
type ContextualInvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema>, ParentEvents extends ReadonlyArray<TaggedSchema>, Raw> = Raw extends InvokeTyped<any, any, any, any, any> ? unknown : [Extract<keyof Raw, "onDone" | "onFailure" | "onElement" | "onSnapshot">] extends [never] ? unknown : Raw extends {
|
|
3489
3681
|
readonly effect: infer Source;
|
|
3490
3682
|
} ? InvokeFactoryResult<Source> extends infer Fx extends Effect.Effect<any, any, any> ? InvokeDoneRequirement<Effect.Success<Fx>, InvokeTransition<States, Events, Emits, StateId, InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<Fx>, InputEvents, ParentEvents>>> & InvokeFailureRequirement<Effect.Error<Fx>, InvokeTransition<States, Events, Emits, StateId, InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<Fx>, InputEvents, ParentEvents>>> & {
|
|
3491
3683
|
readonly onSnapshot?: never;
|
|
3684
|
+
} : never : Raw extends {
|
|
3685
|
+
readonly stream: infer Source;
|
|
3686
|
+
} ? InvokeFactoryResult<Source> extends infer SourceStream extends Stream.Stream<any, any, any> ? InvokeElementRequirement<Stream.Success<SourceStream>, InvokeTransition<States, Events, Emits, StateId, InvokeElementContext<States, Events, Emits, StateId, Stream.Success<SourceStream>, InputEvents, ParentEvents>>> & {
|
|
3687
|
+
readonly onDone: InvokeTransition<States, Events, Emits, StateId, InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>>;
|
|
3688
|
+
} & InvokeFailureRequirement<Stream.Error<SourceStream>, InvokeTransition<States, Events, Emits, StateId, InvokeFailureContext<States, Events, Emits, StateId, Stream.Error<SourceStream>, InputEvents, ParentEvents>>> & {
|
|
3689
|
+
readonly onSnapshot?: never;
|
|
3492
3690
|
} : never : Raw extends {
|
|
3493
3691
|
readonly after: unknown;
|
|
3494
3692
|
} ? {
|
|
@@ -3535,10 +3733,10 @@ export declare namespace Machine {
|
|
|
3535
3733
|
readonly entry?: (context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => StateActionResult<any, any>;
|
|
3536
3734
|
readonly exit?: (context: StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => StateActionResult<any, any>;
|
|
3537
3735
|
readonly invoke?: InvokeDefinition<States, Events, Emits, StateId, InputEvents, ParentEvents> | TypedInvokeDefinition;
|
|
3538
|
-
readonly always?: TransitionConfig<States, Events, Emits, StateId, AlwaysContext<States, Events, Emits, StateId, InputEvents, ParentEvents
|
|
3539
|
-
readonly onDone?: TransitionConfig<States, Events, Emits, StateId, DoneContext<States, Events, Emits, StateId, InputEvents, ParentEvents
|
|
3736
|
+
readonly always?: TransitionConfig<States, Events, Emits, StateId, AlwaysContext<States, Events, Emits, StateId, InputEvents, ParentEvents>, false, TransitionAcceptance>;
|
|
3737
|
+
readonly onDone?: TransitionConfig<States, Events, Emits, StateId, DoneContext<States, Events, Emits, StateId, InputEvents, ParentEvents>, false, TransitionAcceptance>;
|
|
3540
3738
|
readonly on?: {
|
|
3541
|
-
readonly [EventTag in TagOf<Events[number]>]?: TransitionConfig<States, Events, Emits, StateId, HandlerContext<States, Events, Emits, StateId, EventTag, E, R, InputEvents, ParentEvents>, true>;
|
|
3739
|
+
readonly [EventTag in TagOf<Events[number]>]?: TransitionConfig<States, Events, Emits, StateId, HandlerContext<States, Events, Emits, StateId, EventTag, E, R, InputEvents, ParentEvents>, true, TransitionAcceptance>;
|
|
3542
3740
|
};
|
|
3543
3741
|
readonly initialize?: StateInitializeHandler<States, Events, Emits, StateId, InputEvents, ParentEvents>;
|
|
3544
3742
|
} & ActiveOutputHandlerConfig<States, Events, StateId>;
|
|
@@ -3739,7 +3937,7 @@ export declare namespace Machine {
|
|
|
3739
3937
|
readonly [Key in UnknownKeys]: HandlerValidationError<"Handler config contains an event key that does not exist", StateId, Key>;
|
|
3740
3938
|
};
|
|
3741
3939
|
} : unknown;
|
|
3742
|
-
type TransitionResultInitialTargetPath<Result> = IsAny<Result> extends true ? never : Result extends Effect.Effect<infer Success, any, any> ? TransitionResultInitialTargetPath<Success> : Result extends StateConstruction<infer Constructed> ? TransitionResultInitialTargetPath<Constructed> : Result extends {
|
|
3940
|
+
type TransitionResultInitialTargetPath<Result> = IsAny<Result> extends true ? never : Result extends Effect.Effect<infer Success, any, any> ? TransitionResultInitialTargetPath<Success> : Result extends SelectedBranch<any, infer Selected> ? TransitionResultInitialTargetPath<Selected> : Result extends StateConstruction<infer Constructed> ? TransitionResultInitialTargetPath<Constructed> : Result extends {
|
|
3743
3941
|
readonly [Topology.InitialTargetTypeId]: typeof Topology.InitialTargetTypeId;
|
|
3744
3942
|
readonly _tag: "InitialTarget";
|
|
3745
3943
|
} ? Result extends {
|
|
@@ -3840,7 +4038,7 @@ export declare namespace Machine {
|
|
|
3840
4038
|
* @category models
|
|
3841
4039
|
* @since 0.4.0
|
|
3842
4040
|
*/
|
|
3843
|
-
type EventHandlerMap<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R> = Readonly<Record<PropertyKey, TransitionConfig<States, Events, Emits, StateId, HandlerContext<States, Events, Emits, StateId, EventTag, E, R>, true>>>;
|
|
4041
|
+
type EventHandlerMap<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, EventTag extends TagOf<Events[number]>, E, R> = Readonly<Record<PropertyKey, TransitionConfig<States, Events, Emits, StateId, HandlerContext<States, Events, Emits, StateId, EventTag, E, R>, true, TransitionAcceptance>>>;
|
|
3844
4042
|
/**
|
|
3845
4043
|
* Runtime state config stored for a single state tag.
|
|
3846
4044
|
*
|
|
@@ -3851,8 +4049,8 @@ export declare namespace Machine {
|
|
|
3851
4049
|
readonly entry?: (context: StateActionContext<States, Events, Emits, StateId>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => StateActionResult<E, R>;
|
|
3852
4050
|
readonly exit?: (context: StateActionContext<States, Events, Emits, StateId>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => StateActionResult<E, R>;
|
|
3853
4051
|
readonly invoke?: InvokeDefinition<States, Events, Emits, StateId>;
|
|
3854
|
-
readonly always?: TransitionConfig<States, Events, Emits, StateId, AlwaysContext<States, Events, Emits, StateId
|
|
3855
|
-
readonly onDone?: TransitionConfig<States, Events, Emits, StateId, DoneContext<States, Events, Emits, StateId
|
|
4052
|
+
readonly always?: TransitionConfig<States, Events, Emits, StateId, AlwaysContext<States, Events, Emits, StateId>, false, TransitionAcceptance>;
|
|
4053
|
+
readonly onDone?: TransitionConfig<States, Events, Emits, StateId, DoneContext<States, Events, Emits, StateId>, false, TransitionAcceptance>;
|
|
3856
4054
|
readonly output?: ((context: FinalOutputContext<States, Events, StateId>) => unknown) | ((context: ParallelOutputContext<States, Events, StateId>) => unknown);
|
|
3857
4055
|
readonly on?: EventHandlerMap<States, Events, Emits, StateId, EventTag, E, R>;
|
|
3858
4056
|
}
|
|
@@ -3951,10 +4149,7 @@ export declare const state: StateConstructor;
|
|
|
3951
4149
|
* Machine.make({
|
|
3952
4150
|
* states: States.states,
|
|
3953
4151
|
* events: Machine.events(),
|
|
3954
|
-
* initial: {
|
|
3955
|
-
* target: (to) => to.idle(),
|
|
3956
|
-
* resolve: ({ target }) => target.from()
|
|
3957
|
-
* }
|
|
4152
|
+
* initial: (to) => to.idle().resolve(({ target }) => target.from())
|
|
3958
4153
|
* })
|
|
3959
4154
|
* ```
|
|
3960
4155
|
*
|
|
@@ -3962,31 +4157,22 @@ export declare const state: StateConstructor;
|
|
|
3962
4157
|
* @since 0.4.0
|
|
3963
4158
|
*/
|
|
3964
4159
|
export declare const states: StatesConstructor;
|
|
3965
|
-
type
|
|
3966
|
-
readonly target: (to: Machine.InitialSelector<States>) => Selection;
|
|
3967
|
-
readonly resolve?: (context: {
|
|
3968
|
-
readonly input: Input;
|
|
3969
|
-
readonly target: Machine.SelectionBuilder<Selection>;
|
|
3970
|
-
}) => Machine.SelectedTargetResult<Selection>;
|
|
3971
|
-
readonly cases?: never;
|
|
3972
|
-
readonly otherwise?: never;
|
|
3973
|
-
};
|
|
3974
|
-
type MakeConfig<States extends Machine.StateSchemas, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, Input extends Schema.Top, InitialE, InitialR, InternalEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>> = {
|
|
4160
|
+
type MakeConfig<States extends Machine.StateSchemas, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, Input extends Schema.Top, InitialE, InitialR, InternalEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentDeclaration extends Parent.Any | undefined> = {
|
|
3975
4161
|
readonly id?: string;
|
|
3976
4162
|
readonly states: States & DefineStateTreeInput<NoInfer<States>>;
|
|
3977
4163
|
readonly events: Machine.EventProtocol<"public", InputEvents> & ValidateInputEventProtocol<NoInfer<InputEvents>>;
|
|
3978
4164
|
readonly internalEvents?: Machine.EventProtocol<"internal", InternalEvents> & ValidateInternalEventProtocol<NoInfer<InputEvents>, NoInfer<InternalEvents>>;
|
|
3979
4165
|
readonly emittedEvents?: Machine.EventProtocol<"emitted", Emits>;
|
|
3980
|
-
readonly
|
|
4166
|
+
readonly parent?: ParentDeclaration;
|
|
3981
4167
|
readonly input?: Input;
|
|
3982
4168
|
readonly initial: unknown;
|
|
3983
4169
|
};
|
|
3984
|
-
type MakeResult<States extends Machine.StateSchemas, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, Input extends Schema.Top, InitialE, InitialR, InternalEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
4170
|
+
type MakeResult<States extends Machine.StateSchemas, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, Input extends Schema.Top, InitialE, InitialR, InternalEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentDeclaration extends Parent.Any | undefined> = Definition<States, readonly [...InputEvents, ...InternalEvents], Input, InitialE, InitialR, Machine.FinalStateFromDefinition<States>, Machine.TerminalOutput<States>, Emits, InputEvents, Machine.ParentEventsOf<ParentDeclaration>>;
|
|
3985
4171
|
interface Make {
|
|
3986
|
-
<const States extends Machine.StateSchemas, const InputEvents extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, InitialE = never, InitialR = never, const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const
|
|
3987
|
-
readonly initial:
|
|
3988
|
-
}, ..._validation: ValidateDefinedStates<NoInfer<States>>): MakeResult<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents,
|
|
3989
|
-
<const States extends Machine.StateSchemas, const InputEvents extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, InitialE = never, InitialR = never, const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const
|
|
4172
|
+
<const States extends Machine.StateSchemas, const InputEvents extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, InitialE = never, InitialR = never, const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentDeclaration extends Parent.Any | undefined = undefined>(config: Omit<MakeConfig<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents, ParentDeclaration>, "initial"> & {
|
|
4173
|
+
readonly initial: Machine.InitialBuilderInput<States, Input["Type"]>;
|
|
4174
|
+
}, ..._validation: ValidateDefinedStates<NoInfer<States>>): MakeResult<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents, ParentDeclaration>;
|
|
4175
|
+
<const States extends Machine.StateSchemas, const InputEvents extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, InitialE = never, InitialR = never, const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentDeclaration extends Parent.Any | undefined = undefined>(config: Omit<MakeConfig<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents, ParentDeclaration>, "states"> & {
|
|
3990
4176
|
readonly states: InvalidDefinedStateTreeInput<States>;
|
|
3991
4177
|
}): never;
|
|
3992
4178
|
}
|
|
@@ -4001,11 +4187,17 @@ interface Make {
|
|
|
4001
4187
|
* `states` or is passed inline. Call `handle` on the returned definition
|
|
4002
4188
|
* to implement state behavior with ordinary TypeScript control flow.
|
|
4003
4189
|
*
|
|
4190
|
+
* `initial` is a target-first callback. Its outer selector runs once while the
|
|
4191
|
+
* definition is captured; an attached `.resolve(...)` callback remains lazy
|
|
4192
|
+
* until initial planning. Return a bare selected state when its schema supports
|
|
4193
|
+
* default construction.
|
|
4194
|
+
*
|
|
4004
4195
|
* `Machine.events` defines the public input protocol. `Machine.internalEvents`
|
|
4005
4196
|
* adds raised events and other machine-local deliveries.
|
|
4006
|
-
* `Machine.emittedEvents` defines outward ephemeral notifications
|
|
4007
|
-
* `
|
|
4008
|
-
*
|
|
4197
|
+
* `Machine.emittedEvents` defines outward ephemeral notifications. The
|
|
4198
|
+
* `parent` configuration accepts `Machine.parent(events)` for a required owner
|
|
4199
|
+
* or `Machine.optionalParent(events)` for a root-capable machine. All
|
|
4200
|
+
* descriptors expose deferred constructors while retaining their
|
|
4009
4201
|
* schemas opaquely for runtime validation. Public and internal tags must be
|
|
4010
4202
|
* disjoint.
|
|
4011
4203
|
*
|
|
@@ -4029,18 +4221,13 @@ interface Make {
|
|
|
4029
4221
|
* const counter = Machine.make({
|
|
4030
4222
|
* states: States.states,
|
|
4031
4223
|
* events: Events,
|
|
4032
|
-
* initial: {
|
|
4033
|
-
* target: (to) => to.Count(),
|
|
4034
|
-
* resolve: ({ target }) => target(new Count({ value: 0 }))
|
|
4035
|
-
* }
|
|
4224
|
+
* initial: (to) => to.Count().resolve(({ target }) => target(new Count({ value: 0 })))
|
|
4036
4225
|
* }).handle({
|
|
4037
4226
|
* Count: {
|
|
4038
4227
|
* on: {
|
|
4039
|
-
* Increment:
|
|
4040
|
-
*
|
|
4041
|
-
*
|
|
4042
|
-
* target(new Count({ value: state.value + event.by }))
|
|
4043
|
-
* })
|
|
4228
|
+
* Increment: (to) =>
|
|
4229
|
+
* to.full.Count().resolve(({ event, state, target }) =>
|
|
4230
|
+
* target(new Count({ value: state.value + event.by })))
|
|
4044
4231
|
* }
|
|
4045
4232
|
* }
|
|
4046
4233
|
* })
|
|
@@ -4087,6 +4274,27 @@ export declare const events: {
|
|
|
4087
4274
|
<const Schemas extends ReadonlyArray<Machine.TaggedSchema>>(...schemas: Schemas & ValidateInputEventProtocol<NoInfer<Schemas>>): Machine.EventProtocol<"public", readonly [...Schemas]>;
|
|
4088
4275
|
<const Inputs extends ReadonlyArray<Machine.EventProtocolInput<"public">>>(...inputs: Inputs & ValidateEventProtocolBuilder<"public", Inputs>): Machine.EventProtocol<"public", Machine.EventProtocolInputSchemasOf<"public", Inputs>>;
|
|
4089
4276
|
};
|
|
4277
|
+
/**
|
|
4278
|
+
* Requires the machine to run as an owned child whose parent accepts the
|
|
4279
|
+
* supplied public event protocol.
|
|
4280
|
+
*
|
|
4281
|
+
* Required-parent machines expose a non-optional `parent` target in behavior
|
|
4282
|
+
* contexts and are rejected by root execution APIs.
|
|
4283
|
+
*
|
|
4284
|
+
* @category constructors
|
|
4285
|
+
* @since 0.17.0
|
|
4286
|
+
*/
|
|
4287
|
+
export declare const parent: <const Events extends ReadonlyArray<Machine.TaggedSchema>>(events: Machine.EventProtocol<"public", Events>) => Parent<"required", Events>;
|
|
4288
|
+
/**
|
|
4289
|
+
* Declares public events a machine may send to its owner while preserving the
|
|
4290
|
+
* ability to run that machine as a root.
|
|
4291
|
+
*
|
|
4292
|
+
* Optional-parent machines expose `parent` as a possibly absent target.
|
|
4293
|
+
*
|
|
4294
|
+
* @category constructors
|
|
4295
|
+
* @since 0.17.0
|
|
4296
|
+
*/
|
|
4297
|
+
export declare const optionalParent: <const Events extends ReadonlyArray<Machine.TaggedSchema>>(events: Machine.EventProtocol<"public", Events>) => Parent<"optional", Events>;
|
|
4090
4298
|
/**
|
|
4091
4299
|
* Defines an internal event protocol and returns deferred constructors for
|
|
4092
4300
|
* every statically finite configured event tag.
|
|
@@ -4175,10 +4383,7 @@ export declare const emittedEvents: {
|
|
|
4175
4383
|
* const machine = Machine.make({
|
|
4176
4384
|
* states: States.states,
|
|
4177
4385
|
* events: Machine.events(),
|
|
4178
|
-
* initial: {
|
|
4179
|
-
* target: (to) => to.Idle(),
|
|
4180
|
-
* resolve: ({ target }) => target.from()
|
|
4181
|
-
* }
|
|
4386
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
4182
4387
|
* }).handle({ Idle: {} })
|
|
4183
4388
|
*
|
|
4184
4389
|
* const encoded = Effect.gen(function*() {
|
|
@@ -4222,10 +4427,7 @@ export declare const encodeSnapshot: <const States extends Machine.StateSchemas,
|
|
|
4222
4427
|
* const machine = Machine.make({
|
|
4223
4428
|
* states: States.states,
|
|
4224
4429
|
* events: Machine.events(),
|
|
4225
|
-
* initial: {
|
|
4226
|
-
* target: (to) => to.Idle(),
|
|
4227
|
-
* resolve: ({ target }) => target.from()
|
|
4228
|
-
* }
|
|
4430
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
4229
4431
|
* }).handle({ Idle: {} })
|
|
4230
4432
|
*
|
|
4231
4433
|
* const roundTrip = Effect.gen(function*() {
|
|
@@ -4243,168 +4445,64 @@ export declare const decodeSnapshot: <const States extends Machine.StateSchemas,
|
|
|
4243
4445
|
type EffectInvokeSource<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, unknown, unknown>> = {
|
|
4244
4446
|
readonly id: InvokeLifecycleId;
|
|
4245
4447
|
readonly effect: Source;
|
|
4448
|
+
readonly stream?: never;
|
|
4246
4449
|
readonly after?: never;
|
|
4247
4450
|
readonly logic?: never;
|
|
4248
4451
|
readonly child?: never;
|
|
4249
4452
|
readonly address?: never;
|
|
4453
|
+
readonly onElement?: never;
|
|
4250
4454
|
readonly onSnapshot?: never;
|
|
4251
4455
|
};
|
|
4252
4456
|
type EffectDoneHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeTransition<States, Events, Emits, StateId, Machine.InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<ReturnType<NoInfer<Source>>>, InputEvents, ParentEvents>>;
|
|
4253
4457
|
type EffectFailureHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeTransition<States, Events, Emits, StateId, Machine.InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<ReturnType<NoInfer<Source>>>, InputEvents, ParentEvents>>;
|
|
4254
|
-
type EffectInvokeResult<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.
|
|
4255
|
-
type
|
|
4256
|
-
type BoundEffectInvokeSource<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, unknown, unknown>> = {
|
|
4458
|
+
type EffectInvokeResult<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<Effect.Success<ReturnType<Source>>, Effect.Error<ReturnType<Source>>, Effect.Services<ReturnType<Source>>, never>;
|
|
4459
|
+
type StreamInvokeSource<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<any>) => unknown> = {
|
|
4257
4460
|
readonly id: InvokeLifecycleId;
|
|
4258
|
-
readonly
|
|
4461
|
+
readonly stream: Source & ((context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown);
|
|
4462
|
+
readonly effect?: never;
|
|
4259
4463
|
readonly after?: never;
|
|
4260
4464
|
readonly logic?: never;
|
|
4261
4465
|
readonly child?: never;
|
|
4262
4466
|
readonly address?: never;
|
|
4263
4467
|
readonly onSnapshot?: never;
|
|
4264
4468
|
};
|
|
4265
|
-
type
|
|
4266
|
-
type
|
|
4267
|
-
type
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
* Captures one exact transition topology while preserving handler inference.
|
|
4278
|
-
*
|
|
4279
|
-
* @category constructors
|
|
4280
|
-
* @since 0.14.0
|
|
4281
|
-
*/
|
|
4282
|
-
type ConditionalTransitionResult<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateNodeIdentifier<States>, Context, Reenter extends boolean, Cases extends readonly [
|
|
4283
|
-
TransitionCaseTyped,
|
|
4284
|
-
...ReadonlyArray<TransitionCaseTyped>
|
|
4285
|
-
], OtherwiseSelection extends Machine.TargetSelection<any, any, any>> = Omit<Machine.TransitionConditionalInput<States, Events, Emits, StateId, Context, Reenter, Cases, OtherwiseSelection>, "cases"> & {
|
|
4286
|
-
readonly cases: Cases;
|
|
4287
|
-
} & Machine.TransitionTyped<States, Events, Emits, StateId, Context, Reenter>;
|
|
4288
|
-
/**
|
|
4289
|
-
* Contextually types direct and conditional transition definitions.
|
|
4290
|
-
*
|
|
4291
|
-
* @category constructors
|
|
4292
|
-
* @since 0.14.0
|
|
4293
|
-
*/
|
|
4294
|
-
export interface TransitionConstructor {
|
|
4295
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateNodeIdentifier<States>, Context, const Selection extends Machine.TargetSelection<any, any, any>, Reenter extends boolean = never>(config: Machine.TransitionDirectInput<States, Events, Emits, StateId, Context, Reenter, Selection>): Machine.TransitionDirectInput<States, Events, Emits, StateId, Context, Reenter, Selection> & (Machine.SelectionKind<Selection> extends "none" ? Machine.TargetlessTransitionTyped : Machine.TransitionTyped<States, Events, Emits, StateId, Context, Reenter>);
|
|
4296
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateNodeIdentifier<States>, Context, const Cases extends readonly [
|
|
4297
|
-
TransitionCaseTyped,
|
|
4298
|
-
...ReadonlyArray<TransitionCaseTyped>
|
|
4299
|
-
], const OtherwiseSelection extends Machine.TargetSelection<any, any, any>, Reenter extends boolean = never>(config: Machine.TransitionConditionalInput<States, Events, Emits, StateId, Context, Reenter, Cases, OtherwiseSelection>): ConditionalTransitionResult<States, Events, Emits, StateId, Context, Reenter, Cases, OtherwiseSelection>;
|
|
4300
|
-
}
|
|
4301
|
-
/**
|
|
4302
|
-
* Defines a statically inspectable transition.
|
|
4303
|
-
*
|
|
4304
|
-
* It is required for every event, lifecycle, choice, and invocation transition
|
|
4305
|
-
* so the destination selected by `target` can contextually type the
|
|
4306
|
-
* corresponding resolver. Conditional transitions use the locally bound
|
|
4307
|
-
* `branch` constructor so every case independently infers its matched value and
|
|
4308
|
-
* selected destination, with no limit on the number of cases.
|
|
4309
|
-
*
|
|
4310
|
-
* ```ts
|
|
4311
|
-
* Machine.transition({
|
|
4312
|
-
* target: (to) => to.full.Ready(),
|
|
4313
|
-
* resolve: ({ target }) => target.from()
|
|
4314
|
-
* })
|
|
4315
|
-
*
|
|
4316
|
-
* Machine.transition({
|
|
4317
|
-
* cases: (branch) => [
|
|
4318
|
-
* branch({
|
|
4319
|
-
* title: "has cached data",
|
|
4320
|
-
* when: ({ event }) => event.cached,
|
|
4321
|
-
* target: (to) => to.full.Ready(),
|
|
4322
|
-
* resolve: ({ match, target }) => target.from({ data: match })
|
|
4323
|
-
* })
|
|
4324
|
-
* ],
|
|
4325
|
-
* otherwise: {
|
|
4326
|
-
* target: (to) => to.full.Loading(),
|
|
4327
|
-
* resolve: ({ target }) => target.from()
|
|
4328
|
-
* }
|
|
4329
|
-
* })
|
|
4330
|
-
* ```
|
|
4331
|
-
*
|
|
4332
|
-
* @category constructors
|
|
4333
|
-
* @since 0.14.0
|
|
4334
|
-
*/
|
|
4335
|
-
export declare const transition: TransitionConstructor;
|
|
4336
|
-
/**
|
|
4337
|
-
* Machine-bound invocation constructor that preserves the owning machine's
|
|
4338
|
-
* public input and parent protocols in every invocation callback.
|
|
4339
|
-
*
|
|
4340
|
-
* @category constructors
|
|
4341
|
-
* @since 0.11.0
|
|
4342
|
-
*/
|
|
4343
|
-
export interface Invoker<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>> {
|
|
4344
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, unknown, unknown>>(config: BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4345
|
-
readonly onDone: BoundEffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4346
|
-
readonly onFailure: BoundEffectFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4347
|
-
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
4348
|
-
"onDone must be omitted when the Effect output is never"
|
|
4349
|
-
] : InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
4350
|
-
"onFailure must be omitted when the Effect error is never"
|
|
4351
|
-
] : []): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4352
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, never, unknown>>(config: BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4353
|
-
readonly onDone: BoundEffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4354
|
-
readonly onFailure?: never;
|
|
4355
|
-
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
4356
|
-
"onDone must be omitted when the Effect output is never"
|
|
4357
|
-
] : []): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4358
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<never, unknown, unknown>>(config: BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4359
|
-
readonly onDone?: never;
|
|
4360
|
-
readonly onFailure: BoundEffectFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4361
|
-
}, ..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
4362
|
-
"onFailure must be omitted when the Effect error is never"
|
|
4363
|
-
] : []): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4364
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<never, never, unknown>>(config: BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4365
|
-
readonly onDone?: never;
|
|
4366
|
-
readonly onFailure?: never;
|
|
4367
|
-
}): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4368
|
-
<StateId extends Machine.StateIdentifier<States>, const Config extends object>(config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>;
|
|
4369
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown, Address extends ChildAddress<never>>(config: {
|
|
4370
|
-
readonly logic: Source;
|
|
4371
|
-
} & Machine.LogicInvokeArgs<States, Events, Emits, StateId, Machine.LogicStateOf<ReturnType<Source>>, Machine.LogicEventOf<ReturnType<Source>>, Machine.LogicErrorOf<ReturnType<Source>>, Machine.LogicServicesOf<ReturnType<Source>>, Machine.LogicOutputOf<ReturnType<Source>>, Machine.LogicInitialErrorOf<ReturnType<Source>>, Address, Source, InputEvents, ParentEvents>, ..._validation: ReturnType<Source> extends {
|
|
4372
|
-
readonly initial: unknown;
|
|
4373
|
-
readonly run: unknown;
|
|
4374
|
-
} ? [] : [
|
|
4375
|
-
"logic factory must return Machine.Logic"
|
|
4376
|
-
]): Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<Machine.LogicOutputOf<ReturnType<Source>>, Machine.LogicErrorOf<ReturnType<Source>>, Machine.LogicServicesOf<ReturnType<Source>>, Machine.LogicInitialErrorOf<ReturnType<Source>>>;
|
|
4377
|
-
<StateId extends Machine.StateIdentifier<States>, const Source, Address extends ChildAddress<never>>(config: {
|
|
4378
|
-
readonly logic: Source;
|
|
4379
|
-
} & Machine.LogicInvokeArgs<States, Events, Emits, StateId, Machine.LogicStateOf<Source>, Machine.LogicEventOf<Source>, Machine.LogicErrorOf<Source>, Machine.LogicServicesOf<Source>, Machine.LogicOutputOf<Source>, Machine.LogicInitialErrorOf<Source>, Address, Source, InputEvents, ParentEvents>, ..._validation: Source extends {
|
|
4380
|
-
readonly initial: unknown;
|
|
4381
|
-
readonly run: unknown;
|
|
4382
|
-
} ? [] : [
|
|
4383
|
-
"logic must implement Machine.Logic"
|
|
4384
|
-
]): Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<Machine.LogicOutputOf<Source>, Machine.LogicErrorOf<Source>, Machine.LogicServicesOf<Source>, Machine.LogicInitialErrorOf<Source>>;
|
|
4385
|
-
<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, InputEvents, ParentEvents>): 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"]>, Machine.EventOf<Machine.ParentEvents<Child["machine"]>>>;
|
|
4386
|
-
}
|
|
4469
|
+
type StreamSourceResult<Source extends (...args: ReadonlyArray<any>) => unknown> = ReturnType<Source> extends infer Result extends Stream.Stream<any, any, any> ? Result : never;
|
|
4470
|
+
type StreamElementHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<any>) => unknown> = Machine.InvokeTransition<States, Events, Emits, StateId, Machine.InvokeElementContext<States, Events, Emits, StateId, Stream.Success<StreamSourceResult<NoInfer<Source>>>, InputEvents, ParentEvents>>;
|
|
4471
|
+
type StreamDoneHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>> = Machine.InvokeTransition<States, Events, Emits, StateId, Machine.InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>>;
|
|
4472
|
+
type StreamFailureHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<any>) => unknown> = Machine.InvokeTransition<States, Events, Emits, StateId, Machine.InvokeFailureContext<States, Events, Emits, StateId, Stream.Error<StreamSourceResult<NoInfer<Source>>>, InputEvents, ParentEvents>>;
|
|
4473
|
+
type StreamInvokeResult<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<any>) => unknown> = Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<void, Stream.Error<StreamSourceResult<Source>>, Stream.Services<StreamSourceResult<Source>>, never>;
|
|
4474
|
+
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false;
|
|
4475
|
+
type TransitionBranchRecordError<Message extends string, Key extends PropertyKey = never> = {
|
|
4476
|
+
readonly "~effect/Machine/TransitionBranchRecordError": Message;
|
|
4477
|
+
readonly key: Key;
|
|
4478
|
+
};
|
|
4479
|
+
type InvalidStaticTransitionBranchKey<Branches> = Extract<keyof Branches, "" | number | symbol>;
|
|
4480
|
+
type ValidateTransitionBranchRecord<Branches> = [keyof Branches] extends [never] ? TransitionBranchRecordError<"Branch records must contain at least one branch"> : [InvalidStaticTransitionBranchKey<Branches>] extends [never] ? unknown : TransitionBranchRecordError<"Branch keys must be non-empty, non-index strings", InvalidStaticTransitionBranchKey<Branches>>;
|
|
4387
4481
|
/**
|
|
4388
4482
|
* Preserves inference for a state-owned invocation configuration.
|
|
4389
4483
|
*
|
|
4390
|
-
* Use `effect` for one-shot work, `
|
|
4391
|
-
* reusable process logic, or `child` for a
|
|
4392
|
-
*
|
|
4393
|
-
*
|
|
4484
|
+
* Use `effect` for one-shot work, `stream` for repeated values, `after` for a
|
|
4485
|
+
* cancellable timer, `logic` for reusable process logic, or `child` for a
|
|
4486
|
+
* complete child machine. Stream elements are handled by `onElement` before
|
|
4487
|
+
* the next element is pulled. `onDone` is required whenever the source can
|
|
4488
|
+
* complete, while `onFailure` is required only when the source has a typed
|
|
4489
|
+
* failure channel.
|
|
4394
4490
|
*
|
|
4395
4491
|
* This constructor is an identity at runtime, but preserves lifecycle callback
|
|
4396
|
-
* inference through published declarations. Effect factories run
|
|
4397
|
-
* owning state is entered and infer the owner context,
|
|
4398
|
-
* service channels together without a return annotation.
|
|
4492
|
+
* inference through published declarations. Effect and Stream factories run
|
|
4493
|
+
* when their owning state is entered and infer the owner context, value,
|
|
4494
|
+
* output, error, and service channels together without a return annotation.
|
|
4495
|
+
* Durations may be
|
|
4399
4496
|
* supplied directly or derived from the owning state's entry context. Logic
|
|
4400
4497
|
* invocations require both a lifecycle `id` and a typed communication
|
|
4401
4498
|
* `address`. Child descriptors already own their identity, so `id` and
|
|
4402
4499
|
* `address` must not be repeated.
|
|
4403
4500
|
*
|
|
4404
4501
|
* Inside `handle(...)`, the owning definition contextually supplies its public
|
|
4405
|
-
* input and
|
|
4502
|
+
* input and declared parent protocols. Invocation sources and lifecycle handlers
|
|
4406
4503
|
* can therefore send through `self` and `parent` without naming the definition.
|
|
4407
|
-
* The
|
|
4504
|
+
* The standard `Machine.invoke(...)` constructor preserves these contexts
|
|
4505
|
+
* directly; no intermediate definition method is required.
|
|
4408
4506
|
*
|
|
4409
4507
|
* ```ts
|
|
4410
4508
|
* invoke: Machine.invoke({
|
|
@@ -4414,14 +4512,12 @@ export interface Invoker<States extends Machine.StateSchemas, Events extends Rea
|
|
|
4414
4512
|
* try: () => fetch("/api/data").then((response) => response.json()),
|
|
4415
4513
|
* catch: (cause) => new LoadError({ cause })
|
|
4416
4514
|
* }),
|
|
4417
|
-
* onDone:
|
|
4418
|
-
*
|
|
4419
|
-
*
|
|
4420
|
-
*
|
|
4421
|
-
*
|
|
4422
|
-
*
|
|
4423
|
-
* resolve: ({ error, target }) => target.from({ error })
|
|
4424
|
-
* })
|
|
4515
|
+
* onDone: (to) =>
|
|
4516
|
+
* to.full.Ready().resolve(({ output, target }) =>
|
|
4517
|
+
* target.from({ data: output })),
|
|
4518
|
+
* onFailure: (to) =>
|
|
4519
|
+
* to.full.Failed().resolve(({ error, target }) =>
|
|
4520
|
+
* target.from({ error }))
|
|
4425
4521
|
* })
|
|
4426
4522
|
* ```
|
|
4427
4523
|
*
|
|
@@ -4429,34 +4525,74 @@ export interface Invoker<States extends Machine.StateSchemas, Events extends Rea
|
|
|
4429
4525
|
* @since 0.9.0
|
|
4430
4526
|
*/
|
|
4431
4527
|
export declare const invoke: {
|
|
4432
|
-
<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, InputEvents, ParentEvents>) => Effect.Effect<unknown, unknown, unknown>, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4528
|
+
<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, InputEvents, ParentEvents>) => Effect.Effect<unknown, unknown, unknown>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4433
4529
|
readonly onDone: EffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4434
4530
|
readonly onFailure: EffectFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4435
4531
|
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
4436
4532
|
"onDone must be omitted when the Effect output is never"
|
|
4437
4533
|
] : InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
4438
4534
|
"onFailure must be omitted when the Effect error is never"
|
|
4439
|
-
] : []): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4440
|
-
<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, InputEvents, ParentEvents>) => Effect.Effect<unknown, never, unknown>, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4535
|
+
] : []): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4536
|
+
<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, InputEvents, ParentEvents>) => Effect.Effect<unknown, never, unknown>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4441
4537
|
readonly onDone: EffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4442
4538
|
readonly onFailure?: never;
|
|
4443
4539
|
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
4444
4540
|
"onDone must be omitted when the Effect output is never"
|
|
4445
|
-
] : []): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4446
|
-
<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, InputEvents, ParentEvents>) => Effect.Effect<never, unknown, unknown>, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4541
|
+
] : []): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4542
|
+
<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, InputEvents, ParentEvents>) => Effect.Effect<never, unknown, unknown>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4447
4543
|
readonly onDone?: never;
|
|
4448
4544
|
readonly onFailure: EffectFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4449
4545
|
}, ..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
4450
4546
|
"onFailure must be omitted when the Effect error is never"
|
|
4451
|
-
] : []): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4452
|
-
<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, InputEvents, ParentEvents>) => Effect.Effect<never, never, unknown>, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4547
|
+
] : []): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4548
|
+
<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, InputEvents, ParentEvents>) => Effect.Effect<never, never, unknown>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4453
4549
|
readonly onDone?: never;
|
|
4454
4550
|
readonly onFailure?: never;
|
|
4455
|
-
}): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4456
|
-
<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, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config &
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4551
|
+
}): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4552
|
+
<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, InputEvents, ParentEvents>) => Stream.Stream<unknown, unknown, any>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4553
|
+
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4554
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>;
|
|
4555
|
+
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4556
|
+
}, ..._validation: InvokeChannelIsNever<Stream.Success<ReturnType<Source>>> extends true ? [
|
|
4557
|
+
"onElement must be omitted when the Stream element is never"
|
|
4558
|
+
] : InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
4559
|
+
"onFailure must be omitted when the Stream error is never"
|
|
4560
|
+
] : []): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4561
|
+
<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, InputEvents, ParentEvents>) => Stream.Stream<never, unknown, any>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4562
|
+
readonly onElement?: never;
|
|
4563
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>;
|
|
4564
|
+
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4565
|
+
}, ..._validation: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
4566
|
+
"onFailure must be omitted when the Stream error is never"
|
|
4567
|
+
] : []): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4568
|
+
<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, InputEvents, ParentEvents>) => Stream.Stream<never, never, any>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4569
|
+
readonly onElement?: never;
|
|
4570
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>;
|
|
4571
|
+
readonly onFailure?: never;
|
|
4572
|
+
}): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4573
|
+
<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, InputEvents, ParentEvents>) => Stream.Stream<unknown, never, any>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4574
|
+
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4575
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>;
|
|
4576
|
+
readonly onFailure?: never;
|
|
4577
|
+
}): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4578
|
+
<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, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>): NoInfer<Config> & Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<void, never, never, never>;
|
|
4579
|
+
<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, InputEvents, ParentEvents>) => unknown, Address extends ChildAddress<never>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & {
|
|
4580
|
+
readonly logic: Source;
|
|
4581
|
+
} & Machine.LogicInvokeArgs<States, Events, Emits, StateId, Machine.LogicStateOf<ReturnType<Source>>, Machine.LogicEventOf<ReturnType<Source>>, Machine.LogicErrorOf<ReturnType<Source>>, Machine.LogicServicesOf<ReturnType<Source>>, Machine.LogicOutputOf<ReturnType<Source>>, Machine.LogicInitialErrorOf<ReturnType<Source>>, Address, Source, InputEvents, ParentEvents>, ..._validation: ReturnType<Source> extends {
|
|
4582
|
+
readonly initial: unknown;
|
|
4583
|
+
readonly run: unknown;
|
|
4584
|
+
} ? [] : [
|
|
4585
|
+
"logic factory must return Machine.Logic"
|
|
4586
|
+
]): NoInfer<Config> & Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<Machine.LogicOutputOf<ReturnType<Source>>, Machine.LogicErrorOf<ReturnType<Source>>, Machine.LogicServicesOf<ReturnType<Source>>, Machine.LogicInitialErrorOf<ReturnType<Source>>>;
|
|
4587
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source, Address extends ChildAddress<never>, const Config extends object, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & {
|
|
4588
|
+
readonly logic: Source;
|
|
4589
|
+
} & Machine.LogicInvokeArgs<States, Events, Emits, StateId, Machine.LogicStateOf<Source>, Machine.LogicEventOf<Source>, Machine.LogicErrorOf<Source>, Machine.LogicServicesOf<Source>, Machine.LogicOutputOf<Source>, Machine.LogicInitialErrorOf<Source>, Address, Source, InputEvents, ParentEvents>, ..._validation: Source extends {
|
|
4590
|
+
readonly initial: unknown;
|
|
4591
|
+
readonly run: unknown;
|
|
4592
|
+
} ? [] : [
|
|
4593
|
+
"logic must implement Machine.Logic"
|
|
4594
|
+
]): NoInfer<Config> & Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<Machine.LogicOutputOf<Source>, Machine.LogicErrorOf<Source>, Machine.LogicServicesOf<Source>, Machine.LogicInitialErrorOf<Source>>;
|
|
4595
|
+
<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, const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(config: Config & Machine.ChildInvokeArgs<States, Events, Emits, StateId, Child["machine"], Child, InputEvents, ParentEvents>): Config & Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents> & 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"]>, Machine.EventOf<Machine.ParentEvents<Child["machine"]>>>;
|
|
4460
4596
|
};
|
|
4461
4597
|
/**
|
|
4462
4598
|
* Plans the initial state for a machine without executing machine commands.
|
|
@@ -4487,10 +4623,7 @@ export declare const invoke: {
|
|
|
4487
4623
|
* const machine = Machine.make({
|
|
4488
4624
|
* states: States.states,
|
|
4489
4625
|
* events: Machine.events(),
|
|
4490
|
-
* initial: {
|
|
4491
|
-
* target: (to) => to.Idle(),
|
|
4492
|
-
* resolve: ({ target }) => target.from()
|
|
4493
|
-
* }
|
|
4626
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
4494
4627
|
* }).handle({ Idle: {} })
|
|
4495
4628
|
*
|
|
4496
4629
|
* const initialState = Effect.map(Machine.planInitial(machine), (plan) => plan.state)
|
|
@@ -4501,7 +4634,7 @@ export declare const invoke: {
|
|
|
4501
4634
|
* @category constructors
|
|
4502
4635
|
* @since 0.4.0
|
|
4503
4636
|
*/
|
|
4504
|
-
export declare const planInitial: <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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<{
|
|
4637
|
+
export declare const planInitial: <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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates> & Machine.RootCompatible<ParentEvents>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<{
|
|
4505
4638
|
readonly startingState: Machine.Snapshot<States>;
|
|
4506
4639
|
readonly initialEntryPaths: ReadonlyArray<Machine.StateIdentifier<States>>;
|
|
4507
4640
|
readonly state: Machine.Snapshot<States>;
|
|
@@ -4558,9 +4691,9 @@ export declare const initialDefinition: <M extends Machine.Any>(machine: M) => M
|
|
|
4558
4691
|
*
|
|
4559
4692
|
* Event handlers retain their handler-key order within each source state and
|
|
4560
4693
|
* are followed by eventless and completion handlers. This function does not
|
|
4561
|
-
* execute
|
|
4562
|
-
*
|
|
4563
|
-
* `
|
|
4694
|
+
* execute resolvers. Every direct, named, and targetless branch exposes the
|
|
4695
|
+
* destination selected by its required static `target` declaration, while
|
|
4696
|
+
* `acceptance` reports whether the resolver may decline the transition.
|
|
4564
4697
|
*
|
|
4565
4698
|
* @category getters
|
|
4566
4699
|
* @since 0.4.0
|
|
@@ -4593,7 +4726,12 @@ export declare const activityDefinitions: <M extends Machine.Any>(machine: M) =>
|
|
|
4593
4726
|
*/
|
|
4594
4727
|
export declare const configuration: <M extends Machine.Any>(machine: M, state: Machine.Snapshot<Machine.States<M>>) => ReadonlyArray<Machine.ActiveStateNode<Machine.StateIdentifier<Machine.States<M>>, Machine.ChoiceIdentifier<Machine.States<M>>>>;
|
|
4595
4728
|
/**
|
|
4596
|
-
* Returns
|
|
4729
|
+
* Returns event tags with at least one structurally eligible handler in the
|
|
4730
|
+
* current state snapshot.
|
|
4731
|
+
*
|
|
4732
|
+
* A `declinable` handler may still reject a concrete event at planning time,
|
|
4733
|
+
* so this is a static candidate query rather than a guarantee that every value
|
|
4734
|
+
* with the returned tag will be handled.
|
|
4597
4735
|
*
|
|
4598
4736
|
* @category getters
|
|
4599
4737
|
* @since 0.4.0
|
|
@@ -4629,17 +4767,12 @@ export declare const enabled: <const States extends Machine.StateSchemas, const
|
|
|
4629
4767
|
* const machine = Machine.make({
|
|
4630
4768
|
* states: States.states,
|
|
4631
4769
|
* events: Machine.events(Toggle),
|
|
4632
|
-
* initial: {
|
|
4633
|
-
* target: (to) => to.Off(),
|
|
4634
|
-
* resolve: ({ target }) => target.from()
|
|
4635
|
-
* }
|
|
4770
|
+
* initial: (to) => to.Off().resolve(({ target }) => target.from())
|
|
4636
4771
|
* }).handle({
|
|
4637
4772
|
* Off: {
|
|
4638
4773
|
* on: {
|
|
4639
|
-
* Toggle:
|
|
4640
|
-
* target
|
|
4641
|
-
* resolve: ({ target }) => target.from()
|
|
4642
|
-
* })
|
|
4774
|
+
* Toggle: (to) =>
|
|
4775
|
+
* to.full.On().resolve(({ target }) => target.from())
|
|
4643
4776
|
* }
|
|
4644
4777
|
* },
|
|
4645
4778
|
* On: {}
|
|
@@ -4656,7 +4789,7 @@ export declare const enabled: <const States extends Machine.StateSchemas, const
|
|
|
4656
4789
|
* @category combinators
|
|
4657
4790
|
* @since 0.4.0
|
|
4658
4791
|
*/
|
|
4659
|
-
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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, state: Machine.Snapshot<States>, event: Machine.EventInputOf<InputEvents>) => Effect.Effect<{
|
|
4792
|
+
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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates> & Machine.RootCompatible<ParentEvents>, state: Machine.Snapshot<States>, event: Machine.EventInputOf<InputEvents>) => Effect.Effect<{
|
|
4660
4793
|
readonly next: Machine.Snapshot<States>;
|
|
4661
4794
|
readonly commands: ReadonlyArray<Command>;
|
|
4662
4795
|
readonly emittedEvents: ReadonlyArray<Machine.EmitOf<Emits>>;
|
|
@@ -4802,7 +4935,7 @@ export declare const watch: <State, Event, Error = never, Output = never>(ref: M
|
|
|
4802
4935
|
* @category constructors
|
|
4803
4936
|
* @since 0.11.0
|
|
4804
4937
|
*/
|
|
4805
|
-
export declare const prepare: <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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<Prepared<Machine.Snapshot<States>, Machine.EventInputOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output, Machine.EmittedEventOf<Emits>, InitialE | E | ActionError<InitialR | R> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError, ExcludeCompatibleRuntime<ExecutionServices<InitialR | R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>>;
|
|
4938
|
+
export declare const prepare: <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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates> & Machine.RootCompatible<ParentEvents>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<Prepared<Machine.Snapshot<States>, Machine.EventInputOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output, Machine.EmittedEventOf<Emits>, InitialE | E | ActionError<InitialR | R> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError, ExcludeCompatibleRuntime<ExecutionServices<InitialR | R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>>;
|
|
4806
4939
|
/**
|
|
4807
4940
|
* Starts a machine.
|
|
4808
4941
|
*
|
|
@@ -4836,10 +4969,7 @@ export declare const prepare: <const States extends Machine.StateSchemas, const
|
|
|
4836
4969
|
* const machine = Machine.make({
|
|
4837
4970
|
* states: States.states,
|
|
4838
4971
|
* events: Machine.events(),
|
|
4839
|
-
* initial: {
|
|
4840
|
-
* target: (to) => to.Idle(),
|
|
4841
|
-
* resolve: ({ target }) => target.from()
|
|
4842
|
-
* }
|
|
4972
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
4843
4973
|
* }).handle({ Idle: {} })
|
|
4844
4974
|
*
|
|
4845
4975
|
* const state = Effect.gen(function*() {
|
|
@@ -4853,7 +4983,7 @@ export declare const prepare: <const States extends Machine.StateSchemas, const
|
|
|
4853
4983
|
* @category constructors
|
|
4854
4984
|
* @since 0.4.0
|
|
4855
4985
|
*/
|
|
4856
|
-
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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.EventInputOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output, Machine.EmittedEventOf<Emits>>, InitialE | E | ActionError<InitialR | R> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError, ExcludeCompatibleRuntime<ExecutionServices<InitialR | R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>;
|
|
4986
|
+
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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates> & Machine.RootCompatible<ParentEvents>, ...args: [...Machine.InputArgs<Input>]) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.EventInputOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output, Machine.EmittedEventOf<Emits>>, InitialE | E | ActionError<InitialR | R> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError, ExcludeCompatibleRuntime<ExecutionServices<InitialR | R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>;
|
|
4857
4987
|
/**
|
|
4858
4988
|
* Starts a fresh managed runtime from a decoded logical snapshot.
|
|
4859
4989
|
*
|
|
@@ -4889,10 +5019,7 @@ export declare const start: <const States extends Machine.StateSchemas, const Ev
|
|
|
4889
5019
|
* const machine = Machine.make({
|
|
4890
5020
|
* states: States.states,
|
|
4891
5021
|
* events: Machine.events(),
|
|
4892
|
-
* initial: {
|
|
4893
|
-
* target: (to) => to.Idle(),
|
|
4894
|
-
* resolve: ({ target }) => target.from()
|
|
4895
|
-
* }
|
|
5022
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
4896
5023
|
* }).handle({ Idle: {} })
|
|
4897
5024
|
*
|
|
4898
5025
|
* const resumed = Effect.gen(function*() {
|
|
@@ -4908,5 +5035,5 @@ export declare const start: <const States extends Machine.StateSchemas, const Ev
|
|
|
4908
5035
|
* @category constructors
|
|
4909
5036
|
* @since 0.4.0
|
|
4910
5037
|
*/
|
|
4911
|
-
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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates>, snapshot: Machine.Snapshot<States>) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.EventInputOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output, Machine.EmittedEventOf<Emits>>, MachineSchemaDecodeError, ExcludeCompatibleRuntime<ExecutionServices<R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>;
|
|
5038
|
+
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, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents> & EnsureExecutable<States, UnhandledStates, OutputStates> & Machine.RootCompatible<ParentEvents>, snapshot: Machine.Snapshot<States>) => Effect.Effect<MachineRef<Machine.Snapshot<States>, Machine.EventInputOf<InputEvents>, E | ActionError<R> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, Output, Machine.EmittedEventOf<Emits>>, MachineSchemaDecodeError, ExcludeCompatibleRuntime<ExecutionServices<R>, Machine.EventOf<Events>, Machine.EmitOf<Emits>>>;
|
|
4912
5039
|
//# sourceMappingURL=Machine.d.ts.map
|