@typeonce/effect-machine 0.16.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 +98 -106
- package/dist/Machine.d.ts +324 -367
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +61 -96
- package/dist/Machine.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 +10 -3
- package/dist/internal/machine/executionPlan.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 +191 -25
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +19 -4
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +56 -20
- package/dist/internal/machine/planner.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 +9 -0
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +16 -0
- 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 +2 -0
- package/dist/internal/testing/machine/transitionCoverage.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +11 -11
- 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 +144 -147
- package/package.json +1 -1
- package/src/Machine.ts +1118 -1178
- package/src/internal/machine/atom.ts +20 -15
- package/src/internal/machine/cluster.ts +14 -9
- package/src/internal/machine/executionPlan.ts +8 -3
- package/src/internal/machine/machine.ts +301 -40
- package/src/internal/machine/planner.ts +89 -27
- package/src/internal/machine/stateDefinition.ts +39 -0
- package/src/internal/machine/topology.ts +28 -0
- package/src/internal/testing/machine/finiteModel.ts +18 -21
- package/src/internal/testing/machine/transitionCoverage.ts +2 -0
- package/src/testing/MachineTest.ts +14 -11
- package/src/unstable/cluster/ClusterMachine.ts +8 -4
- package/src/unstable/reactivity/AtomMachine.ts +19 -12
package/src/Machine.ts
CHANGED
|
@@ -53,6 +53,9 @@ declare const MachineTypeId: unique symbol
|
|
|
53
53
|
declare const EventConstructionTypeId: unique symbol
|
|
54
54
|
declare const EmittedEventConstructionTypeId: unique symbol
|
|
55
55
|
declare const EventProtocolTypeId: unique symbol
|
|
56
|
+
declare const ParentModeTypeId: unique symbol
|
|
57
|
+
|
|
58
|
+
const ParentTypeId = "~effect/Machine/Parent"
|
|
56
59
|
|
|
57
60
|
const ChildMachineLogicTypeId: typeof internal.ChildMachineLogicTypeId = internal.ChildMachineLogicTypeId
|
|
58
61
|
|
|
@@ -184,16 +187,16 @@ export interface Machine<
|
|
|
184
187
|
readonly emittedEvents: Machine.EventProtocol<"emitted", Emits>
|
|
185
188
|
|
|
186
189
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
190
|
+
* Declared owning-machine protocol, or `undefined` when this machine does
|
|
191
|
+
* not communicate with its owner.
|
|
189
192
|
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
+
* Required parents make the machine child-only and expose a non-optional
|
|
194
|
+
* `parent` target to handlers. Optional parents keep root execution valid
|
|
195
|
+
* and expose `parent` as possibly absent.
|
|
193
196
|
*
|
|
194
|
-
* @since 0.
|
|
197
|
+
* @since 0.17.0
|
|
195
198
|
*/
|
|
196
|
-
readonly
|
|
199
|
+
readonly parent: Machine.ParentDeclarationOf<ParentEvents>
|
|
197
200
|
|
|
198
201
|
/**
|
|
199
202
|
* Optional schema used to decode the machine input before initialization.
|
|
@@ -220,15 +223,6 @@ export interface Machine<
|
|
|
220
223
|
/** @internal */
|
|
221
224
|
readonly handlers: Machine.StateConfigs<States, Events, Emits, UnhandledStates, Machine.TagOf<Events[number]>, E, R>
|
|
222
225
|
|
|
223
|
-
/**
|
|
224
|
-
* Machine-bound equivalent of {@link invoke}. Both forms preserve this
|
|
225
|
-
* machine's public input and parent protocols in invocation callbacks;
|
|
226
|
-
* `Machine.invoke(...)` inside `handle(...)` is the canonical inline form.
|
|
227
|
-
*
|
|
228
|
-
* @since 0.11.0
|
|
229
|
-
*/
|
|
230
|
-
readonly invoke: Invoker<States, Events, Emits, InputEvents, ParentEvents>
|
|
231
|
-
|
|
232
226
|
/** @internal */
|
|
233
227
|
readonly initial: (...args: [...Machine.InputArgs<Input>]) => Machine.InitialResult<States, InitialE, InitialR>
|
|
234
228
|
/** @internal */
|
|
@@ -471,22 +465,61 @@ export interface MachineTarget<in Event> {
|
|
|
471
465
|
readonly send: (event: Event) => Effect.Effect<void, StoppedError>
|
|
472
466
|
}
|
|
473
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Availability declared for an owning-machine target.
|
|
470
|
+
*
|
|
471
|
+
* @category models
|
|
472
|
+
* @since 0.17.0
|
|
473
|
+
*/
|
|
474
|
+
export type ParentMode = "required" | "optional"
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Owning-machine protocol declared by {@link parent} or
|
|
478
|
+
* {@link optionalParent}.
|
|
479
|
+
*
|
|
480
|
+
* @category models
|
|
481
|
+
* @since 0.17.0
|
|
482
|
+
*/
|
|
483
|
+
export interface Parent<Mode extends ParentMode, Events extends ReadonlyArray<Machine.TaggedSchema>> {
|
|
484
|
+
readonly [ParentTypeId]: typeof ParentTypeId
|
|
485
|
+
readonly mode: Mode
|
|
486
|
+
readonly events: Machine.EventProtocol<"public", Events>
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Namespace containing type-level members associated with {@link Parent}.
|
|
491
|
+
*
|
|
492
|
+
* @category models
|
|
493
|
+
* @since 0.17.0
|
|
494
|
+
*/
|
|
495
|
+
export declare namespace Parent {
|
|
496
|
+
/** Any owning-machine protocol declaration. */
|
|
497
|
+
export type Any = Parent<ParentMode, ReadonlyArray<Machine.TaggedSchema>>
|
|
498
|
+
}
|
|
499
|
+
|
|
474
500
|
/**
|
|
475
501
|
* Machine targets available while evaluating machine behavior.
|
|
476
502
|
*
|
|
477
503
|
* @category models
|
|
478
504
|
* @since 0.12.0
|
|
479
505
|
*/
|
|
480
|
-
export
|
|
506
|
+
export type MachineReferences<
|
|
481
507
|
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
482
508
|
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>
|
|
483
|
-
>
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
509
|
+
> =
|
|
510
|
+
& {
|
|
511
|
+
/** Target for the current machine. Sending queues a later mailbox event. */
|
|
512
|
+
readonly self: MachineTarget<Machine.EventInputOf<InputEvents>>
|
|
513
|
+
}
|
|
514
|
+
& (Machine.ParentModeOf<ParentEvents> extends "required" ? {
|
|
515
|
+
/** Required target for the machine that owns this child. */
|
|
516
|
+
readonly parent: MachineTarget<Machine.EventInputOf<ParentEvents>>
|
|
517
|
+
} :
|
|
518
|
+
Machine.ParentModeOf<ParentEvents> extends "optional" ? {
|
|
519
|
+
/** Target for the owning machine, or `undefined` when running as a root. */
|
|
520
|
+
readonly parent: MachineTarget<Machine.EventInputOf<ParentEvents>> | undefined
|
|
521
|
+
} :
|
|
522
|
+
{})
|
|
490
523
|
|
|
491
524
|
/**
|
|
492
525
|
* Synchronous commands available while a machine transition is being
|
|
@@ -600,6 +633,8 @@ type IncompatibleRuntime<Requirements, Events, Emits> = Requirements extends Run
|
|
|
600
633
|
|
|
601
634
|
const InvokeTypeId: typeof internal.InvokeTypeId = internal.InvokeTypeId
|
|
602
635
|
const TransitionTypeId: typeof internal.TransitionTypeId = internal.TransitionTypeId
|
|
636
|
+
declare const TransitionBuilderTypeId: unique symbol
|
|
637
|
+
declare const InitialBuilderTypeId: unique symbol
|
|
603
638
|
|
|
604
639
|
type StateDefinitionError<
|
|
605
640
|
Message extends string,
|
|
@@ -725,6 +760,29 @@ type ValidateOutputSchema<Node> = "output" extends keyof Node ? Node extends { r
|
|
|
725
760
|
: StateDefinitionError<"State output must be a schema">
|
|
726
761
|
: unknown
|
|
727
762
|
|
|
763
|
+
type SelectorChildKey<Children extends Machine.StateSchemas> = ActiveStateKey<Children> | ChoiceStateKey<Children>
|
|
764
|
+
|
|
765
|
+
type ValidateInitialSelectorChild<Children extends Machine.StateSchemas, Path extends PropertyKey> = "initial" extends
|
|
766
|
+
SelectorChildKey<Children> ? StateDefinitionError<
|
|
767
|
+
"Active and choice child states cannot use the reserved target selector key \"initial\"",
|
|
768
|
+
StateDefinitionPath<Extract<Path, string>, "initial">,
|
|
769
|
+
"initial"
|
|
770
|
+
>
|
|
771
|
+
: unknown
|
|
772
|
+
|
|
773
|
+
type ValidateWithSelectorChild<
|
|
774
|
+
Node extends Machine.StateNodeConfig,
|
|
775
|
+
Children extends Machine.StateSchemas,
|
|
776
|
+
Path extends PropertyKey
|
|
777
|
+
> = Node extends { readonly schema: Machine.TaggedSchema } ?
|
|
778
|
+
"with" extends SelectorChildKey<Children> ? StateDefinitionError<
|
|
779
|
+
"Schema-backed compound child states cannot use the reserved local target selector key \"with\"",
|
|
780
|
+
StateDefinitionPath<Extract<Path, string>, "with">,
|
|
781
|
+
"with"
|
|
782
|
+
>
|
|
783
|
+
: unknown
|
|
784
|
+
: unknown
|
|
785
|
+
|
|
728
786
|
type ValidateStateNodeWithChildren<
|
|
729
787
|
Node extends Machine.StateNodeConfig,
|
|
730
788
|
Children,
|
|
@@ -732,8 +790,9 @@ type ValidateStateNodeWithChildren<
|
|
|
732
790
|
> = Children extends Machine.StateSchemas ?
|
|
733
791
|
Node extends { readonly type: "final" } ? StateDefinitionError<"Final states cannot declare child states">
|
|
734
792
|
: Node extends { readonly type: "parallel" } ?
|
|
735
|
-
|
|
736
|
-
|
|
793
|
+
& ValidateInitialSelectorChild<Children, Path>
|
|
794
|
+
& ("initial" extends keyof Node ? StateDefinitionError<"Parallel states cannot declare an initial child">
|
|
795
|
+
: { readonly states: ValidateStateTree<Children, true, Extract<Path, string>> } & ValidateOutputSchema<Node>)
|
|
737
796
|
: "output" extends keyof Node ? StateDefinitionError<"Only final and parallel states can declare output">
|
|
738
797
|
: ValidateCompoundStateNode<Node, Children, Path>
|
|
739
798
|
: StateDefinitionError<"Child states must be a state tree">
|
|
@@ -743,9 +802,12 @@ type ValidateCompoundStateNode<
|
|
|
743
802
|
Children extends Machine.StateSchemas,
|
|
744
803
|
Path extends PropertyKey
|
|
745
804
|
> = Node extends { readonly initial: infer Initial } ?
|
|
746
|
-
Initial extends ActiveStateKey<Children> | ChoiceStateKey<Children> ?
|
|
747
|
-
|
|
748
|
-
|
|
805
|
+
Initial extends ActiveStateKey<Children> | ChoiceStateKey<Children> ?
|
|
806
|
+
& ValidateInitialSelectorChild<Children, Path>
|
|
807
|
+
& ValidateWithSelectorChild<Node, Children, Path>
|
|
808
|
+
& {
|
|
809
|
+
readonly states: ValidateStateTree<Children, true, Extract<Path, string>>
|
|
810
|
+
}
|
|
749
811
|
: StateDefinitionError<
|
|
750
812
|
"Compound initial must be one of its direct child keys",
|
|
751
813
|
Path,
|
|
@@ -2465,6 +2527,35 @@ export declare namespace Machine {
|
|
|
2465
2527
|
readonly parentEvents: ParentEvents
|
|
2466
2528
|
}
|
|
2467
2529
|
|
|
2530
|
+
/** @internal Carries parent availability without widening the event tuple. */
|
|
2531
|
+
export type ParentEventSchemas<
|
|
2532
|
+
Mode extends ParentMode,
|
|
2533
|
+
Events extends ReadonlyArray<TaggedSchema>
|
|
2534
|
+
> = Events & { readonly [ParentModeTypeId]: Mode }
|
|
2535
|
+
|
|
2536
|
+
/** Extracts the parent availability encoded in a machine event tuple. */
|
|
2537
|
+
export type ParentModeOf<Events extends ReadonlyArray<TaggedSchema>> = Events extends
|
|
2538
|
+
{ readonly [ParentModeTypeId]: infer Mode extends ParentMode } ? Mode
|
|
2539
|
+
: Events extends readonly [] ? "none"
|
|
2540
|
+
: "optional"
|
|
2541
|
+
|
|
2542
|
+
/** Extracts the event schemas declared by an owning-machine protocol. */
|
|
2543
|
+
export type ParentEventsOf<Declaration extends Parent.Any | undefined> = Declaration extends Parent<
|
|
2544
|
+
infer Mode,
|
|
2545
|
+
infer Events
|
|
2546
|
+
> ? ParentEventSchemas<Mode, Events>
|
|
2547
|
+
: readonly []
|
|
2548
|
+
|
|
2549
|
+
/** Extracts the owning-machine declaration carried by a machine. */
|
|
2550
|
+
export type ParentDeclarationOf<Events extends ReadonlyArray<TaggedSchema>> = ParentModeOf<Events> extends
|
|
2551
|
+
infer Mode ? Mode extends ParentMode ? Parent<Mode, Events> : undefined
|
|
2552
|
+
: never
|
|
2553
|
+
|
|
2554
|
+
/** Constraint applied to APIs that create an independent root runtime. */
|
|
2555
|
+
export type RootCompatible<Events extends ReadonlyArray<TaggedSchema>> = ParentModeOf<Events> extends "required"
|
|
2556
|
+
? never
|
|
2557
|
+
: unknown
|
|
2558
|
+
|
|
2468
2559
|
/**
|
|
2469
2560
|
* Any schema-first machine.
|
|
2470
2561
|
*
|
|
@@ -2485,7 +2576,7 @@ export declare namespace Machine {
|
|
|
2485
2576
|
readonly events: EventProtocol.Any<"public">
|
|
2486
2577
|
readonly internalEvents: EventProtocol.Any<"internal">
|
|
2487
2578
|
readonly emittedEvents: EventProtocol.Any<"emitted">
|
|
2488
|
-
readonly
|
|
2579
|
+
readonly parent: Parent.Any | undefined
|
|
2489
2580
|
readonly input: Schema.Top | undefined
|
|
2490
2581
|
readonly id: string | undefined
|
|
2491
2582
|
/** @internal */
|
|
@@ -2495,8 +2586,6 @@ export declare namespace Machine {
|
|
|
2495
2586
|
/** @internal */
|
|
2496
2587
|
readonly handlers: any
|
|
2497
2588
|
/** @internal */
|
|
2498
|
-
readonly invoke: any
|
|
2499
|
-
/** @internal */
|
|
2500
2589
|
readonly initial: any
|
|
2501
2590
|
/** @internal */
|
|
2502
2591
|
readonly initialDefinition: InitialDefinition
|
|
@@ -2612,6 +2701,9 @@ export declare namespace Machine {
|
|
|
2612
2701
|
/** Extracts the public input protocol required from an owning machine. */
|
|
2613
2702
|
export type ParentEvents<M extends Any> = M[typeof MachineTypeId]["parentEvents"]
|
|
2614
2703
|
|
|
2704
|
+
/** Extracts whether a machine requires or optionally accepts an owner. */
|
|
2705
|
+
export type ParentAvailability<M extends Any> = ParentModeOf<M[typeof MachineTypeId]["parentEvents"]>
|
|
2706
|
+
|
|
2615
2707
|
/** Extracts an internal event schema tuple from the complete and public protocols. */
|
|
2616
2708
|
export type InternalEventSchemas<
|
|
2617
2709
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
@@ -3306,6 +3398,7 @@ export declare namespace Machine {
|
|
|
3306
3398
|
readonly source: SourcePath
|
|
3307
3399
|
readonly trigger: TransitionTrigger<EventTag>
|
|
3308
3400
|
readonly reenter: boolean
|
|
3401
|
+
readonly acceptance: TransitionAcceptance
|
|
3309
3402
|
readonly branches: ReadonlyArray<TransitionBranch<TargetPath>>
|
|
3310
3403
|
}
|
|
3311
3404
|
|
|
@@ -4184,6 +4277,24 @@ export declare namespace Machine {
|
|
|
4184
4277
|
readonly [Topology.NoTargetTypeId]: typeof Topology.NoTargetTypeId
|
|
4185
4278
|
}
|
|
4186
4279
|
|
|
4280
|
+
/**
|
|
4281
|
+
* Opaque result returned when a declinable transition does not accept the
|
|
4282
|
+
* current event or lifecycle outcome.
|
|
4283
|
+
*
|
|
4284
|
+
* Declining selects no transition and discards operations enqueued by that
|
|
4285
|
+
* resolver. Hierarchical event and eventless dispatch continues with the
|
|
4286
|
+
* next eligible ancestor candidate.
|
|
4287
|
+
*
|
|
4288
|
+
* @category models
|
|
4289
|
+
* @since 0.17.0
|
|
4290
|
+
*/
|
|
4291
|
+
export interface Declined {
|
|
4292
|
+
readonly [Topology.DeclinedTypeId]: typeof Topology.DeclinedTypeId
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4295
|
+
/** Static acceptance contract of one transition definition. */
|
|
4296
|
+
export type TransitionAcceptance = "required" | "declinable"
|
|
4297
|
+
|
|
4187
4298
|
/**
|
|
4188
4299
|
* Transition instruction that restores a history pseudo-state's parent.
|
|
4189
4300
|
*
|
|
@@ -4393,11 +4504,14 @@ export declare namespace Machine {
|
|
|
4393
4504
|
readonly "~effect/Machine/TargetSelectionResult"?: Types.Covariant<Result>
|
|
4394
4505
|
}
|
|
4395
4506
|
|
|
4396
|
-
type
|
|
4507
|
+
type SelectionValue<Builder, Path extends string, Kind extends Topology.TargetSelectionKind = "state"> =
|
|
4397
4508
|
TargetSelection<Builder, Path, Kind>
|
|
4398
4509
|
|
|
4510
|
+
type SelectionMethod<Builder, Path extends string, Kind extends Topology.TargetSelectionKind = "state"> = () =>
|
|
4511
|
+
SelectionValue<Builder, Path, Kind>
|
|
4512
|
+
|
|
4399
4513
|
type InitialSelectionMethod<Builder, Path extends string> = Builder extends { readonly initial: infer Initial } ? {
|
|
4400
|
-
readonly initial:
|
|
4514
|
+
readonly initial: SelectionValue<Initial, Path, "initial">
|
|
4401
4515
|
}
|
|
4402
4516
|
: {}
|
|
4403
4517
|
|
|
@@ -4477,7 +4591,7 @@ export declare namespace Machine {
|
|
|
4477
4591
|
LocalTargetBuilder<States, Source> extends infer Builder ?
|
|
4478
4592
|
& SelectionTreeWithPrefix<States, Children, Scope, "local", Builder>
|
|
4479
4593
|
& ("with" extends keyof Builder ? {
|
|
4480
|
-
readonly with:
|
|
4594
|
+
readonly with: SelectionValue<Builder["with"], Scope>
|
|
4481
4595
|
}
|
|
4482
4596
|
: {})
|
|
4483
4597
|
: {}
|
|
@@ -4491,7 +4605,7 @@ export declare namespace Machine {
|
|
|
4491
4605
|
Builder
|
|
4492
4606
|
> = {
|
|
4493
4607
|
readonly [Key in Extract<HistoryContainingKey<States>, keyof Builder>]: States[Key] extends HistoryStateNodeConfig ?
|
|
4494
|
-
|
|
4608
|
+
SelectionValue<
|
|
4495
4609
|
Builder[Key],
|
|
4496
4610
|
JoinPath<Prefix, Key>,
|
|
4497
4611
|
"history"
|
|
@@ -4505,12 +4619,17 @@ export declare namespace Machine {
|
|
|
4505
4619
|
: never
|
|
4506
4620
|
}
|
|
4507
4621
|
|
|
4508
|
-
/**
|
|
4622
|
+
/**
|
|
4623
|
+
* Definition-time topology selector available to an ordinary transition.
|
|
4624
|
+
* Topology-only instructions (`none`, declared `initial` and history
|
|
4625
|
+
* selections, and `local.with`) are values. State and choice destinations
|
|
4626
|
+
* remain callable selection methods.
|
|
4627
|
+
*/
|
|
4509
4628
|
export interface TargetSelector<
|
|
4510
4629
|
States extends StateSchemas,
|
|
4511
4630
|
Source extends StateNodeIdentifier<States>
|
|
4512
4631
|
> {
|
|
4513
|
-
readonly none:
|
|
4632
|
+
readonly none: SelectionValue<TargetBuilder<States, Source>["none"], never, "none">
|
|
4514
4633
|
readonly local: LocalTargetSelector<States, Source>
|
|
4515
4634
|
readonly branch: BranchTargetSelector<States, Source>
|
|
4516
4635
|
readonly full: FullTargetSelector<States>
|
|
@@ -4518,10 +4637,10 @@ export declare namespace Machine {
|
|
|
4518
4637
|
}
|
|
4519
4638
|
|
|
4520
4639
|
/** Definition-time selector that can choose only a valid top-level initial entry. */
|
|
4521
|
-
|
|
4640
|
+
type InitialTargetSelector<States extends StateSchemas> = {
|
|
4522
4641
|
readonly [Key in Extract<ActiveStateKey<States>, keyof InitialBuilder<States>>]: States[Key] extends
|
|
4523
4642
|
{ readonly states: StateSchemas } ? {
|
|
4524
|
-
readonly initial:
|
|
4643
|
+
readonly initial: SelectionValue<InitialBuilder<States>[Key], Key, "initial">
|
|
4525
4644
|
}
|
|
4526
4645
|
: SelectionMethod<InitialBuilder<States>[Key], Key>
|
|
4527
4646
|
}
|
|
@@ -4532,7 +4651,7 @@ export declare namespace Machine {
|
|
|
4532
4651
|
* @category models
|
|
4533
4652
|
* @since 0.4.0
|
|
4534
4653
|
*/
|
|
4535
|
-
export
|
|
4654
|
+
export type HandlerContext<
|
|
4536
4655
|
States extends StateSchemas,
|
|
4537
4656
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4538
4657
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -4542,7 +4661,7 @@ export declare namespace Machine {
|
|
|
4542
4661
|
R,
|
|
4543
4662
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4544
4663
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4545
|
-
>
|
|
4664
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4546
4665
|
readonly state: StateByIdentifier<States, StateId>
|
|
4547
4666
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4548
4667
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4565,14 +4684,14 @@ export declare namespace Machine {
|
|
|
4565
4684
|
* @category models
|
|
4566
4685
|
* @since 0.4.0
|
|
4567
4686
|
*/
|
|
4568
|
-
export
|
|
4687
|
+
export type StateActionContext<
|
|
4569
4688
|
States extends StateSchemas,
|
|
4570
4689
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4571
4690
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4572
4691
|
StateId extends StateIdentifier<States>,
|
|
4573
4692
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4574
4693
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4575
|
-
>
|
|
4694
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4576
4695
|
readonly state: StateByIdentifier<States, StateId>
|
|
4577
4696
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4578
4697
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4585,14 +4704,14 @@ export declare namespace Machine {
|
|
|
4585
4704
|
* @category models
|
|
4586
4705
|
* @since 0.4.0
|
|
4587
4706
|
*/
|
|
4588
|
-
export
|
|
4707
|
+
export type InvokeContext<
|
|
4589
4708
|
States extends StateSchemas,
|
|
4590
4709
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4591
4710
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4592
4711
|
StateId extends StateIdentifier<States>,
|
|
4593
4712
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4594
4713
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4595
|
-
>
|
|
4714
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4596
4715
|
readonly state: StateByIdentifier<States, StateId>
|
|
4597
4716
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4598
4717
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4605,7 +4724,7 @@ export declare namespace Machine {
|
|
|
4605
4724
|
* @category models
|
|
4606
4725
|
* @since 0.4.0
|
|
4607
4726
|
*/
|
|
4608
|
-
export
|
|
4727
|
+
export type InvokeSnapshotContext<
|
|
4609
4728
|
States extends StateSchemas,
|
|
4610
4729
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4611
4730
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -4615,7 +4734,7 @@ export declare namespace Machine {
|
|
|
4615
4734
|
Output,
|
|
4616
4735
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4617
4736
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4618
|
-
>
|
|
4737
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4619
4738
|
readonly id: string
|
|
4620
4739
|
readonly state: StateByIdentifier<States, StateId>
|
|
4621
4740
|
readonly containingState: ParentStateValue<States, StateId>
|
|
@@ -4630,7 +4749,7 @@ export declare namespace Machine {
|
|
|
4630
4749
|
* @category models
|
|
4631
4750
|
* @since 0.4.0
|
|
4632
4751
|
*/
|
|
4633
|
-
export
|
|
4752
|
+
export type InvokeDoneContext<
|
|
4634
4753
|
States extends StateSchemas,
|
|
4635
4754
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4636
4755
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -4638,7 +4757,7 @@ export declare namespace Machine {
|
|
|
4638
4757
|
Output,
|
|
4639
4758
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4640
4759
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4641
|
-
>
|
|
4760
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4642
4761
|
readonly id: string
|
|
4643
4762
|
readonly state: StateByIdentifier<States, StateId>
|
|
4644
4763
|
readonly containingState: ParentStateValue<States, StateId>
|
|
@@ -4649,7 +4768,7 @@ export declare namespace Machine {
|
|
|
4649
4768
|
}
|
|
4650
4769
|
|
|
4651
4770
|
/** Context passed to a Stream invocation's element transition. */
|
|
4652
|
-
export
|
|
4771
|
+
export type InvokeElementContext<
|
|
4653
4772
|
States extends StateSchemas,
|
|
4654
4773
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4655
4774
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -4657,7 +4776,7 @@ export declare namespace Machine {
|
|
|
4657
4776
|
Element,
|
|
4658
4777
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4659
4778
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4660
|
-
>
|
|
4779
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4661
4780
|
readonly id: string
|
|
4662
4781
|
readonly state: StateByIdentifier<States, StateId>
|
|
4663
4782
|
readonly containingState: ParentStateValue<States, StateId>
|
|
@@ -4668,7 +4787,7 @@ export declare namespace Machine {
|
|
|
4668
4787
|
}
|
|
4669
4788
|
|
|
4670
4789
|
/** Context passed to an invocation typed-failure transition. */
|
|
4671
|
-
export
|
|
4790
|
+
export type InvokeFailureContext<
|
|
4672
4791
|
States extends StateSchemas,
|
|
4673
4792
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4674
4793
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -4676,7 +4795,7 @@ export declare namespace Machine {
|
|
|
4676
4795
|
Error,
|
|
4677
4796
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4678
4797
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4679
|
-
>
|
|
4798
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4680
4799
|
readonly id: string
|
|
4681
4800
|
readonly state: StateByIdentifier<States, StateId>
|
|
4682
4801
|
readonly containingState: ParentStateValue<States, StateId>
|
|
@@ -4692,14 +4811,14 @@ export declare namespace Machine {
|
|
|
4692
4811
|
* @category models
|
|
4693
4812
|
* @since 0.4.0
|
|
4694
4813
|
*/
|
|
4695
|
-
export
|
|
4814
|
+
export type AlwaysContext<
|
|
4696
4815
|
States extends StateSchemas,
|
|
4697
4816
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4698
4817
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4699
4818
|
StateId extends StateIdentifier<States>,
|
|
4700
4819
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4701
4820
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4702
|
-
>
|
|
4821
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4703
4822
|
readonly state: StateByIdentifier<States, StateId>
|
|
4704
4823
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4705
4824
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4723,14 +4842,14 @@ export declare namespace Machine {
|
|
|
4723
4842
|
* @category models
|
|
4724
4843
|
* @since 0.4.0
|
|
4725
4844
|
*/
|
|
4726
|
-
export
|
|
4845
|
+
export type DoneContext<
|
|
4727
4846
|
States extends StateSchemas,
|
|
4728
4847
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4729
4848
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4730
4849
|
StateId extends StateIdentifier<States>,
|
|
4731
4850
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4732
4851
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4733
|
-
>
|
|
4852
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4734
4853
|
readonly state: StateByIdentifier<States, StateId>
|
|
4735
4854
|
readonly containingState: ParentStateValue<States, StateId>
|
|
4736
4855
|
readonly ancestors: ParentStateValues<States, StateId>
|
|
@@ -4750,14 +4869,14 @@ export declare namespace Machine {
|
|
|
4750
4869
|
}
|
|
4751
4870
|
|
|
4752
4871
|
/** Context passed to a transient choice resolver. There is no `state` value. */
|
|
4753
|
-
export
|
|
4872
|
+
export type ChoiceContext<
|
|
4754
4873
|
States extends StateSchemas,
|
|
4755
4874
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
4756
4875
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4757
4876
|
ChoiceId extends ChoiceIdentifier<States>,
|
|
4758
4877
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4759
4878
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4760
|
-
>
|
|
4879
|
+
> = MachineReferences<InputEvents, ParentEvents> & {
|
|
4761
4880
|
readonly containingState: StateByIdentifier<
|
|
4762
4881
|
States,
|
|
4763
4882
|
Extract<ImmediateParentStateIdentifier<ChoiceId>, StateIdentifier<States>>
|
|
@@ -4947,8 +5066,10 @@ export declare namespace Machine {
|
|
|
4947
5066
|
* @category utility types
|
|
4948
5067
|
* @since 0.4.0
|
|
4949
5068
|
*/
|
|
4950
|
-
export type EventTransitionReturn<Transition> = Transition extends
|
|
4951
|
-
|
|
5069
|
+
export type EventTransitionReturn<Transition> = Transition extends (...args: any) => infer Authored ?
|
|
5070
|
+
Authored extends TransitionBuilderEvidence<infer Result, any> ? Result : never
|
|
5071
|
+
: Transition extends { readonly resolve?: infer Resolve } ?
|
|
5072
|
+
NonNullable<Resolve> extends (...args: any) => infer Ret ? Ret : never
|
|
4952
5073
|
: never
|
|
4953
5074
|
/**
|
|
4954
5075
|
* Extracts the return value from a state's event handlers.
|
|
@@ -5165,24 +5286,19 @@ export declare namespace Machine {
|
|
|
5165
5286
|
| Effect.Services<ChoiceReturn<Config>>
|
|
5166
5287
|
| InvokeRequirements<Config>
|
|
5167
5288
|
|
|
5168
|
-
/** Type evidence retained by
|
|
5289
|
+
/** Type evidence retained by an authored transition without affecting runtime data. */
|
|
5169
5290
|
export interface TransitionTyped<
|
|
5170
5291
|
States extends StateSchemas,
|
|
5171
5292
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5172
5293
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5173
5294
|
StateId extends StateNodeIdentifier<States>,
|
|
5174
5295
|
Context,
|
|
5175
|
-
Reenter extends boolean
|
|
5296
|
+
Reenter extends boolean,
|
|
5297
|
+
Acceptance extends TransitionAcceptance = "required"
|
|
5176
5298
|
> {
|
|
5177
5299
|
readonly [TransitionTypeId]: {
|
|
5178
5300
|
readonly owner: Types.Covariant<readonly [States, Events, Emits, StateId, Context]>
|
|
5179
|
-
|
|
5180
|
-
}
|
|
5181
|
-
|
|
5182
|
-
/** Type evidence for a targetless transition reusable in every owning context. */
|
|
5183
|
-
export interface TargetlessTransitionTyped {
|
|
5184
|
-
readonly [TransitionTypeId]: {
|
|
5185
|
-
readonly targetless: true
|
|
5301
|
+
readonly acceptance: Types.Covariant<Acceptance>
|
|
5186
5302
|
}
|
|
5187
5303
|
}
|
|
5188
5304
|
|
|
@@ -5193,41 +5309,9 @@ export declare namespace Machine {
|
|
|
5193
5309
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5194
5310
|
StateId extends StateNodeIdentifier<States>,
|
|
5195
5311
|
Context,
|
|
5196
|
-
Reenter extends boolean = false
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
| TransitionTyped<States, Events, Emits, StateId, Context, Reenter>
|
|
5200
|
-
| TargetlessTransitionTyped
|
|
5201
|
-
| TargetlessTransitionInput<Events, Emits, Context>
|
|
5202
|
-
)
|
|
5203
|
-
& {
|
|
5204
|
-
readonly reenter?: [Reenter] extends [true] ? boolean : never
|
|
5205
|
-
}
|
|
5206
|
-
|
|
5207
|
-
/** Direct shorthand for a non-reentering targetless transition. */
|
|
5208
|
-
// Keep the context generic so omitting `target` is deferred until a resolver
|
|
5209
|
-
// is actually authored instead of expanding every TransitionConfig eagerly.
|
|
5210
|
-
interface TargetlessTransitionResolver<
|
|
5211
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5212
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5213
|
-
Context
|
|
5214
|
-
> {
|
|
5215
|
-
<ResolvedContext extends Omit<Context, "target">>(
|
|
5216
|
-
context: ResolvedContext,
|
|
5217
|
-
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5218
|
-
): undefined
|
|
5219
|
-
}
|
|
5220
|
-
|
|
5221
|
-
export type TargetlessTransitionInput<
|
|
5222
|
-
Events extends ReadonlyArray<TaggedSchema>,
|
|
5223
|
-
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5224
|
-
Context
|
|
5225
|
-
> = {
|
|
5226
|
-
readonly target: TargetlessSelector
|
|
5227
|
-
readonly resolve?: TargetlessTransitionResolver<Events, Emits, Context>
|
|
5228
|
-
readonly branches?: never
|
|
5229
|
-
readonly reenter?: never
|
|
5230
|
-
}
|
|
5312
|
+
Reenter extends boolean = false,
|
|
5313
|
+
Acceptance extends TransitionAcceptance = "required"
|
|
5314
|
+
> = TransitionBuilderInput<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
5231
5315
|
|
|
5232
5316
|
export type SelectionBuilder<Selection> = Selection extends TargetSelection<infer Builder, any, any> ? Builder : never
|
|
5233
5317
|
export type SelectionKind<Selection> = Selection extends TargetSelection<any, any, infer Kind> ? Kind : never
|
|
@@ -5239,6 +5323,13 @@ export declare namespace Machine {
|
|
|
5239
5323
|
TargetBuilderResult<Builder>
|
|
5240
5324
|
: never
|
|
5241
5325
|
|
|
5326
|
+
type SelectionSupportsDefaultConstruction<Selection> = SelectionKind<Selection> extends "none" ? true
|
|
5327
|
+
: SelectionBuilder<Selection> extends { readonly from: (...args: infer Args) => any } ? [] extends Args ? true
|
|
5328
|
+
: false
|
|
5329
|
+
: SelectionBuilder<Selection> extends (...args: infer Args) => any ? [] extends Args ? true
|
|
5330
|
+
: false
|
|
5331
|
+
: false
|
|
5332
|
+
|
|
5242
5333
|
export type TransitionResolveContext<
|
|
5243
5334
|
Context,
|
|
5244
5335
|
Selection
|
|
@@ -5246,6 +5337,11 @@ export declare namespace Machine {
|
|
|
5246
5337
|
& Omit<Context, "target">
|
|
5247
5338
|
& (SelectionKind<Selection> extends "none" ? {} : { readonly target: SelectionBuilder<Selection> })
|
|
5248
5339
|
|
|
5340
|
+
/** Context capability available only to explicitly declinable resolvers. */
|
|
5341
|
+
export interface DeclineCapability {
|
|
5342
|
+
readonly decline: () => Declined
|
|
5343
|
+
}
|
|
5344
|
+
|
|
5249
5345
|
export type TransitionResolver<
|
|
5250
5346
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5251
5347
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
@@ -5256,20 +5352,17 @@ export declare namespace Machine {
|
|
|
5256
5352
|
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5257
5353
|
) => SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined
|
|
5258
5354
|
|
|
5259
|
-
export type
|
|
5260
|
-
States extends StateSchemas,
|
|
5355
|
+
export type DeclinableTransitionResolver<
|
|
5261
5356
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5262
5357
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5263
|
-
StateId extends StateNodeIdentifier<States>,
|
|
5264
5358
|
Context,
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
}
|
|
5359
|
+
Selection
|
|
5360
|
+
> = (
|
|
5361
|
+
context: TransitionResolveContext<Context, Selection> & DeclineCapability,
|
|
5362
|
+
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5363
|
+
) =>
|
|
5364
|
+
| (SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined)
|
|
5365
|
+
| Declined
|
|
5273
5366
|
|
|
5274
5367
|
/** One named destination declared by a branching transition. */
|
|
5275
5368
|
export interface TransitionBranchInput<
|
|
@@ -5337,308 +5430,632 @@ export declare namespace Machine {
|
|
|
5337
5430
|
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5338
5431
|
) => BranchSelectionResult<Branches>
|
|
5339
5432
|
|
|
5340
|
-
export type
|
|
5341
|
-
States extends StateSchemas,
|
|
5433
|
+
export type DeclinableTransitionBranchesResolver<
|
|
5342
5434
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5343
5435
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5344
|
-
StateId extends StateNodeIdentifier<States>,
|
|
5345
5436
|
Context,
|
|
5346
|
-
Reenter extends boolean,
|
|
5347
5437
|
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
5348
|
-
> =
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
readonly reenter?: Reenter
|
|
5438
|
+
> = (
|
|
5439
|
+
context: TransitionBranchesResolveContext<Context, Branches> & DeclineCapability,
|
|
5440
|
+
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5441
|
+
) => BranchSelectionResult<Branches> | Declined
|
|
5442
|
+
|
|
5443
|
+
/** @internal Type evidence retained by a transition authored through its bound selector. */
|
|
5444
|
+
export interface TransitionBuilderEvidence<out Result, out Acceptance extends TransitionAcceptance> {
|
|
5445
|
+
readonly [TransitionBuilderTypeId]: {
|
|
5446
|
+
readonly result: Types.Covariant<Result>
|
|
5447
|
+
readonly acceptance: Types.Covariant<Acceptance>
|
|
5448
|
+
}
|
|
5360
5449
|
}
|
|
5361
5450
|
|
|
5362
|
-
|
|
5451
|
+
type TransitionReenterOption<Reenter extends boolean> = [Reenter] extends [true] ? { readonly reenter?: boolean }
|
|
5452
|
+
: { readonly reenter?: never }
|
|
5453
|
+
|
|
5454
|
+
type TransitionRequiredOptions<Reenter extends boolean> =
|
|
5455
|
+
& TransitionReenterOption<Reenter>
|
|
5456
|
+
& { readonly declinable?: false }
|
|
5457
|
+
|
|
5458
|
+
type TransitionDeclinableOptions<Reenter extends boolean> =
|
|
5459
|
+
& TransitionReenterOption<Reenter>
|
|
5460
|
+
& { readonly declinable: true }
|
|
5461
|
+
|
|
5462
|
+
type BuiltTransition<
|
|
5363
5463
|
States extends StateSchemas,
|
|
5364
5464
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5365
5465
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5366
5466
|
StateId extends StateNodeIdentifier<States>,
|
|
5367
|
-
Context
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5467
|
+
Context,
|
|
5468
|
+
Reenter extends boolean,
|
|
5469
|
+
Result,
|
|
5470
|
+
Acceptance extends TransitionAcceptance
|
|
5471
|
+
> =
|
|
5472
|
+
& TransitionTyped<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
5473
|
+
& TransitionBuilderEvidence<Result, Acceptance>
|
|
5371
5474
|
|
|
5372
|
-
|
|
5373
|
-
export interface InvokeOwned<
|
|
5475
|
+
interface TransitionResolveRequired<
|
|
5374
5476
|
States extends StateSchemas,
|
|
5375
5477
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5376
5478
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5377
|
-
StateId extends
|
|
5479
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5480
|
+
Context,
|
|
5481
|
+
Reenter extends boolean,
|
|
5482
|
+
Selection extends TargetSelection<any, any, any>
|
|
5378
5483
|
> {
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5484
|
+
(
|
|
5485
|
+
resolve: TransitionResolver<Events, Emits, Context, Selection>,
|
|
5486
|
+
options?: TransitionRequiredOptions<Reenter>
|
|
5487
|
+
): BuiltTransition<
|
|
5488
|
+
States,
|
|
5489
|
+
Events,
|
|
5490
|
+
Emits,
|
|
5491
|
+
StateId,
|
|
5492
|
+
Context,
|
|
5493
|
+
Reenter,
|
|
5494
|
+
SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined,
|
|
5495
|
+
"required"
|
|
5496
|
+
>
|
|
5392
5497
|
}
|
|
5393
5498
|
|
|
5394
|
-
|
|
5499
|
+
interface TransitionResolveDeclinable<
|
|
5395
5500
|
States extends StateSchemas,
|
|
5396
5501
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5397
5502
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5398
|
-
StateId extends
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
}
|
|
5419
|
-
| {
|
|
5420
|
-
readonly id: string
|
|
5421
|
-
readonly stream: (
|
|
5422
|
-
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5423
|
-
) => Stream.Stream<any, any, any>
|
|
5424
|
-
readonly effect?: never
|
|
5425
|
-
readonly after?: never
|
|
5426
|
-
readonly logic?: never
|
|
5427
|
-
readonly child?: never
|
|
5428
|
-
readonly address?: never
|
|
5429
|
-
readonly onElement?: unknown
|
|
5430
|
-
readonly onDone: unknown
|
|
5431
|
-
readonly onFailure?: unknown
|
|
5432
|
-
readonly onSnapshot?: never
|
|
5433
|
-
}
|
|
5434
|
-
| {
|
|
5435
|
-
readonly id: string
|
|
5436
|
-
readonly after: InvokeSource<
|
|
5437
|
-
Duration.Input,
|
|
5438
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5439
|
-
>
|
|
5440
|
-
readonly effect?: never
|
|
5441
|
-
readonly stream?: never
|
|
5442
|
-
readonly logic?: never
|
|
5443
|
-
readonly child?: never
|
|
5444
|
-
readonly address?: never
|
|
5445
|
-
readonly onDone: unknown
|
|
5446
|
-
readonly onFailure?: never
|
|
5447
|
-
readonly onElement?: never
|
|
5448
|
-
readonly onSnapshot?: never
|
|
5449
|
-
}
|
|
5450
|
-
| {
|
|
5451
|
-
readonly id: string
|
|
5452
|
-
readonly address: string
|
|
5453
|
-
readonly logic: InvokeSource<
|
|
5454
|
-
Logic<any, any, any, any, any, any>,
|
|
5455
|
-
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5456
|
-
>
|
|
5457
|
-
readonly effect?: never
|
|
5458
|
-
readonly stream?: never
|
|
5459
|
-
readonly after?: never
|
|
5460
|
-
readonly child?: never
|
|
5461
|
-
readonly onDone?: unknown
|
|
5462
|
-
readonly onFailure?: unknown
|
|
5463
|
-
readonly onElement?: never
|
|
5464
|
-
readonly onSnapshot?: unknown
|
|
5465
|
-
}
|
|
5466
|
-
| {
|
|
5467
|
-
readonly child: ChildMachine.Any
|
|
5468
|
-
readonly input?:
|
|
5469
|
-
| {}
|
|
5470
|
-
| null
|
|
5471
|
-
| ((context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
5472
|
-
readonly id?: never
|
|
5473
|
-
readonly address?: never
|
|
5474
|
-
readonly effect?: never
|
|
5475
|
-
readonly stream?: never
|
|
5476
|
-
readonly after?: never
|
|
5477
|
-
readonly logic?: never
|
|
5478
|
-
readonly onDone?: unknown
|
|
5479
|
-
readonly onFailure?: unknown
|
|
5480
|
-
readonly onElement?: never
|
|
5481
|
-
readonly onSnapshot?: unknown
|
|
5482
|
-
}
|
|
5483
|
-
)
|
|
5503
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5504
|
+
Context,
|
|
5505
|
+
Reenter extends boolean,
|
|
5506
|
+
Selection extends TargetSelection<any, any, any>
|
|
5507
|
+
> {
|
|
5508
|
+
(
|
|
5509
|
+
resolve: DeclinableTransitionResolver<Events, Emits, Context, Selection>,
|
|
5510
|
+
options: TransitionDeclinableOptions<Reenter>
|
|
5511
|
+
): BuiltTransition<
|
|
5512
|
+
States,
|
|
5513
|
+
Events,
|
|
5514
|
+
Emits,
|
|
5515
|
+
StateId,
|
|
5516
|
+
Context,
|
|
5517
|
+
Reenter,
|
|
5518
|
+
| (SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined)
|
|
5519
|
+
| Declined,
|
|
5520
|
+
"declinable"
|
|
5521
|
+
>
|
|
5522
|
+
}
|
|
5484
5523
|
|
|
5485
|
-
/**
|
|
5486
|
-
export type
|
|
5524
|
+
/** A selected transition target with target-specific resolver operations. */
|
|
5525
|
+
export type TransitionTarget<
|
|
5487
5526
|
States extends StateSchemas,
|
|
5488
5527
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5489
5528
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5490
|
-
StateId extends
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5529
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5530
|
+
Context,
|
|
5531
|
+
Reenter extends boolean,
|
|
5532
|
+
Acceptance extends TransitionAcceptance,
|
|
5533
|
+
Selection extends TargetSelection<any, any, any>
|
|
5534
|
+
> =
|
|
5535
|
+
& Selection
|
|
5536
|
+
& (SelectionSupportsDefaultConstruction<Selection> extends true ? BuiltTransition<
|
|
5537
|
+
States,
|
|
5538
|
+
Events,
|
|
5539
|
+
Emits,
|
|
5540
|
+
StateId,
|
|
5541
|
+
Context,
|
|
5542
|
+
Reenter,
|
|
5543
|
+
SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined,
|
|
5544
|
+
"required"
|
|
5545
|
+
>
|
|
5546
|
+
: {})
|
|
5547
|
+
& {
|
|
5548
|
+
readonly resolve:
|
|
5549
|
+
& TransitionResolveRequired<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
5550
|
+
& ("declinable" extends Acceptance ? TransitionResolveDeclinable<
|
|
5551
|
+
States,
|
|
5552
|
+
Events,
|
|
5553
|
+
Emits,
|
|
5554
|
+
StateId,
|
|
5555
|
+
Context,
|
|
5556
|
+
Reenter,
|
|
5557
|
+
Selection
|
|
5558
|
+
>
|
|
5559
|
+
: {})
|
|
5560
|
+
}
|
|
5561
|
+
& ([Reenter] extends [true] ? SelectionSupportsDefaultConstruction<Selection> extends true ? {
|
|
5562
|
+
readonly reenter: () => BuiltTransition<
|
|
5563
|
+
States,
|
|
5564
|
+
Events,
|
|
5565
|
+
Emits,
|
|
5566
|
+
StateId,
|
|
5567
|
+
Context,
|
|
5568
|
+
Reenter,
|
|
5569
|
+
SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined,
|
|
5570
|
+
"required"
|
|
5571
|
+
>
|
|
5572
|
+
}
|
|
5573
|
+
: {}
|
|
5574
|
+
: {})
|
|
5496
5575
|
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5576
|
+
/** @internal Type evidence retained by a machine initial-entry declaration. */
|
|
5577
|
+
export interface InitialBuilderEvidence<out Selection> {
|
|
5578
|
+
readonly [InitialBuilderTypeId]: Types.Covariant<Selection>
|
|
5579
|
+
}
|
|
5500
5580
|
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5581
|
+
/** A selected machine initial entry with its exact resolver target. */
|
|
5582
|
+
export type InitialTransitionTarget<Input, Selection extends TargetSelection<any, any, any>> =
|
|
5583
|
+
& Selection
|
|
5584
|
+
& (SelectionSupportsDefaultConstruction<Selection> extends true ? InitialBuilderEvidence<Selection> : {})
|
|
5585
|
+
& {
|
|
5586
|
+
readonly resolve: (
|
|
5587
|
+
resolve: (context: {
|
|
5588
|
+
readonly input: Input
|
|
5589
|
+
readonly target: SelectionBuilder<Selection>
|
|
5590
|
+
}) => SelectedTargetResult<Selection>
|
|
5591
|
+
) => InitialBuilderEvidence<Selection>
|
|
5592
|
+
}
|
|
5504
5593
|
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5594
|
+
type InitialSelectorNode<Input, Node> = Node extends (...args: infer Args) => infer Selection ?
|
|
5595
|
+
Selection extends TargetSelection<any, any, any> ?
|
|
5596
|
+
& ((...args: Args) => InitialTransitionTarget<Input, Selection>)
|
|
5597
|
+
& {
|
|
5598
|
+
readonly [Key in keyof Node]: InitialSelectorNode<Input, Node[Key]>
|
|
5599
|
+
}
|
|
5508
5600
|
: never
|
|
5601
|
+
: Node extends TargetSelection<any, any, any> ? InitialTransitionTarget<Input, Node>
|
|
5602
|
+
: {
|
|
5603
|
+
readonly [Key in keyof Node]: InitialSelectorNode<Input, Node[Key]>
|
|
5604
|
+
}
|
|
5509
5605
|
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5606
|
+
/** Definition-time selector for a machine's top-level initial entry. */
|
|
5607
|
+
export type InitialSelector<States extends StateSchemas, Input = void> = InitialSelectorNode<
|
|
5608
|
+
Input,
|
|
5609
|
+
InitialTargetSelector<States>
|
|
5610
|
+
>
|
|
5514
5611
|
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
:
|
|
5612
|
+
/** Target-first initial-entry declaration accepted by {@link make}. */
|
|
5613
|
+
export type InitialBuilderInput<States extends StateSchemas, Input> = (
|
|
5614
|
+
to: InitialSelector<States, Input>
|
|
5615
|
+
) => InitialBuilderEvidence<TargetSelection<any, any, any>>
|
|
5616
|
+
|
|
5617
|
+
type TransitionSelectorNode<
|
|
5618
|
+
States extends StateSchemas,
|
|
5619
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5620
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5621
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5622
|
+
Context,
|
|
5623
|
+
Reenter extends boolean,
|
|
5624
|
+
Acceptance extends TransitionAcceptance,
|
|
5625
|
+
Node
|
|
5626
|
+
> = Node extends (...args: infer Args) => infer Selection ? Selection extends TargetSelection<any, any, any> ?
|
|
5627
|
+
& ((...args: Args) => TransitionTarget<
|
|
5628
|
+
States,
|
|
5629
|
+
Events,
|
|
5630
|
+
Emits,
|
|
5631
|
+
StateId,
|
|
5632
|
+
Context,
|
|
5633
|
+
Reenter,
|
|
5634
|
+
Acceptance,
|
|
5635
|
+
Selection
|
|
5636
|
+
>)
|
|
5637
|
+
& {
|
|
5638
|
+
readonly [Key in keyof Node]: TransitionSelectorNode<
|
|
5639
|
+
States,
|
|
5640
|
+
Events,
|
|
5641
|
+
Emits,
|
|
5642
|
+
StateId,
|
|
5643
|
+
Context,
|
|
5644
|
+
Reenter,
|
|
5645
|
+
Acceptance,
|
|
5646
|
+
Node[Key]
|
|
5647
|
+
>
|
|
5648
|
+
}
|
|
5518
5649
|
: never
|
|
5650
|
+
: Node extends TargetSelection<any, any, any> ? TransitionTarget<
|
|
5651
|
+
States,
|
|
5652
|
+
Events,
|
|
5653
|
+
Emits,
|
|
5654
|
+
StateId,
|
|
5655
|
+
Context,
|
|
5656
|
+
Reenter,
|
|
5657
|
+
Acceptance,
|
|
5658
|
+
Node
|
|
5659
|
+
>
|
|
5660
|
+
: {
|
|
5661
|
+
readonly [Key in keyof Node]: TransitionSelectorNode<
|
|
5662
|
+
States,
|
|
5663
|
+
Events,
|
|
5664
|
+
Emits,
|
|
5665
|
+
StateId,
|
|
5666
|
+
Context,
|
|
5667
|
+
Reenter,
|
|
5668
|
+
Acceptance,
|
|
5669
|
+
Node[Key]
|
|
5670
|
+
>
|
|
5671
|
+
}
|
|
5519
5672
|
|
|
5520
|
-
|
|
5673
|
+
interface TransitionBranchesResolveRequired<
|
|
5521
5674
|
States extends StateSchemas,
|
|
5522
5675
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5523
5676
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5524
|
-
StateId extends
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5677
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5678
|
+
Context,
|
|
5679
|
+
Reenter extends boolean,
|
|
5680
|
+
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
5681
|
+
> {
|
|
5682
|
+
(
|
|
5683
|
+
resolve: TransitionBranchesResolver<Events, Emits, Context, Branches>,
|
|
5684
|
+
options?: TransitionRequiredOptions<Reenter>
|
|
5685
|
+
): BuiltTransition<
|
|
5686
|
+
States,
|
|
5687
|
+
Events,
|
|
5688
|
+
Emits,
|
|
5689
|
+
StateId,
|
|
5690
|
+
Context,
|
|
5691
|
+
Reenter,
|
|
5692
|
+
BranchSelectionResult<Branches>,
|
|
5693
|
+
"required"
|
|
5532
5694
|
>
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5695
|
+
}
|
|
5696
|
+
|
|
5697
|
+
interface TransitionBranchesResolveDeclinable<
|
|
5698
|
+
States extends StateSchemas,
|
|
5699
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5700
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5701
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5702
|
+
Context,
|
|
5703
|
+
Reenter extends boolean,
|
|
5704
|
+
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
5705
|
+
> {
|
|
5706
|
+
(
|
|
5707
|
+
resolve: DeclinableTransitionBranchesResolver<Events, Emits, Context, Branches>,
|
|
5708
|
+
options: TransitionDeclinableOptions<Reenter>
|
|
5709
|
+
): BuiltTransition<
|
|
5542
5710
|
States,
|
|
5543
5711
|
Events,
|
|
5544
5712
|
Emits,
|
|
5545
5713
|
StateId,
|
|
5546
|
-
|
|
5714
|
+
Context,
|
|
5715
|
+
Reenter,
|
|
5716
|
+
BranchSelectionResult<Branches> | Declined,
|
|
5717
|
+
"declinable"
|
|
5547
5718
|
>
|
|
5548
5719
|
}
|
|
5549
5720
|
|
|
5550
|
-
|
|
5721
|
+
/** Selector supplied to inline transition declarations. */
|
|
5722
|
+
export type TransitionSelector<
|
|
5551
5723
|
States extends StateSchemas,
|
|
5552
5724
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5553
5725
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5554
|
-
StateId extends
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
ChildRequirements,
|
|
5559
|
-
ChildOutput,
|
|
5560
|
-
ChildInitialError,
|
|
5561
|
-
Address extends ChildAddress<never>,
|
|
5562
|
-
Source = Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>,
|
|
5563
|
-
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5564
|
-
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5726
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5727
|
+
Context,
|
|
5728
|
+
Reenter extends boolean,
|
|
5729
|
+
Acceptance extends TransitionAcceptance
|
|
5565
5730
|
> =
|
|
5731
|
+
& TransitionSelectorNode<
|
|
5732
|
+
States,
|
|
5733
|
+
Events,
|
|
5734
|
+
Emits,
|
|
5735
|
+
StateId,
|
|
5736
|
+
Context,
|
|
5737
|
+
Reenter,
|
|
5738
|
+
Acceptance,
|
|
5739
|
+
TargetSelector<States, StateId>
|
|
5740
|
+
>
|
|
5566
5741
|
& {
|
|
5567
|
-
readonly
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
Emits,
|
|
5584
|
-
StateId,
|
|
5585
|
-
NoInfer<ChildState>,
|
|
5586
|
-
NoInfer<ChildError>,
|
|
5587
|
-
NoInfer<ChildOutput>,
|
|
5588
|
-
InputEvents,
|
|
5589
|
-
ParentEvents
|
|
5590
|
-
>
|
|
5591
|
-
>
|
|
5742
|
+
readonly branches: <const Branches extends Readonly<Record<string, TransitionBranchInput>>>(
|
|
5743
|
+
branches: Branches & ValidateTransitionBranchRecord<NoInfer<Branches>>
|
|
5744
|
+
) => {
|
|
5745
|
+
readonly resolve:
|
|
5746
|
+
& TransitionBranchesResolveRequired<States, Events, Emits, StateId, Context, Reenter, Branches>
|
|
5747
|
+
& ("declinable" extends Acceptance ? TransitionBranchesResolveDeclinable<
|
|
5748
|
+
States,
|
|
5749
|
+
Events,
|
|
5750
|
+
Emits,
|
|
5751
|
+
StateId,
|
|
5752
|
+
Context,
|
|
5753
|
+
Reenter,
|
|
5754
|
+
Branches
|
|
5755
|
+
>
|
|
5756
|
+
: {})
|
|
5757
|
+
}
|
|
5592
5758
|
}
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5759
|
+
|
|
5760
|
+
/** Inline transition declaration accepted by state and invocation handlers. */
|
|
5761
|
+
export type TransitionBuilderInput<
|
|
5762
|
+
States extends StateSchemas,
|
|
5763
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5764
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5765
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5766
|
+
Context,
|
|
5767
|
+
Reenter extends boolean,
|
|
5768
|
+
Acceptance extends TransitionAcceptance
|
|
5769
|
+
> = (
|
|
5770
|
+
to: TransitionSelector<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
5771
|
+
) =>
|
|
5772
|
+
& TransitionTyped<States, Events, Emits, StateId, Context, Reenter, Acceptance>
|
|
5773
|
+
& TransitionBuilderEvidence<any, Acceptance>
|
|
5774
|
+
|
|
5775
|
+
export type InvokeTransition<
|
|
5776
|
+
States extends StateSchemas,
|
|
5777
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5778
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5779
|
+
StateId extends StateNodeIdentifier<States>,
|
|
5780
|
+
Context
|
|
5781
|
+
> = TransitionConfig<States, Events, Emits, StateId, Context, true, TransitionAcceptance>
|
|
5782
|
+
|
|
5783
|
+
export type InvokeSource<Value, Context> = Value | ((context: Context) => Value)
|
|
5784
|
+
|
|
5785
|
+
/** Inline state-owned work that runs for the lifetime of its active state. */
|
|
5786
|
+
export interface InvokeOwned<
|
|
5787
|
+
States extends StateSchemas,
|
|
5788
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5789
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5790
|
+
StateId extends StateIdentifier<States>,
|
|
5791
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5792
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5793
|
+
> {
|
|
5794
|
+
readonly "~effect/Machine/InvokeOwner"?: Types.Covariant<
|
|
5795
|
+
readonly [States, Events, Emits, StateId, InputEvents, ParentEvents]
|
|
5612
5796
|
>
|
|
5797
|
+
}
|
|
5613
5798
|
|
|
5614
|
-
|
|
5799
|
+
/** Type evidence retained by {@link invoke} without affecting runtime data. */
|
|
5800
|
+
export interface InvokeTyped<Output, Error, Requirements, InitialError, Emits = never, ParentEvent = never> {
|
|
5801
|
+
readonly [InvokeTypeId]: {
|
|
5802
|
+
readonly output: Types.Covariant<Output>
|
|
5803
|
+
readonly error: Types.Covariant<Error>
|
|
5804
|
+
readonly requirements: Types.Covariant<Requirements>
|
|
5805
|
+
readonly initialError: Types.Covariant<InitialError>
|
|
5806
|
+
readonly emits: Types.Covariant<Emits>
|
|
5807
|
+
readonly parentEvents: Types.Covariant<ParentEvent>
|
|
5808
|
+
}
|
|
5809
|
+
}
|
|
5810
|
+
|
|
5811
|
+
export type InvokeConfig<
|
|
5615
5812
|
States extends StateSchemas,
|
|
5616
5813
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5617
5814
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5618
5815
|
StateId extends StateIdentifier<States>,
|
|
5619
|
-
ChildDefinition extends Machine.Any,
|
|
5620
|
-
Child extends ChildMachine<string, ChildDefinition>,
|
|
5621
5816
|
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5622
5817
|
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5623
5818
|
> =
|
|
5624
|
-
&
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5819
|
+
& InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5820
|
+
& (
|
|
5821
|
+
| {
|
|
5822
|
+
readonly id: string
|
|
5823
|
+
readonly effect: (
|
|
5824
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5825
|
+
) => Effect.Effect<any, any, any>
|
|
5826
|
+
readonly stream?: never
|
|
5827
|
+
readonly after?: never
|
|
5828
|
+
readonly logic?: never
|
|
5829
|
+
readonly child?: never
|
|
5830
|
+
readonly address?: never
|
|
5831
|
+
readonly onDone?: unknown
|
|
5832
|
+
readonly onFailure?: unknown
|
|
5833
|
+
readonly onElement?: never
|
|
5834
|
+
readonly onSnapshot?: never
|
|
5835
|
+
}
|
|
5836
|
+
| {
|
|
5837
|
+
readonly id: string
|
|
5838
|
+
readonly stream: (
|
|
5839
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5840
|
+
) => Stream.Stream<any, any, any>
|
|
5841
|
+
readonly effect?: never
|
|
5842
|
+
readonly after?: never
|
|
5843
|
+
readonly logic?: never
|
|
5844
|
+
readonly child?: never
|
|
5845
|
+
readonly address?: never
|
|
5846
|
+
readonly onElement?: unknown
|
|
5847
|
+
readonly onDone: unknown
|
|
5848
|
+
readonly onFailure?: unknown
|
|
5849
|
+
readonly onSnapshot?: never
|
|
5850
|
+
}
|
|
5851
|
+
| {
|
|
5852
|
+
readonly id: string
|
|
5853
|
+
readonly after: InvokeSource<
|
|
5854
|
+
Duration.Input,
|
|
5855
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5856
|
+
>
|
|
5857
|
+
readonly effect?: never
|
|
5858
|
+
readonly stream?: never
|
|
5859
|
+
readonly logic?: never
|
|
5860
|
+
readonly child?: never
|
|
5861
|
+
readonly address?: never
|
|
5862
|
+
readonly onDone: unknown
|
|
5863
|
+
readonly onFailure?: never
|
|
5864
|
+
readonly onElement?: never
|
|
5865
|
+
readonly onSnapshot?: never
|
|
5866
|
+
}
|
|
5867
|
+
| {
|
|
5868
|
+
readonly id: string
|
|
5869
|
+
readonly address: string
|
|
5870
|
+
readonly logic: InvokeSource<
|
|
5871
|
+
Logic<any, any, any, any, any, any>,
|
|
5872
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5873
|
+
>
|
|
5874
|
+
readonly effect?: never
|
|
5875
|
+
readonly stream?: never
|
|
5876
|
+
readonly after?: never
|
|
5877
|
+
readonly child?: never
|
|
5878
|
+
readonly onDone?: unknown
|
|
5879
|
+
readonly onFailure?: unknown
|
|
5880
|
+
readonly onElement?: never
|
|
5881
|
+
readonly onSnapshot?: unknown
|
|
5882
|
+
}
|
|
5883
|
+
| {
|
|
5884
|
+
readonly child: ChildMachine.Any
|
|
5885
|
+
readonly input?:
|
|
5886
|
+
| {}
|
|
5887
|
+
| null
|
|
5888
|
+
| ((context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
5889
|
+
readonly id?: never
|
|
5890
|
+
readonly address?: never
|
|
5891
|
+
readonly effect?: never
|
|
5892
|
+
readonly stream?: never
|
|
5893
|
+
readonly after?: never
|
|
5894
|
+
readonly logic?: never
|
|
5895
|
+
readonly onDone?: unknown
|
|
5896
|
+
readonly onFailure?: unknown
|
|
5897
|
+
readonly onElement?: never
|
|
5898
|
+
readonly onSnapshot?: unknown
|
|
5899
|
+
}
|
|
5900
|
+
)
|
|
5901
|
+
|
|
5902
|
+
/** State-bound inline invocation configuration. */
|
|
5903
|
+
export type InvokeDefinition<
|
|
5904
|
+
States extends StateSchemas,
|
|
5905
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5906
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5907
|
+
StateId extends StateIdentifier<States>,
|
|
5908
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5909
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5910
|
+
> =
|
|
5911
|
+
| InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5912
|
+
| ReadonlyArray<InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>>
|
|
5913
|
+
|
|
5914
|
+
type TypedInvokeDefinition =
|
|
5915
|
+
| InvokeTyped<any, any, any, any, any, any>
|
|
5916
|
+
| ReadonlyArray<InvokeTyped<any, any, any, any, any, any>>
|
|
5917
|
+
|
|
5918
|
+
type InvokeHandlerRequirement<Value, Handler> = IsAny<Value> extends true ? { readonly handler: Handler }
|
|
5919
|
+
: [Value] extends [never] ? { readonly handler?: never }
|
|
5920
|
+
: { readonly handler: Handler }
|
|
5921
|
+
|
|
5922
|
+
export type InvokeDoneRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends
|
|
5923
|
+
infer Requirement ? Requirement extends { readonly handler: infer Required } ? { readonly onDone: Required }
|
|
5924
|
+
: { readonly onDone?: never }
|
|
5925
|
+
: never
|
|
5926
|
+
|
|
5927
|
+
export type InvokeFailureRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends
|
|
5928
|
+
infer Requirement ? Requirement extends { readonly handler: infer Required } ? { readonly onFailure: Required }
|
|
5929
|
+
: { readonly onFailure?: never }
|
|
5930
|
+
: never
|
|
5931
|
+
|
|
5932
|
+
export type InvokeElementRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends
|
|
5933
|
+
infer Requirement ? Requirement extends { readonly handler: infer Required } ? { readonly onElement: Required }
|
|
5934
|
+
: { readonly onElement?: never }
|
|
5935
|
+
: never
|
|
5936
|
+
|
|
5937
|
+
export type TimerInvokeArgs<
|
|
5938
|
+
States extends StateSchemas,
|
|
5939
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5940
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5941
|
+
StateId extends StateIdentifier<States>,
|
|
5942
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5943
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5944
|
+
> = {
|
|
5945
|
+
readonly id: InvokeLifecycleId
|
|
5946
|
+
readonly after: InvokeSource<
|
|
5947
|
+
Duration.Input,
|
|
5948
|
+
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5949
|
+
>
|
|
5950
|
+
readonly effect?: never
|
|
5951
|
+
readonly stream?: never
|
|
5952
|
+
readonly logic?: never
|
|
5953
|
+
readonly child?: never
|
|
5954
|
+
readonly address?: never
|
|
5955
|
+
readonly onFailure?: never
|
|
5956
|
+
readonly onElement?: never
|
|
5957
|
+
readonly onSnapshot?: never
|
|
5958
|
+
readonly onDone: InvokeTransition<
|
|
5959
|
+
States,
|
|
5960
|
+
Events,
|
|
5961
|
+
Emits,
|
|
5962
|
+
StateId,
|
|
5963
|
+
InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
5964
|
+
>
|
|
5965
|
+
}
|
|
5966
|
+
|
|
5967
|
+
export type LogicInvokeArgs<
|
|
5968
|
+
States extends StateSchemas,
|
|
5969
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5970
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5971
|
+
StateId extends StateIdentifier<States>,
|
|
5972
|
+
ChildState,
|
|
5973
|
+
ChildEvent,
|
|
5974
|
+
ChildError,
|
|
5975
|
+
ChildRequirements,
|
|
5976
|
+
ChildOutput,
|
|
5977
|
+
ChildInitialError,
|
|
5978
|
+
Address extends ChildAddress<never>,
|
|
5979
|
+
Source = Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>,
|
|
5980
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
5981
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
5982
|
+
> =
|
|
5983
|
+
& {
|
|
5984
|
+
readonly id: InvokeLifecycleId
|
|
5985
|
+
readonly address: Address & ChildAddress.Compatibility<Address, ChildEvent>
|
|
5986
|
+
readonly logic: Source
|
|
5987
|
+
readonly effect?: never
|
|
5988
|
+
readonly stream?: never
|
|
5989
|
+
readonly after?: never
|
|
5990
|
+
readonly child?: never
|
|
5991
|
+
readonly onElement?: never
|
|
5992
|
+
readonly onSnapshot?: InvokeTransition<
|
|
5993
|
+
States,
|
|
5994
|
+
Events,
|
|
5995
|
+
Emits,
|
|
5996
|
+
StateId,
|
|
5997
|
+
InvokeSnapshotContext<
|
|
5998
|
+
States,
|
|
5999
|
+
Events,
|
|
6000
|
+
Emits,
|
|
6001
|
+
StateId,
|
|
6002
|
+
NoInfer<ChildState>,
|
|
6003
|
+
NoInfer<ChildError>,
|
|
6004
|
+
NoInfer<ChildOutput>,
|
|
6005
|
+
InputEvents,
|
|
6006
|
+
ParentEvents
|
|
6007
|
+
>
|
|
6008
|
+
>
|
|
6009
|
+
}
|
|
6010
|
+
& InvokeDoneRequirement<
|
|
6011
|
+
NoInfer<ChildOutput>,
|
|
6012
|
+
InvokeTransition<
|
|
6013
|
+
States,
|
|
6014
|
+
Events,
|
|
6015
|
+
Emits,
|
|
6016
|
+
StateId,
|
|
6017
|
+
InvokeDoneContext<States, Events, Emits, StateId, NoInfer<ChildOutput>, InputEvents, ParentEvents>
|
|
6018
|
+
>
|
|
6019
|
+
>
|
|
6020
|
+
& InvokeFailureRequirement<
|
|
6021
|
+
NoInfer<ChildError>,
|
|
6022
|
+
InvokeTransition<
|
|
6023
|
+
States,
|
|
6024
|
+
Events,
|
|
6025
|
+
Emits,
|
|
6026
|
+
StateId,
|
|
6027
|
+
InvokeFailureContext<States, Events, Emits, StateId, NoInfer<ChildError>, InputEvents, ParentEvents>
|
|
6028
|
+
>
|
|
6029
|
+
>
|
|
6030
|
+
|
|
6031
|
+
export type ChildInvokeArgs<
|
|
6032
|
+
States extends StateSchemas,
|
|
6033
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
6034
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
6035
|
+
StateId extends StateIdentifier<States>,
|
|
6036
|
+
ChildDefinition extends Machine.Any,
|
|
6037
|
+
Child extends ChildMachine<string, ChildDefinition>,
|
|
6038
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
6039
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
6040
|
+
> =
|
|
6041
|
+
& {
|
|
6042
|
+
readonly child:
|
|
6043
|
+
& Child
|
|
6044
|
+
& (ChildDefinition extends EnsureExecutable<
|
|
6045
|
+
Machine.States<ChildDefinition>,
|
|
6046
|
+
Machine.UnhandledStates<ChildDefinition>,
|
|
6047
|
+
Machine.OutputStates<ChildDefinition>
|
|
6048
|
+
> ? unknown :
|
|
6049
|
+
never)
|
|
6050
|
+
readonly id?: never
|
|
6051
|
+
readonly address?: never
|
|
6052
|
+
readonly effect?: never
|
|
6053
|
+
readonly stream?: never
|
|
6054
|
+
readonly after?: never
|
|
6055
|
+
readonly logic?: never
|
|
6056
|
+
readonly onElement?: never
|
|
6057
|
+
readonly onSnapshot?: InvokeTransition<
|
|
6058
|
+
States,
|
|
5642
6059
|
Events,
|
|
5643
6060
|
Emits,
|
|
5644
6061
|
StateId,
|
|
@@ -5726,6 +6143,7 @@ export declare namespace Machine {
|
|
|
5726
6143
|
ParentEvents extends ReadonlyArray<TaggedSchema>,
|
|
5727
6144
|
Raw
|
|
5728
6145
|
> = Raw extends InvokeTyped<any, any, any, any, any> ? unknown
|
|
6146
|
+
: [Extract<keyof Raw, "onDone" | "onFailure" | "onElement" | "onSnapshot">] extends [never] ? unknown
|
|
5729
6147
|
: Raw extends { readonly effect: infer Source } ?
|
|
5730
6148
|
InvokeFactoryResult<Source> extends infer Fx extends Effect.Effect<any, any, any> ?
|
|
5731
6149
|
& InvokeDoneRequirement<
|
|
@@ -6011,14 +6429,18 @@ export declare namespace Machine {
|
|
|
6011
6429
|
Events,
|
|
6012
6430
|
Emits,
|
|
6013
6431
|
StateId,
|
|
6014
|
-
AlwaysContext<States, Events, Emits, StateId, InputEvents, ParentEvents
|
|
6432
|
+
AlwaysContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
6433
|
+
false,
|
|
6434
|
+
TransitionAcceptance
|
|
6015
6435
|
>
|
|
6016
6436
|
readonly onDone?: TransitionConfig<
|
|
6017
6437
|
States,
|
|
6018
6438
|
Events,
|
|
6019
6439
|
Emits,
|
|
6020
6440
|
StateId,
|
|
6021
|
-
DoneContext<States, Events, Emits, StateId, InputEvents, ParentEvents
|
|
6441
|
+
DoneContext<States, Events, Emits, StateId, InputEvents, ParentEvents>,
|
|
6442
|
+
false,
|
|
6443
|
+
TransitionAcceptance
|
|
6022
6444
|
>
|
|
6023
6445
|
readonly on?: {
|
|
6024
6446
|
readonly [EventTag in TagOf<Events[number]>]?: TransitionConfig<
|
|
@@ -6027,7 +6449,8 @@ export declare namespace Machine {
|
|
|
6027
6449
|
Emits,
|
|
6028
6450
|
StateId,
|
|
6029
6451
|
HandlerContext<States, Events, Emits, StateId, EventTag, E, R, InputEvents, ParentEvents>,
|
|
6030
|
-
true
|
|
6452
|
+
true,
|
|
6453
|
+
TransitionAcceptance
|
|
6031
6454
|
>
|
|
6032
6455
|
}
|
|
6033
6456
|
readonly initialize?: StateInitializeHandler<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
@@ -7022,7 +7445,8 @@ export declare namespace Machine {
|
|
|
7022
7445
|
Emits,
|
|
7023
7446
|
StateId,
|
|
7024
7447
|
HandlerContext<States, Events, Emits, StateId, EventTag, E, R>,
|
|
7025
|
-
true
|
|
7448
|
+
true,
|
|
7449
|
+
TransitionAcceptance
|
|
7026
7450
|
>
|
|
7027
7451
|
>
|
|
7028
7452
|
>
|
|
@@ -7056,14 +7480,18 @@ export declare namespace Machine {
|
|
|
7056
7480
|
Events,
|
|
7057
7481
|
Emits,
|
|
7058
7482
|
StateId,
|
|
7059
|
-
AlwaysContext<States, Events, Emits, StateId
|
|
7483
|
+
AlwaysContext<States, Events, Emits, StateId>,
|
|
7484
|
+
false,
|
|
7485
|
+
TransitionAcceptance
|
|
7060
7486
|
>
|
|
7061
7487
|
readonly onDone?: TransitionConfig<
|
|
7062
7488
|
States,
|
|
7063
7489
|
Events,
|
|
7064
7490
|
Emits,
|
|
7065
7491
|
StateId,
|
|
7066
|
-
DoneContext<States, Events, Emits, StateId
|
|
7492
|
+
DoneContext<States, Events, Emits, StateId>,
|
|
7493
|
+
false,
|
|
7494
|
+
TransitionAcceptance
|
|
7067
7495
|
>
|
|
7068
7496
|
readonly output?:
|
|
7069
7497
|
| ((context: FinalOutputContext<States, Events, StateId>) => unknown)
|
|
@@ -7220,10 +7648,7 @@ export const state: StateConstructor = internal.state as StateConstructor
|
|
|
7220
7648
|
* Machine.make({
|
|
7221
7649
|
* states: States.states,
|
|
7222
7650
|
* events: Machine.events(),
|
|
7223
|
-
* initial: {
|
|
7224
|
-
* target: (to) => to.idle(),
|
|
7225
|
-
* resolve: ({ target }) => target.from()
|
|
7226
|
-
* }
|
|
7651
|
+
* initial: (to) => to.idle().resolve(({ target }) => target.from())
|
|
7227
7652
|
* })
|
|
7228
7653
|
* ```
|
|
7229
7654
|
*
|
|
@@ -7232,20 +7657,6 @@ export const state: StateConstructor = internal.state as StateConstructor
|
|
|
7232
7657
|
*/
|
|
7233
7658
|
export const states: StatesConstructor = internal.states
|
|
7234
7659
|
|
|
7235
|
-
type InitialDirectInput<
|
|
7236
|
-
States extends Machine.StateSchemas,
|
|
7237
|
-
Input,
|
|
7238
|
-
Selection extends Machine.TargetSelection<any, any, any>
|
|
7239
|
-
> = {
|
|
7240
|
-
readonly target: (to: Machine.InitialSelector<States>) => Selection
|
|
7241
|
-
readonly resolve?: (context: {
|
|
7242
|
-
readonly input: Input
|
|
7243
|
-
readonly target: Machine.SelectionBuilder<Selection>
|
|
7244
|
-
}) => Machine.SelectedTargetResult<Selection>
|
|
7245
|
-
readonly cases?: never
|
|
7246
|
-
readonly otherwise?: never
|
|
7247
|
-
}
|
|
7248
|
-
|
|
7249
7660
|
type MakeConfig<
|
|
7250
7661
|
States extends Machine.StateSchemas,
|
|
7251
7662
|
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -7254,7 +7665,7 @@ type MakeConfig<
|
|
|
7254
7665
|
InitialE,
|
|
7255
7666
|
InitialR,
|
|
7256
7667
|
InternalEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7257
|
-
|
|
7668
|
+
ParentDeclaration extends Parent.Any | undefined
|
|
7258
7669
|
> = {
|
|
7259
7670
|
readonly id?: string
|
|
7260
7671
|
readonly states: States & DefineStateTreeInput<NoInfer<States>>
|
|
@@ -7268,7 +7679,7 @@ type MakeConfig<
|
|
|
7268
7679
|
NoInfer<InternalEvents>
|
|
7269
7680
|
>
|
|
7270
7681
|
readonly emittedEvents?: Machine.EventProtocol<"emitted", Emits>
|
|
7271
|
-
readonly
|
|
7682
|
+
readonly parent?: ParentDeclaration
|
|
7272
7683
|
readonly input?: Input
|
|
7273
7684
|
readonly initial: unknown
|
|
7274
7685
|
}
|
|
@@ -7281,7 +7692,7 @@ type MakeResult<
|
|
|
7281
7692
|
InitialE,
|
|
7282
7693
|
InitialR,
|
|
7283
7694
|
InternalEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7284
|
-
|
|
7695
|
+
ParentDeclaration extends Parent.Any | undefined
|
|
7285
7696
|
> = Definition<
|
|
7286
7697
|
States,
|
|
7287
7698
|
readonly [...InputEvents, ...InternalEvents],
|
|
@@ -7292,7 +7703,7 @@ type MakeResult<
|
|
|
7292
7703
|
Machine.TerminalOutput<States>,
|
|
7293
7704
|
Emits,
|
|
7294
7705
|
InputEvents,
|
|
7295
|
-
|
|
7706
|
+
Machine.ParentEventsOf<ParentDeclaration>
|
|
7296
7707
|
>
|
|
7297
7708
|
|
|
7298
7709
|
interface Make {
|
|
@@ -7304,17 +7715,16 @@ interface Make {
|
|
|
7304
7715
|
InitialE = never,
|
|
7305
7716
|
InitialR = never,
|
|
7306
7717
|
const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
7307
|
-
const
|
|
7308
|
-
const InitialSelection extends Machine.TargetSelection<any, any, any> = Machine.TargetSelection<any, any, any>
|
|
7718
|
+
const ParentDeclaration extends Parent.Any | undefined = undefined
|
|
7309
7719
|
>(
|
|
7310
7720
|
config:
|
|
7311
7721
|
& Omit<
|
|
7312
|
-
MakeConfig<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents,
|
|
7722
|
+
MakeConfig<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents, ParentDeclaration>,
|
|
7313
7723
|
"initial"
|
|
7314
7724
|
>
|
|
7315
|
-
& { readonly initial:
|
|
7725
|
+
& { readonly initial: Machine.InitialBuilderInput<States, Input["Type"]> },
|
|
7316
7726
|
..._validation: ValidateDefinedStates<NoInfer<States>>
|
|
7317
|
-
): MakeResult<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents,
|
|
7727
|
+
): MakeResult<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents, ParentDeclaration>
|
|
7318
7728
|
<
|
|
7319
7729
|
const States extends Machine.StateSchemas,
|
|
7320
7730
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -7323,10 +7733,13 @@ interface Make {
|
|
|
7323
7733
|
InitialE = never,
|
|
7324
7734
|
InitialR = never,
|
|
7325
7735
|
const InternalEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
7326
|
-
const
|
|
7736
|
+
const ParentDeclaration extends Parent.Any | undefined = undefined
|
|
7327
7737
|
>(
|
|
7328
7738
|
config:
|
|
7329
|
-
& Omit<
|
|
7739
|
+
& Omit<
|
|
7740
|
+
MakeConfig<States, InputEvents, Emits, Input, InitialE, InitialR, InternalEvents, ParentDeclaration>,
|
|
7741
|
+
"states"
|
|
7742
|
+
>
|
|
7330
7743
|
& { readonly states: InvalidDefinedStateTreeInput<States> }
|
|
7331
7744
|
): never
|
|
7332
7745
|
}
|
|
@@ -7342,11 +7755,17 @@ interface Make {
|
|
|
7342
7755
|
* `states` or is passed inline. Call `handle` on the returned definition
|
|
7343
7756
|
* to implement state behavior with ordinary TypeScript control flow.
|
|
7344
7757
|
*
|
|
7758
|
+
* `initial` is a target-first callback. Its outer selector runs once while the
|
|
7759
|
+
* definition is captured; an attached `.resolve(...)` callback remains lazy
|
|
7760
|
+
* until initial planning. Return a bare selected state when its schema supports
|
|
7761
|
+
* default construction.
|
|
7762
|
+
*
|
|
7345
7763
|
* `Machine.events` defines the public input protocol. `Machine.internalEvents`
|
|
7346
7764
|
* adds raised events and other machine-local deliveries.
|
|
7347
|
-
* `Machine.emittedEvents` defines outward ephemeral notifications
|
|
7348
|
-
* `
|
|
7349
|
-
*
|
|
7765
|
+
* `Machine.emittedEvents` defines outward ephemeral notifications. The
|
|
7766
|
+
* `parent` configuration accepts `Machine.parent(events)` for a required owner
|
|
7767
|
+
* or `Machine.optionalParent(events)` for a root-capable machine. All
|
|
7768
|
+
* descriptors expose deferred constructors while retaining their
|
|
7350
7769
|
* schemas opaquely for runtime validation. Public and internal tags must be
|
|
7351
7770
|
* disjoint.
|
|
7352
7771
|
*
|
|
@@ -7370,18 +7789,13 @@ interface Make {
|
|
|
7370
7789
|
* const counter = Machine.make({
|
|
7371
7790
|
* states: States.states,
|
|
7372
7791
|
* events: Events,
|
|
7373
|
-
* initial: {
|
|
7374
|
-
* target: (to) => to.Count(),
|
|
7375
|
-
* resolve: ({ target }) => target(new Count({ value: 0 }))
|
|
7376
|
-
* }
|
|
7792
|
+
* initial: (to) => to.Count().resolve(({ target }) => target(new Count({ value: 0 })))
|
|
7377
7793
|
* }).handle({
|
|
7378
7794
|
* Count: {
|
|
7379
7795
|
* on: {
|
|
7380
|
-
* Increment:
|
|
7381
|
-
*
|
|
7382
|
-
*
|
|
7383
|
-
* target(new Count({ value: state.value + event.by }))
|
|
7384
|
-
* })
|
|
7796
|
+
* Increment: (to) =>
|
|
7797
|
+
* to.full.Count().resolve(({ event, state, target }) =>
|
|
7798
|
+
* target(new Count({ value: state.value + event.by })))
|
|
7385
7799
|
* }
|
|
7386
7800
|
* }
|
|
7387
7801
|
* })
|
|
@@ -7438,7 +7852,34 @@ export const events: {
|
|
|
7438
7852
|
} = internal.events as any
|
|
7439
7853
|
|
|
7440
7854
|
/**
|
|
7441
|
-
*
|
|
7855
|
+
* Requires the machine to run as an owned child whose parent accepts the
|
|
7856
|
+
* supplied public event protocol.
|
|
7857
|
+
*
|
|
7858
|
+
* Required-parent machines expose a non-optional `parent` target in behavior
|
|
7859
|
+
* contexts and are rejected by root execution APIs.
|
|
7860
|
+
*
|
|
7861
|
+
* @category constructors
|
|
7862
|
+
* @since 0.17.0
|
|
7863
|
+
*/
|
|
7864
|
+
export const parent: <const Events extends ReadonlyArray<Machine.TaggedSchema>>(
|
|
7865
|
+
events: Machine.EventProtocol<"public", Events>
|
|
7866
|
+
) => Parent<"required", Events> = internal.parent
|
|
7867
|
+
|
|
7868
|
+
/**
|
|
7869
|
+
* Declares public events a machine may send to its owner while preserving the
|
|
7870
|
+
* ability to run that machine as a root.
|
|
7871
|
+
*
|
|
7872
|
+
* Optional-parent machines expose `parent` as a possibly absent target.
|
|
7873
|
+
*
|
|
7874
|
+
* @category constructors
|
|
7875
|
+
* @since 0.17.0
|
|
7876
|
+
*/
|
|
7877
|
+
export const optionalParent: <const Events extends ReadonlyArray<Machine.TaggedSchema>>(
|
|
7878
|
+
events: Machine.EventProtocol<"public", Events>
|
|
7879
|
+
) => Parent<"optional", Events> = internal.optionalParent
|
|
7880
|
+
|
|
7881
|
+
/**
|
|
7882
|
+
* Defines an internal event protocol and returns deferred constructors for
|
|
7442
7883
|
* every statically finite configured event tag.
|
|
7443
7884
|
*
|
|
7444
7885
|
* Use these constructors for raised events and other machine-local deliveries.
|
|
@@ -7535,10 +7976,7 @@ export const emittedEvents: {
|
|
|
7535
7976
|
* const machine = Machine.make({
|
|
7536
7977
|
* states: States.states,
|
|
7537
7978
|
* events: Machine.events(),
|
|
7538
|
-
* initial: {
|
|
7539
|
-
* target: (to) => to.Idle(),
|
|
7540
|
-
* resolve: ({ target }) => target.from()
|
|
7541
|
-
* }
|
|
7979
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
7542
7980
|
* }).handle({ Idle: {} })
|
|
7543
7981
|
*
|
|
7544
7982
|
* const encoded = Effect.gen(function*() {
|
|
@@ -7620,10 +8058,7 @@ export const encodeSnapshot: <
|
|
|
7620
8058
|
* const machine = Machine.make({
|
|
7621
8059
|
* states: States.states,
|
|
7622
8060
|
* events: Machine.events(),
|
|
7623
|
-
* initial: {
|
|
7624
|
-
* target: (to) => to.Idle(),
|
|
7625
|
-
* resolve: ({ target }) => target.from()
|
|
7626
|
-
* }
|
|
8061
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
7627
8062
|
* }).handle({ Idle: {} })
|
|
7628
8063
|
*
|
|
7629
8064
|
* const roundTrip = Effect.gen(function*() {
|
|
@@ -7728,669 +8163,162 @@ type EffectFailureHandler<
|
|
|
7728
8163
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7729
8164
|
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7730
8165
|
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7731
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7732
|
-
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
7733
|
-
> = Machine.InvokeTransition<
|
|
7734
|
-
States,
|
|
7735
|
-
Events,
|
|
7736
|
-
Emits,
|
|
7737
|
-
StateId,
|
|
7738
|
-
Machine.InvokeFailureContext<
|
|
7739
|
-
States,
|
|
7740
|
-
Events,
|
|
7741
|
-
Emits,
|
|
7742
|
-
StateId,
|
|
7743
|
-
Effect.Error<ReturnType<NoInfer<Source>>>,
|
|
7744
|
-
InputEvents,
|
|
7745
|
-
ParentEvents
|
|
7746
|
-
>
|
|
7747
|
-
>
|
|
7748
|
-
|
|
7749
|
-
type EffectInvokeResult<
|
|
7750
|
-
States extends Machine.StateSchemas,
|
|
7751
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7752
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7753
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7754
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7755
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7756
|
-
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
7757
|
-
> =
|
|
7758
|
-
& Machine.
|
|
7759
|
-
& Machine.InvokeTyped<
|
|
7760
|
-
Effect.Success<ReturnType<Source>>,
|
|
7761
|
-
Effect.Error<ReturnType<Source>>,
|
|
7762
|
-
Effect.Services<ReturnType<Source>>,
|
|
7763
|
-
never
|
|
7764
|
-
>
|
|
7765
|
-
|
|
7766
|
-
type StreamInvokeSource<
|
|
7767
|
-
States extends Machine.StateSchemas,
|
|
7768
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7769
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7770
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7771
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7772
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7773
|
-
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
7774
|
-
> = {
|
|
7775
|
-
readonly id: InvokeLifecycleId
|
|
7776
|
-
readonly stream:
|
|
7777
|
-
& Source
|
|
7778
|
-
& ((context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
7779
|
-
readonly effect?: never
|
|
7780
|
-
readonly after?: never
|
|
7781
|
-
readonly logic?: never
|
|
7782
|
-
readonly child?: never
|
|
7783
|
-
readonly address?: never
|
|
7784
|
-
readonly onSnapshot?: never
|
|
7785
|
-
}
|
|
7786
|
-
|
|
7787
|
-
type StreamSourceResult<Source extends (...args: ReadonlyArray<any>) => unknown> = ReturnType<Source> extends
|
|
7788
|
-
infer Result extends Stream.Stream<any, any, any> ? Result : never
|
|
7789
|
-
|
|
7790
|
-
type StreamElementHandler<
|
|
7791
|
-
States extends Machine.StateSchemas,
|
|
7792
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7793
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7794
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7795
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7796
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7797
|
-
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
7798
|
-
> = Machine.InvokeTransition<
|
|
7799
|
-
States,
|
|
7800
|
-
Events,
|
|
7801
|
-
Emits,
|
|
7802
|
-
StateId,
|
|
7803
|
-
Machine.InvokeElementContext<
|
|
7804
|
-
States,
|
|
7805
|
-
Events,
|
|
7806
|
-
Emits,
|
|
7807
|
-
StateId,
|
|
7808
|
-
Stream.Success<StreamSourceResult<NoInfer<Source>>>,
|
|
7809
|
-
InputEvents,
|
|
7810
|
-
ParentEvents
|
|
7811
|
-
>
|
|
7812
|
-
>
|
|
7813
|
-
|
|
7814
|
-
type StreamDoneHandler<
|
|
7815
|
-
States extends Machine.StateSchemas,
|
|
7816
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7817
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7818
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7819
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7820
|
-
StateId extends Machine.StateIdentifier<States>
|
|
7821
|
-
> = Machine.InvokeTransition<
|
|
7822
|
-
States,
|
|
7823
|
-
Events,
|
|
7824
|
-
Emits,
|
|
7825
|
-
StateId,
|
|
7826
|
-
Machine.InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
7827
|
-
>
|
|
7828
|
-
|
|
7829
|
-
type StreamFailureHandler<
|
|
7830
|
-
States extends Machine.StateSchemas,
|
|
7831
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7832
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7833
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7834
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7835
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7836
|
-
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
7837
|
-
> = Machine.InvokeTransition<
|
|
7838
|
-
States,
|
|
7839
|
-
Events,
|
|
7840
|
-
Emits,
|
|
7841
|
-
StateId,
|
|
7842
|
-
Machine.InvokeFailureContext<
|
|
7843
|
-
States,
|
|
7844
|
-
Events,
|
|
7845
|
-
Emits,
|
|
7846
|
-
StateId,
|
|
7847
|
-
Stream.Error<StreamSourceResult<NoInfer<Source>>>,
|
|
7848
|
-
InputEvents,
|
|
7849
|
-
ParentEvents
|
|
7850
|
-
>
|
|
7851
|
-
>
|
|
7852
|
-
|
|
7853
|
-
type StreamInvokeResult<
|
|
7854
|
-
States extends Machine.StateSchemas,
|
|
7855
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7856
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7857
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7858
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7859
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7860
|
-
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
7861
|
-
> =
|
|
7862
|
-
& Machine.
|
|
7863
|
-
& Machine.InvokeTyped<
|
|
7864
|
-
void,
|
|
7865
|
-
Stream.Error<StreamSourceResult<Source>>,
|
|
7866
|
-
Stream.Services<StreamSourceResult<Source>>,
|
|
7867
|
-
never
|
|
7868
|
-
>
|
|
7869
|
-
|
|
7870
|
-
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false
|
|
7871
|
-
|
|
7872
|
-
type
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7876
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7877
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7878
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7879
|
-
Source extends (
|
|
7880
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7881
|
-
) => Effect.Effect<unknown, unknown, unknown>
|
|
7882
|
-
> = {
|
|
7883
|
-
readonly id: InvokeLifecycleId
|
|
7884
|
-
readonly effect: Source
|
|
7885
|
-
readonly stream?: never
|
|
7886
|
-
readonly after?: never
|
|
7887
|
-
readonly logic?: never
|
|
7888
|
-
readonly child?: never
|
|
7889
|
-
readonly address?: never
|
|
7890
|
-
readonly onElement?: never
|
|
7891
|
-
readonly onSnapshot?: never
|
|
7892
|
-
}
|
|
7893
|
-
|
|
7894
|
-
type BoundEffectDoneHandler<
|
|
7895
|
-
States extends Machine.StateSchemas,
|
|
7896
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7897
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7898
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7899
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7900
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7901
|
-
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
7902
|
-
> = Machine.InvokeTransition<
|
|
7903
|
-
States,
|
|
7904
|
-
Events,
|
|
7905
|
-
Emits,
|
|
7906
|
-
StateId,
|
|
7907
|
-
Machine.InvokeDoneContext<
|
|
7908
|
-
States,
|
|
7909
|
-
Events,
|
|
7910
|
-
Emits,
|
|
7911
|
-
StateId,
|
|
7912
|
-
Effect.Success<ReturnType<NoInfer<Source>>>,
|
|
7913
|
-
InputEvents,
|
|
7914
|
-
ParentEvents
|
|
7915
|
-
>
|
|
7916
|
-
>
|
|
7917
|
-
|
|
7918
|
-
type BoundEffectFailureHandler<
|
|
7919
|
-
States extends Machine.StateSchemas,
|
|
7920
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7921
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7922
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7923
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7924
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7925
|
-
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
7926
|
-
> = Machine.InvokeTransition<
|
|
7927
|
-
States,
|
|
7928
|
-
Events,
|
|
7929
|
-
Emits,
|
|
7930
|
-
StateId,
|
|
7931
|
-
Machine.InvokeFailureContext<
|
|
7932
|
-
States,
|
|
7933
|
-
Events,
|
|
7934
|
-
Emits,
|
|
7935
|
-
StateId,
|
|
7936
|
-
Effect.Error<ReturnType<NoInfer<Source>>>,
|
|
7937
|
-
InputEvents,
|
|
7938
|
-
ParentEvents
|
|
7939
|
-
>
|
|
7940
|
-
>
|
|
7941
|
-
|
|
7942
|
-
type BoundEffectInvokeResult<
|
|
7943
|
-
States extends Machine.StateSchemas,
|
|
7944
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7945
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7946
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7947
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7948
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
7949
|
-
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
7950
|
-
> =
|
|
7951
|
-
& Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7952
|
-
& Machine.InvokeTyped<
|
|
7953
|
-
Effect.Success<ReturnType<Source>>,
|
|
7954
|
-
Effect.Error<ReturnType<Source>>,
|
|
7955
|
-
Effect.Services<ReturnType<Source>>,
|
|
7956
|
-
never
|
|
7957
|
-
>
|
|
7958
|
-
|
|
7959
|
-
/** Captures one exact named-branch topology while preserving handler inference. */
|
|
7960
|
-
type BranchingTransitionResult<
|
|
7961
|
-
States extends Machine.StateSchemas,
|
|
7962
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7963
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7964
|
-
StateId extends Machine.StateNodeIdentifier<States>,
|
|
7965
|
-
Context,
|
|
7966
|
-
Reenter extends boolean,
|
|
7967
|
-
Branches extends Readonly<Record<string, Machine.TransitionBranchInput>>
|
|
7968
|
-
> =
|
|
7969
|
-
& Machine.TransitionBranchesInput<States, Events, Emits, StateId, Context, Reenter, Branches>
|
|
7970
|
-
& Machine.TransitionTyped<States, Events, Emits, StateId, Context, Reenter>
|
|
7971
|
-
|
|
7972
|
-
type TransitionBranchRecordError<Message extends string, Key extends PropertyKey = never> = {
|
|
7973
|
-
readonly "~effect/Machine/TransitionBranchRecordError": Message
|
|
7974
|
-
readonly key: Key
|
|
7975
|
-
}
|
|
7976
|
-
|
|
7977
|
-
type InvalidStaticTransitionBranchKey<Branches> = Extract<keyof Branches, "" | number | symbol>
|
|
7978
|
-
|
|
7979
|
-
type ValidateTransitionBranchRecord<Branches> = [keyof Branches] extends [never] ?
|
|
7980
|
-
TransitionBranchRecordError<"Branch records must contain at least one branch">
|
|
7981
|
-
: [InvalidStaticTransitionBranchKey<Branches>] extends [never] ? unknown
|
|
7982
|
-
: TransitionBranchRecordError<
|
|
7983
|
-
"Branch keys must be non-empty, non-index strings",
|
|
7984
|
-
InvalidStaticTransitionBranchKey<Branches>
|
|
7985
|
-
>
|
|
7986
|
-
|
|
7987
|
-
/**
|
|
7988
|
-
* Contextually types direct and branching transition definitions.
|
|
7989
|
-
*
|
|
7990
|
-
* @category constructors
|
|
7991
|
-
* @since 0.14.0
|
|
7992
|
-
*/
|
|
7993
|
-
export interface TransitionConstructor {
|
|
7994
|
-
<
|
|
7995
|
-
const States extends Machine.StateSchemas,
|
|
7996
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7997
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7998
|
-
StateId extends Machine.StateNodeIdentifier<States>,
|
|
7999
|
-
Context,
|
|
8000
|
-
const Selection extends Machine.TargetSelection<any, any, any>,
|
|
8001
|
-
Reenter extends boolean = never
|
|
8002
|
-
>(
|
|
8003
|
-
config: Machine.TransitionDirectInput<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
8004
|
-
):
|
|
8005
|
-
& Machine.TransitionDirectInput<States, Events, Emits, StateId, Context, Reenter, Selection>
|
|
8006
|
-
& (Machine.SelectionKind<Selection> extends "none" ? Machine.TargetlessTransitionTyped
|
|
8007
|
-
: Machine.TransitionTyped<States, Events, Emits, StateId, Context, Reenter>)
|
|
8008
|
-
<
|
|
8009
|
-
const States extends Machine.StateSchemas,
|
|
8010
|
-
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8011
|
-
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8012
|
-
StateId extends Machine.StateNodeIdentifier<States>,
|
|
8013
|
-
Context,
|
|
8014
|
-
const Branches extends Readonly<Record<string, Machine.TransitionBranchInput>>,
|
|
8015
|
-
Reenter extends boolean = never
|
|
8016
|
-
>(
|
|
8017
|
-
config:
|
|
8018
|
-
& Machine.TransitionBranchesInput<
|
|
8019
|
-
States,
|
|
8020
|
-
Events,
|
|
8021
|
-
Emits,
|
|
8022
|
-
StateId,
|
|
8023
|
-
Context,
|
|
8024
|
-
Reenter,
|
|
8025
|
-
Branches
|
|
8026
|
-
>
|
|
8027
|
-
& ValidateTransitionBranchRecord<NoInfer<Branches>>
|
|
8028
|
-
): BranchingTransitionResult<
|
|
8029
|
-
States,
|
|
8030
|
-
Events,
|
|
8031
|
-
Emits,
|
|
8032
|
-
StateId,
|
|
8033
|
-
Context,
|
|
8034
|
-
Reenter,
|
|
8035
|
-
Branches
|
|
8036
|
-
>
|
|
8037
|
-
}
|
|
8038
|
-
|
|
8039
|
-
/**
|
|
8040
|
-
* Defines a statically inspectable transition.
|
|
8041
|
-
*
|
|
8042
|
-
* It is required for every event, lifecycle, choice, and invocation transition
|
|
8043
|
-
* so the destination selected by `target` can contextually type the
|
|
8044
|
-
* corresponding resolver. Branching transitions declare every possible
|
|
8045
|
-
* destination up front, then select one through ordinary TypeScript control
|
|
8046
|
-
* flow in `resolve`.
|
|
8047
|
-
*
|
|
8048
|
-
* ```ts
|
|
8049
|
-
* Machine.transition({
|
|
8050
|
-
* target: (to) => to.full.Ready(),
|
|
8051
|
-
* resolve: ({ target }) => target.from()
|
|
8052
|
-
* })
|
|
8053
|
-
*
|
|
8054
|
-
* Machine.transition({
|
|
8055
|
-
* branches: (to) => ({
|
|
8056
|
-
* cached: { target: to.full.Ready() },
|
|
8057
|
-
* loading: { target: to.full.Loading() }
|
|
8058
|
-
* }),
|
|
8059
|
-
* resolve: ({ event, select }) => event.cached
|
|
8060
|
-
* ? select.cached.from({ data: event.cached })
|
|
8061
|
-
* : select.loading.from()
|
|
8062
|
-
* })
|
|
8063
|
-
* ```
|
|
8064
|
-
*
|
|
8065
|
-
* @category constructors
|
|
8066
|
-
* @since 0.14.0
|
|
8067
|
-
*/
|
|
8068
|
-
export const transition: TransitionConstructor = ((config: unknown) => config) as TransitionConstructor
|
|
8069
|
-
|
|
8070
|
-
/**
|
|
8071
|
-
* Sentinel used by direct targetless transition shorthands.
|
|
8072
|
-
*
|
|
8073
|
-
* This is the concise form of `target: (to) => to.none()`.
|
|
8074
|
-
*
|
|
8075
|
-
* ```ts
|
|
8076
|
-
* onElement: {
|
|
8077
|
-
* target: Machine.targetless,
|
|
8078
|
-
* resolve: ({ element }, enqueue) => {
|
|
8079
|
-
* enqueue.raise(new MeasurementReceived({ value: element }))
|
|
8080
|
-
* }
|
|
8081
|
-
* }
|
|
8082
|
-
*
|
|
8083
|
-
* onDone: { target: Machine.targetless }
|
|
8084
|
-
* ```
|
|
8085
|
-
*
|
|
8086
|
-
* @category constructors
|
|
8087
|
-
* @since 0.16.0
|
|
8088
|
-
*/
|
|
8089
|
-
export interface TargetlessSelector {
|
|
8090
|
-
readonly "~effect/Machine/TargetlessSelector": true
|
|
8091
|
-
<
|
|
8092
|
-
const States extends Machine.StateSchemas,
|
|
8093
|
-
StateId extends Machine.StateNodeIdentifier<States>
|
|
8094
|
-
>(to: Machine.TargetSelector<States, StateId>): ReturnType<Machine.TargetSelector<States, StateId>["none"]>
|
|
8095
|
-
}
|
|
8096
|
-
|
|
8097
|
-
/**
|
|
8098
|
-
* Selects no transition target while keeping enqueue operations explicit.
|
|
8099
|
-
*
|
|
8100
|
-
* Use as the `target` of a direct handler object when the handler should keep
|
|
8101
|
-
* the current state configuration and only raise, emit, or send events.
|
|
8102
|
-
*
|
|
8103
|
-
* @category constructors
|
|
8104
|
-
* @since 0.16.0
|
|
8105
|
-
*/
|
|
8106
|
-
export const targetless: TargetlessSelector = Object.assign(
|
|
8107
|
-
(to: Machine.TargetSelector<any, any>) => to.none(),
|
|
8108
|
-
{ "~effect/Machine/TargetlessSelector": true as const }
|
|
8109
|
-
)
|
|
8110
|
-
|
|
8111
|
-
/**
|
|
8112
|
-
* Machine-bound invocation constructor that preserves the owning machine's
|
|
8113
|
-
* public input and parent protocols in every invocation callback.
|
|
8114
|
-
*
|
|
8115
|
-
* @category constructors
|
|
8116
|
-
* @since 0.11.0
|
|
8117
|
-
*/
|
|
8118
|
-
export interface Invoker<
|
|
8119
|
-
States extends Machine.StateSchemas,
|
|
8120
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8121
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8122
|
-
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8123
|
-
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>
|
|
8124
|
-
> {
|
|
8125
|
-
<
|
|
8126
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8127
|
-
const Source extends (
|
|
8128
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8129
|
-
) => Effect.Effect<unknown, unknown, unknown>
|
|
8130
|
-
>(
|
|
8131
|
-
config:
|
|
8132
|
-
& BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8133
|
-
& {
|
|
8134
|
-
readonly onDone: BoundEffectDoneHandler<
|
|
8135
|
-
States,
|
|
8136
|
-
Events,
|
|
8137
|
-
Emits,
|
|
8138
|
-
InputEvents,
|
|
8139
|
-
ParentEvents,
|
|
8140
|
-
StateId,
|
|
8141
|
-
Source
|
|
8142
|
-
>
|
|
8143
|
-
readonly onFailure: BoundEffectFailureHandler<
|
|
8144
|
-
States,
|
|
8145
|
-
Events,
|
|
8146
|
-
Emits,
|
|
8147
|
-
InputEvents,
|
|
8148
|
-
ParentEvents,
|
|
8149
|
-
StateId,
|
|
8150
|
-
Source
|
|
8151
|
-
>
|
|
8152
|
-
},
|
|
8153
|
-
..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
8154
|
-
"onDone must be omitted when the Effect output is never"
|
|
8155
|
-
]
|
|
8156
|
-
: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
8157
|
-
"onFailure must be omitted when the Effect error is never"
|
|
8158
|
-
]
|
|
8159
|
-
: []
|
|
8160
|
-
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8161
|
-
<
|
|
8162
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8163
|
-
const Source extends (
|
|
8164
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8165
|
-
) => Effect.Effect<unknown, never, unknown>
|
|
8166
|
-
>(
|
|
8167
|
-
config:
|
|
8168
|
-
& BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8169
|
-
& {
|
|
8170
|
-
readonly onDone: BoundEffectDoneHandler<
|
|
8171
|
-
States,
|
|
8172
|
-
Events,
|
|
8173
|
-
Emits,
|
|
8174
|
-
InputEvents,
|
|
8175
|
-
ParentEvents,
|
|
8176
|
-
StateId,
|
|
8177
|
-
Source
|
|
8178
|
-
>
|
|
8179
|
-
readonly onFailure?: never
|
|
8180
|
-
},
|
|
8181
|
-
..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
8182
|
-
"onDone must be omitted when the Effect output is never"
|
|
8183
|
-
]
|
|
8184
|
-
: []
|
|
8185
|
-
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8186
|
-
<
|
|
8187
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8188
|
-
const Source extends (
|
|
8189
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8190
|
-
) => Effect.Effect<never, unknown, unknown>
|
|
8191
|
-
>(
|
|
8192
|
-
config:
|
|
8193
|
-
& BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8194
|
-
& {
|
|
8195
|
-
readonly onDone?: never
|
|
8196
|
-
readonly onFailure: BoundEffectFailureHandler<
|
|
8197
|
-
States,
|
|
8198
|
-
Events,
|
|
8199
|
-
Emits,
|
|
8200
|
-
InputEvents,
|
|
8201
|
-
ParentEvents,
|
|
8202
|
-
StateId,
|
|
8203
|
-
Source
|
|
8204
|
-
>
|
|
8205
|
-
},
|
|
8206
|
-
..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
8207
|
-
"onFailure must be omitted when the Effect error is never"
|
|
8208
|
-
]
|
|
8209
|
-
: []
|
|
8210
|
-
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8211
|
-
<
|
|
8212
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8213
|
-
const Source extends (
|
|
8214
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8215
|
-
) => Effect.Effect<never, never, unknown>
|
|
8216
|
-
>(
|
|
8217
|
-
config:
|
|
8218
|
-
& BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8219
|
-
& {
|
|
8220
|
-
readonly onDone?: never
|
|
8221
|
-
readonly onFailure?: never
|
|
8222
|
-
}
|
|
8223
|
-
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8224
|
-
<
|
|
8225
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8226
|
-
const Source extends (
|
|
8227
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8228
|
-
) => Stream.Stream<unknown, unknown, any>
|
|
8229
|
-
>(
|
|
8230
|
-
config:
|
|
8231
|
-
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8232
|
-
& {
|
|
8233
|
-
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8234
|
-
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8235
|
-
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8236
|
-
},
|
|
8237
|
-
..._validation: InvokeChannelIsNever<Stream.Success<ReturnType<Source>>> extends true ? [
|
|
8238
|
-
"onElement must be omitted when the Stream element is never"
|
|
8239
|
-
]
|
|
8240
|
-
: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
8241
|
-
"onFailure must be omitted when the Stream error is never"
|
|
8242
|
-
]
|
|
8243
|
-
: []
|
|
8244
|
-
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8245
|
-
<
|
|
8246
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8247
|
-
const Source extends (
|
|
8248
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8249
|
-
) => Stream.Stream<never, unknown, any>
|
|
8250
|
-
>(
|
|
8251
|
-
config:
|
|
8252
|
-
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8253
|
-
& {
|
|
8254
|
-
readonly onElement?: never
|
|
8255
|
-
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8256
|
-
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8257
|
-
},
|
|
8258
|
-
..._validation: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
8259
|
-
"onFailure must be omitted when the Stream error is never"
|
|
8260
|
-
]
|
|
8261
|
-
: []
|
|
8262
|
-
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8263
|
-
<
|
|
8264
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8265
|
-
const Source extends (
|
|
8266
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8267
|
-
) => Stream.Stream<never, never, any>
|
|
8268
|
-
>(
|
|
8269
|
-
config:
|
|
8270
|
-
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8271
|
-
& {
|
|
8272
|
-
readonly onElement?: never
|
|
8273
|
-
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8274
|
-
readonly onFailure?: never
|
|
8275
|
-
}
|
|
8276
|
-
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8277
|
-
<
|
|
8278
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8279
|
-
const Source extends (
|
|
8280
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8281
|
-
) => Stream.Stream<unknown, never, any>
|
|
8282
|
-
>(
|
|
8283
|
-
config:
|
|
8284
|
-
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8285
|
-
& {
|
|
8286
|
-
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8287
|
-
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8288
|
-
readonly onFailure?: never
|
|
8289
|
-
}
|
|
8290
|
-
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8291
|
-
<StateId extends Machine.StateIdentifier<States>, const Config extends object>(
|
|
8292
|
-
config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8293
|
-
): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>
|
|
8294
|
-
<
|
|
8295
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8296
|
-
const Source extends (
|
|
8297
|
-
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8298
|
-
) => unknown,
|
|
8299
|
-
Address extends ChildAddress<never>
|
|
8300
|
-
>(
|
|
8301
|
-
config:
|
|
8302
|
-
& { readonly logic: Source }
|
|
8303
|
-
& Machine.LogicInvokeArgs<
|
|
8304
|
-
States,
|
|
8305
|
-
Events,
|
|
8306
|
-
Emits,
|
|
8307
|
-
StateId,
|
|
8308
|
-
Machine.LogicStateOf<ReturnType<Source>>,
|
|
8309
|
-
Machine.LogicEventOf<ReturnType<Source>>,
|
|
8310
|
-
Machine.LogicErrorOf<ReturnType<Source>>,
|
|
8311
|
-
Machine.LogicServicesOf<ReturnType<Source>>,
|
|
8312
|
-
Machine.LogicOutputOf<ReturnType<Source>>,
|
|
8313
|
-
Machine.LogicInitialErrorOf<ReturnType<Source>>,
|
|
8314
|
-
Address,
|
|
8315
|
-
Source,
|
|
8316
|
-
InputEvents,
|
|
8317
|
-
ParentEvents
|
|
8318
|
-
>,
|
|
8319
|
-
..._validation: ReturnType<Source> extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
8320
|
-
"logic factory must return Machine.Logic"
|
|
8321
|
-
]
|
|
8322
|
-
):
|
|
8323
|
-
& Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8324
|
-
& Machine.InvokeTyped<
|
|
8325
|
-
Machine.LogicOutputOf<ReturnType<Source>>,
|
|
8326
|
-
Machine.LogicErrorOf<ReturnType<Source>>,
|
|
8327
|
-
Machine.LogicServicesOf<ReturnType<Source>>,
|
|
8328
|
-
Machine.LogicInitialErrorOf<ReturnType<Source>>
|
|
8329
|
-
>
|
|
8330
|
-
<
|
|
8331
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8332
|
-
const Source,
|
|
8333
|
-
Address extends ChildAddress<never>
|
|
8334
|
-
>(
|
|
8335
|
-
config:
|
|
8336
|
-
& { readonly logic: Source }
|
|
8337
|
-
& Machine.LogicInvokeArgs<
|
|
8338
|
-
States,
|
|
8339
|
-
Events,
|
|
8340
|
-
Emits,
|
|
8341
|
-
StateId,
|
|
8342
|
-
Machine.LogicStateOf<Source>,
|
|
8343
|
-
Machine.LogicEventOf<Source>,
|
|
8344
|
-
Machine.LogicErrorOf<Source>,
|
|
8345
|
-
Machine.LogicServicesOf<Source>,
|
|
8346
|
-
Machine.LogicOutputOf<Source>,
|
|
8347
|
-
Machine.LogicInitialErrorOf<Source>,
|
|
8348
|
-
Address,
|
|
8349
|
-
Source,
|
|
8350
|
-
InputEvents,
|
|
8351
|
-
ParentEvents
|
|
8352
|
-
>,
|
|
8353
|
-
..._validation: Source extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
8354
|
-
"logic must implement Machine.Logic"
|
|
8355
|
-
]
|
|
8356
|
-
):
|
|
8357
|
-
& Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8358
|
-
& Machine.InvokeTyped<
|
|
8359
|
-
Machine.LogicOutputOf<Source>,
|
|
8360
|
-
Machine.LogicErrorOf<Source>,
|
|
8361
|
-
Machine.LogicServicesOf<Source>,
|
|
8362
|
-
Machine.LogicInitialErrorOf<Source>
|
|
8363
|
-
>
|
|
8364
|
-
<
|
|
8365
|
-
StateId extends Machine.StateIdentifier<States>,
|
|
8366
|
-
const Child extends ChildMachine.Any,
|
|
8367
|
-
const Config extends object
|
|
8368
|
-
>(
|
|
8369
|
-
config:
|
|
8370
|
-
& Config
|
|
8371
|
-
& Machine.ChildInvokeArgs<
|
|
8372
|
-
States,
|
|
8373
|
-
Events,
|
|
8374
|
-
Emits,
|
|
8375
|
-
StateId,
|
|
8376
|
-
Child["machine"],
|
|
8377
|
-
Child,
|
|
8378
|
-
InputEvents,
|
|
8379
|
-
ParentEvents
|
|
8380
|
-
>
|
|
8381
|
-
):
|
|
8382
|
-
& Config
|
|
8383
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
8384
|
-
& Machine.InvokeTyped<
|
|
8385
|
-
Machine.Output<Child["machine"]>,
|
|
8386
|
-
Machine.Error<Child["machine"]> | ActionError<Machine.Services<Child["machine"]>>,
|
|
8387
|
-
Machine.Services<Child["machine"]>,
|
|
8388
|
-
Machine.InitialError<Child["machine"]>,
|
|
8389
|
-
Machine.Emit<Child["machine"]>,
|
|
8390
|
-
Machine.EventOf<Machine.ParentEvents<Child["machine"]>>
|
|
8391
|
-
>
|
|
8166
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8167
|
+
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
8168
|
+
> = Machine.InvokeTransition<
|
|
8169
|
+
States,
|
|
8170
|
+
Events,
|
|
8171
|
+
Emits,
|
|
8172
|
+
StateId,
|
|
8173
|
+
Machine.InvokeFailureContext<
|
|
8174
|
+
States,
|
|
8175
|
+
Events,
|
|
8176
|
+
Emits,
|
|
8177
|
+
StateId,
|
|
8178
|
+
Effect.Error<ReturnType<NoInfer<Source>>>,
|
|
8179
|
+
InputEvents,
|
|
8180
|
+
ParentEvents
|
|
8181
|
+
>
|
|
8182
|
+
>
|
|
8183
|
+
|
|
8184
|
+
type EffectInvokeResult<
|
|
8185
|
+
States extends Machine.StateSchemas,
|
|
8186
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8187
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8188
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8189
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8190
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8191
|
+
Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>
|
|
8192
|
+
> =
|
|
8193
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8194
|
+
& Machine.InvokeTyped<
|
|
8195
|
+
Effect.Success<ReturnType<Source>>,
|
|
8196
|
+
Effect.Error<ReturnType<Source>>,
|
|
8197
|
+
Effect.Services<ReturnType<Source>>,
|
|
8198
|
+
never
|
|
8199
|
+
>
|
|
8200
|
+
|
|
8201
|
+
type StreamInvokeSource<
|
|
8202
|
+
States extends Machine.StateSchemas,
|
|
8203
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8204
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8205
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8206
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8207
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8208
|
+
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
8209
|
+
> = {
|
|
8210
|
+
readonly id: InvokeLifecycleId
|
|
8211
|
+
readonly stream:
|
|
8212
|
+
& Source
|
|
8213
|
+
& ((context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
8214
|
+
readonly effect?: never
|
|
8215
|
+
readonly after?: never
|
|
8216
|
+
readonly logic?: never
|
|
8217
|
+
readonly child?: never
|
|
8218
|
+
readonly address?: never
|
|
8219
|
+
readonly onSnapshot?: never
|
|
8220
|
+
}
|
|
8221
|
+
|
|
8222
|
+
type StreamSourceResult<Source extends (...args: ReadonlyArray<any>) => unknown> = ReturnType<Source> extends
|
|
8223
|
+
infer Result extends Stream.Stream<any, any, any> ? Result : never
|
|
8224
|
+
|
|
8225
|
+
type StreamElementHandler<
|
|
8226
|
+
States extends Machine.StateSchemas,
|
|
8227
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8228
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8229
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8230
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8231
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8232
|
+
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
8233
|
+
> = Machine.InvokeTransition<
|
|
8234
|
+
States,
|
|
8235
|
+
Events,
|
|
8236
|
+
Emits,
|
|
8237
|
+
StateId,
|
|
8238
|
+
Machine.InvokeElementContext<
|
|
8239
|
+
States,
|
|
8240
|
+
Events,
|
|
8241
|
+
Emits,
|
|
8242
|
+
StateId,
|
|
8243
|
+
Stream.Success<StreamSourceResult<NoInfer<Source>>>,
|
|
8244
|
+
InputEvents,
|
|
8245
|
+
ParentEvents
|
|
8246
|
+
>
|
|
8247
|
+
>
|
|
8248
|
+
|
|
8249
|
+
type StreamDoneHandler<
|
|
8250
|
+
States extends Machine.StateSchemas,
|
|
8251
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8252
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8253
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8254
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8255
|
+
StateId extends Machine.StateIdentifier<States>
|
|
8256
|
+
> = Machine.InvokeTransition<
|
|
8257
|
+
States,
|
|
8258
|
+
Events,
|
|
8259
|
+
Emits,
|
|
8260
|
+
StateId,
|
|
8261
|
+
Machine.InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
8262
|
+
>
|
|
8263
|
+
|
|
8264
|
+
type StreamFailureHandler<
|
|
8265
|
+
States extends Machine.StateSchemas,
|
|
8266
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8267
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8268
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8269
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8270
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8271
|
+
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
8272
|
+
> = Machine.InvokeTransition<
|
|
8273
|
+
States,
|
|
8274
|
+
Events,
|
|
8275
|
+
Emits,
|
|
8276
|
+
StateId,
|
|
8277
|
+
Machine.InvokeFailureContext<
|
|
8278
|
+
States,
|
|
8279
|
+
Events,
|
|
8280
|
+
Emits,
|
|
8281
|
+
StateId,
|
|
8282
|
+
Stream.Error<StreamSourceResult<NoInfer<Source>>>,
|
|
8283
|
+
InputEvents,
|
|
8284
|
+
ParentEvents
|
|
8285
|
+
>
|
|
8286
|
+
>
|
|
8287
|
+
|
|
8288
|
+
type StreamInvokeResult<
|
|
8289
|
+
States extends Machine.StateSchemas,
|
|
8290
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8291
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8292
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8293
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8294
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8295
|
+
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
8296
|
+
> =
|
|
8297
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8298
|
+
& Machine.InvokeTyped<
|
|
8299
|
+
void,
|
|
8300
|
+
Stream.Error<StreamSourceResult<Source>>,
|
|
8301
|
+
Stream.Services<StreamSourceResult<Source>>,
|
|
8302
|
+
never
|
|
8303
|
+
>
|
|
8304
|
+
|
|
8305
|
+
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false
|
|
8306
|
+
|
|
8307
|
+
type TransitionBranchRecordError<Message extends string, Key extends PropertyKey = never> = {
|
|
8308
|
+
readonly "~effect/Machine/TransitionBranchRecordError": Message
|
|
8309
|
+
readonly key: Key
|
|
8392
8310
|
}
|
|
8393
8311
|
|
|
8312
|
+
type InvalidStaticTransitionBranchKey<Branches> = Extract<keyof Branches, "" | number | symbol>
|
|
8313
|
+
|
|
8314
|
+
type ValidateTransitionBranchRecord<Branches> = [keyof Branches] extends [never] ?
|
|
8315
|
+
TransitionBranchRecordError<"Branch records must contain at least one branch">
|
|
8316
|
+
: [InvalidStaticTransitionBranchKey<Branches>] extends [never] ? unknown
|
|
8317
|
+
: TransitionBranchRecordError<
|
|
8318
|
+
"Branch keys must be non-empty, non-index strings",
|
|
8319
|
+
InvalidStaticTransitionBranchKey<Branches>
|
|
8320
|
+
>
|
|
8321
|
+
|
|
8394
8322
|
/**
|
|
8395
8323
|
* Preserves inference for a state-owned invocation configuration.
|
|
8396
8324
|
*
|
|
@@ -8412,9 +8340,10 @@ export interface Invoker<
|
|
|
8412
8340
|
* `address` must not be repeated.
|
|
8413
8341
|
*
|
|
8414
8342
|
* Inside `handle(...)`, the owning definition contextually supplies its public
|
|
8415
|
-
* input and
|
|
8343
|
+
* input and declared parent protocols. Invocation sources and lifecycle handlers
|
|
8416
8344
|
* can therefore send through `self` and `parent` without naming the definition.
|
|
8417
|
-
* The
|
|
8345
|
+
* The standard `Machine.invoke(...)` constructor preserves these contexts
|
|
8346
|
+
* directly; no intermediate definition method is required.
|
|
8418
8347
|
*
|
|
8419
8348
|
* ```ts
|
|
8420
8349
|
* invoke: Machine.invoke({
|
|
@@ -8424,14 +8353,12 @@ export interface Invoker<
|
|
|
8424
8353
|
* try: () => fetch("/api/data").then((response) => response.json()),
|
|
8425
8354
|
* catch: (cause) => new LoadError({ cause })
|
|
8426
8355
|
* }),
|
|
8427
|
-
* onDone:
|
|
8428
|
-
*
|
|
8429
|
-
*
|
|
8430
|
-
*
|
|
8431
|
-
*
|
|
8432
|
-
*
|
|
8433
|
-
* resolve: ({ error, target }) => target.from({ error })
|
|
8434
|
-
* })
|
|
8356
|
+
* onDone: (to) =>
|
|
8357
|
+
* to.full.Ready().resolve(({ output, target }) =>
|
|
8358
|
+
* target.from({ data: output })),
|
|
8359
|
+
* onFailure: (to) =>
|
|
8360
|
+
* to.full.Failed().resolve(({ error, target }) =>
|
|
8361
|
+
* target.from({ error }))
|
|
8435
8362
|
* })
|
|
8436
8363
|
* ```
|
|
8437
8364
|
*
|
|
@@ -8447,10 +8374,12 @@ export const invoke: {
|
|
|
8447
8374
|
const Source extends (
|
|
8448
8375
|
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8449
8376
|
) => Effect.Effect<unknown, unknown, unknown>,
|
|
8377
|
+
const Config extends object,
|
|
8450
8378
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8451
8379
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8452
8380
|
>(
|
|
8453
8381
|
config:
|
|
8382
|
+
& Config
|
|
8454
8383
|
& EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8455
8384
|
& {
|
|
8456
8385
|
readonly onDone: EffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
@@ -8463,7 +8392,7 @@ export const invoke: {
|
|
|
8463
8392
|
"onFailure must be omitted when the Effect error is never"
|
|
8464
8393
|
]
|
|
8465
8394
|
: []
|
|
8466
|
-
): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8395
|
+
): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8467
8396
|
<
|
|
8468
8397
|
const States extends Machine.StateSchemas,
|
|
8469
8398
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8472,10 +8401,12 @@ export const invoke: {
|
|
|
8472
8401
|
const Source extends (
|
|
8473
8402
|
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8474
8403
|
) => Effect.Effect<unknown, never, unknown>,
|
|
8404
|
+
const Config extends object,
|
|
8475
8405
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8476
8406
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8477
8407
|
>(
|
|
8478
8408
|
config:
|
|
8409
|
+
& Config
|
|
8479
8410
|
& EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8480
8411
|
& {
|
|
8481
8412
|
readonly onDone: EffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
@@ -8485,7 +8416,7 @@ export const invoke: {
|
|
|
8485
8416
|
"onDone must be omitted when the Effect output is never"
|
|
8486
8417
|
]
|
|
8487
8418
|
: []
|
|
8488
|
-
): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8419
|
+
): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8489
8420
|
<
|
|
8490
8421
|
const States extends Machine.StateSchemas,
|
|
8491
8422
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8494,10 +8425,12 @@ export const invoke: {
|
|
|
8494
8425
|
const Source extends (
|
|
8495
8426
|
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8496
8427
|
) => Effect.Effect<never, unknown, unknown>,
|
|
8428
|
+
const Config extends object,
|
|
8497
8429
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8498
8430
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8499
8431
|
>(
|
|
8500
8432
|
config:
|
|
8433
|
+
& Config
|
|
8501
8434
|
& EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8502
8435
|
& {
|
|
8503
8436
|
readonly onDone?: never
|
|
@@ -8507,7 +8440,7 @@ export const invoke: {
|
|
|
8507
8440
|
"onFailure must be omitted when the Effect error is never"
|
|
8508
8441
|
]
|
|
8509
8442
|
: []
|
|
8510
|
-
): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8443
|
+
): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8511
8444
|
<
|
|
8512
8445
|
const States extends Machine.StateSchemas,
|
|
8513
8446
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8516,16 +8449,18 @@ export const invoke: {
|
|
|
8516
8449
|
const Source extends (
|
|
8517
8450
|
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8518
8451
|
) => Effect.Effect<never, never, unknown>,
|
|
8452
|
+
const Config extends object,
|
|
8519
8453
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8520
8454
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8521
8455
|
>(
|
|
8522
8456
|
config:
|
|
8457
|
+
& Config
|
|
8523
8458
|
& EffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8524
8459
|
& {
|
|
8525
8460
|
readonly onDone?: never
|
|
8526
8461
|
readonly onFailure?: never
|
|
8527
8462
|
}
|
|
8528
|
-
): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8463
|
+
): NoInfer<Config> & EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8529
8464
|
<
|
|
8530
8465
|
const States extends Machine.StateSchemas,
|
|
8531
8466
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8534,10 +8469,12 @@ export const invoke: {
|
|
|
8534
8469
|
const Source extends (
|
|
8535
8470
|
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8536
8471
|
) => Stream.Stream<unknown, unknown, any>,
|
|
8472
|
+
const Config extends object,
|
|
8537
8473
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8538
8474
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8539
8475
|
>(
|
|
8540
8476
|
config:
|
|
8477
|
+
& Config
|
|
8541
8478
|
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8542
8479
|
& {
|
|
8543
8480
|
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
@@ -8551,7 +8488,7 @@ export const invoke: {
|
|
|
8551
8488
|
"onFailure must be omitted when the Stream error is never"
|
|
8552
8489
|
]
|
|
8553
8490
|
: []
|
|
8554
|
-
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8491
|
+
): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8555
8492
|
<
|
|
8556
8493
|
const States extends Machine.StateSchemas,
|
|
8557
8494
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8560,10 +8497,12 @@ export const invoke: {
|
|
|
8560
8497
|
const Source extends (
|
|
8561
8498
|
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8562
8499
|
) => Stream.Stream<never, unknown, any>,
|
|
8500
|
+
const Config extends object,
|
|
8563
8501
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8564
8502
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8565
8503
|
>(
|
|
8566
8504
|
config:
|
|
8505
|
+
& Config
|
|
8567
8506
|
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8568
8507
|
& {
|
|
8569
8508
|
readonly onElement?: never
|
|
@@ -8574,7 +8513,7 @@ export const invoke: {
|
|
|
8574
8513
|
"onFailure must be omitted when the Stream error is never"
|
|
8575
8514
|
]
|
|
8576
8515
|
: []
|
|
8577
|
-
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8516
|
+
): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8578
8517
|
<
|
|
8579
8518
|
const States extends Machine.StateSchemas,
|
|
8580
8519
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8583,17 +8522,19 @@ export const invoke: {
|
|
|
8583
8522
|
const Source extends (
|
|
8584
8523
|
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8585
8524
|
) => Stream.Stream<never, never, any>,
|
|
8525
|
+
const Config extends object,
|
|
8586
8526
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8587
8527
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8588
8528
|
>(
|
|
8589
8529
|
config:
|
|
8530
|
+
& Config
|
|
8590
8531
|
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8591
8532
|
& {
|
|
8592
8533
|
readonly onElement?: never
|
|
8593
8534
|
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8594
8535
|
readonly onFailure?: never
|
|
8595
8536
|
}
|
|
8596
|
-
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8537
|
+
): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8597
8538
|
<
|
|
8598
8539
|
const States extends Machine.StateSchemas,
|
|
8599
8540
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8602,17 +8543,19 @@ export const invoke: {
|
|
|
8602
8543
|
const Source extends (
|
|
8603
8544
|
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8604
8545
|
) => Stream.Stream<unknown, never, any>,
|
|
8546
|
+
const Config extends object,
|
|
8605
8547
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8606
8548
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8607
8549
|
>(
|
|
8608
8550
|
config:
|
|
8551
|
+
& Config
|
|
8609
8552
|
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8610
8553
|
& {
|
|
8611
8554
|
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8612
8555
|
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8613
8556
|
readonly onFailure?: never
|
|
8614
8557
|
}
|
|
8615
|
-
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8558
|
+
): NoInfer<Config> & StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8616
8559
|
<
|
|
8617
8560
|
const States extends Machine.StateSchemas,
|
|
8618
8561
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8623,64 +8566,60 @@ export const invoke: {
|
|
|
8623
8566
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8624
8567
|
>(
|
|
8625
8568
|
config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8626
|
-
):
|
|
8569
|
+
):
|
|
8570
|
+
& NoInfer<Config>
|
|
8571
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8572
|
+
& Machine.InvokeTyped<void, never, never, never>
|
|
8627
8573
|
<
|
|
8628
8574
|
const States extends Machine.StateSchemas,
|
|
8629
8575
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8630
8576
|
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8631
8577
|
StateId extends Machine.StateIdentifier<States>,
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
ChildRequirements,
|
|
8636
|
-
ChildOutput,
|
|
8637
|
-
ChildInitialError,
|
|
8578
|
+
const Source extends (
|
|
8579
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8580
|
+
) => unknown,
|
|
8638
8581
|
Address extends ChildAddress<never>,
|
|
8582
|
+
const Config extends object,
|
|
8639
8583
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8640
8584
|
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8641
8585
|
>(
|
|
8642
|
-
config:
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
ChildInitialError
|
|
8586
|
+
config:
|
|
8587
|
+
& Config
|
|
8588
|
+
& { readonly logic: Source }
|
|
8589
|
+
& Machine.LogicInvokeArgs<
|
|
8590
|
+
States,
|
|
8591
|
+
Events,
|
|
8592
|
+
Emits,
|
|
8593
|
+
StateId,
|
|
8594
|
+
Machine.LogicStateOf<ReturnType<Source>>,
|
|
8595
|
+
Machine.LogicEventOf<ReturnType<Source>>,
|
|
8596
|
+
Machine.LogicErrorOf<ReturnType<Source>>,
|
|
8597
|
+
Machine.LogicServicesOf<ReturnType<Source>>,
|
|
8598
|
+
Machine.LogicOutputOf<ReturnType<Source>>,
|
|
8599
|
+
Machine.LogicInitialErrorOf<ReturnType<Source>>,
|
|
8600
|
+
Address,
|
|
8601
|
+
Source,
|
|
8602
|
+
InputEvents,
|
|
8603
|
+
ParentEvents
|
|
8661
8604
|
>,
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8605
|
+
..._validation: ReturnType<Source> extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
8606
|
+
"logic factory must return Machine.Logic"
|
|
8607
|
+
]
|
|
8665
8608
|
):
|
|
8666
|
-
&
|
|
8609
|
+
& NoInfer<Config>
|
|
8610
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8667
8611
|
& Machine.InvokeTyped<
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8612
|
+
Machine.LogicOutputOf<ReturnType<Source>>,
|
|
8613
|
+
Machine.LogicErrorOf<ReturnType<Source>>,
|
|
8614
|
+
Machine.LogicServicesOf<ReturnType<Source>>,
|
|
8615
|
+
Machine.LogicInitialErrorOf<ReturnType<Source>>
|
|
8672
8616
|
>
|
|
8673
8617
|
<
|
|
8674
8618
|
const States extends Machine.StateSchemas,
|
|
8675
8619
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8676
8620
|
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8677
8621
|
StateId extends Machine.StateIdentifier<States>,
|
|
8678
|
-
|
|
8679
|
-
ChildEvent,
|
|
8680
|
-
ChildError,
|
|
8681
|
-
ChildRequirements,
|
|
8682
|
-
ChildOutput,
|
|
8683
|
-
ChildInitialError,
|
|
8622
|
+
const Source,
|
|
8684
8623
|
Address extends ChildAddress<never>,
|
|
8685
8624
|
const Config extends object,
|
|
8686
8625
|
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
@@ -8688,30 +8627,34 @@ export const invoke: {
|
|
|
8688
8627
|
>(
|
|
8689
8628
|
config:
|
|
8690
8629
|
& Config
|
|
8630
|
+
& { readonly logic: Source }
|
|
8691
8631
|
& Machine.LogicInvokeArgs<
|
|
8692
8632
|
States,
|
|
8693
8633
|
Events,
|
|
8694
8634
|
Emits,
|
|
8695
8635
|
StateId,
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8636
|
+
Machine.LogicStateOf<Source>,
|
|
8637
|
+
Machine.LogicEventOf<Source>,
|
|
8638
|
+
Machine.LogicErrorOf<Source>,
|
|
8639
|
+
Machine.LogicServicesOf<Source>,
|
|
8640
|
+
Machine.LogicOutputOf<Source>,
|
|
8641
|
+
Machine.LogicInitialErrorOf<Source>,
|
|
8702
8642
|
Address,
|
|
8703
|
-
|
|
8643
|
+
Source,
|
|
8704
8644
|
InputEvents,
|
|
8705
8645
|
ParentEvents
|
|
8706
|
-
|
|
8646
|
+
>,
|
|
8647
|
+
..._validation: Source extends { readonly initial: unknown; readonly run: unknown } ? [] : [
|
|
8648
|
+
"logic must implement Machine.Logic"
|
|
8649
|
+
]
|
|
8707
8650
|
):
|
|
8708
|
-
& Config
|
|
8709
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
8651
|
+
& NoInfer<Config>
|
|
8652
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8710
8653
|
& Machine.InvokeTyped<
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8654
|
+
Machine.LogicOutputOf<Source>,
|
|
8655
|
+
Machine.LogicErrorOf<Source>,
|
|
8656
|
+
Machine.LogicServicesOf<Source>,
|
|
8657
|
+
Machine.LogicInitialErrorOf<Source>
|
|
8715
8658
|
>
|
|
8716
8659
|
<
|
|
8717
8660
|
const States extends Machine.StateSchemas,
|
|
@@ -8728,7 +8671,7 @@ export const invoke: {
|
|
|
8728
8671
|
& Machine.ChildInvokeArgs<States, Events, Emits, StateId, Child["machine"], Child, InputEvents, ParentEvents>
|
|
8729
8672
|
):
|
|
8730
8673
|
& Config
|
|
8731
|
-
& Machine.InvokeOwned<States, Events, Emits, StateId>
|
|
8674
|
+
& Machine.InvokeOwned<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8732
8675
|
& Machine.InvokeTyped<
|
|
8733
8676
|
Machine.Output<Child["machine"]>,
|
|
8734
8677
|
Machine.Error<Child["machine"]> | ActionError<Machine.Services<Child["machine"]>>,
|
|
@@ -8767,10 +8710,7 @@ export const invoke: {
|
|
|
8767
8710
|
* const machine = Machine.make({
|
|
8768
8711
|
* states: States.states,
|
|
8769
8712
|
* events: Machine.events(),
|
|
8770
|
-
* initial: {
|
|
8771
|
-
* target: (to) => to.Idle(),
|
|
8772
|
-
* resolve: ({ target }) => target.from()
|
|
8773
|
-
* }
|
|
8713
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
8774
8714
|
* }).handle({ Idle: {} })
|
|
8775
8715
|
*
|
|
8776
8716
|
* const initialState = Effect.map(Machine.planInitial(machine), (plan) => plan.state)
|
|
@@ -8814,7 +8754,8 @@ export const planInitial: <
|
|
|
8814
8754
|
InputEvents,
|
|
8815
8755
|
ParentEvents
|
|
8816
8756
|
>
|
|
8817
|
-
& EnsureExecutable<States, UnhandledStates, OutputStates
|
|
8757
|
+
& EnsureExecutable<States, UnhandledStates, OutputStates>
|
|
8758
|
+
& Machine.RootCompatible<ParentEvents>,
|
|
8818
8759
|
...args: [...Machine.InputArgs<Input>]
|
|
8819
8760
|
) => Effect.Effect<
|
|
8820
8761
|
& {
|
|
@@ -8899,7 +8840,8 @@ export const initialDefinition: <M extends Machine.Any>(machine: M) => Machine.I
|
|
|
8899
8840
|
* Event handlers retain their handler-key order within each source state and
|
|
8900
8841
|
* are followed by eventless and completion handlers. This function does not
|
|
8901
8842
|
* execute resolvers. Every direct, named, and targetless branch exposes the
|
|
8902
|
-
* destination selected by its required static `target` declaration
|
|
8843
|
+
* destination selected by its required static `target` declaration, while
|
|
8844
|
+
* `acceptance` reports whether the resolver may decline the transition.
|
|
8903
8845
|
*
|
|
8904
8846
|
* @category getters
|
|
8905
8847
|
* @since 0.4.0
|
|
@@ -8952,7 +8894,12 @@ export const configuration: <M extends Machine.Any>(
|
|
|
8952
8894
|
> = internal.configuration
|
|
8953
8895
|
|
|
8954
8896
|
/**
|
|
8955
|
-
* Returns
|
|
8897
|
+
* Returns event tags with at least one structurally eligible handler in the
|
|
8898
|
+
* current state snapshot.
|
|
8899
|
+
*
|
|
8900
|
+
* A `declinable` handler may still reject a concrete event at planning time,
|
|
8901
|
+
* so this is a static candidate query rather than a guarantee that every value
|
|
8902
|
+
* with the returned tag will be handled.
|
|
8956
8903
|
*
|
|
8957
8904
|
* @category getters
|
|
8958
8905
|
* @since 0.4.0
|
|
@@ -9022,17 +8969,12 @@ export const enabled: <
|
|
|
9022
8969
|
* const machine = Machine.make({
|
|
9023
8970
|
* states: States.states,
|
|
9024
8971
|
* events: Machine.events(Toggle),
|
|
9025
|
-
* initial: {
|
|
9026
|
-
* target: (to) => to.Off(),
|
|
9027
|
-
* resolve: ({ target }) => target.from()
|
|
9028
|
-
* }
|
|
8972
|
+
* initial: (to) => to.Off().resolve(({ target }) => target.from())
|
|
9029
8973
|
* }).handle({
|
|
9030
8974
|
* Off: {
|
|
9031
8975
|
* on: {
|
|
9032
|
-
* Toggle:
|
|
9033
|
-
* target
|
|
9034
|
-
* resolve: ({ target }) => target.from()
|
|
9035
|
-
* })
|
|
8976
|
+
* Toggle: (to) =>
|
|
8977
|
+
* to.full.On().resolve(({ target }) => target.from())
|
|
9036
8978
|
* }
|
|
9037
8979
|
* },
|
|
9038
8980
|
* On: {}
|
|
@@ -9082,7 +9024,8 @@ export const plan: <
|
|
|
9082
9024
|
InputEvents,
|
|
9083
9025
|
ParentEvents
|
|
9084
9026
|
>
|
|
9085
|
-
& EnsureExecutable<States, UnhandledStates, OutputStates
|
|
9027
|
+
& EnsureExecutable<States, UnhandledStates, OutputStates>
|
|
9028
|
+
& Machine.RootCompatible<ParentEvents>,
|
|
9086
9029
|
state: Machine.Snapshot<States>,
|
|
9087
9030
|
event: Machine.EventInputOf<InputEvents>
|
|
9088
9031
|
) => Effect.Effect<
|
|
@@ -9344,7 +9287,8 @@ export const prepare: <
|
|
|
9344
9287
|
InputEvents,
|
|
9345
9288
|
ParentEvents
|
|
9346
9289
|
>
|
|
9347
|
-
& EnsureExecutable<States, UnhandledStates, OutputStates
|
|
9290
|
+
& EnsureExecutable<States, UnhandledStates, OutputStates>
|
|
9291
|
+
& Machine.RootCompatible<ParentEvents>,
|
|
9348
9292
|
...args: [...Machine.InputArgs<Input>]
|
|
9349
9293
|
) => Effect.Effect<
|
|
9350
9294
|
Prepared<
|
|
@@ -9405,10 +9349,7 @@ export const prepare: <
|
|
|
9405
9349
|
* const machine = Machine.make({
|
|
9406
9350
|
* states: States.states,
|
|
9407
9351
|
* events: Machine.events(),
|
|
9408
|
-
* initial: {
|
|
9409
|
-
* target: (to) => to.Idle(),
|
|
9410
|
-
* resolve: ({ target }) => target.from()
|
|
9411
|
-
* }
|
|
9352
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
9412
9353
|
* }).handle({ Idle: {} })
|
|
9413
9354
|
*
|
|
9414
9355
|
* const state = Effect.gen(function*() {
|
|
@@ -9455,7 +9396,8 @@ export const start: <
|
|
|
9455
9396
|
InputEvents,
|
|
9456
9397
|
ParentEvents
|
|
9457
9398
|
>
|
|
9458
|
-
& EnsureExecutable<States, UnhandledStates, OutputStates
|
|
9399
|
+
& EnsureExecutable<States, UnhandledStates, OutputStates>
|
|
9400
|
+
& Machine.RootCompatible<ParentEvents>,
|
|
9459
9401
|
...args: [...Machine.InputArgs<Input>]
|
|
9460
9402
|
) => Effect.Effect<
|
|
9461
9403
|
MachineRef<
|
|
@@ -9518,10 +9460,7 @@ export const start: <
|
|
|
9518
9460
|
* const machine = Machine.make({
|
|
9519
9461
|
* states: States.states,
|
|
9520
9462
|
* events: Machine.events(),
|
|
9521
|
-
* initial: {
|
|
9522
|
-
* target: (to) => to.Idle(),
|
|
9523
|
-
* resolve: ({ target }) => target.from()
|
|
9524
|
-
* }
|
|
9463
|
+
* initial: (to) => to.Idle().resolve(({ target }) => target.from())
|
|
9525
9464
|
* }).handle({ Idle: {} })
|
|
9526
9465
|
*
|
|
9527
9466
|
* const resumed = Effect.gen(function*() {
|
|
@@ -9570,7 +9509,8 @@ export const resume: <
|
|
|
9570
9509
|
InputEvents,
|
|
9571
9510
|
ParentEvents
|
|
9572
9511
|
>
|
|
9573
|
-
& EnsureExecutable<States, UnhandledStates, OutputStates
|
|
9512
|
+
& EnsureExecutable<States, UnhandledStates, OutputStates>
|
|
9513
|
+
& Machine.RootCompatible<ParentEvents>,
|
|
9574
9514
|
snapshot: Machine.Snapshot<States>
|
|
9575
9515
|
) => Effect.Effect<
|
|
9576
9516
|
MachineRef<
|