@typeonce/effect-machine 0.12.0 → 0.13.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 +56 -4
- package/dist/Machine.d.ts +353 -84
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +12 -10
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +1 -0
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js +23 -0
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/commandRuntime.d.ts.map +1 -1
- package/dist/internal/machine/commandRuntime.js +2 -5
- package/dist/internal/machine/commandRuntime.js.map +1 -1
- package/dist/internal/machine/configuration.d.ts +5 -0
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +6 -2
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts +1 -0
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +43 -18
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/initialization.d.ts +5 -0
- package/dist/internal/machine/initialization.d.ts.map +1 -0
- package/dist/internal/machine/initialization.js +61 -0
- package/dist/internal/machine/initialization.js.map +1 -0
- package/dist/internal/machine/inspectionRuntime.d.ts +25 -0
- package/dist/internal/machine/inspectionRuntime.d.ts.map +1 -0
- package/dist/internal/machine/inspectionRuntime.js +79 -0
- package/dist/internal/machine/inspectionRuntime.js.map +1 -0
- package/dist/internal/machine/invocation.d.ts +2 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +17 -10
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/machine.d.ts +1 -2
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +21 -6
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +15 -0
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +117 -44
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +4 -2
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +27 -3
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +440 -64
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/symbols.d.ts +2 -0
- package/dist/internal/machine/symbols.d.ts.map +1 -1
- package/dist/internal/machine/symbols.js +2 -0
- package/dist/internal/machine/symbols.js.map +1 -1
- package/dist/internal/machine/topology.d.ts +13 -0
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +9 -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 +3 -3
- package/dist/internal/testing/machine/finiteModel.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +9 -0
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +9 -0
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +102 -9
- package/package.json +5 -5
- package/src/Machine.ts +505 -174
- package/src/internal/machine/atom.ts +26 -0
- package/src/internal/machine/commandRuntime.ts +2 -9
- package/src/internal/machine/configuration.ts +28 -3
- package/src/internal/machine/executionPlan.ts +50 -17
- package/src/internal/machine/initialization.ts +73 -0
- package/src/internal/machine/inspectionRuntime.ts +102 -0
- package/src/internal/machine/invocation.ts +37 -12
- package/src/internal/machine/machine.ts +31 -6
- package/src/internal/machine/planner.ts +136 -42
- package/src/internal/machine/process.ts +4 -2
- package/src/internal/machine/runtime.ts +661 -89
- package/src/internal/machine/symbols.ts +3 -0
- package/src/internal/machine/topology.ts +27 -0
- package/src/internal/testing/machine/finiteModel.ts +8 -7
- package/src/unstable/reactivity/AtomMachine.ts +12 -0
package/dist/Machine.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type * as Cause from "effect/Cause";
|
|
7
7
|
import type * as Duration from "effect/Duration";
|
|
8
8
|
import type * as Effect from "effect/Effect";
|
|
9
|
+
import type * as Exit from "effect/Exit";
|
|
9
10
|
import type * as Option from "effect/Option";
|
|
10
11
|
import type { Pipeable } from "effect/Pipeable";
|
|
11
12
|
import type * as Schema from "effect/Schema";
|
|
@@ -534,13 +535,30 @@ type NodeBuilderMethod<Node, Arguments extends ReadonlyArray<unknown>, Result, F
|
|
|
534
535
|
readonly from: FromCallable<FromArguments, FromResult>;
|
|
535
536
|
};
|
|
536
537
|
type NodeMethod<Node, Arguments extends ReadonlyArray<unknown>, Result, FromArguments extends ReadonlyArray<unknown>> = Machine.NodeSchema<Node> extends never ? FromMethod<FromArguments, Result> : ((...args: Arguments) => Result) & FromMethod<FromArguments, Result>;
|
|
538
|
+
type NodeMethodWithInitial<Node, Arguments extends ReadonlyArray<unknown>, Result, FromArguments extends ReadonlyArray<unknown>, Path extends string> = Machine.NodeSchema<Node> extends never ? {
|
|
539
|
+
readonly from: FromCallable<FromArguments, Machine.StateConstruction<Result>>;
|
|
540
|
+
readonly initial: InitialTargetFactory<Node, Path>;
|
|
541
|
+
} : ((...args: Arguments) => Result) & {
|
|
542
|
+
readonly from: FromCallable<FromArguments, Machine.StateConstruction<Result>>;
|
|
543
|
+
readonly initial: InitialTargetFactory<Node, Path>;
|
|
544
|
+
};
|
|
545
|
+
interface InitialTargetMethod<Node, Path extends string> {
|
|
546
|
+
/** Enters this state through its declared initial configuration. */
|
|
547
|
+
readonly initial: InitialTargetFactory<Node, Path>;
|
|
548
|
+
}
|
|
549
|
+
interface InitialTargetFactory<Node, Path extends string> {
|
|
550
|
+
(...args: WithNodeValue<Node, readonly []>): Machine.InitialTarget<Path>;
|
|
551
|
+
readonly from: FromCallable<WithNodeInput<Node, readonly []>, Machine.StateConstruction<Machine.InitialTarget<Path>>>;
|
|
552
|
+
}
|
|
537
553
|
type NodeConstructionSelectorFromCallable<Node, Builder, Result> = Machine.NodeSchema<Node> extends never ? {
|
|
538
554
|
<Selected extends ConstructionResult<Result>>(state: (builder: Builder) => Selected): Machine.StateConstruction<UnwrapConstruction<Selected>>;
|
|
539
555
|
} : ConstructionSelectorFromCallable<NodeMakeInput<Node>, Builder, Result>;
|
|
540
|
-
type NestedTargetMethod<Node, Builder, Result> = Machine.NodeSchema<Node> extends never ? {
|
|
556
|
+
type NestedTargetMethod<Node, Builder, Result, Path extends string> = Machine.NodeSchema<Node> extends never ? {
|
|
541
557
|
readonly from: NodeConstructionSelectorFromCallable<Node, Builder, Result>;
|
|
558
|
+
readonly initial: InitialTargetFactory<Node, Path>;
|
|
542
559
|
} : (<Selected extends ConstructionResult<Result>>(value: NodeValue<Node>, state: (builder: Builder) => Selected) => Selected) & {
|
|
543
560
|
readonly from: NodeConstructionSelectorFromCallable<Node, Builder, Result>;
|
|
561
|
+
readonly initial: InitialTargetFactory<Node, Path>;
|
|
544
562
|
};
|
|
545
563
|
type ConstructionSelectorFromCallable<Input, Builder, Result> = {} extends Input ? {
|
|
546
564
|
<Selected extends ConstructionResult<Result>>(state: (builder: Builder) => Selected): Machine.StateConstruction<UnwrapConstruction<Selected>>;
|
|
@@ -622,6 +640,14 @@ type FullSnapshotFromArguments<States extends Machine.StateSchemas, StateId exte
|
|
|
622
640
|
state: (builder: FullSnapshotBuilderWithPrefix<Children, Path>) => ConstructionResult<Machine.SnapshotWithPrefix<Children, Path> | Machine.ChoiceTargetInstruction<Machine.ChoiceIdentifierWithPrefix<Children, Path>>>
|
|
623
641
|
]> : WithNodeInput<Node, []> : never;
|
|
624
642
|
type FullSnapshotResult<States extends Machine.StateSchemas, StateId extends ActiveStateKey<States>, Prefix extends string, Path extends string = Machine.JoinPath<Prefix, StateId>> = Machine.SnapshotByIdentifierWithPath<States, StateId, Path>;
|
|
643
|
+
type InitialEntryStateKey<States extends Machine.StateSchemas> = {
|
|
644
|
+
readonly [Key in ActiveStateKey<States>]: States[Key] extends {
|
|
645
|
+
readonly states: Machine.StateSchemas;
|
|
646
|
+
} ? Key : never;
|
|
647
|
+
}[ActiveStateKey<States>];
|
|
648
|
+
type FullInitialTargetBuilder<States extends Machine.StateSchemas> = {
|
|
649
|
+
readonly [Key in InitialEntryStateKey<States>]: InitialTargetMethod<States[Key], Key>;
|
|
650
|
+
};
|
|
625
651
|
type FullParallelBuilder<States extends Machine.StateSchemas, Prefix extends string, Remaining extends ActiveStateKey<States> = ActiveStateKey<States>, Regions = {}, Constructed extends boolean = false> = SnapshotBuilderComplete<Regions, Constructed> & {
|
|
626
652
|
readonly [Key in Remaining]: NodeBuilderMethod<States[Key], FullSnapshotArguments<States, Key, Prefix>, FullParallelBuilder<States, Prefix, Exclude<Remaining, Key>, Regions & {
|
|
627
653
|
readonly [Region in Key]: FullSnapshotResult<States, Key, Prefix>;
|
|
@@ -703,13 +729,13 @@ type LocalTargetBuilderWithPrefix<AllStates extends Machine.StateSchemas, States
|
|
|
703
729
|
type LocalTargetMethod<AllStates extends Machine.StateSchemas, States extends Machine.StateSchemas, StateId extends ActiveStateKey<States>, Prefix extends string, Source extends Machine.StateNodeIdentifier<AllStates>, Path extends string = Machine.JoinPath<Prefix, StateId>> = States[StateId] extends infer Node ? Node extends {
|
|
704
730
|
readonly type: "parallel";
|
|
705
731
|
readonly states: infer Children extends Machine.StateSchemas;
|
|
706
|
-
} ? Source extends Path | `${Path}.${string}` ? NestedTargetMethod<Node, LocalTargetBuilderWithPrefix<AllStates, Children, Path, Source>, LocalTargetResultWithPrefix<AllStates, Children, Path
|
|
732
|
+
} ? Source extends Path | `${Path}.${string}` ? NestedTargetMethod<Node, LocalTargetBuilderWithPrefix<AllStates, Children, Path, Source>, LocalTargetResultWithPrefix<AllStates, Children, Path>, Path> : NodeMethodWithInitial<Node, WithNodeValue<Node, [
|
|
707
733
|
states: (builder: FullParallelBuilder<Children, Path>) => SnapshotBuilderComplete<Machine.SnapshotRegionsWithPrefix<Children, Path>>
|
|
708
734
|
]>, Machine.Target<AllStates, StateIdentifierFromPath<AllStates, Path>>, WithNodeInput<Node, [
|
|
709
735
|
states: (builder: FullParallelBuilder<Children, Path>) => SnapshotBuilderComplete<Machine.SnapshotRegionsWithPrefix<Children, Path>, boolean>
|
|
710
|
-
]
|
|
736
|
+
]>, Path> : Node extends {
|
|
711
737
|
readonly states: infer Children extends Machine.StateSchemas;
|
|
712
|
-
} ? NestedTargetMethod<Node, LocalTargetBuilderWithPrefix<AllStates, Children, Path, Source>, LocalTargetResultWithPrefix<AllStates, Children, Path
|
|
738
|
+
} ? NestedTargetMethod<Node, LocalTargetBuilderWithPrefix<AllStates, Children, Path, Source>, LocalTargetResultWithPrefix<AllStates, Children, Path>, Path> : NodeMethod<Node, WithNodeValue<Node, []>, Machine.Target<AllStates, StateIdentifierFromPath<AllStates, Path>>, WithNodeInput<Node, []>> : never;
|
|
713
739
|
type LocalTargetBuilderForScope<States extends Machine.StateSchemas, Scope extends Machine.StateIdentifier<States>, Source extends Machine.StateNodeIdentifier<States>> = ChildrenOf<States, Scope> extends infer Children extends Machine.StateSchemas ? LocalTargetBuilderWithPrefix<States, Children, Scope, Source> & (Scope extends Machine.ValuedStateIdentifier<States> ? {
|
|
714
740
|
/**
|
|
715
741
|
* Updates the value of the state containing the local group and moves to
|
|
@@ -737,13 +763,13 @@ type BranchTargetBuilderWithPrefix<AllStates extends Machine.StateSchemas, State
|
|
|
737
763
|
type BranchTargetMethod<AllStates extends Machine.StateSchemas, States extends Machine.StateSchemas, StateId extends ActiveStateKey<States>, Prefix extends string, Source extends Machine.StateNodeIdentifier<AllStates>, Path extends string = Machine.JoinPath<Prefix, StateId>> = States[StateId] extends infer Node ? Node extends {
|
|
738
764
|
readonly type: "parallel";
|
|
739
765
|
readonly states: infer Children extends Machine.StateSchemas;
|
|
740
|
-
} ? Source extends Path | `${Path}.${string}` ? NestedTargetMethod<Node, BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source>, BranchTargetResultWithPrefix<AllStates, Children, Path
|
|
766
|
+
} ? Source extends Path | `${Path}.${string}` ? NestedTargetMethod<Node, BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source>, BranchTargetResultWithPrefix<AllStates, Children, Path>, Path> & BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source> : NodeMethodWithInitial<Node, WithNodeValue<Node, [
|
|
741
767
|
states: (builder: FullParallelBuilder<Children, Path>) => SnapshotBuilderComplete<Machine.SnapshotRegionsWithPrefix<Children, Path>>
|
|
742
768
|
]>, Machine.Target<AllStates, StateIdentifierFromPath<AllStates, Path>>, WithNodeInput<Node, [
|
|
743
769
|
states: (builder: FullParallelBuilder<Children, Path>) => SnapshotBuilderComplete<Machine.SnapshotRegionsWithPrefix<Children, Path>, boolean>
|
|
744
|
-
]
|
|
770
|
+
]>, Path> : Node extends {
|
|
745
771
|
readonly states: infer Children extends Machine.StateSchemas;
|
|
746
|
-
} ? NestedTargetMethod<Node, BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source>, BranchTargetResultWithPrefix<AllStates, Children, Path
|
|
772
|
+
} ? NestedTargetMethod<Node, BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source>, BranchTargetResultWithPrefix<AllStates, Children, Path>, Path> & BranchTargetBuilderWithPrefix<AllStates, Children, Path, Source> : NodeMethod<Node, WithNodeValue<Node, []>, Machine.Target<AllStates, StateIdentifierFromPath<AllStates, Path>>, WithNodeInput<Node, []>> : never;
|
|
747
773
|
type BranchTargetBuilderForRoot<States extends Machine.StateSchemas, Root extends ActiveStateKey<States>, Source extends Machine.StateNodeIdentifier<States>> = {
|
|
748
774
|
readonly [Key in Root]: BranchTargetMethod<States, States, Key, "", Source>;
|
|
749
775
|
};
|
|
@@ -815,6 +841,164 @@ export type RuntimeSnapshot<State, Error = never, Output = never> = {
|
|
|
815
841
|
readonly status: "stopped";
|
|
816
842
|
readonly state: State;
|
|
817
843
|
};
|
|
844
|
+
/**
|
|
845
|
+
* Live, root-scoped records describing one prepared machine tree.
|
|
846
|
+
*
|
|
847
|
+
* Inspection records deliberately erase machine-specific values to `unknown`:
|
|
848
|
+
* one stream may contain unrelated root, child-machine, and `Logic` protocols.
|
|
849
|
+
* The record structure remains a closed discriminated union, while typed
|
|
850
|
+
* application observation continues through `changes` and `emissions`.
|
|
851
|
+
*
|
|
852
|
+
* @category models
|
|
853
|
+
* @since 0.13.0
|
|
854
|
+
*/
|
|
855
|
+
export declare namespace Inspection {
|
|
856
|
+
/** Read-only identity of a local machine endpoint. */
|
|
857
|
+
interface Endpoint {
|
|
858
|
+
readonly id: string;
|
|
859
|
+
readonly sessionId: string;
|
|
860
|
+
}
|
|
861
|
+
/** Read-only identity of a runtime represented in the inspection tree. */
|
|
862
|
+
interface Subject extends Endpoint {
|
|
863
|
+
readonly kind: "Machine" | "Logic";
|
|
864
|
+
}
|
|
865
|
+
/** Causal origin of an inspected runtime. */
|
|
866
|
+
type Origin = {
|
|
867
|
+
readonly _tag: "Root";
|
|
868
|
+
} | {
|
|
869
|
+
readonly _tag: "Invoke";
|
|
870
|
+
readonly ownerPath: string;
|
|
871
|
+
readonly invokeId: string;
|
|
872
|
+
} | {
|
|
873
|
+
readonly _tag: "Spawn";
|
|
874
|
+
readonly address: string | undefined;
|
|
875
|
+
};
|
|
876
|
+
/** Causal owner of a send or emission. */
|
|
877
|
+
type Causation = {
|
|
878
|
+
readonly _tag: "Initialization";
|
|
879
|
+
} | {
|
|
880
|
+
readonly _tag: "Macrostep";
|
|
881
|
+
readonly macrostepId: number;
|
|
882
|
+
} | {
|
|
883
|
+
readonly _tag: "Activity";
|
|
884
|
+
readonly activitySessionId: string;
|
|
885
|
+
};
|
|
886
|
+
/** Closed command projection safe for observation. */
|
|
887
|
+
type Command = {
|
|
888
|
+
readonly _tag: "SendTo";
|
|
889
|
+
readonly target: Endpoint | {
|
|
890
|
+
readonly id: string;
|
|
891
|
+
};
|
|
892
|
+
readonly event: unknown;
|
|
893
|
+
} | {
|
|
894
|
+
readonly _tag: "Stop";
|
|
895
|
+
readonly target: Endpoint | {
|
|
896
|
+
readonly id: string;
|
|
897
|
+
};
|
|
898
|
+
};
|
|
899
|
+
/** One statechart microstep in a committed macrostep. */
|
|
900
|
+
interface Microstep {
|
|
901
|
+
readonly event: unknown;
|
|
902
|
+
readonly transitions: ReadonlyArray<Machine.RetainedTransition>;
|
|
903
|
+
readonly raisedEvents: ReadonlyArray<unknown>;
|
|
904
|
+
readonly emittedEvents: ReadonlyArray<unknown>;
|
|
905
|
+
readonly commands: ReadonlyArray<Command>;
|
|
906
|
+
readonly exitPaths: ReadonlyArray<string>;
|
|
907
|
+
readonly entryPaths: ReadonlyArray<string>;
|
|
908
|
+
readonly changed: boolean;
|
|
909
|
+
}
|
|
910
|
+
/** Common ordering and identity fields for every record. */
|
|
911
|
+
interface Base {
|
|
912
|
+
/** Total publication order within this prepared root. */
|
|
913
|
+
readonly sequence: number;
|
|
914
|
+
/** Session id of the prepared root that owns this inspection stream. */
|
|
915
|
+
readonly rootSessionId: string;
|
|
916
|
+
/** Runtime instance described by this record. */
|
|
917
|
+
readonly subject: Subject;
|
|
918
|
+
}
|
|
919
|
+
/** Announces allocation of a root or owned process identity. */
|
|
920
|
+
interface Created extends Base {
|
|
921
|
+
readonly _tag: "Created";
|
|
922
|
+
readonly parent: Subject | undefined;
|
|
923
|
+
readonly origin: Origin;
|
|
924
|
+
/** Compiled statechart definition; absent for generic `Logic`. */
|
|
925
|
+
readonly definition: Machine.Any | undefined;
|
|
926
|
+
}
|
|
927
|
+
/** Announces successful initialization. */
|
|
928
|
+
interface Initialized extends Base {
|
|
929
|
+
readonly _tag: "Initialized";
|
|
930
|
+
readonly snapshot: RuntimeSnapshot<unknown, unknown, unknown>;
|
|
931
|
+
readonly initialEntryPaths: ReadonlyArray<string>;
|
|
932
|
+
readonly microsteps: ReadonlyArray<Microstep>;
|
|
933
|
+
}
|
|
934
|
+
/** Announces failure before an initial runtime snapshot exists. */
|
|
935
|
+
interface StartFailed extends Base {
|
|
936
|
+
readonly _tag: "StartFailed";
|
|
937
|
+
readonly cause: Cause.Cause<unknown>;
|
|
938
|
+
}
|
|
939
|
+
/** Announces acceptance of an event by a local mailbox. */
|
|
940
|
+
interface EventSent extends Base {
|
|
941
|
+
readonly _tag: "EventSent";
|
|
942
|
+
readonly deliveryId: number;
|
|
943
|
+
readonly source: Subject | undefined;
|
|
944
|
+
readonly target: Endpoint;
|
|
945
|
+
readonly event: unknown;
|
|
946
|
+
readonly causedBy: Causation | undefined;
|
|
947
|
+
}
|
|
948
|
+
/** Announces complete processing of one statechart mailbox event. */
|
|
949
|
+
interface EventProcessed extends Base {
|
|
950
|
+
readonly _tag: "EventProcessed";
|
|
951
|
+
readonly macrostepId: number;
|
|
952
|
+
readonly deliveryId: number;
|
|
953
|
+
readonly source: Subject | undefined;
|
|
954
|
+
readonly event: unknown;
|
|
955
|
+
readonly before: RuntimeSnapshot<unknown, unknown, unknown>;
|
|
956
|
+
readonly after: RuntimeSnapshot<unknown, unknown, unknown>;
|
|
957
|
+
readonly handled: boolean;
|
|
958
|
+
readonly configurationChanged: boolean;
|
|
959
|
+
readonly microsteps: ReadonlyArray<Microstep>;
|
|
960
|
+
}
|
|
961
|
+
/** Announces a direct state update made by generic `Logic`. */
|
|
962
|
+
interface StateChanged extends Base {
|
|
963
|
+
readonly _tag: "StateChanged";
|
|
964
|
+
readonly before: unknown;
|
|
965
|
+
readonly after: unknown;
|
|
966
|
+
readonly causedByDeliveryId: number | undefined;
|
|
967
|
+
}
|
|
968
|
+
/** Announces actual publication on a machine's domain emission stream. */
|
|
969
|
+
interface Emitted extends Base {
|
|
970
|
+
readonly _tag: "Emitted";
|
|
971
|
+
readonly emission: unknown;
|
|
972
|
+
readonly causedBy: Causation | undefined;
|
|
973
|
+
}
|
|
974
|
+
/** Identity of one Effect or timer invocation run. */
|
|
975
|
+
interface Activity {
|
|
976
|
+
readonly id: string;
|
|
977
|
+
readonly sessionId: string;
|
|
978
|
+
readonly owner: Subject;
|
|
979
|
+
readonly ownerPath: string;
|
|
980
|
+
readonly kind: "Effect" | "Timer";
|
|
981
|
+
}
|
|
982
|
+
/** Announces an Effect or timer invocation starting. */
|
|
983
|
+
interface ActivityStarted extends Base {
|
|
984
|
+
readonly _tag: "ActivityStarted";
|
|
985
|
+
readonly activity: Activity;
|
|
986
|
+
}
|
|
987
|
+
/** Announces an Effect or timer invocation outcome. */
|
|
988
|
+
interface ActivityStopped extends Base {
|
|
989
|
+
readonly _tag: "ActivityStopped";
|
|
990
|
+
readonly activity: Activity;
|
|
991
|
+
/** Success or failure from the invoke; interruption means its owner stopped it. */
|
|
992
|
+
readonly exit: Exit.Exit<unknown, unknown>;
|
|
993
|
+
}
|
|
994
|
+
/** Announces a terminal local runtime snapshot. */
|
|
995
|
+
interface Terminated extends Base {
|
|
996
|
+
readonly _tag: "Terminated";
|
|
997
|
+
readonly snapshot: RuntimeSnapshot<unknown, unknown, unknown>;
|
|
998
|
+
}
|
|
999
|
+
/** Complete live inspection protocol. */
|
|
1000
|
+
type Event = Created | Initialized | StartFailed | EventSent | EventProcessed | StateChanged | Emitted | ActivityStarted | ActivityStopped | Terminated;
|
|
1001
|
+
}
|
|
818
1002
|
/**
|
|
819
1003
|
* Represents a classified terminal outcome derived from a runtime snapshot.
|
|
820
1004
|
*
|
|
@@ -878,6 +1062,13 @@ export interface Prepared<out State, in Event, out Error, out Output, out Emitte
|
|
|
878
1062
|
readonly changes: Stream.Stream<RuntimeSnapshot<State, Error, Output>, StartError>;
|
|
879
1063
|
/** Streams ephemeral notifications published after subscription. */
|
|
880
1064
|
readonly emissions: Stream.Stream<Emitted>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Streams ordered operational records for this root and every locally owned
|
|
1067
|
+
* descendant. The stream is hot, non-replayed, never fails, and completes
|
|
1068
|
+
* after the prepared root terminates. Subscribe before evaluating `start` to
|
|
1069
|
+
* observe initialization.
|
|
1070
|
+
*/
|
|
1071
|
+
readonly inspection: Stream.Stream<Inspection.Event>;
|
|
881
1072
|
/** Initializes this machine once and returns its running reference. */
|
|
882
1073
|
readonly start: Effect.Effect<MachineRef<State, Event, Error, Output, Emitted>, StartError, StartRequirements>;
|
|
883
1074
|
}
|
|
@@ -2419,6 +2610,22 @@ export declare namespace Machine {
|
|
|
2419
2610
|
readonly path: HistoryId;
|
|
2420
2611
|
readonly parent: Extract<ParentPath<HistoryId>, StateIdentifier<States>>;
|
|
2421
2612
|
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Transition instruction that enters a compound or parallel state through
|
|
2615
|
+
* its declared initial configuration.
|
|
2616
|
+
*
|
|
2617
|
+
* @category models
|
|
2618
|
+
* @since 0.13.0
|
|
2619
|
+
*/
|
|
2620
|
+
interface InitialTarget<StateId extends string> {
|
|
2621
|
+
readonly [Topology.TargetTypeId]: typeof Topology.TargetTypeId;
|
|
2622
|
+
readonly [Topology.TargetSnapshotTypeId]?: never;
|
|
2623
|
+
readonly [Topology.InitialTargetTypeId]: typeof Topology.InitialTargetTypeId;
|
|
2624
|
+
readonly _tag: "InitialTarget";
|
|
2625
|
+
readonly path: StateId;
|
|
2626
|
+
readonly value: never;
|
|
2627
|
+
readonly values?: never;
|
|
2628
|
+
}
|
|
2422
2629
|
/** Branded transient target instruction used while constructing initial states. */
|
|
2423
2630
|
interface ChoiceTargetInstruction<ChoiceId extends string = string> {
|
|
2424
2631
|
readonly [Topology.ChoiceTargetTypeId]: typeof Topology.ChoiceTargetTypeId;
|
|
@@ -2443,7 +2650,7 @@ export declare namespace Machine {
|
|
|
2443
2650
|
* @category utility types
|
|
2444
2651
|
* @since 0.4.0
|
|
2445
2652
|
*/
|
|
2446
|
-
type FullTargetBuilder<States extends StateSchemas> = FullSnapshotBuilderWithPrefix<States>;
|
|
2653
|
+
type FullTargetBuilder<States extends StateSchemas> = [InitialEntryStateKey<States>] extends [never] ? FullSnapshotBuilderWithPrefix<States> : FullSnapshotBuilderWithPrefix<States> & FullInitialTargetBuilder<States>;
|
|
2447
2654
|
/**
|
|
2448
2655
|
* Builder for a complete fallback configuration containing a history owner.
|
|
2449
2656
|
*
|
|
@@ -2784,9 +2991,9 @@ export declare namespace Machine {
|
|
|
2784
2991
|
*/
|
|
2785
2992
|
type StateActionReturn<Config, Key extends "entry" | "exit"> = Key extends keyof Config ? NonNullable<Config[Key]> extends (...args: any) => infer Ret ? Ret : never : never;
|
|
2786
2993
|
/** Extracts the return value from an implicit initial child implementation. */
|
|
2787
|
-
type
|
|
2788
|
-
readonly
|
|
2789
|
-
} ? NonNullable<
|
|
2994
|
+
type StateInitializeReturn<Config> = Config extends {
|
|
2995
|
+
readonly initialize?: infer Initialize;
|
|
2996
|
+
} ? NonNullable<Initialize> extends (...args: any) => infer Ret ? Ret : never : never;
|
|
2790
2997
|
/** Extracts the return values from a state's history defaults. */
|
|
2791
2998
|
type HistoryDefaultReturn<Config> = Config extends {
|
|
2792
2999
|
readonly history?: infer History;
|
|
@@ -2837,10 +3044,11 @@ export declare namespace Machine {
|
|
|
2837
3044
|
* @since 0.4.0
|
|
2838
3045
|
*/
|
|
2839
3046
|
type InvokeResolvedSource<Source> = Source extends (...args: any) => infer Resolved ? Resolved : Source;
|
|
3047
|
+
type InvokeFactoryResult<Source> = Source extends (...args: any) => infer Resolved ? Resolved : never;
|
|
2840
3048
|
type ChildMachineLogic<Child> = Child extends ChildMachine<string, infer M> ? Logic<Snapshot<States<M>>, EventInput<InputEvent<M>>, Error<M> | ActionError<Services<M>> | InfiniteTransitionError | MachineSchemaDecodeError | StoppedError, ExcludeCompatibleRuntime<Exclude<ExecutionServices<InitialServices<M> | Services<M>>, internalRuntime.MachineRuntime>, Event<M>, Emit<M>>, Output<M>, InitialError<M> | Error<M> | ActionError<InitialServices<M> | Services<M>> | InfiniteTransitionError | MachineSchemaDecodeError | StartupError | StoppedError> : never;
|
|
2841
3049
|
type InvokeLogic<Invoke> = Invoke extends {
|
|
2842
3050
|
readonly effect: infer Source;
|
|
2843
|
-
} ?
|
|
3051
|
+
} ? InvokeFactoryResult<Source> extends infer Fx extends Effect.Effect<any, any, any> ? Logic<void, never, Effect.Error<Fx>, Effect.Services<Fx>, Effect.Success<Fx>> : never : Invoke extends {
|
|
2844
3052
|
readonly after: unknown;
|
|
2845
3053
|
} ? Logic<void, never, never, never, void> : Invoke extends {
|
|
2846
3054
|
readonly logic: infer Source;
|
|
@@ -2967,11 +3175,11 @@ export declare namespace Machine {
|
|
|
2967
3175
|
* @category utility types
|
|
2968
3176
|
* @since 0.4.0
|
|
2969
3177
|
*/
|
|
2970
|
-
type ConfigServices<Config> = Effect.Services<EventHandlerReturn<Config>> | Effect.Services<AlwaysReturn<Config>> | Effect.Services<DoneReturn<Config>> | Effect.Services<StateActionReturn<Config, "entry">> | Effect.Services<StateActionReturn<Config, "exit">> | Effect.Services<
|
|
2971
|
-
type InvokeTransition<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Context> = ((context: Context
|
|
3178
|
+
type ConfigServices<Config> = Effect.Services<EventHandlerReturn<Config>> | Effect.Services<AlwaysReturn<Config>> | Effect.Services<DoneReturn<Config>> | Effect.Services<StateActionReturn<Config, "entry">> | Effect.Services<StateActionReturn<Config, "exit">> | Effect.Services<HistoryDefaultReturn<Config>> | Effect.Services<ChoiceReturn<Config>> | InvokeRequirements<Config>;
|
|
3179
|
+
type InvokeTransition<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Context> = ((context: NoInfer<Context>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => HandlerResult<States, any, any>) | {
|
|
2972
3180
|
readonly reenter?: boolean;
|
|
2973
3181
|
readonly targets?: ReadonlyArray<StateNodeIdentifier<States>>;
|
|
2974
|
-
readonly transition: (context: Context
|
|
3182
|
+
readonly transition: (context: NoInfer<Context>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => HandlerResult<States, any, any>;
|
|
2975
3183
|
};
|
|
2976
3184
|
type InvokeSource<Value, Context> = Value | ((context: Context) => Value);
|
|
2977
3185
|
interface AnyLogicSource {
|
|
@@ -2995,7 +3203,7 @@ export declare namespace Machine {
|
|
|
2995
3203
|
}
|
|
2996
3204
|
type InvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = InvokeOwned<States, Events, Emits, StateId> & ({
|
|
2997
3205
|
readonly id: string;
|
|
2998
|
-
readonly effect:
|
|
3206
|
+
readonly effect: (context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<any, any, any>;
|
|
2999
3207
|
readonly after?: never;
|
|
3000
3208
|
readonly logic?: never;
|
|
3001
3209
|
readonly child?: never;
|
|
@@ -3059,15 +3267,6 @@ export declare namespace Machine {
|
|
|
3059
3267
|
} : {
|
|
3060
3268
|
readonly onFailure?: never;
|
|
3061
3269
|
} : never;
|
|
3062
|
-
type EffectInvokeArgs<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, Fx extends Effect.Effect<any, any, any>, Source = Fx, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = {
|
|
3063
|
-
readonly id: InvokeLifecycleId;
|
|
3064
|
-
readonly effect: Source;
|
|
3065
|
-
readonly after?: never;
|
|
3066
|
-
readonly logic?: never;
|
|
3067
|
-
readonly child?: never;
|
|
3068
|
-
readonly address?: never;
|
|
3069
|
-
readonly onSnapshot?: never;
|
|
3070
|
-
} & InvokeDoneRequirement<Effect.Success<NoInfer<Fx>>, InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<NoInfer<Fx>>, InputEvents, ParentEvents>>> & InvokeFailureRequirement<Effect.Error<NoInfer<Fx>>, InvokeTransition<States, Events, Emits, InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<NoInfer<Fx>>, InputEvents, ParentEvents>>>;
|
|
3071
3270
|
type TimerInvokeArgs<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = {
|
|
3072
3271
|
readonly id: InvokeLifecycleId;
|
|
3073
3272
|
readonly after: InvokeSource<Duration.Input, InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>>;
|
|
@@ -3109,7 +3308,7 @@ export declare namespace Machine {
|
|
|
3109
3308
|
type LogicInitialErrorOf<Value> = Value extends Logic<any, any, any, any, any, infer Error> ? Error : never;
|
|
3110
3309
|
type ContextualInvokeConfig<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema>, ParentEvents extends ReadonlyArray<TaggedSchema>, Raw> = Raw extends InvokeTyped<any, any, any, any, any> ? unknown : Raw extends {
|
|
3111
3310
|
readonly effect: infer Source;
|
|
3112
|
-
} ?
|
|
3311
|
+
} ? InvokeFactoryResult<Source> extends infer Fx extends Effect.Effect<any, any, any> ? InvokeDoneRequirement<Effect.Success<Fx>, InvokeTransition<States, Events, Emits, InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<Fx>, InputEvents, ParentEvents>>> & InvokeFailureRequirement<Effect.Error<Fx>, InvokeTransition<States, Events, Emits, InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<Fx>, InputEvents, ParentEvents>>> & {
|
|
3113
3312
|
readonly onSnapshot?: never;
|
|
3114
3313
|
} : never : Raw extends {
|
|
3115
3314
|
readonly after: unknown;
|
|
@@ -3179,10 +3378,15 @@ export declare namespace Machine {
|
|
|
3179
3378
|
readonly transition: (context: HandlerContext<States, Events, Emits, StateId, EventTag, E, R, InputEvents, ParentEvents>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => HandlerResult<States, any, any>;
|
|
3180
3379
|
};
|
|
3181
3380
|
};
|
|
3182
|
-
readonly
|
|
3381
|
+
readonly initialize?: StateInitializeHandler<States, Events, Emits, StateId, InputEvents, ParentEvents>;
|
|
3183
3382
|
} & ActiveOutputHandlerConfig<States, Events, StateId>;
|
|
3184
|
-
/**
|
|
3185
|
-
|
|
3383
|
+
/**
|
|
3384
|
+
* Values constructed for a state's schema-valued direct initial children.
|
|
3385
|
+
*
|
|
3386
|
+
* @category utility types
|
|
3387
|
+
* @since 0.13.0
|
|
3388
|
+
*/
|
|
3389
|
+
type StateInitializeValue<States extends StateSchemas, StateId extends StateIdentifier<States>> = NodeByIdentifier<States, StateId> extends infer Node ? Node extends {
|
|
3186
3390
|
readonly type: "parallel";
|
|
3187
3391
|
readonly states: infer Children extends StateSchemas;
|
|
3188
3392
|
} ? {
|
|
@@ -3190,11 +3394,53 @@ export declare namespace Machine {
|
|
|
3190
3394
|
} : Node extends {
|
|
3191
3395
|
readonly states: infer Children extends StateSchemas;
|
|
3192
3396
|
readonly initial: infer Initial;
|
|
3193
|
-
} ? Initial extends ActiveStateKey<Children> ? NodeSchema<Children[Initial]> extends never ? never :
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3397
|
+
} ? Initial extends ActiveStateKey<Children> ? NodeSchema<Children[Initial]> extends never ? never : {
|
|
3398
|
+
readonly [Key in Initial]: NodeValue<Children[Initial]>;
|
|
3399
|
+
} : never : never : never;
|
|
3400
|
+
type StateInitializeCompoundBuilder<Node, Initial extends PropertyKey> = Node extends {
|
|
3401
|
+
readonly states: infer Children extends StateSchemas;
|
|
3402
|
+
} ? Initial extends ActiveStateKey<Children> ? NodeSchema<Children[Initial]> extends never ? never : NodeBuilderMethod<Children[Initial], readonly [value: NodeValue<Children[Initial]>], SnapshotBuilderComplete<{
|
|
3403
|
+
readonly [Key in Initial]: NodeValue<Children[Initial]>;
|
|
3404
|
+
}>, readonly [input: NodeMakeInput<Children[Initial]>], SnapshotBuilderComplete<{
|
|
3405
|
+
readonly [Key in Initial]: NodeValue<Children[Initial]>;
|
|
3406
|
+
}, true>> : never : never;
|
|
3407
|
+
type StateInitializeParallelBuilder<Children extends StateSchemas, Remaining extends ActiveStateKey<Children> = {
|
|
3408
|
+
readonly [Key in ActiveStateKey<Children>]: NodeSchema<Children[Key]> extends never ? never : Key;
|
|
3409
|
+
}[ActiveStateKey<Children>], Values = {}, Constructed extends boolean = false> = SnapshotBuilderComplete<Values, Constructed> & {
|
|
3410
|
+
readonly [Key in Remaining]: NodeBuilderMethod<Children[Key], readonly [value: NodeValue<Children[Key]>], StateInitializeParallelBuilder<Children, Exclude<Remaining, Key>, Values & {
|
|
3411
|
+
readonly [Region in Key]: NodeValue<Children[Key]>;
|
|
3412
|
+
}, Constructed>, readonly [input: NodeMakeInput<Children[Key]>], StateInitializeParallelBuilder<Children, Exclude<Remaining, Key>, Values & {
|
|
3413
|
+
readonly [Region in Key]: NodeValue<Children[Key]>;
|
|
3414
|
+
}, true>>;
|
|
3415
|
+
};
|
|
3416
|
+
/**
|
|
3417
|
+
* Builder bound to the direct initial child or regions owned by a state.
|
|
3418
|
+
*
|
|
3419
|
+
* @category utility types
|
|
3420
|
+
* @since 0.13.0
|
|
3421
|
+
*/
|
|
3422
|
+
type StateInitializeBuilder<States extends StateSchemas, StateId extends StateIdentifier<States>, Node = NodeByIdentifier<States, StateId>> = Node extends {
|
|
3423
|
+
readonly type: "parallel";
|
|
3424
|
+
readonly states: infer Children extends StateSchemas;
|
|
3425
|
+
} ? StateInitializeParallelBuilder<Children> : Node extends {
|
|
3426
|
+
readonly initial: infer Initial;
|
|
3427
|
+
} ? StateInitializeCompoundBuilder<Node, Initial & PropertyKey> : never;
|
|
3428
|
+
/**
|
|
3429
|
+
* Context passed to an implicit child-state initializer.
|
|
3430
|
+
*
|
|
3431
|
+
* @category models
|
|
3432
|
+
* @since 0.13.0
|
|
3433
|
+
*/
|
|
3434
|
+
type StateInitializeContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = StateActionContext<States, Events, Emits, StateId, InputEvents, ParentEvents> & {
|
|
3435
|
+
readonly builder: StateInitializeBuilder<States, StateId>;
|
|
3436
|
+
};
|
|
3437
|
+
/**
|
|
3438
|
+
* Initial child value implementation for a compound or parallel state.
|
|
3439
|
+
*
|
|
3440
|
+
* @category models
|
|
3441
|
+
* @since 0.13.0
|
|
3442
|
+
*/
|
|
3443
|
+
type StateInitializeHandler<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema> = Events, ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []> = (context: StateInitializeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>, enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>) => SnapshotBuilderComplete<StateInitializeValue<States, StateId>, boolean>;
|
|
3198
3444
|
/** Context used only when a history node has no previously captured record. */
|
|
3199
3445
|
interface HistoryDefaultContext<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, ParentId extends StateIdentifier<States>> {
|
|
3200
3446
|
readonly event: LifecycleEvent<Events>;
|
|
@@ -3229,7 +3475,7 @@ export declare namespace Machine {
|
|
|
3229
3475
|
readonly on?: never;
|
|
3230
3476
|
readonly onDone?: never;
|
|
3231
3477
|
readonly output?: never;
|
|
3232
|
-
readonly
|
|
3478
|
+
readonly initialize?: never;
|
|
3233
3479
|
}
|
|
3234
3480
|
/**
|
|
3235
3481
|
* Configuration accepted for a final state.
|
|
@@ -3297,7 +3543,7 @@ export declare namespace Machine {
|
|
|
3297
3543
|
type HandlerTree<AllStates extends StateSchemas, States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, E, R, InputEvents extends ReadonlyArray<TaggedSchema>, ParentEvents extends ReadonlyArray<TaggedSchema>, Prefix extends string> = {
|
|
3298
3544
|
readonly [Key in ActiveStateKey<States> | ChoiceStateKey<States>]?: HandlerNode<AllStates, States[Key], Events, Emits, E, R, InputEvents, ParentEvents, HandlerNodeId<AllStates, JoinPath<Prefix, Key>>>;
|
|
3299
3545
|
};
|
|
3300
|
-
type HandlerNodeConfigKey = "always" | "choice" | "entry" | "exit" | "history" | "
|
|
3546
|
+
type HandlerNodeConfigKey = "always" | "choice" | "entry" | "exit" | "history" | "initialize" | "invoke" | "on" | "onDone" | "output" | "states";
|
|
3301
3547
|
type HandlerValidationError<Message extends string, Path extends string, Detail = unknown> = {
|
|
3302
3548
|
readonly "~effect/Machine/HandlerError": readonly [message: Message, path: Path, detail: Detail];
|
|
3303
3549
|
};
|
|
@@ -3338,6 +3584,26 @@ export declare namespace Machine {
|
|
|
3338
3584
|
type TransitionResultTargetPath<Result> = IsAny<Result> extends true ? never : Result extends Effect.Effect<infer Success, any, any> ? TransitionResultTargetPath<Success> : Result extends StateConstruction<infer Constructed> ? TransitionResultTargetPath<Constructed> : Result extends {
|
|
3339
3585
|
readonly path: infer Path extends string;
|
|
3340
3586
|
} ? Path : never;
|
|
3587
|
+
type TransitionResultInitialTargetPath<Result> = IsAny<Result> extends true ? never : Result extends Effect.Effect<infer Success, any, any> ? TransitionResultInitialTargetPath<Success> : Result extends StateConstruction<infer Constructed> ? TransitionResultInitialTargetPath<Constructed> : Result extends {
|
|
3588
|
+
readonly [Topology.InitialTargetTypeId]: typeof Topology.InitialTargetTypeId;
|
|
3589
|
+
readonly _tag: "InitialTarget";
|
|
3590
|
+
} ? Result extends {
|
|
3591
|
+
readonly path: infer Path extends string;
|
|
3592
|
+
} ? Path : never : never;
|
|
3593
|
+
type HandlerConfigInitialTargetPath<Config> = TransitionResultInitialTargetPath<EventHandlerReturn<Config> | AlwaysReturn<Config> | DoneReturn<Config> | ChoiceReturn<Config> | InvokeOutcomeReturn<InvokeReturn<Config>>>;
|
|
3594
|
+
type RequiredInitializersForTargetPath<AllStates extends StateSchemas, Path> = string extends Path ? never : Path extends StateIdentifier<AllStates> ? InitializerClosureForNode<AllStates, NodeByIdentifier<AllStates, Path>, Path> : never;
|
|
3595
|
+
type HandlerInitializeValidationAtPath<Config, Path extends string> = HandlerConfigAtPath<Config, Path> extends infer StateConfig ? [StateConfig] extends [never] ? HandlerValidationAtPath<Path, {
|
|
3596
|
+
readonly initialize: HandlerValidationError<"State requires initialize because a transition enters its declared initial configuration", Path>;
|
|
3597
|
+
}> : "initialize" extends keyof StateConfig ? never : HandlerValidationAtPath<Path, {
|
|
3598
|
+
readonly initialize: HandlerValidationError<"State requires initialize because a transition enters its declared initial configuration", Path>;
|
|
3599
|
+
}> : never;
|
|
3600
|
+
type HandlerInitialTargetValidationForPaths<AllStates extends StateSchemas, Config, Required> = Types.UnionToIntersection<Required extends string ? HandlerInitializeValidationAtPath<Config, Required> : unknown>;
|
|
3601
|
+
type HandlerTreeInitialTargetPath<Config> = string extends keyof Config ? never : Config extends object ? {
|
|
3602
|
+
readonly [Key in keyof Config]: HandlerConfigInitialTargetPath<HandlerConfigPart<Config[Key]>> | (Config[Key] extends {
|
|
3603
|
+
readonly states: infer Children;
|
|
3604
|
+
} ? HandlerTreeInitialTargetPath<Children> : never);
|
|
3605
|
+
}[keyof Config] : never;
|
|
3606
|
+
type HandlerInitialTargetValidation<AllStates extends StateSchemas, Config> = HandlerTreeInitialTargetPath<Config> extends infer TargetPath ? HandlerInitialTargetValidationForPaths<AllStates, Config, RequiredInitializersForTargetPath<AllStates, TargetPath>> : unknown;
|
|
3341
3607
|
type DeclaredTransitionTarget<Transition> = Transition extends {
|
|
3342
3608
|
readonly targets: infer Targets extends ReadonlyArray<string>;
|
|
3343
3609
|
} ? Targets[number] : never;
|
|
@@ -3376,7 +3642,10 @@ export declare namespace Machine {
|
|
|
3376
3642
|
] extends [never] ? unknown : {
|
|
3377
3643
|
readonly output: HandlerValidationError<"Handler config is missing a region output implementation required by parallel output", StateId, Exclude<RequiredParallelOutputStates<AllStates, StateId>, AvailableOutputStates>>;
|
|
3378
3644
|
} : unknown : unknown);
|
|
3379
|
-
type
|
|
3645
|
+
type HandlerRequiredHistoryInitializeValidation<AllStates extends StateSchemas, StateId extends StateIdentifier<AllStates>, Config> = [HistoryIdentifier<AllStates>] extends [never] ? unknown : StateId extends RequiredHistoryInitializers<AllStates> ? "initialize" extends keyof Config ? unknown : {
|
|
3646
|
+
readonly initialize: HandlerValidationError<"State requires initialize for shallow history restoration", StateId>;
|
|
3647
|
+
} : unknown;
|
|
3648
|
+
type HandlerNodeValidation<AllStates extends StateSchemas, Node, Events extends ReadonlyArray<TaggedSchema>, InputEvents extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, StateId extends StateNodeIdentifier<AllStates>, Config, AvailableOutputStates extends StateIdentifier<AllStates>> = StateId extends ChoiceIdentifier<AllStates> ? HandlerChoiceUnknownConfigKeyValidation<StateId, Config> & HandlerChoiceTargetValidation<StateId, Config> & HandlerRuntimeValidation<Events, Emits, StateId, Config> : StateId extends StateIdentifier<AllStates> ? HandlerUnknownConfigKeyValidation<StateId, Config> & HandlerOnKeyValidation<Events, StateId, Config> & HandlerOnTargetValidation<StateId, Config> & HandlerDirectTargetValidation<StateId, Config, "always"> & HandlerDirectTargetValidation<StateId, Config, "onDone"> & HandlerInvokeParentEventsValidation<InputEvents, StateId, Config> & HandlerChildrenValidation<Node, StateId, Config> & HandlerOutputRequirementValidation<AllStates, StateId, AvailableOutputStates, Config> & HandlerRequiredHistoryInitializeValidation<AllStates, StateId, Config> & HandlerRuntimeValidation<Events, Emits, StateId, Config> : unknown;
|
|
3380
3649
|
type HandlerChoiceUnknownConfigKeyValidation<StateId extends string, Config, UnknownKeys extends string = Exclude<Extract<keyof Config, string>, "choice">> = [UnknownKeys] extends [never] ? unknown : {
|
|
3381
3650
|
readonly [Key in UnknownKeys]: HandlerValidationError<"Choice handler config contains an invalid key", StateId, Key>;
|
|
3382
3651
|
};
|
|
@@ -3392,7 +3661,7 @@ export declare namespace Machine {
|
|
|
3392
3661
|
type HandlerNodeValidationAtPath<AllStates extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, InputEvents extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Config, AvailableOutputStates extends StateIdentifier<AllStates>, StateId extends StateNodeIdentifier<AllStates>, NodeConfig = HandlerConfigAtPath<Config, StateId>> = [NodeConfig] extends [never] ? never : HandlerNodeValidation<AllStates, HandlerNodeByPath<AllStates, StateId>, Events, InputEvents, Emits, StateId, NodeConfig, AvailableOutputStates> extends infer Validation ? unknown extends Validation ? never : HandlerValidationAtPath<StateId, Validation> : never;
|
|
3393
3662
|
type HandlerTreeNodeValidations<AllStates extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, InputEvents extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Config, AvailableOutputStates extends StateIdentifier<AllStates>> = Types.UnionToIntersection<StateNodeIdentifier<AllStates> extends infer StateId extends StateNodeIdentifier<AllStates> ? StateId extends StateNodeIdentifier<AllStates> ? HandlerNodeValidationAtPath<AllStates, Events, InputEvents, Emits, Config, AvailableOutputStates, StateId> : never : never>;
|
|
3394
3663
|
type HandlerTreeValidation<AllStates extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, InputEvents extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Config, AvailableOutputStates extends StateIdentifier<AllStates>> = HandlerUnknownStateKeyValidation<AllStates, "", Config> & HandlerTreeNodeValidations<AllStates, Events, InputEvents, Emits, Config, AvailableOutputStates>;
|
|
3395
|
-
type HandlerHasRequiredInitial<AllStates extends StateSchemas, StateId extends StateIdentifier<AllStates>, Config> = StateId extends RequiredHistoryInitializers<AllStates> ? "
|
|
3664
|
+
type HandlerHasRequiredInitial<AllStates extends StateSchemas, StateId extends StateIdentifier<AllStates>, Config> = StateId extends RequiredHistoryInitializers<AllStates> ? "initialize" extends keyof Config ? true : false : true;
|
|
3396
3665
|
type HandlerHasRequiredHistoryDefaults<Node, Config> = Node extends {
|
|
3397
3666
|
readonly states: infer Children extends StateSchemas;
|
|
3398
3667
|
} ? [HistoryStateKey<Children>] extends [never] ? true : Config extends {
|
|
@@ -3408,7 +3677,7 @@ export declare namespace Machine {
|
|
|
3408
3677
|
Exclude<ChoiceStateKey<Children>, Extract<keyof NonNullable<ChildrenConfig>, string>>
|
|
3409
3678
|
] extends [never] ? true : false : false : true;
|
|
3410
3679
|
type HandlerImplementedStateId<AllStates extends StateSchemas, Node, StateId extends StateIdentifier<AllStates>, Config> = [HistoryIdentifier<AllStates> | ChoiceIdentifier<AllStates>] extends [never] ? StateId : HandlerHasRequiredInitial<AllStates, StateId, Config> extends true ? HandlerHasRequiredHistoryDefaults<Node, Config> extends true ? HandlerHasRequiredChoices<Node, Config> extends true ? StateId : never : never : never;
|
|
3411
|
-
type HandlerConfigError<Config> = Effect.Error<EventHandlerReturn<Config>> | Effect.Error<AlwaysReturn<Config>> | Effect.Error<DoneReturn<Config>> | Effect.Error<StateActionReturn<Config, "entry">> | Effect.Error<StateActionReturn<Config, "exit">> | Effect.Error<
|
|
3680
|
+
type HandlerConfigError<Config> = Effect.Error<EventHandlerReturn<Config>> | Effect.Error<AlwaysReturn<Config>> | Effect.Error<DoneReturn<Config>> | Effect.Error<StateActionReturn<Config, "entry">> | Effect.Error<StateActionReturn<Config, "exit">> | Effect.Error<HistoryDefaultReturn<Config>> | Effect.Error<ChoiceReturn<Config>> | InvokeError<Config>;
|
|
3412
3681
|
type HandlerNodeEvidence<AllStates extends StateSchemas, Config, StateId extends StateNodeIdentifier<AllStates>, NodeConfig = HandlerConfigAtPath<Config, StateId>> = [NodeConfig] extends [never] ? never : {
|
|
3413
3682
|
readonly stateId: StateId extends StateIdentifier<AllStates> ? HandlerImplementedStateId<AllStates, HandlerNodeByPath<AllStates, StateId>, StateId, NodeConfig> : never;
|
|
3414
3683
|
readonly error: HandlerConfigError<HandlerConfigPart<NodeConfig>>;
|
|
@@ -3424,7 +3693,7 @@ export declare namespace Machine {
|
|
|
3424
3693
|
* @since 0.4.0
|
|
3425
3694
|
*/
|
|
3426
3695
|
interface Handler<States extends StateSchemas, Events extends ReadonlyArray<TaggedSchema>, Emits extends ReadonlyArray<TaggedSchema>, Input extends Schema.Top, UnhandledStates extends StateIdentifier<States>, E, R, InitialE, InitialR, FinalStates extends StateIdentifier<States>, Output, OutputStates extends StateIdentifier<States>, InputEvents extends ReadonlyArray<TaggedSchema>, ParentEvents extends ReadonlyArray<TaggedSchema>> {
|
|
3427
|
-
<const Config extends HandlerTree<States, States, Events, Emits, E, R, InputEvents, ParentEvents, "">>(config: Config & HandlerInvokeContexts<States, Events, InputEvents, Emits, ParentEvents, NoInfer<Config>> & HandlerTreeValidation<States, Events, InputEvents, Emits, NoInfer<Config>, OutputStates | Extract<HandlerTreeEvidence<States, NoInfer<Config>>["outputState"], StateIdentifier<States>>>): HandleTreeResult<States, Events, Emits, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, OutputStates, InputEvents, ParentEvents, Config>;
|
|
3696
|
+
<const Config extends HandlerTree<States, States, Events, Emits, E, R, InputEvents, ParentEvents, "">>(config: Config & HandlerInvokeContexts<States, Events, InputEvents, Emits, ParentEvents, NoInfer<Config>> & HandlerTreeValidation<States, Events, InputEvents, Emits, NoInfer<Config>, OutputStates | Extract<HandlerTreeEvidence<States, NoInfer<Config>>["outputState"], StateIdentifier<States>>> & ([StateIdentifier<States>] extends [UnhandledStates] ? HandlerInitialTargetValidation<States, NoInfer<Config>> : unknown)): HandleTreeResult<States, Events, Emits, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, OutputStates, InputEvents, ParentEvents, Config>;
|
|
3428
3697
|
}
|
|
3429
3698
|
/**
|
|
3430
3699
|
* Any state config.
|
|
@@ -3759,7 +4028,7 @@ export declare const encodeSnapshot: <const States extends Machine.StateSchemas,
|
|
|
3759
4028
|
* @since 0.4.0
|
|
3760
4029
|
*/
|
|
3761
4030
|
export declare const decodeSnapshot: <const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema> = readonly [], const Input extends Schema.Top = typeof Schema.Void, UnhandledStates extends Machine.StateIdentifier<States> = Machine.StateIdentifier<States>, E = never, R = never, InitialE = never, InitialR = never, FinalStates extends Machine.StateIdentifier<States> = never, Output = never, OutputStates extends Machine.StateIdentifier<States> = never, InputEvents extends ReadonlyArray<Machine.TaggedSchema> = Events, ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []>(machine: Machine<States, Events, Input, UnhandledStates, E, R, InitialE, InitialR, FinalStates, Output, Emits, OutputStates, InputEvents, ParentEvents>, encoded: unknown) => Effect.Effect<Machine.Snapshot<States>, MachineSchemaDecodeError, Machine.SnapshotDecodingServices<States>>;
|
|
3762
|
-
type
|
|
4031
|
+
type EffectInvokeSource<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<unknown, unknown, unknown>> = {
|
|
3763
4032
|
readonly id: InvokeLifecycleId;
|
|
3764
4033
|
readonly effect: Source;
|
|
3765
4034
|
readonly after?: never;
|
|
@@ -3768,11 +4037,11 @@ type DynamicEffectInvokeSource<States extends Machine.StateSchemas, Events exten
|
|
|
3768
4037
|
readonly address?: never;
|
|
3769
4038
|
readonly onSnapshot?: never;
|
|
3770
4039
|
};
|
|
3771
|
-
type
|
|
3772
|
-
type
|
|
3773
|
-
type
|
|
4040
|
+
type EffectDoneHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeTransition<States, Events, Emits, Machine.InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<ReturnType<NoInfer<Source>>>, readonly [], readonly []>>;
|
|
4041
|
+
type EffectFailureHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeTransition<States, Events, Emits, Machine.InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<ReturnType<NoInfer<Source>>>, readonly [], readonly []>>;
|
|
4042
|
+
type EffectInvokeResult<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeConfig<States, Events, Emits, StateId, readonly [], readonly []> & Machine.InvokeTyped<Effect.Success<ReturnType<Source>>, Effect.Error<ReturnType<Source>>, Effect.Services<ReturnType<Source>>, never>;
|
|
3774
4043
|
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false;
|
|
3775
|
-
type
|
|
4044
|
+
type BoundEffectInvokeSource<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, unknown, unknown>> = {
|
|
3776
4045
|
readonly id: InvokeLifecycleId;
|
|
3777
4046
|
readonly effect: Source;
|
|
3778
4047
|
readonly after?: never;
|
|
@@ -3781,9 +4050,9 @@ type BoundDynamicEffectInvokeSource<States extends Machine.StateSchemas, Events
|
|
|
3781
4050
|
readonly address?: never;
|
|
3782
4051
|
readonly onSnapshot?: never;
|
|
3783
4052
|
};
|
|
3784
|
-
type
|
|
3785
|
-
type
|
|
3786
|
-
type
|
|
4053
|
+
type BoundEffectDoneHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeTransition<States, Events, Emits, Machine.InvokeDoneContext<States, Events, Emits, StateId, Effect.Success<ReturnType<NoInfer<Source>>>, InputEvents, ParentEvents>>;
|
|
4054
|
+
type BoundEffectFailureHandler<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeTransition<States, Events, Emits, Machine.InvokeFailureContext<States, Events, Emits, StateId, Effect.Error<ReturnType<NoInfer<Source>>>, InputEvents, ParentEvents>>;
|
|
4055
|
+
type BoundEffectInvokeResult<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, Source extends (...args: ReadonlyArray<never>) => Effect.Effect<unknown, unknown, unknown>> = Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<Effect.Success<ReturnType<Source>>, Effect.Error<ReturnType<Source>>, Effect.Services<ReturnType<Source>>, never>;
|
|
3787
4056
|
/**
|
|
3788
4057
|
* Machine-bound invocation constructor that preserves the owning machine's
|
|
3789
4058
|
* public input and parent protocols in every invocation callback.
|
|
@@ -3792,31 +4061,30 @@ type BoundDynamicEffectInvokeResult<States extends Machine.StateSchemas, Events
|
|
|
3792
4061
|
* @since 0.11.0
|
|
3793
4062
|
*/
|
|
3794
4063
|
export interface Invoker<States extends Machine.StateSchemas, Events extends ReadonlyArray<Machine.TaggedSchema>, Emits extends ReadonlyArray<Machine.TaggedSchema>, InputEvents extends ReadonlyArray<Machine.TaggedSchema>, ParentEvents extends ReadonlyArray<Machine.TaggedSchema>> {
|
|
3795
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, unknown, unknown>>(config:
|
|
3796
|
-
readonly onDone:
|
|
3797
|
-
readonly onFailure:
|
|
4064
|
+
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, unknown, unknown>>(config: BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4065
|
+
readonly onDone: BoundEffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4066
|
+
readonly onFailure: BoundEffectFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
3798
4067
|
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
3799
4068
|
"onDone must be omitted when the Effect output is never"
|
|
3800
4069
|
] : InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
3801
4070
|
"onFailure must be omitted when the Effect error is never"
|
|
3802
|
-
] : []):
|
|
3803
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, never, unknown>>(config:
|
|
3804
|
-
readonly onDone:
|
|
4071
|
+
] : []): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4072
|
+
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<unknown, never, unknown>>(config: BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
4073
|
+
readonly onDone: BoundEffectDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
3805
4074
|
readonly onFailure?: never;
|
|
3806
4075
|
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
3807
4076
|
"onDone must be omitted when the Effect output is never"
|
|
3808
|
-
] : []):
|
|
3809
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<never, unknown, unknown>>(config:
|
|
4077
|
+
] : []): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4078
|
+
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<never, unknown, unknown>>(config: BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
3810
4079
|
readonly onDone?: never;
|
|
3811
|
-
readonly onFailure:
|
|
4080
|
+
readonly onFailure: BoundEffectFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
3812
4081
|
}, ..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
3813
4082
|
"onFailure must be omitted when the Effect error is never"
|
|
3814
|
-
] : []):
|
|
3815
|
-
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<never, never, unknown>>(config:
|
|
4083
|
+
] : []): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
4084
|
+
<StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Effect.Effect<never, never, unknown>>(config: BoundEffectInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source> & {
|
|
3816
4085
|
readonly onDone?: never;
|
|
3817
4086
|
readonly onFailure?: never;
|
|
3818
|
-
}):
|
|
3819
|
-
<StateId extends Machine.StateIdentifier<States>, const Fx extends Effect.Effect<any, any, any>, const Config extends object>(config: Config & Machine.EffectInvokeArgs<States, Events, Emits, StateId, Fx, Fx, InputEvents, ParentEvents>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<Effect.Success<Fx>, Effect.Error<Fx>, Effect.Services<Fx>, never>;
|
|
4087
|
+
}): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>;
|
|
3820
4088
|
<StateId extends Machine.StateIdentifier<States>, const Config extends object>(config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>;
|
|
3821
4089
|
<StateId extends Machine.StateIdentifier<States>, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address extends ChildAddress<never>>(config: Machine.LogicInvokeArgs<States, Events, Emits, StateId, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address, (context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>, InputEvents, ParentEvents>): Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents> & Machine.InvokeTyped<ChildOutput, ChildError, ChildRequirements, ChildInitialError>;
|
|
3822
4090
|
<StateId extends Machine.StateIdentifier<States>, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address extends ChildAddress<never>, const Config extends object>(config: Config & Machine.LogicInvokeArgs<States, Events, Emits, StateId, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address, Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>, InputEvents, ParentEvents>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<ChildOutput, ChildError, ChildRequirements, ChildInitialError>;
|
|
@@ -3831,12 +4099,13 @@ export interface Invoker<States extends Machine.StateSchemas, Events extends Rea
|
|
|
3831
4099
|
* is required only when the source has a typed failure channel.
|
|
3832
4100
|
*
|
|
3833
4101
|
* This constructor is an identity at runtime, but preserves lifecycle callback
|
|
3834
|
-
* inference through published declarations.
|
|
3835
|
-
*
|
|
3836
|
-
*
|
|
3837
|
-
*
|
|
3838
|
-
* lifecycle `id` and a typed communication
|
|
3839
|
-
* own their identity, so `id` and
|
|
4102
|
+
* inference through published declarations. Effect factories run when their
|
|
4103
|
+
* owning state is entered and infer the owner context, output, error, and
|
|
4104
|
+
* service channels together without a return annotation. Durations may be
|
|
4105
|
+
* supplied directly or derived from the owning state's entry context. Logic
|
|
4106
|
+
* invocations require both a lifecycle `id` and a typed communication
|
|
4107
|
+
* `address`. Child descriptors already own their identity, so `id` and
|
|
4108
|
+
* `address` must not be repeated.
|
|
3840
4109
|
*
|
|
3841
4110
|
* Owner references are intentionally non-sendable here because this standalone
|
|
3842
4111
|
* constructor does not know the owning definition. When a callback sends to
|
|
@@ -3847,10 +4116,11 @@ export interface Invoker<States extends Machine.StateSchemas, Events extends Rea
|
|
|
3847
4116
|
* ```ts
|
|
3848
4117
|
* invoke: Machine.invoke({
|
|
3849
4118
|
* id: "load",
|
|
3850
|
-
* effect:
|
|
3851
|
-
*
|
|
3852
|
-
*
|
|
3853
|
-
*
|
|
4119
|
+
* effect: () =>
|
|
4120
|
+
* Effect.tryPromise({
|
|
4121
|
+
* try: () => fetch("/api/data").then((response) => response.json()),
|
|
4122
|
+
* catch: (cause) => new LoadError({ cause })
|
|
4123
|
+
* }),
|
|
3854
4124
|
* onDone: ({ output, target }) => target.full.Ready({ data: output }),
|
|
3855
4125
|
* onFailure: ({ error, target }) => target.full.Failed({ error })
|
|
3856
4126
|
* })
|
|
@@ -3860,31 +4130,30 @@ export interface Invoker<States extends Machine.StateSchemas, Events extends Rea
|
|
|
3860
4130
|
* @since 0.9.0
|
|
3861
4131
|
*/
|
|
3862
4132
|
export declare const invoke: {
|
|
3863
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<unknown, unknown, unknown>>(config:
|
|
3864
|
-
readonly onDone:
|
|
3865
|
-
readonly onFailure:
|
|
4133
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<unknown, unknown, unknown>>(config: EffectInvokeSource<States, Events, Emits, StateId, Source> & {
|
|
4134
|
+
readonly onDone: EffectDoneHandler<States, Events, Emits, StateId, Source>;
|
|
4135
|
+
readonly onFailure: EffectFailureHandler<States, Events, Emits, StateId, Source>;
|
|
3866
4136
|
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
3867
4137
|
"onDone must be omitted when the Effect output is never"
|
|
3868
4138
|
] : InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
3869
4139
|
"onFailure must be omitted when the Effect error is never"
|
|
3870
|
-
] : []):
|
|
3871
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<unknown, never, unknown>>(config:
|
|
3872
|
-
readonly onDone:
|
|
4140
|
+
] : []): EffectInvokeResult<States, Events, Emits, StateId, Source>;
|
|
4141
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<unknown, never, unknown>>(config: EffectInvokeSource<States, Events, Emits, StateId, Source> & {
|
|
4142
|
+
readonly onDone: EffectDoneHandler<States, Events, Emits, StateId, Source>;
|
|
3873
4143
|
readonly onFailure?: never;
|
|
3874
4144
|
}, ..._validation: InvokeChannelIsNever<Effect.Success<ReturnType<Source>>> extends true ? [
|
|
3875
4145
|
"onDone must be omitted when the Effect output is never"
|
|
3876
|
-
] : []):
|
|
3877
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<never, unknown, unknown>>(config:
|
|
4146
|
+
] : []): EffectInvokeResult<States, Events, Emits, StateId, Source>;
|
|
4147
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<never, unknown, unknown>>(config: EffectInvokeSource<States, Events, Emits, StateId, Source> & {
|
|
3878
4148
|
readonly onDone?: never;
|
|
3879
|
-
readonly onFailure:
|
|
4149
|
+
readonly onFailure: EffectFailureHandler<States, Events, Emits, StateId, Source>;
|
|
3880
4150
|
}, ..._validation: InvokeChannelIsNever<Effect.Error<ReturnType<Source>>> extends true ? [
|
|
3881
4151
|
"onFailure must be omitted when the Effect error is never"
|
|
3882
|
-
] : []):
|
|
3883
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<never, never, unknown>>(config:
|
|
4152
|
+
] : []): EffectInvokeResult<States, Events, Emits, StateId, Source>;
|
|
4153
|
+
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Source extends (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Effect.Effect<never, never, unknown>>(config: EffectInvokeSource<States, Events, Emits, StateId, Source> & {
|
|
3884
4154
|
readonly onDone?: never;
|
|
3885
4155
|
readonly onFailure?: never;
|
|
3886
|
-
}):
|
|
3887
|
-
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Fx extends Effect.Effect<any, any, any>, const Config extends object>(config: Config & Machine.EffectInvokeArgs<States, Events, Emits, StateId, Fx, Fx, readonly [], readonly []>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<Effect.Success<Fx>, Effect.Error<Fx>, Effect.Services<Fx>, never>;
|
|
4156
|
+
}): EffectInvokeResult<States, Events, Emits, StateId, Source>;
|
|
3888
4157
|
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, const Config extends object>(config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, readonly [], readonly []>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>;
|
|
3889
4158
|
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address extends ChildAddress<never>>(config: Machine.LogicInvokeArgs<States, Events, Emits, StateId, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address, (context: Machine.InvokeContext<States, Events, Emits, StateId, readonly [], readonly []>) => Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>, readonly [], readonly []>): Machine.InvokeConfig<States, Events, Emits, StateId, readonly [], readonly []> & Machine.InvokeTyped<ChildOutput, ChildError, ChildRequirements, ChildInitialError>;
|
|
3890
4159
|
<const States extends Machine.StateSchemas, const Events extends ReadonlyArray<Machine.TaggedSchema>, const Emits extends ReadonlyArray<Machine.TaggedSchema>, StateId extends Machine.StateIdentifier<States>, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address extends ChildAddress<never>, const Config extends object>(config: Config & Machine.LogicInvokeArgs<States, Events, Emits, StateId, ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError, Address, Logic<ChildState, ChildEvent, ChildError, ChildRequirements, ChildOutput, ChildInitialError>, readonly [], readonly []>): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<ChildOutput, ChildError, ChildRequirements, ChildInitialError>;
|